Skip to main content

Posts

Showing posts from 2013

Running django on apache with mod_wsgi in Ubuntu/Linux Mint

Django comes with a built in web server that should only be used in development. Integrating django and apache is a bit messy. Apart from Django and Apache itself, libapache2-mod-wsgi is needed to run django with apache2. There are four steps involved. Creating a wsgi file that enables wsgi handler . Creating a conf file in sites-available directory of apache Enabling the site and reloading apache configuration Adding a host entry that points to localhost for the site Detailed Steps First to create a mysite.wsgi file in any directory of your choice with following code [python] import os import sys sys.path = ['/var/www/mysite'] + sys.path # change the path to project directory os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi.WSGIHandler() [/python] Then create mysite.conf file in /etc/apache2/sites-available directory and write following code [xml] <VirtualHost *.80> WSGIScriptAlias / /home/user/mys

Setup connection for MDMA

MDMA is a mobile network monitoring application. It shows information such as QoS, detailed signal information. I like to use MDMA rather than Huawei dashboards. It’s lightweight and much faster than Huawei Dashboards. MDMA 1.1.0.0 requires you to have connection entry ‘ MDMA ’ by default otherwise you get an error. [caption id="attachment_95" align="aligncenter" width="470"] Cannot find phone book entry error[/caption] Setting up a connection entry for MDMA Go to Control Panel\Network and Internet\Network and Sharing Center [caption id="attachment_96" align="aligncenter" width="280"] Open Network & Sharing folder[/caption] Create a copy of existing connection. [caption id="attachment_97" align="aligncenter" width="411"] Create a copy of existing connection[/caption] Rename it to MDMA [caption id="attachment_98" align="aligncenter" width="416"] Renaming

Disable join/part messages in HexChat/XChat

Join messages are very annoying while hanging out in IRC. Its best to disable them. [caption id="attachment_84" align="aligncenter" width="1056"] Annoying join messages in IRC channels[/caption] To do this just go to Settings | Preferences | Chatting | Advanced and Check the Hide join and part messages option as shown below. [caption id="attachment_85" align="aligncenter" width="693"] Check the Hide join and part messages[/caption] You can also set this for individual channels by right clicking on channel name and choosing Hide join/part messages from settings option. [caption id="attachment_86" align="aligncenter" width="477"] Applying for individual channels[/caption]

Proxy settings in Linux Mint 14

Linux Mint 14 has a Network Manager that allows to set proxy settings but unfortunately that do not get applied to system level. [caption id="attachment_71" align="aligncenter" width="555"] Setting Network Proxy Preference in Linux Mint[/caption] To configure apt follow the following steps Go to /etc/apt/apt.conf.d/ Create a file called “30proxy” using a text editor like vi Add the following lines Acquire::http::proxy “http://username:password@host:port/”; Acquire::https::proxy “http://username:password@host:port/”; Acquire::ftp::proxy “http://username:password@host:port/”; [caption id="attachment_75" align="aligncenter" width="665"] Configuring apt to use network proxy[/caption] To configure bash in order to use curl, wget etc behind proxy Add following line in ~/.bashrc export http_proxy=http://username:password@host:port/ export ftp_proxy=http://username:password@host:port/ Don't forget to replace username and pass

Code Completion in Aptana Studio 3 for CodeIgniter 2

If you don't know code completion in Aptana Studio 3/ Eclipse for CodeIgniter 2 is very easy. Only thing required is to put following code in any new file in CodeIgniter project directory. It’s just a class in which all the codeigniter library clasees are initialized. You can even add support for custom classes by initializing it as shown. [php] <?php class _ { function _() { // any classes you want included in autocompletion $this->load = new CI_Loader(); $this->config = new CI_Config(); $this->email = new CI_Email(); $this->encrypt = new CI_Encrypt(); $this->pagination = new CI_Pagination; $this->session = new CI_Session(); $this->driver = new CI_Driver(); $this->benchmark = new CI_Benchmark(); $this->typography = new CI_Typography(); $this->form_validation = new CI_Form_validation(); $this->profiler = new CI_Profiler

jQuery support in Aptana Studio 3

I use Aptana Studio primarily for web development. It has great support for languages like PHP and JavaScript. But the problem is that I mostly use jQuery rather than code in JavaScript and Aptana does not have good support / content assist from beginning. So we need to install ruble for jQuery library. Ruble is short for Ruby bundle and is a runtime environment that allows the extensibility of Aptana Studio's editors by using Ruby. To install the jQuery bundle follow the following steps: Navigate to Commands | Bundle Developement | Install Bundle. Select jQuery and click OK. Aptana will clone jQuery ruble from github. Include appropriate jQuery sdocml in Project Build Path from Project Properties. Include a VSDoc file for jQuery in your project. [caption id="attachment_47" align="aligncenter" width="1313"] Aptana fetching jquery ruble from GitHub[/caption] You must include appropriate version VSDoc for correct Content Assist. [caption id="attac

flotjs labels on tooltips for categories plugin

