Subscriptions with stripe
Code examples use the stripe ruby gem. Most of the links are to stripe's documentation.
![stripe's object model][stripe_object_model_diagram]
To start, create some plans.
Code examples use the stripe ruby gem. Most of the links are to stripe's documentation.
![stripe's object model][stripe_object_model_diagram]
To start, create some plans.
FAYE_TOKEN = 'secretToken' | |
if defined? Rails | |
if Rails.env == 'development' | |
FAYE_URI = "http://#{APP_CONFIG[:nameremoved_service][:host]}:9292/faye" | |
else | |
FAYE_URI = "https://#{APP_CONFIG[:nameremoved_service][:host]}/faye" | |
end |
class AuthenticatedScraper | |
def initialize(args) | |
if args[:session] | |
@cookie_jar = args[:session] | |
@agent = Mechanize.new | |
@agent.cookie_jar = load_session(@cookie_jar) | |
else | |
@agent = Mechanize.new | |
@agent.login(args[:username], args[ password]) | |
end |
/* Example tokeninput style #1: Token vertical list*/ | |
ul.token-input-list { | |
overflow: hidden; | |
height: auto !important; | |
height: 1%; | |
width: 400px; | |
border: 1px solid #999; | |
cursor: text; | |
font-size: 12px; | |
font-family: Verdana; |
require 'md5' | |
class Chargify::HooksController < ApplicationController | |
protect_from_forgery :except => :dispatch | |
before_filter :verify, :only => :dispatch | |
EVENTS = %w[ test signup_success signup_failure renewal_success renewal_failure payment_success payment_failure billing_date_change subscription_state_change subscription_product_change ].freeze | |
def dispatch | |
event = params[:event] |
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep -B6 bindings:.*: |
##Simply annoying Tweets
Annoyingly extended words (4+ of the same letter in a phrase): OOOOHHHHMMMMYYYYGGGGOOOODDDD
([a-z])/1{4}
Tweet w/ just a single hashtag: #omgthissucks
^ *#[^ ]+$
Someone recently asked the following question in the discussion forum of the Rubyists LinkedIn group: What separates a junior Rails developer from a senior one? | |
My response follows. Join us at http://www.linkedin.com/groups?gid=120725 to weigh in on this and other topics of interest to Rubyists. As of today there are almost 1,200 members, including numerous movers and shakers in the Ruby and Rails communities. | |
“Distinguishing between junior and senior people in the Rails world is not so different from making the distinction in other web development environments. | |
“Junior Rails people have not dealt with scaling issues to the degree that senior people have. Getting a public-facing Rails application to perform under significant stress is more challenging than doing the same with other building materials such as PHP. Senior people know how to performance-test Rails applications, where to look for bottlenecks, and how to eliminate them one after another until performance is acceptable in real conditions. The Ra |
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common | |
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libatk1.0-dev libx11-dev libxpm-dev libxt-dev | |
#Optional: so vim can be uninstalled again via `dpkg -r vim` | |
sudo apt-get install checkinstall | |
sudo rm -rf /usr/local/share/vim /usr/bin/vim | |
cd ~ |
My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.
As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.
I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.
So, in order to profile your worker, add this to your Sidekiq configuration:
if ENV["PROFILE"]