Skip to content

Instantly share code, notes, and snippets.

View Mparaiso's full-sized avatar

mparaiso Mparaiso

View GitHub Profile
@Mparaiso
Mparaiso / pthreads.md
Created September 10, 2013 14:25 — forked from krakjoe/pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls
<?php
// src/Foobar/Controller/FooController.php
namespace Foobar\Controller;
class FooController
{
public function helloAction($request)
{
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
authRouteProvider.$inject = ['$routeProvider'];
function authRouteProvider ($routeProvider) {
/**
* Creates a controller bound to the route, or wraps the controller in param
* so the authentication check is run before the original controller is executed
* @param currentController
* @return {Function} The wrapper controller
*/
function redirectCtrlFactory (currentController) {
_ctrl.$inject = ['currentUser__', 'userRole__', '$location'];
var colors = ['#580201','#d9bd6a','#d9d49a','#037f8b','#025e73'];
var elems = [];
var body = document.getElementsByTagName('body')[0];
var xElems = window.innerWidth/30,
yElems = body.clientHeight/10,
fragment = document.createDocumentFragment();
for(var j = 0 ; j<yElems;j++){

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@Mparaiso
Mparaiso / currycompose.coffee
Created November 30, 2012 00:01 — forked from twfarland/currycompose.coffee
Currying / Function composition in coffeescript
arr = Array::
arrSlice = arr.slice
curry = ->
args = arrSlice.call arguments
->
args2 = arrSlice.call arguments
args[0].apply @, args.slice(1).concat(args2)
sum = ->
@Mparaiso
Mparaiso / Add field to an existing Django app with South
Created October 10, 2012 16:29 — forked from DaveEveritt/Add field to an existing Django app with South
quickly add field(s) to existing Django models with South
====================================================================
Simple-as-possible instructions to add a field (or more) using South
to an existing Django model with existing data.
====================================================================
Two versions:
1. Super-condensed (the bare minimum - jfdi)
2. Detailed-but-brief (if you want more information).
Notes: