Category Archives: Programming

Programming

Bitwise and Enum

It’s been so long that I haven’t touched C# and today I got the chance to use it again, as you know, Enum is kind of popular in C# and for sure I encountered the bitwise operation again. To quickly pick it up again, I came across this awesome article http://weblogs.asp.net/wim/archive/2004/04/07/109095.aspx

Category: C#

Django common dictionary available to templates

We need to leverage TEMPLATE_CONTEXT_PROCESSORS, the following example uses the “home” application add this to settings.py TEMPLATE_CONTEXT_PROCESSORS = (“django.contrib.auth.context_processors.auth”, “django.core.context_processors.debug”, “django.core.context_processors.i18n”, “django.core.context_processors.media”, “django.core.context_processors.static”, “django.contrib.messages.context_processors.messages”, “home.context_processor.remote_ip”) in home application, create a python file called context_processor.py in the context_processor.py add a function like this: def remote_ip(request): return {‘remote_ip’: request.META[‘REMOTE_ADDR’]} for any templates needs to use this processor… Read More »

PHP Snippet: Get dates from a given range

function get_range_dates($start, $end){ $days = array(); $start_tmp = explode(“-“,$start); $end_tmp = explode(“-“,$end); $start_time = mktime(1,1,1, $start_tmp[1], $start_tmp[2], $start_tmp[0]); $end_time = mktime(1,1,1, $end_tmp[1], $end_tmp[2], $end_tmp[0]); while($start_time <= $end_time){ $days[] = date(“Y-m-d”, $start_time); $start_time += 86400; } return $days; } //calling the function get_range_dates(‘2011-02-01’, ‘2011-03-08’); Result: Array ( [0] => 2011-02-01 [1] => 2011-02-02 [2] => 2011-02-03… Read More »

Category: PHP

PHP Tutorial: Server load bar chart

Server Load: Just a quick tutorial on drawing the server load bar chart in php: serverload.php function get_server_load($windows = 0) { $os = strtolower(PHP_OS); if (strpos($os, “win”) === false) { if (file_exists(“/proc/loadavg”)) { $load = file_get_contents(“/proc/loadavg”); $load = explode(‘ ‘, $load); return $load; } elseif (function_exists(“shell_exec”)) { $load = explode(‘ ‘, `uptime`); return $load; }… Read More »

Category: PHP

How to create a Linux daemon in Python

I was writing a Python program to perform some routine tasks on twitter API, and came across this very helpful article for creating daemon process in Python… thought you might be interested… A simple unix/linux daemon in Python

Firebug 1.6.0 released

Overview of Firebug 1.6 Firebug 1.6 supports Firefox 3.6 Console and Command Line Command line available on all panels New API for the console object: console.table() Console allows to filter its content Improved auto-completion now the best of all Logging of cut/copy/paste events Support for XPath console logging Descriptive background colors for console messages HTML… Read More »

My dokuwiki plugins

A while ago I wrote some dokuwiki plugins: User Home Page Auto Include Index Table Math Modal Popup ACL Made Easy

Category: PHP