Skip to content

Instantly share code, notes, and snippets.

:octocat:
#building

Leon Gaban leongaban

:octocat:
#building
Block or report user

Report or block leongaban

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@leongaban
leongaban / dynamicPropertyDestructuring.js
Created Jan 17, 2018
Dynamic Property Destructuring O_O
View dynamicPropertyDestructuring.js
const obj = { "foo": "bar" };
const p = "foo";
const { [p]: val } = obj;
console.log(val);
> "bar"
// Real world
const { [f]: param = false } = getContextParams(CONTEXT);
@leongaban
leongaban / update-using.git
Last active Jan 4, 2018
git update-using
View update-using.git
update-using = "!f(){ CUR_BRANCH=$(git rev-parse --abbrev-ref HEAD); git checkout "$1" && git pull && git push --no-verify origin "$1":"$1" && git checkout $CUR_BRANCH && git rebase "$1"; }; f"
# 1) Grabs the name of the branch you're on
# 2) Checks out the REL branch you specified
# 3) Updates the REL branch from upstream
# 4) Hydrates the REL branch on origin
# 5) Checks out your feature branch again [from step 1]
# 6) Begins rebasing REL onto your feature branch
# Set upstream branch
# git branch --set-upstream-to upstream/REL_ENUDDEN
@leongaban
leongaban / getQuery.js
Created Oct 31, 2017
Query url & array
View getQuery.js
/* eslint-disable import/prefer-default-export */
const queryArray = arr => arr.map((v) => {
const a = v.split('='); // Split by the kvp separator (=)
return {
name: a.shift(), // Grab text before the first equal sign (the key)
value: a.join('=') // Grab the value (everything after the first equals)
};
});
@leongaban
leongaban / redux.js
Created Oct 30, 2017
cleanMapStateToProps function for redux
View redux.js
/* eslint-disable import/prefer-default-export */
import { initialStates } from '../reducers';
const defaultPropDef = {
value: null,
writable: false,
configurable: true,
enumerable: true
};
@leongaban
leongaban / pre-push
Created Sep 22, 2017
githooks pre-push
View pre-push
#!/bin/sh
yarn run test-eslint
RESULT=$?
[ $RESULT -ne 0 ] && exit 1
yarn run test-jest
RESULT=$?
[ $RESULT -ne 0 ] && exit 1
exit 0
@leongaban
leongaban / environment.js
Created Jun 12, 2017
Get environment variable into node and create a js file
View environment.js
const environment = process.env.NODE_ENV;
const stream = fs.createWriteStream("src/services/environment.js");
stream.once('open', function(fd) {
stream.write('const env = "'+environment+'"\n');
stream.write('export default env');
stream.end();
});
@leongaban
leongaban / validate_zipcode.js
Created May 4, 2017
Validate Zipcode in Javascript
View validate_zipcode.js
// http://stackoverflow.com/questions/160550/zip-code-us-postal-code-validation
const validZipcode = (zipcode) => zipcode.match(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
@leongaban
leongaban / formatPhoneNumber.js
Created May 4, 2017
Phone number formatting in Javascript
View formatPhoneNumber.js
const numberVerified = (number) => R.isEmpty(number) ? false : number.match(/^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/);
const formatPhone = (number) => {
// http://stackoverflow.com/questions/6204867/fastest-way-to-remove-hyphens-from-a-string-js
const new_number = number.replace(/-/g, '');
return Number(new_number);
};
@leongaban
leongaban / hyper.js
Created Mar 3, 2017
My HyperTerm gist
View hyper.js
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
View InfiniteScrolling.js
const maxlimitCheck = () => this.tags.length >= TOTAL_TAGS;
const checkScrollLimit = () => {
if (!LIMIT_REACHED) {
const scrollingTrue = true;
PARAMS.start += this.limit;
maxlimitCheck() ? LIMIT_REACHED = true : fetchTags(scrollingTrue);
}
};
You can’t perform that action at this time.