Skip to content

Instantly share code, notes, and snippets.

# cap web:deploy:desable & cap web:deploy:enable
server {
...
if (-f $document_root/system/maintenance.html) { set $maintenance 1; }
if ($request_uri ~* (jpg|jpeg|gif|js|css)$) { set $maintenance 0; }
if ($maintenance) { rewrite ^(.*)$ /system/maintenance.html; break; }
...
}
@Ptico
Ptico / ruby-1.9-tips.rb
Created February 27, 2011 22:18 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 tips and tricks
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
require 'resque/tasks'
task "resque:setup" => :environment
namespace :queue do
task :start => :environment do
pidfile = Rails.root.join('tmp', 'pids', 'resque.pid')
logfile = Rails.root.join('log', 'resque.log')
errlogfile = Rails.root.join('log', 'resque_errors.log')
@Ptico
Ptico / shoulda_am.rb
Created September 22, 2011 12:41
Shoulda activemodel matchers cheatsheet
# Shoulda activemodel cheatsheet
# DB
should have_db_column(:title).of_type(:string).with_options(default: 'Untitled', null: false)
should have_db_index(:email).unique(:true)
# Associations
should belong_to :company
should have_one(:profile).dependent(:destroy)
should have_many(:posts).dependent(:nullify)
@Ptico
Ptico / spec.rb
Created October 7, 2011 15:30
Rspec functioning principle
# Core
class Object
def should(matcher)
puts matcher.match(self)
end
end
class Matcher
def initialize(expected, &block)
@expected = expected
[BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
-- Control frame information -----------------------------------------------
c:0007 p:---- s:0021 b:0021 l:000020 d:000020 CFUNC :next!
c:0006 p:0049 s:0018 b:0018 l:000017 d:000017 METHOD /Users/ptico/.rvm/gems/ruby-1.9.3-p0/gems/data_objects-0.10.7/lib/data_objects/reader.rb:35
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 FINISH
c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :to_a
c:0003 p:0087 s:0009 b:0008 l:001638 d:002478 EVAL do.rb:8
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
var Baby = (function() {
function Baby(name) { // Constructor
this.name = name;
}
Baby.prototype = { // Public
introduce: function() {
alert("Hello! My name is " + name);
},
play: function() {
App = {};
// Another sandbox functions
/**
* Creates namespace in sandbox by string definition
* If part of namespace already defined - keep it untouchable,
* else - create empty object.
*
* App.namespace("Hello.World");
@Ptico
Ptico / class-test.js
Created April 15, 2012 01:20
Just an experiment with JS object model and ES5 functions
var Hello = Class({
attrReader: "val",
initialize: function(val) {
this.val = val;
},
publicFn: function() {
console.log(this.val);
this.privateFn();
@Ptico
Ptico / widget.js
Created August 30, 2012 16:10
bee.js widget proposition
define(["bee/widget", "app/models/transport", "app/modules/cargo-log"], function(Widget, Transport, CargoLog) {
"use strict";
var Transports = new Widget({
root: "#transports-sidebar",
extends: [CargoLog],
init: function() {
this.transports = [];