Roshan Book

My Tech Notebook

Improve battery life and reduce overheating in Ubuntu/Debian

Feeling the heat from your laptop? Overheating and reduced battery life is common ‘phenomenon’ in Linux Mint. Jupiter was the best tool to reduce overheating in Linux desktop but since its development has stopped, you can use TLP or CPUFREQ instead of Jupiter. Install TLP using the following command:

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp tlp-rdw
sudo tlp start

No configuration required for using TLP. Install it and forget about it. If you want to use CPUFREQ, read this article how to use CPUFREQ to reduce overheating in Ubuntu.

Creating a TinyURL with TinyURL’s API

How To Create Your Own Tinyurl Style URL Shortener

A URL shortener is a service that takes in a long URL and  gives you a short and memorable URL that you can distribute to anyone you want. The service takes care of redirecting users who land up at the shortened URL to the original URL.

TinyURL, of course, was one of the pioneers in the field but ever since Micro blogging sites like Twitter started to take off, a number of services have come up that all provide essentially the same URL shortening service.

One major problem with using a third-party URL shortening service is that all your links are always bound to that one service and if they ever go out of business, like tr.im did, all your data is gone too. And that is why, if you’re serious about saving all the wonderful links that you’ve discovered from around the web, you might want to consider running your own URL shortening service.

YOURLS gives you exactly that.

Installation

First of all, you need to download YOURLS to your web server and unzip the package.

yourls-download

Now, use your favorite tool to create a mysql database for YOURLS. If you’re using a shared hosting provider, there must be a way to do this from inside your domain control panel. If not, just open a ticket with your hosting provider and let them handle it for you. I named my database ‘kunz_yourls‘.

Now, browse over to the includes directory and rename the file named ‘config-sample.php’ to ‘config.php’.

Open ‘config.php’ in a text editor and edit the following variables.

‘YOURLS_DB_USER’
YOURLS_DB_PASS
YOURLS_DB_NAME
YOURLS_DB_HOST
YOURLS_SITE
$yourls_user_passwords

The comments in the file are pretty self explanatory and you can also get an overview here.

yourls-config

Now, from your web browser, visit the site http://<website>/admin, where website is the domain name where you installed YOURLS. Click the “Install YOURLS” button.

If all went well, you will see the following message which means that YOURLS was successfully installed on your domain.

yourls-install

Start creating your own Short URLs

Browse over to http://<website>/admin/index.php and login using the username/password combination that you entered earlier in config.php. If you didn’t enter any, try username/password. That’s the default combination and that is why you should change it when you’re installing YOURLS.

Upon login, you’ll be able to create short URLs easily by just entering the complete URL in the prominently displayed text box and clicking “Shorten the URL” button.

yourls-url

You can even get some nice and simple statistics about the short URLs that you’ve created.

yourls-stats

Be sure to check out the bundled tools. You get two cool bookmarklets that you can use to create short URLs right from your browser toolbar.

YOURLS also provides an API that you can take advantage of in custom applications and such.

Did you find YOURLS useful? Will you use it over, say, bit.ly? Let us know in the comments.

Redirecting non-www to www with .htaccess

Source : http://dense13.com/blog/2008/02/27/redirecting-non-www-to-www-with-htaccess/

If you want to redirect all non-www requests to your site to the www version, all you need to do is add the following code to your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

This will redirect any requests to http://my-domain.com to http://www.my-domain.com. There are several benefits from doing that:

  • It will avoid duplicate content in Google
  • It will avoid the possibility of split page rank and/or split link popularity (inbound links).
  • It’s nicer, and more consistent.

Note that if your site has already been indexed by Google without the www, this might cause unwanted side effects, like lost of PR. I don’t think this would happen, or in any case it would be a temporary issue (we are doing a permanent redirect, 301, so Google should transfer all rankings to the www version). But anyway, use at your own risk!

Something nice about the code above is that you can use it for any website, since it doesn’t include the actual domain name.

Redirecting www to non-www

If you want to do the opposite, the code is very similar:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]

In this case we are explicitly typing the domain name. I’m sure it’s possible to do it in a generic way, but I haven’t had the time to work one out and test it. So remember to change ‘my-domain’ with your domain name!

Transform Gedit Into A Web Developer IDE

Source: http://maketecheasier.com/transform-gedit-into-a-web-developer-ide/2010/12/29

Gedit is the default text-editor in Gnome based distro. To many, it may seems like a normal text-editor with no special functions (just like notepad in Windows), but for those regular users, they will swear by it and marvel at how powerful and versatile it can be. With its plugins system, it can easily transform itself from a basic text-editor to complicated and powerful programming IDE. Here’s how you can do it.

NoteFor this tutorial, I will focus mainly on HTML, PHP and CSS since that are the web programming languages I used. You can modify it to suit your needs.

First, install the extra set of gedit plugins In your system.

sudo apt-get install gedit-plugins

This will install the following plugins:

  • Commander: Command line interface for advanced editing
  • Color Picker: Pick a color from a dialog and insert its hexadecimal representation.
  • Character Map: Insert special characters just by clicking on them.
  • Draw Spaces: Draw Spaces and Tabs
  • Session Saver: Save and restore your working sessions
  • Word Completion: Word completion using the completion framework
  • Multi Edit: Edit document in multiple places at once
  • Code comment: Comment out or uncomment a selected block of code.
  • Bracket Completion: Automatically adds closing brackets.
  • Show/Hide Tabbar: Add a menu entry to show/hide the tabbar.
  • Smart Spaces: Forget you’re not using tabulations.
  • Embedded Terminal: Embed a terminal in the bottom pane.
  • Bookmarks: Easy document navigation with bookmarks
  • Join/Split Lines: Join several lines or split long ones

