Skip to content

Instantly share code, notes, and snippets.

@mwunsch
mwunsch / index.js
Last active July 20, 2016 17:53
CFN Custom Resource - GitHub CodeDeploy webhook
const response = require('cfn-response');
const http = require('https');
const url = require('url');
exports.handler = function(event, context) {
var props = event.ResourceProperties;
var options = {
hostname: 'api.github.com',
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `token ${props.GitHubToken}`,
@mwunsch
mwunsch / emoji.plist
Created February 1, 2013 14:22
Apple Plist generated by https://gist.github.com/4687777. Merge this into your OS X Text Substitution preferences (Made simple with osxsub: https://github.com/mwunsch/osxsub)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>on</key>
<integer>1</integer>
<key>replace</key>
<string>:smile:</string>
<key>with</key>
void setup() {
size(1080, 1080);
noStroke();
background(0, 0, 255);
int rows = int(pow(2, int(random(1,6))));
int u = height / (rows + 4);
int thickness = int(pow(2, int(random(1, 4))));
int uth1 = u / thickness;
int uth2 = u + uth1;
int startX = int(-u * 0.75);
@mwunsch
mwunsch / Gemfile
Last active January 13, 2016 05:54
Add the full range of the emoji cheat sheet to your OS X substitution list.
gem 'rumoji', :git => "git://github.com/mwunsch/rumoji.git", :tag => "v0.2.0"
gem 'osxsub', :git => "git://github.com/mwunsch/osxsub.git", :tag => "v0.1.2"
fibRecurse := method(n,
if(n == 0, 0,
if(n == 1, 1,
fibRecurse(n-1) + fibRecurse(n - 2)
)
)
)
fibLoop := method(n,
i := 0 ; a := 0 ; b := 1
require 'sinatra'
get '/' do
erb :index
end
get '/events' do
f = File.new("pipe")
content_type 'text/event-stream'
def fibonacci(n)
Enumerator.new do |yielder|
i = j = 1
loop do
yielder << i
i, j = j, i+j
end
end.take(n)
end
def sieve(n)
integers = 2..n
not_primes = (2..Math.sqrt(n).ceil).reduce([]) do |marked, p|
(p**2).step(n, p) {|j| marked << j }
marked
end
integers.to_a - not_primes
end
@mwunsch
mwunsch / talking_my_language.sh
Last active December 23, 2015 22:59
Automating my Twitter activity. NOW you're talking my language!https://twitter.com/markwunsch/status/382969649509707776
t timeline -l | ruby -e 'puts $stdin.readlines.shuffle.pop' | awk '{ print $1}' | xargs -J % t reply % 'NOW you'"'"'re talking my language! (cf. https://twitter.com/markwunsch/status/382969649509707776)'
@mwunsch
mwunsch / osxsub.rb
Last active December 11, 2015 20:48
require 'formula'
class Osxsub < Formula
homepage 'https://github.com/mwunsch/osxsub'
url 'https://github.com/mwunsch/osxsub/tarball/v0.1.2'
sha1 '93c766bfde5aa27c186018d4450c0c41ddae6ffa'
head 'https://github.com/mwunsch/osxsub.git'
def install
bin.install 'bin/osxsub'