Posts with the category Programming Languages

Perlbrew

Installing perlbrew is a one-liner:

curl -L http://install.perlbrew.pl | bash

Add this lines to your ~/.bashrc:

source ~/perl5/perlbrew/etc/bashrc

To get a stable perl distribution, do:

perlbrew install stable

To use it, run:

perlbrew list
perlbrew switch perl-5.20.2

To upgrade to the latest stable Perl distribution at a later point:

perlbrew...

Read on

Installing iRoot from TATA Institute on Mac OS X

iRoot is a product of the India-based Neutrino Observatory collaboration lead by Prof.Naba Mondal at the Tata Institute of Fundamental Research.
It is a simple plotting and analysis tool based on the popular ROOT from CERN and is primarily intended for analysis using the TTree structures in ROOT. iRoot is supported...

Read on

SQLite DB Introspection

If you have an SQLite database file and want to check its structure (programmatically)

SELECT * FROM sqlite_master;

To do this via Python as simple as possible, run:

conn = sqlite3.connect("your/database.sqlite")
c = conn<span...

Read on

SQL

http://en.wikipedia.org/wiki/SQL

search using SQL

SELECT * from bash_history where  command LIKE '%modprobe%'

% is the wildcard character in SQL!

SQlite specifics

http://www.sqlite.org/lang.html

...

Read on

Automized Extraction of Transactions on the ING-DiBa Online Banking Website

This is an iMacros script to extract transaction details on the online banking website of the German branch of the bank ING-DiBa. As this is mostly interesting to Germans, the following blog post is in German. If you want to read it in English, consider translating it using Google...

Read on

Colourful SVN Diff on Mac OS X

I do not particulary like SVN but sometimes I have to use it. The diff output on the Mac OS X command line usually is not colored which is annoying. The solution is to tell SVN it should use colordiff instead. You can easily install colordiff using homebrew:

brew...

Read on

FUSE Filesystems

With FUSE - The Filesystem in Userspace you can mount all different kinds of remote / local filesystems on you Linux/Unix/Mac computer. Here are some implementations of interesting FUSE filesystems:

Read on

ezyfit - An Alternative to Matlab's Curve Fitting Toolbox

ezyfit can prevent you from buying the Curve Fitting Tool that Matlab does not come with by default. This is how I use it to fit data according to a function :

x=15:45
y = 30 +...

Read on

Handle 16bit TIFF Images in Python

There seem to be quite a lot of problems with 16-bit grey scale TIFF images (especially with the Python Imaging Library - PIL). If you can, you may want to use FITS instead of TIFF. There are good and up-to-date libraries for Python: PyFITS.

For me, however, the FreeImage...

Read on

hub teaches git about GitHub

Hub is a useful extension to make git GitHub aware.

catch lines:

hub introduces git to GitHub
and
hub teaches git about GitHub

Installation

brew install hub

Usage

See hub's webpage for introductory examples and its man page for further reference.

...

Read on

Use the Python Module MacFSEvents to Monitor Directories for Changes on Mac OS X

MacFSEvents is an up-to-date solution to monitor directories for changes on Mac OS X when using the scripting language Python. It is a binding to FSEvents, Mac OS X's filesystem monitoring framework.

Install MacFSEvents

pip install macfsevents

Quickstart

from fsevents import Observer, Stream

<span...

Read on

Light Wavelength from Energy

You can use the following Python function to convert a photon energy (in electron volts) to the corresponding wavelength (in nano meters):

def wavelength_from_energy ( electron_volts):
    """Returns a photon wavelength in nm from a photon energy given in eV."""
 ...

Read on

Physical Constants in Python

SciPy (updated to CODATA 2010)

Installation (easiest using pip):

  1. Install Fortran as described for your OS on http://www.scipy.org/Installing_SciPy (or via brew install gfortran on Max OS X)
  2. Install SciPy itself: pip install scipy

Usage:

from scipy.constants import *
print "The Planck constant h:", <span...

Read on

Install matplotlib on Mac OS X

Installation of the pre-built binaries for OS X

Read Installing OSX binaries in the matplotlib Installation FAQ.

Installation via pip

This is a good way if you have an up-to-date Python installation on your computer and pip installed. It takes, however, some time (~ 20 mins for me) to install as it...

Read on

Easy Usage of XML with Python

The builtin Python modules to work with markup languages can be found on http://docs.python.org/library/markup.html. For XML these are mainly DOM (incl. minidom), SAX and ElementTree.

A comparison of minidom and ElementTree including good examples can be found on http://mike.hostetlerhome.com/present_files/pyxml.html.

Other than the default Python modules there is also a very...

Read on

Use the Python Module Watchdog to Monitor Directories for Changes

Watchdog is a cross platform solution to monitor directories for changes on Python and has been initiated by Yesudeep Mangalapilly. Very helpful is the readme file of the watchdog module.

Requirements and Installation

You may want to have a look at its source code on GitHub.

The dependencies of watchdog...

Read on

Watching Directories for Changes using Python : An Overview

Operating System Independent Solutions

