giovedì 15 marzo 2012

Midori Web browser - Using SOCK5 proxy server

If you need to use a ssh secure tunnel (as explained here for example)you have to set the correct proxy SOCK5 server in your browser.
Unfortunately Midori web browser lacks of this feature out of the box, but as mentioned on the official faqs we can found a workaround.

Install tsocks:


user@user-laptop:~$ sudo apt-get install tsocks


Edit the /etc/tsocks.conf file:


user@user-laptop:~$ sudo vi /etc/tsocks.conf


Edit in this way :


# Default server
# For connections that aren't to the local subnets or to 150.0.0.0/255.255.0.0
# the server at 192.168.0.1 should be used (again, hostnames could be used
# too, see note above)

server = 127.0.0.1
# Server type defaults to 4 so we need to specify it as 5 for this one
server_type = 5
# The port defaults to 1080 but I've stated it here for clarity
server_port = 1080


In this example configuration the proxy server is the localhost, the proxy server is a Sock5 and the localhost port is 1080 (you can change port number how you prefer)

Then launch midori in this way from terminal:


user@user-laptop:~$tsocks midori


Thats all

sabato 10 marzo 2012

Vim - How to set TAB key to 4 spaces

To use Vim as editor (for python in my case) is better to set the tab space to 4 spaces instead the default 8 spaces.
Its pretty simple to do.
In Ubuntu 10.10 and similar simple add this 4 lines to /etc/vim/vimrc :


Open the file..

user@box:~$ sudo vi /etc/vim/vimrc


append these lines:

"--------Setting for 4 spaces TAB key------
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
"---------End of setting -----------------


Save and restart Vim and it should work.

venerdì 9 marzo 2012

wxPython - Sum 2 numbers tool



I modified a little example found on this nice website :

http://zetcode.com/wxpython/events/
The structure is simple, 2 input boxes and a button the get the result of the sum.
Obiouvsly you need wxPython installed to make it work.









This is the code:

 #!/usr/bin/python  
 # Sum of 2 numbers   
 import wx  
 class Sum_2_numbers(wx.Frame):  
     def __init__(self, parent, id, title ):  
         wx.Frame.__init__(self, parent, id, title, size=(320, 230))  
         wx.StaticText(self, -1, 'Number 1:', (30,25))  
         wx.StaticText(self, -1, 'Number 2:', (30,65))  
         wx.StaticText(self, -1, 'Sum:', (30,180))  
         self.in1 = wx.TextCtrl(self, -1, 'put a number', (100,20),size=(100,30))  
         self.in2 = wx.TextCtrl(self, -1, 'put a number', (100,60),size=(100,30))  
         self.st3 = wx.StaticText(self, -1, '', (100, 180))  
         self.Button = wx.Button(self, -1, "Sum !", wx.Point(80,120),size = (120,30))  
         self.Bind(wx.EVT_BUTTON, self.OnClick)  
         self.Centre()  
         self.Show(True)  
     def OnClick(self, event):  
         a = float(self.in1.GetValue())  
         b = float(self.in2.GetValue())  
         self.st3.SetLabel(str(a+b))  
 app = wx.App()  
 Sum_2_numbers(None, -1, 'Tool for summing 2 numbers...')  
 app.MainLoop()  

venerdì 17 febbraio 2012

Comandi vi

Comandi base vi

Comandi avanzati vi

UBUNTU - Add an entry to fstab (fat32 rw partition)

Quite simple task, anyway:
First of all give a look to your mounted filesystems, ok I want automatically at boot to mount the fat32 partition /dev/sda7 in the /media/DATA mount point.

fem@rodizio:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda5 206626768 33899652 162231052 18% /
none 1854844 304 1854540 1% /dev
none 1862524 284 1862240 1% /dev/shm
none 1862524 356 1862168 1% /var/run
none 1862524 0 1862524 0% /var/lock
none 1862524 0 1862524 0% /lib/init/rw
/dev/sda7 102348272 15804064 86544208 16% /media/DATA

create a mount point (in this case /media/DATA/ )

