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 / 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);
@ghedo
ghedo / gist_backup.pl
Last active September 1, 2021 18:25
Clone all the gists of a GitHub user
#!/usr/bin/perl
# Usage: gist_backup.pl <user>
# Clone all the gists of a GitHub user
use strict;
use warnings;
use Git::Raw;
use Pithub::Gists;
@ghedo
ghedo / mouse_wrap.c
Last active July 2, 2021 11:58
Wrap mouse pointer at screen edges
/*
* Wrap mouse pointer at screen edges.
*
* Compile:
* $ cc -o mousewrap mouse_wrap.c -lX11 -lXi
*
* Usage:
* $ ./mwrap
*
* Copyright (C) 2012 Alessandro Ghedini <alessandro@ghedini.me>
@ghedo
ghedo / sleepd.c
Last active July 5, 2020 10:21
Execute a command after some time of inactivity
/*
* Execute a command after some time of inactivity
*
* Compile:
* $ cc -o sleepd sleepd.c
*
* Usage:
* $ ./sleepd -t 600 -c "slock"
*
* NOTE: to run this as a normal (non-root) user you may need to change
@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 / MMA8452Q.cpp
Last active August 11, 2018 16:57
Arduino library for the MMA8452Q three-axis accelerometer
/*
* Arduino library for the MMA8452Q three-axis accelerometer.
*
* The MMA8452Q is a tiny and low-power three-axis accelerometer. This
* library implements a simple interface to access most of the chip
* functionality from an Arduino.
*
* FEATURES:
* + Normal and fast raw axes values reading
* + Scale configuration (allowed 2g, 4g and 8g scales)
@ghedo
ghedo / ATSHA204.cpp
Last active November 26, 2019 12:35
Arduino library for the ATSHA204 authentication chip
/*
* Arduino library for the ATSHA204 authentication chip.
*
* The ATSHA204 is a tiny and low-power authentication chip. This library
* implements a simple interface to access most of the chip functionality from
* an Arduino.
*
* Note that only the Single-Wire Interface (SWI) is currently supported.
*
* FEATURES:
@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";