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 | |
require "readline" | |
require "fileutils" | |
class CompileObjectiveC | |
attr_accessor :code_lines | |
TMP_DIR = "/tmp" |
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
1. Until very recently there was a bug where if href has '#' in it, when you scroll through dropdown it will be automatically closed. (https://github.com/ivaynberg/select2/issues/425) | |
2. For selects dynamically created selects (for js templates), the positioning is all screwed up on scroll.https://github.com/ivaynberg/select2/issues/149#issuecomment-7542630 | |
3. Forgetting some which we worked around. :( | |
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
desc "Remove branches that are merged to master" | |
task :grm do | |
branch_string = `git branch --merged master` | |
branches = branch_string.strip.split("\n") | |
branches.each do |branch_name| | |
branch_name.strip! | |
unless branch_name =~ /master/ | |
print "Deleting branch #{branch_name} y/n: " | |
char = STDIN.gets() | |
if char.is_a?(Fixnum) |
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
run <<-CMD.compact | |
cd -- #{deploy_to.shellescape}/ && | |
LC_COLLATE=C sort REQUIRED_ASSETS -o REQUIRED_ASSETS && | |
cd -- #{shared_path.shellescape}/assets/ && | |
for f in $( | |
find * -mmin +#{expire_after_mins.to_s.shellescape} -type f | LC_COLLATE=C sort | | |
LC_COLLATE=C comm -23 -- - #{deploy_to.shellescape}/REQUIRED_ASSETS | |
); do | |
echo "Removing unneeded asset: $f"; | |
rm -f -- "$f"; |
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
module Foo | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def metaclass; class << self; self; end; end | |
def hello(name = nil) | |
if name |
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
var canvas = document.getElementById('canvas'); | |
var ctx = canvas.getContext('2d'); | |
var width = canvas.width; | |
var height = canvas.height; | |
var i = 0; | |
// inset box shadow alpha values | |
var shades = [140, 163, 184, 201, 217, 229, 240, 247, 252]; | |
// draw inset box shadow |
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 | |
# | |
# Copyright 2013 John Leach <[email protected]> | |
# | |
# Distributed under terms of the MIT license | |
# | |
# Takes a screeshot using scrot and uploads it via scp and sticks the | |
# url on the clipboard as quickly as possible. | |
# | |
# For speed, it cheats and puts the url on the clipboard *before* |
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
class Invite | |
add_state :accepted, :after => :accept_job | |
add_event(:accept) do | |
transitions :to => :accepted, :from => :pending | |
end | |
private | |
def accept_job | |
unless job.accept! |
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
require "benchmark" | |
require "prime" | |
class Integer | |
# http://en.wikipedia.org/wiki/Miller-Rabin_primality_test | |
def prime? | |
n = self.abs() | |
return true if n == 2 | |
return false if n == 1 || n & 1 == 0 |
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
class Foo | |
def hello &block | |
instance_eval &block | |
end | |
end | |
a = 10 | |
b = Foo.new() |