Browsing CategoryOld Notes

crontab Format

[I could never remember this so I’m putting it here.]
These are the fields of a crontab file:


a b c d e /full/path/to/script

where

a = minute (0-59),
b = hour (0-23),
c = day of the month (1-31),
d = month of the year (1-12),
e = day of the week (0-6 with 0=Sunday).

* = every min, hour, day, etc.
*/10 = every 10 min, hour, day, etc.

Read A Text File

This will open a text file and read it line by line. As it is, it will just print each line to the screen, so very much like the unix ‘cat’ command, but could very well do anything on the line just read by replacing the cout statement.


#include <fstream>
#include <iostream>
#include <string>

void main() {
    string s;
    ifstream infile;

    infile.open("aaa.txt");

    while(infile >> s) {
        cout << s << endl;
    }
}

stty Settings

This is my stty setting (all in one line):


stty intr '^c' erase '^?' kill '^u' echoe 
echoctl echoke -ixany

Detect CPU Endian-ness

To detect a CPU’s endian architecture, use either one of the variables set like so:


$is_big_endian = unpack("h*", pack("s", 1)) =~ /01/;
$is_little_endian = unpack("h*", pack("s", 1)) =~ /^1/;

Found in Perlmonks