Skip to content

Instantly share code, notes, and snippets.


Ernesto Celis ecelis

View GitHub Profile
View helloworld.js
var serialport = require('node-serialport')
var sp = new serialport.SerialPort("/dev/ttyO3", {
parser: serialport.parsers.raw,
baud: 9600
sp.on('data', function(chunk) {
console.log(chunk.toString('hex'), chunk.toString(), chunk)
ecelis / form.html
Last active Aug 29, 2015
Aggregate data in PHP
View form.html
<form action="process.php" method="post">
<textarea name="myinput" id="myinput" cols="12" rows="6"></textarea>
<input type="submit" value="send">
ecelis / fiddle.css
Last active Aug 29, 2015
Leaflet OSM
View fiddle.css
#map {
width: 400px;
height: 400px;
View generate-pushid.js
* Fancy ID generator that creates 20-character string identifiers with the following properties:
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
ecelis / myreg.php
Last active Aug 29, 2015
Custom wordpress registration form
View myreg.php
* Plugin Name: My Registration
* mkdir wp-content/plugins/myreg
// Add new form element
add_action('register_form', 'myreg_register_form');
function myreg_register_form() {
if(!empty($_POST['first_name'])) {
ecelis /
Created Mar 26, 2015
Java FileLock & IPC server example
package server.ipc;
//import server.model.*;
public class RepositoryServer {
ServerSocket serverSocket = null;
int state = 0;
//IProtocolHandler protocolHandler;
ecelis /
Last active Aug 29, 2015
Java Version Checker
/* Code taken from
> java ClassVersionChecker ClassVersionChecker.class
ClassVersionChecker.class: 49 . 0
public class ClassVersionChecker {

Keybase proof

I hereby claim:

  • I am ecelis on github.
  • I am ecelis ( on keybase.
  • I have a public key whose fingerprint is F29C 399A 7B19 FA67 4B9E BDF6 2D55 1002 2615 FA80

To claim this, I am signing this object:

ecelis /
Created Oct 18, 2015 — forked from chrisroos/
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

ecelis / imaway
Created May 23, 2016 — forked from sdague/imaway
dbus xchat integration
View imaway
import dbus
import dbus.glib
import gobject
import subprocess
def lock():
print "Screen saver turned on"