Read on

Control the 6 channel Pfeiffer MaxiGauge TPG 256A pressure gauge controller via Python

update in 2014: The script from this blog post evolved into its own Python software repository on Github: pklaus/MaxiGauge. Please use that for the latest code and functionality.

original post:

I wrote a Python module for this pressure gauge controller. The module can be found on https://gist.github.com/1378695. Using the module...

Read on

Access Serial Connections via LabView

To access devices that have a serial port using LabView, you should build a state machine (essentially a case structure inside a while loop, see this forum topic). More about that on http://zone.ni.com/devzone/cda/tut/p/id/3024#toc1.

Resources

...

Read on

A PID Controller in Python

...

Read on

Windows PowerShell

http://de.wikipedia.org/wiki/Windows_PowerShell
Windows 7 ships with v2.0 of the Windows PowerShell. On a German Win7 installation you can start it via Start → Alle Programme → Zubehör → Windows PowerShell → Windows PowerShell (ISE).

Get Help

Owner's manual: http://technet.microsoft.com/en-us/library/ee221100.aspx

Help -?

or via get-help *.

Translating Simple DOS Commands to Powershell cmdLets

<table class="table...

Read on

js-Unicode-Selector – A tool to have a closer look at Unicode Symbols

Yesterday, I had to prepare for an exam at the University but instead of learning for it I wrote a small tool to browse the unicode characters. You can have a look at it on http://pklaus.github.com/js-Unicode-Selector. It's fun...

Read on

The Bash

The Bash is probably the most important shell and scripting language in the world as it is included with almost any operating system (excl. MS Windows). The automation that can be achieved with very predictable results is great even though the complexity of the scripts is somehow limited. Doing calculations...

Read on

First Contact with amd64 (x86_64) Assembler Code

On Wikipedia there is a Comparison of (x86) assemblers. You can sort the table by x86_64 capability.

Syntax

Most x86 assemblers use Intel syntax. Here is a little comparison: http://asm.sourceforge.net/articles/linasm.html#Syntax

Intel syntax

Most widely used assembler syntax.

AT&T syntax

At the end of the mnemonics you put a size suffix (one letter). To change...

Read on

The Programming Language C

Operators in C

Operators in C and C++: http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B

C supports a rich set of operators, which are symbols used within an expression to specify the manipulations to be performed while evaluating that expression. C has operators for:

  • arithmetic (+, -, *, /, %)
  • equality testing (==, !=)
  • order relations (<, <=, >, >=)
  • boolean...

Read on

`python-sipgate-xmlrpc` – Easy to use Python bindings for the Sipgate XML-RPC API

The German VoIP provider Sipgate has a great offer for people who want to replace their landline with a modern internet based SIP telephony account. Sipgate offers an XML-RPC API to all its customers (you must at least have created a free 'basic' account). With the API, you...

Read on

Install Gitosis on Debian Squeeze

You can use gitosis to allow people to collaborate on a project via git. Its a utility to allow read and write access based on SSH encryption keys. And you only need to create a single system account, not one for every contributor.

First, install gitosis:

su
apt-get install gitosis

Now...

Read on

Install as many python modules as you like - in virtual environments

su
easy_install virtualenv

And create your virtualenv :

mkdir ~/venv
virtualenv --no-site-packages ~/venv/django-cooking
source ~/venv/django-cooking/bin/activate

Now you can install a whole bunch of stuff to that virtual python environment:

easy_install django psycopg2 django-extensions werkzeug south reportlab pypdf html5lib pisa pil

When using virtualenv, you should also consider using virtualenvwrapper! It provides...

Read on

PHP SQlite3 with PDO

If you want to use SQlite3 databases with PHP you should probably use PDO.

Install it like this:

su
apt-get install php5 php5-sqlite
echo -e "\nextension=pdo.so\n" >> ../conf/php.ini

Note: You don't need any command like pecl install pdo_sqlite or pecl install pdo as PDO is now included in the package php5-sqlite...

Read on

SQLite

http://www.sqlite.org/

Important Notes

Omitted SQL Language Features
http://www.sqlite.org/omitted.html

SQLite Keywords
http://www.sqlite.org/lang_keywords.html
you cannot choose table names from the keywords list!!!

enforce foreign keys
SQLite Foreign Key Trigger Generator: http://www.rcs-comp.com/site/index.php/view/Utilities-SQLite_foreign_key_trigger_generator
http://glossar.hs-augsburg.de/SQLite_Foreign_Keys_erzwingen
http://sqlzoo.net/howto/source/u.cgi/tip241028/sqlite

Jump Start

SQLite with Python

http://docs.python.org/library/sqlite3.html
http://www.wdvl.com/Authoring/python/SQLite/Watts07162009.html

Admin tools / GUIs

SQLiteStudio

http://sqlitestudio.one.pl/

Open Source, cross platform!

SQLite Database Browser

http://sqlitebrowser.sourceforge.net/

sudo apt-get install sqlitebrowser

Sqliteman

http://sqliteman.com/

sudo...

Read on