Skip to content

Instantly share code, notes, and snippets.

View rudle's full-sized avatar
🖱️
extremely online

human person rudle

🖱️
extremely online
  • San Francisco
View GitHub Profile
require 'rubygems'
require 'nokogiri'
require 'httparty'
doc = Nokogiri(HTTParty.get('http://www.gutenberg.org/wiki/Harvard_Classics_(Bookshelf)'))
ids = doc.css('a').select{|a| a.attr('title') =~ /ebook:/ }.map do |a|
a.attr('title') =~ /ebook:(\d+)/
{:title => a.text, :id => $1 }
end.compact.uniq
module Kernel
alias_method :_exit, :exit
def exit(*args, &blk)
puts "EXIT CALLED BY #{caller.inspect} #{args.inspect}"
_exit(*args, &blk)
end
end
@rudle
rudle / gist:5234198
Created March 25, 2013 00:19
Date.strftime, Date.strptime don't commute
Date.today.strftime('%-m%-d%y') # 3242013
Date.strptime('3242013','%-m%-d%y') # ArgumentError: invalid date
@rudle
rudle / add-align.patch
Created September 9, 2013 03:34
maximum-awesome patches
diff --git a/vimrc.bundles b/vimrc.bundles
index 9e9a983..829977c 100644
--- a/vimrc.bundles
+++ b/vimrc.bundles
@@ -32,6 +32,7 @@ Bundle 'tpope/vim-unimpaired'
Bundle 'tpope/vim-vividchalk'
Bundle 'uarun/vim-protobuf'
Bundle 'vim-ruby/vim-ruby'
+Bundle 'vim-scripts/align.vim'
Bundle 'vim-scripts/greplace.vim'
@rudle
rudle / read.c
Last active August 29, 2015 14:00
#include <string.h>
#include <stdio.h>
#include <zmq.h>
#include <assert.h>
int main (int argc, char ** archv) {
void * context = zmq_init(1);
void *socket = zmq_socket (context, ZMQ_SUB);
assert (socket);
@rudle
rudle / git-fixup
Created February 17, 2015 02:44
git-fixup
#! /usr/bin/env ruby
staged_files = Array(`git diff --name-only --cached`.split("\n"))
puts "staged files are: #{staged_files}"
staged_files.each do |file|
sha_to_fixup = `git log -n1 --format=%h #{file}`.gsub(/\s*/, '')
# assert sha has not been merged
fail "no commit to fixup in this topic branch" if `git branch --contains #{sha_to_fixup}`.split("\n").any? { |branch| branch =~ /\s*master\s*/ }
puts sha_to_fixup
`git commit --fixup #{sha_to_fixup}`
var ChordSpeller = {
chord: {}, // this represents the cord the user is holding down. map[string] -> int
chordView: null, // cached chord view
self: this,
init: function() {
console.log("requesting MIDI access");
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess({
sysex: false
}).then(ChordSpeller.onMIDISuccess, ChordSpeller.onMIDIFailure);
class ChordSpeller {
constructor(chordView) {
if (this.chordView === null) {
alert("no chordview accessible");
}
this.chord = {};
this.scope = this;
}
(defun dotspacemacs/user-config ()
(setq org-capture-templates (quote (("tw" "to do [WORK]" entry (file+headline "~/Dropbox/org/work.org" "Work Todo")
"* TODO %^{Brief description} %^G
%?
SCHEDULED: %t
%a
"))))
)
package main
import "k8s.io/kubernetes/pkg/labels"
func main() {
_, err := labels.Parse(labels.Nothing().String())
if err != nil {
panic("test failure")
}
}