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
| #Declaring a new Hash instance | |
| creditcard = { | |
| "name" => "Billy Bob", | |
| "number" => "4444333322221111", | |
| "code" => "555", | |
| "expiry" => "07/2016" | |
| } | |
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
| #Using Symbols as keys | |
| customer = { | |
| name: "Billy Bob", | |
| tel: "(415)555-5555", | |
| } |
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
| defaults = {font: 'Arial', font_size: '12px'} | |
| customer_prefs = {font: 'Helvetica'} | |
| style = defaults.merge customer_prefs |
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
| hsh = { name: "Wallace", favourite: "Vegan Captain Kirk" } |
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 Shell Setup FOR BASH ONLY | |
| Add Tab completion for GIT and the current branch to your terminal prompt | |
| This Process Installs these awesome scripts on a Mac OSX: | |
| https://github.com/git/git/tree/master/contrib/completion | |
| ##Installation: |
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 parallel_assigns | |
| # Parallel Assignment | |
| puts "Parallel assign a and b" | |
| a, b = 1, 2 | |
| puts "a is #{a}" | |
| puts "b is #{b}" | |
| puts "Initializing c and d" |
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 SearchController < ApplicationController | |
| skip_before_filter :verify_authenticity_token | |
| def results | |
| @search_form = SearchForm.new(params.require(:search_form).permit(:q)) | |
| if (@search_form.valid?) | |
| # This sample assumes a model called Contacts with a column field called name | |
| @results = @search_form.search_within (Contacts.all, :name) | |
| end |
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
| var exposed = function (){ | |
| function my_secret() | |
| { | |
| return 'I like unicorns' | |
| } | |
| this.tell_secret = function() | |
| { | |
| return 'Hello! Shhh, but ' + my_secret() + "!"; | |
| } |
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 'fiber' | |
| #https://practicingruby.com/articles/building-enumerable-and-enumerator | |
| module FakeEnumerable | |
| def select | |
| result = [] | |
| each do |value| | |
| result << value if yield(value) | |
| end |
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 falsey_truthy string_test | |
| begin | |
| value = eval string_test | |
| puts "#{string_test} -> '#{value}' is #{value ? 'truthy' : 'falsey'}" | |
| rescue NameError => e | |
| puts e | |
| end | |
| end | |
| tests = [ |
OlderNewer