Skip to content

Instantly share code, notes, and snippets.

@alvinthen
alvinthen / transform-symbol-member.js
Created November 12, 2016 16:26
Replace node_modules/babel-preset-react-native/transforms/transform-symbol-member.js to transform RxJS v5 on React Native
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*/
/* eslint-disable */
'use strict';
/*eslint consistent-return: 0*/
@alvinthen
alvinthen / README.md
Last active November 22, 2016 18:28
Add fields to devise model

Add name to User model

rails g migration AddNameToUser name:string

Add devise's registrations views to our project

rails g devise:views users -v registrations
@alvinthen
alvinthen / users.yml
Created November 22, 2016 19:13
Devise fixtures
one:
name: One
email: one@one.com
encrypted_password: <%= Devise::Encryptor.digest(User, 'password') %>
two:
name: Two
email: two@two.com
encrypted_password: <%= Devise::Encryptor.digest(User, 'password') %>
@alvinthen
alvinthen / README.md
Created November 22, 2016 19:50
Rails image upload using carrierwave and fog

Add gems

gem 'carrierwave',             '0.11.2'
gem 'mini_magick',             '4.5.1'
gem 'fog',                     '1.38.0'

Run rails g uploader Image

@alvinthen
alvinthen / README.md
Created December 19, 2016 11:49
Convert .mov to .gif with speed up and reduced file size
mkdir output
ffmpeg -i Untitled.mov -vf scale=640:-1 -r 3 output/ffout%3d.png
convert -delay 1 -loop 0 output/ffout*.png output/output.gif     
convert output/output.gif -fuzz 10% -layers Optimize output/result.gif
@alvinthen
alvinthen / README.md
Last active January 6, 2017 14:41
Rails minitest and guard setup

Add gems

group :test do
  gem 'rails-controller-testing', '0.1.1'
  gem 'minitest-reporters',       '1.1.9'
  gem 'guard',                    '2.13.0'
  gem 'guard-minitest',           '2.4.4'
end
@alvinthen
alvinthen / material-typography.txt
Last active March 6, 2017 07:22
Material typography
display4: 7rem 112px light 300
display3: 3.5rem 56px regular 400
display2: 2.813rem 45px regular 400
display1: 2.215rem 34px regular 400
headline: 1.5rem 24px regular 400
title: 1.25rem 20px medium 500
subheading2: 1rem 16px regular 400
subheading1: .938rem 15px regular 400
body2: .875rem 14px medium 500
body1: .875rem 14px regular 400
@alvinthen
alvinthen / .eslintrc
Created October 25, 2017 06:21
eslint config
{
"parser": "babel-eslint",
"plugins":[
"flowtype"
],
"extends": [
"airbnb",
"plugin:flowtype/recommended"
],
"rules": {
@alvinthen
alvinthen / settings.json
Last active February 20, 2018 08:46
VSCode config
// Place your settings in this file to overwrite the default settings
{
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.fontSize": 16,
"editor.fontWeight": "400",
"editor.renderControlCharacters": false,
"editor.renderWhitespace": "all",
"editor.rulers": [100],
"editor.scrollBeyondLastLine": false,
@alvinthen
alvinthen / index.js
Created April 2, 2018 15:39
Kurento browser
var ws = new WebSocket('ws://localhost:8080');
var videoInput;
var videoOutput;
var webRtcPeer;
var state = null;
const I_CAN_START = 0;
const I_CAN_STOP = 1;
const I_AM_STARTING = 2;