Skip to content

Instantly share code, notes, and snippets.

View cbrunnkvist's full-sized avatar

Conny Brunnkvist cbrunnkvist

View GitHub Profile
@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 / 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 / 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 / ClosesConnectionsAfterTestTrait.php
Last active August 29, 2015 14:17
Make a LiipFunctionalTestBundle::WebTestCase explicitly close (some) Doctrine DB connections
<?php
namespace MVMS\ApiBundle\Tests;
trait ClosesConnectionsAfterTestTrait
{
public static $dbConnections = [];
/** @after */
public function ensureDbConnectionsGetClosed()
{
@cbrunnkvist
cbrunnkvist / ReflectsAndCleansPropertiesAfterTestTrait.php
Last active August 29, 2015 14:18
Try to keep PHP/Symfony/Doctrine functional tests memory usage from exploding #uphillbattle
<?php
namespace MVMS\ApiBundle\Tests;
trait ReflectsAndCleansPropertiesAfterTestTrait
{
/** @after */
public function cleanUpTestAndContainerProperties()
{
if (($container = $this->getContainer()) != null) {
$refl = new \ReflectionObject($container);
@cbrunnkvist
cbrunnkvist / Makefile.mk
Created July 28, 2015 07:29
Use make(1) to build a ZIP archive of current dir (originally used to prepare Chrome Web Store uploads)
# name the uploadable archive
ARCHIVE=MyChromePackagedAppSubmission.zip
###################
DIR=$(shell basename `pwd`)
release: build/$(ARCHIVE)
@echo Archive created: $(PWD)/build/$(ARCHIVE)
build/$(ARCHIVE): build *
@cbrunnkvist
cbrunnkvist / 05-lenovo-yoga-2-modeline.conf
Created July 31, 2015 05:05
Xorg (on Ubuntu 14.04) config for "1:2" pixel-to-element (=half resolution) display resolution
# Place in /usr/share/X11/xorg.conf.d/05-lenovo-yoga-2-modeline.conf
Section "Monitor"
Identifier "Monitor0"
# Calculated with "cvt $((3200/2)) $((1800/2))"
# 1600x900 59.95 Hz (CVT 1.44M9) hsync: 55.99 kHz; pclk: 118.25 MHz
Modeline "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
EndSection
Section "Screen"
@cbrunnkvist
cbrunnkvist / .inputrc
Last active October 14, 2015 11:54
[Mac OS X Terminal] Enable ^← and ^→ shortcuts for moving the cursor backward and forward fasterererER!
"\e[5D": backward-word
"\e[5C": forward-word
@cbrunnkvist
cbrunnkvist / android5.json
Created October 27, 2015 14:52
[Appcelerator Titanium SDK 4.1.1] First argument received by push notification event handler
{
"type": "callback",
"source": {
"pushType": "gcm",
"invocationAPIs": [],
"bubbleParent": true,
"showTrayNotification": true,
"enabled": false,
"__propertiesDefined__": true,
"singleCallback": false,
@cbrunnkvist
cbrunnkvist / promise-generator-coroutine.js
Created January 20, 2016 06:41
A verbose example of making JS/ES6 async code feel synchronous using generator/yield
'use strict';
const Promise = require('bluebird');
function someAsyncTask() {
return new Promise(function(resolve) {
let delay = Math.floor(Math.random() * 10000);
setTimeout(function () {
resolve(delay);