Skip to content

Instantly share code, notes, and snippets.

View AlainODea's full-sized avatar

Alain O'Dea AlainODea

View GitHub Profile
@AlainODea
AlainODea / FipsCode.scala
Created September 3, 2011 04:10
Quick and dirty FIPS code lookup by state and county using Scala
import java.net.URI
import io.Source
object FipsCode {
def forStateAndCounty(state: String, county: String): Option[String] =
fipsCodeLookup.get((state, county))
lazy val fipsCodeLookup = {
val url = ((URI create "http://www.census.gov/geo/www/ansi/national.txt") toURL)
((for (line <- Source.fromInputStream(url.openStream()).getLines();
@AlainODea
AlainODea / restore_git_branches.sh
Created September 12, 2012 02:26
Restore Git branches after backup restore of Git Server
#!/usr/bin/env bash
function checkout_and_push {
git checkout $1 && git push origin $1
}
git branch -r | cut -c 10- | grep -ve '^HEAD' | while read i; do checkout_and_push $i; done
@AlainODea
AlainODea / usbkey config
Created January 23, 2013 03:19
Configuring an external vnic for SmartOS guests
external_nic=0:c:29:18:ec:10
external0_ip=dhcp
external0_netmask=...
external0_gateway=...
@AlainODea
AlainODea / hadoop.json
Created March 28, 2013 19:16
Hadoop JSON payload that fails with "timed out waiting for /var/svc/provisioning to move <UUID>" on vmadm create.
{
"alias": "hadoop",
"max_physical_memory": 16192,
"quota": 1024,
"dataset_uuid": "6344c3f4-64d9-11e2-af3d-af797e5b19ca",
"nics": [
{
"nic_tag": "external",
"vlan_id": 6,
"ip": "10.100.0.87",
@AlainODea
AlainODea / remove_old_kernels.sh
Last active December 15, 2015 14:29
Remove previous Ubuntu Kernel images, headers, etc. to prevent /boot from filling up.
dpkg --get-selections | grep linux-image- | grep generic | cut -f 1 | head -n-1 | tr '\n' ' ' | xargs apt-get --assume-yes purge
@AlainODea
AlainODea / .bashrc
Last active December 16, 2015 00:49
Setup script for Joyent CloudAPI on a SmartMachine
if [ ! "$SSH_AUTH_SOCK" ]; then
eval $(ssh-agent)
ssh-add "$SDC_CLI_IDENTITY"
fi
@AlainODea
AlainODea / zotonic.xml
Last active December 17, 2015 16:49
Install Zotonic on SmartMachine
pkgin up
pkgin in -y erlang postgresql92-server ImageMagick build-essential scmgit unzip
curl -L https://github.com/downloads/basho/rebar/rebar > /opt/local/bin/rebar
chmod +x /opt/local/bin/rebar
groupadd zotonic
useradd -m -s /usr/bin/bash -G zotonic zotonic
vim /var/pgsql/data/pg_hba.conf
# add lines above any uncommented rules (trim leading hash on each line)
## Postgres off the ground settings
#local all postgres ident
@AlainODea
AlainODea / joyent-smartmachine.erb
Last active December 19, 2015 23:29
Joyent SmartMachine bootstrap with environment and proxy support.
bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
if [ ! -f /opt/local/bin/chef-client ]; then
pkgin -f -y update
pkgin -f -y upgrade
pkgin -y install build-essential $(pkgin se rubygems | grep rubygems | cut -d" " -f1 | head -n1) pkg-config
gem install ohai --no-ri --no-rdoc
gem install chef --no-ri --no-rdoc <%= bootstrap_version_string %>
@AlainODea
AlainODea / install-isc-smf.sh
Last active December 21, 2015 14:39
An SMF manifest for ISC DHCP on SmartOS
#!/bin/bash
curl https://gist.githubusercontent.com/AlainODea/6321603/raw/760ebf43a2f48a78d99b8ca6dbc98a4b84684647/isc-dhcpd-smf.xml > /opt/local/lib/svc/manifest/isc-dhcpd-smf.xml
svccfg import /opt/local/lib/svc/manifest/isc-dhcpd-smf.xml
echo Run 'svcadm enable svc:/pkgsrc/isc-dhcpd:default' to enable ISC DHCP Daemon after configuration
@AlainODea
AlainODea / smartos.ipxe
Created August 29, 2013 03:53
iPXE Menu Boot Configuration including SmartOS and DBAN
!ipxe
set smartos-build 20130822T211238Z
set boot-url http://example.com/boot-isos
######## MAIN MENU ###################
:start
menu Welcome to iPXE's Boot Menu
item
item --gap -- ------------------------- Operating systems ------------------------------
item smartos Boot SmartOS (${smartos-build})