2014/04/09

Why my computer is slow? 7 steps to make your Windows 7 faster.

Why my computer is slow?

Perhaps this is the question that millions of people around the globe are asking every day. This is popular topic within the Windows users and there is usually good reason why your computer is slow.

Personally now days i can tune almost any windows computer to work fast. Or if not fast, at least a lot faster. There is few tuning tips that i want to give. If you follow these steps, your computer will be faster.

I don't like when people are recommending reinstalling of whole Windows every time when computer is acting slowly. Its easy solution, like cheating. 90% of the time, its not even necessary.

Your computer has became slow, since its stuffed with running processes. Every time when you any kind of application running on background, its eating CPU cycles and consuming memory. Your hard drive has started defragmenting. Defragmenting means that bits that reside your physical hard drive surface has been scattered, and system needs to spend extra time looking for them.

To keep your computer running smoothly, you need to keep things simple. Here is few tips that i recommend doing, if you wish to kick some speed to your can. These examples are for Windows 7. This might be bit aggressive approach, so pay attention. Sometimes desperate time require desperate measures!

Performance tuning Windows 7


1. Make sure that your windows is up to date.

This is natural and good step to start tuning your Windows. If you missed service pack updates, that is going to affect your performance since it includes many performance updates. Check your updates, update everything you can, reboot and repeat this until Windows update doesn't have anything else to offer. Open up start menu and search for 'Windows Update'. Then just click 'Install updates'.

Search for 'Windows Update'
Keep installing updates, until Windows update doesn't have anything else to offer.

2. Delete unused applications, that you don't need anymore.

Be careful here, remove only applications that you recognize. There can be bunch of frameworks and drivers need to be there. But don't be scared, your system wont die if you accidentally deleted something that you shouldn't. Open 'Add or remove programs' select application from the list, press uninstall and follow the instructions after uninstaller starts.
Search for 'Add or remove programs'

3. Remove ALL start up applications. 

Yes, everything, unless you are certain that you need them. Its easier to come back and enable the applications than just leave them hanging around useless. Anti virus software is a good example which you could leave enabled. Open application called 'msconfig', select 'Startup' tab and start deselecting applications. After you are done, hit OK.

Search for 'msconfig'
Remove everything what you don't need.


4. Run CCleaner

This handy piece of software will delete all of your temporary files with one click. You can also clean up your registry. Just hit 'Analyze' to see what CCleaner is about to do and after that click 'Run Cleaner'. You can repeat this step at 'Registry' tab.

Download latest version of CCleaner here:
http://www.piriform.com/ccleaner/download

CCleaner analyze

5. Reboot your system

Now on system startup should already start feeling less painful. Keep an eye out if something is missing, go back to 'msconfig' and re-enable applications if needed.

6. Defrag your system

You really don't have to (or actually shouldn't) do this if you are using SSD drive. SSD or Solid state drives wears out by doing intensive read/write operations (which defrag is doing). And since seek-time of SSD drive is 0ms its really needed anyway. If you are not sure, listen to your harddrive, if you hear it spinning and keeping noise, then its a standard hard drive, and you most probably should defrag it.

Open 'Disk Defragmenter', click Disk you want to defrag and hit 'Defragment disk'. This might take a while. Tts better to leave it running and not to do too much stuff with your computer during that time.

Search for 'Disk Defragmenter'
Select drive and click 'Defragment disk'


7. Clean your desktop

This might be an illusion, but seriously try it! Making your desktop clear from all the temporary documents and crap will make your computer appear to be running faster. Also change a shiny new background. If you don't know where to look for one, i recommend http://interfacelift.com/.
Before

After
Thats it, now your system should be bit faster again. Hopefully this was helpful.

2014/04/07

Saving screenshot to clipboard or desktop on Mac OS X

Here is few very handy shortcuts for taking screenshots in Mac OS X. Especially saving your region directly to clipboard can be a great time saver when working on a presentation or anything alike.

Cmd - Shift - 3
Capture screen and save it on desktop.

Cmd - Shift - Control - 3
Capture screen and save it on clipboard.

Cmd - Shift - 4
Capture region and save it on desktop.

Cmd - Control - Shift - 4
Capture region and save it on clipboard.

Saving screenshot (3) or region (4) to clipboard.

Taking screenshot on Samusung Galaxy S4

It wasn't too obivius so i had to search for it.

Classical way for taking screenshot in Samsung Galaxy S4 is to press:

power/lock screen button + home button at the same time for 1 second.

After this screenshot will be taken and saved into your gallery. You could also use Samusing motion sensor and swipe your hand across the screen. This has to be somehow enabled from the menus, but since i find this feature useless anyway, i didn't even bother to try it out.

2014/03/06

Enable password authentication for Google Compute Engine instance.

By default Compute Engine instance uses key pairs to authenticate you into your instance. This is very much recommended for security reasons. When you are first time connecting your instance through gcutil ssh, you will be asked to create a pass phrase for your ssh keys. Gcutil will create key pair in your local machine and copy it over to your project.

