Skip to content

Instantly share code, notes, and snippets.

View oddlyzen's full-sized avatar
:electron:
Working with Electron

Mark Coates oddlyzen

:electron:
Working with Electron
View GitHub Profile

Array<T>

Legend:

  • ✏️ method changes this.
  • 🔒 method does not change this.

Array<T>.prototype.*:

  • concat(...items: Array): T[] 🔒 ES3
require "bundler/capistrano"
server "96.126.100.112", :web, :app, :db, primary: true
set :application, "capteste"
set :user, "deployer"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :port, "3030"
@oddlyzen
oddlyzen / deploy.rb
Created February 20, 2014 20:12 — forked from andrebras/deploy.rb
set :application, "sprai"
# RVM integration
# http://beginrescueend.com/integration/capistrano/
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, "1.9.2-p290"
set :rvm_type, :user
# Bundler integration (bundle install)
@oddlyzen
oddlyzen / toys.rb
Created February 13, 2014 18:21 — forked from lucapette/toys.rb
class Array
def self.toy(n=10, &block)
block_given? ? Array.new(n,&block) : Array.new(n) {|i| i+1}
end
end
class Hash
def self.toy(n=10)
Hash[Array.toy(n).zip(Array.toy(n){|c| (96+(c+1)).chr})]
end
# app/models/my_model.rb
module MyApp
module Model
def self.included(base)
base.send :include, Mongoid::Document
base.send :include, Mongoid::Timestamps
base.send :include, ActiveAdmin::Mongoid::Patches
end
end
Rails3 - CheatSheet - CommandLine
rails new ApplicationName – Create a new application
rails _3.0.9_ new ApplicationName – Create a new application with a specific version of rails
rails generate/g model ModelName – Creates a model with the specified model_name
rails generate/g controller ControllerName – Creates a controller with the specified controller_name
rails generate/g migration MigrationName – Creates a migration with the specified migration_name
rails generate/g scaffold ModelName ControllerName – A shortcut for creating your controller, model and view files etc.
rails destroy controller ControllerName – Destroys the created controller and its related file.
rails destroy model - Destroys the created model and its related file.
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@oddlyzen
oddlyzen / rspec-syntax-cheat-sheet.rb
Created December 12, 2011 16:56 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")

Note to Self

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy

<script>
// test for localStorage support
if(('localStorage' in window) && window['localStorage'] !== null){
var f = document.getElementById('mainform');
// test with Ruby if the form was sent (the submit button has the name "sent")
<% if params[:sent] %>
// get the HTML of the form and cache it in the property "state"
localStorage.setItem('state',f.innerHTML);
// if the form hasn't been sent...
<% else %>