Skip to content

Instantly share code, notes, and snippets.

View ziadoz's full-sized avatar

Jamie York ziadoz

View GitHub Profile
@adactio
adactio / placeholderFromDatalist.js
Created August 12, 2012 15:54
Generate a placeholder attribute from the datalist associated with that input.
(function(win,doc) {
if (doc.querySelectorAll) {
var inputs = doc.querySelectorAll('input[list]'),
total = inputs.length;
for (var i=0; i<total; i++) {
var input = inputs[i],
id = input.getAttribute('list'),
list = doc.getElementById(id),
options = list.getElementsByTagName('option'),
amount = options.length,
@jamierumbelow
jamierumbelow / gist:3702259
Created September 11, 2012 21:38
Something stupidly cool in Ruby
def search id
Model.find id
rescue => e
log "Error in search: #{e.message}"
end
@jamierumbelow
jamierumbelow / composer.json
Created November 19, 2012 19:50
Installing PHPUnit via Composer
{
"require": {
"phpunit/phpunit": "3.7.*"
}
}
@cheeaun
cheeaun / jscampasia2012.md
Created November 29, 2012 08:19
JSCamp.Asia links & resources
@getify
getify / 1.md
Created November 30, 2012 12:04
rethink how javascript "inheritance" ACTUALLY works...

JavaScript does not have "inheritance" or "prototypal inheritance" or "classes" or any of that jazz... what you've been told, and how you've been taught about it, are a misunderstanding... all this nonsense about constructor functions and new and such... that's all hogwash... well, it's all unnecessary effort, at best.

"Instead... only try to realize the truth... there is no spoon."

What JavaScript does have is "behavior delegation"... and object linking through the "prototype chain"... you merely link two instances of objects together, say Foo and Baz, and say that Baz "delegates" to Foo for any behavior that Baz doesn't own itself but that Foo does own. And thus, any object b (aka, "b is an instance of Baz" in the more confusing terminology) which is linked to Baz, delegates first to Baz, and then to Foo, for behavior.

That's it. Seriously. And function constructors and new and all that stuff, everything you've read before about OO in JS, they're just distractions that lea

<?php
$connection = Illuminate\Database\Connectors\ConnectionFactory::make([
'driver' => 'mysql',
'host' => '',
'database' => '',
'username' => '',
'password' => '',
'charset' => '',
'prefix' => '',
@dhrrgn
dhrrgn / Db.php
Created December 8, 2012 02:31
The Db file for easy use of the Database package from L4 outside of L4.
<?php
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\ConnectionResolver;
use Illuminate\Database\DatabaseManager;
class Db {
private static $resolver = null;
@nojacko
nojacko / Testing PHP Random Salt Generation
Last active December 10, 2015 11:38
Testing PHP Random Salt Generataion
# Testing PHP Random Salt Generation
## Functions for generating salt
### mt_rand()
```
function mtSalt ($length = 22)
{
mt_srand();
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./';
$salt = '';
@mattattui
mattattui / deploy.sh
Created January 5, 2013 09:48
Simple default-safe rsync deployment script
#!/bin/bash
# Will add --dry-run unless the --go option is set. All other arguments passed to rsync (e.g. --delete)
SOURCE=.
DEST=example.com:/var/www/mysite
DRYRUN="--dry-run"
args=()
for var in "$@"
@igorw
igorw / FooController.php
Last active December 11, 2015 01:38
Convention-based Reflection Controller Provider for Silex.
<?php
// src/Igorw/FooController.php
namespace Igorw;
class FooController
{
function getIndexAction()
{