script/console is a very useful tool when building your RoR application.
And one of my favorite features is the ability to autocomplete the method name (just by pressing tab).
This gives me a kind of Ruby on Rails IDE taste, since when I'm at Windows I (happily) use Notepad++ (which has a ruby plugin) to code.
Friday, 8 February 2008
Monday, 4 February 2008
multiples screens with SSH ("screen")
When remotely accessing a host with SSH, you may (frequently) want to run a shell command, track the output, leave a console free for more commands input, and leave everything running even after you close the remote connection.
When working locally, you can count with the multiple screens (ctr+alt+[0..9]).
Remotely, you can simulate that same behavior with the command "screen".
> screen -h
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]
Options:
-a Force all capabilities into each window's termcap.
-A -[r|R] Adapt all windows to the new display width & height.
-c file Read configuration file instead of '.screenrc'.
-d (-r) Detach the elsewhere running screen (and reattach here).
-dmS name Start as daemon: Screen session in detached mode.
-D (-r) Detach and logout remote (and reattach here).
-D -RR Do whatever is needed to get a screen session.
-e xy Change command characters.
-f Flow control on, -fn = off, -fa = auto.
-h lines Set the size of the scrollback history buffer.
-i Interrupt output sooner when flow control is on.
-l Login mode on (update /var/run/utmp), -ln = off.
-list or -ls. Do nothing, just list our SockDir.
-L Turn on output logging.
-m ignore $STY variable, do create a new screen session.
-O Choose optimal output rather than exact vt100 emulation.
-p window Preselect the named window if it exists.
-q Quiet startup. Exits with non-zero return code if unsuccessful.
-r Reattach to a detached screen process.
-R Reattach if possible, otherwise start a new session.
-s shell Shell to execute rather than $SHELL.
-S sockname Name this session.sockname instead of ...
-t title Set title. (window's name).
-T term Use term as $TERM for windows, rather than "screen".
-U Tell screen to use UTF-8 encoding.
-v Print "Screen version 4.00.02 (FAU) 5-Dec-03".
-wipe Do nothing, just clean up SockDir.
-x Attach to a not detached screen. (Multi display mode).
-X Execute as a screen command in the specified session.
When working locally, you can count with the multiple screens (ctr+alt+[0..9]).
Remotely, you can simulate that same behavior with the command "screen".
> screen -h
Use: screen [-opts] [cmd [args]]
or: screen -r [host.tty]
Options:
-a Force all capabilities into each window's termcap.
-A -[r|R] Adapt all windows to the new display width & height.
-c file Read configuration file instead of '.screenrc'.
-d (-r) Detach the elsewhere running screen (and reattach here).
-dmS name Start as daemon: Screen session in detached mode.
-D (-r) Detach and logout remote (and reattach here).
-D -RR Do whatever is needed to get a screen session.
-e xy Change command characters.
-f Flow control on, -fn = off, -fa = auto.
-h lines Set the size of the scrollback history buffer.
-i Interrupt output sooner when flow control is on.
-l Login mode on (update /var/run/utmp), -ln = off.
-list or -ls. Do nothing, just list our SockDir.
-L Turn on output logging.
-m ignore $STY variable, do create a new screen session.
-O Choose optimal output rather than exact vt100 emulation.
-p window Preselect the named window if it exists.
-q Quiet startup. Exits with non-zero return code if unsuccessful.
-r Reattach to a detached screen process.
-R Reattach if possible, otherwise start a new session.
-s shell Shell to execute rather than $SHELL.
-S sockname Name this session
-t title Set title. (window's name).
-T term Use term as $TERM for windows, rather than "screen".
-U Tell screen to use UTF-8 encoding.
-v Print "Screen version 4.00.02 (FAU) 5-Dec-03".
-wipe Do nothing, just clean up SockDir.
-x Attach to a not detached screen. (Multi display mode).
-X Execute
Thursday, 31 January 2008
ActiveRecord error : duplicate key violates unique constraint
I'm currently working (and still exploring) Ruby on Rails for a VoIP services management web portal project.
I frequently stumble upon some doubts about the correct RoR way of doing things - I admit, I tend to do it java style =( - but this one was really driving me crazy...
When creating a new record for a table named "groups", the ActiveRecord was hitting me with the following exception:
«ActiveRecord::StatementInvalid: RuntimeError: ERROR C23505
Mduplicate key violates unique constraint "pk_groups"»
after some "googlening", I manage to solve this. Apparently, the problem was with the expected sequence, from RoR, for that table "groups".
Since the postgresql was returning the correct next sequence number:
# select nextval('groups_group_id_seq');
nextval
---------
17
(1 row)
it was only a matter of resetting the ActiveRecord sequence (on script/console)
>> ActiveRecord::Base.connection.reset_pk_sequence!('groups')
=> "17"
I frequently stumble upon some doubts about the correct RoR way of doing things - I admit, I tend to do it java style =( - but this one was really driving me crazy...
When creating a new record for a table named "groups", the ActiveRecord was hitting me with the following exception:
«ActiveRecord::StatementInvalid: RuntimeError: ERROR C23505
Mduplicate key violates unique constraint "pk_groups"»
after some "googlening", I manage to solve this. Apparently, the problem was with the expected sequence, from RoR, for that table "groups".
Since the postgresql was returning the correct next sequence number:
# select nextval('groups_group_id_seq');
nextval
---------
17
(1 row)
it was only a matter of resetting the ActiveRecord sequence (on script/console)
>> ActiveRecord::Base.connection.reset_pk_sequence!('groups')
=> "17"
Monday, 19 November 2007
Linux: recover from failure
When you need to recover from a Linux OS failure.
Locally:
10-boot-time-parameters-you-should-know-about-the-linux-kernel
reboot-or-halt-linux-system-in-emergency
Remotely:
IP Tables network magic SysRq function
Locally:
10-boot-time-parameters-you-should-know-about-the-linux-kernel
reboot-or-halt-linux-system-in-emergency
Remotely:
IP Tables network magic SysRq function
Friday, 16 November 2007
IMS-Communicator and IPSec SAs
I've spent the last couple of days trying to implement the establishment of the IPSec Security Associations between the P-CSCF an the IMS-Communicator during the initial registration of the SIP UA.
The IMS-Communicator is a SIP softphone, based on the old version of the SIP-Communicator, in which I added some logic to support the IMS procedures for the UE.
Most of the work was done during my last year's academic project (in 2006) entitled "Protocols and Services in Convergent Networks", and it is used since then by people at PT-Inovação and IT, and some other folks around the globe, specially to test against the OpenIMSCore ...
But like I said in the beginning, I'm trying to support IPsec (for now only on Linux, using the ipsec-tools and setkey) so the AKAv1-MD5 authentication is finally fully implemented.
After I've done this, one of my next objectives regarding IMS-Communicator is to port all this IMS logic to the new and shinning SIP-Communicator.
Unfortunately, must probably I'll have to do it on my (little) spare time :-/

Update 1: Franz Edler manages a VM image for a kind of IMS-in-a-bottle, based on OpenIMSCore and IMS-Communicator.
The IMS-Communicator is a SIP softphone, based on the old version of the SIP-Communicator, in which I added some logic to support the IMS procedures for the UE.
Most of the work was done during my last year's academic project (in 2006) entitled "Protocols and Services in Convergent Networks", and it is used since then by people at PT-Inovação and IT, and some other folks around the globe, specially to test against the OpenIMSCore ...
But like I said in the beginning, I'm trying to support IPsec (for now only on Linux, using the ipsec-tools and setkey) so the AKAv1-MD5 authentication is finally fully implemented.
After I've done this, one of my next objectives regarding IMS-Communicator is to port all this IMS logic to the new and shinning SIP-Communicator.
Unfortunately, must probably I'll have to do it on my (little) spare time :-/

Update 1: Franz Edler manages a VM image for a kind of IMS-in-a-bottle, based on OpenIMSCore and IMS-Communicator.
Friday, 9 November 2007
linux: find string
> grep -r "string" "path"
this will list the lines where the "string" occurs in "path" (folders, files and lines inside files)
this will list the lines where the "string" occurs in "path" (folders, files and lines inside files)
Friday, 26 October 2007
capture packets on linux
capture packets : tethereal tool
ex:
> tethereal -R tcp.port==8185 -i any -w output.cap
params:
-R «Wireshark filter string»
-i «interface anme»
-w «output file»
ex:
> tethereal -R tcp.port==8185 -i any -w output.cap
params:
-R «Wireshark filter string»
-i «interface anme»
-w «output file»
Friday, 31 August 2007
Creative Zen Vision:M + Last.fm
When you use Winamp to play music files hosted on your PMP (in my case, Creative Zen Vision:M), it is treated as a streaming source.
This work-around allows you to submit to your Last.fm account the tracks info received by a streaming source (like internet radio, I suppose, but didn't test it yet =)
- winamp 5.33+
- last.fm 1.1.10 (audioscrobbler.wa.1.1.10.exe)
- windows regedit:
HKEY_CURRENT_USER\Software\Audioscrobbler\Winamp Plugin
allowhttp = 1
This work-around allows you to submit to your Last.fm account the tracks info received by a streaming source (like internet radio, I suppose, but didn't test it yet =)
- winamp 5.33+
- last.fm 1.1.10 (audioscrobbler.wa.1.1.10.exe)
- windows regedit:
HKEY_CURRENT_USER\Software\Audioscrobbler\Winamp Plugin
allowhttp = 1
Tuesday, 28 August 2007
saudações
Why a blog?
Well, I need something where to take notes of those bits and bytes of knowledge that I learn every day in a way that I could easily aggregate and access them.
A blog looks to be a good idea, let me give a try :)
But why in English? I guess it could be easier in Portuguese... I'll use both :P
Well, I need something where to take notes of those bits and bytes of knowledge that I learn every day in a way that I could easily aggregate and access them.
A blog looks to be a good idea, let me give a try :)
But why in English? I guess it could be easier in Portuguese... I'll use both :P
Subscribe to:
Posts (Atom)