Skip to content

Instantly share code, notes, and snippets.

View alyssais's full-sized avatar
🤒
Out sick

Alyssa Ross alyssais

🤒
Out sick
View GitHub Profile
import Darwin
let isLittleEndian = Int(OSHostByteOrder()) == OSLittleEndian
let htons = isLittleEndian ? _OSSwapInt16 : { $0 }
let htonl = isLittleEndian ? _OSSwapInt32 : { $0 }
let htonll = isLittleEndian ? _OSSwapInt64 : { $0 }
let ntohs = isLittleEndian ? _OSSwapInt16 : { $0 }
let ntohl = isLittleEndian ? _OSSwapInt32 : { $0 }
let ntohll = isLittleEndian ? _OSSwapInt64 : { $0 }
import Foundation
typealias Forest = Tree[]
protocol Tree {
func parent() -> Tree?
func nodes() -> Forest
}
func nodes(tree: Tree) -> Forest {
@alyssais
alyssais / mp.json
Last active August 29, 2015 14:03
Contact details for UK MPs, extracted from http://parliament.uk
[
{
"constituency": "Hackney North and Stoke Newington",
"email": "[email protected]",
"id": 172,
"name": "Ms Diane Abbott MP",
"party": "Labour",
"tel": "020 7219 4426",
"twitter": "@hackneyabbott",
"website": "http://www.dianeabbott.org.uk"

Keybase proof

I hereby claim:

  • I am penman on github.
  • I am penman (https://keybase.io/penman) on keybase.
  • I have a public key whose fingerprint is 9B36 DC74 20E5 0DC0 278D C839 05CC 00A7 63F8 2E0B

To claim this, I am signing this object:

@alyssais
alyssais / httppp.rb
Created October 8, 2014 21:18
HTTP Plays Pokémon!
require 'java'
require 'sinatra'
def keycode(key)
name = "VK_#{key.upcase}"
java.awt.event.KeyEvent.const_get(name)
end
robot = java.awt.Robot.new
export ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
COMPLETION_WAITING_DOTS="true"
HIST_STAMPS="yyyy-mm-dd"
plugins=(git)
export PATH=$HOME/.rbenv/bin:$HOME/.pyenv/bin:$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin
export LANG=en_GB.UTF-8
export TERM="xterm-256color"
source $ZSH/oh-my-zsh.sh
eval "$(rbenv init -)"
@alyssais
alyssais / authentication_spec.rb
Last active August 29, 2015 14:13
Testing controller concerns in Rails
# This is an example spec that uses the ControllerConcernHelper module
require "rails_helper"
describe Authentication, type: :controller_concern do
controller do
include AbstractController::Callbacks
before_action :authenticate
def test_action

Keybase proof

I hereby claim:

  • I am penman on github.
  • I am penman (https://keybase.io/penman) on keybase.
  • I have a public key whose fingerprint is 4E88 5A31 6BE3 361F E95E C23A 716C 6648 9EA7 86B5

To claim this, I am signing this object:

@alyssais
alyssais / require_external_gem.rb
Last active August 29, 2015 14:27
A very hacky way to require gems from outside a bundler environment
require 'shellwords'
def require_external_gem(name)
return require name unless defined? Bundler
dir = Bundler.with_clean_env do
`echo #{name.shellescape} | ruby -e \
'puts Gem::Specification.find_by_name(STDIN.read.chomp).gem_dir'`.chomp
end
@alyssais
alyssais / rspec
Created August 16, 2015 12:50
Fix pry terminal corruption issues with rspec. The same file is executed by both Ruby and Bash. Isn't that cool‽
#!/bin/sh
<<SH_COMMENT
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')