Skip to content

Instantly share code, notes, and snippets.

View rbraband's full-sized avatar

Roland Braband rbraband

  • Nordmann, Rassmann GmbH
  • DE - Hamburg
View GitHub Profile
@rbraband
rbraband / example 1
Created February 24, 2012 14:12
Howto implement stored procedures within Redis
# Step 0 -- create test data
redis-cli HSET :object:30343552:data foo bar
# Step 1 -- store sample function 'sampleFunction'
redis-cli SET :functions:sample "redis.call('SELECT', 0);local data=redis.call('HGETALL',':object:' .. ARGV[1] .. ':data');return data"
# Step 2 -- create function loader
redis-cli SCRIPT LOAD "f=loadstring(redis.call('get',':functions:' .. KEYS[1]));return f()"
# Step 3 -- test
<?php
// constants
define('WITHSCORES', true);
define('REDIS_CONNECTION', ((CLI) ? '/var/run/redis.socket' : '127.0.0.1')); // localhost or socket
#define('REDIS_CONNECTION', '127.0.0.1'); // localhost only
define('REDIS_NAMESPACE', 'lou:'); // use custom prefix on all keys
define('REDIS_DB', 1);
#define('REDIS_AUTH', '');
define('REDIS_LOG_FILE', ((CLI) ? $_SERVER['PWD'] : $_SERVER['DOCUMENT_ROOT']).'/logs/redis.txt');
@rbraband
rbraband / SplClassLoader.php
Created August 24, 2012 10:49 — forked from grisha87/SplClassLoader.php
Returning $this on setters and some formatting fixes
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
<?php
/**
* php_XCache
*
* @package XCache
* @version $Id$
* @copyright 2014
* @author Roland Braband <[email protected]>
* @license BSD {@link http://www.opensource.org/licenses/bsd-license.php}
L.Control.Button = L.Control.extend({
options: {
position: 'bottomleft'
},
initialize: function (options) {
this._button = {};
this.setButton(options);
},
@rbraband
rbraband / LCircleEditor
Last active February 4, 2016 22:42
L.CircleEditor is an extension of L.Circle, just to add the edition part (remember, radius in meters).
/*
* L.CircleEditor is an extension of L.Circle, just to add the edition part (remember, radius in meters).
*/
L.CircleEditor = L.Circle.extend ({
options: {
icon: new L.DivIcon({
iconSize: new L.Point(8, 8),
className: 'leaflet-div-icon leaflet-editing-icon'
@rbraband
rbraband / weekly.cmd
Created October 20, 2014 13:53
Graphhopper weekly update script for Windows Task-Scheduler
@ECHO OFF && PUSHD "%~dp0" && SETLOCAL
ECHO [%date% - %time%] Log start > download.log
SC Stop Graphhopper > nul
RENAME europe-latest.osm.pbf old_europe-latest.osm.pbf
REM Wget: retrieve files from the WWW http://gnuwin32.sourceforge.net/packages/wget.htm
WGET --no-verbose --append-output=download.log --tries=3 http://download.geofabrik.de/europe-latest.osm.pbf
IF exist %~dp0\europe-latest.osm.pbf (
ECHO [%date% - %time%] Download successful >> download.log
DEL old_europe-latest.osm.pbf
PUSHD %~dp0\europe-latest.osm-gh
@rbraband
rbraband / 0_reuse_code.js
Created February 9, 2016 12:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/bin/bash
rundir=$(dirname "$(readlink -e "$0")")
pidfile=$rundir/test.pid
(nohup php -q -f test.php > /dev/null) & echo $! > $pidfile &
@rbraband
rbraband / browser.html
Last active February 10, 2022 21:58 — forked from devsnek/funcord.js
custom discord client
<!doctype HTML>
<html>
<head>
<title>discord browser example</title>
</head>
<body>
<script>
'use strict';
class EventEmitter {