Skip to content

Instantly share code, notes, and snippets.

View vectoroc's full-sized avatar

Victor Grigoriev vectoroc

  • Prague, Czech Republic
View GitHub Profile
alert(1)
<?php
class BracesToken {
private $ch = null;
// store char index for simplicity
private $index = null;
// keys are opening braces
// values are theirs closing brases respectively
private static $pairs = array('[' => ']', '(' => ')', '{' => '}');
@vectoroc
vectoroc / gist:635e231167e60ecb1285
Created March 7, 2015 11:43
interactive python shell
def debug_shell(locals):
import code
import readline
import rlcompleter
# do something here
vars = globals()
vars.update(locals)
readline.set_completer(rlcompleter.Completer(vars).complete)
@vectoroc
vectoroc / potx.drush.inc
Created December 13, 2012 13:37
potx-6.x drush integration / with help of this plugin you can keep in sync your codebase and language translations
<?php
function potx_drush_command() {
$items['po-import'] = array(
'aliases' => array('poi'),
'description' => "Update project translations from po-files.",
'examples' => array(
'drush po-import' => 'Re-import all po-files from enabled modules',
'drush po-import mymodule1 mymodule2' => 'Re-import po-files from specified modules',
),
@vectoroc
vectoroc / GlobalMercator.php
Created September 11, 2012 11:36
Port of GlobalMercator from python to php
<?php
###############################################################################
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/
#
###############################################################################
(function() {
var db = openDatabase('friends', '0', 'Offline friends storage', 1024*1024, function (db) {
db.changeVersion('', '0', function (t) {
t.executeSql('CREATE TABLE friends (id UNIQUE, name, ava)');
t.executeSql('CREATE TABLE history (event, data, time DEFAULT (CURRENT_TIMESTAMP))');
});
});
function logDeleted(friend) {
db.transaction(function(t) {