-
Add this to your Rails app's
Gemfile
:gem 'requirejs-rails'
and then run
bundle install
on the command line.
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
# Want to pass in a hash or instance of object. Was hoping to avoid is_a? or creating a new object but | |
# think that can only be done with is_a? or overriding new. Also, I might be missing the point as | |
# avoiding is_a? should mean I am using Duck Typing but if I'm using Duck Typing then I shouldn't be | |
# checking object equality anyway. See RSpec test for details. | |
class MyClass | |
attr_accessor :name | |
attr_accessor :description | |
def initialize(args = {}) |
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 | |
require "net/http" | |
require "json" | |
CODESHIP_API_KEY = "PUT_YOUR_CODESHIP_API_KEY_HERE".freeze | |
origin_remote_url = `git config --get remote.$(git config --get branch.master.remote).url`.chomp | |
current_project_name = %r{(?:\:|\/)(.+)\.git$}.match(origin_remote_url)[1] | |
current_branch_name = `git rev-parse --abbrev-ref HEAD`.chomp |
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 | |
require "nokogiri" | |
require "net/http" | |
courtenay_place = 5002 # Get your stop number from the metlink.co.nz website | |
buses_i_care_about = %w(52 56 57 58) | |
# .../departures returns 20 results |
Good blog post on promises: https://developers.google.com/web/fundamentals/getting-started/primers/promises
- A built-in part of the JS language since ES6
- Native in most browsers now (except IE11 and older, Android 4.4 and older)
- Available everywhere using JS implementation
- http://caniuse.com/#search=promises
Why promises
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 Part2 | |
# 1 | |
# 2 3 4 | |
# 5 6 7 8 9 | |
# A B C | |
# D | |
class State | |
def go_u; self; end | |
def go_d; self; end | |
def go_l; self; 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
#!/bin/bash | |
# This script can be used in "run & hope" mode or you can use it as a recipe to | |
# do things manually - you probably want the latter if you really care about | |
# the data in your databases. | |
# Happy hacking | |
# /Eoin/ | |
# Tell bash to stop if something goes wrong | |
set -e |
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Started GET "/numbers/" for 127.0.0.1 at 2019-01-19 17:25:17 +1300
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Processing by PagesController#show as HTML
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Parameters: {"slug"=>"numbers"}
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Setting Load (1.4ms) SELECT "settings".* FROM "settings" WHERE "settings"."key" = $1 LIMIT $2 [["key", "footer"], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Page Load (11.2ms) SELECT "pages".* FROM "pages" WHERE "pages"."id" = $1 ORDER BY "pages"."order" ASC LIMIT $2 [["id", 11], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Page Load (3.2ms) SELECT "pages".* FROM "pages" WHERE "pages"."slug" = $1 ORDER BY "pages"."order" ASC LIMIT $2 [["slug", "numbers"], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Rendering pages/numbers.html.haml within layouts/application
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
# Add this to your ~/.zshrc (it only works in zsh not bash AFAIK) | |
# ##################################### | |
# A fast way of chdir to a code project | |
function work { | |
cd ~/Code/repos/$1 | |
} | |
function _work() { | |
local state |