This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(number){ | |
console.log(number); // 2 | |
number = 1; | |
console.log(arguments[0]); // 1 | |
}(2)); | |
(function(number){ | |
"use strict"; | |
console.log(number); // 2 | |
number = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Just in case is not supported or not included by your framework | |
//*************************************************** | |
Array.prototype.some = function(fn, thisObj) { | |
var scope = thisObj || window; | |
for ( var i=0, j=this.length; i < j; ++i ) { | |
if ( fn.call(scope, this[i], i, this) ) { | |
return true; | |
} | |
} | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($_GET['key'] == $_SESSION['hash_key']) { | |
//has key validation passed | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertir($fecha) { | |
$months = array(); | |
$months [] = "Enero"; | |
$months [] = "Febrero"; | |
$months [] = "Marzo"; | |
$months [] = "Abril"; | |
$months [] = "Mayo"; | |
$months [] = "Junio"; | |
$months [] = "Julio"; | |
$months [] = "Agosto"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function injector (objects) { | |
function functionArgsName(fn) { | |
var fragment; | |
fn = fn.toString(); | |
//remove comments | |
fn = fn.replace(/(\/\*([\s\S]*?)\*\/)|(\/\/(.*)$)/gm,""); | |
fragment = fn.match(/function\s*\w*\s*\((.*?)\)/)[1]; | |
if (!/^[\s]*$/g.test(fragment)) { | |
return fragment.replace(/(\s)/g,"").split(","); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Observable = Rx.Observable; | |
var button = document.getElementById('button'); | |
var clicks = Observable.fromEvent(button, 'click'); | |
clicks.forEach(function( ){ | |
console.log('click') | |
}); | |
// dispose | |
var Observable = Rx.Observable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getWatchers(root) { | |
root = angular.element(root || document.documentElement); | |
var watcherCount = 0; | |
function getElemWatchers(element) { | |
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope); | |
var scopeWatchers = getWatchersFromScope(element.data().$scope); | |
var watchers = scopeWatchers.concat(isolateWatchers); | |
angular.forEach(element.children(), function (childElement) { | |
watchers = watchers.concat(getElemWatchers(angular.element(childElement))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Notes from funfunfunction videos | |
/* | |
Functional programming | |
According to the video FP should improve your code, less time and more understandable, in javascript functions are values | |
*/ | |
// functions can be assigned to variables | |
var triple = function (x) { | |
return x * 3; | |
} | |
var waffle = triple; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mutators | |
// push , pop, shift, unshift | |
var array = []; | |
/ | |
function memoria(limit) { | |
var array = []; | |
return function (element) { | |
var isSet = arguments.length >= 1; | |
if (isSet) { | |
array.push(element) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import OAuth from 'oauth-1.0a'; | |
import CryptoJS from 'crypto-js'; | |
/** | |
* oAuthHeader - Get Authentication header with OAuth. | |
* | |
* @param {string} url Request URL | |
* @param {string} method HTTP method. | |
* @return {object} Authentication header object | |
*/ |
OlderNewer