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 / matheval.lua
Created March 17, 2019 10:49 — forked from hmenke/matheval.lua
Simple mathematical expression parser and evaluator in Lua with LPEG
local lpeg = require"lpeg"
local C, P, R, S, V = lpeg.C, lpeg.P, lpeg.R, lpeg.S, lpeg.V
local white = S(" \t") ^ 0
local digit = R("09")
local dot = P(".")
local eE = S("eE")
local sign = S("+-")^-1
local mantissa = digit^1 * dot * digit^0 + dot * digit^1 + digit^1
@golgote
golgote / d7install.bash
Created October 11, 2018 21:09 — forked from ricardoamaro/d7install.bash
Drupal Installation Script for Linux Debian/Ubuntu
#!/bin/bash -e
#############################
#
# Auto Install Drupal on Debian/Ubuntu boxes
# Author: ricardo amaro
# https://drupal.org/user/666176
#
# License: http://www.gnu.org/licenses/gpl-2.0.html
#
@golgote
golgote / bindinghandler.js
Created February 26, 2016 13:49 — forked from anonymous/bindinghandler.js
Knockout + bootstrap-tagsinput
ko.bindingHandlers.tagsinput = {
init: function(element, valueAccessor, allBindings) {
var options = allBindings().tagsinputOptions || {};
var value = valueAccessor();
var valueUnwrapped = ko.unwrap(value);
var el = $(element);
el.tagsinput(options);
@golgote
golgote / config.json
Last active August 29, 2015 14:22 — forked from anonymous/config.json
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
# example location parts of nginx.conf
# add your own AWS keys, server lines etc, and set your aws domains, paths
http {
# you will need the luacrypto in the cpath, download from http://luacrypto.luaforge.net/
lua_package_cpath "/home/justin/lua/luacrypto-0.2.0/src/l?.so.0.2.0;;";
server {
listen 80;
<?php
class ImageDiff {
// not bigger 20
private $matrix = 15;
public function getImageInfo($image_path){
list($width, $height, $type, $attr) = getimagesize($image_path);
$image_type = '';
@golgote
golgote / Article.rb
Last active August 29, 2015 14:12 — forked from otobrglez/Article.rb
# This method finds related articles using Jaccard index (optimized for PostgreSQL).
# More info: http://en.wikipedia.org/wiki/Jaccard_index
class Article < ActiveRecord::Base
def related(limit=10)
Article.find_by_sql(%Q{
SELECT
a.*,
( SELECT array_agg(t.name) FROM taggings tg, tags t
--------------------------------------------------------------------------------
-- PHP-style serialization in PostgreSQL
-- Making a better situation of someone else's bad decision
-- See examples at bottom
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Serialization function per type
CREATE OR REPLACE FUNCTION php_serialize(boolean) RETURNS text
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.1.1
-- Dumped by pg_dump version 9.1.1
-- Started on 2011-11-02 16:53:36 EET
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
<?
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 )