Skip to content

Instantly share code, notes, and snippets.

View piranna's full-sized avatar

Jesús Leganés-Combarro piranna

View GitHub Profile
access config from a single place, propagate it using only function or constructor arguments
Single error handler
log result in a single place, or very few places, at most high level as possibleº
Don't log errors, throw them and catch them in caller function
use object destructuring from parameters
standar error responses
bunyan as logger
limit tests timeout
# AppendingTiffWriter
# -*- coding: utf-8 -*-
#
# "file object wrapper class" that is able to append a TIF to an existing one
#
# Code by @vashek (https://github.com/vashek) published at
# https://github.com/python-pillow/Pillow/issues/733#issuecomment-249380397
#
# Fixed PEP8 and clean by Jesús Leganés-Combarro 'piranna' <piranna@gmail.com>
# AppendingTiffWriter
#
# "file object wrapper class" that is able to append a TIF to an existing one
#
# Code by @vashek (https://github.com/vashek) published at
# https://github.com/python-pillow/Pillow/issues/733#issuecomment-249380397
#
# Fixed PEP8 and clean by Jesús Leganés-Combarro 'piranna' <piranna@gmail.com>
from enum import Enum
@piranna
piranna / hexdump.log
Last active April 16, 2016 21:25
Shorten hexdump of a tar ball
# NodeOS layer 4.png
00000000 64 6f 63 73 2f 4e 6f 64 65 4f 53 20 6c 61 79 65 |docs/NodeOS laye|
00000010 72 20 34 2e 70 6e 67 00 00 00 00 00 00 00 00 00 |r 4.png.........|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 00 00 00 00 30 30 30 36 34 34 20 00 30 30 31 37 |....000644 .0017| # Information about the file
00000070 35 30 20 00 30 30 30 31 34 34 20 00 30 30 30 30 |50 .000144 .0000| #
#!/usr/bin/env node
var Interface = require('readline').Interface
var ReadStream = require('tty').ReadStream
var spawn = require('child_process').spawn
Interface(process.stdin, process.stdout)
var stdin = ReadStream(process.stdin.fd)
process.stdin.pause()
@piranna
piranna / index.html
Last active August 29, 2015 14:15 — forked from formula1/blog.html
<!doctype html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script>
<script type="text/javascript">
var path = "/NodeOS/NodeOS/issues";
</script>
</head>
<body>
<h1>NodeOS Blog</h1>
@piranna
piranna / mouse.js
Last active May 21, 2022 09:13 — forked from bfncs/mouse.js
/**
* Read Linux mouse(s) in node.js
* Author: Marc Loehe (marcloehe@gmail.com)
*
* Adapted from Tim Caswell's nice solution to read a linux joystick
* http://nodebits.org/linux-joystick
* https://github.com/nodebits/linux-joystick
*/
var fs = require('fs'),
@piranna
piranna / urlencode.cpp
Created June 27, 2012 11:18
Functions to encode and decode strings to be valid URL ones
/*
* urlencode.c
*
* Based on code from http://www.zedwood.com/article/111/cpp-urlencode-function
*
* Created on: 21/06/2012
* Author: piranna
*/
#include "urlencode.hpp"
@piranna
piranna / remote-desktop.sh
Created May 4, 2012 12:15
Script to open a remote X11 graphic session via ssh
#!/bin/sh
# Script to open a remote X11 graphic session via ssh
#
# (c) 2012 Jesús Leganés Combarro "piranna" <piranna@gmail.com>
# for Vaelsys (http://www.vaelsys.com)
#
# To use it, just set the parameters to you own needs. It requires that you have
# a SSH Public-Key Authentication to the remote machine properly configured.
@piranna
piranna / print_done.py
Created February 9, 2012 15:23
Decorator to print the stacked level of the function and when it goes into and goes out. It only records the decorated functions and methods, not the full program stack...
def print_done(func):
print_done.level = 0
print_done.levels = []
def wrapper(*args, **kwargs):
# Entering function
print_done.level += 1
if print_done.level > len(print_done.levels):
print_done.levels.append(1)