Skip to content

Instantly share code, notes, and snippets.

Denis Papathanasiou dpapathanasiou

Block or report user

Report or block dpapathanasiou

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View camel.pl
#!/usr/bin/perl -w # camel code
use strict;
$_='ev
al("seek\040D
ATA,0, 0;");foreach(1..3)
{<DATA>;}my @camel1hump;my$camel;
my$Camel ;while( <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary 1=split(//);if(defined($
_=<DATA>)){@camel1hum p=split(//);}while(@dromeda
@dpapathanasiou
dpapathanasiou / Makefile
Last active Aug 29, 2015
Makefile for libmodbus
View Makefile
SHELL = /bin/sh
CC = gcc
FLAGS = -I /usr/local/include/modbus
LDIR = /usr/local/lib
LIBS = -lmodbus
%: %.c
$(CC) $(FLAGS) $^ -o $@ -L$(LDIR) $(LIBS)
@dpapathanasiou
dpapathanasiou / debian-install.sh
Created Jan 18, 2015
All the packages I install on a new debian system
View debian-install.sh
apt-get install -y build-essential \
# development \
git mercurial roxterm curl gawk \
libpcre3-dev libssl-dev \
qt4-dev-tools libqt4-dev libqt4-core libqt4-gui libqt4-opengl libqt4-network \
libssl-dev libdb5.1++-dev libboost-all-dev libqrencode-dev libminiupnpc-dev \
python-all-dev python-lxml python-magic python-imaging python-pip python-pandas \
erlang \
# word processing \
texlive-latex-base latex2rtf texlive-full \
@dpapathanasiou
dpapathanasiou / sha1sum.sh
Last active Dec 16, 2015
Since mac osx does not have the sha1sum tool installed (why, Apple, why?) this script gets openssl to produce the same output.
View sha1sum.sh
#!/bin/sh
# since mac osx does not have the sha1sum tool installed
# this script gets openssl to produce the same output
if [ $# -ne 1 ]
then
echo "Usage:\n\n$0 [file to check]"
else
openssl sha1 $1 | sed 's/.*(\(.*\))= \(.*\)$/\2 \1/'
@dpapathanasiou
dpapathanasiou / reflexes.c
Last active Dec 26, 2015
Concurrency programming example: test user reflexes
View reflexes.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <pthread.h>
void *listen(void *timestamp) {
int c;
while((c = getc(stdin)) != EOF) {
if( c == '\n' ) {
@dpapathanasiou
dpapathanasiou / reflexes.go
Created Dec 26, 2015
Concurrency programming example: test user reflexes
View reflexes.go
package main
import (
"bufio"
"fmt"
"math/rand"
"os"
"time"
)
@dpapathanasiou
dpapathanasiou / mouseTrackPlot.R
Created Jun 19, 2013
This gist contains functions to plot the data logged by the buckabuckaboo plugin (https://github.com/dpapathanasiou/buckabuckaboo) as an animated sequence of lines per distinct IP address (visitor) against a grayed-out background image which represents the page on the site being monitored using R (http://www.r-project.org/).
View mouseTrackPlot.R
#
# mouseTrackPlot.R
#
# Functions to plot the data logged by the buckabuckaboo plugin (https://github.com/dpapathanasiou/buckabuckaboo)
# as an animated sequence of lines per distinct IP address (visitor) against a grayed-out background image
# which represents the page on the site being monitored using R (http://www.r-project.org/).
#
# To run this inside an R repl, use these commands:
#
# > source("mouseTrackPlot.R")
@dpapathanasiou
dpapathanasiou / RaspberryPi_A_Plus_Wifi.md
Created Jan 10, 2015
How to setup a usb wifi dongle on the Raspberry Pi Model A+
View RaspberryPi_A_Plus_Wifi.md

Rationale

The Raspberry Pi Model A+ has just a single usb port, so getting the wifi configured has to done by editing /etc/network/interfaces from a command line prompt.

These instructions assume the Raspbian OS on the SD card, and a usb wifi adapter that supports the RTL8192cu chipset, since the current Raspbian has built-in support for it.

Before the first boot

  1. Put a keyboard in the usb slot
  2. Connect the HDMI slot to a monitor
@dpapathanasiou
dpapathanasiou / MatrixDSL.scala
Created Jul 26, 2015
DSL processing in Scala
View MatrixDSL.scala
/* This is a scala solution for a mini domain specific language (DSL)
* defining instructions for populating an empty matrix.
*
* Input consists of a single string separated by spaces:
* - the first number represents the size of the matrix, NxN
* - the rest of the input consists of one or more strings defining
* the range of cells and how each of their populations will be
* incremented
*
* Increment pattern possibilities:
@dpapathanasiou
dpapathanasiou / gist:2790864
Created May 25, 2012
Using lxml to parse the Microsoft API translation result from the xml
View gist:2790864
#!/usr/bin/python
from lxml import etree
def get_text_from_msmt_xml (xml):
"""Parse the xml string returned by the MS machine translation API, and return just the text"""
text = []
doc = etree.fromstring(xml)
for elem in doc.xpath('/foo:string', namespaces={'foo': 'http://schemas.microsoft.com/2003/10/Serialization/'}):
You can’t perform that action at this time.