Skip to content

Instantly share code, notes, and snippets.

View levity's full-sized avatar

Lawrence Wang levity

View GitHub Profile

0x217ba17fd9049fe37abd27222d96bafd833296844e56b07f7c809f7c236610ba

Keybase proof

I hereby claim:

  • I am levity on github.
  • I am lwang (https://keybase.io/lwang) on keybase.
  • I have a public key ASCy3-ThBgbEoTuSBit5xQJxosWcpg_ljf-GRFHqlxSkogo

To claim this, I am signing this object:

// before: store/selectors/getPost.js
const getPost = ormCreateSelector(
state => state,
state => orm.session(state.orm),
(state, props) => props.id,
(state, session, id) => {
try {
const post = session.Post.get({id})
return {
const request = require('request')
const crypto = require('crypto')
const url = 'https://api.bitfinex.com/v1'
const apiKey = '<Your API key here>'
const apiSecret = '<Your API secret here>'
const payload = {
'request': '/v1/account_infos',
'nonce': Date.now().toString()
}
@levity
levity / gist:f0bf0f890d0f5587d6b836d04be169a2
Created February 3, 2017 00:22
yarnpkg.com partial outage
Command: curl -I https://yarnpkg.com/latest.tar.gz
West Coast US:
HTTP/1.1 404 Not Found
Date: Fri, 03 Feb 2017 00:17:42 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=df3a36c097b2974c57d5a70443866f69f1486081062; expires=Sat, 03-Feb-18 00:17:42 GMT; path=/; domain=.yarnpkg.com; HttpOnly
Cache-Control: public, max-age=0, must-revalidate
Verifying I am +lw on my passcard. https://onename.com/lw
@levity
levity / mosql.rake
Created March 25, 2014 22:55
Rake task for MoSQL on Heroku
# This is a simplified version of what we're using in production for drinksoma.com
namespace :mosql do
task :run => :environment do
conf_path = Rails.root.join('config', 'collections.yml')
cmd = "mosql -c #{conf_path} --sql #{ENV['MOSQL_POSTGRES_URI']} --mongo #{ENV['MOSQL_MONGO_URI']}"
IO.popen(cmd) do |child|
trap('TERM') { Process.kill 'INT', child.pid }
$stdout.sync = true
@levity
levity / change.js
Last active January 4, 2016 08:19
editing a page with VoodooPad API
var Page = function(key) {
var page = document.pageForKey(key),
data = page.dataAsAttributedString(),
text = data.mutableString(),
changed = false;
this.write = function(msg) {
changed = true;
text.appendString(msg);
};
@levity
levity / branch_ages.rb
Created January 10, 2013 00:48
list remote branches sorted by age
require 'date'
branch_times = `git remote show origin`.split("\n").grep(/tracked/).map do |line|
name = line.split(' ').first
last_log = `git log -n1 origin/#{name}`
last_time = Date.parse(last_log.split("\n").grep(/^Date/).first.sub(/^Date\s+/, ''))
[name, last_time.to_date]
end.sort_by(&:last)
branch_name_maxlen = branch_times.map(&:first).map(&:size).max
@levity
levity / rspec-syntax-cheat-sheet.rb
Created November 28, 2011 20:10 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")