Skip to content

Instantly share code, notes, and snippets.

View luca-m's full-sized avatar

lucam luca-m

View GitHub Profile
#opencv
import cv2.cv as cv
import cv2
import numpy as np
def build_filters():
filters = []
ksize = 31
for theta in np.arange(0, np.pi, np.pi / 32):
@luca-m
luca-m / opencv.cproject
Created July 23, 2013 08:31
.cproject modification for enabling OpenCV in eclipse
<!--
...
-->
<option id="gnu.c.compiler.option.include.paths.651068615" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/usr/local/include/opencv"/>
</option>
<!--
...
-->
<option id="gnu.cpp.link.option.libs.2101947007" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
@luca-m
luca-m / zlib-decompress.py
Created July 22, 2013 18:45
Quick and dirty script for decompressing a gz stream
#!/usr/bin/python
import zlib,sys,os
print 'Usage: %s <infile> <offset-addr> <length> <outfile>' % sys.argv[0]
if len(sys.argv) < 5:
exit(-1)
fr = open(sys.argv[1], 'rb')
@luca-m
luca-m / xor-gif.py
Created July 22, 2013 09:50
Simple script for xorring toghether all layers of a GIF image. This work with indexed image, working with multi-channel images could need some modifications.
#!/usr/bin/env python
import Image
import sys
def xorImage( infile ):
try:
im = Image.open( infile )
except IOError:
print "Cant load", infile
@luca-m
luca-m / .Xresources
Created July 9, 2013 13:52
.Xresources for urxvt, clipboard CTRL+SHIFT+(C|V|X), CTRL+Arrow for word cursor movement
!! cd /usr/lib/urxvt/perl; git clone https://github.com/muennich/urxvt-perls .
!! Perl extensions
URxvt.perl-ext-common: default,clipboard,matcher,keyboard-select
!! URLs
URxvt.keysym.C-U: perl:url-select:select_next
URxvt.url-launcher: /usr/bin/firefox -new-tab
URxvt.underlineURLs: True
URxvt.matcher.button: 1
@luca-m
luca-m / battery-mon.sh
Last active December 19, 2015 11:19
Lightweight battery monitor.Using lightweight desktop environment such as awesome, i3 or xmonad may be really comfortable for certain aspect, but there are also few thing that you may miss from a regular desktop environment.This is the case of some kind of warning pop-up which indicates you that your battery is going dead. How many times do you …
#!/bin/bash
#
# Print battery warning
#
VERBOSE=0
SUSPEND_CMD=/home/stk/.i3/suspend.sh
TIMEOUT=120
DEVNAME='/org/freedesktop/UPower/devices/battery_BAT0'
ALERT_THR=15
@luca-m
luca-m / useful-commands
Last active December 18, 2015 23:29
A collection of useful commands.
# convert images
convert *.pgm %d.jpg
# video from image sequence
avidemux2_cli --video-codec DV --fps 1 --load jpg/*.jpg --save out.avi --quit
# No ASLR
sysctl -w kernel.randomize_va_space=0
paxctl -x <program>
setarch `arch` -R <program>
alphabet=''.join([chr(i) for i in xrange(256) if chr(i) not in '!"#$&*+-/0123456789;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^abcdefghijklmnopqrstuvwxyz|' and i != 0])
def filt(s):
return s.translate(ident,'!"#$&*+-/0123456789;=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^abcdefghijklmnopqrstuvwxyz|')
def obfNum(n):
""" Obfuscate a number """
if n==0:
return "([]<{})"
elif n==1:
#
# Timing Attack Miscellaneous
#
import string
import sys
import re
import time
import threading
import httplib
#
# RSA TOOLKIT v.0.1a
#
import gmpy,string
ALPHABET=string.lowercase+" '"
#
# Factorization
#
def factorize(Num):