This file contains hidden or 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 vm = require('vm'), | |
code = 'var square = n * n;', | |
fn = new Function('n', code), | |
script = vm.createScript(code), | |
sandbox; | |
n = 5; | |
sandbox = { n: n }; | |
benchmark = function(title, funk) { |
This file contains hidden or 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 fl.text.TLFTextField; | |
var tlfTxt:TLFTextField = new TLFTextField(); | |
tlfTxt.border = true; | |
tlfTxt.text = "The quick brown fox jumps over the lazy dog."; | |
tlfTxt.x = tlfTxt.y = 20; | |
addChild(tlfTxt); |
This file contains hidden or 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 'thread' | |
require 'facebook_oauth' | |
require 'launchy' | |
require 'sinatra/base' | |
callback_uri = URI.parse('http://localhost:6789/') | |
fb_client = FacebookOAuth::Client.new( | |
:application_id => 'XXXXXXXXXXXX', | |
:application_secret => 'XXXXXXXXXXXXXXXXXXXXXXXX', |
This file contains hidden or 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
# Set the number of connections AR pool | |
# | |
# place in an initializer such as: config/connection_pool.rb | |
Rails.application.config.after_initialize do | |
ActiveRecord::Base.connection_pool.disconnect! | |
ActiveSupport.on_load(:active_record) do | |
config = Rails.application.config.database_configuration[Rails.env] | |
config['pool'] = ENV['DB_POOL'] || 6 |
This file contains hidden or 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
heroku pgbackups:capture | |
curl -o latest.dump `heroku pgbackups:url` | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost \ | |
-U `whoami` -d `ruby -e "require 'yaml' ; File.open( 'config/database.yml' ) { |file| puts YAML::load(file)['development']['database'] }"` latest.dump | |
rm latest.dump | |
This file contains hidden or 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:User>': undefined method `image_accessor' for User:Class (NoMethodError) | |
from /Users/chee/rails3apps/socialmarket/app/models/user.rb:3:in `<top (required)>' | |
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:469:in `load' | |
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:469:in `block in load_file' | |
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:639:in `new_constants_in' | |
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:468:in `load_file' | |
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:353:in `require_or_load' | |
from /Users/chee/.rvm/gems/ruby-1.9.3-p362@socialmart/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:502:in `load_missing_constant' | |
from /Users/chee/. |
This file contains hidden or 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
# uses the mongoex plugin | |
if System.get_env("MONGOHQ_URL") !== nil do | |
connection = URI.parse( System.get_env("MONGOHQ_URL") ) | |
host = '#{connection.host}' | |
port = connection.port | |
userinfo = String.split( connection.userinfo, ":" ) | |
username = Enum.at(userinfo,0) | |
password = Enum.at(userinfo,1) | |
pool = 4 |
This file contains hidden or 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
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{HTTP_USER_AGENT} !(Chrome\/[0-8]|Android\s[0-3])\. | |
RewriteCond %{HTTP_USER_AGENT} Chrome [OR] | |
RewriteCond %{HTTP_ACCEPT} image/webp | |
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f | |
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1] | |
</IfModule> | |
<IfModule mod_headers.c> |
This file contains hidden or 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
tst=["GBP","USD","EUR"] | |
tst.each_with_object({}) do |item, memo| | |
memo[item] = item.downcase | |
end |
This file contains hidden or 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 like_enter = function(){ | |
$(".already_liked").find('.title').text('Unlike It'); | |
$(".already_liked").find('i.icon-circle').addClass('unliked-circle'); | |
$(".already_liked").find('i.icon-light').removeClass('icon-heart').addClass('icon-remove'); | |
} | |
var like_leave = function(){ | |
$(".already_liked").find('.title').text('Like It'); | |
$(".already_liked").find('i.icon-circle').removeClass('unliked-circle'); | |
$(".already_liked").find('i.icon-light').removeClass('icon-remove').addClass('icon-heart'); |