Saturday, February 23, 2013

SSHFS - Mount remote directory through gateway machine

  1. Expose target target server ssh port with ssh local port forwarding
    $ ssh -C -N -L localhost:local_port:target:target_ssh_port gateway_user@gateway
  2. Mount with sshfs through the port just exposed
    $ sshfs target_user@localhost:/target_directory /mount_point -o port=local_port
$ ssh -C -N -L localhost:22222:tap-machine:22
$ sshfs tap@localhost:~/work /mnt/work -o port=22222

Thursday, February 21, 2013

Execute one line command on IRB or Rails's console through Unix shell

Basic Unix approach - echo and pipe:
$ echo "<command>" | irb
For example,
$ echo "1 + 1" | irb
1 + 1
You can change irb to rails console to execute that command in the Rails environment.

Thursday, February 7, 2013

PostgreSQL - export/import schema only


Use -s to specify schema only
pg_dump <src_database_name> -s > schema.sql
(Optional) Use -t to specify table. For more than 1 table just add more -t.
 pg_dump <src_database_name> -s -t <table1_name> -t <table2_name> > schema.sql

psql <dest_database_name> -f schema.sql


Allow other people to publish gem to RubyGems

To do that, you need to add them as an owner of that gem with gem owner command.

This is an example
gem owner gem_name -a
Credit: How to add more 'owners' to a gem in RubyGem

Config number of file descriptors on Linux

Check file descriptor limit for a process. Vary depending on owner of the process $ cat /proc/{process-id}/limits Check current number of...