Skip to content

Instantly share code, notes, and snippets.

View cbrunnkvist's full-sized avatar

Conny Brunnkvist cbrunnkvist

View GitHub Profile
@cbrunnkvist
cbrunnkvist / gist:8d1172a32e52d5502d51
Created January 30, 2015 14:13
Avoid some DNS resolver slowness in Vagrant box (..?)
...
config.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
end
...
@cbrunnkvist
cbrunnkvist / gist:8ef4a0c26a6f49635156
Created December 29, 2014 03:39
Simple loop to run the tests - because sometimes editor plugins or file modification monitoring is just overkill.
while [ $? == 0 ] ; do OUTPUT=`./vendor/bin/phpunit --group wip 2>&1` ; clear ; echo "$OUTPUT" ; sleep 2 ; done
@cbrunnkvist
cbrunnkvist / start-mongodb-dev.sh
Created October 13, 2014 08:32
MongoDB lab start
#!/bin/bash
pushd $(dirname $0) > /dev/null
D=$(pwd)
echo D $D
popd > /dev/null
ulimit -n 1000
mongod --dbpath $D --logpath $D/mongodb.log --fork $*
@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>"; }
#!/bin/sh
dig +short myip.opendns.com @resolver1.opendns.com
@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> -->
var FooPrototype = {
methodA: function methodA() {},
methodB: function methodB() {},
methodC: function methodC() {}
};
exports.createFoo = function() {
return Object.create(FooPrototype);
};
@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"
@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 / 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