Tuesday, July 20, 2010

file permissions and chmod

When you "ls -l" you get some crazy symbols on the left similar to "drwxr-xr-x". These represent the file permissions. Here is how they work.
You have 10 letters: "0123456789"
0 will be 'd' if it's a directory and '-' otherwise
123, 456, 789 correspond to the rights for "owner", "group" (owner's group), "every body else"
so, 1,4,7 are for the "read" right
2,5,8 are for the "write" right
3,6,9 are for the "execute" right
If you have the right, there will be an 'r', 'w', or 'x' respectively, otherwise a '-'
The command to change those is chmod. To change something, you must have a "write" right, or be a root.
chmod works in 2 ways:
- Either write "chmod xxx file" where x is a single octadecimal digit corresponding to the rights you give to each group, where the 1st x is for the 1st group and so on.
As a side note, here is a table for octadecimal transformation into binary:
0 -> 000
1 -> 001
2 -> 010
3 -> 011
4 -> 100
5 -> 101
6 -> 110
7 -> 111
so, now map the 3 binary digits to "rwx" and you get your rights for one group. For example, 5, which is 101, represents r-x rights.

- the other way to use chmod is to do use some letters
'u' = user (owner)
'g' = group
'o' = others
'a' = all (the 3 permissions)
'r' = read
'w' = right
'x' = execute
'-' = remove
'+' = add
and you write it such as "chmod [a|u|g|o]+ [+|-] [r|w|x]+". What this means in english is, write chmod, then write any combination of "augo" then write '+' or '-' then write any combination of "rwx". So u+x will give the owner execute right and og-rw will remove the read and write from others and group.
Take care because sometimes a-r or a-w or u-r or u-w can be dangerous if you don't have root access. There are a lot of other options, consult the chmod manual (man chmod) for the full details.


Saturday, July 10, 2010

kturtle scripts

I modified the leaf script from http://www.medphys.ucl.ac.uk/~mbanaji/recreation/kturtle.html to work with kturtle and I wrote my own Mandelbrot set tutrle script. I thought this might be useful for someone else.

Here is the code for the mandelbrot set. The code can scale to very high resolution but you will face terrible problems with kturtle speed. For best performance, select full speed (No highlight) from the Run menu.



Here is the code for the leaf. It is a modified version to work with kturtle as well as some fixed logic mistakes. Again use the same running environment as mandelbrot for best results.

Forgot to say, these files will not work if you just copy/paste them in the kturtle editor, you should .turtle files then open them from kturtle. This is because the turtle script is different from what is saved in the file and when you save/open it translates back and forth between both.

Wednesday, July 7, 2010

Cranking to power a laptop

I was watching a guy talking about that they want to create a laptop that gives you a 1:10 ratio of cranking vs. operation time. A human cranking with a good generator that doesn't lose a lot in the process of converting the energy could give a 100 watts output for a few minutes after which he will start getting tired and the output will decrease. So what this guy is talking about is only achievable if you can get your laptop to function under 10 watts. Which is a feasible number, and actually it is currently at 8 watts with a target of 2 watts. Now the other option is mentioned was to hang a heavy rock on a pulley that would rotate your generator and you would just pull the rock up when it's approaching the ground to sustain the electricity generation. Here he has done a lot of imagination. Let's say you have a 5 kg rock, you hang it 2 meters high. The energy you stored in that rock is mgh which is 5*10*2. This is 100 joules. If you even have the 2 watts laptop, 100 joules will sustain you for 50 seconds. So it seems you need a 100kg rock, along with a pulley and a rope that could support that, and even then, it would give you roughly a quarter hour of operation time.

I believe that our devices had gone far beyond our capability to generate their power by pedaling. We either need extremely power efficient devices that operate in the range of 0.1-0.5 watts, or we need to generate the power in another way.