Skip to content

Instantly share code, notes, and snippets.

View drj11's full-sized avatar

David Jones drj11

View GitHub Profile
@drj11
drj11 / sizeof.c
Created October 14, 2015 08:23
Print sizes (in bits) of int, long, and pointer types in C
#include <assert.h>
#include <limits.h>
#include <stdio.h>
int main(void) {
size_t i = sizeof(int);
size_t l = sizeof(long);
size_t p = sizeof(void *);
assert(i <= INT_MAX/CHAR_BIT);
@drj11
drj11 / grub.cfg
Created October 29, 2015 10:13
grub 2015-10-29
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
@drj11
drj11 / 2015-12-08-minutes.md
Last active December 8, 2015 16:54
2015-12-08 Sheffield Software Carpentry

Minutes

We will get TUOS to be an Affiliate supporter of Software Carpentry (http://software-carpentry.org/scf/membership.html). @walkingrandomly to act.

We will hold a Data Carpentry course first, then plan 2 more (Software Carpentry) courses.

1st course to be held in March ish. Check Semester / PhD program dates. @annakystalli to find out the PhD program dates.

@drj11
drj11 / gist:5636862
Last active December 17, 2015 16:09
generate username to uid number map
# this avoids picking some old empty unused directories that are owned by root
ls -n | sort -n -k 3 | awk '$3>0{print $NF ":x:" $3}'
@drj11
drj11 / gist:5917057
Last active December 19, 2015 07:09
Example of how to format dates in go.
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now()
fmt.Println(t.Format("2006-01-02 15:04:05 -0700")) // works
@drj11
drj11 / gist:a166dc235259b1a26ca0
Last active December 21, 2015 15:19
Clegg 2015-12-21
[I asked Nick Clegg to support EDM 660 http://www.parliament.uk/edm/2015-16/660]
Clegg's reply:
I have not been in the practice of signing Early Day Motions for
many years now; in fact, I was precluded from doing so whilst I
was in Government. Although Early Day Motions have their place,
I have found from experience that they are not always the most
effective tool to bring about the change that is sought. I
personally think it’s far more effective to contact Ministers
@drj11
drj11 / augment.dot
Last active December 26, 2015 20:09
strict digraph {
l1 [label="[1, 2]" shape=box];
l2 [label="[2]" shape=box];
p -> l1;
op -> l1;
q -> l2;
label = "after p += q";
ordering = out;
}
a = ['hello']
b = a
def f(x):
pass
# anything you like here
f(a)
print(a is b)
@drj11
drj11 / gist:f166cae63e846ba6370d
Created January 28, 2016 11:08
close over unassigned variable
def box(x):
if x:
a = x
def f():
return a
return f
gives1 = box(1)
print(gives1())
explodes = box(0)
# With "unamed expressions"
x = 1 + 2 + 3 + 4
# Without:
x = 1
x += 2
x += 3
x += 4