Skip to content

Instantly share code, notes, and snippets.

Working from home


Working from home
View GitHub Profile
View ig-request.js
// node ig-request.js username
// 1. visit
// 2. save it as ${%Y%m%d}-${username}.json and upload it to a Google Cloud Storage Bucket
// 3. Automatically renew cookies so we can continue ot obtain JSONs
// 4. deploy it as a Cloud Function (bonus)
// 5. Health Monitor and logging. (bonus)
const request = require('request');
const fs = require('fs');
View output.yaml
- models:
- name: 1 Series
- year: 2008
- submodel: 1 Series Convertible # Becomes "submodel > modelName"
trim: 128i
- submodel: 1 Series Coupe # Becomes "submodel > modelName"
trim: 128i
- submodel: 1 Series Coupe
View sample.json
"models": [
"id": "BMW_1_Series",
"name": "1 Series",
"niceName": "1-series",
"make": {
"id": 200000081,
"name": "BMW",
"niceName": "bmw"
View 11_algolia_nested_attribute.rb
class Car < ActiveRecord::Base
belongs_to :owner, class_name: 'FormUser', foreign_key: 'user_id'
include AlgoliaSearch
algoliasearch id: :permalink do
attribute :owner do
{ uid: owner.uid }
chrisyeung1121 / 10_AJAX_rebind_event.js
Created Jun 16, 2015
binding will work with AJAX created DOM
View 10_AJAX_rebind_event.js
// Will not work after new DOM created on AJAX
$('.photo-options-hero').on('click', function() {
// Will work after AJAX DOM Creation
$('body').on('click', '.photo-options-hero', function() {
chrisyeung1121 /
Created Apr 28, 2015

Making videos into GIFs on the command-line with gifify I like making gifs.

You also probably like making gifs.

It's a thing we do.

On a regular basis I'll have video from television shows or movies or other video I've taken myself like screencasts that I want to turn into a gif.

Turning video into a gif can be done using online services, but I need a quick way to do it on the command line.

View 9_devise_learning.rb
## << Devise::RegistrationController
### Build an user (resource) object from temporary
build_resource({|k,v| v.present?})
# > #<User id: nil, created_at: nil, updated_at: nil, email: "a@b.c", encrypted_password: "$2a$10$HufMLSGEoWzbwhVO.IRztuvE8NKTrQgaXNZthem3wid...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil>
### :validatable module in devise. (took me three hours)
# ActiveRecord::RecordNotUnique in Users::RegistrationsController#create
# PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_email" DETAIL: Key (email)=() already exists. : INSERT INTO "users" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id"
View 8_ruby_select.rb
def sign_up_params
# If user input :email => '', :password=> nil
puts sign_up_params
# $> {"email"=>"", "password"=>""}
puts{|k,v| v.present?}
chrisyeung1121 /
Last active Aug 29, 2015
Rails Deploying to Heroku Tips

Adding PG to heroku (Database)

don't need to set database.yml, it is set automatically.

heroku addons:add heroku-postgresql:hobby-dev -a carshare-all


chrisyeung1121 /
Created Apr 21, 2015
Sprockets::FileNotFound: couldn't find file 'swiper/dist/js/swiper.jquery.js' with type 'application/javascript'
Sprockets::FileNotFound: couldn't find file 'swiper/dist/js/swiper.jquery.js' with type 'application/javascript'
How to solve?