Skip to content

Instantly share code, notes, and snippets.

View k2052's full-sized avatar
🦄
awesome

K k2052

🦄
awesome
View GitHub Profile

First list all your installed NPM modules with:

$ npm list -g --depth=0 > installNPMModules.sh

Then you could just multiline edit or regex stuff from:

First step, choose the authority. Decide if you are syncing from your app to stripe or from stripe to your app. Usually in most cases it works best to choose your own DB as the authority, then you update Stripe based on what is in your DB.

Store the plans in the DB, update those plans in response to events or hooks. The simplest hooks are just your auth flow, user registration, user subscribes etc. If you can, just manually add a call to stripe at every point where a plan changes. That will scale just fine for 90% of cases. But if you have a large app with a lot of contributors you will need to figure out a place/mental model where all the sync to Stripe code goes and how it works. Usually the best for it is some sort of events or job queue.

I found the best model for when you have to sync updates to another place is events. It scales a lot better. Otherwise eventually you end with all this spaghetti code and cron scripts keeping things in sync. You end up with all sorts of questions eventually like, if I

@k2052
k2052 / README.md
Last active August 29, 2015 14:17
RethinkDB changefeeds with ruby, celluloid, and angelo
$ brew install rethinkdb
$ gem install angelo
$ gem install rethinkdb

You'll want something for testing:

$ npm install -g wscat
@k2052
k2052 / example.md
Last active August 29, 2015 14:11
Turns a Markdown list into a directory structure. Very messy and not nearly enough safety checks (there are none) but it works for my use case
  • animals
    • dogs
      • dog.rb
    • penguins
  • humans
  • cats.md
sudo wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xzf ta-lib-0.4.0-src.tar.gz or sudo tar -xzf ta-lib-0.4.0-src.tar.gz
cd ta-lib/
./configure LDFLAGS="-lm" -prexix="/usr/local"
make
sudo make install
@k2052
k2052 / simpleDataBinder.coffee
Last active December 31, 2015 16:19
Simple Data Binding in CoffeeScript using jQuery. jsFiddle] at http://jsfiddle.net/L8JkR/2/
class DataBinder extends jQuery
pubSub: null
constructor: (objectid) ->
@pubSub = $ {}
attribute = "data-bind-#{objectid}"
message = "#{objectid}:change"
$(document).on "change", "[#{attribute}]", (event) =>
$elem = $(event.target)
@k2052
k2052 / padrino-zurb.rb
Last active December 27, 2015 17:19
Padrino + MongoMapper + Zurb Foundation + Compass
project :orm => :mongomapper, :test => :rspec, :renderer => :slim
require_dependencies(
'puma', 'imperator', 'oj', 'multi_json',
# Assets
'sprockets', 'sprockets-sass',
'coffee-script', 'uglifier',
'padrino-pipeline',
@k2052
k2052 / CodeMirror-github.sass
Created October 5, 2013 22:49
Github Like Codemirror theme
.CodeMirror.cm-s-github
.CodeMirror-activeline-background
background: rgba(255, 255, 255, 0.031)
.CodeMirror-gutters
background: #f0f0f0x
border-right: 1px solid #4D4D4D
box-shadow: 0 10px 20px black
.CodeMirror-linenumber
@k2052
k2052 / cariosample.moon
Created August 8, 2013 22:41
lgi + moonscript + cario
lgi = require 'lgi'
cario = lgi.cairo
Gtk = lgi.Gtk
class CairoSample
@size: 30
new: () =>
@window = Gtk.Window(title: 'cats', on_destroy: Gtk.main_quit)
@window\set_default_size(450, 550)
@k2052
k2052 / words.k2052.me-import.rb
Created April 3, 2013 00:08
Creates a post from a passed in markdown file with meta data
#!/usr/bin/env ruby
require 'metadown'
require 'rest_client'
file_name = ARGV[0]
url = ARGV[1]
url ||= 'http://words.k2052.me/jots'
source = File.read(file_name)