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 / gist:1347562
Created November 8, 2011 11:40
Use palette.pl in TextMate to output colors used in a CSS file
#!/usr/bin/env ruby
# Palette is a Perl tool that creates a color swatch from a CSS file
# http://code.google.com/p/css-palette/source/browse/trunk/src/palette.pl
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"
palette = ENV["TM_BUNDLE_SUPPORT"] + "/palette.pl"
TextMate.save_current_document
@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");
@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
@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: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 / 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 / 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
- 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 / 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;
});
<?
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 )