Skip to content

Instantly share code, notes, and snippets.

View cbrunnkvist's full-sized avatar

Conny Brunnkvist cbrunnkvist

View GitHub Profile
@cbrunnkvist
cbrunnkvist / example1.sh
Last active October 31, 2019 13:04 — forked from rbraband/example 1
Howto implement stored procedures within Redis (-with enable_strict_lua)
# Step 0 -- create test data
redis-cli HSET :object:30343552:data foo bar
# Step 1 -- store sample function 'sampleFunction'
redis-cli SET :functions:sample1 "
redis.call('SELECT', 0);
local data = redis.call('HGETALL', ':object:' .. ARGV[1] .. ':data');
return table.concat(data, '+');
"
@cbrunnkvist
cbrunnkvist / .bash_profile
Last active February 13, 2024 01:40 — forked from burpnoes/.bash_profile
Bash git prompt and command completion with Xcode / Mac OS X >= Mavericks (no Homebrew required)
if [ -f /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash ]; then
. /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash
fi
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.sh
# configuration variables as documented in:
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh#L8
#
GIT_PS1_SHOWDIRTYSTATE="yes"
@cbrunnkvist
cbrunnkvist / DIY-coroutines.js
Last active January 27, 2017 10:12
Extensively commented version of the simplest possible ES6 `co`/`Bluebird.coroutine`-like implementation
function executeWithCoroutine(generatorFunction) {
function letItYield(rejectionError, resolvedValue) {
// 1st round: resolvedValue is empty at kick off (see last line in executeAsCoroutine)
// 2nd round and onwards: resolvedValue is the value we pass ourselves at promise resolution
// let the generatorObject deal with the error in case of promise rejection
if (rejectionError) {
generatorObject.throw(rejectionError)
}
@cbrunnkvist
cbrunnkvist / traits-mixins-example-class-composition.js
Last active March 22, 2017 09:52
ES6 composition: mixins / traits using anonymous subclass factories
class Fig { constructor() { console.log("I'm Ficus carica") } }
const Dateable = (SC) => class extends SC { constructor() { super(); this.creationDate = new Date() } }
const Invisible = (SC) => class extends SC { isVisible() { return false } }
class InvisibleDateableFig extends Invisible(Dateable(Fig)) {}
let f = new InvisibleDateableFig()
// > f
@cbrunnkvist
cbrunnkvist / gist:0082aec281d745a0103ef8e784a75ada
Last active December 15, 2016 11:50
Docker LAMP development image: Echo access- and error log from dev server
From c12288f5242d84a497c60452562b535f3044f1da Mon Sep 17 00:00:00 2001
From: Conny Brunnkvist <cbrunnkvist@gmail.com>
Date: Thu, 15 Dec 2016 18:42:13 +0700
Subject: [PATCH] Echo access- and error log from dev server
---
devel/Dockerfile | 1 +
1 file changed, 1 insertion(+)
diff --git a/devel/Dockerfile b/devel/Dockerfile

Keybase proof

I hereby claim:

  • I am cbrunnkvist on github.
  • I am conny (https://keybase.io/conny) on keybase.
  • I have a public key whose fingerprint is 7E6F 21B0 5536 B1E6 B1D5 37FD BE54 54A1 14A6 40FD

To claim this, I am signing this object:

@cbrunnkvist
cbrunnkvist / docker-machine_dot_bash_profile.sh
Last active April 7, 2017 20:28
Bash aliases for common invocations of `docker-machine`
# ~/.bash_profile
# `docker-machine` is commonly used for controlling a local VM which acts as your
# Docker host. What occationaly happens is that I have to(*) restart the VM, and
# subsequently re-assign the DOCKER_* environment variables in each Terminal
# window I have open. These completion-friendly aliases makes it less of a chore.
alias docker-env-eval='eval "$(docker-machine env default)"'
alias docker-machine-refresh='(docker-machine stop || docker-machine kill) ; docker-machine start; docker-env-eval'
@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);
@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 / .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