Skip to content

Instantly share code, notes, and snippets.

@hacst
hacst / binasc2asc
Created February 3, 2013 23:02
Since people don't stop writing text as binary ASCII and rewriting the same line over and over again to decode it gets boring real quick remember it as a gist ;) Usage: echo 01000010 00101101 01110011 01101001 01100100 01100101 | ./binasc2asc.py
#!/usr/bin/env python
import sys
print "".join([chr(int(c,2)) for c in sys.stdin.read().strip().split()])
@hacst
hacst / .bashrc
Created January 15, 2013 12:30
Custom dash prompt which displays current branch and dirty status in the prompt line when in a git repository folder. Add to .bashrc or another file executed by it like .bash_aliases.
RS="\033[0m" # reset
HC="\033[1m" # hicolor
INV="\033[7m" # inverse background and foreground
function git_dirty() {
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
echo -n "\[$INV\]*"
else
echo -n "\[$HC\]"
fi
@hacst
hacst / gist:3824223
Created October 3, 2012 00:37 — forked from rlemon/gist:3814072
Callback maybe
It threw an exception from hell,
You ask me, trace wouldn't tell,
I know JS really well,
Events are in my way.
I trade my sleep for a fix,
time and more time trying tricks,
I wasn't looking for this,
Callbacks are in my way.
@hacst
hacst / touchpad.sh
Created September 21, 2012 19:36
Small script for reliably disabling the touchpad over suspend/resume. Tested on Ubuntu 12.04 with a Lenovo X230.
#!/bin/sh
#
# Small script for enabling/disabling the touchpad
# reliably even if it is "hotplugged" with every
# wakeup from standy. Tested on Lenovo X230 with
# Ubuntu 12.04.
#
# Author:
# Stefan Hacker <[email protected]>
@hacst
hacst / playingwithchrono.cpp
Created March 17, 2012 09:12
Cross-platform, high-resolution time measurement using C++11's std::chrono
#include <iostream>
#include <chrono>
#include <thread>
using namespace std;
using namespace chrono;
int main()
{
cout << "Measurement resolution: " <<
@hacst
hacst / README.txt
Created January 15, 2012 08:27
Automatic update and restart shell scripts for rotc servers
Automatic updates and restarts for an rotc server
=================================================
1) Create an rotc user on your server (home: /home/rotc/)
2) Checkout rotc using git to /home/rotc/rotc/
3) Place these two scripts into the /home/rotc/rotc/ folder (and adjust them)
4) Adjust runme.sh:
* Make the -srv variable point to your server configuration.
* If you don't intend to run the script as root remove the sudo's inside.
If you run as root make sure the runme.sh script isn't editable by anyone else).