Skip to content

Instantly share code, notes, and snippets.

View bendavies's full-sized avatar
🏠
Working from home

Ben Davies bendavies

🏠
Working from home
View GitHub Profile
@sixfeetover
sixfeetover / osx_homebrew_rvm_rails_unixodbc_sqlserver.md
Created September 4, 2010 19:49
Setup OS X 10.6.4 w/ homebrew, rvm, rails, unixodbc, freetds and SQL Server

Setup new mac from scratch

These commands are good as of 2010-11-18.

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

Install xcode (download, or on the OS X install DVD)

http://developer.apple.com/technology/xcode.html
@Ocramius
Ocramius / User.php
Created October 23, 2011 14:22
Doctrine 2 @OneToMany @manytoone example
<?php
namespace HelloWorld;
use InvalidArgumentException;
/**
* This class is somewhere in your library
* @Entity
* @Table(name="users")
*/
@ziadoz
ziadoz / awesome-php.md
Last active May 10, 2024 15:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@suprememoocow
suprememoocow / intercept.js
Created May 29, 2012 09:53
AJAX timing interceptor: this class intercepts all AJAX calls and records the time taken for the HTTP request to complete. These timings are posted back to the server in batches, if there are any to send, about every two seconds. Tested in Firefox, Chrome
(function(XHR) {
"use strict";
var stats = [];
var timeoutId = null;
var open = XHR.prototype.open;
var send = XHR.prototype.send;
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active June 5, 2024 22:16 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@Ocramius
Ocramius / User.php
Last active February 16, 2024 14:57
Doctrine 2 ManyToMany - the correct way
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*/
class User
@stevelacey
stevelacey / UrlGenerator.php
Last active October 7, 2015 21:18
Symfony2: use object to set route parameters
<?php
namespace Acme\BaseBundle\Routing\Generator;
use Symfony\Component\Routing\Generator\UrlGenerator as BaseUrlGenerator;
use Doctrine\Common\Util\Inflector;
/**
* UrlGenerator generates URL based on a set of routes.
*
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active June 28, 2024 08:56
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@makasim
makasim / gist:3720535
Last active June 26, 2017 06:32
form partial bind
<?php
namespace Foo\CoreBundle\Form\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormInterface;
/**
* Changes Form->bind() behavior so that it treats not set values as if they
@kjantzer
kjantzer / jquery.sortableWithIndexWatch.js
Created September 19, 2012 17:00
jQuery sortableWithIndexWatch - modified jquery ui sortable widget to store before and after index of moved item
// custom Sortable widget - gets before and after index of moved item
// https://gist.github.com/3750782
$.widget("ui.sortableWithIndexWatch", $.extend({}, $.ui.sortable.prototype, {
_trigger: function() {
switch(arguments[0]){
case 'start':
this.currentItem.indexStart = this.currentItem.index();