$strings a.out /lib64/ld-linux-x86-64.so.2 libc.so.6 printf __libc_start_main __gmon_start__ GLIBC_2.2.5 fffff. []A\A]A^A_ hello ;*3$" GCC: (Debian 4.9.2-10) 4.9.2 GCC: (Debian 4.8.3-13) 4.8.3 hello.c long unsigned int short unsigned int short int GNU C 4.9.2 -mtune=generic -march=x86-64 -g unsigned char long int sizetype main hello.c /home/jeffrin .symtab .strtab .shstrtab .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .text .fini .rodata .eh_frame_hdr .eh_frame .init_array .fini_array .jcr .dynamic .got .got.plt .data .bss .comment .debug_aranges .debug_info .debug_abbrev .debug_line .debug_str crtstuff.c __JCR_LIST__ deregister_tm_clones register_tm_clones __do_global_dtors_aux completed.6661 __do_global_dtors_aux_fini_array_entry frame_dummy __frame_dummy_init_array_entry hello.c __FRAME_END__ __JCR_END__ __init_array_end _DYNAMIC __init_array_start _GLOBAL_OFFSET_TABLE_ __libc_csu_fini _ITM_deregisterTMCloneTable data_start _edata _fini printf@@GLIBC_2.2.5 __libc_start_main@@GLIBC_2.2.5 __data_start __gmon_start__ __dso_handle _IO_stdin_used __libc_csu_init _end _start __bss_start main _Jv_RegisterClasses __TMC_END__ _ITM_registerTMCloneTable _init $
6 Framed photos was added to the collection
6 Framed photos was added to the collection 4 small ones and 2 relatively bigger ones All the photos are related to NATIONAL GEOGRAPHIC
Hacking with listing local system locks
ABOUT lslocks
lslocks lists information about all the currently held file locks in a Linux system. File locking is a mechanism that restricts access to a computer file by allowing only one user or process access at any specific time. Systems implement locking to prevent the classic interceding update scenario (see race condition).
[bash]
$lslocks -p 23897
$lslocks -p 1404
$lslocks -p 15099
$lslocks -p 17229
COMMAND PID TYPE SIZE MODE M START END PATH
chromium 17229 POSIX 68K WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/Web Data
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/Local Extension Settings
chromium 17229 POSIX 140K WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/History
chromium 17229 POSIX 1.5M WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/Favicons
chromium 17229 POSIX 20K WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/Shortcuts
chromium 17229 POSIX 12K WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/Login Data
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/Extension Rules/LOCK
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/File System/Origins/LOCK
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/Session Storage/LOCK
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/Extension State/LOCK
$lslocks
COMMAND PID TYPE SIZE MODE M START END PATH
atd 580 POSIX 0B WRITE 0 0 0 /run
cron 614 FLOCK 0B WRITE 0 0 0 /run
tracker-miner-f 1505 POSIX 27.1M READ 0 1073741826 1073742335 /home/jeffrin/.cache/tracker/meta.db
tracker-miner-f 1505 POSIX 32K READ 0 128 128 /home/jeffrin/.cache/tracker/meta.db-shm
chromium 17229 POSIX 68K WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/Web Data
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/Local Extension Setting
chromium 17229 POSIX 140K WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/History
chromium 17229 POSIX 1.5M WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/Favicons
chromium 17229 POSIX 20K WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/Shortcuts
chromium 17229 POSIX 12K WRITE 0 1073741824 1073742335 /home/jeffrin/.config/chromium/Default/Login Data
(unknown) 543 FLOCK 0B WRITE 0 0 0 /run
lpd 594 FLOCK 0B WRITE 0 0 0 /run
runsv 670 FLOCK 0B WRITE 0 0 0 /
tracker-store 1512 POSIX 27.1M READ 0 1073741826 1073742335 /home/jeffrin/.cache/tracker/meta.db
tracker-store 1512 POSIX 32K READ 0 128 128 /home/jeffrin/.cache/tracker/meta.db-shm
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/Extension Rules/LOCK
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/File System/Origins/LOC
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/Session Storage/LOCK
chromium 17229 POSIX 0B WRITE 0 0 0 /home/jeffrin/.config/chromium/Default/Extension State/LOCK
$
[/bash]
LINKS
http://man7.org/linux/man-pages/man8/lslocks.8.html
https://unix.stackexchange.com/questions/85994/how-to-list-processes-locking-file
Hacking with an arbitrary precision calculator
dc is a reverse-polish desk calculator which supports unlimited preci‐ sion arithmetic. It also allows you to define and call macros. Nor‐ mally dc reads from the standard input; if any command arguments are given to it, they are filenames, and dc reads and executes the contents of the files before reading from standard input. All normal output is to standard output; all error output is to standard error. A reverse-polish calculator stores numbers on a stack. Entering a num‐ ber pushes it on the stack. Arithmetic operations pop arguments off the stack and push the results. To enter a number in dc, type the digits (using upper case letters A through F as "digits" when working with input bases greater than ten), with an optional decimal point. Exponential notation is not supported. To enter a negative number, begin the number with ``_''. ``-'' cannot be used for this, as it is a binary operator for subtraction instead. To enter two numbers in succession, separate them with spaces or new‐ lines. These have no meaning as commands. $dc 1234 f 1234 2322 f 2322 1234 p * 2 2322 f 2 2865348 f 2 2865348 2 * p 4 f 4 2865348 p * 1 4 p 1 p 1 f 1 11461392 dc: dc: stack empty f $
Ultimate Survival Alaska – Competitors :30
[youtube https://www.youtube.com/watch?v=2Z0l5mJ9ls8?rel=0&w=560&h=315]
Introducing The Linux Foundation Certification Program
[youtube https://www.youtube.com/watch?v=Y29qZ71Kicg?rel=0&w=560&h=315]
Example for an Array with processing language
/**
* Array.
*
* An array is a list of data. Each piece of data in an array
* is identified by an index number representing its position in
* the array. Arrays are zero based, which means that the first
* element in the array is [0], the second element is [1], and so on.
* In this example, an array named "coswav" is created and
* filled with the cosine values. This data is displayed three
* separate ways on the screen.
*/
float[] coswave;
void setup() {
size(640, 360);
coswave = new float[width];
for (int i = 0; i < width; i++) {
float amount = map(i, 0, width, 0, PI);
coswave[i] = abs(cos(amount));
}
background(255);
noLoop();
}
void draw() {
int y1 = 0;
int y2 = height/3;
for (int i = 0; i < width; i+=2) {
stroke(coswave[i]*255);
line(i, y1, i, y2);
}
y1 = y2;
y2 = y1 + y1;
for (int i = 0; i < width; i+=2) {
stroke(coswave[i]*255 / 4);
line(i, y1, i, y2);
}
y1 = y2;
y2 = height;
for (int i = 0; i < width; i+=2) {
stroke(255 - coswave[i]*255);
line(i, y1, i, y2);
}
}
Hacking with GNU grep . ( grep ‘[1-9]\$’ price.list )
$emacs price.list $grep '[1-9]$' price.list 1 2 3 4 45 46 78 $54 $cat price.list 1 2 3 4 45 46 78 $54 54$ 31$ 21$ $grep '[1-9]' price.list 1 2 3 4 45 46 78 $54 54$ 31$ 21$ $grep '[1-9]\$' price.list 54$ 31$ 21$ $
A program to solve project euler problem 11
[python]
# This program is copied from http://code.jasonbhill.com/python/project-euler-problem-11/
# Largest product in a grid
# https://projecteuler.net/problem=11
import time
start = time.time()
L = []
L.append("08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08")
L.append("49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00")
L.append("81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65")
L.append("52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91")
L.append("22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80")
L.append("24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50")
L.append("32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70")
L.append("67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21")
L.append("24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72")
L.append("21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95")
L.append("78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92")
L.append("16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57")
L.append("86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58")
L.append("19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40")
L.append("04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66")
L.append("88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69")
L.append("04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36")
L.append("20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16")
L.append("20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54")
L.append("01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48")
M = [i.split() for i in L]
M = [[int(j) for j in i] for i in M]
# there are 20 rows, each containing 20 integers
max_prod = 0
for i in range(20):
for j in range(16):
# right/left products
prod = M[i][j]*M[i][j+1]*M[i][j+2]*M[i][j+3]
if prod > max_prod: max_prod = prod
# up/down products
prod = M[j][i]*M[j+1][i]*M[j+2][i]*M[j+3][i]
if prod > max_prod: max_prod = prod
# diagonal products
for i in range(16):
for j in range(16):
prod = M[i][j]*M[i+1][j+1]*M[i+2][j+2]*M[i+3][j+3]
if prod > max_prod: max_prod = prod
for i in range(3,20):
for j in range(16):
prod = M[i][j]*M[i-1][j+1]*M[i-2][j+2]*M[i-3][j+3]
if prod > max_prod: max_prod = prod
elapsed = (time.time() – start)
print "%s found in %s seconds" % (max_prod,elapsed)
[/python]
Hacking with the quote command on Bash shell
ABOUT Quoting
Quoting is used to remove the special meaning of certain characters or words to the shell. Quoting can
be used to disable special treatment for special characters, to prevent reserved words from being
recognized as such, and to prevent parameter expansion.
Each of the shell metacharacters (*note Definitions::) has special meaning to the shell and must be
quoted if it is to represent itself. When the command history expansion facilities are being used
(*note History Interaction::), the HISTORY EXPANSION character, usually '!', must be quoted to prevent
history expansion. *Note Bash History Facilities::, for more details concerning history expansion.
There are three quoting mechanisms: the ESCAPE CHARACTER, single quotes, and double quotes.
Escape Character
A non-quoted backslash '\' is the Bash escape character. It preserves the literal value of the next
character that follows, with the exception of 'newline'. If a '\newline' pair appears, and the backslash
itself is not quoted, the '\newline' is treated as a line continuation (that is, it is removed from the
input stream and effectively ignored).
Single Quotes
Enclosing characters in single quotes (''') preserves the literal value of each character within the
quotes. A single quote may not occur between single quotes, even when preceded by a backslash.
Double Quotes
Enclosing characters in double quotes ('"') preserves the literal value of all characters within the
quotes, with the exception of '$', '`', '\', and, when history expansion is enabled, '!'.
The characters '$' and '`' retain their special meaning within double quotes (*note Shell
Expansions::). The backslash retains its special meaning only when followed by one of the following
characters: '$', '`', '"', '\', or 'newline'. Within double quotes, backslashes that are followed by
one of these characters are removed. Backslashes preceding characters without a special meaning are left
unmodified. A double quote may be quoted within double quotes by preceding it with a backslash. If
enabled, history expansion will be performed unless an '!' appearing in double quotes is escaped using a
backslash. The backslash preceding the '!' is not removed.
The special parameters '*' and '@' have special meaning when in double quotes (*note Shell Parameter
Expansion::).
TYPICAL SHELL SESSION RELATED
[bash]
$echo quote ls
quote ls
$echo ‘quote ls’
quote ls
$echo ‘quote ls`
> ;
> ^C
$echo `quote ls`
‘ls’
$echo `ls`
animal.png animal.xcf icon.png
$ls
animal.png animal.xcf icon.png
$ls `quote ls`
ls: cannot access ‘ls’: No such file or directory
$ls ‘quote `ls`’
ls: cannot access quote `ls`: No such file or directory
$echo ‘quote `ls`’
quote `ls`
$echo `quote `ls“
”ls
$echo "quote `ls`"
quote animal.png
animal.xcf
icon.png
$echo ‘quote `ls`’
quote `ls`
$echo ‘ls `ls`’
ls `ls`
$quote "ls pwd"
‘ls pwd’$
$quote "ls pwd \n"
‘ls pwd \n’$
$ls `quote ls`
ls: cannot access ‘ls’: No such file or directory
$ls `ls`
animal.png animal.xcf icon.png
$
[/bash]
LINK
https://www.gnu.org/software/bash/manual/bash.txt