Skip to content

Instantly share code, notes, and snippets.

View JulienBreux's full-sized avatar

Julien Breux JulienBreux

View GitHub Profile
@jrom
jrom / nginx.conf
Created February 7, 2012 17:14
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@sss
sss / executable-with-subcommands-using-thor.log
Created February 24, 2012 20:16
Revised: Namespacing thor commands in a standalone Ruby executable
$ ./executable-with-subcommands-using-thor.rb
Tasks:
executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task
executable-with-subcommands-using-thor.rb subA [TASK] # Execute a task in namespace subA
executable-with-subcommands-using-thor.rb subB [TASK] # Execute a task in namespace subB
executable-with-subcommands-using-thor.rb test # test in CLI
$ ./executable-with-subcommands-using-thor.rb help
Tasks:
executable-with-subcommands-using-thor.rb help [TASK] # Describe available tasks or one specific task
@niepi
niepi / osx_php_homebrew.setup.md
Created February 28, 2012 13:23
OSX PHP Homebrew Setup

install php

with mysql pgsql intl support

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl

set php timezone in php ini

date.timezone = Europe/Vienna
@jpauli
jpauli / gist:2158791
Created March 22, 2012 14:54
Simple PHP chat using nc
<?php
$p = proc_open("/bin/nc -l -p 11111", array (STDIN, array("pipe", "w"), array("file", "/dev/null", 'w')), $pipes);
while (1) {
$read = array($pipes[1]);
$write = $except = null;
stream_select($read, $write, $except, 2);
echo fgets($pipes[1]);
}
@neocoder
neocoder / MainViewController.m
Created April 10, 2012 13:44
PhoneGap/Cordova patch to disable page elastic bounce
- (void)viewDidLoad
{
[super viewDidLoad];
UIScrollView* sv = nil;
for(UIView* v in self.webView.subviews){
if([v isKindOfClass:[UIScrollView class] ]){
sv = (UIScrollView*) v;
sv.bounces = NO;
}
}
@nixme
nixme / acr122u.rb
Created May 17, 2012 08:00
Read NFC tag IDs from a Tagstand ACR122U USB reader
# Quick and dirty script to read unique IDs from NFC tags using the ACR122U USB
# reader.
#
# PC/SC-based API details for the ACR122U available at
# http://acs.com.hk/drivers/eng/API_ACR122U_v2.01.pdf
#
# Assumes ruby >= 1.9.2
# `gem install smartcard` first
#
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@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 = git@github.com: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:

@umpirsky
umpirsky / Application.php
Created November 2, 2012 14:40
Enable query logging for Doctrine in Silex
<?php
if ($this['debug']) {
$logger = new DebugStack();
$this->extend('doctrine_orm.configuration', function(Configuration $configuration) use ($logger) {
$configuration->setSQLLogger($logger);
return $configuration;
});
@rayfranco
rayfranco / GravatarExtension.php
Last active November 6, 2018 05:30
Twig extension filter that convert email into gravatar url, or secure gravatar url
<?php
// Acme\DemoBundle\Twig\GravatarExtension
namespace Acme\DemoBundle\Twig;
class GravatarExtension extends \Twig_Extension
{
private $secure_request = false;