Skip to content

Instantly share code, notes, and snippets.

View alexpchin's full-sized avatar

Alex Chin alexpchin

View GitHub Profile
@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 / mongo-autostart-osx.md
Created January 7, 2018 00:34 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

@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 / 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 / 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
@alexpchin
alexpchin / LICENSE
Created July 15, 2016 12:41 — forked from ifraixedes/LICENSE
AWS lambda handler which download images from S3, resizes them and upload the new ones to S3; tested with mocha, chai, sinon and proxyquire
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004
(http://www.wtfpl.net/about/)
Copyright (C) 2015 Mario Mendes (@hyprstack)
Copyright (C) 2015 Ivan Fraixedes (https://ivan.fraixed.es)
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@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
@alexpchin
alexpchin / gist:cbb87a3bf56c4b7754fc
Created February 19, 2016 00:54 — forked from fnakstad/gist:5383750
Attaches a function called "seed" to Mongoose models, which basically wraps the create function, but returns a promise. This way seeding can be done through a promise chain.
var mongoose = require('mongoose');
mongoose.Model.seed = function(entities) {
var promise = new mongoose.Promise;
this.create(entities, function(err) {
if(err) { promise.reject(err); }
else { promise.resolve(); }
});
return promise;
};
@alexpchin
alexpchin / customer.js
Created February 15, 2016 22:59 — forked from swaj/customer.js
A mongoose model that takes advantage of the handy invalidate method to run multiple validations
var mongoose = require('./db-connect'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
uuid = require('node-uuid'),
Validator = require('validator').Validator,
val = new Validator(),
bcrypt = require('bcrypt');
Validator.prototype.error = function(msg) { return false; };
@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>