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()