Skip to content

Instantly share code, notes, and snippets.

View skl's full-sized avatar

Stephen Lang skl

View GitHub Profile
@skl
skl / gist:2301078
Created April 4, 2012 13:35
AssertionTuple with DataSetValue stack
<?php
class DataSetValue
{
const ALPHA_LOWER = 'abcdefghijklmnopqrstuvwxyz';
const ALPHA_NUMERIC = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
/* more constants */
public function __construct($data = self::ALPHA_NUMERIC, $dataLength = 62)
{
@skl
skl / rpi-model-b-setup.md
Created December 16, 2012 00:26
Expanding the root parition of the SD card in Arch Linux

Raspberry Pi Model B

Expanding the root parition of the SD card

Whilst booted into Arch on the pi:

fdisk /dev/mmcblk0

Delete the second partition /dev/mmcblk0p2:

@skl
skl / etc-network-interfaces
Last active December 11, 2015 22:19
iptables auto save and restore
# /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
pre-up iptables-restore < /etc/iptables.conf
post-down iptables-save > /etc/iptables.conf
@skl
skl / xen lvm snap
Created January 31, 2013 01:49
Basic LVM snapshot to file for Xen domU.
#!/bin/bash
[ $# -ne 2 ] && { echo "Usage: ./snap <lvm group> <domU>"; exit 1; }
##
# Export an LVM device to file
#
# @param string $1 LVM_GROUP The logical volume manager group (e.g. vg0)
# @param string $2 DOMU The guest domain to snap (e.g. w01)
#
@skl
skl / rules.v4
Last active December 16, 2015 19:19
iptables base firewall
# usgae: iptables-restore < firewall.rules
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [606:306949]
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
@skl
skl / jenkins.md
Created August 13, 2013 14:28
Jenkins installation

Creating a new Jenkins Server

First step, make sure java -version reports 1.6 or higher. If the command fails or the version isn't high enough, download the latest version of Java JDK from Oracle (http://www.oracle.com/technetwork/java/javase/downloads/index.html) (jdk-7u25-linux-x64.tar.gz at the time of writing) - a quick uname -m will let you know if you need the 32 or 64bit version. Installation instructions are available here (http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html#install-64).

My preference is to extract these to /usr/local and then ln -s /usr/local/jdk1.7.0_25 /usr/local/jdk.

Add /usr/local/jdk/bin to your $PATH.

Download the latest Jenkins WAR (1.519 currently) file from http://mirrors.jenkins-ci.org/war/latest/.

@skl
skl / Git to Stash Mirror
Created February 24, 2014 16:24
Mirror public git repositories to an Atlassian Stash instance
#!/bin/bash
set -e
function stash_create_repo()
{
local username="$1"
local password="$2"
local hostname="$3"
local port="$4"
local project="$5"
@skl
skl / Module.php
Created September 16, 2015 16:13
ZF2 ModuleEvent listener that prioritises `ViewJsonStrategy` over `ZfcTwigViewStrategy` in order to properly render a JsonModel.
<?php
namespace Application;
use Zend\ModuleManager\ModuleEvent;
use Zend\ModuleManager\ModuleManager;
/**
* Class Module
* @package Application
@skl
skl / gist:10a32cf602ff9aee4043f0f4f4c66e66
Created September 10, 2016 16:11
ATmega 328P Internal Temperature Sensor on ADC8
; Initialise A/D multiplex register for internal temp. sensor (ADC8)
; Use internal (1.1V) as reference voltage and left-adjust
ADC_TempSensor_Init:
ldi r17, (1<<REFS1) | (1<<REFS0) | (1<<MUX3) | (1<<ADLAR)
sts ADMUX, r17 ; out of range for OUT, using STS instead
ret
; Reads ADCL into r21 and ADCH into r22
ADC_TempSensor_Read:
; Enable ADC with a clock division factor of 128 (125 kHz)
@skl
skl / hostapd
Last active May 12, 2017 13:51
Reliable hostapd init script - example with brcmfmac driver in GB region - See http://skl.me/#wifi-access-point-in-debian
#!/bin/sh
### BEGIN INIT INFO
# Provides: hostapd
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start: $network
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6