Remove all gems in windows and linux

This is at the first results in google but here is a shortcut:

gem list | cut -d" " -f1 | xargs gem uninstall -aIx

This will remove all gems if you are developing in Linux. Here is more detailed description.

For windows developers there is also a quick tip. You have to start PowerShell to run that (hit start button and just type it, if you are using Windows7)

gem list | %{$_.split(' ')[0]} | %{gem uninstall -Iax $_ }

And the detailed explanations if you want to learn the commands.

CakePHP DebugKit analog for Ruby On Rails – RackBug installation

I am using Ruby on Rails for a project and I was searching for a similar tool like DebugKit in CakePHP, but for Rails and found RackBug. The both tools provide you with debug information, database queries, request details and so on.

Installing RackBug is easy. You can follow the steps in the readme file, provided with the gem. Just run

gem install rack-bug

Adding

config.middleware.use "Rack::Bug"

sometimes didn’t work. You have to change “Rack::Bug” -> ::Rack::Bug and add RackBug namespace in the environment/development.rb in your project. So you will have to have this

require 'rack/bug'
config.middleware.use ::Rack::Bug

Don’t forget to open this url in your application to enable RackBug

http://RAILS_APP/__rack_bug__/bookmarklet.html

I wish you debugless debugging :)

Installing Ruby gem on Windows 7 – json (1.6.5) – Unfortunately, a fatal error has occurred.

I was setting up a new project in Ruby and get the message

Installing json (1.6.5) Unfortunately, a fatal error has occurred. Please report
this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues
so that we can fix it. Thanks!

The issue is reported here, but the solution is simple.

You have to install json gem, but it give other error:

ERROR:  Error installing json:
 The 'json' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
 from 'http://rubyinstaller.org/downloads' and follow the instructions
 at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

In short – install DevKit and json gem and try again.

Here are more detailed steps to follow:

1. Download DevKit from here. You have to extract DevKit files to some directory (specify separate directory. The extractor didn’t create it’s own)

2. Create config.yml running

ruby dk.rb init

in the directory where you extracted DevKit.

3. Run

ruby dk.rb install

to add DevKit to Ruby

4. Install json gem with

gem install json

You are done. Run the project creation with

rails new /path/project_name

Here are more detailed steps of installing DevKit.

Kindle hidden features and shortcuts

Probably you remember that hidden features in software are named “easter eggs”. Almost all programs have such, activated with hidden shortcuts, gestures or any other condition. I remember the time of Windows 98 there was an egg activated when you click on three exact coordinates in the tab where you set time zones. There was a lot of clicking for that to see a list with people in a movie who made that joke.

Kindle users may not know, but their devices have such hidden features too activated with key combinations. For some reason Amazon didn’t provide the combinations in the official useg guide or maybe I was not reading carefully.

The best hidden feature according the e-book reader is screenshot saved in PNG format on the device and can be downloaded to a computer when you connect the device. There is also other “cool” hidden features

General shortcuts

  • Alt + Shift + g – create screenshot
  • Alt + g – screen refresh
  • Alt + Shift + m – play game (execute shortcut from home and play minesweeper or 5 in a row)
  • Alt + Home – go to Kindle store
  • Turn off the device with holding power slide button for 7 seconds
  • Reset your device with holding down the power slide button fo 15 seconds

Keys while reading

  • Click Menu anytime to see clock. When reading you can also see the progress bar
  • Alt + b – add or remove bookmark
  • Right navigation arrow – skip to next chapter
  • Left navigation arrow – go to previous chapter
  • Shift + Sym – turn text to speech On/Off
  • Back – turns off text to speech
  • Spacebar – pauses text to speech
  • Set cursor to position where to start the speech
  • Alt + Space – turn music On/Off
  • Alt + f – skip to next track

To activate and use your image viewer follow the steps

  • Plug your device into your computer with the USB cable
  • Create folder “pictures” in one of the other folders
  • Inside the folder create another folder to add the images. Adding images directly in “pictures” folder doesn’t work. For multiple collections, create multiple folders
  • Unplug your device from PC and click Alt + z on the home screen to add newly created image folders to the book list. When click on a folder the image viewer will launch.

And finally image viewer functions

  • q – zoom in
  • w – zoom out
  • e – reset zoom
  • c – actual size
  • f – full screen
  • r – rotate
  • Use navigation controller to pan
  • Change images with page Prev/Next buttons

If you have another shortcuts – please share.

How to avoid apache restart for gettext cache issue

