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
x = -1.01:.001:1.01;
y = 4/5*(sqrt(1-x.^2) + sqrt(abs(x)));
z = 4/5*(-sqrt(1-x.^2) + sqrt(abs(x)));
plot(x,y,'r');
plot(x,z,'r');
#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)
#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]);
@dakk
dakk / getCase.py
Created July 4, 2016 15:36
Send a desktop notification if a new house is available on Subito.it
import requests
import time
from gi.repository import Notify
Notify.init("getCase")
def getCase ():
d = requests.get ("http://www.subito.it/annunci-sardegna/affitto/appartamenti/cagliari/cagliari/?pe=5").text
return int (d.split ("Tutti: ")[1].split ('<')[0])
@dakk
dakk / asyncronize.ml
Last active June 22, 2016 17:14
Simple async for ocaml
open Printf;;
open Thread;;
let async f a fc =
let wrapper a = fc (f a) |> ignore in
Thread.create wrapper a;
Thread.yield ()
;;
@dakk
dakk / pdftopath.sh
Created April 12, 2016 17:11
Convert a pdf with text to a pdf with curves
pdftops $1
ps2pdf $1
pdfcrop $1
@dakk
dakk / frisbyChain.js
Last active April 9, 2016 10:29
An utility to avoid waterfalling of frisby tests throught middleware chains
var frisby = require ('frisby');
/* FrisbyChain */
var frisbyChain = function (baseData, callChain) {
callChain.push (function (data) {});
var nextPrepare = function (data, i) {
if (i < callChain.length)
return function (data, next) {
return callChain[i] (data, nextPrepare (data, i+1));
@dakk
dakk / ml_snippets.ml
Created March 23, 2016 14:15
OCaml various snippets
#use "printf.ml";;
(* Type def *)
type json =
| Object of (string * json) list
| Bool of bool
| Float of float
| Int of int
| Null
| String of string
@dakk
dakk / contractvm.json
Last active December 14, 2015 10:16
Contractvm configuration for protected networks
{
"chain": "XTN",
"dht": {
"port": 5051,
"seeds": []
},
"dapps": {
"list": [],
"enabled": []
},
@dakk
dakk / shiba2.py
Created November 16, 2015 23:40
shiba2 hash
#!/usr/bin/python
# -*- coding: UTF-8
#
# shiba256 - the shiba 256bit hash (such hash, so secure, much crypto)
#
#---------▄--------------▄
#--------▌▒█-----------▄▀▒▌
#--------▌▒▒▀▄-------▄▀▒▒▒▐
#-------▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
#-----▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