Skip to content

Instantly share code, notes, and snippets.

addModel: function (model, scroll) {
if (model != null)
{
// we want to set a new model, check whether we already have one or not
if (this.model == null)
{
// split the views
a.setRatio(0.5);
// set the maximiztion and close tools
this.tools = $('<div class="tools"><div id="close"><img src="/close.png" alt="" /></div><div id="max"><img src="/max.png" alt="" /></div></div>');
//ViewPane
addModel: function (model, scroll) {
if (model != null)
{
// we want to set a new model, check whether we already have one or not
if (this.model == null)
{
// split the views
a.setRatio(0.5);
// set the maximiztion and close tools
@nambrot
nambrot / gist:1793544
Created February 10, 2012 22:21
IRB session history
[ [ 0] "foo = lambda {|n| n.to_s.split('').map { |digit| digit.to_i }.inject(0){|a,b| a+b}}", [ 1] "foo.call(1)", [ 2] "foo.call(2)", [ 3] "foo.call(20)", [ 4] "foo.call(21)", [ 5] "foo.call(i)", [ 6] "puts foo.call(i)", [ 7] "def fact", [ 8] "def fact(n)", [ 9] "n==0 ? 1 : fact(n-1) * n", [ 10] "for i in 1..20", [ 11] "puts foo.call(fact(i))", [ 12] "fact(2)", [ 13] "fact(6)", [ 14] "i = 0", [ 15] "while foo.call(fact(i)) != 8001", [ 16] "i++", [ 17] "while foo.call(fact(i)) != 8001 do", [ 18] "i += 1", [ 19] "end", [ 20] "i",
[ 21] "fact(787)",
[ 22] "foo.call(fact(787))",
[ 23] "require 'nogokiri'",
[ 24] "require 'net/http'",
[ 25] "Net::Http",
[ 26] "Net",
[ 27] "Net::HTTP.new(\"http://apply.embed.ly/static/data/2.html",
[ 28] "re:",
[ 29] ":",
@nambrot
nambrot / unicorn.rb
Created February 16, 2012 06:45
config/unicorn.rb
worker_processes 2 # amount of unicorn workers to spin up
timeout 3000
@resque_pid = nil
@resque_pid2 = nil
before_fork do |server, worker|
@resque_pid ||= spawn("bundle exec rake jobs:work")
@resque_pid2 ||= spawn("bundle exec clockwork app/clock.rb")
end
@nambrot
nambrot / clock.rb
Created February 16, 2012 06:47
app/clock.rb
require 'clockwork'
include Clockwork
require File.expand_path('../../config/boot', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
every(2.hours, 'feeds.refresh') { Delayed::Job.enqueue CollegeJob.new }
class CollegeJob < Object
def perform
College.all.each {|d| College.getPhotos(d)}
it "should have unique connections respective to their context", :debug => true do
TpSubidentity.create!({
:uid => 'test10',
:context_name => 'batchspectpsicontext',
:name => 'ttest',
:image => 'http://graph.facebook.com/523538207/picture',
:url => 'http://graph.facebook.com/523538207/picture',
:objecttype => 'something',
:credentials => {},
:attributes => {}
"raw_info" => {
"firstName" => "Nam",
"headline" => "Co-Founder at Webcred",
"id" => "WGSx5l71fC",
"industry" => "Information Technology and Services",
"lastName" => "Chu Hoai",
"pictureUrl" => "http://m3.licdn.com/mpr/mprx/0_1C0R3cu-LOnuqoFUAbak3vu1dj8yq7cUl_Ik3Nah94NuIIhRxkfc7qsaFPh_Be9B-TjLa1rrAmVa",
"positions" => {
"_total" => 1,
"values" => [
countdown = 2
cb = ->
console.log countdown
countdown = countdown - 1
user.trigger 'change' if countdown == 0
$.ajax
type: 'GET'
url: "https://www.credport.org/api/v1/users/#{user.get('id')}/socialconnections?include=verifications"
contentType: "application/json"
dataType: 'jsonp'
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@nambrot
nambrot / gist:4140555
Created November 24, 2012 17:10
Credport Badge
<div id="credport-button">
</div>
<script type="text/javascript">
window.credport = {
user: {
md5_email: "<%= Digest::MD5.hexdigest @user.email %>"
},
buttontext: "We have partnered with Credport to help you build a portable trustworthy profile.
Credport increases your chance of a transaction (like a good eBay rating)
and lets you bring your reputation anywhere"