Skip to content

Instantly share code, notes, and snippets.

View golgote's full-sized avatar

Bertrand Mansion golgote

  • Mamasam
  • Vincennes, France
View GitHub Profile
@golgote
golgote / partition_trigger.sql.lua
Created October 9, 2014 18:55
PLlua procedure and trigger to automatically create partition tables in Postgresql
--- vim: set nosta noet ts=4 sw=4 ft=lua:
---
--- Hello. I'm a partitioner that puts rows into dated tables, segmented by date ranges.
--- Install me like so on your master table, as a db admin user (for the security definer):
---
--- CREATE TRIGGER auto_partition BEFORE INSERT ON [table] FOR EACH ROW EXECUTE PROCEDURE auto_partition()
---
CREATE OR REPLACE FUNCTION clear_partition_cache()
RETURNS boolean
@golgote
golgote / readcookie.js
Created September 9, 2014 12:17
Fast function to read cookies in javascript browser
function readcookie(a, b, c) {
b = '; ' + document.cookie;
c = b.split('; ' + a + '=');
return !!(c.length - 1) ? c.pop().split(';').shift() : '';
}
<?
function get_avatar_from_service($service, $userid, $size) {
// Based on original Javascript function at https://gist.github.com/jcsrb/1081548
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter (via avatars.io) use get_avatar_from_service('twitter', username, default )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
@golgote
golgote / l.php
Created December 22, 2013 20:52 — forked from adriengibrat/l.php
<?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;
});
- 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"
@golgote
golgote / vlcrc.js
Created September 5, 2013 22:41 — forked from garth/vlcrc.js
// To start vlc with telnet remote control:
// ./VLC --extraintf rc --rc-host 0.0.0.0:3000
//
// To connect to multiple vlc's
// node vlcrc.js host1:3000 host2:3000
var net = require('net');
var readline = require('readline');
//addresses of servers
@golgote
golgote / Count tweets, likes, shares, etc
Last active December 22, 2015 08:09
Found here : http://toolspot.org/script-to-get-shared-count.php API used here might be deprecated
<?
class shareCount
{
private $url,$timeout;
function __construct($url,$timeout=10)
{
$this->url=rawurlencode($url);
$this->timeout=$timeout;
}
@golgote
golgote / gist:6130472
Created August 1, 2013 11:17
Old init script for openoffice daemon, with umask
#!/bin/sh
# Startup script for soffice
#
# chkconfig: 2345 75 35
# description: Run soffice in server mode
# Source function library.
. /etc/rc.d/init.d/functions
SOFFICE=/opt/openoffice.org2.4/program/soffice
@golgote
golgote / gist:4106044
Created November 18, 2012 16:13
Lua 5.2 html generator
--[[ ©2012 Tangent128
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 furnished to
do so, subject to the Conditions of the MIT License as specified here:
http://opensource.org/licenses/MIT
@golgote
golgote / gist:1509226
Created December 22, 2011 06:24
Shell script for mounting sshfs volumes found on Crunchbanglinux
#!/bin/sh
# A bash script for muotning remote systems using sshfs
#------------------------------------------------------------
clear
echo "This script will help you mount a remote system using sshfs."
echo ""
echo -n "Continue? (Y|n) > "
read a
if [ "$a" = "y" ] || [ "$a" = "Y" ] || \
[ "$a" = "" ]; then