You won’t need all of them, but it is useful to have them readily available.

Install gedit-Gmate

Gmate is an additional set of plugin for gedit to make it more similar to TextMate. It contains code snippets, plugins, and an automatic registration of rails-related files.

To install Gmate:

sudo apt-add-repository ppa:ubuntu-on-rails/ppa
sudo apt-get update
sudo apt-get install gedit-gmate exuberant-ctags

Activating the plugins

Now that you have installed the extra plugins, it is time to activate and configure the necessary plugins. Open gedit and go to “Edit -> Preferences“. Click on the “Plugins” tab.

gedit-plugins

Scroll down the list and select the following plugins:

  • bracket completion – Automatically add closing brackets
  • class browser – show all the functions and tags for the current file.
  • color picker
  • File browser pane – easy file access from the side pane
  • Find in File / Find in Project
  • Session Saver
  • Smart indent
  • TextStyle autocompletion – Press “ESC” to autocomplete
  • Tag list – insert commonly used tags
  • Word Completion

Note: The above plugins are the one that I used. You are free to activate/deactivate any other plugins.

Once you have activated the plugins, your gedit should now be equipped with syntax highlighting, auto-completion, tag list for quick insertion, color picker, class browser that display all your functions, file browser, bracket balancing etc.

Installing extra tag list

The default tag list only comes with support for HTML and XSL. To add support for PHP, CSS and xHTML, we need to install additional set of tag list.

Download gedit_webdev_tags-0.1.tar.gz. Extract the content into a folder “taglist” in your Home directory. Open a terminal:

cd taglist
sudo cp *.tags /usr/share/gedit-2/plugins/taglist

Open your gedit, you should be able to see the tag list for CSS, PHP and xHTMLnow.

gedit-extra-taglist

Install Clientside

Clientside plugin for gedit is an useful plugin for web developer who deals with CSS and Javascript. It can minify and beautify javascript and CSS. It also includes jsLint and has option to gzip the current file.

First install the prerequisites:

sudo apt-get install nodejs php5-cli

Download the ClientSide zip file.

gedit-download-clientside

Extract the zip file. Copy the “clientside.gedit-plugin” file and the “clientside” folder to “/home/USERNAME/.gnome2/gedit/plugins”. If the “plugins” folder does not exist, create it.

Go to your gedit. In the plugin section, activate the clientside plugin. Click on the Configure Plugin button. Enter the following:

How do I call NodeJS?: nodejs
How do I call PHP?: php

gedit-configure-clientside

Configuring FTP access

You can directly transfer your files to your server via FTP without a FTP client.

Open Nautilus File Manager and go to “File -> Connect to Server”. Connect to your FTP server. Remember to check the box “Add bookmark”.

gedit-configure-ftp-server

In your gedit, open your side pane and go to the file browser. At the dropdown field, select “Bookmarks”. You should see the FTP server bookmark. You can click on it to connect to your server.

gedit-connect-ftp-server

That’s it. Your gedit should be a fully functional web developing IDE now.

Title bar gone – Linux Mint 13 xfce

Here is Roshanbook’s annual report

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

4,329 films were submitted to the 2012 Cannes Film Festival. This blog had 25,000 views in 2012. If each view were a film, this blog would power 6 Film Festivals

Click here to see the complete report.

Remove Windows Activation Key & Licence

To remove windows activation key and Licence follow these steps:

 

  1. Open a command prompt as an Administrator.
  2. Enter slmgr /upk and wait for this to complete. This will uninstall the current product key from Windows and put it into an unlicensed state.
  3. Enter slmgr /cpky and wait for this to complete. This will remove the product key from the registry if it’s still there.
  4. Enter slmgr /rearm and wait for this to complete. This is to reset the Windows activation timers so the new users will be prompted to activate Windows when they put in the key.

Hostgator Coupon

Here is coupon code which will give a discount of $9.94 for your next hosting purchase from hostgator

While signing up , just enter this code : “manashoffer“, without double quotes.

Ah yes, I will get commission for it, and you will get discount. A perfect win-win situation🙂

 

 

Solving : net usershare add: cannot convert name “Everyone” to a SID + unexpected information received

Today while sharing my Public folder , I was getting this error:

“net usershare add: cannot convert name “Everyone” to a SID + unexpected information received”.

Agter searching for a while, I found solution which worked from here : http://ubuntuforums.org/showthread.php?t=1982137

 

[1] Do not ever use gadmin-samba again for as long as you live.

[2] Purging the “samba” package will not resolve your discombobulated smb.conf file since that file doesn’t come from the “samba” package.

[3] Restore a factory fresh copy of smb.conf:

(**) Make sure the following file exists: /usr/share/samba/smb.conf

(**) Make a backup of your current smb.conf

Code:
  sudo cp /etc/samba/smb.conf /etc/samba/smb.confMOD

(**) Start with a fresh one:

Code:
sudo cp -a /usr/share/samba/smb.conf /etc/samba/

(**) Correct one mistake in the new one:
Find the line:

Quote:
encrypt passwords = false

and change it to:

Quote:
encrypt passwords = true

(**) Restart samba

Code:
sudo service smbd restart
%d bloggers like this: