This file contains 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/sh | |
# on OSX : /Applications/Google\ Chrome\ 2.app/Contents/MacOS/Google\ Chrome | |
/path/to/Chrome --user-data-dir=/tmp/test1 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-web-security |
This file contains 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
# SSL self signed localhost for rails start to finish, no red warnings. | |
# 0) Unless present, create `~/.ssl/` | |
$ mkdir ~/.ssl | |
# 1) Create your private key (any password will do, we remove it below) | |
$ openssl genrsa -des3 -out ~/.ssl/localhost.orig.key 2048 |
This file contains 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
# fork it | |
# | |
# make it print all true with only ONE LINE OF CODE | |
class A | |
def A.foo | |
@foo ||= ( | |
if self == A | |
'42.0' | |
else |
This file contains 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/php5 | |
<?php | |
/** | |
* Simple script to weight PostgreSQL query planner costs (`analyze` times included!) in explain log file. | |
* Handy for analyzing large query plans with a lot of subqueries. | |
* Example output (this scan took ~21% of total query run time, worth optimizing): | |
-> Seq Scan on public.tablename (cost=0.00..3919.54 rows=1 width=0) (actual time=64.232..86.516 rows=1 loops=1) | |
Cost: 0.00..22.35% | |
Time: 15.53..20.92% | |
Output: tablename.id, tablename.name, tablename.another_id |
This file contains 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
package main | |
import ( | |
"flag" | |
"fmt" | |
"net/http" | |
"github.com/codegangsta/martini" | |
"github.com/garyburd/redigo/redis" | |
"github.com/martini-contrib/render" |
This file contains 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 GroupersController < ApplicationController::Base | |
def create | |
@grouper = Grouper.new(leader: current_member) | |
if @grouper.save | |
ConfirmedGrouperEmails.new(@grouper).deliver | |
AssignBarForGrouper.enqueue(@grouper.id) | |
redirect_to home_path | |
else |
This file contains 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
def check | |
yield | |
rescue => e | |
e | |
end | |
check { "hello, #{1}" } # ? | |
check { "hello, " + 1 } # ? | |
check { "hello, " << 1 } # ? |
This file contains 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 A | |
def to_s | |
'A1' | |
end | |
def to_str | |
'A2' | |
end | |
end |
This file contains 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(web_lager_handler). | |
-behaviour(gen_event). | |
-export([subscribe/1, unsubscribe/1]). | |
-export([init/1, handle_call/2, handle_event/2, handle_info/2, terminate/2, | |
code_change/3]). | |
-export([remover_loop/0]). |
This file contains 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
BEFORE: | |
sam@ubuntu discourse % rm -fr tmp/cache | |
sam@ubuntu discourse % rm -fr public/assets | |
sam@ubuntu discourse % time RAILS_ENV=production bin/rake assets:precompile | |
58.55s user 1.79s system 100% cpu 1:00.02 total | |
AFTER: |