Skip to content

Instantly share code, notes, and snippets.

@gnufied
gnufied / obj.rb
Last active December 11, 2015 03:28
objective c reply
#!/usr/bin/env ruby
require "readline"
require "fileutils"
class CompileObjectiveC
attr_accessor :code_lines
TMP_DIR = "/tmp"
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. :(
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)
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";
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
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
#!/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*
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!
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
class Foo
def hello &block
instance_eval &block
end
end
a = 10
b = Foo.new()