fem@rodizio:~$ sudo mkdir /media/DATA

generate the uuid number for the partition /dev/sda7

fem@rodizio:~$ sudo ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 429CA4729CA461E1 -> ../../sda3
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 7830198a-6c13-4b13-99ac-c6fe1eb15e80 -> ../../sda5
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 9cf45b4e-2b01-4e70-806b-be488e4ebe59 -> ../../sda6
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 C2C0A2A6C0A29FE1 -> ../../sda2
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 C8D6A22CD6A21AA8 -> ../../sda1
lrwxrwxrwx 1 root root 10 2012-02-17 09:46 E9ED-DDA3 -> ../../sda7

So the uuid for the partition /dev/sda7 is E9ED-DDA3
Then edit /etc/fstab with vi or another editor.

fem@rodizio:~$ sudo vi /etc/fstab

and add this line:

UUID=E9ED-DDA3 /media/DATA/ vfat auto,umask=000 0 0

Note that "auto,umask=000 0 0" let you gain read/write permission on fat32 filesystem for the normal user.
Then reboot or give this command

fem@rodizio:~$ sudo mount -a

that's all

giovedì 9 febbraio 2012

iPhone 4 - How to pass AT Commands (and make a voice call)

My goal is to send a call via iPhone shell using AT commands.

I installed minicom from Cydia (but I think you could use other programs to "speak" with the serial interface of the phone).
I refer to this page
for more infos.
I found problems on serial port setup, i tryed these interfaces with no luck :

/dev/debug
/dev/dlci.spi-baseband.extra_13

I had a look in /dev folder and I found these interfaces:

iPhone4:/dev root# ls /dev
aes_0 io8logmt tty.highland-park
bpf0 klog tty.iap
bpf1 mux.spi-baseband tty.umts
bpf2 null ttyp0
bpf3 pf ttyp1
btreset ptmx ttyp2
btwake ptyp0 ttyp3
console ptyp1 ttyp4
cu.bluetooth ptyp2 ttyp5
cu.debug ptyp3 ttyp6
cu.gas-gauge ptyp4 ttyp7
cu.gps ptyp5 ttyp8
cu.highland-park ptyp6 ttyp9
cu.iap ptyp7 ttypa
cu.umts ptyp8 ttypb
disk0 ptyp9 ttypc
disk0s1 ptypa ttypd
disk0s2 ptypb ttype
disk0s2s1 ptypc ttypf
dlci.spi-baseband.call ptypd ttys000
dlci.spi-baseband.chatty ptype uart.bluetooth
dlci.spi-baseband.cl1 ptypf uart.debug
dlci.spi-baseband.extra_0 random uart.gas-gauge
dlci.spi-baseband.iq rdisk0 uart.gps
dlci.spi-baseband.low rdisk0s1 uart.highland-park
dlci.spi-baseband.pdp_0 rdisk0s2 uart.iap
dlci.spi-baseband.pdp_1 rdisk0s2s1 uart.umts
dlci.spi-baseband.pdp_2 sha1_0 urandom
dlci.spi-baseband.pdp_3 tty vn0
dlci.spi-baseband.pdp_ctl tty.bluetooth vn1
dlci.spi-baseband.reg tty.debug zero
dlci.spi-baseband.sms tty.gas-gauge
io8log tty.gps


I found /dev/dlci.spi-baseband.extra_0 working fine but honestly I cannot ensure it work for you too.

You have to setup minicom to work properly,

iPhone4:/dev root# minicom -s

then chose "Serial port setup" and press A and edit the line of the serial device (for me was that):

A - Serial Device : /dev/dlci.spi-baseband.extra_0

Type esc and "Save setup as dfl", then exit and type

iPhone4:/dev root# minicom -w

to connect to the phone.
Then type AT, if you receive an "OK" answer all is fine otherwise check "serial port setup" setting.
To make a call to the 3931111111 number simply type:

atd3931111111;

and to hang call

ath

To get iccid number (sim serial number)
type:

at+ccid

To get imei number.

at+cgsn


That's all.