Skip to content

Instantly share code, notes, and snippets.

View alejandrolechuga's full-sized avatar
🤯
Focusing

neptuno alejandrolechuga

🤯
Focusing
View GitHub Profile
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

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)));
@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
*/
// 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 / 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;
@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(",");