View dumpprof.py
import pstats | |
pstats.Stats('prof').strip_dirs().sort_stats("cumulative").print_stats() |
View drbob.c
float actual = 0.0f; | |
float target = 100.0f; | |
for ( int step=0; step<500; step++ ){ | |
actual += (target - actual)/16 | |
printf("%f\n", actual); | |
} |
View Makefile
src = $(wildcard *.c) | |
obj = $(src:.c=.o) | |
LDFLAGS = -lz | |
psf: $(obj) | |
$(CC) -o $@ $^ $(LDFLAGS) | |
.PHONY: clean | |
clean: |
View omnisharp.json
{ | |
"FormattingOptions": { | |
"NewLine": "\n", | |
"UseTabs": false, | |
"TabSize": 4, | |
"IndentationSize": 4, | |
"SpacingAfterMethodDeclarationName": false, | |
"SpaceWithinMethodDeclarationParenthesis": false, | |
"SpaceBetweenEmptyMethodDeclarationParentheses": false, | |
"SpaceAfterMethodCallName": false, |
View del-old-snapshots.sh
#!/bin/bash | |
# Delete old snapshots except the newest one | |
# Replace product and variant as needed | |
del_product () { | |
read -a FILES <<< `ls -dt $1_BUILD_$2_*` | |
unset FILES[0] # Do not delete newest | |
for dir in ${FILES[*]} | |
do |
View new_gist_file_0
:%!python -m json.tool |
View create_2disk_lvm.sh
# A very comprehensive document: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html-single/Logical_Volume_Manager_Administration/index.html | |
# Assuming both disks have a partition created already. Think they should be already lvm2 pv? | |
sudo pvcreate /dev/sdc1 /dev/sdd1 | |
sudo vgcreate workvg /dev/sdc1 /dev/sdd1 | |
sudo lvcreate -l 100%FREE -n worklv workvg | |
sudo mkfs.ext4 /dev/workvg/worklv | |
sudo echo '/dev/workvg/worklv /work ext4 defaults 0 2' >> /etc/fstab |
View ioctl-errno.c
static unsigned char commit_ioctl() | |
{ | |
int block_dev = -1; | |
int error_code = 0; | |
int retval = 0; | |
unsigned retry_count = 0; | |
errno = 0; /* Clear errno - successfull function calls might leave old value. */ | |
block_dev = open(block_dev_name, O_RDWR); | |
/* Need to save errno as it might be reset by library calls. */ |
View tpf.py
#!/usr/bin/python | |
import sys | |
from prettytable import PrettyTable | |
from collections import defaultdict | |
import pprint | |
# Columns | |
HOME_TEAM = 1 | |
AWAY_TEAM = 4 |
View validate.py
import sys | |
valid_words = ('opsub', 'opequal', 'opadd', 'opmult', 'oprdiv', 'opidiv') | |
def is_valid(str): | |
return all(word in valid_words for word in str.split()) | |
not_validated = sys.argv[1] | |
if is_valid(not_validated): |
NewerOlder