code

A Gopher named Gophy

If you are just starting out with Go, head over to the Go Playground and concentrate on figuring out how my little Go Story works. It’s about a Gopher, named Gophy who joint the Gophers but lost his identity in the process. Once you get how he gets his identity back you’ll be golden. Here is the code: package main import "fmt" type I interface{} var gophers map[uint]I = make(map[uint]I) type gopher struct { Name string } func main() { g := AddToGophers("Goghy") fmt.

Cfg

Features: You can define your config items in your application as a struct. You can save a json template of your struct You can save runtime modifications to the config Docs: import "bitbucket.org/gotamer/cfg" func Load(filename string, o interface{}) (err error) Load gets your config from the json file, and fills your struct with the option func Save(filename string, o interface{}) (err error) Save will save your struct to the given filename, this is a good way to create a json template

jgdb

About the implementation: This project is in alha state! Object Types Tuple (In Memory Database) Beta List (Single file persistent database) Beta Object (Multi file persistent database) Alpha Cache (Cache for Tuple) Not yet implemented Backends Json Glob Not yet implemented The major distinction between List and Object is that one, the List type uses a single file as backend with each record placed in one line.

Citadel vCard Sync

Features Citadel Sync will work on most operating systems including Linux, Mac, PC, Android … Converts a multi vCard file in to many for each to hold a single contact Adds UID and REV fields to the vCard if missing Uploads vCards to a given remote [Citadel] Mail Server You can specify, which folder on the server to upload to Can populate the Display name field from first and last name, or populate first and last name from display name Features planned Compare revision state and sync in case you modify a vCard on the server.

Sometimes I fall in love with code

I don’t use this, since I need often more but isn’t this just need? http://play.golang.org/p/QFheQeChIn package main import "log" const debug debugging = true // or flip to false type debugging bool func (d debugging) Printf(format string, args ...interface{}) { d { log.Printf(format, args...) } } func main() { debug.Printf("foo %d %.2f", 42, 12.7) }

Hugo, a static website generator

Just a couple of days ago I posted about jkl, a static website generator written in Go, and based on Jekyll. While setting up jkl, I stumbled over Hugo! I was impressed at first sight with Hugo. Since then I have reconfigured my site to work with Hugo. I didn’t have to fiddle with the Hugo code, everything just works, and it really does most everything that comes to mind. This whole website thing has been bothering me for a long time; and finally I am a happy champer.

Multiple PHP installations

How to install PHP 5.3.X as secondary php version from source PHPV=5.3.6 cd /usr/local/src wget http://us.php.net/get/php-$PHPV.tar.gz/from/this/mirror mv mirror php-$PHPV.tar.gz tar xzvf php-$PHPV.tar.gz chown -R $USER:$USER php-$PHPV/ cd php-$PHPV/ apt-get install libxml2-dev libssl-dev libcurl4-gnutls-dev libjpeg62-dev libpng12-dev libfreetype6-dev unixodbc-dev ./configure --prefix=/usr/local/php5.3 --with-config-file-path=/usr/local/etc/php5.3 --with-config-file-scan-dir=/usr/local/etc/php5.3/$SAPIconf.d --with-libdir=/lib --disable-cgi --with-libxml-dir=/usr/ --with-mysql=/usr/ --enable-pdo --with-pdo-mysql --with-mysqli --with-zlib-dir=/usr --with-curl --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/lib --with-gettext --enable-mbstring --enable-soap --enable-ftp --enable-fpm --with-openssl make make test make install More help in case you have errors: PHP-Configure-und-Compile-Fehler

fixing php's gettype function

<?php public static function getType($value, $max_length = 50){ $type = gettype($value); if($type == 'NULL' || $type == 'boolean' || $type == 'integer' || $type == 'double' || $type == 'object' || $type == 'resource' || $type == 'array' ) return array('type'=>$type,'value'=>$value); if($type == 'string' && empty($value)) return array('type'=>'NULL','value'=>$value); if($type == 'string' && strlen($value) > $max_length) return array('type'=>'blob','value'=>$value); if($type == 'string' && substr($value, 0,1) === '0') return array('type'=>'string','value'=>$value); if($type == 'string' && is_numeric($value)){ $int = (int) $value; $float = (float) $value; if($int == $value){ $value = $int; $type = 'integer'; }elseif($float == $value){ $value = $float; $type = 'double'; } }elseif($type == 'string'){ $type = 'string'; }else{ $type = 'blob'; } return array('type'=>$type,'value'=>$value); } ?

num_row with PDO

There is no num_row() function for PHP PDO Here are my two solutions: One with prepare & execute: db->prepare($sql); $sth->execute(array($key)); $rows = $sth->fetch(PDO::FETCH_NUM); echo $rows[0]; One with query: db->query($sql); $row = $result->fetch(PDO::FETCH_NUM); echo $row[0];

Load functions and array's

This class is used to load functions and array’s. It also can copy functions and array’s to the linux memory drive and load them from there to speed thinks up. <?php if(!defined('DROOT')) trigger_error("Please define data location (DROOT)"); /** * * This class loads stuff * * 1) Functions * 2) Array's * * @todo Load array's * @category Data * @package TaMeR * @copyright Copyright (c) 2010 - 2011 Dennis T Kaplan * @license http://www.