Skip to content

Instantly share code, notes, and snippets.

View fercreek's full-sized avatar
😎
Coding coding coding

Fernando Contreras fercreek

😎
Coding coding coding
View GitHub Profile
/*
Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.
For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case.
The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y".
Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien".
*/
function mutation(arr) {
count = 0;
arr[0] = arr[0].split("").map(function(x){return x.toLowerCase();}).join("");
var status = arr[1].split("").every(function(e){
function fizzBuzz(val) {
var msg = '';
if (val % 3 == 0) msg += 'Fizz'
if (val % 5 ==0 ) msg +='Buzz'
return (msg.length == 0 ? val : msg) ;
}
for (var i = 1; i <= 100; i++) {
console.log(fizzBuzz(i));
}
@fercreek
fercreek / property.js
Created August 2, 2016 21:52
Object has a given property
var ferObject = {
name: 'Todd',
favouriteDrink: null,
cool: false
};
!!ferObject.name //true
!!ferObject.favouriteDrink //false
!!ferObject.cool //false
!!ferObject.cools //false
@fercreek
fercreek / listeners.js
Created June 7, 2016 15:52 — forked from toddmotto/listeners.js
Automatic unbinding on $scope.$destroy for $rootScope listeners
/*!
* $rootScope listeners, remember to unbind on $destroy
*/
var $rootListeners = {
'transmitProgress': $rootScope.$on('transmit:progress', transmitProgress),
'transmitSuccess': $rootScope.$on('transmit:success', transmitSuccess),
'transmitError': $rootScope.$on('transmit:error', transmitError)
};
// iterate the Object and pass the methods to be called on $destroy
#!/usr/bin/env python
import yaml
def generateHtml(msg):
return '''
<li>
<div class="collapsible-header">
<div class="text--size">{title}</div>
</div>
@fercreek
fercreek / renamePDFs.py
Created May 8, 2016 23:41
Script to rename pdf files
import os
from os import path
def removeDots(filename):
for n in ['.', ' ', ',']:
filename = filename.replace(n, '')
return filename
"use strict";
const barker = (state) => ({
bark: () => console.log('Woof, I am ' + state.name)
})
const driver = (state) => ({
drive: () => state.position = state.position + state.speed
})
const dog = () => {
const sound = 'woof'
return {
talk: () => console.log(sound)
}
}
const sniffles = dog()
sniffles.talk()
import 'babelify/polyfill'
function loadImage(url) {
return new Promise((resolve, reject) => {
let image = new Image()
image.onload = function() {
resolve(image)
}
"use strict";
let categories = [
{id: 'animals', parent: null },
{id: 'mammals', parent: 'animals' },
{id: 'cats', parent: 'mammals' },
{id: 'dogs', parent: 'mammals' },
{id: 'chihuahua', parent: 'dogs' },
{id: 'labrador', parent: 'dogs' },
{id: 'persian', parent: 'cats' },