Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/input.h>
int read_event(struct input_event *event)
{
return fread(event, sizeof(struct input_event), 1, stdin) == 1;
}
@drucoder
drucoder / .bashrc
Created June 1, 2016 06:50
Git shell settings
# Show a current active git branch in the shell prompt
export PS1='\t \[\033[01;32m\]\u\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '
# Shortcat for the pretty git log. Can be extended with the commit count parameter (last -10, last -35)
alias last='git log --graph --all --oneline --decorate '
@rofl0r
rofl0r / bb-ping.c
Last active May 30, 2022 08:56
ping utility ripped off from busybox rev 1.22.0, turned into a standalone program + added SOCK_DGRAM functionality for root-free ping and ping6. [ http://lists.busybox.net/pipermail/busybox/2014-January/080206.html rejected SOCK_DGRAM patch as taken from busybox ml]
/* vi: set sw=4 ts=4: */
/*
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
*
* Adapted from the ping in netkit-base 0.10:
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
*
@rofl0r
rofl0r / init.c
Created August 6, 2013 21:15
minimal init daemon by rich felker, author of musl libc
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <unistd.h>
int main()
{
sigset_t set;
int status;
if (getpid() != 1) return 1;
@rofl0r
rofl0r / sleep.c
Created March 13, 2012 03:04
gnu compatible sleep tool.
#define _POSIX_C_SOURCE 200809L
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
int main(int argc, char** argv) {
int i;
char* end;
int times;
for(i = 1; i < argc; i++) {