Skip to content

Instantly share code, notes, and snippets.

View coderabbi's full-sized avatar

Yitz Willroth coderabbi

View GitHub Profile
@bussiere
bussiere / citations
Created December 24, 2010 10:16
citations quote informatic informatique quotes computer science
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
“In order to understand recursion, one must first understand recursion.” – Author Unknown
“I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone.” – Bjarne Stroustrup
“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila.” – Mitch Ratcliffe
“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -C.A.R. Hoare
“The gap between theory and practice is not as wide in theory as it is in practice.” – Author Unknown
“If builders built buildings the way progra
@ziadoz
ziadoz / awesome-php.md
Last active July 13, 2024 05:29
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
#!/bin/zsh
#
# Highlight a given file and copy it as RTF.
#
# Simon Olofsson <simon@olofsson.de>
#
set -o errexit
set -o nounset
@adamwathan
adamwathan / scublish.sh
Created November 4, 2014 14:57
Sculpin GitHub publish script
function scublish() {
sculpin generate --env=prod
cd output_prod
git add --all
git commit -am "$1"
git push origin master
cd ..
}
# Tail Laravel and Webserver (NGINX & Apache 2) log files
# Compatible with Laravel 4 & 5
#
alias tl="ls -d /var/log/nginx/* /var/log/apache2/* storage/logs/* app/storage/logs/* storage/laravel.log | grep -v 'gz$' | grep -v '1$' | xargs tail -f"
@bgallagh3r
bgallagh3r / hosts.ps1
Created December 10, 2014 00:43
Powershell script to add/edit/list/remove entries from the hosts file.
Set-ExecutionPolicy RemoteSigned
# Edit HOSTS file Script
# Brian Gallagher (http://briangallagher.me)
#
# If you use Sublime text, and don't have an alias for it yet, uncomment the line below and change the path to ST
#Set-Alias st 'C:\Program Files\Sublime Text 3\sublime_text.exe'
$file = join-path -path $env:SystemRoot -childpath "System32\drivers\etc\hosts"

Start throwing "not found" exceptions in your repositories

99% of the time you're going to want to bail if you're expecting to find an entity by a specific key. Having code like the two private methods in the old code below in every single one of your handlers is crazy and not DRY.

I think the idea of "only throw exceptions when something exceptional happens" is too generic and doesn't take context into consideration.

A repository's only job is to find entities. If you give it a key and it can't find it, i think that's exceptional(in the context of the repository).

If it actually is expected in your client code it's not a big deal, catch the EntityNotFoundException and carry on.

@adamwathan
adamwathan / import-reference.md
Last active December 5, 2016 06:58
Importing class mixins by reference

This is the workflow I really love with Less that's missing in Sass. Killer way to use a library like Bootstrap without coupling any of your markup to Bootstrap itself.

Import a bunch of vendor styles by reference only, mix in the classes you want to keep into your own aliases, no vendor class names end up in your compiled CSS.

Sass doesn't support reference import or the ability to mixin a class, only a mixin.

// Vendor less
.btn {
 // a bunch
@ryanwinchester
ryanwinchester / bitwise.php
Last active May 22, 2024 11:19
BITWISE FLAGS for Custom PHP Objects
<?php
/**
* BITWISE FLAGS for Custom PHP Objects
*
* @link http://php.net/manual/en/language.operators.bitwise.php#108679
*
* Sometimes I need a custom PHP Object that holds several boolean TRUE or FALSE values.
* I could easily include a variable for each of them, but as always, code has a way to
* get unweildy pretty fast. A more intelligent approach always seems to be the answer,
@jlem
jlem / ApplicationsServiceProvider.php
Created August 21, 2015 14:35
Laravel 5 App Skeleton
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Request;
use View;
use App;
abstract class ApplicationsServiceProvider extends ServiceProvider
{
public function register()