Skip to content

Instantly share code, notes, and snippets.

View carlosvillu's full-sized avatar
🏠
Working from home

Carlos Villuendas Zambrana carlosvillu

🏠
Working from home
View GitHub Profile
@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

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

@carlosvillu
carlosvillu / extend.js
Created November 15, 2012 10:44 — forked from tcorral/extend.js
Safe extend to bypass constructors that throw Errors.
/**
* This piece of code has been created to safely extend classes/objects in Javascript.
* After talk with a great friend that was upset trying to extend a class/object that throws an error
* if some parameter in the constructor of the class/object is missing.
*
* var Search = function ( sToSearch ) {
* if ( sToSearch == null ) { // Check if sToSearch is null or undefined
* throw new Error( 'Search needs a string to search' );
* }
* this.sToSearch = sToSearch;
@carlosvillu
carlosvillu / server.js
Created November 6, 2014 10:21
Poc server
var http = require('http'),
ipReg = /\api\/v1\/ip\/(\w+)/,
iplookup = require( './lib/iplookup' );
http.createServer(function (req, res) {
var ip = req.url.match( ipReg );
if( !ip )
{
res.writeHead(404, {'Content-Type': 'text/html'});
let carlos = new Person();
@carlosvillu
carlosvillu / git-completion.sh
Created March 1, 2015 22:42
git-completion.sh
#!bash
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
set nocompatible " use vim features
" set foldmethod=syntax
set foldmethod=marker
set foldlevelstart=1
set foldnestmax=5
set foldclose=all
set nobackup " no backup
set nowritebackup " no backup during edit session
set backspace=indent,eol,start " backspace over everything
set tabstop=2 " size of a tab
@carlosvillu
carlosvillu / src.js
Created July 15, 2015 10:59
Solución al workshop de ES6
// Number -> Number -> Number
export const add = (a, b) => a + b
export const sum = (...numbers) => numbers.reduce(add, 0)
// Number -> Number
export const square = (x) => x * x
// Number -> Void
export const asyncSquare = (coll) => () => coll.map(square)
class BusEvents {
on(event, fn){}
emit(event, ...data){}
}
class JQueryBusEvents extends BusEvents{
constructor($=window.jQuery){
super();
this.$doc = $(document);
}
@carlosvillu
carlosvillu / better-console-log.js
Last active September 1, 2015 13:28 — forked from RReverser/better-console-log.js
Better console.log in Node
// UPD:
// Now available as npm module!
// Check out https://github.com/RReverser/better-log for details.
console.log = (function (log, inspect) {
return function () {
return log.apply(this, Array.prototype.map.call(arguments, function (arg) {
return inspect(arg, { depth: 1, colors: true });
}));
};