Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am keeguon on github.
  • I am keeguon (https://keybase.io/keeguon) on keybase.
  • I have a public key whose fingerprint is F521 7FD3 0B9B B2DF 3C3D A937 1741 1310 CAFD 785E

To claim this, I am signing this object:

@keeguon
keeguon / countries.json
Created Apr 5, 2012
A list of countries in JSON
View countries.json
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@keeguon
keeguon / gist:1788669
Created Feb 10, 2012
Pattern to check validity of URIs
View gist:1788669
<?php
$pattern = "/^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?$/i";
@keeguon
keeguon / singleton.js
Created Aug 9, 2011
JavaScript Singleton
View singleton.js
/* Author:
- Félix Bellanger <felix.bellanger@gmail.com>
*/
var Singleton = (function() {
var instance = null;
function init(options) {
@keeguon
keeguon / mapreduce.php
Created Aug 4, 2011
Improved array Map/Reduce in PHP (wrote on the fly, need to be tested w/ real data)
View mapreduce.php
<?php
class MapReduce
{
/**
* The original data
*
* @var array
*/
protected $data;
@keeguon
keeguon / .vimrc
Created Apr 6, 2011
My vimrc file
View .vimrc
" Theme
set background=dark
let g:solarized_termcolors=16
colorscheme solarized
" General settings
syntax on
set nocompatible
set number
@keeguon
keeguon / Process.class.php
Created Mar 14, 2011
A class to manage background processes (launch, kill, get status) in PHP.
View Process.class.php
<?php
class Process
{
protected
$command = '',
$outputFile = '',
$pidFile = ''
;
@keeguon
keeguon / UIDGenerator.php
Created Nov 16, 2010
Generate somewhat strong unique identifiers
View UIDGenerator.php
<?php
/**
* Generate somewhat strong unique identifiers
* Example usage:
* - create non standard mysql ids
* - create app key/secret for OAuth
* - ...
*
* @return string containing the unique identifier
View gist:540019
- (NSString *)niceTimeFormat:(NSTimeInterval)interval {
// set a past flag if the timeInterval is negative and inverse it
BOOL past = NO;
if (interval < 0) {
past = YES;
interval = -interval;
}
// set some time units
double second = 1, minute, hour, day, week;
@keeguon
keeguon / gist:525624
Created Aug 15, 2010
Basic Twitter object, demo at the bottom (require jQuery here but could also write your own Ajax function). This should work w/ all Twitter APIs which do not require authentification.
View gist:525624
var Twitter = {
version: '1.0',
apiUrl: 'http://api.twitter.com',
apiVersion: '1',
api: function(endpoint, options, callback) {
var fullUrl = this.apiUrl + '/' + this.apiVersion + '/' + endpoint + '.json';
$.ajax({
async: true,
url: fullUrl,
data: options.data,