Skip to content

Instantly share code, notes, and snippets.

View Angelfire's full-sized avatar
👾
Hardcore JavaScript Developer

Andrés Bedoya (SrHart) Angelfire

👾
Hardcore JavaScript Developer
View GitHub Profile
@Angelfire
Angelfire / rsync
Created October 8, 2015 02:58
Copy folder excluding subfolders
rsync -av --exclude='folder1' --exclude='folder2' origin/ dest/
@Angelfire
Angelfire / mapBy.js
Last active January 14, 2016 14:20
Map array data
/*
Create a mapped object by any identifier
example:
var a = [{id:1, name:'a'},{id:2, name:'b'},{id:3, name:'c'}];
a.mapBy('id')
output: [
{1:{id:1,name:'a'}},
{2:{id:2,name:'b'}},
{3:{id:3,name:'c'}}
]
@Angelfire
Angelfire / strip-url.js
Last active January 29, 2019 17:47
strip url UTM
var obj = {};
var strUTM = "https://myapp.com/?utm_source=Facebook&utm_medium=Social&utm_term=pinned-post&utm_content=First-Post-Philly&utm_campaign=Philly-Launch";
strUTM.replace(/^.+\?/, '').split('&').forEach(function (i) { obj[i.split('=')[0]] = i.split('=')[1] })
/*
Object {
utm_source: "Facebook",
utm_medium: "Social",
utm_term: "pinned-post",
@Angelfire
Angelfire / lib.scss
Created June 27, 2016 20:05
SASS mixin for :before and :after background images
@mixin before-after-background($height, $side-width, $before, $after) {
height: $height;
position: relative;
z-index: 1;
&:before, &:after {
content: '';
display: block;
height: $height;
position: absolute;
@Angelfire
Angelfire / replaceregex.js
Last active November 27, 2016 15:47
replace using regex
let format = 'BLACK: 5:00 MIN/KM';
format.replace(/MIN|KM|MI/gi, $1 => $1.toLowerCase());
/**
Challenge
Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty.
Sample Test Cases
Input:"fun&!! time"
Output:"time"
Input:"I love dogs"
@Angelfire
Angelfire / FirstFactorial.js
Last active December 10, 2018 21:46
Factorial
/**
Challenge
Factorial
Sample Test Cases
Input: 1
Output: 1
Input: 4
@Angelfire
Angelfire / FirstReverse.js
Created October 17, 2018 01:45
Reverse string
/**
Challenge
Using the JavaScript language, have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order. For example: if the input string is "Hello World and Coders" then your program should return the string sredoC dna dlroW olleH.
Sample Test Cases
Input:"coderbyte"
Output:"etybredoc"
Input:"I Love Code"
@Angelfire
Angelfire / graphql-basic.js
Last active December 10, 2018 21:42
Very Basic GraphQL
const {
GraphQLObjectType,
GraphQLString,
GraphQLSchema,
graphql
} = require('graphql');
const schema = new GraphQLSchema({
query = new GraphQLObjectType({
name: 'Query',
@Angelfire
Angelfire / getRandomNumber.js
Created December 11, 2018 15:09
Get a random integer, between two integers
// https://stackoverflow.com/questions/4959975/generate-random-number-between-two-numbers-in-javascript
getRandomNumber = function(min, max) {
min = typeof(min) === 'number' && min % 1 === 0 ? min : 0;
max = typeof(max) === 'number' && max % 1 === 0 ? max : 0;
return Math.floor(Math.random() * (max - min + 1) + min);
}