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
# sudo gem install bson | |
# sudo gem install bson_ext | |
# sudo gem install yajl-ruby | |
# sudo gem install json | |
# sudo gem install msgpack | |
require 'rubygems' | |
require 'benchmark' | |
require 'yaml' | |
require 'bson' |
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 DevelopmentProfiler | |
def self.prof(file_name) | |
RubyProf.start | |
yield | |
results = RubyProf.stop | |
# Print a flat profile to text | |
File.open "#{Rails.root}/tmp/performance/#{file_name}-graph.html", 'w' do |file| |
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
module AfterCommitCallbacks | |
def self.included(base) | |
base.send(:extend, ObserverCallbacks) unless base.respond_to?(:define_model_callbacks_for_observers) | |
[:create, :update, :destroy].each do |action| | |
base.send(:define_model_callbacks_for_observers, :"commit_on_#{action}", :only => :after) | |
end | |
base.send(:attr_accessor, :newly_created) | |
base.send(:before_validation, AfterCommitCallbacks::Handlers) |
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 'msgpack' | |
require 'thread' | |
class ProcessPool | |
def initialize(num_process, args={}) | |
queue_size, worker_class = parse_args([ | |
:queue_size, nil, | |
:worker_class, Worker, | |
], args) |
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
# ruby-2.5.0 | |
user system total real | |
YAML 15.112795 0.030577 15.143372 ( 15.190573) | |
JSON 0.648957 0.001520 0.650477 ( 0.652856) | |
Marshal 0.474775 0.000922 0.475697 ( 0.477678) | |
MessagePack 0.326430 0.001763 0.328193 ( 0.330159) | |
# ruby-2.4.3 | |
user system total real | |
YAML 20.400000 0.050000 20.450000 ( 20.517600) |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.3/ember.js"></script> | |
<script src="//maps.googleapis.com/maps/api/js?sensor=false"></script> | |
</head> | |
<body> | |
<script> |
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
# 1.install gource using HomeBrew | |
$ brew install gource | |
# 2.install avconv | |
git clone git://git.libav.org/libav.git | |
cd libav | |
# it will take 3-5 minutes to complie, be patient. | |
./configure --disable-yasm | |
make && make install |
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 Session from 'appkit/models/session'; | |
export default Ember.Application.initializer({ | |
name: 'currentUser', | |
initialize: function(container, app) { | |
// Register a new container | |
container.register('session:current-user', Session); | |
// Load the current user | |
container.lookup('session:current-user').find(); |
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
declare class Two { | |
type: Two.Types; | |
width: number; | |
height: number; | |
constructor(params?: TwoConstructionParams); | |
appendTo(element: HTMLElement); | |
makeLine(x1: number, y1: number, x2: number, y2: number): Two.Shape; | |
makeRectangle(x: number, y: number, width: number, height: number): Two.Shape; |
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
// app/transforms/array.js | |
import Ember from 'ember'; | |
import DS from 'ember-data'; | |
export default DS.Transform.extend({ | |
deserialize: function(value) { | |
if (Ember.isArray(value)) { | |
return Ember.A(value); | |
} else { | |
return Ember.A(); |
OlderNewer