Category: Code

Execute JavaScript files using Rhino

The command to execute a javascript file using rhino. java -jar /path/to/custom_rhino.jar JS_File.js Get Custom Rhino(From Dojo Library)

Creating a Toolbar in GTK Python(PyGTK)

Creating a toolbar using GTK Python. There is an old method – but this example shows a better method of…

Install Rhino

Installing Rhino(Javascript interpreter created in java) on Fedora 7 sudo yum install rhino-manual rhino-demo rhino

Python Function for Space Units

A Python function to return readable size using the given size(KB) # Returns a more readable format of the given…

Get Result of Command using Python in Linux

Execute a command and get its results using python in Linux import commands result = commands.getoutput(“ls”)

301 Redirect using PHP

301 Redirect using PHP header (‘HTTP/1.1 301 Moved Permanently’); header (‘Location: ‘.$new_location);

Command to Print Until Regular Expression

Print a file until a regular expression is matched. cat file.txt | perl -pe “exit if(/Thats all/)”

CSV Export/Import Functions in PHP

Functions to Export and import CSV data using PHP //*Get the result of the query as a CSV stream. function…

Using Git – the Basic Commands

Initialize a New Project in Git… git init git add . git commit #Add a file git add file.php git…

Remove empty directories

Remove all empty directories within the current directory find . -type d -empty -exec rmdir {} \; perl -MFile::Find -e”finddepth(sub{rmdir},’.’)”…