I had been using awesome flot.js charting library on my results app . The charts were easy to generate and I included categories plugin to replace x-axis labels to words rather than integer values. But I faced some issues while enabling tooltips and having them display the labels rather than x coordinates. I checked up the source code. [caption id="attachment_35" align="aligncenter" width="646"] getAxes()??[/caption] plot.getAxes() method described in the documentation was giving me an undefined method error.I searched the docs, searched on Google, stackexchange etc.. but to no avail. Then I found solution thanks to firebug. I did a console.log() of the whole item object and began inspecting. I could see few objects that looked promising. Upon further inspection I found a way to map a value back to its label. [caption id="attachment_34" align="aligncenter" width="924"] Dumping entire item object in firebug[/caption] I foun

How to split large mp3 files using mp3splt

If you have a  lengthy  or large MP3 file and you want to  split  it into files of smaller size or duration, You can easily do this using mp3splt. Mp3splt   is an utility to split mp3 and ogg vorbis digital audio files without the need of decoding. It can be used to split a file into no of tracks of fixed duration and size or specified  split points. It supports variable bit rate mp3 files, silent detection, splitting with local .XMCD, .CDDB or .CUE file splitpoints or from external servers like   tracktype.org . It copies the original files first and then generates new, smaller files during the process of splitting without altering the original file. It does not do any encoding or decoding so the splitting is very fast and lossless. Steps to follow Navigate to directory where you have downloaded mp3splt { if using portable version } . Run and execute mp3slpt using the command   mp3splt  . Specify the options according to which you wanna split. The basic syntax is   mp3splt [file path]

hash passwords using MySQL inbuilt functions

I just realized that MySQL has inbuilt function for encrypting strings upon insertions and it can easily be accessed from phpMyAdmin. It has many other inbuilt functions as well. Previously I used to hash strings manually through PHP functions or used external sites whenever I was building some login system and needed some database records to test. I used to copy output of PHP’s md5/sha1 function and paste it into password field manually. All those instructors in screencasts from which I learned used to do it manually too. I just picked up from them.

Removing index.php from CodeIgniter installation

CodeIgniter by default routes URLs through index.php. It is a bad practise from SEO perspective and also makes URLs ugly. In order to remove index.php from CodeIgniter we need to create a .htaccess file in the root directory of CodeIgniter installation. First of all we need ensure that AllowOverride is On in order to .htaccess to work. Second we need to check mod_rewrite is installed and enabled. In the .htaccess file created above we need to write following rules. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # PHP under mod_php5 <IfModule mod_php5.c>     RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> # PHP under fast-CGI or other <IfModule !mod_php5.c>     RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule> </IfModule> Note the difference between mod_php5 and fast-CGI RewriteRule. fastCGI rule has a ‘ ? ’ after index.php. What Rewrite rule behind the

WordPress Not sufficient permissions to access admin page

While installing WordPress for my blog, I was trying out different subdomain/ folder options. After final installation when I tried to access the admin page I was being redirected to /wp-admin/profile.php but getting insufficient permission error like shown below. I could access the front page easily but couldn’t log in admin panel. I tried changing the permission of WordPress files  and directories to 755 but to no avail. The problem was that while installing WordPress I used different table prefixes each time. WordPress uses the table prefix for forming the option and usermeta keys name for storing roles and capabilities information. So in the process, database tables had correct table prefixes but some records in the some  of the tables still had old table prefix and this was causing the problem. To fix the issue you need to update your database using phpMyAdmin or php. Check in your database in the usermeta and options table if they have correct table prefix in al

Convert/Compress multiple images at once using IrfanView

Want to convert/compress multiple images at once? You can easily do this using a very useful and small image viewer called IrfanView. IrfanView is free image viewer that can be used to view, convert, optimize, process image files of numerous formats. It can also handle few video/audio formats, and has limited image creation and painting capabilities. It’s like an Swiss Army Knife for images. Some Features:— You can read more about IrfanView Here. Let’s get started. Open IrfanView and select Batch Conversion/Rename option from File Menu(Shortcut Key: B ) Navigate to folder where your images are located and Add the ones you want to compress. Choose the options you want to do from left window pane. Select the format and other options like Compression Ratio etc. from the Batch Conversion Settings Menu. Choose the options according to your need. After you are all set Click Start Batch. You images will be converted and you can find them in the specified output directory. Note—>

Check Who Is Copying Files From Your Shared Folders

If you share files on local network you sometimes might have wanted to know who is downloading files from network shares. You can do this easily with built-in tools in Windows. Do the following steps:— Open Microsoft Management Console by typing ‘mmc’ Run or Search box in Start Menu. Then select File—>Add/Remove Snap-in in the open Console Window.(You can also use CTRL + M shortcut key.) Choose Shared Folders from available snap-ins and click Add button. Choose All view and click Finish . This creates the MMC Console which displays shared folders, current sessions and open files. Expand the Shared Folders menu and select Sessions . You will be able to see users currently connected to your pc and the exact file they have opened.   This method works in Windows 7 as well as Windows 8 also.