- assets and specs can be CoffeeScript
- 3rd party JS can be placed to vendor/assets/javascripts or vendor gems
- detects gem-vendored JS via application.js require
- uses jasmine-headless-webkit to run the suite outside the browser
- this requires Qt4.7 installation
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
let A be the given array of integers | |
let maxSum = -infinity, maxLeft = 0, maxRight = 0, currentMax = 0, left = 0, right = 0 | |
for i = 0 to A.length - 1 | |
currentMax += A[i] | |
if currentMax > maxSum | |
maxSum = currentMax | |
right = i; | |
maxLeft = left | |
maxRight = right | |
if currentMax < 0 |
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 ActiveRecord | |
class Base | |
def self.random | |
if (c = count) != 0 | |
find(:first, :offset =>rand(c)) | |
end | |
end | |
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
<%= form_for parent do |parent_form_builder| %> | |
<%= parent_form_builder.text_field :name %> | |
<% parent.children.each_with_index do |child, index| %> | |
<% parent_form_builder.fields_for :children, child do |child_form_builder| %> | |
<%= child_form_builder.select :age, (0..99).to_a %> | |
<%# generates "parent[:children_attributes][index][age]" as name for the input %> | |
<% end %> | |
<% end %> | |
<%= f.submit %> | |
<% 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
Backbone.View.prototype.proxy = function(source, eventName, options) { | |
if (!options) { options = {}; } | |
var self = this; | |
source.bind(eventName, function(args) { | |
var name = options["proxyName"] || eventName; | |
var newArgs = options["proxyArgs"] ? _.combine(args, options["proxyArgs"]) : args; | |
self.trigger(name, newArgs); | |
}); | |
}; |
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
# Invoked with : | |
# thin -DR config.ru start | |
# (single, undetached process, oracle Ok) | |
# thin -DR config.ru -s2 start | |
# (two forked processed, oracle error ORA-12154) | |
$LOAD_PATH << File.expand_path(File.dirname(__FILE__)) | |
require 'rack' | |
require 'init.rb' |
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
// A collection holding many tweet objects. | |
// also responsible for performing the | |
// search that fetches them. | |
var Tweets = Backbone.Collection.extend({ | |
model: Tweet, | |
initialize: function(models, options) { | |
this.query = options.query; | |
}, | |
url: function() { | |
return "http://search.twitter.com/search.json?q=" + this.query + "&callback=?"; |
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
#!/usr/bin/env ruby | |
## | |
# Compile script for Rails assets that puts the assets into their [environment] branch | |
# thus not polluting the master branch with the files in public/assets that only | |
# apply to that environment. See https://github.com/rails/sass-rails/issues/93#issuecomment-3982582 | |
# | |
# Usage: ./compile [environment] | |
# supported environments |
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
/** | |
* This snipplet adds the following methods: | |
* VEMap.DropPushpin | |
* VEShapeLayer.DropPushpin | |
* | |
* This is similar to VEMap.AddPushpin except the pin is animated (it "falls" on the map). | |
* | |
* Works even in IE6 and the IPhone. Generic solution based on this proof of concept: | |
* http://www.garzilla.net/vemaps/DropPushPin.aspx | |
*/ |
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
digital-alley:tmpdir aaron$ vagrant up | |
digital-alley:tmpdir aaron$ vagrant ssh | |
vagrant@lucid32:~$ sudo apt-get install unzip | |
vagrant@lucid32:~$ sudo apt-get install rpm | |
vagrant@lucid32:~$ cd /tmp | |
vagrant@lucid32:~$ cp /vagrant/instantclient-* . | |
vagrant@lucid32:~$ cd /opt | |
vagrant@lucid32:~$ sudo mkdir oracle | |
vagrant@lucid32:~$ cd oracle |
OlderNewer