Skip to content

Instantly share code, notes, and snippets.

@bastman
bastman / replace.php
Created February 1, 2012 13:06
str replace (php) - for a simple template engine
function replace ($text, array $replace) {
// @see: http://www.php.net/manual/en/function.strtr.php#106282
$text = "".$text;
$keys = array_keys($replace);
$length = array_combine($keys, array_map('strlen', $keys));
arsort($length);
$array[] = $text;
@bastman
bastman / Micro_Lib_Db_Mysql_Pdo_Exception.php
Created February 1, 2012 18:05
Php Mysql PDO Client (standalone)
<?php
/**
* Created by JetBrains PhpStorm.
* User: seb
* To change this template use File | Settings | File Templates.
*/
class Micro_Lib_Db_Mysql_Pdo_Exception extends Exception
{
/**
@bastman
bastman / JsEvalProxy.as
Created April 7, 2012 13:03
JsEvalProxy for as3: pimp flash.external.ExternalInterface
package de.basilicom.utils
{
/**
* @requires: JSON on javascript-side, e.g: JSON2.js
* @description pimp flash.external.ExternalInterface
* @author seb
*/
import com.adobe.serialization.json.JSON;
import flash.external.ExternalInterface;
@bastman
bastman / gist:2954207
Created June 19, 2012 13:34
Tornado nginx example setup
http://sebschmidt.tumblr.com/post/7920812905/nginx-how-to-setup-tornado-and-apache-on-a-virtual
http://stackoverflow.com/questions/5375220/how-do-i-stop-tornado-web-server
http://stackoverflow.com/questions/1447342/how-can-i-start-multiple-tornado-server-intances-in-multiple-ports
./demos/blog/blog.py --port=8889
@bastman
bastman / Base64.php
Created June 20, 2012 11:47
Lib_Utils_Base64 (urlsafe for encoding e.g.: rijndal encrypted data)
<?php
/**
* Lib_Utils_Base64
*
* Array Utils
*
* @category basilicom
* @package Lib_Utils
*
@bastman
bastman / gist:3742518
Created September 18, 2012 10:39
rpc server misc/utils (php)
public function parseRpcMethod($rpcMethod)
{
$rpcMethod = '' . strtolower(trim('' . $rpcMethod));
$parts = (array)explode('.', $rpcMethod);
$_parts = array();
foreach($parts as $part) {
$part = ''. ucfirst(trim(''.$part));
$_parts[] = $part;
}
#!/bin/sh
open -a "TextMate" $1
@bastman
bastman / gist:4032596
Created November 7, 2012 16:22
_design/migrating/sync_machine_logic
_design/migrating/sync_machine_logic
function (doc, meta) {
if (meta.type == "json") {
// If the document is JSON, sort by the schema
var splitId = meta.id.split(":");
if(splitId[0] == 'game' && splitId[1] == 'logic'){
emit(splitId[0], null);
}
@bastman
bastman / gist:4032599
Created November 7, 2012 16:22
_design/migrating/sync_machine_logic
_design/migrating/sync_machine_logic
function (doc, meta) {
if (meta.type == "json") {
// If the document is JSON, sort by the schema
var splitId = meta.id.split(":");
if(splitId[0] == 'game' && splitId[1] == 'logic'){
emit(splitId[0], null);
}
@bastman
bastman / chaining.php
Created November 11, 2012 10:16
chaining issues with php ide's: proper autocompletion/type hinting vs proper oop
<?php
/**
* a demo of current issues when working with chaining
* Looking forward to phpstorm 6
*
* @see: http://youtrack.jetbrains.com/issue/WI-2225
*
*
* file: chaining.php
* run: php chaining.php