Skip to content

Instantly share code, notes, and snippets.

View cbrunnkvist's full-sized avatar

Conny Brunnkvist cbrunnkvist

View GitHub Profile
@cbrunnkvist
cbrunnkvist / upgrade_vbox_guest_additions.sh
Created September 13, 2011 10:09
Upgrading VirtualBox Guest Additions inside a running Vagrant box
#!/bin/sh
# For simplicity's sake I dump this file in the project folder and execute
# it from the VM straight out of /vagrant -> could run as part of box/basebox buildout.
alias apt-get="sudo apt-get"
alias mount="sudo mount"
alias umount="sudo umount"
# Oh. Start by making .vbox_version contain the desired version string.
VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
@cbrunnkvist
cbrunnkvist / sample-progress-indicator.py
Created September 21, 2011 09:09
Simplest fake progress indicator
#!/usr/bin/env python
# Update some incrementing counter to give feedback about progress
import time
import sys
try:
for i in range(101):
print i,
sys.stdout.flush()
time.sleep(0.01)
@cbrunnkvist
cbrunnkvist / unholy_sqlite_reorder.sh
Created October 3, 2011 11:15
Change row sequence of an SQLite table and reset/regenerate id (PK) column accordingly
#!/bin/sh
set -e
if [ ! -w "$1" ] ; then
echo "Usage: $0 [sqlite.db]"
exit 1
fi
sqlite3 -echo -bail $1 << __EOF
BEGIN TRANSACTION;
@cbrunnkvist
cbrunnkvist / gist:1766212
Created February 8, 2012 06:53
dot-gitconfig
[color]
branch = auto
status = auto
diff = auto
[alias]
svn-clone-head = "!f() { git svn clone -`svn log -q --limit 1 $1 | awk '/^r/{print $1}'` $1 $2; }; f"
ll = log --branches --oneline --graph --decorate -n10
aa = add --all
ca = commit --verbose --all
s = status
@cbrunnkvist
cbrunnkvist / script.js
Created December 10, 2012 18:15
Titanium Mobile: Branch in literal declaration
var Ti = {Platform:{osname:"android"}};
var theme = {
fontFamily: {
iphone : 'Helvetica Neue',
android : 'Droid Sans' }[Ti.Platform.osname]
};
document.body.appendChild(document.createTextNode(theme.fontFamily));
@cbrunnkvist
cbrunnkvist / km_KH.po
Created April 1, 2013 11:00
WordPress Khmer (km_KH) translation file / gettext catalog As stated in the meta-data, I am not (nor am I affiliated with-) the original author. I extracted this `.po` from an `.mo` original retrieved from the Internet Archive Wayback Machine: http://web.archive.org/web/*/http://translate.e-khmer.net/wordpress/wp-includes/languages/*
msgid ""
msgstr ""
"Project-Id-Version: OSSK (Open Source Software in Khmer)\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2006-03-09 10:17+0900\n"
"Last-Translator: Chay Sengtha <[email protected]>\n"
"Language-Team: OSSK <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
var FooPrototype = {
methodA: function methodA() {},
methodB: function methodB() {},
methodC: function methodC() {}
};
exports.createFoo = function() {
return Object.create(FooPrototype);
};
@cbrunnkvist
cbrunnkvist / gist:9157945
Last active August 29, 2015 13:56
Location-independent snippet for LiveReload without browser plugin
<script>
// Use LiveReload on iOS / Safari Mobile, in case your build tool middleware does not inject a tag already.
// Ref: http://feedback.livereload.com/knowledgebase/articles/86232-how-do-i-use-livereload-on-iphone-ipad-android-etc
// This variant of the script does away with having to hardcode the hostname (and protocol):
$(document).ready(function(){
$.getScript('//'+location.hostname+':35729/livereload.js');
});
</script>
<!-- </body> -->
#!/bin/sh
dig +short myip.opendns.com @resolver1.opendns.com
@cbrunnkvist
cbrunnkvist / retry.sh
Created August 22, 2014 09:00
Retry command line util exit with success
#!/bin/bash
function retry()
{
local n=0
local try=$1
local cmd="${@: 2}"
[[ $# -le 1 ]] && {
echo "Usage $0 <retry_number> <Command>"; }