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
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
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
| """SQLAlchemy Metadata and Session object""" | |
| from sqlalchemy import MetaData | |
| from sqlalchemy.orm import scoped_session, sessionmaker | |
| from sqlalchemy.orm.session import Session as SessionBase | |
| from sqlalchemy.interfaces import ConnectionProxy | |
| from datetime import datetime | |
| import time | |
| __all__ = ['Session', 'metadata', 'BaseModel'] |
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
| bcx david$ rake stats | |
| +----------------------+-------+-------+---------+---------+-----+-------+ | |
| | Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
| +----------------------+-------+-------+---------+---------+-----+-------+ | |
| | Controllers | 3704 | 2942 | 72 | 479 | 6 | 4 | | |
| | Helpers | 1901 | 1529 | 13 | 261 | 20 | 3 | | |
| | Models | 5310 | 4116 | 50 | 653 | 13 | 4 | | |
| | Libraries | 2167 | 1593 | 51 | 200 | 3 | 5 | | |
| | Integration tests | 297 | 217 | 6 | 1 | 0 | 215 | | |
| | Functional tests | 3897 | 3065 | 61 | 11 | 0 | 276 | |
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 'date' | |
| # Actually doesn't matter WHAT you choose as the epoch, it | |
| # won't change the algorithm. Just don't change it after you | |
| # have cached computed scores. Choose something before your first | |
| # post to avoid annoying negative numbers. Choose something close | |
| # to your first post to keep the numbers smaller. This is, I think, | |
| # reddit's own epoch. | |
| $our_epoch = Time.local(2005, 12, 8, 7, 46, 43).to_time |
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
| ENV["RAILS_ENV"] = "test" | |
| require File.expand_path('../../config/environment', __FILE__) | |
| require 'rails/test_help' | |
| require 'minitest/autorun' | |
| require 'minitest/pride' | |
| require 'capybara/rails' | |
| class MiniTest::Spec | |
| include ActiveSupport::Testing::SetupAndTeardown |
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
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
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
| # A Basic API Controller for Rails | |
| # Handles authentication via Headers, params, and HTTP Auth | |
| # Automatically makes all requests JSON format | |
| # | |
| # Written for production code | |
| # Made public for: http://broadcastingadam.com/2012/03/state_of_rails_apis | |
| # | |
| # Enjoy! | |
| class ApiController < ApplicationController |
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
| $(function() { | |
| /* Convenience for forms or links that return HTML from a remote ajax call. | |
| The returned markup will be inserted into the element id specified. | |
| */ | |
| $('form[data-update-target]').live('ajax:success', function(evt, data) { | |
| var target = $(this).data('update-target'); | |
| $('#' + target).html(data); | |
| }); | |
| }); |
You have your Rails Apps with specific Gemsets in RVM.
The following commands creates a wrapped unicorn_rails bin. Be sure to replace the variables and that you have unicorn in your bundle.
rvmsudo rvm wrapper [RUBY VERSION]@[GEMSET] [GEMSET] unicorn_rails
Now you have a /usr/local/rvm/bin/[GEMSET]_unicorn_rails I will refer to [GEMSET]_unicorn_rails as [WRAPPED_NAME]