Skip to content

Instantly share code, notes, and snippets.

View ptigas's full-sized avatar
🐙

Panagiotis Tigas ptigas

🐙
View GitHub Profile
@ptigas
ptigas / gist:2036981
Created March 14, 2012 14:48
bash animations
while true; do echo -n "◐\r"; sleep .1; echo -n "◓\r"; sleep .1; echo -n "◑\r"; sleep .1; echo -n "◒\r"; sleep .1; done
while true; do echo -n "◜\r"; sleep .1; echo -n "◠\r"; sleep .1; echo -n "◝\r"; sleep .1; echo -n "◞\r"; sleep .1; echo -n "◡\r"; sleep .1; echo -n "◟\r"; sleep .1; done
while true; do a=$a" "; echo -n "\r" $a "✈ "; sleep .1; done
while true; do a=$a" "; echo -n "\r" $a "\xcf\x80\xce\xbf\xcf\x8d\xcf\x84\xcf\x83\xce\xb1 "; sleep .1; done
@ptigas
ptigas / memento_fib.py
Created March 6, 2012 20:17
memento decorator applied on fibonacci
class Memento :
__mem__ = {}
def __init__(self, f) :
self.f = f
def __call__(self, arg) :
if arg not in self.__mem__ :
self.__mem__[arg] = self.f(arg)
return self.__mem__[arg]
@ptigas
ptigas / singleton.py
Created March 6, 2012 19:47
example of singleton design pattern in python
counter = 1
class TestSingleton:
__instance = None
__var = 0
def __init__(self):
global counter
self.__var = counter
counter += 1
@ptigas
ptigas / stack.c
Created March 4, 2012 13:17
quick and dirty stack implementation in C
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *next;
};
struct list {
struct node *head;
@ptigas
ptigas / loop_detection.py
Created March 3, 2012 21:18
Example of Floyd algorithm for loop detection
'''
Example of Floyd algorithm for loop detection
'''
class Node :
def __init__(self, data) :
self.next = None
self.data = data
def __str__(self) :
@ptigas
ptigas / names.csv
Created March 3, 2012 10:43
names.csv
We can't make this file beautiful and searchable because it's too large.
John,1,male,1880
Mary,9655,female,1880
William,2,male,1880
Anna,9533,female,1880
James,3,male,1880
Emma,5927,female,1880
Charles,4,male,1880
Elizabeth,5348,female,1880
George,5,male,1880
Minnie,5126,female,1880
@ptigas
ptigas / names.json
Last active December 28, 2016 12:38
names.json
{"Andreas": "male", "Arely": "female", "Mortimer": "male", "Pauletta": "female", "Zita": "female", "Casen": "male", "Araceli": "female", "Ronald": "female", "Eura": "female", "Aracely": "female", "Destany": "female", "Cael": "male", "Kaleigh": "female", "Ayleen": "female", "Nikhil": "male", "Elex": "male", "Myah": "female", "Channie": "female", "Evalyn": "female", "Less": "male", "Jerel": "male", "Sandi": "female", "Lesa": "female", "Paul": "male", "Sandy": "female", "Kraig": "male", "Merlin": "male", "Vanesa": "female", "Matthew": "female", "Althea": "female", "Lucille": "female", "Samatha": "female", "Hamilton": "male", "Johnie": "female", "Dionne": "female", "Stephania": "female", "Stephanie": "male", "Raheem": "male", "Murl": "female", "Lafe": "male", "Ginger": "female", "Audy": "male", "Hughie": "male", "Jewell": "female", "Edra": "female", "Tatyanna": "female", "Quincy": "male", "Harvey": "male", "Agustus": "male", "Basil": "male", "Casey": "male", "Kaydence": "female", "Leilani": "female", "Dejuan": "m
@ptigas
ptigas / gist:1730997
Created February 3, 2012 16:34
letter frequency
from itertools import groupby
[(i, len(list(j))) for i,j in groupby(sorted('hullabaloo'))]
@ptigas
ptigas / gist:1451403
Created December 9, 2011 12:49
Check postfix logs for memory issues
cat /var/log/maillog* | grep "$(date '+%b %d' | sed 's/0\([0-9]\)/ \1/g')" | grep "Cannot allocate memory"
@ptigas
ptigas / gist:1444735
Created December 7, 2011 21:25
MapReduce example in python
'''
Playing with MapReduce in python
ref.
http://mikecvet.wordpress.com/2010/07/02/parallel-mapreduce-in-python/
'''
from multiprocessing import Pool
def generate_data(A = 90000, B = 20) :
return [ [ [j] for j in range(B)] for i in range(A)]