Skip to content

Instantly share code, notes, and snippets.

View piranna's full-sized avatar

Jesús Leganés-Combarro piranna

View GitHub Profile
@piranna
piranna / OrderedHashMap.h
Created October 14, 2011 10:24
OrderedHashMap similar to Python OrderedDict implemented with Boost
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/sequenced_index.hpp>
using namespace ::boost;
using namespace ::boost::multi_index;
template <typename T1,typename T2>
struct mutable_pair
@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)
@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" <[email protected]>
# 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 / 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 / mouse.js
Last active May 21, 2022 09:13 — forked from bfncs/mouse.js
/**
* Read Linux mouse(s) in node.js
* Author: Marc Loehe ([email protected])
*
* 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 / 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>
#!/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 / 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| #
# 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' <[email protected]>
from enum import Enum
# 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' <[email protected]>