Skip to content

Instantly share code, notes, and snippets.

View panzi's full-sized avatar

Mathias Panzenböck panzi

View GitHub Profile
fn main() {
let args = os::args();
let mut washed_args = Vec::new();
for arg in args.iter() {
washed_args.push(arg.as_slice())
}
match washed_args.as_slice() {
[_, "review", opts..] => { review(opts) }
_ => { usage() }
@panzi
panzi / grouping.py
Last active August 29, 2015 14:10
simple grouping function in Python
from collections import defaultdict
__all__ = 'group_by', 'index_by'
def group_by(iterable, key):
grouped = defaultdict(list)
for item in iterable:
grouped[key(item)].append(item)
return grouped
@panzi
panzi / gotcha.py
Last active August 29, 2015 14:12 — forked from skatenerd/gotcha.py
def make_adder():
grand_total = 0
def adder(to_add):
nonlocal grand_total
print("Grand total moved from: %s" % grand_total)
grand_total += to_add
print("To: %s \n" % grand_total)
return grand_total
return adder
@panzi
panzi / saveCanvas.js
Last active November 28, 2021 09:31
JavaScript function to save the contents of canvas element to a file.
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
window.saveAs = window.saveAs || window.webkitSaveAs || window.mozSaveAs || window.msSaveAs;
function saveCanvas (canvas, filename, fileformat) {
if (navigator.msSaveBlob || window.URL || window.saveAs) {
if (canvas.toBlob) {
canvas.toBlob(function (blob) {
saveBlob(blob, filename);
}, fileformat);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <linux/input.h>
#include <sys/types.h>
#include <fcntl.h>
int main (int argc, char *argv[]) {
struct input_event ev;
@panzi
panzi / toronto_twitter.css
Last active November 7, 2015 18:14
Toronto Gal emote for twitter.com and Tweetdeck with scalable icon (SVG), colors and animations.
@-moz-document domain("twitter.com"), domain("tweetdeck.twitter.com") {
.hearty .prf .lst-profile .icon-favorite:before,
.hearty .tweet-action .icon-favorite:before,
.hearty .tweet-detail-action .icon-favorite:before {
-webkit-filter: grayscale(1) brightness(2.4);
filter: grayscale(1) brightness(2.4);
}
.hearty .prf .lst-profile a:hover .icon-favorite:before,
.hearty .prf .lst-profile a:focus .icon-favorite:before,
@panzi
panzi / dirdiff.py
Last active January 24, 2016 22:17
A very simple script to compare two folders, only based on file names (and not file content).
#!/usr/bin/env python
#
# A very simple script to compare two folders, only based on file names (and
# not file content).
# I'm sure there are lots of programs that do just this but given how short it
# is it was faster for me to write this than to search for a tool that does
# exactly what I want.
from __future__ import print_function
@panzi
panzi / new_ecmascript.html
Last active November 27, 2021 08:36
Pseudo synchronously load scripts that use new ECMAScript syntax in Chrome and Firefox.
<!--
This is useful in debug mode. For production you want to compile your
scripts down to an signle file and an old ECMAScript version.
-->
<script type="application/javascript;version=1.8">
// Firefox needs application/javascript;version=1.7 or ...;version=1.8
// for new ECMAScript syntax features. It will also include Mozilla-only
// syntax extensions, so be careful not to accidentally use those.
// However, other browsers don't understand that script type.
@panzi
panzi / stop_tweetdeck_videos.user.js
Last active October 5, 2016 01:20
This stops auto-play of videos (vines, GIFs) on TweetDeck. You can still manually play videos by clicking them, though.
// ==UserScript==
// @name Auto-scroll in rabb.it chat
// @namespace http://panzi.github.io/
// @description Automaticall scroll the chat on rabb.it to the bottom.
// @include https://www.rabb.it/*
// @include http://www.rabb.it/*
// @include https://rabb.it/*
// @include http://rabb.it/*
// @version 1.0
// ==/UserScript==
@panzi
panzi / rabbit-autoscroll.user.js
Created October 5, 2016 00:58
Automaticall scroll the chat on rabb.it to the bottom. You need to install the Greasemonkey Browser add-on.
// ==UserScript==
// @name Auto-scroll in rabb.it chat
// @namespace http://panzi.github.io/
// @description Automaticall scroll the chat on rabb.it to the bottom.
// @include https://www.rabb.it/*
// @include http://www.rabb.it/*
// @include https://rabb.it/*
// @include http://rabb.it/*
// @version 1.0
// ==/UserScript==