ensure that you have rails 4.2 like envioroment
git clone git://github.com/RailsApps/rails-stripe-membership-saas.git
cd rails-stripe-membership-saas
bundle
rake db:migrate
ensure that you have rails 4.2 like envioroment
git clone git://github.com/RailsApps/rails-stripe-membership-saas.git
cd rails-stripe-membership-saas
bundle
rake db:migrate
json_payload = | |
"{ | |
\"orders\": [ | |
{ | |
\"id\": \"R123456789\", | |
\"status\": \"complete\", | |
\"channel\": \"spree\", | |
\"email\": \"spree@example.com\", | |
\"currency\": \"USD\", | |
\"placed_on\": \"2017-03-10T15: 20: 43Z\", |
# The traverse iterator will iterate over the tree in the same | |
# breadth-first order. | |
class Tree | |
attr_accessor :left | |
attr_accessor :right | |
attr_accessor :data | |
def initialize(x=nil) | |
@left = @right = nil |
# We have a pole with a certain number of disks staked on it; | |
# call this the source pole. We want move all of these to the | |
# destination pole, using a third (auxiliary) pole as an | |
# intermediate resting place. The catch is that you can move | |
# only one disk at the time, and you cannot ever place a larger | |
# disk onto a smaller one. | |
def towers(list) | |
while !list.empty? | |
n, src, dst, aux = list.pop |
# IP V4 Address are four decimal numbers separated by periods, | |
# each number ranging from 0 to 255. | |
number = /(\d|[01]?\d\d|2[0-4]\d|25[0-5])/ | |
expression = /^(#{number}\.){3}#{number}$/ | |
sample_text = "10.123.80.202" | |
sample_text =~ expression |
# Extracts the keyword and the value. The assumptions are that | |
# the keyword oor attribute is a single word, the value extends | |
# to the end of the line, and the equal sign may be surrounded | |
# by whitespace. | |
expression = /(\w+)\s*=\s*(.*?)$/ | |
sample_text = "color = blue" | |
sample_text =~ expression |
def quicksort(arr, first, last) | |
return arr unless first < last | |
p_index = partition(arr, first, last) | |
quicksort(arr, first, p_index - 1) | |
quicksort(arr, p_index + 1, last) | |
arr | |
end | |
def quickselect(arr, first, last, i) | |
return arr[first] if first == last |
# Andrew's monotone chain convex hull algorithm constructs the convex hull | |
# of a set of 2-dimensional points in O(n\log n) time. | |
# It does so by first sorting the points lexicographically (first by x-coordinate, | |
# and in case of a tie, by y-coordinate), and then constructing upper and lower | |
# hulls of the points inO(n) time. | |
# An upper hull is the part of the convex hull, which is visible from the above. | |
# It runs from its rightmost point to the leftmost point in counterclockwise order. | |
# Lower hull is the remaining part of the convex hull. |