Modify Jquery Typing disable enter key / some key from start event

I have chat applications based on NodeJS that using Jquery-typing for detecting user activity. This plugin is great, but i facing some problem with enter keys.

I make some script if user press “ENTER”, it will send message. But seems Jquery-typing detect “ENTER” key as start typing activity. It will make my chat application give stop typing notification into another users which message already send. I want to disable some keys in Jquery Typing.

So, i fork from original github and add-ed some additional feature called “keyClear”. Here are some implementation. “ENTER” keyCode is 13. So, i add it into keyclear options :

$('#text-input').typing({
start: function (event, $elem) {
if(checkVariable(now.name, now.roomId)){
now.statusOnWriting();
}
},
stop: function (event, $elem) {
if(checkVariable(now.name, now.roomId)){
now.statusOffWriting();
}
},
keyclear: 13,
delay: 1000
});

Now when people press “ENTER” it make not activity, not start or stop typing either.

You can clone it on : https://github.com/yodiaditya/jquery-typing.

How to remove upstream remote repository in Github

When you forking repository, you usually add stream to enable push your changes into origin master. Adding stream to remote repository by :


git remote add upstream git://github.com/octocat/Spoon-Knife.git

But how to remove upstream if we use wrong github repository. Adding again will throw error “fatal: remote upstream already exists”, for example like this:


fatal: 'git//github.com/narfdotpl/jquery-typing.git' does not appear to be a git repository

To solve this problem, edit .git/config and remove upstream :


