Skip to content

Instantly share code, notes, and snippets.

View assertchris's full-sized avatar

Christopher Pitt assertchris

View GitHub Profile
@assertchris
assertchris / rules.md
Last active January 2, 2016 20:19 — forked from machuga/rules.md

Asking for help in #laravel on Freenode

Please behave in a polite, considerate, and inclusive manner in the channel at all times. People volunteer their time in the channel to help people like you with your Laravel problems and some respect (in both directions) will go an extremely long way.

When asking questions in the #laravel channel, please follow these 12 simple rules.

  1. Do your research before hand. Your question may be answerable with a quick Google search or by simply experimenting. If it's a concept you're confused about, first check out our Official Documentation. If you're using a method in Laravel, you can look it up in the API Docs.
  2. If you've tried Googling, explain what terms you've tried to use so people can better help you.
  3. Clearly explain what is happening and create a Help Request (http://help.laravel.io) to better explain yourself, or just a simple Gist (http://gist.github.com) if you are just creating a simple example
App 1: App::bind('Full\Interface\Namespace', 'Full\Implementation\Namespace1');
App 2: App::bind('Full\Interface\Namespace', 'Full\Implementation\Namespace2');
App 3: App::bind('Full\Interface\Namespace', 'Full\Implementation\Namespace3');
App 4: App::bind('Full\Interface\Namespace', 'Full\Implementation\Namespace4');
App::bind('Full\Interface\Namespace', 'Full\Implementation\Namespace');
class Foo
{
public function __construct(Full\Interface\Namespace $bar)
{
$this->bar = $bar; // instance of Full\Implementation\Namespace
}
}
$posts = Post::whereHas('comments', function($q)
{
$q->where('content', 'like', 'foo%');
})->get();
@assertchris
assertchris / gist:8283083
Last active January 2, 2016 09:29
Temporarily setting local environment until Vagrant setup is complete.
$env = $app->detectEnvironment(function() {
return "local";
});
# Remove APT cache
apt-get clean -y
apt-get autoclean -y
# Zero free space to aid VM compression
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
# Remove APT files
find /var/lib/apt -type f | xargs rm -f
<?php
# ...
$filters = [];
foreach (Input::all() as $key => $value)
{
if ($key->startsWith("filter:") or $key->startsWith("where:"))
{
@assertchris
assertchris / gist:5305496
Created April 3, 2013 21:26
Arduino N-Tier Demultiplexing
int controlPin1 = 2;
int controlPin2 = 3;
int controlPin3 = 4;
int controlPin4 = 5;
int controlPin5 = 6;
int controlPin6 = 7;
int signalPin = 9;
<?php
class SplNotReallyFixedArray extends SplFixedArray
{
public function offsetSet($index, $value)
{
if ($index > $this->getSize() - 1)
{
$this->setSize($index + 1);
}
@assertchris
assertchris / gist:5097745
Last active June 6, 2016 00:18
Converting from any base number system to decimal (and back).
<?php
function toDecimal($base, $value)
{
$value = (string) $value;
$key = array_flip(str_split($base));
$base = count($key);
$parts = str_split($value);