Skip to content

Instantly share code, notes, and snippets.

View srdjanmarjanovic's full-sized avatar

Srdjan Marjanovic srdjanmarjanovic

View GitHub Profile
@srdjanmarjanovic
srdjanmarjanovic / sum_array
Created July 7, 2015 12:43
Function to sum all members of an array with array_reduce
function sum_array(array $params) {
return array_reduce($params, function($sum, $item){
return $sum += $item;
}, 0);
}
@srdjanmarjanovic
srdjanmarjanovic / slugify.bash
Created January 19, 2016 12:32
Useful script for naming branches for Git flow
#!/bin/bash
type="$1"
title="$2"
max_length="${3:-150}"
slug="$({
tr '[A-Z]' '[a-z]' | tr -cs '[[:alnum:]]' '-'
} <<< "$title")"

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@srdjanmarjanovic
srdjanmarjanovic / Pretty git log
Created December 24, 2016 20:07 — forked from JeffreyWay/.bash_profile
Prettier git logs
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@srdjanmarjanovic
srdjanmarjanovic / decorator.php
Created December 24, 2016 20:10 — forked from JeffreyWay/decorator.php
Decorator PHP dummy example
<?php
interface Thing {
public function execute();
}
class A implements Thing {
public function execute()
@srdjanmarjanovic
srdjanmarjanovic / Vagrantfile
Created December 24, 2016 20:28 — forked from JeffreyWay/Vagrantfile
Quickie vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.33.21"
@srdjanmarjanovic
srdjanmarjanovic / SSH key copy
Last active December 24, 2016 20:33 — forked from JeffreyWay/gist:6176883
Add this to your bash_profile. Now, whenever you need to fetch your ssh-key, just type sshkey, and it'll be copied to your clipboard.
alias sshkey="cat ~/.ssh/id_rsa.pub | pbcopy && echo 'Copied to clipboard.'"
@srdjanmarjanovic
srdjanmarjanovic / pattern-state.php
Last active December 29, 2016 23:22
Simple Light On/Off PHP example of the State Design Pattern
<?php
interface StateInterface {
/**
* Turn the light on.
*/
public function ligthOn();
/**
* Turn the light off.
@srdjanmarjanovic
srdjanmarjanovic / pattern-strategy.php
Created December 30, 2016 22:12
Simple PHP example of the Strategy Design Pattern
<?php
interface StrategyInterface {
/**
* Do something.
*/
public function handle();
}
class Context {
@srdjanmarjanovic
srdjanmarjanovic / gist:44b5fa6a5fcf8b3e29b84c5c536f71f7
Last active May 18, 2017 20:35 — forked from tabacitu/gist:dbcfd71375e72c857474
Tabacitu Laravel Package Service Provider boilerplate code
<?php
namespace League\Skeleton;
use Illuminate\Support\ServiceProvider;
use Illuminate\Routing\Router;
class SkeletonServiceProvider extends ServiceProvider
{
/**