[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:yodiaditya/jquery-typing.git
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "upstream"]
url = git://github.com/narfdotpl/jquery-typing.git
fetch = +refs/heads/*:refs/remotes/upstream/*

Into


[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:yodiaditya/jquery-typing.git
[branch "master"]
remote = origin
merge = refs/heads/master

Then you can add new upstream git agains. :)

Auto checking errors for Javascript in VIM using JavascriptLint

I have edited a lot of javascript files in VIM. Checking errors in a lot of javascripts line is such a pain till i found JavasriptLint + VIM Plugin. Let get started, i use Ubuntu Natty 11.04 on this installation.

Updated!
You can fork it on Github :
Davepacheco’s javascriptlint Github

1. Install JavascriptLint


cd ~/
wget -c http://www.javascriptlint.com/download/jsl-0.3.0-src.tar.gz
tar -xvvf jsl-0.3.0-src.tar.gz
cd ~/jsl-0.3.0/src/
make -f Makefile.ref
sudo ln -s ~/jsl-0.3.0/src/Linux_All_DBG.OBJ/jsl /usr/local/bin/jsl

2. Install JavascriptLint.vim

Download from http://www.vim.org/scripts/script.php?script_id=2578.

Or if youre using Vundle / Pathogen, then you can use this github :
http://github.com/joestelmach/javaScriptLint.vim.

Now, every you edit JS files, you will see error syntax checking windows in bottom of your VIM. Great tools!

Solving Snipmate vim error Snippet c) is already defined

Today i get these errors after forking my github :


Warning in snipMate.vim: Snippet c) is already defined. See :h multi_snip for help on snippets with multiple matches.
Warning in snipMate.vim: Snippet date is already defined. See :h multi_snip for help on snippets with multiple matches.
Warning in snipMate.vim: Snippet ddate is already defined. See :h multi_snip for help on snippets with multiple matches

Warning in snipMate.vim: Snippet while is already defined. See :h multi_snip for
help on snippets with multiple matches.
Warning in snipMate.vim: Snippet r is already defined. See :h multi_snip for hel
p on snippets with multiple matches.
Warning in snipMate.vim: Snippet w is already defined. See :h multi_snip for hel
p on snippets with multiple matches.
Warning in snipMate.vim: Snippet rw is already defined. See :h multi_snip for he
lp on snippets with multiple matches.
Warning in snipMate.vim: Snippet defs is already defined. See :h multi_snip for
help on snippets with multiple matches.
Warning in snipMate.vim: Snippet defmm is already defined. See :h multi_snip for
help on snippets with multiple matches.
Warning in snipMate.vim: Snippet am is al

What the heck with this snipMate problem? Until i remember something :D

here are the solution :

delete snippets folder in bundle/snipmate.vim. This error happen because you already have another snipmate snippets in bundle folder. Just delete the default snippets in Snipmate.vim and all problems gone!

Hot tips collection about using VIM

Today i try to learn VIM and found several trivial things that probably gain my effectivity about using VIM. Note that i use VIM for editing PHP, Python, Javascript, CSS and HTML. Also i create my own VIM like Netbeans ( Which it’s still my primary IDE for web development ) in http://github.com/yodiaditya/vim-netbeans. Here are hot tips :

How to indent visual blocks in VIM ?
After blocking using v, now press > for right indentation or < for indentation. Press . for repeat it's command if you think need to indent more. Fix indent width by put shiftwidth=2 or more in .vimrc.

For auto-indent, press ==

How to block one line in VIM ?
Using shift+v

How to paste with indentation included ?
After blocking code with v and y (for yanking / copy ), select your cursor to where the start aligning position. Then you can use ]p for paste text aligning indentation with surroundings

I will update this post as i found another tips.

How to solve tmp/cache/ is not writable [CORE/cake/libs/cache/file.php, line 267] app/tmp/cache/persistent/ is not writable [CORE/cake/libs/cache/ file.php, line 267]

Today i got this kind of error in my CakePHP 1.3. Here are the error code :


tmp/cache/ is not writable [CORE/cake/libs/cache/file.php, line 267] app/tmp/cache/persistent/ is not writable [CORE/cake/libs/cache/ file.php, line 267]

I tried to solve this by chmod and change permisssion recursive into app/tmp.


cd app/
chmod 777 -R tmp

Hey, after change permission, it’s still give me error. What happen here? After walking around and analyze the error, i found the problem. It’s because i use file caching built-in CakePHP. So, i better disable it’s by editing app/config/core.php :


if($_SERVER['SERVER_NAME'] == 'localhost') {
Configure::write('Cache.disable', true);
}else{
Configure::write('Cache.disable', false);
}

This fixed my CakePHP in localhost. Now, time to works again and swipe another errors :)

How to learn and customized VIM like Netbeans for PHP + Python

Today i start learning VIM which it takes me scracth my head overtime. Need a full 1 day to know that VIM actually is a powerfull text editor on the earth. Here are the reason why i and you should move into VIM rather using IDE editor :

1. VIM is widely used by many TOP developers around the world.
There so many great developer using VIM as default editor. Also, this editor became as standard in many insitution, big company and community. I heard that Googlers also using VIM with their custom configuration to editing and integrate with Google System.

2. VIM is text-editor that can be programmed.
For example, you need to edit Phyton files and press Shift+E to execute this file immediatelly. Which you can programmed Shift+E equal with command “/usr/bin/python your-script.py”. In another tabs, you need to do same thing, which Shift+e equal with “/usr/bin/php your-script.php”. You need text-editor that doing different service as based on the file extension.

Or maybe, you want to press F4 to commit this file into Github repo. It’s can be programmed as long as what you wanted to. You can make custom text editor based on your standard programming.

3. There only one editor that can match with VIM, called Netbeans. And yes, i still using Netbeans for editing some projects. And it’s still okay dude.

4. VIM is kind of investment. Just like you are PHP programmer that look Python is great language in the future. We need to invest them to be able catch up need in the future.

Being Technical.

When you start to learning VIM, i suggest to give one full day and use is as many time you have. Practice is one key to gain your skill on everything.

I use Ubuntu 11.04 and Macbook Pro here. So, what i share here is 100% working on Ubuntu.

I assume you’re newbies like me before knowing VIM. So, there are 2 things that you should know about VIM, that called .vimrc & .vim. This are located on your home directory ( ~/ ).

.vimrc is contain VIM configuration and .vim contain many plugins, syntax, documentation and many additional things that loaded by .vimrc when you opening VIM. So, start to search about .vimrc and .vim on Google.

Basic things to use VIM ( quotes not included ):

1. To editing file, press “i” or “Insert”
2. To back into command mode, press “CTRL+C” and press “:” for start execute command
3. To save, press “:w”
4. To save and quit, press “:wq”
5. When you see it’s meaning Backslash Button
6. Use “CTRL+F” for PAGE DOWN and “CTRL+B” for PAGE UP
7. In command mode, you can use UP and DOWN arrow to use same command before. Like in shell.

How to copy paste in VIM ?

1. Press “v” and using your arrow keys to block some text
2. Press “d” to cut or “y” for copy. Then press “p” to paste

How to search in VIM ?
1. Press “:/” and type what do you want to search. ex: :/hello
2. To next search, press “n”

How to execute this script on VIM ?
Use “:! %”. Example, execute this python script by “:!python %”

That’s for basic. Now, i am approaching how to make VIM like my Netbeans editor which it have autocomplete, file tree, tag / function list, auto indentation and many else!

Actually, i’m going crazy here. So, i start build my VIM. I suggest you to open vimrc and follow link and documentation there. It’s will helping you to customize VIM as what you want.
Here are some of my steps ( All explanation already in vimrc ) :

1. Editing .vimrc and make basic things.


syntax on " syntax highlighing
filetype on " try to detect filetypes
filetype plugin indent on " enable loading indent file for filetype
set number " Display line numbers
set numberwidth=1 " using only 1 column (and 1 space) while possible
set background=dark " We are using dark background in vim
set title " show title in console title bar
set wildmenu " Menu completion in command mode on
set wildmode=full " cycles between all matching choices.

2. NerdTree ( https://github.com/scrooloose/nerdtree )
After clone it, copy all files into ~/.vim by
cp -dR nerdtree/* ~/.vim/

To start using NerdTree, type :NERDTree in Vim. To move between windows, press “CTRL+w+w”

3. Pathogen
Why we should you Pathogen? Here is some cases. You have downloaded many plugins into VIM folder. In one day, some of your plugins updated. Then, what you should do? Deleting old files ? What happen if you delete wrong files?. Using Pathogen will ease our development which make each plugin run independently and updated from github.

Thank to https://github.com/tpope.

To install Pathogen :

mkdir -p ~/.vim/autoload ~/.vim/bundle
curl https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim \
> ~/.vim/autoload/pathogen.vim

3. Snipmate
Is TextMate on VIM. I use Snipmate from Tpope as maintainer


% cd ~/.vim
% mkdir bundle
% cd bundle
% git clone git://github.com/garbas/vim-snipmate.git

# Install dependencies:
% git clone https://github.com/tomtom/tlib_vim.git
% git clone https://github.com/MarcWeber/vim-addon-mw-utils.git
% git clone https://github.com/honza/snipmate-snippets.git

4. Installing Python Debugger like Pylint, Pyflakes and Pep8


sudo pip install pylint
sudo pip install pyflakes
sudo pip install pep8

For TLDR;
Go to https://github.com/yodiaditya/vim-netbeans and clone it!

Fixing Memcached Problem in Ubuntu Natty

When restarting Memcached service, suddenly i got this kind of error :


Restarting memcached: perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
memcached.

After googling for a while, i got the solution is :

sudo apt-get install language-pack-en-base

Kudos to http://bookmarks.honewatson.com/2009/05/30/perl-warning-please-check-that-your-locale-settings-ubuntu/

Auto remember form input content while typing using JQUERY

When clients inserting data into form, suddenly their connection lost or accidentally refreshed the web page. And guess what? they facing new empty form again and feel tired to inserting same data again. We can reduce this by using JQUERY cookies which can remember what clients type into form. So, when they refreshed pages even close and open it again, they have previous input data.

To do this, you must download Jquery & Jquery Cookies.



Now if you have input form with name attribute is “website” :

Then, now it’s auto remembering.

Kudos to : http://www.komodomedia.com/blog/2008/07/using-jquery-to-save-form-details/