Skip to content

Instantly share code, notes, and snippets.

View alexpchin's full-sized avatar

Alex Chin alexpchin

View GitHub Profile
@alexpchin
alexpchin / cors_rails_4.rb
Last active April 30, 2020 11:09
CORS Rails 4
# ApplicationController
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept, Authorization, Token'
headers['Access-Control-Max-Age'] = "1728000"
@alexpchin
alexpchin / gulpfile.js
Created January 20, 2016 13:56 — forked from edouard-lopez/gulpfile.js
Gulp copy font-awesome files to dist/ directory
'use strict';
// Generated on 2014-04-14 using generator-leaflet 0.0.14
var gulp = require('gulp');
var open = require('open');
var wiredep = require('wiredep').stream;
// Load plugins
var $ = require('gulp-load-plugins')();
@alexpchin
alexpchin / js-cheatsheet.md
Created August 16, 2016 16:57
JS Cheatsheet

JS Cheat Sheet

A selection of JavaScript snippets for your quick perusal when you are dashing between billion-dollar ideas.

Trivial expressions

blah
## Android
Active files: 471
Active lines: 56,744
Total commits: 822
Note: Files matching MIME type image, binary has been ignored
+----------------+--------+---------+-------+--------------------+
| name | loc | commits | files | distribution (%) |
@alexpchin
alexpchin / gist:2ced507ab4640b3bc52483933af56e7b
Last active February 7, 2018 02:08
Convert all js to ts recursively
find . -iname "*.js" -exec bash -c 'mv "$0" "${0%\.js}.ts"' {} \;
@alexpchin
alexpchin / dropzone-directive.js
Created February 13, 2016 23:01 — forked from compact/dropzone-directive.js
AngularJS directive for Dropzone.js
/**
* An AngularJS directive for Dropzone.js, http://www.dropzonejs.com/
*
* Usage:
*
* <div ng-app="app" ng-controller="SomeCtrl">
* <button dropzone="dropzoneConfig">
* Drag and drop files here or click to upload
* </button>
* </div>
@alexpchin
alexpchin / gist:a039af9e1eb93e2f1f26872218d937e5
Created April 27, 2017 08:57
Remove last file from Github
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch FOLDERNAME" -- --all
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
git push --all --force
@alexpchin
alexpchin / Spinning
Created February 16, 2015 15:21
Spinning
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; var DI= document.images; DIL=DI.length; function A(){for(i=0; i < DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5+"px"; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5+"px"}R++}tag=setInterval('A()',5 );document.onmousedown=function(){clearInterval(tag);for(i=0; i < DIL; i++){DI.style.position="static";}}; void(0)
@alexpchin
alexpchin / gist:d524d9358ccdf33ba1c8cd794626df84
Created September 13, 2016 23:44
Multiplied image to png
Here is one thing you can do.
Copy the image you want to multiply. (CtrlA and CtrlC)
Make a new 'Black' color layer and click 'add mask'.
alt-click the Mask icon, so that you can enter to mask edit mode.
Paste your 'multiply' images in the mask (b/w) , and then invert it.
You will have a black layer with your multiply material masked.
You can adjust opacity of that layer to find best looking image. (30~40%?)
If you save it as transparent PNG file, you are done.
@alexpchin
alexpchin / summit-presentation.md
Last active April 25, 2016 19:14
SummitPresentation

London

image


Initial Baseline adoption

  • I taught the initial Baseline trial for WDI14 in London - June 2015