Skip to content

Instantly share code, notes, and snippets.

View panzi's full-sized avatar

Mathias Panzenböck panzi

View GitHub Profile
@panzi
panzi / gist:4519534
Created January 12, 2013 17:45
fourcc as uint32_t
#include <stdint.h>
#include <endian.h>
#define _MAGIC_FROM_CHARS(C1,C2,C3,C4) (uint32_t)(((C1) << 24) | ((C2) << 16) | ((C3) << 8) | (C4))
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define MAGIC_FROM_CHARS(C1,C2,C3,C4) _MAGIC_FROM_CHARS(C4,C3,C2,C1)
#elif __BYTE_ORDER == __BIG_ENDIAN
BrowserPonies.loadConfig({"speed":3,"speakProbability":0.1,"volume":1,"interval":40,"fps":25,"interactionInterval":500,"audioEnabled":false,"showFps":false,"preloadAll":false,"showLoadProgress":true,"fadeDuration":500,"spawn":{"ScratchedDisk":1},"autostart":true,"ponies":[{"behaviors":[{"name":"Stand","probability":0.5,"maxduration":15,"minduration":7.56,"speed":0,"rightimage":"http://i.imgur.com/zCdjk.gif","leftimage":"http://i.imgur.com/fVo9j.gif","movement":"None","auto_select_images":false,"dont_repeat_animation":false,"skip":false,"x":0,"y":0,"rightcenter":{"x":53,"y":48},"leftcenter":{"x":53,"y":48},"group":0},{"name":"Trot","probability":0.5,"maxduration":15,"minduration":5,"speed":2,"rightimage":"http://i.imgur.com/OKpoI.gif","leftimage":"http://i.imgur.com/iRVOf.gif","movement":"Diagonal_horizontal","auto_select_images":false,"dont_repeat_animation":false,"skip":false,"x":0,"y":0,"rightcenter":{"x":53,"y":48},"leftcenter":{"x":53,"y":48},"group":0}],"speeches":[{"name":"Signing in","text":"Scratched
@panzi
panzi / getwebfont.sh
Last active December 15, 2015 21:18
This downloads all variants of a Google Web Font. Please be sure that the font in question uses a license that allows this.
#!/bin/bash
family=`echo "$1"|tr ' ' '+'`
filename=`echo "$1"|sed 's/ //g'`
weight=$2
subset=$3
if [ "$weight" != "" ]; then
family="$family:$weight"
filename="$filename-$weight"
// derived from https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js
var TRANSLITERATE_MAP = {
// latin
'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'AE', 'Å': 'A', 'Æ': 'AE', 'Ç':
'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Î': 'I',
'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö':
'OE', 'Ő': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ü': 'UE', 'Ű': 'U',
'Ý': 'Y', 'Þ': 'TH', 'ß': 'ss', 'à':'a', 'á':'a', 'â': 'a', 'ã': 'a', 'ä':
'ae', 'å': 'a', 'æ': 'ae', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e',
@panzi
panzi / mkplaylist.sh
Created June 21, 2013 01:54
Makes a playlist of all audio files in directory and all descendant directories. It detects audio files just by some well known file name extensions.
#!/bin/sh
dir="$1"
playlist="$2"
if [ "$playlist" = "" ]; then
playlist=playlist.m3u
fi
find "`readlink -f "$dir"`" -type f -and \( -iname '*.mp3' -or -iname '*.ogg' -or -iname '*.wav' -or -iname '*.flac' -or -iname '*.m4a' -or -iname '*.aac' -or -iname '*.wma' -or -iname '*.opus' \) > "$playlist"
@panzi
panzi / detect_svg_support.js
Created July 18, 2013 17:48
Detect SVG browser support.
function supportsSVG() {
return !!document.createElementNS && !!document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect;
}
@panzi
panzi / .bashrc
Last active March 26, 2017 10:25 — forked from henrik/.bashrc
No color and only show basename of current working directory.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine dir [master]$ # clean working directory
# username@Machine dir [master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ [\1$(parse_git_dirty)]/"
@panzi
panzi / main.rs
Last active December 20, 2015 14:59
None-working unsafe weakrefs for rust (currently crashes the compiler, later it will crash any program that uses this). **Don't use this!** This is just an experiment.
use weakref::{Weakref,Weakrefs,Referred};
mod weakref;
struct Node {
weakrefs: ~Weakrefs<Node>,
parent: ~Weakref<Node>,
children: ~[~Node],
data: ~str
}
@panzi
panzi / blogger-social-share-privacy.html
Last active December 20, 2015 21:09
Please consider hosting of the scripts, styles and images yourself.
<link rel="stylesheet" type="text/css" href="http://panzi.github.io/SocialSharePrivacy/stylesheets/jquery.socialshareprivacy.min.css" />
<style type="text/css">
#content-wrapper {
position: relative;
}
#share {
position: absolute;
top: 0px;
left: -100px;
opacity: 0.3;
@panzi
panzi / format.js
Created September 14, 2013 03:41
Very simple string interpolation in JavaScript. {} expands to positional arguments, {NAME} to named arguments, {{ to {, and }} to }.
function format (fmt, kwargs) {
var args = arguments;
var index = 1;
return fmt.replace(/{([^{}]*)}|{{|}}|{|}/g, function (match, key) {
if (key !== undefined) {
if (key) {
return kwargs[key];
}
else {