Skip to content

Instantly share code, notes, and snippets.

@joshenders
joshenders / hdparm
Created December 21, 2014 02:13
/etc/default/hdparm
# To set the same options for a block of harddisks, do so with something
# like the following example options:
# harddisks="/dev/hda /dev/hdb"
# hdparm_opts="-d1 -X66"
# This is run before the configuration in hdparm.conf. Do not use
# this arrangement if you need modules loaded for your hard disks,
# or need udev to create the nodes, or have some other local quirk
# These are better addressed with the options in /etc/hdparm.conf
#
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
/*
setxattrs - bubbaATbubba.org
Properly sets sparse bundle extended attributes lost when rsyncing
sparse bundle data to a platform that does not support extended
attributes. This is only need when restoring/retrieving the
bundle.
To use, sync/copy all bundle files, then run this tool on the
sparse bundle:
def params_to_dict(param_str):
splits = param_str.split(" ")
data = {}
prev_key = None
prev_val = None
for s in splits:
if "=" in s:
key, val = s.split("=")
if prev_key:
@joshenders
joshenders / sshrc
Created March 13, 2015 12:47
/etc/ssh/sshrc to fix X11 Forwarding on Debian
if read proto cookie && [ -n "$DISPLAY" ]; then
if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
# X11UseLocalhost=yes
echo add unix:`echo $DISPLAY |
cut -c11-` $proto $cookie
else
# X11UseLocalhost=no
echo add $DISPLAY $proto $cookie
fi | xauth -q -
fi
>>> a = "1.0"
>>> int(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.0'
>>> int(float(a))
1
>>> foo = "1.0"
>>> int(foo)
Traceback (most recent call last):
#!/bin/bash
# for each list of nodes in ISP metadata list
for country in metadata/by-isp/*; do
ccode="$(basename ${country})"
echo "${ccode}"
mkdir "by-isp/${ccode}"
# from node list for each country, create file with only tests from said country
pattern=$(awk '{ print $2 }' "${country}" \
[root@dev-aje:~]# apt-cache --help | grep -- depends
depends - Show raw dependency information for a package
rdepends - Show reverse dependency information for a package
[root@dev-aje:~]# apt-cache depends libpng12-0
libpng12-0
Depends: libc6
Depends: zlib1g
PreDepends: multiarch-support
Conflicts: libpng12-dev
Conflicts: <mzscheme>
@joshenders
joshenders / stats-by-country.py
Created March 30, 2015 06:58
stats-by-country.py
#!/usr/bin/python3.4
import math
import statistics as stats
import signal
import sys
from os.path import basename
# Hide stack trace from KeyboardInterrupt
jenders@jenders-mba tmp :) $ cat ./foo.sh
#!/bin/bash
echo "\$@: $@"
flags=()
for flag in "$@"; do
if [[ "${flag}" =~ ^- ]]; then
flags=("${flags[@]}" "${flag}")
fi