Sunday, November 10, 2013

Using Google Chrome with a proxy server

Works: When there's no other Chrome instance is running already, that means the one you are going to open has to be the first
This method is useful for those who use a lot of proxy and the ones who use proxies for only specific sites.
To open Chrome with a proxy server support, use the following command (Note: Wasn't tried on Windows).
google-chrome --proxy-server="<host>:<port>"

Saturday, November 02, 2013

Convert images and apply various effects on them using the command line

One thing is for sure, something so beautiful as Linux needs exploring. You can't expect anyone to trully show it's virtues that might come in handy to you. Everybody has their own cut, you have to do your.
So this other minute I was looking for some cheatsheet wallpaper to put up on my Desktop. Got a lot of them. Chose one, but the images is Black text on white backgroud, a serious problem to a maniac like me. Figured it needs some invertion, but firing up GIMP for such trivial task? :/ After a bit of drooling on ideas, Imagemagick hit my mind. One of the best tools for batch processing of images using the terminal. To install, type in:
sudo apt-get install imagemagick
There are many many options and things that can be done using this gem, cropping, resizing, inverting, even combining multiple effects. Some example commands are listed below
# Change format
convert howtogeek.png howtogeek.jpg

# Enforcing compression level
convert howtogeek.png -quality 95 howtogeek.jpg

# Resizing
convert example.png -resize 200×100 example.png
# enforce specification
convert example.png -resize 200×100! example.png
# maintain ratio
convert example.png -resize 200 example.png
# or 
convert example.png -resize x100 example.png

# Rotation
convert howtogeek.jpg -rotate 90 howtogeek-rotated.jpg

# Effects
# charcoal
convert howtogeek.jpg -charcoal 2 howtogeek-charcoal.jpg
# implode
convert howtogeek.jpg -implode 1 howtogeek-imploded.jpg
# invert
convert howtogeek.jpg -negate imploded.jpg

# Combination
convert howtogeek.png -resize 400×400 -rotate 180 -charcoal 4 -quality 95 howtogeek.jpg
You should explore the endless possibilities yourself.
NOTE: The commands have been copied from www.howtogeek.com

Friday, November 01, 2013

Make a backup of your dotfiles

If you are a regular Linux user, chances are you change distros to experiment with them. I am one of such persons who like to experiment with various Linux distros for both educational and experimental reasons. This activity may sometimes lead to problems regarding your Desktop Environment (DE) and others. It also might be the case that you just want to clean up your /home but keep your configurations intact using your dotfiles (The directories and files in your /home whose name start with a '.'). Moving these files manually is cumbersome (at least for me). The following script does it for me. And moves it to a folder called "dotfiles" in your ~/.
CAUTION: It removes any folder called 'dotfiles" in you ~/ and creates a new one.
You MUST run this in your ~/
rm -rf dotfiles
mkdir dotfiles
while read line; do
        if [ "$line" = "" ]; then
                continue
        fi
        if [ -d "$PWD/$line" ]; then
                echo "$PWD/$line is a folder"
                cp $PWD/$line $PWD/dotfiles/$line # substitute cp with mv to move the files
        else
                echo "$PWD/$line is a file"
                cp $PWD/$line $PWD/dotfiles/$line # substitute cp with mv to move the files
        fi
done < <(find . -maxdepth 1 -name ".*" -printf '%P\n')

Saturday, October 26, 2013

Linux shell cheatsheet (Can it become one?)

I love the command line, the CLI. I wish somethings were a little bit different allowing me to use CLI for every task, but the world is a cruel place, apart from stupid M$ mistakes regarding their crappy GUI. You do realize there wouldn't be such a crappy product without dependency on the GUI, right?
I'm not categorizing it right now, because there's not much to categorize actually
Show line number in "grep" output: grep "text" -n

Running your first PHP application in Google App Engine (Fix for the --php_executable_path flag () issue)

As I may (or may not) have mentioned before, I mostly blog here for the purpose of note-keeping for myself. In most of the cases I don't really care about how good the tutorials (not so much) are coming out. So, please do your homework if you are following any of my tutorials at all. This is gonna be a disclaimer somewhere, but see? I can't give a damn here. Thanks.
I was trying my hands on the Google App Engine. My system is Linux so I downloaded, followed the linux part of things from their official how-to-first-time page here [ https://developers.google.com/appengine/docs/php/gettingstarted/installing ]
As you can see from that page (yeah, that's a dependency) you
1. Download the PHP SDK
2. Extract it some nice place
3. Write a "hello world!" PHP script
4. Execute the python script (dev_appserver.py) in the the "google_appengine" (if you haven't done it otherwise) folder.
BUT ! I got stuck here for sometime, and looked up for the fix.
Source of the problem:
_PHPBinaryError: The path specified with the --php_executable_path flag () does not exist.
Which naturally implied 2 things
1. The PHP installation was NOT as the app engine wants it to be
2. God doen't want me to code anymore
I naturally believe God loves it when I'm busy with my favourite thing so number 2 was obsolete. I looked up on Google for some solutions and a sudden SO page suggested that executing the appserver executable like
./dev_appserver.py --php_executable_path="...path..to..the..php-cgi..executable..." helloworld
will solve the problem.
Following this trail I came to notice that my ignorance toward the tutorial's PHP installation paid of here. The problem was actually my PHP installtion was a CLI version. While the app engine essentially wants a CGI version. For doing so, the tutorial has very good instructions, and yes, php-cgi is NOT available in Ubuntu repos. So I did
sudo apt-get install gcc libmysqlclient-dev libxml2-dev
  wget --trust-server-names http://us2.php.net/get/php-5.4.15.tar.bz2/from/us1.php.net/mirror
  tar xjf php-5.4.15.tar.bz2
  cd php-5.4.15
  ./configure --prefix=$PWD/installdir --enable-bcmath --with-mysql
  make install
  cd -
And afterwards executed
./dev_appserver.py --php_executable_path="...path..to..the..php-cgi..executable..." helloworld
And it went smooth. :) By the way, the above method will NOT harm you normal PHP installation.

Saturday, August 17, 2013

Playing UT2004 in your desired Resolution

Well, that's more of a "Note for self" than anything else, so I'll leave it short and simple.
setres 1366x768x32

Wednesday, July 24, 2013

[Ubuntu] How to fix dependency problems

This is not a very generic method to solve dependency hells but in many obvious cases this is a very good one. It solved one of my problems with some components of "MySQL" being replaced / removed by some mysterious force. I'll pick the scenario here and try to draw a picture on the approach. The solution is based on the askUbuntu answer here [ http://askubuntu.com/questions/227978/problem-after-mysql-server-installation-i-cant-install-any-thing-in-ubuntu-12-04/228450#228450 ]

The problem: I was trying to access a web app that I was working on inside my 'localhost', but for some reason the mysql components were not functioning properly.
The server configuration: Apache2, PHP5, MySQL. The server was setup using 'Automatic virtual hosting' method.
The packages used were installed using:
apt-get install ia32-libs-multiarch build-essential ncurses-term g++ mc lfm unrar firefox apache2 apache2-doc apache2-suexec git zsh vim aria2 awesome curl chromium-browser mpd ncmpcpp git conky pcregrep unagi mysql-server libapache2-mod-auth-mysql php5-mysql php5 php-pear php5-sqlite php5-curl php5-imap php5-intl php5-mysql phpmyadmin openssh-server php5-mcrypt 
It's the full string from my server setup script, you can see the apache, php and mysql packages being used in the list.
How did I find the cause: I tried the package installation script again and it threw these errors
The following packages have unmet dependencies:
 mysql-server : Depends: mysql-server-5.5 but it is not going to be installed
 php5-curl : Depends: php5-common (= 5.4.9-4ubuntu2) but 5.4.9-4ubuntu2.1 is to be installed
 php5-mysql : Depends: php5-common (= 5.4.9-4ubuntu2) but 5.4.9-4ubuntu2.1 is to be installed
E: Unable to correct problems, you have held broken packages.
Then I Googled the first line (mysql) and found the askUbuntu answer page.
This indicated the cause to be a recent addition of and external repo into my repo list.
How did I fix the problem : I first removed repos that were added by me from Synaptic > Other softwares. [ Open Synaptic and then untick repos from "Other software" tab
First I executed the commands
sudo apt-get -f remove mysql-server-core-5.5 mysql-server-5.5 mysql-server-5.5 mysql-server
sudo apt-get -f remove php5-curl
sudo apt-get -f remove php5-common
Then executed the installation commands again and the problem was fixed.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...