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 LazyCollection extends Backbone.Collection | |
| indexQuerystring: 'index' | |
| index: 1 | |
| lastLength: 0 | |
| fetch: (options) -> | |
| options or= {} | |
| if options.reset | |
| @index = 1 | |
| @lastLength = 0 | |
| else |
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
| AppView = Backbone.View.extend({ | |
| initialize: function(){ | |
| this.router = new AppRouter(); | |
| this.collection = new MyCollection(); | |
| this.someView = new SomeView(); | |
| this.someView.render(); | |
| Backbone.history.start(); | |
| } |
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 Syslogger | |
| def initialize | |
| read, @write = IO.pipe | |
| fork do | |
| @write.close | |
| $stdin.reopen read | |
| exec *%w(logger -trails) | |
| end | |
| read.close |
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 Api::RegistrationsController < Api::BaseController | |
| respond_to :json | |
| def create | |
| user = User.new(params[:user]) | |
| if user.save | |
| render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
| return | |
| else |
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) Running a raw RackAdapter in config.ru mounted at '/' works fine | |
| require 'bundler/setup' | |
| require 'yard' | |
| run YARD::Server::RackAdapter.new( | |
| {'surfiki' => [YARD::Server::LibraryVersion.new('surfiki', nil, File.expand_path('../.yardoc', __FILE__))]}, | |
| { | |
| :single_library => true, | |
| :caching => false | |
| }) |
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
| deployment: | |
| production: | |
| branch: master | |
| heroku: | |
| appname: sirinova-prod | |
| commands: | |
| - git push git@heroku.com:sirinova-prod.git | |
| - heroku run rake db:migrate | |
| - heroku restart |
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
| $ git branch -r --merged | | |
| grep origin | | |
| grep -v '>' | | |
| grep -v master | | |
| xargs -L1 | | |
| awk '{split($0,a,"/"); print a[2]}' | | |
| xargs git push origin --delete |
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
| # .railsrc for Rails 3, encoding: utf-8 | |
| # see http://rbjl.net/49-railsrc-rails-console-snippets | |
| if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else | |
| # # # | |
| def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end | |
| # # # | |
| # loggers |
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
| user sax staff; | |
| worker_processes 1; | |
| daemon off; | |
| error_log /var/log/nginx/error.log; | |
| #error_log logs/error.log notice; | |
| #error_log logs/error.log info; | |
| #pid logs/nginx.pid; | |
| pid /var/run/nginx.pid; |
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
| def self.prevent_recursion(method_name) | |
| flag_name = "in:#{name}##{method_name}" | |
| original = instance_method(method_name) | |
| define_method(method_name) do |*args| | |
| if Thread.current[flag_name] | |
| return | |
| else | |
| begin | |
| Thread.current[flag_name] = true | |
| original.bind(self).call(*args) |