Skip to content

Instantly share code, notes, and snippets.

View peinwag's full-sized avatar
:octocat:

Patrick Einwag peinwag

:octocat:
View GitHub Profile
@peinwag
peinwag / StringCalculatorTest.php
Last active December 23, 2015 15:59
tdd session phpunconference2013
<?php
class StringCalculator
{
public function add($numbers)
{
$separators = array(',', "\n");
$matches = null;
preg_match_all("~^\[(.)\]*~", $numbers, $matches);
if(isset($matches[1][0]) && $matches[1][0] != null) {
@peinwag
peinwag / ubuntu-php-development-environment.md
Created November 3, 2012 12:54 — forked from DaRaFF/ubuntu-php-development-environment.md
Ubuntu php development environment

#Introduction If you're a php developer on ubuntu, there comes the time where you have to install/reinstall your system. I did it already a few times and i decided to write down the steps for a typical web developer stack with php. This is for a developer machine and not for live environment!

I hope it's a help also for you!

#Installation stack

@peinwag
peinwag / buildStructure.php
Created September 14, 2012 20:29
Structure creator for project euler problems
<?php
if(!file_exists('goutte.phar')) {
die("\ngoutte is missing! download it here: https://raw.github.com/fabpot/Goutte/master/goutte.phar\n");
}
require_once 'goutte.phar';
use Goutte\Client;
@peinwag
peinwag / gist:2994588
Created June 26, 2012 09:12
pre deployment scrip
#!/bin/bash
files=$(git diff --name-only master master@{1})
for file in $files; do
phpcsout=$(phpcs -s $file)
if [ "$phpcsout" != "" ]; then
affectedLines=$(git blame -s $file | grep eeb3cc3 | cut -d " " -f2 |sed 's/)//g')
@peinwag
peinwag / pre-commit.sh
Created June 22, 2012 08:49
Precommit hook for git that checks new modified lines against a given codingstandard with phpcs
#!/bin/bash
files=$(git diff-index --name-only --cached --diff-filter=ACMR HEAD --)
for file in $files; do
phpcsout=$(phpcs -s $file)
if [ "$phpcsout" != "" ]; then
affectedLines=$(git blame -s $file | grep 00000000 | cut -d " " -f2 |sed 's/)//g')
@peinwag
peinwag / gist:2867750
Created June 4, 2012 11:04
ipc notes
-----------------------------
Day 1 04.06.2012
-----------------------------
Profiling PHP Applications
-----------------------------
@peinwag
peinwag / gist:1944507
Created February 29, 2012 21:23
packages 4 sublimetext 2
- http://wbond.net/sublime_packages/package_control (package_control)
- https://github.com/Kronuz/SublimeCodeIntel (autocompletion)
- http://wbond.net/sublime_packages/community (all the crazy shit)
- http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/
@peinwag
peinwag / gist:1944485
Created February 29, 2012 21:19
sublimetext 2 eclipse keybindings
[
{ "keys": ["shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/Default/Add Line.sublime-macro"} },
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+alt+j"], "command": "join_lines" },
{ "keys": ["ctrl+alt+down"], "command": "duplicate_line" },
{ "keys": ["shift+ctrl+r"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["ctrl+shift+s"], "command": "save_all" },
{ "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["shift+ctrl+f4"], "command": "close_all" },
@peinwag
peinwag / gist:1767296
Created February 8, 2012 09:36
using the github url shortener
curl -i http://git.io -F "url=https://github.com/predscore" 2>&1 | egrep -o "http://git.io/(.*)$"
http://git.io/FH03Nw
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 260.19.06 (buildd@palmer) Mon Oct 4 16:01:38 UTC 2010
Section "ServerLayout"
# Removed Option "Xinerama" "0"
# Removed Option "Xinerama" "1"
Identifier "Layout0"
Screen 0 "Screen0" 0 0