Skip to content

Instantly share code, notes, and snippets.

View romac's full-sized avatar
🔮
λ

Romain Ruetschi romac

🔮
λ
View GitHub Profile
@romac
romac / Mumbo-Jumbo Email Address Validation Regular Expression
Created October 27, 2009 09:57
Mumbo-Jumbo Email Address Validation Regular Expression
As saw in the FLOW3 (http://flow3.typo3.org) sources:
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:
@romac
romac / RRNil.class.php
Created November 11, 2009 13:20
A PHP 5 class miming Objective-C's nil object.
<?php
/*
* Copyright (c) 2009, Romain Ruetschi <[email protected]>
* Code licensed under the BSD License:
* See http://opensource.org/licenses/bsd-license.php
*/
final class RRNil
{
@romac
romac / PTMFRO.txt
Created November 30, 2009 23:42
PHP Turing Machine First Run Output
Input
=====
1:0:+1|1:1:+1|2:e:-1
3:e:-1|4:e:-1|0:e:-1
3:e:-1|3:e:-1|5:1:+1
4:e:-1|4:e:-1|5:1:+1
0:e:-1|0:e:-1|0:e:-1
Starting Turing Machine
=======================
@romac
romac / _allup
Created February 17, 2010 10:40
This simple bash script update all the working copies in the current folder. Handle Git and Subversion.
#!/usr/bin/env bash
cd "$1";
PATH=`pwd`;
SVN_FOLDER=".svn"
SVN_BIN="/opt/local/bin/svn"
GIT_FOLDER=".git"
GIT_BIN="/opt/local/bin/git"
<?php
// Include the autoloader.
require_once( dirname( __FILE__ ) . '/Classes/RRoEmbed/Autoloader.class.php' );
// Register the autoloader.
RRoEmbed_Autoloader::getInstance()->register();
// Create a new consumer.
$c = new RRoEmbed_Consumer();
<?php
/*
* Copyright (c) 2010 Romain Ruetschi <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@romac
romac / Increment Digits In Selected Text.php
Created June 17, 2010 11:50
Two Commands for TextMate which allows you to increment any digits/numbers in the selected text.
#!/usr/bin/env php
<?php
$text = $_ENV[ 'TM_SELECTED_TEXT' ];
print preg_replace_callback(
'/(\d)/',
function( $matches )
{
return $matches[ 0 ] + 1;
@romac
romac / RRoEmbedUsageExample.php
Created June 19, 2010 13:54
RRoEmbed Usage Example
<?php
// Include the autoloader.
require_once( dirname( __FILE__ ) . '/Classes/RRoEmbed/Autoloader.class.php' );
// Register the autoloader.
RRoEmbed_Autoloader::getInstance()->register();
// Create a new consumer.
$c = new RRoEmbed_Consumer();
@romac
romac / .gitconfig GitHub token protection on Mac OS X
Created November 2, 2010 09:39
To make this work, you should first create a password in "Keychain Access" named "github.token" and set the password to your GitHub token.
# To make this work, you should first create a password in "Keychain Access" named "github.token" and set the password to your GitHub token.
[github]
user = USERNAME
token = !security 2>&1 >/dev/null find-generic-password -gs github.token | ruby -e 'print $1 if STDIN.gets =~ /^password: \\\"(.*)\\\"$/'
@romac
romac / Singleton.class.php
Created November 2, 2010 17:29
A self-contained Singleton for PHP 5.3
<?php
abstract class Singleton
{
/**
* This is an array of the different singletons instances, indexed
* by class name.
*
* @var Singleton[]