Skip to content

Instantly share code, notes, and snippets.

View the-creature's full-sized avatar

Liccy Creature the-creature

  • Fuentes Innovation
  • Los Angeles, CA
View GitHub Profile
@the-creature
the-creature / gist:d8fa4dbec135dfd6b63e
Created December 10, 2014 05:10
Show Current GIT Branch on terminal
# add to .profile file
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
[
{"code":"ab","name":"Abkhaz","nativeName":"аҧсуа"},
{"code":"aa","name":"Afar","nativeName":"Afaraf"},
{"code":"af","name":"Afrikaans","nativeName":"Afrikaans"},
{"code":"ak","name":"Akan","nativeName":"Akan"},
{"code":"sq","name":"Albanian","nativeName":"Shqip"},
{"code":"am","name":"Amharic","nativeName":"አማርኛ"},
{"code":"ar","name":"Arabic","nativeName":"العربية"},
{"code":"an","name":"Aragonese","nativeName":"Aragonés"},
{"code":"hy","name":"Armenian","nativeName":"Հայերեն"},
@the-creature
the-creature / flatten.js
Created February 1, 2017 04:27
es6 flat array
const flatten = arr => arr.reduce(
(a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []
);
testArr = [[1,2,[3]],4]
console.log(flatten(testArr));
@the-creature
the-creature / ES6-filter-map-basic.js
Last active October 8, 2017 16:31
ES6 filter and map basic
const numbers = [1,2,3,4,5,6,7,8,9,10];
const getEvenNumbers = numbers.filter(n => n % 2 === 0);
getEvenNumbers // [2, 4, 6, 8, 10]
const double = getEvenNumbers.map(n => n * 2);
double // [4, 8, 12, 16, 20]
numbers // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const C = [16, 9, 12, 4, 4, 3, 4, 7, 6, 4, 12, 15, 4, 11, 12, 15, 8, 12, 10, 10];
const F = C.map(n => Math.round(n * (9/5)) + 32);
// [61, 48, 54, 39, 39, 37, 39, 45, 43, 39, 54, 59, 39, 52, 54, 59, 46, 54, 50, 50]
const avg = F.reduce((s, e) => s + e, 0) / F.length; //48.05
Math.round(avg) // 48
@the-creature
the-creature / closure.js
Created October 4, 2017 23:21
ES6 quick demo about closure
const a = (type) => {
const t = 'Hi ' + type;
const s = () => { return t;}
return s;
}
const b = a('closure');
b();
@the-creature
the-creature / ES6-filter-split-sort-function.txt
Last active October 8, 2017 16:30
ES6 Filter, Sort, Split function
const sentence = ( p = 'text some txt' ) => p.split(' ').filter(v => !(v.length % 2)).sort((a, b) => a.length - b.length).toString().replace(/\W/g, ' ');
sentence('longer sentence with in to blah!'); // "in to with longer sentence"
@the-creature
the-creature / ES6 and Curry
Created October 24, 2017 05:25
es6Curry.js
const whoAmI = name => field => location =>
name + ' is a ' + field + ' from ' + location;
const first = whoAmI('Liccy Fuentes');
const two = first('Front End Developer');
console.log(two('Florida'));
function curry(fn, ...args1) {
return (...args2) => fn(...args1, ...args2);
}
(function() {
var Gallery = (function() {
var stageImageContentTemplate = '';
var stageImageTemplate = '';
var viewMoreTemplate = '';
var modalTemplate = '';
var slideTemplate = '';
var modalSlideTemplate = '';
var modalImageTemplate = '';
[
{
"id": "90ff6571-4941-42a7-8eb3-063331241a20",
"firstName": "Marshall",
"lastName": "Soto",
"age": 29,
"email": "marshallsoto@megall.com",
"active": true,
"lastLogin": "2014-08-07T03:35:08-01:00"
},