Author: Andres Paglayan

~ 18/02/11

ruby-1.8.7-p330 :040 > t = Time.now
=> Fri Feb 18 15:20:09 -0700 2011
ruby-1.8.7-p330 :041 > ((‘a’..’z').to_a + (‘A’..’Z').to_a).each{|l| puts “strftime with #{l} gives: ” + t.strftime(“%#{l}”) }
strftime with a gives: Fri
strftime with b gives: Feb
strftime with c gives: Fri Feb 18 15:20:09 2011
strftime with d gives: 18
strftime with e gives: 18
strftime with f gives: %f
strftime with g gives: 11
strftime with h gives: Feb
strftime with i gives: %i
strftime with j gives: 049
strftime with k gives: 15
strftime with l gives: 3
strftime with m gives: 02
strftime with n gives:
strftime with o gives: %o
strftime with p gives: PM
strftime with q gives: %q
strftime with r gives: 03:20:09 PM
strftime with s gives: 1298067609
strftime with t gives:
strftime with u gives: 5
strftime with v gives: %v
strftime with w gives: 5
strftime with x gives: 02/18/11
strftime with y gives: 11
strftime with z gives: -0700
strftime with A gives: Friday
strftime with B gives: February
strftime with C gives: 20
strftime with D gives: 02/18/11
strftime with E gives: %E
strftime with F gives: 2011-02-18
strftime with G gives: 2011
strftime with H gives: 15
strftime with I gives: 03
strftime with J gives: %J
strftime with K gives: %K
strftime with L gives: %L
strftime with M gives: 20
strftime with N gives: %N
strftime with O gives: %O
strftime with P gives: pm
strftime with Q gives: %Q
strftime with R gives: 15:20
strftime with S gives: 09
strftime with T gives: 15:20:09
strftime with U gives: 07
strftime with V gives: 07
strftime with W gives: 07
strftime with X gives: 15:20:09
strftime with Y gives: 2011
strftime with Z gives: MST

Post tags:

Author: Andres Paglayan

~ 10/08/10

You don’t need a week to switch to vim, one hour can do.

Here’s a quicky for Vim and Rails setup.

1./ Install vim (duh)

2./ Install the rails plugin
>cd ~/Downloads
>git clone git://github.com/tpope/vim-rails.git
>cd vim-rails
>rake install

2./ Install the NERDTree plugin
>cd ~/Downloads (if you weren’t there already)
>git clone http://github.com/scrooloose/nerdtree.git
>cd nerdtree
>rake install

(you can delete the original downloads afterward, as the rake task installs the right files in the right place)

3./ edit your ~/.vimrc
> vim ~/.vimrc
a basic one will look like this:

set nocompatible
set autoindent
set smartindent
set showmatch
set ruler
set incsearch
set number
set expandtab
set softtabstop=2
set shiftwidth=2
set tabstop=8
set ignorecase
set smartcase
syntax on
filetype plugin indent on
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p

(the two last ones will launch NERDTree by default)

write it with :w

4./ activate the Rails plugin Help
inside vim in command mode run ->  :helptags ~/.vim/doc

5./ quit vim and relaunch it.

6./ read the Rails Help
:help rails

7./ Make your own cheat-card to learn basic navigation, v editing commands,  tab commands, buffer commands and windows commands.

For starters,  you’ll need to know what the following are for:

ESC (back to command mode)
i (insert)
a (append)
o (insert in line below)
A (at the end of line)
u (undo)
h (left)
k (up)
l (right)
j (down)
* (next wd)
# (previous wd)
G (end of file)
(number)G (go to line)
dd (del line)
(number)dd
v (x p | y p) visual cut/yank paste
/search
/
:%s/search/replace/g
:s/search/repalce/g

:g/delete/d

(tabs are awasome)
:tabe _file_ (edit file in new tab)
:tabm (number)
gt (move to next tab)
gT
(number)gt
gf (edit file under cursor on new tab)

Window controll (all bellow after with Ctrl-w)
s (split)
v (vert split)
n (new)
p (previous)
o (only)
q (quit)
b (move to bottom)
r (rotate)
x (swap)
=make=
+ (bigger)
- (smaller)
_ (maximize)
> (wider)
:sfind
———
:buffers (list buffers)
:b (number) (go to buffer number)

Memorize that previous list and you are ready to go.
And don’t worry, the great thing about vim is that you’ll never reach the “expert” level, not even after years of use and continuous  learning.

Post tags:

Author: admin

~ 03/12/09

grep will do a first find and return the matched file names
xargs will pass each file name with its path to sed
and obviously sed will edit inline and replace the contents

grep -rl “oldword” ./  | xargs sed -i  ‘s/oldword/newword/’

Post tags:

Author: admin

~ 28/11/09

how to install ubuntu server on raid 10

Provided you have 4 hard drives,

boot on any live disk
open a console

Partition your four disk all the same

Repeat these steps for your four disks,
using the appropriate devices: e.g. sda, sdb, sdc, sdd,

fdisk /dev/sda
n p 1 (and pick enough space for boot)
t 1 fd (makes the partition Linux auto array)
a 1 (makes the partition bootable)
n p 2 (and pick most of space, leave enough for swap on the next one)
t 2 fd
n p 3 (and pick the rest of space, this one will be swap)
t 3 fd
w (writes partition table and exits)
(repeat for sdb, sdc, sdd)

so now you’ll have /dev/sda1 /dev/sda2 and /dev/sda3
and so on for sdb sdc and sdd after doing partitioning for all the four disks,

now create the raid devices,

mdadm –create /dev/md0 –level=1 –raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
(these are all the bootable ones, will be set for /boot later, note that is array 1 )

mdadm –create /dev/md1 –level=10 –raid-devices=4 /dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2
(these are for /, will be set later)

mdadm –create /dev/md2 –level=10 –raid-devices=4 /dev/sda3 /dev/sdb3 /dev/sdc3 /dev/sdd3
(these are the swap)

Note that you create a 5 with one spare as well,

# mdadm –create /dev/md1 –raid-devices=3 –spare-devices=1 –level=5 /dev/sd[a-c]1

And so on

now format the array devices
just format them,
do not ever think on putting a partition on top of an md device

mkfs.ext3 /dev/md0
mkfs.ext3 /dev/md1
mkswap /dev/md2

after that,
reboot using your install drive,
when going to partition, select manual,
it won’t see the devices,
click on manage array options and then on finish,
this is so the installer loads the array tools,
it will go back to partition dialog and will show the three devices devices now,

pick the first one, tell to use ext3 and mountpoint /boot
pick the second one, tell to use ext3 and mountpoint /
pick the third one, use as swap

note that you don’t need to format, because you already did.
and if you try formatting it will confuse the installer.

ok with the warnings and it will install like nothing happened
will boot from /dev/md0 which is an array 1 without problems,
and will use the rest of the system as array10

Post tags:

Author: admin

~ 23/11/09

allow screen to support sharing
#>sudo chmod u+s /usr/bin/screen
#>sudo chmod 755 /var/run/screen

set a guest user account in the host machine

screen -S pair
Ctrl-a :multiuser on
Ctrl-a :acladd guest
vim

the remote user logs in as guest

ssh guest@your_accessible_ip
screen -x local_user/pair  (where local_user is your local account running screen)

Post tags:

Author: admin

It’s mainly due to uncle Bob Martin’s twit on how lame we as a society become in terms of not speaking our minds due to unreasonable extreme politeness that I decided  stop procrastinating and write.

It is said we shouldn’t be talking or writing about politics, religion, abortion, drug legalization, gender changing, or other society sensible issue  if you want to keep friends.

When it comes to opinionated Ruby programming code bloging is more complicated. My friends and I can become quite judgmental and hurt mutual feelings, but friends are mine to keep as I love them and they probably do back.

I stand as a democrat but when it comes to guns, abortion and economy I divert from some of the core values.

In other venue of things I am not a mac nor a PC, but a Linux, with Ubuntu as my preferred distro. And btw, a vim rather than an emacs.
That said, Write on!

Keep tuned for more coming soon.

Post tags:

Author: admin

~ 04/07/08

A great linux device, and the envy of those brickable iphones from the fruit brand.

http://us.direct.openmoko.com

Post tags: