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
import android.app.Activity | |
import android.content.Context | |
import android.os.Bundle | |
import android.util.Log | |
import android.view.View | |
import android.view.MotionEvent | |
import android.graphics.Canvas | |
import android.graphics.Paint |
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 Foo | |
@start = Time.now.to_i | |
def self.start | |
@start | |
end | |
def make_another_class | |
Class.new do | |
@start = Time.now.to_i | |
def self.start |
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
require 'mongo' | |
require 'progress_bar' | |
db = Mongo::Connection.new["colors"] | |
identify = "identify %s" | |
convert = "convert %s -format %%c -colors 5 -colorspace LAB histogram:info:-" | |
def run(cmd, *args) | |
str = cmd % args | |
`#{str}` | |
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
% ab -n 10000 -c16 http://mybb.local/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking mybb.local (be patient) | |
Completed 1000 requests | |
Completed 2000 requests | |
Completed 3000 requests | |
Completed 4000 requests |
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
/* Reset.scss | |
* Props to Eric Meyer (meyerweb.com) for his CSS reset file. | |
We're using an adapted version here that cuts out some of the reset HTML elements we will never need here (i.e., dfn, samp, etc). | |
* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ | |
// ERIC MEYER RESET | |
// -------------------------------------------------- | |
html, body { margin: 0; padding: 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
# Fetch and setup the canvas. $canvas is a jQuery object wrapping a <canvas> tag. | |
canvas = $canvas[0] | |
w = $canvas.data('width') || $canvas.width() | |
h = $canvas.data('height') || $canvas.height() | |
canvas.width = w | |
canvas.height = h | |
c = canvas.getContext("2d") | |
c.lineCap = 'round' | |
c.lineWidth = 2.5 |
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
%%{ | |
machine rfc2822_header; | |
action mark { | |
@pos = p | |
} | |
action domain { | |
# We have to match 'foo . bar' per the tests and transform it into 'foo.bar' | |
@parts[:host] = data[@pos..p-1].delete(" ") |
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
# Renders the given content or block in a CDATA section if necessary. If CDATA is not necessary, the raw data is returend. | |
# @param data [String] The data to render. Nil if passing a block. | |
# @yield Template fragment to encode as CDATA if necessary. | |
def cdata(data = nil) | |
data = data.dup if data.present? and data.frozen? | |
if data | |
data.strip! | |
data.gsub!(/\]\]>/, "]]>") | |
if match = data.match(/([<>&]|[^\x20-\x7f])/) | |
data = "\n%s" % data if data.match(/\n/) |
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 AuthenticationHelpers | |
def authenticated_as(roles, options=nil) | |
options = instance_eval(&options) if options.is_a? Proc | |
Array(roles).each do |role| | |
context "when logged in as a #{role}" do | |
before(:all) { @user = FactoryGirl.create role, *Array(options) } | |
after(:all) { DatabaseCleaner.clean } | |
before(:each) { sign_in @user } |
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
% rspec spec.rb --format doc | |
Foo | |
when logged in as a user | |
should == "TEST VALUE" | |
Finished in 0.00047 seconds | |
1 example, 0 failures |