Many applications use gettext for i18n and l10n. Gettext is PHP extension which holds translation strings in key-value pair. The translation is cached when apache first open the file which is good. However the issue with the cache raises a problem when you change some string and want to view the changes. In development environment it is easy solvable – just restart apache, but the problem in production environment can be bigger, especially when you have no rights to restart the web server.

The issue can be solved in PHP, but if it is one time change the effort does not deserve doing it. An easier way is to delete the .po file, refresh the page, upload the changes and refresh again. A much quicker way. Enjoy :)

 

Highlight search keyword in Firefox

While checking some features on Opera I found a nice way to select keywords in a page. When you search for a word with Ctrl + F all words are highlighted and the current selected one is yellow. In addition to this a firm grey background is added to the whole page, making easier to see the highlighted keywords.

keywords highlight on Opera

So I start to search for Firefox plugin that can deliver this exact behaviour. Unfortunately there is no such, but there is already such functionality to highlight a keyword. If you didn’t notice the “Highlight all” button next to Find input, take a look. I ask mysilf how I didn’t notice it. And the nice thing is that there is a shortcut for that. It will hightlight all keywords, so you will notive them.

Alt + A

Well, there is no cool grey background that make you feel Appleish…keyword highlight

NetBeans and Eclipse PDT shortcuts comparison

When I start developing web pages I used Notepad++. It is very light, has a lots of plugins that you can include in your editor and the base functionality is not bad. With time, it became insufficient, there was need for some functionality and shortcuts that I missed. It upgrades often it’s plugin manager and sometimes the plugins became useless, since updates were not available to the current version. Staying old also is not a solutions – there are a lot of plugins, some of them not working well on older versions.

So I start using IDE for developing web applications. There are a lot of choices out there and my favourites are:

  • NetBeans nice and free IDE with good PHP support, syntax highlighting and many more
  • Eclipse PDT (PHP Development Tools) community developed IDE with good PHP support and lots of functionality

There could be also many more, but the focus of this post is to describe the differences in NetBeans and Eclipse PDT since I get used with some shortcuts, but there is always something that I don’t like in each IDE.

I used NetBeans for a long time and when there are a lots of projects in the explorer it take a long time to scan all the code for changes. There are tickets about these issue and the statement is that it should not take more than a minute. But sometimes it gets 4+ minutes to scan the code of all projects and I even do not use or need to use all projects. Closing projects is partially the solution on the price of inconvenience. You can go and make a coffee while the IDE loads you will say, but I already drink a lot of coffee. Also the memory usage using IDE is big, but the good things have price.

So I decided to give a shot on Eclipse PDT and the first thing is to search for the shortcuts that I get used to use in NetBeans. In the list below are the shortcut keys that I use most:

Command NetBeans Eclipse
Syntax highlighting Yes Yes
Has code zoom in/out No No
Comment/uncomment line Ctrl + / Ctrl + / and Ctrl + Shift + C
Add block comment Ctrl + / Ctrl + Shift + /
Copy duplicate line Ctrl + Shift + Up or Down Ctrl + Alt + Down
Ident line Tab selected text Ctrl + I
Insert line above curent line Ctrl + Shift + Enter
Insert line below current line Ctrl + Enter
Insert new line below and move cursor Shift + Enter Shift + Enter
Moves line up or down Ctrl + Up or Down Alt + Up or Down
Delete line Shift + Delete Ctrl + D
Delete next word Ctrl + Delete Ctrl + Delete
Delete previous word Ctrl + Backspace Ctrl + Backspace
To lower case Ctrl + U, L Ctrl + Shift + Y
To upper case Ctrl + U, U Ctrl + Shift + X
Code format Ctrl + Alt + F Ctrl + Shift + F
Autocomplete functions/variables Yes (Ctrl + Space) Yes (Ctrl + Space)
Open method/class Ctrl + Mouse clcik Ctrl + Mouse clcik
Code expand/collapse Ctrl + Pad+/Pad- Ctrl + Pad+/Pad-
Code expand ALL Ctrl + Shift + Pad Ctrl + *
Code collapse ALL Ctrl + Shift + Pad- Ctrl + Shift + /
Auto highlight Click on word Click on word
Go to on view back (history) Alt + Left arrow Alt + Left arrow
Go to one view forward (history) Alt + Right arrow Alt + Right arrow
Go to line Ctrl + G Ctrl + L
Last edit location Alt + Left arrow Ctrl + Q
Cycle tabs Ctrl + Tab Ctrl + PgUp and PgDown
Open declaration Ctrl + click F3
Breakpoint Ctrl + Shift + M
Next Breakpoint Ctrl + Shift + . Ctrl + Shift + .
Previous Breakpoint Ctrl + Shift + , Ctrl + Shift + ,
Find/Find next Ctrl + F3 Ctrl + F3
Quick outline Ctrl + O
Maximize/minimize editor window Shift + Escape Ctrl + M
Show function list
(Navigator in NetBeans)
Ctrl + 7 Alt + Shift + Q, O

