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
(function(websocketClient, $, undefined) { | |
var PING_INTERVAL = 42000, | |
RECONNECT_INTERVAL = 10000, | |
WEBSOCKET_URL = window.location.host + '/websocket'; | |
var config, reconnectInterval, keepAliveInterval, dispatcher; | |
websocketClient.init = function(websocketConfig) { | |
config = websocketConfig; | |
setupDispatcher(); | |
}; |
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
GUESS_RANGE = 100 | |
guessNumber = rand(GUESS_RANGE) | |
puts "Guess the number! (Hint: between 0 and #{GUESS_RANGE})" | |
guessCount = 0 | |
while (userGuess = gets.to_i) != guessNumber # keep getting more numbers | |
# give out hints to the user | |
puts 'Too high' if userGuess > guessNumber |
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
number = rand(10) | |
puts 'Guess the number!' | |
input = 'input number' | |
while input != number | |
input = gets.to_i # keep getting more numbers | |
# give out hints to the user | |
if input > number | |
puts 'Too high' | |
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
param[:attribute] = true | |
# model passes validation as model.attribute = true |
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
has_many model_B | |
before_save set_model_b_attributes | |
def set_model_b_attributes | |
self.bs.each do |b| | |
b.value = self.value | |
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
def set_new_name_on_items? | |
success = ActiveRecord::Base.transaction do | |
model.items.each do |i| | |
i.name = 'new name' | |
i.save or raise ActiveRecord::Rollback | |
end | |
!!success | |
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
pg_restore: executing SEQUENCE SET key_configurations_id_seq | |
pg_restore: processing data for table "kiosk_scans" | |
out of memory |
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
def refund | |
self.items | |
ActiveRecord::Base.transaction do | |
self.items.each { |i| i.update!(refund: true) } | |
end | |
end | |
def refund_v2 | |
refundable_items = self.items.where(refund: false) |
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
gem 'stripe', '1.31.0' | |
require 'stripe' | |
Stripe.api_key = <insert API key here> | |
token = Stripe::Token.create( | |
:card => { | |
:number => "4242424242424242", | |
:exp_month => 3, | |
:exp_year => 2017, | |
:cvc => "314" |
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
################### | |
# Prefix key setup | |
################### | |
set -g prefix C-a # remap prefix to Control + a --> i'm old that way. | |
# bind 'C-a C-a' to type 'C-a' | |
bind a send-prefix # send 'C-a' into terminal app by typing: 'C-a a' | |
bind C-a last-window # bounce between windows just by typing 'C-a C-a' | |
unbind C-b # get rid of C-b as prefix | |
######################## |
OlderNewer