Skip to content

Instantly share code, notes, and snippets.

View spawnwithpid.c
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
int forkstatus;
int exitstatus = 0;
void catch_sigterm () {
if (forkstatus != 0)
View x-www-browser
#!/bin/bash
if [[ $1 =~ ^http ]]; then #http, https
url=$1
else # everything else
url="http://$1"
fi
escaped=$(perl -MURI::Escape -e 'print uri_escape($ARGV[0], "(),");' "$url")
firefox -P default -remote "openURL(${escaped}, new-tab)"
View browsefromclipboard
#!/bin/sh
url=$(xclip -o | sed -e 's/^\s*//' -e 's/\s*$//' | grep -v '^$' | head -n 1)
x-www-browser "$url"
View uvim
#!/bin/sh
exec ${emulator:=urxvtcd} -e vim "$@"
View sanitizeclipboard
#!/bin/sh
temp=$(mktemp)
echo "### clipboard ###" > "$temp"
xclip -o >> "$temp"
env emulator=urxvt uvim -b -c 'set noeol' "$temp" +
sed 1d "$temp" | xclip -i
rm "$temp"
View secretsanta.py
#!/usr/bin/python
import random
import base64
"""Secret Santa generator 0.1, trusted 1-party version.
Ever been dissatisfied with random santa assignment because the group would break up into smaller circles? This script prevents this.
Usage: Edit seed and names, run the script. Each participant will have the obfuscated name of the presentee printed next to their name, run it through the base64 decoder of your choice to reveal it.
View surprisingly decent image sorter in a few lines of shell
#!/bin/sh
# canything can be found here: https://github.com/keiji0/canything
focus=$(xdotool getwindowfocus)
list="./folders"
tosort=$1
if [ -z "$tosort" ]
then
echo "read script source."
exit 1
View pastefix
#!/bin/sh
# fix shift+ins pasting on gtk apps
# use by binding to shift+ins globally like so: ("S-<Insert>", spawn "pastefix")
# depends: xclip, xdotool
# inspired by https://github.com/wh5a/arch/commit/623faac500a0eeb31477b0374b3080eaf2ed3685
clipboard=$(xclip -o -selection clipboard)
xclip -o | xclip -selection clipboard
pid=$(xdotool getwindowfocus getwindowpid)
if head -c 1 >/dev/null 2>/dev/null /proc/$pid/maps && \
grep -q libgtk-x11 /proc/$pid/maps && \
@vrs
vrs / ssh.sh
Created Jan 25, 2011
No Internet for you!
View ssh.sh
#!/bin/bash
# $@: ircssh, a shell account with irssi running
# xmonad line:
# , ("M-S-i", spawn "gnome-terminal -e 'Skripte/ssh.sh ircssh'")
if [[ `date +%k` -lt 18 || `date +%k` -gt 20 ]]
then
echo "Internet geschlossen, Öffnungszeiten 18 bis 21 Uhr."
read
exit 1
fi
View gist:504649
#!/usr/bin/perl -w
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "0.01";
%IRSSI = (
name => 'qwertz.pl',