C++ catching all exceptions

try{ // … } catch (…) { // … } will catch all C++ exceptions, but it should be considered bad design. You can use c++11’s new current_exception mechanism, but if you don’t have the ability to use c++11 (legacy code systems requiring a rewrite), then you have no named exception pointer to use to … Read more

How to use netlink socket to communicate with a kernel module?

After reading kernel source I finally managed to make netlink sockets work for me. Below is an example of Netlink socket basics i.e opening a netlink socket, reading and writing to it and closing it. Kernel Module #include <linux/module.h> #include <net/sock.h> #include <linux/netlink.h> #include <linux/skbuff.h> #define NETLINK_USER 31 struct sock *nl_sk = NULL; static void … Read more

How do I map lists of nested objects with Dapper

Alternatively, you can use one query with a lookup: var lookup = new Dictionary<int, Course>(); conn.Query<Course, Location, Course>(@” SELECT c.*, l.* FROM Course c INNER JOIN Location l ON c.LocationId = l.Id “, (c, l) => { Course course; if (!lookup.TryGetValue(c.Id, out course)) lookup.Add(c.Id, course = c); if (course.Locations == null) course.Locations = new List<Location>(); … Read more

MySQL dump by query

not mysqldump, but mysql cli… mysql -e “select * from myTable” -u myuser -pxxxxxxxxx mydatabase you can redirect it out to a file if you want : mysql -e “select * from myTable” -u myuser -pxxxxxxxx mydatabase > mydumpfile.txt Update: Original post asked if he could dump from the database by query. What he asked … Read more

How to split one string into multiple strings separated by at least one space in bash shell?

I like the conversion to an array, to be able to access individual elements: sentence=”this is a story” stringarray=($sentence) now you can access individual elements directly (it starts with 0): echo ${stringarray[0]} or convert back to string in order to loop: for i in “${stringarray[@]}” do : # do whatever on $i done Of course … Read more