Skip to content

Instantly share code, notes, and snippets.

@happyrobots
happyrobots / input-appearance.css
Created December 30, 2012 11:47
disable default input form appearance
input {
-webkit-appearance: none;
-moz-appearance: none;
}
@happyrobots
happyrobots / MiniMapper.h
Created August 23, 2012 17:13
Mini Mapper
/*
Usage:
1. Initialize
MiniMapper *m = [MiniMapper new];
2. Map
[m forClass:[MyClass class] mapAttributes:^(NSMutableDictionary *dict) {
[dict setObject:@"my_attribute"
forKey:@"my_property"];
@happyrobots
happyrobots / measure.rb
Created May 17, 2012 03:43
Stuff from HAR
#!/usr/bin/env ruby
require 'json'
def group_time_by_hosts(raw)
result = {}
raw["log"]["entries"].each do |entry|
url = entry["request"]["url"]
addr = url.split('/')[2]
addr = addr.split('.')[-2..-1] if addr
@happyrobots
happyrobots / gist:1862963
Created February 19, 2012 10:17
Copy to Clipboard Using Ruby
# Mac
IO.popen('pbcopy', 'r+') { |clipboard| clipboard.puts html_out }
# Linux
IO.popen(’xsel –clipboard –input’, ‘r+’) { |clipboard| clipboard.puts html_out }
#define SuperRandom (arc4random() % ((unsigned)RAND_MAX + 1))
float objectiveFunction(NSArray *vector) {
float result = 0.0;
for (id element in vector) {
result += [element floatValue];
}
return result;
}
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
heroku_status_url = "https://status.heroku.com"
doc = Nokogiri::HTML(open(heroku_status_url))
problems, problem_types = [], { "app" => "App Operations", "tools" => "Tools" }
git branch -m old_branch new_branch
@happyrobots
happyrobots / pretty_generate.rb
Created November 3, 2011 02:07
JSON Pretty Generate
require 'JSON'
puts JSON.pretty_generate(JSON.parse('{"array":[1,2,3,{"sample":"hash"}],"foo":"bar"}'))
{
"array": [
1,
2,
3,
{
:read !pbpaste
bash$ pbpaste | vim -
"*P
@happyrobots
happyrobots / configuration_with_class.rb
Created September 22, 2011 20:36
Configuration Patterns
module MyCoolModule
class Configuration
attr_accessor :my_value
def initialize
# set defaults
end
end
def self.configure