start new:
tmux
start new with session name:
tmux new -s myname
| # dns server using dnslib and gevent | |
| # based on https://bitbucket.org/paulc/dnslib/src/80d85555aae4/src/server/gevent_server.py | |
| # set the key as | |
| # set IP:name ip_addr | |
| # set TXT:name txtfield | |
| # fallback on gevent's dns resolver | |
| # gleicon 2011 | |
| import gevent |
| #!/usr/bin/env python | |
| """ | |
| A sample Mongo server that handles enough of the commands to connect | |
| with the mongo shell. | |
| Requires: https://github.com/chergert/mongo-async-python-driver | |
| """ | |
| from collections import OrderedDict |
| #!/usr/bin/perl -w | |
| # | |
| # This script was developed by Robin Barker (Robin.Barker@npl.co.uk), | |
| # from Larry Wall's original script eg/rename from the perl source. | |
| # | |
| # This script is free software; you can redistribute it and/or modify it | |
| # under the same terms as Perl itself. | |
| # | |
| # Larry(?)'s RCS header: | |
| # RCSfile: rename,v Revision: 4.1 Date: 92/08/07 17:20:30 |
| # (unset) mask = 0xff - (1 << offset) if (nibble == 'lower') else 0xff - (4 << (4 - offset)); operation = & | |
| # (set) mask = 1 << offset if (nibble == 'lower') else 4 << (4 - offset); operation = | | |
| # | |
| # (read) result = (current_values & 0x0F) if (nibble == 'lower') else (current_values & 0xF0) >> 4 | |
| # (write) mask = (offset - 1) & 0xf0 if (nibble == 'lower') else 4 << (offset - 1) & 0x0f; operation = | | |
| def getNibbles(int_type): | |
| """ getNibbles() returns the byte nibbles for a given integer (upper, lower) """ | |
| return((int_type & 0xF0) >> 4, (int_type & 0x0F)) |
| /* | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| */ | |
| #include <arpa/inet.h> | |
| #include <linux/if_packet.h> | |
| #include <stdio.h> |
| /* | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| */ | |
| #include <arpa/inet.h> | |
| #include <linux/if_packet.h> | |
| #include <linux/ip.h> |
| // derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm | |
| function map() { | |
| emit(1, // Or put a GROUP BY key here | |
| {sum: this.value, // the field you want stats for | |
| min: this.value, | |
| max: this.value, | |
| count:1, | |
| diff: 0, // M2,n: sum((val-mean)^2) | |
| }); |
| #include <stdio.h> | |
| #include <sys/socket.h> | |
| #include <linux/netlink.h> | |
| #include <linux/connector.h> | |
| #include <linux/cn_proc.h> | |
| #include <stdlib.h> | |
| #include <errno.h> | |
| struct __attribute__ ((aligned(NLMSG_ALIGNTO))) nlcn_msg { | |
| struct nlmsghdr nl_hdr; |
I want to write about why GDB is a great tool for learning C. At least part of the difficulty in learning C is that the language isn’t as interactive as using Python or Ruby.
TL;DR You can kinda use gdb as a repl for c
What’s the smallest possible program we could debug to learn about pointers?