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
@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
@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
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));
}
/*
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){
const fs = require('fs')
const highland = require('highland')
highland(fs.createReadStream('customers.csv', 'utf8'))
.split()
.map(line => line.split(','))
.map(parts => ({
name: parts[0],
numPurchases: parts[1]
}))
@fercreek
fercreek / file.controller.js
Created October 12, 2016 06:24
Update multiple files from AngularJs
angular.module('starter.controllers', [])
.controller('TestCtrl', TestCtrl);
TestCtrl.$inject = ['updateService'];
function TestCtrl(updateService){
var vm = this;
vm.addImage = addImage;
vm.data = {};
function addImage() {
@fercreek
fercreek / README-Template.md
Created March 23, 2017 16:58 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Keybase proof

I hereby claim:

  • I am fercreek on github.
  • I am fercreek (https://keybase.io/fercreek) on keybase.
  • I have a public key ASCF38-JycSdYOlQSC69estGRE1bpmelkV3U_V_McTs5aAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am fercreek on github.
  • I am fercreek (https://keybase.io/fercreek) on keybase.
  • I have a public key ASCF38-JycSdYOlQSC69estGRE1bpmelkV3U_V_McTs5aAo

To claim this, I am signing this object:

@fercreek
fercreek / geckodriver-install.sh
Created May 16, 2018 20:52 — forked from cgoldberg/geckodriver-install.sh
download and install latest geckodriver for linux or mac (selenium webdriver)
#!/bin/bash
# download and install latest geckodriver for linux or mac.
# required for selenium to drive a firefox browser.
install_dir="/usr/local/bin"
json=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest)
if [[ $(uname) == "Darwin" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("macos"))')
elif [[ $(uname) == "Linux" ]]; then
url=$(echo "$json" | jq -r '.assets[].browser_download_url | select(contains("linux64"))')