Skip to content

Instantly share code, notes, and snippets.

@RyanScottLewis
RyanScottLewis / install-arch-linux-rpi-zero-w.sh
Created January 10, 2018 09:36 — forked from pklaus/install-arch-linux-rpi-zero-w.sh
Install Arch Linux ARM for Raspberry Pi Zero W on SD Card (with commands to configure WiFi before first boot).
#!/bin/sh -exu
dev=$1
cd $(mktemp -d)
function umountboot {
umount boot || true
umount root || true
}
# RPi1/Zero (armv6h):
module System
extend self
def cpu_count
return Java::Java.lang.Runtime.getRuntime.availableProcessors if defined? Java::Java
return File.read('/proc/cpuinfo').scan(/^processor\s*:/).size if File.exist? '/proc/cpuinfo'
require 'win32ole'
WIN32OLE.connect("winmgmts://").ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors
rescue LoadError
Integer `sysctl -n hw.ncpu 2>/dev/null` rescue 1
end
@RyanScottLewis
RyanScottLewis / setter_pattern.coffee
Created July 21, 2012 10:42 — forked from alexaivars/setter_pattern.coffee
Getter Setter patter for Coffeescript
Function::define = (prop, desc) ->
Object.defineProperty this.prototype, prop, desc
class GetterSetterTest
constructor: (@_obj = {}) ->
# 'obj' is defined via the prototype, the definition proxied through
# to 'Object.defineProperty' via a function called 'define' providing
# some nice syntactic sugar. Remember, the value of '@' is
# GetterSetterTest itself when used in the body of it's class definition.
@RyanScottLewis
RyanScottLewis / gist:383882
Created April 29, 2010 16:58 — forked from burke/gist:383832
RuleBook benchmarks
require 'rubygems'
require 'benchmark'
require 'rulebook'
class Foo
[:admin, :blah].each do |role|
define_method "is_#{role}?" do
true
end