Sunday, December 28, 2014

Dropbox installation from the command line

In order to install dropbox from the command line, follow the instructions found here. Useful in case your system is stuck with an old, broken version...
If by any chance you want to install dropbox on a centos system, then this will probably be of use.

It seems that centos has some issues with dropbox client v3. Here is a discussion about it

SELinux in redhat (and friends) systems

If you wonder what SELinux is, you my find this useful. If you ever find yourself wanting to disable SELinux, just set it in permissive mode instead,so you can at least have its logs to use in case something weird happens. Also this blog post gives a nice overview of what SELinux is all about

Wednesday, December 24, 2014

Molecular Mechanisms of Learning and Memory, by Lee Frank

I have started reading this short essay related to the mechanisms and different types of learning at a molecular level. Fascinating stuff, that make digital communications seem simplistic.

Sunday, December 21, 2014

su user cannot open display

Sometimes you want to run something graphical as a different user on your system and when switching to that user using su you get the error "cannot open display"

There are a number of solutions to this problem.
The simplest one (but a bit insecure) is to run xhost + before switching users.
This will disable the authentication mechanism of X windows.

Monday, December 15, 2014

Update postfix virtual address map

You just need to use the command sudo postmap ./virtual in /etc/postfix if your virtual db file is called virtual.

Of course you need to have this activated in the /etc/main.cf using the variables:
virtual_alias_domains and
virtual_alias_maps

if you changed anything in the main.cf you also need to do a postfix reload.

Saturday, December 13, 2014

The Hobbit 3. The battle of 5 armies

Watched this in IMAX 3D. Not bad at all, i have the feeling that the whole production was slightly better than the first and the second.

Wednesday, December 10, 2014

After the history of Florence, SuperFreakonomics

After the history of Florence by Machiavelli, i have started superFreakonomics, a more relaxed reading of unconventional stories related to economy of culture. Some of them are really funny, some are not, but most of of them are at least unexpected.

Thursday, November 27, 2014

Validating json files with python command line

If you ever want to validate a json file and you have not a json parser installed, you can always use python for the purpose: python -m json.tool < data.json
You can also use this approach to pretty print a mangled json file.

Sunday, November 23, 2014

Browsing through ocaml packages

You can always use ocamlfind, but there is also a gui tool called ocamlbrowser. The graphics are not great but it seems to be a convenient tool.

Friday, November 7, 2014

The prince

Reading this book, by Nicolo Machiavelli. If nothing else i may gain some insight in how politician see the world.

Sunday, November 2, 2014

go to specific column with vi

We know that if you want to go to line 30 you just need to type :30
similarly if you want to go to column 30 in the current line you are, you just type 30|

Changing user with su does not allow you to run X apps

It happens whenever you su to a different account on the same machine. The X session details are not inherited by the new user, so you do not have access to the X session.

The solution is to use xhost like this:

> xhost
access control enabled, only authorized clients can connect
SI:localuser:nickapos

activate xhost, and then add the new user that needs to run xapps:


>xhost +si:localuser:nickapostolakis
localuser:nickapostolakis being added to access control list


verify by re-running xhost:

> xhost
access control enabled, only authorized clients can connect
SI:localuser:nickapostolakis
SI:localuser:nickapos

Sunday, October 26, 2014

Pope Joan by Emm. Roidis

Started reading this book a couple of days ago. It is satirical and sarcastic, written in a now abandoned, it is not as easy as the current spoken and written version of Greek, but it has its own elegance and power of expression. More about the writer and his work here

Saturday, October 25, 2014

Compiling a multiple file project in ocaml

When we compile a multiple file project in ocaml, we can use the following command:

ocamlopt -o progprog eaBase.ml eaPoor.ml

If we are using the class or module in the first file in the second, then we need to open the module in the second file. After that inheritance works fine.

More about the ocaml tools here

Using fixtures in Django to import and export data

./manage.py dumpdata --indent 2 > all.json
and load it in again on the dev server (I use git to transfer it but there’s probably a cleaner approach):
./manage.py loaddata all.json

keep in mind that this will dump all the data from the database. if you want to limit the dump to a specific app you can do that. when loading if the data already exist in the database. you will get an error. so it is possible that you want to delete the tables before importing

Thursday, October 23, 2014

Handy ocaml code samples

A handy web site with code samples here. Especially for freshers like me :)

In order to compile my class i need to use:

corebuild eaBase.byte

it simplifies things a lot

and then ./eaBase.byte which calls the main and prints the result.

The official reference page is here

