Skip to content

Instantly share code, notes, and snippets.

View hungryzi's full-sized avatar

Zi Huong Vu hungryzi

  • Vancouver, Canada
View GitHub Profile
@hungryzi
hungryzi / download_all.js
Created January 30, 2015 04:42
Download All snippet
var links = document.getElementsByTagName('a')
var map = [].map
var hrefs = map.call(links, function(l) {return l.href})
hrefs = hrefs.filter(function(h){ return h.match('mobi')})
for (var i=100; i < 300; i++) {
window.open(hrefs[i])
}

Sex ratio at birth in Vietnam

@hungryzi
hungryzi / README.md
Last active November 17, 2016 22:33
Vietname population density by provinces/cities

Visualizing Vietname population density by provinces/cities.

@hungryzi
hungryzi / gist:4e38404f04f4647355c3
Last active August 29, 2015 14:05
Paypal integration

Sandbox Setup

PayPal

Go to PayPal's Developer Website, sign in with your PayPal account, click "Applications" then "Sandbox Accounts" and create a new "Business" account. Once the account is created, click on the triangle next to its email address, then "Profile". The "API Credentials" tab will provide your API credentials (probably). If this tab is blank, try refreshing the page.

You will also need a "Personal" account to test the transactions on your site. Create this in the same way, finding the account information under "Profile" as well. You may need to set a password in order to be able to log in to PayPal's sandbox for this user.

Spree Setup

@hungryzi
hungryzi / Cheffile
Last active December 30, 2015 05:39
site "http://community.opscode.com/api/v1"
cookbook "pivotal_workstation" , :git => "https://github.com/pivotal/pivotal_workstation"
cookbook "neo_workstation" , :git => "https://github.com/neo/neo_workstation"
@hungryzi
hungryzi / phpunit.rb
Last active December 24, 2015 15:59 — forked from itspriddle/phpunit.rb
require 'formula'
class Phpunit < Formula
homepage 'http://www.phpunit.de/manual/current/en/index.html'
url 'https://phar.phpunit.de/phpunit.phar'
sha1 'dc693b34a62644f61cfc01a22d9654ff4b8764af'
version 'HEAD'
def install
bin.install "phpunit.phar" => "phpunit"
@hungryzi
hungryzi / secret_token.rb
Created August 25, 2013 09:52
Load secret_token from ENV
secret = ENV['SECRET_TOKEN']
if secret.length < 30
raise "Secret token cannot be loaded"
else
Rails.application.config.secret_token = secret
end
@hungryzi
hungryzi / add_a_record.js
Last active January 23, 2018 15:25
IndexedDB talk
var request = indexedDB.open('beer_czar');
request.onsuccess = function(event){
var db = event.target.result;
var transaction = db.transaction(['beer'], 'readwrite');
transaction.oncomplete = function(event){
// handle transaction errors here
}
var beerObjectStore = transaction.objectStore('beer');
var operation = beerObjectStore.add(beer)
@hungryzi
hungryzi / inventory-naive-indices1.coffee
Last active December 11, 2015 14:49
Indices for naive modelling
@schema = IndexedDBBackbone.describe('experiment1')
.createStore('catalog_items', keyPath: 'id')
.createStore('inventory_items', keyPath: 'id')
.createIndex('catalog_items', 'serializedIndex', 'serialized', unique: false)
.createIndex('catalog_items', 'categoryIndex', 'category_id', unique: false)
.createIndex('inventory_items', 'locationIndex', 'location_id', unique: false)
.createIndex('inventory_items', 'catalogItemIndex', 'catalog_item_id', unique: false)
@hungryzi
hungryzi / inventory-2nd-try-indices.coffee
Last active December 11, 2015 14:49
Indices for 2nd try modelling
@schema = IndexedDBBackbone.describe('experiment1')
.createStore('catalog_items', keyPath: 'id')
.createStore('inventory_items', keyPath: 'id')
.createIndex( 'catalog_items',
'queryIndex',
['serialized',
'category_id',
'locations_with_quantity'],
{ unique: false, multiEntry: true })
.createIndex('inventory_items', 'catalogItemIndex', 'catalog_item_id', unique: false)