Wednesday, 22 May 2013

shaky live search - additional plugin for live search, delay keyup event until user finished typing!

So.. we had this issue with live search, it could be a bit shaky in producing result when user actually put a long keyword. Came across this lightweight plugin called 'typing' :

http://narf.pl/jquery-typing/

or if you prefer the github link :

https://github.com/narfdotpl/jquery-typing

using it is pretty simple too :

$(':text').typing({
    start: function (event, $elem) {
        $elem.css('background', '#fa0');
    },
    stop: function (event, $elem) {
        $elem.css('background', '#f00');
    },
    delay: 400
});

It will wait until the user actually not pressing any other key and then fire the keyup. We combine it with our liveSearch and it works very well!

Monday, 20 May 2013

homebrew redis on mountain lion

Don't forget to start with :
brew doctor
brew update
brew info redis
and you can start with :
brew install redis
and will be replied with :
==> Downloading http://redis.googlecode.com/files/redis-2.6.13.tar.gz
######################################################################## 100.0%
==> make -C /private/tmp/redis-P7Wt/redis-2.6.13/src CC=cc
==> Caveats
To have launchd start redis at login:
    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
    redis-server /usr/local/etc/redis.conf
==> Summary
🍺  /usr/local/Cellar/redis/2.6.13: 9 files, 752K, built in 5 seconds
what's left to do is run these lines below :
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
to unload from launch control :
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
to open redis client :
redis-cli

Wednesday, 15 May 2013

installing postgresql with brew on mountain lion (10.8.2)

start with :
brew update
brew install postgres
add to ~/.bash_profile :
export PATH=/usr/local/bin:$PATH
create your first Db :
initdb /usr/local/var/postgres -E utf8
if you want it to launch at login :
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
I'm using postgresql to wor with Rails, I found gem lunchy quite handy, you might want to try install it for easy start/stop the postgres server. and for now :
psql postgres
you'll have something like this, then, create a new user, I am creating a superuser for now.
postgres# create user root with password new_username;
postgres# alter user new_username with superuser;
postgres# \q

Monday, 13 May 2013

including __git_ps1 in your osx bash

Just a little note, on modifying bash for osx (I'm running mountain lion - 10.8.2). To achieve something like this:
me@My-MacBook-Pro:~/Projects/project_name(master)$
add this on your ~/.bash_profile :
source /usr/share/git-core/git-completion.bash
export PS1='\u@\h:\w$(__git_ps1 "(%s)")$ '

Friday, 10 May 2013

Too many open files - getcwd

I'm running parallel:spec on my mac machine and having 493 failing spec with this message :
Too many open files - getcwd
What you want to do next is:
ulimit -n
Default is 256, easy way out is:
ulimit -n 1024
That should do it for the time being, unless you want it permanently.