- GitHub Staff
- http://zerowidth.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" copy the entire buffer or selected text as RTF | |
" inspired by https://github.com/dharanasoft/rtf-highlight | |
" but only uses commands available by default on OS X. | |
" | |
" To set html conversion options, :help TOhtml | |
" And, undocumented, to set the font used, | |
" let g:html_font="Your Preferred Font" | |
" | |
function! CopyRTF(line1,line2) | |
if !executable('textutil') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# as suggested by @mcmire, https://twitter.com/mcmire/status/96632723220869120 | |
# and clarified in https://twitter.com/mcmire/status/96647536521129985 | |
class Array | |
def thoroughly_all?(&block) | |
all_true = true | |
each {|obj| all_true &= yield(obj) } | |
all_true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple guardfile for vital testing workshop. | |
# | |
# $ gem install guard guard-rspec growl_notify | |
# | |
# put your code in lib/thing.rb | |
# and the specs in spec/thing_spec.rb | |
# | |
# then | |
# | |
# $ guard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem::Specification.new do |s| | |
s.name = "ar_pg_defaults" | |
s.version = "0.0.1" | |
s.platform = Gem::Platform::RUBY | |
s.author = "Nathan Witmer" | |
s.email = "[email protected]" | |
s.homepage = "https://gist.github.com/1262051" | |
s.summary = "Help AR let postgres do its thing" | |
s.description = "Let postgres insert default values for columns with default values that AR 3.1 doesn't understand" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# inspired by https://gist.github.com/1564252 | |
RED=$(tput setaf 1) | |
GREEN=$(tput setaf 2) | |
BLUE=$(tput setaf 4) | |
CYAN=$(tput setaf 6) | |
RESET=$(tput sgr 0) | |
function header() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# npm install socket.io-client canvas | |
io = require "socket.io-client" | |
util = require "util" | |
fs = require "fs" | |
Canvas = require "canvas" | |
EventEmitter = require("events").EventEmitter | |
class Pixels extends EventEmitter | |
constructor: -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# giftube – Generates an animated gif from a YouTube url. | |
# | |
# Usage: | |
# | |
# giftube [youtube url] [minute:second] [duration] | |
# | |
# ex. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Proc.module_eval { def method_missing(m,*a); call(m.to_s,*a); end } | |
Array.module_eval { def rest; self[1..-1]; end } | |
Object.module_eval { def let; yield self; end } | |
Music = Module.new do | |
def self.load(filename) | |
depth = ->(l) { %r(^([\s-]*)\w).match(l)[1].length } | |
ldepth = ->(l) { %r(^(\s*)\S).match(l)[1].length } | |
nonzero = ->(n) { n > 0 } | |
empty = ->(c) { c.empty? } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn depth-of [line] | |
(count ((re-find #"^([\s-]*)" line) 1))) | |
(defn list-depth [line] | |
(count ((re-find #"^(\s*)" line) 1))) | |
(declare parse-list) | |
(defn parse-hash [lines] | |
(when-let [line (first lines)] | |
(let [depth (depth-of line) | |
children (take-while #(> (depth-of %) depth) (rest lines)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# only way to get the child process to re-bind is to set SO_REUSEPORT on both | |
# the parent socket and the child socket before binding. | |
require "socket" | |
puts "in parent" | |
server = TCPServer.new("127.0.0.1", 4000) | |
server.setsockopt(:SOCKET, :REUSEPORT, true) | |
puts server.inspect |