Monday, March 31, 2014

Fedora: Git cloning Problem (Github) in proxy connection

Today after installing Fedora Scientific, I decided to master Unix type OS and then Git (which I wanted to learn for the last couple of years but had no time). I'm accessing Internet through our college connection which needs proxy to be configured. So, I configured the proxy on Fedora and then Firefox to access this awesome book Pro Git

Then as per the author said I tried to clone this project from GitHub and ended up with an error message. I already had this kind of proxy related mess on Ruby on Rails in Windows, but here in Fedora! I don't know? I first thought. But it was frickin easy to rectify this proxy problem (after a few minutes googling) as I executed this command,

$ git config --global http.proxy '172.16.0.18:8080'

prior to executing the

$ git clone https://github.com/schacon/grit

Problem solved. Connection was established and cloning was successful.

Wednesday, March 19, 2014

Starting/running two or more programs using a single batch file

My problem:
1. Need to start Wamp server (my lazy ass is using mysql from it)
2. Then need to open a command prompt, point it to a particular directory where my rails project is located and run the command

mongrel_rails start

to start the rails environment.
3. Then finally need to start a browser and point it to local host and the particular port at which the app is listening.

What I did (might be lame):
I have no problem doing the above steps to access the app, but my boss doesn't. All he needed is an icon which when he click would do all the above for him. No problem, right! Because, we have the beautiful batch files that could do the above tasks for us when got clicked. So I started writing a batch file. It goes like this(which I think is self explanatory),

@ECHO OFF
START C:\wamp\wampmanager.exe
start cmd /c "cd c:\project && mongrel_rails start && pause"
cd C:\ProgramFiles(x86)\Google\Chrome\Application
start chrome.exe http://127.0.0.1:3000
sleep1
exit

which I saved as filename.bat on desktop. Double clicked it: problem solved.

Monday, March 17, 2014

Running .sh files on windows using Cygwin

Never heard of Cygwin before? No probs, just download the Cygwin installer and run it. Once the Cygwin is installed open the Cygwin terminal. Now just using the path of sh.exe located in 'C:\cygwinXX\bin\sh.exe' and the path of your .sh file you could simply run the file using the command:

c:/cygwin64/bin/sh.exe C:/wamp/www/SMIP_Install_v1_1/install.sh

It will run your .sh file. Note: just check the '/' you use in the path. Don't use '\' but '/' (not windows but UNIX).

Saturday, March 15, 2014

Solution to "The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. rake aborted! no such file to load -- mysql/mysql_api"

I tried installing Fedena this evening. While going through the fifth step i,e executing the command

rake db:create

on my command prompt I ended up with this error message "!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. rake aborted! no such file to load -- mysql/mysql_api". I tried a lot of websites for a solution and ended up smoking three cigarettes in a row and of course with no solution.

Then after an episode of 'House of cards', I again checked back the error and tried the command

gem install mysql

which I did tried three or four times before but neglected the description it gave me. It said the mysql connector was installed successfully but the version might change so get the libmysql.dll from the location it downloaded (for me it is, http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip) the connector into C:\ruby\bin (bin folder in your ruby installation).

Then reluctantly I copied the above url and downloaded the zip file. From the zip I extracted the libmysql.dll (\lib\libmysql.dll) file into the config folder in Fedena directory and replaced the already existing file. That's it. Then the command

rake db:create
worked smoothly and I continued installing Fedena successfully.

Friday, March 14, 2014

Can't install Composer although openssl extension enabled in Wamp!

I tried installing Composer which irritated me at first by telling me to enable the openssl extension and recompile my PHP. I always use Wamp on my home computer, which told me that openssl was installed and active (wamp-> php -> php extensions).

I tried for a few times, disabling and enabling openssl and restarting all services every time. Still ended up with the same error, irritated me more. Then had a smoke and while doing so, my hand guided my computer to the directory where php.ini (in ../wamp/bin/php.phpx.x.xx/) file was located, opened it and searched for openssl. There I found a line 'extension=php_openssl.dll', as a comment.

