Skip to content

Instantly share code, notes, and snippets.

@grawity
grawity / Makefile
Created Jan 11, 2012
NTFS volume creation timestamp
View Makefile
CC = i486-mingw32-gcc
LDFLAGS = -lntoskrnl -lntdll
volumeinfo.exe: volumeinfo.c
$(CC) -o $@ $< $(LDFLAGS)
View WinlogonUnlocker.cpp
#include "stdafx.h"
#define WM_LOGONNOTIFY 0x004c
#define LN_UNLOCK_WORKSTATION 0x0006
void showError()
{
LPTSTR pBuf;
DWORD nBytes = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(), LANG_USER_DEFAULT, (LPWSTR)&pBuf, 4096, NULL);
View mpris-now-playing.c
#if 0
pkg = glib-2.0 gio-2.0
src = $(MAKEFILE_LIST)
app = $(basename $(src))
CFLAGS = $(shell pkg-config --cflags $(pkg)) -x c
LDFLAGS = $(shell pkg-config --libs $(pkg))
$(app): $(src)
View logind-sleep-handler.pl
#!/usr/bin/env perl
use warnings;
use strict;
use Net::DBus;
use Net::DBus::Reactor;
use POSIX;
my $inhibit_fd;
my $logind_mgr;
View LICENSE
MIT Expat License
-----------------
(c) 2011 Mantas Mikulėnas <grawity@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
@grawity
grawity / README.md
Last active Mar 27, 2018
systemd Type=notify implementations
View README.md

The official documentation is in the [sd_notify(3)][1] manual page.

Very short summary:

  1. Change your systemd service to Type=notify.
  2. Your daemon will receive an environment variable NOTIFY_SOCKET, which contains a path to an AF_UNIX socket.
    (If the first path byte is @, this means an "abstract" socket, and you should change the 1st byte to 0x00 before using.)
  3. The protocol consists of sending datagrams containing textual (UTF-8) status messages.
    Each message contains newline-separated KEY=value parameters.
  4. When the daemon is ready, it must send READY=1, and systemd will transition the service from "starting" to "running".
@grawity
grawity / knob.c
Last active May 17, 2018
PulseAudio 'System Events' volume knob
View knob.c
#if 0
pkg = libpulse
src = $(MAKEFILE_LIST)
app = $(basename $(src))
CFLAGS = $(shell pkg-config --cflags $(pkg)) -x c
LDFLAGS = $(shell pkg-config --libs $(pkg))
$(app): $(src)
View 50-usb-deauthorize.rules
ACTION!="add", GOTO="deauthorize_end"
SUBSYSTEM!="usb", GOTO="deauthorize_end"
TEST!="authorized", GOTO="deauthorize_end"
## make hubs deauthorize all devices by default
TEST=="authorized_default", ATTR{authorized_default}="0", GOTO="deauthorize_end"
## whitelist specific devices
ENV{ID_VENDOR}=="Yubico", ENV{ID_MODEL}=="Yubikey_NEO*", ATTR{authorized}="1", GOTO="deauthorize_end"
ENV{ID_VENDOR}=="Zubico", ENV{ID_MODEL}=="Zubikey_GEO*", ATTR{authorized}="1", GOTO="deauthorize_end"
@grawity
grawity / journal-follow.php
Last active Oct 29, 2018
PHP class that wraps `journalctl --follow`; for joltmode in #systemd and http://stackoverflow.com/q/18711610
View journal-follow.php
<?php
/* © 2013 Mantas Mikulėnas <grawity@gmail.com>
* Released under the MIT Expat License <https://opensource.org/licenses/MIT>
*/
/* Iterator extends Traversable {
void rewind()
boolean valid()
void next()
mixed current()
@grawity
grawity / README.md
Last active Jan 8, 2019
Eggdrop scripts
View README.md