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 Kernel | |
MDEF_DEFINED = {} | |
def mdef(name, *types, &block) | |
sig = gen_sig(name, types) | |
MDEF_DEFINED[name] = (MDEF_DEFINED[name] || []) + [ sig ] | |
Kernel.send(:define_method, sig, &block) | |
end | |
def gen_sig(name, types) |
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
var w = Ti.UI.createWindow({ backgroundColor: 'red' }); | |
var sv = Ti.UI.createScrollView({ | |
width: '100%', | |
height: '100%' }); | |
w.add(sv); | |
var wr = Ti.UI.createView({ | |
top: 10, | |
left: 10, |
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
VideoRendering.render({ | |
video: [ | |
fixtureFile("1.m4v"), // passing as TiFile | |
fixtureFile("2.m4v").getNativePath() // passing as URL (native path is presented as file://...) | |
], | |
titles: [ | |
{ text: "AUG 6, 1945", | |
font: "HelveticaNeue-CondensedBlack", | |
fontSize: 32, |
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
namespace :db do | |
desc 'Seed database from db/seed.sql file instead of the traditional db/seed.rb' | |
namespace :seed do | |
config = Rails::Configuration.new.database_configuration[RAILS_ENV] | |
seed_sql = File.expand_path(File.dirname(__FILE__) + '/../../db/seed.sql') | |
if !File.exists?(seed_sql) | |
puts "Missing RAILS_ROOT/db/seed.sql" |
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
# Fills the standard Rails 3-field date picker with the date. | |
# #name# is supposed to lead to one of these fields, either through a label or a CSS selector. | |
# Usage: | |
# fill_in_date "Date of birth", with: 30.years.ago | |
def fill_in_date(name, options) | |
date = options[:with] | |
within find_field(name).parent do | |
find('select[name*="2i"]').select(date.strftime('%B')) | |
find('select[name*="3i"]').select(date.day.to_s) | |
find('select[name*="1i"]').select(date.year.to_s) |
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
# encoding: utf-8 | |
def gas(name = "", acct = "") | |
url = "http://sevgaz.com.ua/index.php?option=com_content&view=article&id=52" | |
data = `curl -F "afam=#{name}" -F "peracc=#{acct}" "#{url}" 2>/dev/null` | |
data.scan(%r{Адрес.*?<tr><td>(.*?)</td>\s*<td>\s*<strong>(.*?)</strong>}).flatten | |
end | |
def water(name = "", acct = "") |
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
describe SomeController do | |
context "if user is not logged in" do | |
[ :show, :edit, :update ].each do |action| | |
specify do | |
get action | |
should redirect_to login_path | |
end | |
end | |
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
//error when the a table row is clicked in nearme_window.js | |
[WARN] Exception in event callback. { | |
line = 59; | |
message = "'undefined' is not a function (evaluating 'pub_win.update_pub_details('blah')')"; | |
name = TypeError; | |
sourceId = 233027648; | |
} | |
//nearme_window.js | |
module.exports = (function() { |
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(t1). | |
-export([primes/1]). | |
primes(N) -> primeA(1, N, []). | |
primeA(X, N, L) -> | |
if | |
X =:= 1 -> primeA(2, N, [1|L]); | |
X > N -> lists:reverse(L); | |
true -> | |
NL = case length([I || I <- L, X rem I =:= 0]) of |
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
> db.m.insert({ body: '1', phone_id: 1 }) | |
> db.m.insert({ body: '2', phone_id: [ 1, 2 ]}) | |
> db.m.find({ phone_id: 1 }) | |
{ "_id" : ObjectId("4e56089fbdfcdc0f68c894ae"), "body" : "1", "phone_id" : 1 } | |
{ "_id" : ObjectId("4e5608afbdfcdc0f68c894af"), "body" : "2", "phone_id" : [ 1, 2 ] } | |
> db.m.find({ phone_id: 2 }) | |
{ "_id" : ObjectId("4e5608afbdfcdc0f68c894af"), "body" : "2", "phone_id" : [ 1, 2 ] } |