I uncommented the line, saved the file and restarted all services on Wamp. Waited for a few seconds and ran the composer setup to witness it installing without any trouble. It was an emotional moment for me.

Now, why I installed Composer for! I don't know. I've got to go figure it out now. my ass!

Did simple Django installation on Windows (Python)!

Today I downloaded some apps that were build on Django. At first I thought it's gonna be a pain in my ass to set up Django and then configure those apps, even to have a glimpse of how they look and work. But I was wrong. I already had Python installed on my computer. So I followed the below steps:

Step 1: Went to Django official download page, downloaded Django-1.6.2.tar.gz and unzipped it into a local folder named 'Django'.

Step 2: Opened command prompt and headed to the local folder 'Django' (C:\Users\userX\Documents\Django).

Step 3: ran the command,

python setup.py install

which made the command prompt go crazy while I sat in front of my computer feeling like a nerd. 

Note: If you encountered the error, 'python' is not recognized as an internal or external command, operable program or batch file, in this step, then add C:\PythonXX\;C:\PythonXX\Scripts; (XX is version of your python like python27 or python33 and so) to your PATH environment variable (system-> advanced sys settings -> environment variables -> PATH-> edit).

Step 4: Once my command prompt came to rest, I typed 'python' and hit enter to turn it into Python interpreter. Then tried importing django (import django) and checked its version (print(django.get_version())). Success!

Step 5: Typed 'ctrl+c' to bounce back to command prompt from interpreter. Then I created an another local directory to create a sample app, took the command prompt to it and entered the command, 

python C:\python27\Scripts\django-admin.py startproject myapp_sample

to finally check every thing's alright and it was, surprisingly

Wednesday, March 12, 2014

pyQt: ui file to py file conversion in windows

Once the anyfile.ui file is saved then it could be converted into anyfile.py file using uic.py script. 

Step 1: Download and install PySide.
Step 2: Open your command prompt and head to the directory where the installed PySide scripts were located on your computer like in mine, C:\Python27\Lib\site-packages\PySide\scripts
Step 3: Now type the command 'python uic.py input.ui -o output.py -x', in which you have to only change the input and output file names. For me this command worked 'C:\Python27\Lib\site-packages\PySide\scripts>python uic.py D:\PyEx\sam.ui -o D:\PyEx\output.py -x'
Note: It would be easier if the ui file to be converted is saved in the same directory as the uic.py file.
Step 4: Open, run and verify the output py file and have a self five.

Monday, March 10, 2014

Grabbing screen size in wxPython

>>import wx
>>screen_size = wx.DisplaySize()
>>print (screen_size)

>>(width, height)



Wednesday, March 5, 2014

Problem installing WAMP on Windows 8.1!

I just updated to Windows 8.1 from 8 and installed Wamp server. At first, Wamp is not working. I mean, I can't open the localhost or any other services from Wamp. So I queried Google and tried installing apache (click Wamp -> Apache -> service -> install service) and mysql (click Wamp -> MySql-> service -> install service) service. That's it, everything works.

Then I tried the phpmyadmin page but it asked me password like it did the last time. I saved some instructions in my evernote about it once, but I was too fuckin' lazy to go through that shit. So I opened the mysql console and typed:
show databases;
use mysql;
from table user show *;

which gave me the username - 'root' and password - ''(blank), using which I used to logged in to my phpmyadmin. But my lazy ass forgot to think about something. I don't want to go through the login page every time on my local server, so all I need is to disable the login page and save me some overhead. So again I went back to my evernote shits. Then I edited (from dir:root/wamp/apps/phpmyadmin/config.inc.php ) the line:

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';

 to

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';

Which solved my problem, adios!

Resources that might have helped me:
http://forum.wampserver.com/read.php?2,116611
http://www.ntu.edu.sg/home/ehchua/programming/howto/WampServer_HowTo.html

This helps too:
http://stackoverflow.com/questions/273159/how-to-determine-if-a-port-is-open-on-a-windows-server
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html