Wednesday, October 22, 2014

Globbing and zsh.

Globbing is a way of expanding wildcard characters in a non-specific file name into a set of specific file names. Shells use globbing all the time. For instance:
$ ls foo*
foo1 foo2
When you enter the above, you're using a glob: foo*. What the shell is doing, however, is interpreting that wildcard character (*) and then passing the actual files to list to the lscommand; so in this instance, the command that is actually being used is ls foo1 foo2.
Some standard wildcards that are often used include:
  • the asterisk (*) character for zero or more characters
  • the question mark (?) character for any single character
  • the [123] specifier, which indicates any of the characters 1, 2, or 3
  • the [0-9] specifier, which indicates any number between 0 and 9 (or [a-z] for any letters between a and z).
You can also use named ranges, such as:
  • [::alpha::] for any letter
  • [::alnum::] for any letter or number
  • [::lower::] for any lowercase character
When it comes to globbing, zsh is one of the most powerful shells with some very interesting wildcard characters that can be used. For instance, you can use glob qualifiers, which are characters with a special meaning. If you wanted to list all the symbolic link files in the current directory you would use:
$ ls *(@)
Some other zsh glob qualifiers include a forward slash (/) for directories and a period (.) for plain files; the zshexpn man page has a full list. If there are no matches, zsh will return an error; if there is nothing to pass to the ls program (or any other program), the program will not even be called by zsh.
There are other useful patterns, such as the (**/) pattern. What this does is tell zsh to match any number of directories to any depth, including the current directory. To find all the (*.sh) and (*.py) files in the current directory and sub-directories in a list suitable for parsing (i.e., perhaps in a script), you would use:
$ ls -1 **/*.(sh|py)
Finally, to enable extended globbing at all times, add this to ~/.zshrc:
setopt extended_glob
If you do decide to use extended globbing, be aware of special characters in file names and the need to quote them. For instance, if you want to copy files from a remote site using scp, you don't want zsh to expand any wildcards locally; you want that wildcard passed to scp for files on the remote end to match, so instead of:
$ scp hades:~/tmp/* .
zsh: no matches found: hades:~/tmp/*
You would need to use:
$ scp "hades:~/tmp/*" 
stollen from here

Monday, October 20, 2014

Ο ρωμηός του Σουρή

Ὁ Ῥωμηός

Στὸν καφενὲ ἀπ᾿ ἔξω σὰν μπέης ξαπλωμένος,
τοῦ ἥλιου τὶς ἀκτῖνες ἀχόρταγα ρουφῶ,
καὶ στῶν ἐφημερίδων τὰ νέα βυθισμένος,
κανέναν δὲν κοιτάζω, κανέναν δὲν ψηφῶ.
Σὲ μία καρέκλα τὅνα ποδάρι μου τεντώνω,
τὸ ἄλλο σὲ μίαν ἄλλη, κι ὀλίγο παρεκεῖ
ἀφήνω τὸ καπέλο, καὶ ἀρχινῶ μὲ τόνο
τοὺς ὑπουργοὺς νὰ βρίζω καὶ τὴν πολιτική.
Ψυχή μου! τί λιακάδα! τί οὐρανὸς ! τί φύσις !
ἀχνίζει ἐμπροστά μου ὁ καϊμακλῆς καφές,
κι ἐγὼ κατεμπνευσμένος γιὰ ὅλα φέρνω κρίσεις,
καὶ μόνος μου τὶς βρίσκω μεγάλες καὶ σοφές.
Βρίζω Ἐγγλέζους, Ρώσους, καὶ ὅποιους ἄλλους θέλω,
καὶ στρίβω τὸ μουστάκι μ᾿ ἀγέρωχο πολύ,
καὶ μέσα στὸ θυμό μου κατὰ διαόλου στέλλω
τὸν ἴδιον ἑαυτό μου, καὶ γίνομαι σκυλί.
Φέρνω τὸν νοῦν στὸν Διάκο καὶ εἰς τὸν Καραΐσκο,
κατενθουσιασμένος τὰ γένια μου μαδῶ,
τὸν Ἕλληνα εἰς ὅλα ἀνώτερο τὸν βρίσκω,
κι ἀπάνω στὴν καρέκλα χαρούμενος πηδῶ.
Τὴν φίλη μας Εὐρώπη μὲ πέντε φασκελώνω,
ἀπάνω στὸ τραπέζι τὸν γρόθο μου κτυπῶ...
Ἐχύθη ὁ καφές μου, τὰ ροῦχα μου λερώνω,
κι ὅσες βλαστήμιες ξέρω ἀρχίζω νὰ τὶς πῶ.
Στὸν καφετζῆ ξεσπάω... φωτιὰ κι ἐκεῖνος παίρνει.
Ἀμέσως ἄνω κάτω τοῦ κάνω τὸν μπουφέ,
τὸν βρίζω καὶ μὲ βρίζει, τὸν δέρνω καὶ μὲ δέρνει,
καὶ τέλος... δὲν πληρώνω δεκάρα τὸν καφέ.

κλεμένο απο εδώ

Sunday, October 19, 2014

Setting up a dynamic dns service in 5 minutes.

Found this excellent blog post.

Copying and pasting the instructions for archival purposes:

You might have recently setup your Raspberry Pi or your Linux box as a 24 x 7 torrent downloader, or a small Web server to host your own website. And just then you realize that your ADSL or Cable Internet connection has a dynamic IP address which changes frequently and every time you reconnect. Thus, it becomes hard to access your box with a fixed Domain name or IP address.

To solve this problem you can setup a Dynamic DNS which will update your IP to a DNS name everytime it changes and you can access you hosted website, or ssh into it to monitor torrent downloads with ease.

While there are many paid dynamic dns service providers available, but here you will see one way to do it for **FREE** [Thanks to freedns.afraid.org]

Step 1
Register for a Free domain at http://freedns.afraid.org/signup/
[We will take techhome.homenet.org in this guide]

Step 2
Logon to FreeDNS (where you just registered) and gotohttp://freedns.afraid.org/dynamic/
Or, simply click on "Dynamic DNS" link from the left navigation menu

Right click on "Direct URL" and copy the URL and paste it somewhere.

You should notice a large and unique alpha-numeric key in the URL, make a note of it as shown below:
http://freedns.afraid.org/dynamic/update.php?[alpha-numeric-key]

Step 3
Install inadyn using the following command:
sudo apt-get install inadyn


Step4
Configure inadyn using the below steps:
sudo nano /etc/inadyn.conf

And add the following contains in it replacing the actual values:
--username techhome
--password mypassword
--update_period 3600
--forced_update_period 14400
--alias techhome.homenet.org,alphanumeric key
--background
--dyndns_system default@freedns.afraid.org
--syslog



Step 4 
Now, we need to ensure that the DNS updater (Inadyn) runs automatically after every re-boot

export EDITOR=gedit && sudo crontab -e

Add the following line:
@reboot /usr/sbin/inadyn


Step 5
Reboot system and then run the following command to ensure inadyn is running:

ps -A | grep inadyn

Now your host is ready and up for accessing from internet...

You can trying ssh-ing from another computer over the internet
ssh username@techhome.homenet.org

Or, if any web server is running, then simply browse to  http://techhome.homenet.org

Or, you can just ping it to test ping techhome.homenet.org

To check the logs you can use this:
more /var/log/messages |grep INADYN

This has been re-tested to be working perfectly with inadyn 1.96.2-1 on Raspbian 3.12.22+

Saturday, October 18, 2014

Kivy: Python based platform independent projects with touch support

Kivy, seems a really interesting project. It can be used to provide write once run everywhere functionality in python, including desktop and mobile platforms and with touch support.
I will give it a go and see what happens.

Tuesday, October 14, 2014

Real world Ocaml

Still studying this book. It is mind-boggling how advanced it is especially compared with other mainstream languages. It will probably end up becoming one of my go-to languages especially for use cases that well suited for the functional paradigm.

Sunday, October 12, 2014

Old blog posts in xml format

It seems that blogger import does not work very well, so i decided to upload my old blogs as an xml file with some minimal xsl formatting here. At the very least it will allow me to search for old things. Of course html has been stripped so there are a lot of cases in which the post is really missing

Older blog post imports

Been trying for a couple of days to import my old blog posts to blogger.
The Blogger API is a mess, so i decided to use an XML import.
I am almost there, and would have everything working if there were more test imports allowed by blogger in order to debug my xml.

Anyway, I will do it eventually. I think that I need to do some more text replacements in the xml and for that, I am going to use vim grouping regular expressions i think.

The regexp that worked is: %s/\(....-..-..\) \(..:..:..\)/\1T\2:00.000-00:00/gc

Friday, October 3, 2014

First blogger post

A first post in blogger. Lets see if I will make it migrating my nucleus posts to blogger. Added all my categories on this post as labels, as it seems that for a label to exist the must be at least one post with it...