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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define MSG "EchoD (v0.1): What you send me - I send you back!\n"
@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)
#
#---------▄--------------▄
#--------▌▒█-----------▄▀▒▌
#--------▌▒▒▀▄-------▄▀▒▒▒▐
#-------▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
#-----▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
@dakk
dakk / gist:4980723
Created February 18, 2013 21:02
Gtk+: change the label of a gtk_image_menu_item created from stock
menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_OK, NULL);
GtkWidget* menu_label = gtk_bin_get_child(GTK_BIN(menu_item));
gtk_label_set_text(GTK_LABEL(menu_label), "new label text");
@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 / isometric_monogame
Last active December 22, 2015 06:38
Isometric 2d rendering with MonoGame (XNA) and F#
open System
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
open Microsoft.Xna.Framework.Storage
open Microsoft.Xna.Framework.Input
/// Logical type of a MapCell
type CellType =
| Empty
@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 / 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 / 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 / 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 / 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])