Skip to content

Instantly share code, notes, and snippets.

View vstarck's full-sized avatar

Valentin Starck vstarck

  • Argentina
View GitHub Profile
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@juandopazo
juandopazo / gist:1182244
Created August 30, 2011 22:14
JavaScript without logical operators or loops
function _if(truthy, then) {
[then, function () {}][+!truthy]();
}
function ifElse(truthy, then, _else) {
[then, _else][+!truthy]();
}
function and(a, b) {
return !!((!!a + !!b) >> 1);
@juandopazo
juandopazo / combo.js
Created July 19, 2012 21:26
Streaming combo handler
var fs = require('fs'),
Stream = require('stream'),
util = require('util');
function ComboStream(files, opts) {
Stream.call(this);
opts = opts || {};
if (!Array.isArray(files)) {
throw new TypeError('First argument must be an Array');
@briancavalier
briancavalier / promise-monad-proof.js
Created August 8, 2012 15:57
A proof that Promises/A is a Monad
//-------------------------------------------------------------
//
// Hypothesis:
//
// Promises/A is a Monad
//
// To be a Monad, it must provide at least:
// - A unit (aka return or mreturn) operation that creates a corresponding
// monadic value from a non-monadic value.
// - A bind operation that applies a function to a monadic value
@carlosvillu
carlosvillu / gist:3762253
Created September 21, 2012 15:44
REST API

Metodos HTTP

  • GET: No altera los datos en el servidor, solo puedes obtener datos de el
  • POST: Crea datos en el server
  • PUT: Altera datos en el server
  • DELETE: Lo borra de forma permanente

También puedes usar POST para hacer llamadas a métodos asíncronos, estos son aquellos que deben de realizar alguna operación que va a requerir más de un tiempo razonable de respuesta ( 100ms en el server ). Si usas POST no deberías de agregar variables GET en la URL.

Códigos de respuesta

@jasonrudolph
jasonrudolph / 00-about.md
Created September 21, 2012 18:42
Rough Notes from Strange Loop 2012
@jlongster
jlongster / gist:3881008
Created October 12, 2012 19:28
js destructuring macro
// Note: there are bugs in hygienic renaming, so this doesn't work all the time yet.
macro varr {
case [$var (,) ...] = $expr => {
var i = 0;
var arr = $expr;
$(var $var = arr[i++];) ...
}
@cowboy
cowboy / call-invo-cursion.js
Last active March 30, 2023 01:59
JavaScript: call invo-cursion?
// OOP
console.log( 'OHAI'.blink() );
// Call invocation
console.log( String.prototype.blink.call('OHAI') );
// $ always makes things look awesome.
var $ = Function.prototype.call;
// Very explicit call invocation
@joseanpg
joseanpg / Vigenere.js
Created January 14, 2013 19:53
Vigenère cipher
//http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
//https://twitter.com/r0aTzdg73QLawWw/status/290907958118842368
//https://gist.github.com/1385585
var vigenere = (function() {
var map = Array.prototype.map;
var canon = function(str){ return map.call(str.toUpperCase(),function(c){return c.charCodeAt(0)-65})}
return function(source, key) {
source = canon(source);
key = canon(key);
// ==UserScript==
// @name Colorful Teg
// @version 1.0
// @match *teg.avature.net*
// @run-at document-end
// ==/UserScript==
[
'.analysis_functional > td {background-color: rgba(255, 80, 168, 0.45) !important; }',
'.testing > td { background-color: rgba(255, 255, 176, 0.45) !important; }',