Skip to content

Instantly share code, notes, and snippets.

View calderaro's full-sized avatar

Angel Calderaro calderaro

View GitHub Profile
@calderaro
calderaro / Input.js
Last active August 29, 2015 14:27
Ejemplo List y Form
/*No fijarse mucho en este archivo es horrible :c */
import React, { PropTypes } from "react";
export default class Input extends React.Component{
constructor(props) {
super(props);
this.state = { focused: false };
this.handler = this.handler.bind(this);
this.onChange = this.onChange.bind(this);
this.clear = this.clear.bind(this);
@calderaro
calderaro / static_server.js
Last active September 3, 2015 01:38 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@calderaro
calderaro / validations.js
Last active September 25, 2015 21:59
validations
var isDup = function (a){
return a.length !== R.uniq(a).length
}
var isEmpty = function (a){
return R.length(a) ? false : true
}
//valid
R.filter(R.test(/[\w]{5,30}/), serials);
@calderaro
calderaro / index.html
Created March 3, 2016 20:54 — forked from anonymous/index.html
Services average // source http://jsbin.com/dekogepivu
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Services average</title>
</head>
<body>
<select id="service">
<option value="none">Select Service</option>
<option value="carpentry">Carpentry</option>
@calderaro
calderaro / LRC.java
Created April 2, 2016 01:03
Longitudinal Redundancy Check (LRC) calculator for a byte array.
public class LRC {
public static byte calculateLRC(byte[] bytes) {
byte LRC = 0;
for (int i = 0; i < bytes.length; i++) {
LRC ^= bytes[i];
}
return LRC;
}
}
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
@calderaro
calderaro / index.html
Created August 4, 2016 02:04 — forked from anonymous/index.html
JS Bin Coding Challenge #30: Phyllotaxis // source http://jsbin.com/hezidi
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Coding Challenge #30: Phyllotaxis">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
canvas {
border: black 1px solid;
@calderaro
calderaro / socket.io-emit-broadcast-usage.js
Created November 13, 2016 03:11 — forked from markogresak/socket.io-emit-broadcast-usage.js
Different destination groups for socket.io emit and broadcast functions
// send to current request socket client
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.sockets.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
canvas {
border: 1px solid black
}
@calderaro
calderaro / mp3.js
Created January 9, 2017 06:20 — forked from dtrce/mp3.js
streaming mp3 using nodejs
var http = require('http'),
fileSystem = require('fs'),
path = require('path')
util = require('util');
http.createServer(function(request, response) {
var filePath = 'path_to_file.mp3';
var stat = fileSystem.statSync(filePath);
response.writeHead(200, {