However if you want to authenticate ssh from outside world using password, here is a simple step what to do:

Edit file /etc/ssh/sshd_config

Find this line from your sshd_config and change it to PasswordAuthentication yes:
 # Change to no to disable tunnelled clear text passwords  
 PasswordAuthentication no  
Then just reload your OpenBSD Secure Shell server (Debian).
  sudo /etc/init.d/ssh reload  
In a CentOS init.d name is bit different, since it uses OpenSSH server.
 sudo /etc/init.d/sshd reload  
Of course also remember to add firewall rule for TCP port 22. This can be done through Developers Console.


2014/02/28

Add quick print button for Google Chrome

My friend was recently wondering that why doesn't chrome have quick print button. Back in the days i also got used to that quick print icon in Internet Explorer. And i do remember using it many times.

In chrome, normally you could print by opening Chrome settings tab from right hand side and select "Print...". Alternatively you can print by using keyboard shortcut Ctrl+P (Windows) or ⌘-P (mac).

Since my IE days are long gone, i would still like to have quick print icon in Google chrome. This is how you can get it.

Select "Customize and control Google chrome", from the top right corner next to the address bar.








Note that Show Bookmarks Bar must be enabled. Select Bookmarks -> Bookmark Manager.















While Bookmarks Bar selected, right click anywhere on the window right hand side and select "Add Page".



Left textbox is the name of the bookmark, i made it "Print". Right side is the bookmark URL, we are going to place small javascript to it: javascript:window.print(). Then hit enter and you are done.

Now you should have nice small quick print icon on your bookmarks bar. I wonder if you could actually have cool printer icon on it as well. Need to research that later.









2014/02/26

Linux: Bash single line for loop examples

Knowing for loop in bash is definitely one of the most powerful tricks. For instance, it makes processing and reading files quick and painless in most cases. Since there can be countless use cases for this, i will write down some basic use scenarios.

Here is few basic examples that could be useful.

Creating files:

 for i in 1 2 3 4;do touch file"$i";done  
 ls -l  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:31 file1  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:31 file2  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:31 file3  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:31 file4  

Renaming all files within directory:

 ls -l  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic01.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic02.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic03.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic04.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic05.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic06.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic07.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic08.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic09.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic10.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic11.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic12.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic13.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic14.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic15.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic16.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic17.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic18.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic19.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 pic20.JPG  

I want to change rename these pictures as picture_01, picture_02 and so on. I could do this:

 for i in *;do mv $i $(echo $i | sed "s/pic/picture_/");done  
 ls -l  
 total 0  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_01.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_02.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_03.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_04.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_05.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_06.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_07.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_08.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_09.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_10.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_11.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_12.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_13.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_14.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_15.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_16.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_17.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_18.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_19.JPG  
 -rw-r--r-- 1 m 5000 0 Feb 26 21:18 picture_20.JPG  

* wildcard in this bash loop (for i in *) refers to all files within current working directory. That's why this for loop will catch all files.

Jinja2 template engine, simple basics.

Template engines will allow you to keep your HTML code outside of your code base. Managing and generating HTML in code is a bad practise. Templates will also give nice boost for performance and give you more secure system. this naturally depends how you are using your templates.

This is what Jinja2 is hyping in their features list:


  • Sandboxed execution
  • Powerful automatic HTML escaping system for XSS prevention
  • Template inheritance
  • Compiles down to the optimal python code just in time
  • Optional ahead of time template compilation
  • Easy to debug. Line numbers of exceptions directly point to the correct line in the template.
  • Configurable syntax

  • I was surprised to see how flexible Jinja2 for instance is. Variables can be modifier by filters you can see the full list of built in filters from here: http://jinja.pocoo.org/docs/templates/#builtin-filters

    Here is some basics, which are usually enough to get going.

    I'm passing this test data to Jinja2 (I'm using Python):

     template_data = {"page_title": "Testing templating",  
                      "page_text": "This is my Jinja2 rendered web page!",  
                      "loop_data": ["item1", "item2", "item3"]}  
    

    Data is in dict format. It consists title, text and some data for demonstrating looping. Loop data is placed inside a list.

    This is my template file:

     <html>  
     <head>  
     <title>{{ page_title }}</title>  
     </head>  
     <body>  
     <h1>{{ page_text }}</h1>  
     Loop data:  
     {% for row in loop_data %}  
      {% if row == "item2" %}  
       <font color="red">{{ row }}</font>  
      {% else %}  
       {{ row }}  
      {% endif %}}  
     {% endfor %}  
     </body>  
     </html>  
    

    Variables are referred with {{ var_name }}.

    For loop works like in any other programming language. Just loop list named loop_data and represent its data with variable row in the loop.

    There is also a example how simple IF works. Basically when row value hits "item2" in the loop, font color should be in red. You can also specify {% elif %} blocks.