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
| url = "http://prod.hi360.com" | |
| params = {:channel_id=>"12345", :lang=>"en"} | |
| key = Marshal.dump(url + "?" + params.to_a.map {|a| a.join("=")}.join('&')) | |
| url = Marshal.load(key) |
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
| describe("Tasks", function() { | |
| var task; | |
| var last_task_id; | |
| beforeEach(function() { | |
| task = new app.models.Task("Buy the milk"); | |
| }); | |
| describe("makeId", function() { |
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 'mongo' | |
| # Get a connection to Mongo | |
| db = Mongo::Connection.new | |
| # Insert records (Create) | |
| db["movies_db"]["movies"].insert({ hello: "there"}) | |
| # Find records (Read) | |
| db["movies_db"]["movies"].find_one |
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
| String.prototype.equals = function(s) { | |
| if(typeof(s) == "object") { | |
| return this.valueOf() === s.valueOf(); | |
| } | |
| else if(typeof(s) == "string") { | |
| return this.valueOf() === s; | |
| } | |
| else { | |
| return undefined; | |
| } |
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 Mammal | |
| def self.factory(type) | |
| if choice == "Dog" | |
| mammal = Dog.new | |
| elsif choice == "Cat" | |
| mammal = Cat.new | |
| elsif choice == "Whale" | |
| mammal = Whale.new | |
| 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
| { | |
| "auto_complete": false, | |
| "color_scheme": "Packages/Color Scheme - Default/Dawn.tmTheme", | |
| "font_size": 12, | |
| "hot_exit": false, | |
| "ignored_packages": | |
| [ | |
| "Floobits", | |
| "Vintage" | |
| ], |
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 Array | |
| def insertion_sort(list = self) | |
| sorted = [self.delete_at(0)] | |
| self.each_with_index do |i, p| | |
| if i < sorted.last | |
| sorted.each_with_index do |j, k| | |
| if sorted[k] >= i | |
| already_sorted = sorted.slice(0, k - 1) | |
| to_shift = sorted.slice(k + 1, sorted.size) | |
| sorted = already_sorted + [i] + to_shift |
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 'spec_helper' | |
| describe Project do | |
| describe 'nested attributes' do | |
| before do | |
| json = { | |
| "title" => "My Amazing Project", | |
| "skills_attributes" => [ |
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
| app.models.Project = Backbone.Model.extend({ | |
| url: function() { | |
| var url = '/users/' + this.user.id + '/projects'; | |
| if(!this.isNew()) { | |
| url += '/' + this.id; | |
| } | |
| return url; | |
| }, |