Skip to content

Instantly share code, notes, and snippets.

View iglosiggio's full-sized avatar
🍙
Rice's theorem denier

Ignacio Esteban Losiggio iglosiggio

🍙
Rice's theorem denier
View GitHub Profile
@iglosiggio
iglosiggio / definir_datos.lua
Last active August 29, 2015 14:24
Pequeña librería para definir estructuras de datos y chequeos correspondientes en lua
if _VERSION == "Lua 5.1" then
table.unpack = unpack
table.pack = function(...) return {...} end
end
local definir_dato = function(claves)
return function(valores)
local estructura = {}
if #claves > #valores
then error("No se proporcionó la cantidad de argumentos necesaria") end
@iglosiggio
iglosiggio / multitables.lua
Created August 5, 2015 13:33
Flat multidimensional tables in lua
local _mt = {
__call = function(t, ...)
-- Los primeros table.dimensiones argumentos corresponden a la
-- ubicación en cada eje
local argumentos = table.pack(...)
local dimensiones = #t.dimensiones
local indice_set_value = dimensiones + 1
local indice_set_nil = dimensiones + 2
local indice = 0
for i = 1,dimensiones do
@iglosiggio
iglosiggio / git_newsarchiver.txt
Last active December 20, 2015 01:14
Acomodo cosas en la api y defino la data que voy a usar
Información global de diarios
/
Historial del global
/historial/
Parámetros:
incluir_diffs
pagina: <num>
max: <num>
@iglosiggio
iglosiggio / parse_package.js
Created September 19, 2016 15:44
Parsea un Package de debian (se puede mejorar pero al menos funca :P)
// Se puede probar con http://repo.huayra.conectarigualdad.gob.ar/huayra/dists/unstable/main/binary-amd64/Packages
function parse_package(text) {
'use strict';
const regex = {
field: /([^:\n]+): ([^\n]+)\n((:? [^\n]*\n)*)/g,
package: /(:?[^\n]+\n)+\n/g
}
var result = {};
@iglosiggio
iglosiggio / displacement.js
Created October 25, 2016 17:38
Nada relevante, olvidar esto
function draw(screen) {
for(var i = 0; i < 640 * 480; i++) {
var r = screen[i * 3 + 0];
var g = screen[i * 3 + 1];
var b = screen[i * 3 + 2];
var idx = (r + g + b) - (r + g + b) % 3;
imgdata.data[i * 4 + 0] = screen[i * 3 + idx + 0];
imgdata.data[i * 4 + 1] = screen[i * 3 + idx + 1];
shntool split -t "%n - %t" -o flac -m "/ :-? " -f <cuefile> <audiofile>
@iglosiggio
iglosiggio / cpcipc_fileexplorer.js
Created January 10, 2017 14:56
Utilidad para explorar los archivos de la página del CPCIPC
const {createInterface} = require('readline')
const {get} = require('http')
const {join, parse} = require('path')
const cmd = createInterface({
input: process.stdin,
output: process.stdout,
historySize: 2000,
prompt: 'cpcipc>'
})
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'ember-cat',
cats: [30, 40, 200],
log(thing) {
console.log(thing);
}
});
@iglosiggio
iglosiggio / eventIterator.js
Created March 8, 2017 17:17
EventEmitter to promise iterator
/* This can be useful with co
*
* Example:
* co.wrap(function* listenChanges(dir, warnlist) {
* const watch = fs.watch(dir);
* const changes = eventIterator(watch, 'change');
* for(change of changes) {
* let [event, file] = yield change; // co will wait the Promise for us
* if(file in warnlist)
* console.info('[WARN] the file %s has %s', file, event);
@iglosiggio
iglosiggio / multi_cb.js
Created May 2, 2017 13:39
Simple callback based promise.all "clone"
/* Returns a function that can only be called once (useful for faulty libs) */
function only_one(f) {
return function single_call(...args) {
if(f) {
let rval = f(...args);
f = null;
return rval;
} else {
return null;
}