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
class Array | |
def bucketize(n) | |
return [] if (buckets = n.to_i) <= 0 | |
j = length / buckets.to_f | |
result = each_with_index.chunk { |_, i| (i / j).floor }.map { |_, v| v.map(&:first) } | |
result << [] until result.length == buckets | |
result | |
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
class Contractor < ActiveRecord::Base | |
.... | |
def stripe_recipient | |
return nil if stripe_recipient_id.nil? | |
Stripe::Recipient.retrieve stripe_recipient_id | |
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
class BankDetailsController < ApplicationController | |
before_filter :set_recipient | |
def show | |
end | |
def update | |
if @recipient.present? && @recipient.verified | |
update_bank_account | |
else |
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
= form_tag({}, {:method => :put}) do | |
- if @recipient.present? && @recipient.verified | |
= text_field_tag 'routing_number' | |
= text_field_tag 'account_number' | |
- else | |
= text_field_tag 'name' | |
= text_field_tag 'tax_id' |
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
stripe_transfer = Stripe::Transfer.create( | |
:amount => transaction_amount_in_cents, | |
:currency => 'usd', | |
:recipient => contractor.stripe_recipient_id, | |
:description => '' | |
) | |
#we store this after creating the transfer | |
stripe_tranfer.id |
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
require 'set' | |
# n^2 solution | |
nums = (-50..50).to_a | |
s = Set.new(nums) | |
triplets_adding_to_zero = [] |
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
{ | |
"auto_complete": true, | |
"auto_complete_commit_on_tab": true, | |
"auto_complete_delay": 0, | |
"auto_complete_selector": "source - comment", | |
"auto_complete_size_limit": 4194304, | |
"auto_complete_triggers": | |
[ | |
{ | |
"characters": "<", |
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
file_name = ARGV[0] | |
puts file_name | |
def rip_num(part) | |
part.split(" ").first.to_i | |
end | |
File.open(file_name) do |f| | |
insertions = 0 |
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
install: --no-rdoc --no-ri | |
update: --no-rdoc --no-ri |
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
alias ll="ls -al" | |
alias gch="git checkout" | |
alias gb="git branch" | |
alias gs="git status" | |
alias gp="git pull" | |
alias gf="git fetch" | |
alias gr="git rebase" | |
alias gl="git log" | |
alias gd="git diff" | |
alias gdo="git diff origin/master" |
OlderNewer