Skip to content

Instantly share code, notes, and snippets.

@beberlei
beberlei / tailrecursion.php
Created November 25, 2012 21:25 — forked from pkriete/gist:2425817
PHP Tail Recursion
<?php
class TailRecursion
{
public $func;
public $acc;
public $recursing;
public function tail()
{
return call_user_func_array($this->func, func_get_args());
@davedevelopment
davedevelopment / index.php
Created November 13, 2012 16:36
Tinkering with a Hal resource DTO, separating the framework from the app and content negotiation
<?php
namespace Demo {
require __DIR__."/vendor/autoload.php";
use Nocarrier\Hal;
class Resource extends Hal {}
class ResourceResponse
<?php
require __DIR__.'/vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
// Create a blob of data for testing
$data = '';
for ($i = 1; $i <= 8; $i++) $data .= $i.str_repeat("\0", 1022)."\n";
@igorw
igorw / FooController.php
Created September 5, 2012 22:13
Silex convention-based controllers
<?php
// src/Foobar/Controller/FooController.php
namespace Foobar\Controller;
class FooController
{
public function helloAction($request)
{
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@cboden
cboden / UvConnection.php
Created July 13, 2012 13:55
Ratchet w/ php-uv
<?php
namespace Ratchet\Server;
use Ratchet\ConnectionInterface;
class UvConnection implements ConnectionInterface {
private $client;
public function __construct($client) {
$this->client = $client;
}
@m4rw3r
m4rw3r / gist:3070816
Created July 8, 2012 12:53
Test interpreter with function-pointers
#include <inttypes.h>
#include <stdio.h>
#define Util_StaticAssert_CONCAT_(a, b) a##b
#define Util_StaticAssert_CONCAT(a, b) Util_StaticAssert_CONCAT_(a, b)
#define Util_StaticAssert(e, msg) \
enum { Util_StaticAssert_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }
@jboner
jboner / latency.txt
Last active April 25, 2025 07:06
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@simonjodet
simonjodet / gist:2713959
Created May 16, 2012 21:07
Nginx configuration for pretty URLs in Silex
server
{
listen 80;
server_name website.loc www.website.loc;
access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log;
root /var/www/website.loc/web/;
index index.php;
@paulmillr
paulmillr / active.md
Last active April 24, 2025 10:07
Most active GitHub users (by contributions). https://paulmillr.com

Most active GitHub users (git.io/top)

The list would not be updated for now. Don't write comments.

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Because of GitHub search limitations, only 1000 first users according to amount of followers are included. If you are not in the list you don't have enough followers. See raw data and source code. Algorithm in pseudocode:

githubUsers