Programming and more

Entries for the ‘Programming’ Category

How to get the size of a List in Python

Ok trivial question, maybe not good for a post, but remember this blog replaced my personal notes, and I am just learning python 🙂 The right way to get the size of a list (In Python reffered as length) is this:   psychedelics= [] psychedelics.append("lsd") psychedelics.append("dmt") psychedelics.append("thc")   len(psychedelics)psychedelics= [] psychedelics.append("lsd") psychedelics.append("dmt") psychedelics.append("thc") len(psychedelics) In […]

How to read a Url in Python

I started learning Python today. I have several java programs that collect/copy content from many webpages in the internet, they work great, but they use a lot of memory, and I need that memory. Also it’s always fun to learn something new and I always hear the best things about Python, which is easy and […]

How to set global maximum heap size (-xmx) for java in linux

Sometimes is usefull to limit the maximum heap size for java. (Especially in a OpenVZ virtual machine(VPS) where java memory managment is terrible: http://www.r00t.gr/2011/03/openvz-vps-and-java-error-and-how-to-fix-it/)You can do this with the xmx parametr of command line java, but if you run many programs, with crons and through other programs, you will need a way to globaly set […]

How to convert byte to String in Java

Java always has something easy implemeted 🙂 So this time, Java String has 2 constructors that take a byte[] array. So: byte[] buf = new byte[1024]; //or whatever […] Fill all the byte array or part of it […] String str = new String(buf);   OR   String str = new String(buf,start,limit); //To create a […]

Creating MVC Framework in PHP

[This article doesn’t explain how to built a Framework, but introduces CodeIgniter, the simplest fucking possible framework out there, at least from those i have seen. If you are looking into how to create a framework, just see spend some time to start reading the documentation. You will see that in 5 hours you will […]

How to unzip a zip file with java

How to unzip a zip file with java I was writing a script in java, to download the some files from a webserver, then open them and read then, and insert some files into the database. What i noticed was that. when i downloaded the files with my browser, everything was ok, but when i […]

How to remove duplicates in a Vector in java

Remove Dublicate entries in Java Vector I was writing a small java program, that copied some ids from a website. Then the program had to process each one of those ids. I used Vector to store these, then i realized that there are a lot of duplicates. To late to change to something else, Like […]