Tuesday, 31 July 2012

JQUERY toggle between two classes

It's so simple... so elegant:

$(".portlet-header").toggleClass("ui-icon-plus").toggleClass("ui-icon-minus");

What is so hard to understand you toggle both the classes and let Jquery figure out the rest. 
CREDIT TO:
http://stackoverflow.com/questions/1644545/toggle-between-two-classes-in-jquery#7886070

Friday, 27 July 2012

want to learn about ruby migrations

http://guides.rubyonrails.org/migrations.html

ruby RAILS_ENV=test on rake db:migrate

CREDITS TO:

https://github.com/pauldix/service-oriented-design-with-ruby/issues/1

Hi Paul,
I'm reading and working through you book page by page, bumping into issues mostly related to the fact that I'm am trying to learn Ruby and SOD at the same time. I have run into this issue on page 19 of the book where it says that to migrate the test database, one needs to run the command:
    rake db:migrate RAILS_ENV=test
Upon repeatedly running this command and searching why it didn't run (to no avail), I turned to the rakefile and there I found that the env variable is set to either SINATRA_ENV or development (line 11?):
   env = ENV["SINATRA_ENV"] || "development"
Then when running the rake command again as below, my migration ran fine:
    rake db:migrate SINATRA_ENV=test
As I said, I am learning as I go, so this may not be the optimal solution.
I would love to hear if I went up the right track on this one.
Rgdz,
Oscar

Thursday, 26 July 2012

use gitflow when you are working on your projects

CREDITS TO:

http://nvie.com/posts/a-successful-git-branching-model/

Tuesday, 17 July 2012

problems with rspec stub and mocks... not anymore

Found the same couple of links popping up every time i was looking for rspec helps and stub/mock help. Hope you can use them as well

https://github.com/rspec/rspec-expectations

http://rubydoc.info/gems/rspec-mocks/frames

Check the bottom of the last link you can find a few more which can help you if you need more information.

EDIT:

To be fair all of the links and much more you can find them here:

http://stackoverflow.com/questions/201385/getting-started-with-rspec-looking-for-tutorials

Thank you stachoverflow :)

Thursday, 12 July 2012

Local repository stop working in Ubuntu

So for no reason what so ever my repository stop working. Or kind of stooped working since i could receive that i had updated but it keep showing me the message that the repository wasn't from trusted sources. 

So this is the solution i found.
1) Open Update Center.
2) Click Settings
3) Tab Ubuntu Software
4) Download From - Others
5) Select Best Server

And it should be working.

Wednesday, 11 July 2012

postgresql first steps... must know


CREDITS TO:



Warning: this post may contain profanity. I'm a programmer, I don't like dealing with sysadmin type things.
love PostgreSQL, the baddest-ass relational database on the planet. For real.
Ugh, but it's super confusing to set up if you are used to just setting up MySQL users with passwords and then connecting to the database with said username and password you set up. Postgres has some odd defaults that make this less than straight forward.
Install PostgreSQL server on your machine:
sudo apt-get install postgresql-9.1
Create a database user, enter "somepass" or whatever you want for the password when it asks (answer no the create roles question):
sudo -u postgres createuser -D -P someuser
Create a database owned by that database user you just created:
sudo -u postgres createdb -O someuser somedb
For "fun" let's try to connect to the database with the "psql" interactive postgres shell:
psql -d somedb -U someuser -W
And the payoff:
Password for user someuser: 
psql: FATAL:  Peer authentication failed for user "someuser"
Oops. Your password didn't work, asshole.
Instead, you need to open up this file/etc/postgresql/9.1/main/pg_hba.conf in a text editor (with root privileges, of course) and change this line:
local   all             all                                     peer
to this:
local   all             all                                     md5
Now, restart the postgres server:
sudo service postgresql restart
Now you can connect:
psql -d somedb -U someuser -W
And this is what you get:
Password for user someuser: 
psql (9.1.1)
Type "help" for help.

somedb=>
You're welcome.

Tuesday, 10 July 2012

Finally autocomplete in Emacs

CREDITS TO:

http://www.quora.com/What-are-the-most-useful-shortcuts-in-Emacs

Most useful shortcuts:

C-_ undo (to redo after undoing, I press space and then C-_ again)
C-g cancel, essential if you make a mistake entering another shortcut
C-s search (incremental), great for navigating around a buffer
M-%  replace, see Jeff Hammerbacher's answer to How can you perform search and replace in Emacs?
M-g g  go-to line
M-; comment, see Adam Hupp's answer to How can I comment out an entire block of text in Emacs?
M-/ autocompletion, from Edmond Lau

You type a prefix, invoke the function, and it'll auto-complete with the strings that are found in other open buffers in your emacs process.  It's not exactly auto-completing from the entire codebase but is fast and works well.  Invoking the function multiple times cycles through possible completions.

Useful Basic Commands:

C-x C-s save file
C-x C-c  exit
C-x C-f open file
C-k kill (cut) from current position to end of line (use this to cut & paste lines)
C-<spacebar> set mark, select region
C-a / C-e beginning/end of line
M-< / M->  beginning/end of buffer
C-x C-x  move back to mark
C-w / M-w wipe (cut/copy)
C-y yank (paste)
C-x b switch buffer (C-x C-b lists buffers)
M-<right/left arrows>  move cursor from one word to the previous/next

Useful Advanced Commands:

M-x lets you type in a command (e.g. M-x revert-buffer reloads the buffer from disk). Some examples:

M-x shell: opens a shell in emacs (but auto-complete doesn't seem to work)
M-x grep: runs grep within emacs
(M-x compile and M-x gdb are nice, too)

Typing C-u before another command lets you supply an argument

M-: lets you evaluate lisp expressions (e.g. rebind a key on the fly)

You can also define new shortcuts by binding keys to commands.  For example:

1
2
3
4
5
6
(defun prev-window ()
  (interactive)
  (other-window -1))

(global-set-key "\033[5D" 'prev-window)
(global-set-key "\033[5C" 'other-window)


makes ctrl-<left arrow> and ctrl-<right arrow> move between windows.

Friday, 6 July 2012

another good link

Here is another good link on ruby development i found

http://www.ruby-doc.org/core-1.9.3/

Wednesday, 4 July 2012

ruby operators

since i always forget about them here is a useful link:

http://www.tutorialspoint.com/ruby/ruby_operators.htm

Tuesday, 3 July 2012

ruby documentation documents

Recently i have to do a lot of specs this bellow link is simple invaluable for me now.

http://rubydoc.info/gems