Skip to content

Instantly share code, notes, and snippets.

View cschaba's full-sized avatar

Carsten Schabacker cschaba

View GitHub Profile
@acdha
acdha / pre-commit
Last active April 18, 2024 02:22
Git pre-commit hook which runs various code linters. Install this to .git/hooks/pre-commit inside your favorite repos
#!/usr/bin/env PYTHONIOENCODING=utf-8 python
# encoding: utf-8
"""Git pre-commit hook which lints Python, JavaScript, SASS and CSS"""
from __future__ import absolute_import, print_function, unicode_literals
import os
import subprocess
import sys
@siddhadev
siddhadev / gist:5814802
Last active November 9, 2021 17:20
Bash script for fixing subversion's "Working copy text base is corrupt" error
#!/bin/bash
set -e
usage(){
echo "Error $errcode $errorcode at line ${BASH_LINENO[0]} while executing: $BASH_COMMAND"
exit $errorcode
}
trap usage ERR
@willurd
willurd / web-servers.md
Last active May 30, 2024 02:54
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@mloughran
mloughran / page.html
Created March 16, 2012 19:27
Mobile Safari crash when returning to WebSocket page
<html>
<head>
<script>
function debug(string) {
var element = document.getElementById("debug");
var p = document.createElement("p");
p.appendChild(document.createTextNode(string));
element.appendChild(p);
}
@grigs
grigs / browserdetect.js
Created March 13, 2012 17:12
Apple's Browser Detection Script - prettified from http://images.apple.com/global/scripts/browserdetect.js
if (typeof (AC) === "undefined") {
AC = {}
}
AC.Detector = {
getAgent: function () {
return navigator.userAgent.toLowerCase()
},
isMac: function (c) {
var d = c || this.getAgent();
return !!d.match(/mac/i)
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@gwarser
gwarser / readcookies.py
Created October 29, 2011 14:21
Opera cookies4.dat reader
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from __future__ import print_function
import os, sys
import struct as st
import time as tm
uint32 = '>I'
int32 = '>i'
@pklaus
pklaus / tunnelbroker-net.sh
Last active January 14, 2024 12:10
tunnelbroker.net automatic tunnel IP update and tunnel setup (on Mac OS X)
#!/bin/bash
#### This script is published by Philipp Klaus <philipp.l.klaus@web.de>
#### on <http://blog.philippklaus.de/2011/05/ipv6-6in4-tunnel-via-hurricane-electric-tunnelbroker-net-automatic-ip-update-on-mac-os-x/>
#### It is originally by freese60 and modified by limemonkey.
#### Found on <http://www.tunnelbroker.net/forums/index.php?topic=287.0>
### Uncomment this line to debug the script:
#set -x
var keyboard = function(window) {
var keyboard = window.keyboard || {};
if (!('isPressed' in keyboard)) {
keyboard._keys = {};
var handler = function(e, flag) {
var key = String.fromCharCode(e.which).toLowerCase();
keyboard._keys[key] = flag;