Skip to content

Instantly share code, notes, and snippets.

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 April 5, 2012 11:11
A list of countries in 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 February 10, 2012 10:36
Pattern to check validity of URIs
<?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 August 9, 2011 15:51
JavaScript Singleton
/* Author:
- Félix Bellanger <[email protected]>
*/
var Singleton = (function() {
var instance = null;
function init(options) {
@keeguon
keeguon / mapreduce.php
Created August 4, 2011 08:38
Improved array Map/Reduce in PHP (wrote on the fly, need to be tested w/ real data)
<?php
class MapReduce
{
/**
* The original data
*
* @var array
*/
protected $data;
@keeguon
keeguon / .vimrc
Created April 6, 2011 09:11
My vimrc file
" 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 March 14, 2011 20:48
A class to manage background processes (launch, kill, get status) in PHP.
<?php
class Process
{
protected
$command = '',
$outputFile = '',
$pidFile = ''
;
@keeguon
keeguon / UIDGenerator.php
Created November 16, 2010 07:09
Generate somewhat strong unique identifiers
<?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
- (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 August 15, 2010 15:44
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.
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,