Saturday, August 29, 2015

Installing JSHint on Ubuntu using npm


When I tried to install jshint on Ubuntu 12.04 using npm, I got errors. It simply didn't work.

If you are trying to use SublimeLinter-jshint for Sublime Text 3, it won't work unless you install 2 things:
1. node.js
2. jshint

Default version on repo for Ubuntu 12.04
$ /usr/bin/node --version
v0.6.12
$ npm --version
1.1.4

When you try
$ /usr/bin/npm install -g jshint
npm http GET https://registry.npmjs.org/jshint

npm ERR! Error: failed to fetch from registry: jshint
...
...
npm not ok


The important thing to note is you must have recent version to install it properly.

Solution

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository --yes ppa:chris-lea/node.js
$ sudo apt-get install nodejs
$ sudo apt-get update

Check the version to confirm once.
$ npm --version
1.4.28
$ node --version
v0.10.37

and finally...
$ sudo npm install -g jshint
/usr/bin/jshint -> /usr/lib/node_modules/jshint/bin/jshint

Success. It's now installed.

Now if you restart the Sublime text and start with any js file, you can see the jshint will hint you for warnings and errors.a

Thursday, August 27, 2015

Install pygame for python3 on Ubuntu 12.04



To install pygame for python3, do the following:

 1. Open up the terminal and type the following code:
     $ sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev

2. Then once all libraries are downloaded and installed:
     $ svn co svn://seul.org/svn/pygame/trunk pygame
     $ cd pygame
     $ python3 setup.py build
     $ sudo python3 setup.py install

Good to go. You can now run pygame with python3.

To test, open the terminal and try for yourself
$ python3
Python 3.2.3 (default, Jun 18 2015, 21:46:58)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>>

Saturday, August 22, 2015

Command to delete trailing white spaces in Sublime Text

After searching a while for how to replace trailing white spaces from the current document, I decided to go with my own method.

One simple way is to do regex replace.
ctrl+h
Find: [ \t]+$
Replace all [ctrl+alt+enter]

I wanted to do it via a keyboard shortcut. Here come "RegReplace" package to the rescue.

Hit ctrl+shift+p.
Install Package.
Search for "reg replace"
Install.

Now you can add new keybinding to you Keybindings-user file.
This is the keybinding.

{ "keys": ["ctrl+shift+t"], "command": "reg_replace",
        "args": {"replacements": ["remove_trailing_spaces"]}

}

Another  cool feature is that, we can just view the findings without replacing,
by setting "find_only": true.

{ "keys": ["ctrl+shift+t"], "command": "reg_replace",
        "args": {"replacements": ["remove_trailing_spaces"], "find_only": true}
 } 


After confirmation, you can press enter to replace all.

Saturday, August 15, 2015

Grub recovery : Recover the gnu linux boot menu after windows installation

If you happen to install any gnu/linux OS distros before Windows installation, the Windows makes itself start by default and the gnu/linux distro disappears from boot menu.

So, how to recover the grub ? It's pretty simple.
Use the Live CD/USB of gnu/linux distro, say, Ubuntu.

The steps mentioned below are tested on Ubuntu versions 11.04, 11.10 and 12.04.

--------------------------------------------------------------------------------------------

Open the Terminal and follow these steps:

theTechGeany:~$ sudo fdisk -l | more


Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b2459d9

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              13        3053    24414208    7  HPFS/NTFS
/dev/sda3            3053       10456    59468800   83  Linux        <=====[Note sda<number> of THIS Partition.sda3 in my laptop]
/dev/sda4           10456       38913   228581217+   5  Extended
/dev/sda5           10706       20104    75497436    b  W95 FAT32
/dev/sda6           20105       29503    75497436    b  W95 FAT32
/dev/sda7           29504       38913    75585793+   b  W95 FAT32

Disk /dev/sdb: 4089 MB, 4089445376 bytes
126 heads, 62 sectors/track, 1022 cylinders
Units = cylinders of 7812 * 512 = 3999744 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00059dc3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        1022     3991901    c  W95 FAT32 (LBA)



theTechGeany:~$ sudo mount /dev/sda3 /mnt    <======[Use "Your" appropriate sda<number> here. sda3 in my system]



theTechGeany:~$ sudo grub-install --root-directory=/mnt /dev/sda
Installation finished. No error reported.



theTechGeany:~$ sudo update-grub                
# might get error. /usr/sbin/grub-probe: error: failed to get canonical path of `/cow`
# might get error. cannot find device for /
Solution (follow these only if you get any error)
        $ for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done    # mount you virtual filesystems

        $ sudo chroot /mnt (get into root and now install)
        # update-grub
It should run successfully.


Now Shutdown. Remove the Pen Drive/CD. Power On.
Grub Should be Corrected now and you can choose between the OS available.

Access Ext4 Hard Disk Format on Mac OS X


Install Fuse for OS X. Download and install 2.8.0 or above.
Download.

Install Fuse EXT-2.
Download

Now reboot the system.

EXT4 partitions will be mounted automatically.