Skip to content

Instantly share code, notes, and snippets.

View alejandrolechuga's full-sized avatar
🤯
Focusing

neptuno alejandrolechuga

🤯
Focusing
View GitHub Profile
// 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)
@alejandrolechuga
alejandrolechuga / high-order-functions.js
Created February 19, 2017 05:53
Functional Programming
// 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;
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)));
@alejandrolechuga
alejandrolechuga / oauth.js
Created November 18, 2016 15:24 — forked from keiver/oauth.js
Get Authentication header with OAuth using oauth-1.0a and crypto-js
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
*/
@alejandrolechuga
alejandrolechuga / observable1.js
Last active July 22, 2016 14:56
Observables with RxJS
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;

Why I hate TypeScript

Warning: These views are highly oppinated and might have some slightly incorrect facts. My experience with typescript was about 2 weeks in Node and a week in angular2.

Not Standard

TypeScript is implementing their own take on JavaScript. Some of the things they are writing will likely never make it in an official ES* spec either.

Technologies that have competing spec / community driven development have a history of failing; take: Flash, SilverLight, CoffeeScript, the list goes on. If you have a large code base, picking TypeScript is something your going to be living with for a long time. I can take a bet in 3 years JavaScript will still be around without a doubt.

Its also worth noting that they have built some things like module system and as soon as the spec came out they ditched it and started using that. Have fun updating!

@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@kentcdodds
kentcdodds / get-watchers.js
Last active December 4, 2023 22:34
Get Watchers of element and its children
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)));
(function(number){
console.log(number); // 2
number = 1;
console.log(arguments[0]); // 1
}(2));
(function(number){
"use strict";
console.log(number); // 2
number = 1;
@alejandrolechuga
alejandrolechuga / functionRegExp.js
Last active October 13, 2015 20:47
Gets the function argument names in an Array
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(",");