Skip to content

Instantly share code, notes, and snippets.

@sturadnidge
sturadnidge / node-armv7l-builder.sh
Created October 7, 2013 22:51
Builds node on ARM chromebook. Slower than cross compiling, but what the hey!
git clone -b v0.10.20-release https://github.com/joyent/node.git
cd node
./configure --prefix=/ --without-snapshot
export BIN_NAME=node-v0.10.20-linux-armv7l-chromebook
mkdir ${BIN_NAME}
make install DESTDIR=${BIN_NAME} V=1 PORTABLE=1
@sturadnidge
sturadnidge / python-2.7-on-CentOS-6.x.txt
Last active December 23, 2015 02:29
python-2.7 on CentOS 6.x
# prereqs
yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel
# python
curl -O http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar -C /usr/src -xzvf Python-2.7.5.tgz
cd /usr/src/Python-2.7.5/
./configure --prefix=/usr/local
@sturadnidge
sturadnidge / cdh4-pseudo-distributed-everything
Last active December 20, 2015 22:39
CDH4 MRv1 install in pseudo-distributed mode, plus optional ZooKeeper, HBase, HttpFS. Assumes you have a Sun JDK installed and JAVA_HOME set for root if installed somewhere other than /usr/java/. This is all basically a summary of various parts of https://ccp.cloudera.com/display/CDH4DOC/CDH4+Documentation
# Add Cloudera RPM-GPG-KEY and repo
rpm --import http://archive.cloudera.com/cdh4/redhat/6/x86_64/cdh/RPM-GPG-KEY-cloudera
rpm -ivh http://archive.cloudera.com/cdh4/one-click-install/redhat/6/x86_64/cloudera-cdh-4-0.x86_64.rpm
# note: if you want to install a specific version,
# modify /etc/yum.repos.d/cloudera-cdh4.repo accordingly.
# For example, if you want to install 4.2.1, use the following baseurl:
# baseurl=http://archive.cloudera.com/cdh4/redhat/6/x86_64/cdh/4.2.1/
# Install CDH4 Base
@sturadnidge
sturadnidge / debian.ipxe
Created June 22, 2013 14:43
ipxe boot script - despite several of these parameters being in the preseed.cfg file, they don't work unless you pass them in as kernel params. Not sure if that is a documentation bug or an actual bug.
#!ipxe
echo
echo attempting to netboot with IP ${ip}
echo
set buildserver your.build.server.fqdn
set pxebase http://${buildserver}/path/to/bootfiles/dir
kernel ${pxebase}/linux preseed/url=http://${buildserver}/${uuid}/preseed.cfg debian-installer/locale=en_US.UTF-
8 keymap=us netcfg/get_hostname=${uuid} netcfg/get_domain=${domain} --
initrd ${pxebase}/initrd.gz
boot ||
@sturadnidge
sturadnidge / wheezy.preseed
Created June 22, 2013 14:40
Debian 7.x preseed file for a simple, minimal install.
#### Contents of the preconfiguration file (for wheezy)
### Localization
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/keymap select us
d-i keymap select us
### Network configuration
d-i netcfg/choose_interface select auto
### Mirror settings
@sturadnidge
sturadnidge / 75-persistent-net-generator.rules
Created June 2, 2013 22:53
Debian Wheezy 75-persistent-net-generator.rules - for some reason it was missing from the last Raspbian build I did.
# These rules generate rules to keep network interface names unchanged
# across reboots and write them to /etc/udev/rules.d/70-persistent-net.rules.
# variables used to communicate:
# MATCHADDR MAC address used for the match
# MATCHID bus_id used for the match
# MATCHDRV driver name used for the match
# MATCHIFTYPE interface type match
# COMMENT comment to add to the generated rule
# INTERFACE_NAME requested name supplied by external tool
@sturadnidge
sturadnidge / pirewall.sh
Last active November 27, 2018 08:59
Script to setup a basic ruleset for iptables, used on my raspberrypi firewall.
#!/bin/sh
# * eth0 = Internet interface (DHCP)
# * eth1 = LAN interface (192.168.1.0/24)
# * eth2 = DMZ interface (172.16.0.0/16)
# * Traffic open from firewall to internet
# * Traffic open and translated from LAN and DMZ to internet
# * Traffic open from LAN to Firewall
# * Traffic open from LAN to DMZ
# * Traffic open from internet to a DMZ web server
@sturadnidge
sturadnidge / minipi.sh
Last active June 13, 2016 13:21
Minimal Raspbian image builder.
#!/bin/bash
# required build environment packages: binfmt-support qemu qemu-user-static debootstrap kpartx lvm2 dosfstools
# made possible by:
# Klaus M Pfeiffer (http://blog.kmp.or.at/2012/05/build-your-own-raspberry-pi-image/)
# Alex Bradbury (http://asbradbury.org/projects/spindle/)
deb_mirror="http://archive.raspbian.org/raspbian/"
deb_local_mirror=$deb_mirror
deb_release="wheezy"
@sturadnidge
sturadnidge / gist:5541742
Created May 8, 2013 16:40
MongoDB shell tricks: add a 'created' field to documents long after the fact
db.test.find({}).forEach( function(obj) {
var _idTimestamp = obj._id.getTimestamp();
obj.created = _idTimestamp.getTime();
db.test.save(obj)
});
@sturadnidge
sturadnidge / gist:5403580
Created April 17, 2013 11:36
M101P week 2 solution in node.js
'use strict';
/*
* Homework assignment 2.2 for M101P, using node.js
*
* Notes: this only works because the student id
* increments by 1, and also because each student
* has more than 1 homework score. If either of
* those conditions weren't true, this code would
* be totally wrong (and dangerous!).
*