Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
🔥 This is fine 🔥

Alessandro Ghedini ghedo

:shipit:
🔥 This is fine 🔥
View GitHub Profile
@ghedo
ghedo / Demo.c
Created Mar 29, 2011
Haiku demo app
View Demo.c
#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 Apr 5, 2011
Serve static files from current working directory
View httpme
#!/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 Mar 10, 2012
Pipe stuff to the browser
View bpipe
#!/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 Mar 11, 2012
Paste stuff to sprunge.us
View sprunge
#!/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 Oct 4, 2015
FFI::Raw and stdio's FILE
View ffi_raw_file.pl
#!/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 Oct 5, 2015
Stupid JSON prettifier
View jsonpretty.c
/*
* Stupid JSON prettifier.
*
* Compile:
* $ cc -o j jsonpretty.c -ljansson
*
* Usage:
* $ ./j < <file>
* $ cat <file> | ./j
*
@ghedo
ghedo / wr
Last active Oct 26, 2015
Translate a word using wordreference.com
View wr
#!/usr/bin/perl
# Usage: wr <term> [<dict>]
# Translate a word using wordreference.com
use strict;
use warnings;
use feature qw(say);
View keybase.md

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 Aug 13, 2013
Bidirectional pipe
View bipipe.c
/*
* 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
Start a systemd unit and wait until it stops
View systemd-start-and-wait.go
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";