Here is a useful table of IDEs comparison.

PHP File Managers for your projects

For a project I have to implement a file manager. Here are some links to ready to implement php tools that you can use. Bellow is just a list of links of file managers

Here are some of the free and/or open source choices

phpFileManager – not so beautiful file manager, but with a lot of functions for configuring, manage file or directroy, support multiple upload, execute shell command (shell/exec), set permissions etc. It has directory tree on the left side and is available for windows/linux and php4/5
ElementIT
- This one is not php, but it has nice features and windows like interface.
PHPfileNavigator2
is open source web based php file manager with cool features. It is easy to install and configure.
FileManager
is simple file manager with support of multi languages, multiple files and whole directory upload and many more.
Encode Explorer
is simple file browser written on PHP.
osFileManager is php open source project for file management. With it you can manage files, directories and users

File managers with paid licences:

FileRun is windows explorer like file manager with paid licece.
filemanager is nice looking file manager with paid licence. Check the link – there is a good video that presents the tool features
Web file explorer is another file manager with some limitation. It provides windows like environment in your web application.

At the end of this post you will find a list with other file managers.

Most useful Firefox tips, tricks and shortcuts

More web developers use Firefox for developing web applications. The facts are that Firefox is open-source, provides useful add-ons and extensions like Web Developer, Firebug, PageSpeed etc. Despite the Google Chome gets more and more popular, Firefoxis still the favorite browser.

You can customize and place as many tollbars as you want. This makes the working area smaller, but you can make the icons smaller with checkbox in View->Toolbars->Customize. The View menu is nicely hidden and shows when you click Alt. Another tip to get more space is to use F11. It hides all toolbars and gives you the space needed.

If you are using Firebug a quick show/hide function is applied on F12 button and makes moving your hand to the mouse and back unnecessary.

Well there are many more shortcuts out there. You can check the list at mozilla page.

Here are the shortcuts I use:

  • Ctrl + L – Go to address bar
  • Ctrl + K – Go to search engine search bar
  • Backspace – Loads the previous page
  • Spacebar – One view down
  • Shift + Spacebar – One view up
  • F5 – Reload page
  • Ctrl + F5 – Reload all resources (even cached)
  • Ctrl + D – Bookmark page
  • Ctrl + F – Opens and go to search box
  • Ctrl + = / Ctrl + - – Increase/decrease font size
  • Alt + Home – Go to home page
  • Ctrl + L – add prefix “www” and “com” suffix in address bar. For example you can type kdelchev in the addess bar and hit Ctrl+Enter. It will automatically translate the addess to www.kdelchev.com and will load the page.

Tab navigation and control

  • Ctrl + T – Opens new tab
  • Ctrl + W – Closes a tab
  • Ctrl + Tab – Go to the next open tab
  • Ctrl + Shift + Tab – Go to the previous tab

Mouse shortcuts

  • Middle click – Opens page in new tab
  • Ctrl + Mouse wheel – Increase/decrease font size
  • Middle click on tab – Closes a tab

Customizing hidden setting on Firefox
about:config – Type this in the address bar. It loads a page with hidden setting for Firefox

Another helpful feature is “Undo Close Tab“. Right-click on the tab and select the option “Undo close tab“. The previously closed tab will open.

Here is a list with Firefox plugins I use in web development.

Wp to Twitter and Google Analyticator plugins for WordPress issues

WordPress plugins WP to Twitter and Google Analyticator works with PHP OAuth extension. Twitter has removed basic authentication since the middle of 2010. So when you try to authenticate and connect to Twitter from the plugin settings page the connection will not be successful.

One of the steps making theese plugins to work is to enable your domain https://www.google.com/accounts/ManageDomains. For WP to Twitter follow the steps in the support forum at http://forums.ronaldheft.com/viewtopic.php?f=5&t=851. The dashboard will only work if you have PHP OAuth extension on your server.

If you own the server you can check installed extensions in your php.ini file, but if you are on a shared hosting you have to run phpinfo() in order to get information about installed extensions. Information about OAuth can be found in header of the list of phpinfo().

If you can’t install OAuth you will not be able to use WP to Twitter plugin. However Google Analyticator will work, except the part with the graphic on the dashboard.

A good idea is to sign in and follow the Twitter API for updates.