Archive

Archive for January, 2015

[webdev] sortable table

January 29, 2015 Leave a comment

Problem
If you create a table with HTML, it’s static. It would be great if you could sort it by various columns. How to do that?

Solution
Create the static table (like before) and integrate it with a Javascript library that will make it sortable. I found a great solution for this called tablesorter. You can also find it on github, though the first link conatains more documentation and examples.

Advertisements
Categories: javascript, web Tags: ,

[webdev] add a stylish Javascript image gallery

January 24, 2015 Leave a comment

Problem
I wanted to add a modern Javascript image gallery to a website. I had some thumbnails and I wanted the following: (1) clicking on a thumbnail the image should appear, (2) the gallery must be browsable in both directions.

Solution
The Lightbox script worked for me like a charm. I’m not a Javascript expert but I could integrate it in 5 minutes. Awesome script!

Check out the project’s home page for a demo.

Categories: javascript, web Tags: ,

Windows: is my system 32-bit or 64-bit?

January 11, 2015 Leave a comment

Problem
You want to figure out whether your Windows is 32-bit or 64-bit.

Solution
Start the “DOS window” (cmd.exe) and execute the following command:

C:\>wmic os get osarchitecture
OSAsarchitecture
64-bit

C:\>
Categories: windows Tags: ,

set up a proxy server for yourself

January 5, 2015 Leave a comment

Problem
You want to have a US proxy for yourself. For instance, you want to listen to Pandora Radio, but its home page tells you “sorry peasant, you don’t live on the holy US soil“.

Solution
Here I explain one possible way. Create a droplet at Digital Ocean (it costs $5 a month). When you create the droplet, select a US location.

Create the droplet, configure the SSH access.

Then, install squid, which is a full featured web proxy cache server.

To start using your proxy, install the FoxyProxy Firefox add-on and configure it.

Now, if you visit http://www.whatismyip.com/, you will notice that behind the proxy your real IP is still visible! You are not anonymous (yet).

To hide behind your proxy, we need some more configurations. Edit “/etc/squid3/squid.conf” and add these lines:

via off
forwarded_for off

request_header_access Allow allow all 
request_header_access Authorization allow all 
request_header_access WWW-Authenticate allow all 
request_header_access Proxy-Authorization allow all 
request_header_access Proxy-Authenticate allow all 
request_header_access Cache-Control allow all 
request_header_access Content-Encoding allow all 
request_header_access Content-Length allow all 
request_header_access Content-Type allow all 
request_header_access Date allow all 
request_header_access Expires allow all 
request_header_access Host allow all 
request_header_access If-Modified-Since allow all 
request_header_access Last-Modified allow all 
request_header_access Location allow all 
request_header_access Pragma allow all 
request_header_access Accept allow all 
request_header_access Accept-Charset allow all 
request_header_access Accept-Encoding allow all 
request_header_access Accept-Language allow all 
request_header_access Content-Language allow all 
request_header_access Mime-Version allow all 
request_header_access Retry-After allow all 
request_header_access Title allow all 
request_header_access Connection allow all 
request_header_access Proxy-Connection allow all 
request_header_access User-Agent allow all 
request_header_access Cookie allow all 
request_header_access All deny all

Restart the squid server:

sudo service squid3 start

Visit http://www.whatismyip.com/ again. It will indicate your proxy’s IP, stating that no proxy is detected :) Cool.

TODO
At the moment anybody can use your proxy if they find out your IP:port combination. I tried to add username / password HTTP authentication but it didn’t work. If someone has a step-by-step guide for that, let me know.

Categories: network Tags: , ,

don’t use free proxy servers

January 4, 2015 Leave a comment

Why are free proxies free?

because it’s an easy way to infect thousands of users and collect their data

When you download a page via a proxy server, there is no guarantee that you get the original page… There is a high risk that the proxy server sent you back a modified page. Read the article above for more details.

Categories: network, security Tags: , ,

dropbox: remove conflicted copies

January 3, 2015 Leave a comment

Problem
If you have Dropbox installed on several machines, sometimes one of the clients litter your Dropbox folder with conflicted copies. Their number can be up to hundred(s). How to get rid of them?

Solution
First, locate the conflicted copies:

$ cd ~/Dropbox  # or wherever your Dropbox folder is
$ find . | grep "conflicted copy"

Investigate the result and make sure they can be deleted.

# one more check:
$ find . | grep "conflicted copy" | while read i; do echo $i; done

# if you are absolutely sure, delete them:
$ find . | grep "conflicted copy" | while read i; do echo $i; \rm "$i"; done

Notice that “$i” is between quotes since these filenames contain spaces.

Categories: bash Tags: ,

copy large files between computers at home over the network

January 2, 2015 Leave a comment

Problem
I have a desktop machine at home with a Windows 2007 virtual machine. I mainly have it because of Powerpoint. Recently I prefer to work on my laptop in the living room. Today I needed Powerpoint, so I decided to copy the whole Windows virtual machine and put it on my laptop. The only problem is that it was 67 GB and I didn’t have that much space on my external HDDs :(

Solution
Don’t panic. On my desktop machine I entered the folder that I wanted to copy and started a web server:

python -m SimpleHTTPServer

With “ifconfig” I checked the local IP address of the machine, it was 192.168.0.53.

On my laptop I opened a browser and navigated to “http://192.168.0.53:8000“. All the files I needed were there. Since I’m lazy and I didn’t want to click on each link one by one, I issued the following command (tip from here):

wget -r --no-parent http://192.168.0.53:8000

The download speed was about 10 MB/sec, so it took almost 2 hours.

Categories: network, python Tags: , ,