This file contains 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
namespace :util do | |
desc "apt software update" | |
task :apt_upgrade do | |
run "#{sudo} apt-get update -q" | |
run %Q\#{sudo} sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade -q -y\ | |
end | |
end |
This file contains 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
desc "Restarts app servers in a rolling fashion, one by one with wait in between" | |
task :rolling_restart, roles: [:passenger] do | |
servers = find_servers_for_task(current_task) | |
servers.each do |s| | |
run "touch #{current_path}/tmp/restart.txt", hosts: s.host | |
puts "#{s.host} restarting...I'm sleep doe." | |
sleep 45 | |
status = capture "sudo passenger-status; true", hosts: s.host | |
# Sometimes nginx/passenger is a bit wonky and fails to restart? | |
# Not sure if it's because of the load balancer fucking things up or what |
This file contains 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 DateTimeUtils | |
def season | |
case self.month | |
when 3, 4, 5 | |
'Spring' | |
when 6, 7, 8 | |
'Summer' | |
when 9, 10, 11 | |
'Fall' | |
when 12, 1, 2 |
This file contains 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
//Ext.ns('CbMobile', 'CbMobile.views'); | |
new Ext.Application({ | |
name: 'CbMobile', | |
SIDEBAR_WIDTH: 320, | |
MENU_WIDTH: 250, | |
MENU_HEIGHT: 200, | |
launch: function() { | |
var app = this; |
This file contains 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
/** | |
* Take string input in varName and determine whether it is defined object in Javascript | |
* ...like isDefined('foo.bar.baz'); | |
* Better than doing if(foo && foo.bar && foo.bar.baz){} | |
* @param {String} varName | |
* @return {boolean} | |
* @author Bilal Soylu | |
*/ | |
function isDefined(varName) { | |
var retStatus = false; |
This file contains 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
Backbone.BaseCollection = Backbone.Collection.extend({ | |
// Holds id of locally deleted items we ignore if we | |
// 'freshen' the collection and changes haven't propagated yet. | |
_localDeletedIds: [], | |
// Take an array of raw objects | |
// If the ID matches a model in the collection, set that model | |
// If the ID is not found in the collection, add it | |
// If a model in the collection is no longer available, remove it | |
// | |
// Keeps local changes, in case we've added things in the meantime. |
This file contains 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
// Inline assignment inside an 'if' statement works with most programming languages. | |
// However, in JavaScript there's a gotcha. | |
// This works in Safari, Firefox & Chrome...but will destroy your life in IE. | |
if(thing=functionThatReturnsThing()) { | |
doStuff(); | |
} | |
// Do this instead | |
var thing=functionThatReturnsThing(); |
This file contains 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
# Projects a user has access to either through ProjectAssignment, or as an "account manager" | |
named_scope :user_has_access_to, lambda{|user| | |
{ | |
:select => 'DISTINCT projects.*', | |
:joins => %q\ | |
LEFT JOIN project_assignments | |
ON ( | |
projects.id = project_assignments.project_id | |
AND project_assignments.has_access = 1 | |
) |
This file contains 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
# If you have a large test suite, being able to test only a subset | |
# of those items is a big speed boost. | |
# | |
# With this in your .autotest file you can run "autotest /some/dir" and only test | |
# the files within. | |
# | |
require 'redgreen/autotest' | |
Autotest.add_hook :initialize do |at| | |
unless ARGV.empty? |
This file contains 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
// Extended model that fires events on CRUD actions, | |
// and allows for reloading of data from the server. | |
Ext.define('CbMobile.model.Base', { | |
extend: 'Ext.data.Model', | |
// Overloaded methods that fire events | |
set: function(fieldName, value) { | |
this.callParent(arguments); | |
this.fireEvent('set', fieldName, value); | |
}, |
OlderNewer