Skip to content

Instantly share code, notes, and snippets.

@lastguest
lastguest / event.function.php
Last active September 6, 2023 23:24
PHP global event handling in a single function.
<?php
/*
* Use
* event('eventname',function(){ ... })
* to add an event handler for 'eventname' event.
*
* Trigger an event with
* event('eventname')
*
upstream php {
server unix:/var/run/php5-fpm.sock;
}
server {
# enforce NO www
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
@DavertMik
DavertMik / gist:7969053
Created December 15, 2013 04:53
EmailTestCase for testing emails with MailCatcher in PHPUnit
<?php
class EmailTestCase extends PHPUnit_Framework_TestCase {
/**
* @var \Guzzle\Http\Client
*/
private $mailcatcher;
public function setUp()
{
@branneman
branneman / better-nodejs-require-paths.md
Last active July 25, 2026 13:41
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@leesmith
leesmith / simple-git-workflow.md
Last active December 30, 2023 23:37
Simple Git Workflow For Continuous Delivery

Simple Git Workflow For Continuous Delivery

Workflow guidelines:

  • master branch is always production-ready, deployable, 100% green test suite
  • New development is done on feature branches, with frequent rebasing onto master
  • Clean commit history by preferring to rebase instead of merge (git pull is configured to automatically rebase)

rebase workflow

Workflow

@noteed
noteed / docker-ovs.md
Last active December 29, 2023 07:07
Docker - Open vSwitch setup
@d11wtq
d11wtq / docker-ssh-forward.bash
Created January 29, 2014 23:32
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@markllama
markllama / schema2ldif.sh
Last active November 30, 2025 10:05
Convert LDAP Schema to LDIF
#!/bin/bash
#
# Stolen from https://stuckinadoloop.wordpress.com/2011/04/14/script-to-convert-openldap-schema-files-to-ldif-format/
SCHEMAD=/etc/openldap/schema
SCHEMAS='dhcp.schema'
tmpd=`mktemp -d`
pushd ${tmpd} >>/dev/null
@mathiasverraes
mathiasverraes / TestFrameworkInATweet.php
Last active May 17, 2026 04:00
A unit testing framework in a tweet.
<?php
function it($m,$p){echo ($p?'✔︎':'')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
@BinaryGeometry
BinaryGeometry / Configure codeigniter-restserver for use with Ember.js
Last active August 10, 2016 09:26
Configure codeigniter-restserver for use with Ember.js
First off you need to modify application/config/rest.php
```
$config['rest_default_format'] = 'json';
```
This will ensure that when your api call is made the server will return json without an additional segment.
You must then create an api controller that will return your codeigniter model in the correct format for Ember.js
```
<?php
require(APPPATH.'/libraries/REST_Controller.php');