Skip to content

Instantly share code, notes, and snippets.

View ghedo's full-sized avatar
:shipit:
🔥 This is fine 🔥

Alessandro Ghedini ghedo

:shipit:
🔥 This is fine 🔥
View GitHub Profile
@ghedo
ghedo / Demo.c
Created March 29, 2011 20:11
Haiku demo app
#include "Demo.h"
#include <StringView.h>
#include <Window.h>
Demo::Demo(void) : BApplication("application/x-vnd.Demo") {
BRect rect(150, 150, 500, 500);
BWindow *win = new BWindow(
rect, "Demo",
B_TITLED_WINDOW,
@ghedo
ghedo / httpme
Created April 5, 2011 10:24
Serve static files from current working directory
#!/usr/bin/perl
# Usage: httpme
# Serve static files from current working directory
use Cwd;
use Plack::Runner;
use Plack::App::Directory;
my $runner = Plack::Runner -> new;
@ghedo
ghedo / bpipe
Created March 10, 2012 14:59
Pipe stuff to the browser
#!/bin/sh -e
# Usage: bpipe [-h|--html]
# Pipe stuff to the browser
if [ -t 0 ]; then
echo "Usage: echo '<h1>some stuff</h1>' | bpipe"
else
opt=`getopt -o h --long html -n bpipe -- "$@"`
eval set -- "$opt"
@ghedo
ghedo / sprunge
Created March 11, 2012 16:21
Paste stuff to sprunge.us
#!/bin/sh -e
# Usage: sprunge < <file>
# Paste stuff to sprunge.us
if [ -t 0 ]; then
echo "Usage: sprunge < some_file.txt"
else
curl -sF 'sprunge=<-' http://sprunge.us < /dev/stdin
fi
@ghedo
ghedo / ffi_raw_file.pl
Last active October 4, 2015 00:58
FFI::Raw and stdio's FILE
#!/usr/bin/perl
use strict;
use warnings;
use FFI::Raw;
use IO::Handle;
my $fopen = FFI::Raw -> new(
'libc.so.6', 'fopen',
@ghedo
ghedo / jsonpretty.c
Last active October 5, 2015 09:07
Stupid JSON prettifier
/*
* Stupid JSON prettifier.
*
* Compile:
* $ cc -o j jsonpretty.c -ljansson
*
* Usage:
* $ ./j < <file>
* $ cat <file> | ./j
*
@ghedo
ghedo / wr
Last active October 26, 2015 03:28
Translate a word using wordreference.com
#!/usr/bin/perl
# Usage: wr <term> [<dict>]
# Translate a word using wordreference.com
use strict;
use warnings;
use feature qw(say);

Keybase proof

I hereby claim:

  • I am ghedo on github.
  • I am ghedo (https://keybase.io/ghedo) on keybase.
  • I have a public key whose fingerprint is A4F4 55C3 414B 1056 3FCC 9244 AFA5 1BD6 CDE5 73CB

To claim this, I am signing this object:

@ghedo
ghedo / bipipe.c
Created August 13, 2013 14:22
Bidirectional pipe
/*
* Bidirectional pipe
*
* Compile:
* $ cc -o bipipe bipipe.c
*
* Examples:
*
* * Unix domain socket chat over SSH:
*
@ghedo
ghedo / systemd-start-and-wait.go
Last active May 4, 2018 13:51
Start a systemd unit and wait until it stops
package main
import "log"
import "os"
import "github.com/docopt/docopt-go"
import "github.com/godbus/dbus"
const target string = "org.freedesktop.systemd1";
const object string = "/org/freedesktop/systemd1";