Posts

Showing posts from December, 2014

How To Enable Auto-Completion in Python Shell

Learn how to use TAB to auto-complete expressions in plain vannila Python shell. If you need to have auto completion in Python shell (almost the same way as iPython), it's very easy. Create a file named .pyreadline with the following content and put it in your home directory. #!python import rlcompleter, readline readline.parse_and_bind('tab: complete') Export the file as PYTHONSTARTUP variable; for example append it to .bashrc . echo "export PYTHONSTARTUP=~/.pyreadline" >> ~/.bashrc

How To Batch-set Environment Variables

Learn how to automatically (dump) set environment variables defined in a file. Sometimes you have a file (usually called .env or .environment ) with dozen of environment variables defined and you have to set those variables before running a command --for example this happens in Django projects with a .env file for settings. The solution is easy: export $(cat ENVIRONMENT_FILE | xargs) && YOUR_COMMAND

How To Add Logging To A Clojure Project

When deploying a Clojure application in a production environment, it is necessary to have logging enabled to be able to, in case of any failure, track down the problem using the logs later. Clojure inhertis serveral logging frameworks from Java like Log4j and it has its own Clojure'esque wrapper around Java logging API called clojure.tools.logging . This HowTo will help you get started with a working “loggable” Clojure project. Though the instructions assume that you're using Leiningen for build automation, it can be applied to any Maven based build too. Setting Up A New Project This creates a new empty project: $ lein new app logger1 Generating a project called logger1 based on the 'app' template. Now edit project.clj to add required dependencies: (defproject logger1 "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url ...

Thoughts On JVM-based Forth Implementation

Image
Is it possible and worth to implement Forth on top of JVM? Forth : A language which looks as weird as it is simple and powerful --and it looks extremely weird! I, first, came to know Forth with help of my good friend Michael a.k.a. ttmrichter and immediately Forth placed itself on top of the favourite language pyramid in my mind, alongside only Lisp family. Since then, I've been eager to do serious coding in Forth. However, there's a problem: most of Forth'ers work in the system/chip programming field which means that there are hardly any higher level libraries (e.g. UI toolkits or database connectors) for someone like me to try Forth in business applications. It's definitely possible to write all those libraries starting from the scratch but even the thought of it turns my stomach! Recently I've been thinking about implementing Forth on JVM. JVM Forth has several advantages: It will be platform independent. It will have access to tons of existing libraries...