svn add all files except ignored files, svn del all missing files at once

To schedule all files and directories in your working copy for addition to the repository recursively, you can do it like below.

$ svn add * --force

Because svn add * can't add files which are not under version control yet in directories which are under version control, --force is needed. But in this case ignored files and directories in current directory are also added.
It also attempts to add files under version control, so many warnings show. It's ugly.

At last I found out there is no good way as long as I am using svn only.

To add all files except ignored files and delete all missing files at once, you can create an alias which filters output of svn status using grep and replaces it using sed like below.


alias svndel="svn st | grep '^!' | sed -e 's/\![ ]*/svn del /g' | sh"
alias svnadd="svn st | grep '^?' | sed -e 's/\?[ ]*/svn add /g' | sh"

It's very convenient!

Source: svn に登録されていないファイルをまとめて svn add:Goodpic
svn addがめんどくさいので | firegoby

How to input control characters


C-q <Control Character>

Example: Input escape character

C-q C-[

Shell, Vim

Ctrl+V <Control Character>

Example: Input escape character

Ctrl+V Ctrl+[

How to find a letter which should be pressed in combination with Control key?

<Control Character> in above explanation should be input in combination with Control key. The letter which should be input with Control key is a letter which is produced by setting 7th bit of the letter you want to input to 1, that is to say, by adding 0x40(64).
You can find it in `man ascii` etc.

Escape character is 0x1B(27).
Set 7th bit to 1, i.e. add 0x40(64) and you get 0x5B(91).
0x5B(91) is '['.
Therefore, to input escape character press Ctrl+[.

Line feed is 0x0A(10).
Set 7th bit to 1, i.e. add 0x40(64) and you get 0x4A(74).
0x4A(74) is 'J'.
Therefore, to input line feed press Ctrl+J.

エスケープ文字の入力方法 - nelnalog.note

Adjust timing of fsck using tune2fs

I rebooted my server but fsck started forcibly on boot and it took long time until the system started.
To show or adjust fsck timing on ext2/ext3/ext4 filesystem, you can use tune2fs.


# tune2fs -l /dev/sda1
Mount count:              7
Maximum mount count:      27
Last checked:             Fri Oct 21 03:41:32 2011
Check interval:           15552000 (6 months)
Next check after:         Wed Apr 18 03:41:32 2012

Stop forcible fsck

# tune2fs -c 0 -i 0 /dev/sda1 
tune2fs 1.39 (29-May-2006)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds


# tune2fs -l /dev/sda1
Mount count:              7
Maximum mount count:      -1
Last checked:             Fri Oct 21 03:41:32 2011
Check interval:           0 (<none>)

Source: tune2fs でfsckを制御 - ike-daiの日記

Prevent an error mail from being sent to the original sender in the case of forwarding failure on Postfix

On Postfix, in the case of forwarding by aliases or .forward, if the forwarding results in an error, the error mail is sent to the original sender. The most easy way to prevent this behavior is setting the alias to a redirection to sendmail command and changing envelope sender address using sendmail -f option like below.

| /usr/sbin/sendmail -f <envelope sender address> <recipient address to forward>



foo: foo, "| /usr/sbin/sendmail -f bar"

sendmail -f option sets the envelope sender address. This is the address where delivery problems are sent to ("bar" in the above example). This means that an error mail is not delivered to the original sender.

Be careful not to create infinite loop
In the above example, you should be careful that foo does not come to be the last recipient.

[postfix-jp:01469] Re: [Q] .forward で転送失敗のメールを送信者に知らせたくない

Find real type of typedef such as system data types

The easiest way is to use ptype with gdb.



#include <sys/types.h>
struct st { int i; char c; };
typedef int Array[10];
typedef struct st St;
int main(void)
  size_t s1;
  ssize_t s2;
  pid_t pid;
  Array arr;
  St st1;
  return 0;
$ gcc -Wall -g -o foo foo.c
$ gdb foo
(gdb) b main
(gdb) run
(gdb) ptype s1
type = long unsigned int
(gdb) ptype size_t
type = long unsigned int
(gdb) ptype s2
type = long int
(gdb) ptype ssize_t 
type = long int
(gdb) ptype pid
type = int
(gdb) ptype pid_t
type = int
(gdb) ptype arr
type = int [10]
(gdb) ptype Array 
type = int [10]
(gdb) ptype st1
type = struct st {
    int i;
    char c;
(gdb) ptype St
type = struct st {
    int i;
    char c;

Like the above example,

ptype <expression or type name>

shows real type.

If the type is an array, it also shows its size. If the type is a struct, it also shows the type of the members of the struct. It's convenient.

You can probably find the real type using gcc -E option and looking into preprecessor's output like below, but it's bothersome and possibly needs hard work.

$ gcc -E foo.c | grep ssize_t
typedef long int __ssize_t;
typedef __ssize_t ssize_t;
(ommitted below)

In the above example (x86_64 GNU/Linux), you can find that ssize_t is
__ssize_t => long int

$ gcc -E foo.c | grep ssize_t
typedef long __darwin_ssize_t;
typedef __darwin_ssize_t ssize_t;

In the above example (Mac OS X), you can find that ssize_t is
ssize_t => __darwin_ssize_t => long

Setting timeout for open-uri

require 'open-uri'
require 'resolv-replace'
require 'timeout'
  timeout(TIMEOUT) do
    open(url) do |f|
      # Do something
rescue TimeoutError => e
  # Do something on timeout
rescue => e
  # Do something on other errors
  • Interrupt with timeout is implemented by Ruby's Thread and it is not effective againt the process implemented by C, so DNS name resolution cannot be timeout. resolv-replace overwrites the methods to use Ruby's resolve library for DNS name resolution and enables timeout.
  • TimeoutError is not subclass of StandardError, so you have to catch TimeoutError explicitly.

Source: open-uriにtimeoutを設定する方法 | やむにやまれず