Skip to content

Instantly share code, notes, and snippets.

View golgote's full-sized avatar

Bertrand Mansion golgote

  • Mamasam
  • Vincennes, France
View GitHub Profile
#!/usr/bin/env lua
-- This program aims to compress too big image when they are uploded
-- A directory and every subdirectories are watched via lua inotify binding :
-- http://github.com/hoelzro/linotify/
--
--
--
--
-- Requirements :
@golgote
golgote / import_module.c
Created December 3, 2011 08:30
PHP C to convert CSV to array found on http://e-normous.com/nerd/import_module.c
/*
compilation:
cc -fPIC -DCOMPILE_DL=1 -I/usr/local/src/php-4.2.3/main/ -I/usr/local/src/php-4.2.3/Zend/ -I/usr/local/src/php-4.2.3/ -I/usr/local/src/php-4.2.3/TSRM import_module.c -c -o import_module.o
gcc -shared -L/usr/local/lib -rdynamic -o import_module.so import_module.o
usage:
- assume headers are in the first row, use them for field titles
dl("/path/to/module");
start_import("/path/to/file");
@Joony
Joony / cssdoc.grammar
Created December 14, 2011 16:11
PEG grammar for CSSDoc
start
= yarr*
yarr
= __ docComment:docComment __ {
return docComment
}
docComment
= comment:comment lineTerminator styles:styles* __ orphanStyles* {
@adhipg
adhipg / countries.sql
Created January 12, 2012 11:41
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@stevedonovan
stevedonovan / ml.lua
Created February 15, 2012 09:36
Microlight - a really compact set of general Lua functions
-----------------
-- Microlight - a very compact Lua utilities module
--
-- Steve Donovan, 2012; License MIT
-- @module ml
local ml = {}
--- String utilties.
-- @section string
@usysrc
usysrc / main.lua
Created April 18, 2012 16:54
Code from my 2nd Löve Tutorial
-- tutorial #2
-- added enemys, shooting, background etc.
function love.load()
bg = love.graphics.newImage("bg.png")
hero = {} -- new table for the hero
hero.x = 300 -- x,y coordinates of the hero
hero.y = 450
hero.width = 30
@gavJackson
gavJackson / AbstractCommand.js
Created October 23, 2012 15:12
Robotlegs inspired classes with Agility.js
/**
* Created by IntelliJ IDEA.
* User: Digital Keystone (gavin.jackson)
* User: gavin.jackson
* Date: 06/03/12
* Time: 11:24
*/
/**
* Class: AbstractCommand
@josegonzalez
josegonzalez / access.lua
Created December 3, 2012 18:26
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
@adriengibrat
adriengibrat / l.php
Last active January 22, 2024 14:45
Extreme minification of shortest possible PSR-0 compliant autoloader, 5 lines !
<?php
//set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__); // optional
spl_autoload_register(function ($class) {
$file = preg_replace('#\\\|_(?!.+\\\)#','/', $class) . '.php';
if (stream_resolve_include_path($file))
require $file;
});
local _M = {}
local cjson = require "cjson"
local mysql = require "resty.mysql"
local math = require "math"
local encode = cjson.encode
local random = math.random
local insert = table.insert