Keyboard Shortcuts using JQuery

Again it is very simple, looks you to feel like a magician if you are done. Just follow the steps :-

Download the shortcut.js file and include it in your layout or view file

http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js

<%= javascript_include_tag ‘shortcut’ %>

Then, add the following lines in the layout or view file where you want the keyboard shortcut to work on

shortcut.add(“e”,function() {
        short_modal2(‘/chats’);
 },{‘disable_in_input’ : true});

disable_in_input: true will make sure the shortcut key ‘e’ won’t work when the user is on input field like textbox and textarea. Default is false.

shortcut.add(“Shift+T”,function() {
short_modal1(‘/tasks/new’);
}
);

For adding a shortcut which is already a shortcut key on a browser like ‘/’, ‘Ctrl + F’, ‘Ctrl + S’ etc…,

shortcut.add(“/”,function() {
    $(‘.keyboard-shortcuts’).css(‘display’,’none’);
 },{‘type’: ‘keydown’, ‘propagate’:false, ‘target’:document
,’keycode’ : 191,’disable_in_input’ : true});

The following are the valid keys (you can also make the combination of any two keys from below) :-

  • All alpha/numeric keys – abc…xyz,01..89
  • Special Characters – Every special character on a standard keyboard can be accessed.
  • Special Keys…
    • Tab
    • Space
    • Return
    • Enter
    • Backspace
    • Scroll_lock
    • Caps_lock
    • Num_lock
    • Pause
    • Insert
    • Home
    • Delete
    • End
    • Page_up
    • Page_down
    • Left
    • Up
    • Right
    • Down
    • F1
    • F2
    • F3
    • F4
    • F5
    • F6
    • F7
    • F8
    • F9
    • F10
    • F11
    • F12

That’s it. Rock the world…

Advertisements

Database Backup (only particular tables) – MYSQL

How do you take a database backup for only particular tables, that too dynamically… Say i have tables like map1, map2, map3, ….. map1000. How do you write a query? Don’t worry it’s very simple :) Just follow the below command

mysql test_v382_development -u root -proot -e ‘show tables like “map%”‘ | grep -v Tables_in| xargs mysqldump  test_v382_development -u root -proot emp dept > backup.sql

The above command will take the database backup for the tables, map1, map2, … mapN dynamically and the tables ’emp’ and ‘dept’. Other tables in the database will not be included in the database backup.