Skip to content

Instantly share code, notes, and snippets.

View bcremer's full-sized avatar

Benjamin Cremer bcremer

View GitHub Profile
@bcremer
bcremer / dropbox-share.sh
Last active August 29, 2015 13:56
Dropbox share file script
#!/usr/bin/env bash
##
# Required
# - dropbox-cli
# optional
# - xclip
# - convert (imagemagick)
##
@bcremer
bcremer / .vimrc
Created June 3, 2014 17:27
My .vimrc
set nocompatible " Disable vi compability
filetype off " required!
" Init Vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
@bcremer
bcremer / .Xmodmap
Last active August 29, 2015 14:04
.Xmodmap to map Capslock + j/k to brace left / brace right
! Forget any previous Caps Lock
clear Lock
keycode 66 = ISO_Group_Shift ISO_Group_Shift ISO_First_Group NoSymbol
keycode 44 = j J braceleft Down dead_belowdot dead_abovedot dead_belowdot
keycode 45 = k K braceright Up kra ampersand kra
keycode 30 = u U bracketleft U downarrow uparrow downarrow
keycode 31 = i I bracketright I rightarrow idotless rightarrow
@bcremer
bcremer / gist:12167985b442d0d195de
Created August 5, 2014 12:01
NGINX as caching REST-API Proxy
upstream backend {
server localhost:8080;
#server backup1.example.com:8080 backup;
#server backup2.example.com:8080 backup;
}
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:10m;
# Set cache key to include identifying components
@bcremer
bcremer / gist:9df5add4ddad08b4bf04
Created August 7, 2014 19:13
PhpStorm use XDG Base Directories
mv ~/.WebIde70/config ~/.config/WebIde70
cp /usr/share/phpstorm/bin/idea.properties ~/.config/WebIde70/idea.properties
vim ~/.config/WebIde70/idea.properties~/.config/WebIde70/idea.properties
- # idea.config.path=${user.home}/.WebIde/config
+ idea.config.path=${user.home}/.config/WebIde70
- # idea.system.path=${user.home}/.WebIde/system
+ idea.system.path=${user.home}/.cache/WebIde70
@bcremer
bcremer / php_class_visibility
Last active August 29, 2015 14:06
PHP Class Visibility
$ php php_class_visibility.php
private method called.
private method called.
@bcremer
bcremer / null_coalesce_operator_example.php
Last active August 29, 2015 14:07
PHP Null Coalesce Operator. Available since PHP7, see: https://wiki.php.net/rfc/isset_ternary
<?php
error_reporting(-1);
ini_set('display_errors', 1);
$example = ['foo' => ['bar' => 'baz']];
var_dump(
$example['foo'] ?? []
);
@bcremer
bcremer / digitalocean_debian_jessie_systemd_howto.md
Created February 6, 2015 21:20
DigitalOcean Debian Jessie with systemd

Install Debian Jessie on DigitalOcean using the Debian 7.0 x64 Image.

First update to Debian 8.0 Jessie:

# Source:
# http://unix.stackexchange.com/questions/90389/how-to-upgrade-debian-stable-wheezy-to-testing-jessie/90391#90391
cp /etc/apt/sources.list{,.bak}
sed -i -e 's/ \(stable\|wheezy\)/ testing/ig' /etc/apt/sources.list
apt-get update
@bcremer
bcremer / lsp_violation.php
Last active January 25, 2017 02:33
Liskov substitution principle Violation
<?php
// conditions are just semantic value objects containing constraint data
// handlers now how to interact with a condition it supports and operates on the given $querybuilder
// The LSP Violation happens in the generateCondition() method of the handler where we want to pull additional values from the condition object.
$condition = new SearchTermCondition("foobar");
$handler = new SearchTermConditionHandler();