Answer Set Programming: with dlv and ASPIDE

- go to http://www.dlvsystem.com/dlv/
- download dlv.x86-64-linux-elf-static.bin
- go to https://www.mat.unical.it/ricca/aspide/download
- chose ".jar packages without installer" to download ASPIDE-Installer-Java-Package.zip
- # mv dlv.x86-64-linux-elf-static.bin dlv
- # chmod a+rx dlv
- extract ASPIDE-Installer-Java-Package.zip, it gives a folder ASPIDE
- go to ASPIDE
- # java -jar startAspide.jar
- internet connection is required here.
- it asks to install latest aspide, chose to install.
- it asks to install aspide add-ons. allow to install it.
- after installation, it asks for registration, register with your name and email.
- it sends a authentication code to mailbox and asks to input authentication code.
- provide authentication code and aspide starts...
- it asks for a project workspace path and then asks for path to dlv, provide them.
- now IDE of aspide opens... close it.
- now onwards aspide can be opened by # java -jar startAspide.jar
however, it needs internet to check updates etc. before starting IDE.
better to use # java -jar application/aspide/aspide.jar
- now IDE opens...
- create a new project
- create a new file : "DLV File with Arithmetic Expressions"
- write an asp program in the file and save it.
- to run the asp program, click Execute->Run.
- to make a query, click Execute->Query.
- query dialog opens, tick the checkbox "Epistemic Mode".
- type the query and suffix it with a question mark, then click "Execute".
- you may need to click "Run Configurations" and set path of dlv executable, if it asks: executable not found.
- enjoy.

Answer Set Programming: with clingo

- goto http://sourceforge.net/projects/potassco/files/clingo/4.4.0/
- download clingo-4.4.0-x86_64-linux.tar.gz
- # tar -xvzf clingo-4.4.0-x86_64-linux.tar.gz
- goto clingo-4.4.0-x86_64-linux folder
- execute an asp program as # ./clingo -n 0 family.lp
- it prints all answer sets; enjoy.

Some low level debugging tools in linux.

nm : just lists symbols from obj file
================
-n sort symbols numerically by address
-D shows dynamic symbols only

Symbol type:
If lowercase, the symbol is local;
if uppercase, the symbol is global (external).
A - symbol's value is absolute, will not be changed by further linking.
B - symbol is in the uninitialized data section (known as BSS).
C - symbol is common. Common symbols are uninitialized data.
D - symbol is in the initialized data section.
N - symbol is a debugging symbol.
R - symbol is in a read only data section.
T - symbol is in the text(code) section.
U - symbol is undefined.

objdump : shows details of obj files
================
-d disassembly
-S mix source code when disassembles
-x display section/program headers
-r display relocation entries
-w more than 80 character wide display

readelf : displays information about contents of ELF format files
================
-a Equivalent to: -h -l -S -s -r -d -V -A -I
-e Equivalent to: -h -l -S

-h Display the ELF file header
-l Display the program headers
-S Display the section headers

-s Display the symbol table
--dyn-syms Display the dynamic symbol table

-r Display the relocations (if present)
-d Display the dynamic section (if present)

-W more than 80 character wide display

good examples:
================
# gcc -c -o test test.c
# readelf -esr test > a.txt

# gcc -g -c -o test test.c
# objdump -drS test > b.txt

PHP code cleaning tools.

PHP LOC statistics:
1. wget --no-check-certificate https://phar.phpunit.de/phploc.phar
2. /opt/lampp/bin/php phploc.phar --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > loc.txt

PHP Mess Detector:
1. Download http://static.phpmd.org/php/2.1.1/phpmd.phar
2. /opt/lampp/bin/php phpmd.phar /mnt/data/MyWebProject/ text codesize --exclude lib,Resources --reportfile code_complexity.txt
[output format: text; available mess detectors: cleancode, codesize, controversial, design, naming, unusedcode]

PHP Code Sniffer (Enforces a coding standard):
1. Download http://download.pear.php.net/package/PHP_CodeSniffer-2.0.0RC1.tgz
2. /opt/lampp/bin/php PHP_CodeSniffer-2.0.0RC1/scripts/phpcs --report-file=code_sniff.txt --standard=Generic --extensions=php --ignore=*/lib/*,*/Resources/* /mnt/data/MyWebProject/

PHP Dead Code Detector:
1. wget --no-check-certificate https://phar.phpunit.de/phpdcd.phar
2. /opt/lampp/bin/php phpdcd.phar --recursive --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > dead_code.txt

PHP Copy Paste Detector
1. wget --no-check-certificate https://phar.phpunit.de/phpcpd.phar
2. /opt/lampp/bin/php phpcpd.phar --exclude="lib" --exclude="Resources" /mnt/data/MyWebProject/ > copy_paste.txt

While searching files with find, exclude some directories

find . -type f -name '*.php' ! -path "./lib/*" ! -path "./Resources/*" -exec vim -s /root/vimscript.scr "{}" \;

To print colored text in linux terminal

echo "$(tput setaf 1) Hello $(tput setaf 2) World! $(tput sgr0)"
or
echo -e "\033[31m Hello \033[32m World! \033[0m"

Option -e means "enable interpretation of backslash escapes"

How to indent php+html+javascript code using Vim on Linux

1. install full vim with plugins.
put following vim commands in /root/.vimrc

:set nocompatible
:filetype indent on
:syntax on
:set tabstop=4
:set shiftwidth=4
:set expandtab

2. create a vim script file (lets say vimscript.scr) in /root
put the following vim commands in vimscript.scr file

" this is a vim script comment
" remove \r in case file is from windows world
:%s/\r$//g

" set filetype as javascript and indent it
:set ft=javascript
gg=G

" set filetype as html and indent it
:set ft=html
gg=G

" set filetype as php and indent it
:set ft=php
gg=G

" convert multiple blank lines to single blank line
:%s/\n\{3,}/\r\r/e

" after indenting save file
:wq
" script end


3. to indent all php files in a dir, go to that dir and run
#find . -type f -name '*.php' -exec vim -s /root/vimscript.scr "{}" \;

Building geany from source

[To compile geany]
Get source tar file from http://www.geany.org/Download/Releases
# cd geany-1.24.1
# ./configure
# make

[To compile geany plugin]
Get source tar file from http://plugins.geany.org/downloads.html
Make sure geany 1.24 is compiled and installed.
# cd geany-plugins-1.24
# ./configure
[This sometimes gives error, "configure: error: Package requirements (geany >= 1.24) were not met".
Test if installation is proper,
#PKG_CONFIG_PATH=/usr/local/lib/pkgconfig pkg-config --modversion geany
# echo $PKG_CONFIG_PATH
May be path is not having /usr/local/lib/pkgconfig, then do,
# PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure]
# make

To create puppy pet/sfs package from source code

Generally:

[compile]
# cd xyz-<ver>
# ./configure
# make

# new2dir make install
# cd ..

[to create a pet]
# dir2pet xyz-<ver>-<arch>

[to create a sfs]
# mksquashfs xyz-<ver>-<arch> xyz-<ver>-<arch>.sfs -noappend

Simplest way to install virtualbox in puppy linux.

VirtualBox has a package for generic Linux distributions, like
http://download.virtualbox.org/virtualbox/4.3.16/VirtualBox-4.3.16-95972-Linux_amd64.run

You can find this link at https://www.virtualbox.org/wiki/Linux_Downloads under name "All distributions".

Simply choose one .run file (32bit or 64bit).
After downloading it, simply run it from terminal.
You need to have devx and kernel-sources packages already loaded into your puppy linux.

VirtualBox gets installed in /opt.

That's it.

To adjust brightness of laptop screen, without help of keyboard. (2)

Some times acpi can't adjust the brightness.

Next thing we need to try is, pass the following parameter to Linux kernel from grub configuration file.

acpi_backlight=vendor

Now if you are lucky, you can control brightness using the same old technique.

Current brightness is provided by file /sys/class/backlight/intel_backlight/actual_brightness.
Collect current brightness.
Max brightness is provided by file /sys/class/backlight/intel_backlight/max_brightness.
Now write a number, from 0 to MAX, to the file /sys/class/backlight/intel_backlight/brightness using echo.
Done.

Thanks to https://wiki.ubuntu.com/Kernel/Debugging/Backlight

To adjust brightness of laptop screen, without help of keyboard.

Thanks to my puppy Linux, which provides nice little scripts "brightness-up" and "brightness-down" to do the job.

Once we peep into it, we see what is going on under the hood.

To adjust brightness of laptop screen, we do this:

Current brightness is provided by file /sys/class/backlight/acpi_video0/actual_brightness.
Collect current brightness.
Max brightness is provided by file /sys/class/backlight/acpi_video0/max_brightness.
Now write a number, from 0 to MAX, to the file /sys/class/backlight/acpi_video0/brightness using echo.
Done.

So simple!!

Compile (with gcc) and link (with ld) to create your executable (without C library).

x.h
===
int add(int a, int b);


a.c
===
#include "x.h"
extern int extra;
int main()
{
int a = 9;
int b = 8;
int c;
c = add(9, 8) + extra;

return 0;
}


b.c
===
#include "x.h"
int extra = 9;
int add(int a, int b)
{
return a+b;
}


start.S
=======
.globl _start

_start:
call main
movl $1, %eax
xorl %ebx, %ebx
int $0x80


Now do
~/# gcc -c -nostdlib a.c
~/# gcc -c -nostdlib b.c
~/# gcc -c -nostdlib start.S
~/# ld -o test a.o b.o start.o

Your executable test is ready!!


Source: https://blogs.oracle.com/ksplice/entry/hello_from_a_libc_free

Good example showing how to create a Position Independent Executable (PIE).

We can create a Position Independent Executable (PIE) using -fPIE compiler option and -pie linker option of gcc.

A nice example collected from net.

aslr.c
======
#include <stdio.h>

static void foo() {}
static int bar = 5;

int main(void)
{
int baz = 5;
printf("function: %p, library function: %p, data: %p, stack: %p\n", foo, &printf, &bar, &baz);
return 0;
}
=======

Now do

$ gcc -o aslr aslr.c; for i in $(seq 1 10); do ./aslr; done
$ gcc -fPIE -o aslr aslr.c; for i in $(seq 1 10); do ./aslr; done
$ gcc -fPIE -pie -o aslr aslr.c; for i in $(seq 1 10); do ./aslr; done

and see what you get!!

Source: https://wiki.archlinux.org/index.php/DeveloperWiki:Security

When 'clear' command doesn't clean the whole terminal window.

We can use 'reset' command to clean the whole terminal window.

C statement execution time in microseconds

#include <sys/time.h>
=====================

struct timeval tv1, tv2;

gettimeofday(&tv1, NULL);
//put c statements here
gettimeofday(&tv2, NULL);

printf ("Total time = %lld microseconds\n", ((long long)tv2.tv_sec*(long long)1000000+(long long)tv2.tv_usec) - ((long long)tv1.tv_sec*(long long)1000000+(long long)tv1.tv_usec));

Sort directories based on human readable size

# du --max-depth=3 . | sort -n | cut -f 2 | while read file_name; do du -sh $file_name; done;

Better strace command

# strace -fFittTvs300 -eraw=all -o output.txt <command or -p pid>

Run dos2unix on all files of a directory

# find . -type f -exec dos2unix '{}' ';'

Git: to get a particular revision of a file

# git show ecc653:my_program.php > k.php

Better grep command

# grep --color=always -i Quad /proc/cpuinfo

Cross gcc compilation

wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gz

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz

wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.6.2/gcc-core-4.6.2.tar.bz2

tar xvzf binutils-2.23.tar.gz

bunzip2 gmp-4.3.2.tar.bz2
tar xvf gmp-4.3.2.tar

bunzip2 mpfr-2.4.2.tar.bz2
tar xvf mpfr-2.4.2.tar

tar zxvf mpc-0.8.1.tar.gz

bunzip2 gcc-core-4.6.2.tar.bz2
tar xvf gcc-core-4.6.2.tar

mkdir src
mv gmp-4.3.2 mpc-0.8.1 mpfr-2.4.2 binutils-2.23 gcc-4.6.2 src

mkdir -p opt/cross

export PREFIX="$HOME/opt/cross"
export TARGET=i586-elf
export PATH="$PREFIX/bin:$PATH"

cd $HOME/src
mkdir build-binutils
cd build-binutils
../binutils-2.23/configure --target=$TARGET --prefix="$PREFIX" --disable-nls
make
make install

mv gmp-4.3.2 gcc-4.6.2/gmp
mv mpc-0.8.1 gcc-4.6.2/mpc
mv mpfr-2.4.2 gcc-4.6.2/mpfr
mkdir build-gcc
cd build-gcc
../gcc-4.6.2/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc

$HOME/opt/cross/bin/$TARGET-gcc --version

#to add cross compiler location to system path
#export PATH="$HOME/opt/cross/bin:$PATH"
#if you like, you can copy the whole "cross" directory from your $HOME/opt to system /opt directory.
#and you add that path to your system path. You can place the export command in .bashrc in $HOME.

Search column name in a mysql db

SELECT
table_name,
column_name,
data_type,
ordinal_position

FROM INFORMATION_SCHEMA.COLUMNS

WHERE table_schema = 'mydb'
AND column_name LIKE '%pattern%' ;

Using script to do something for all files of a folder

#!/bin/bash
# here we try to separate files
#1. that are included in other files
# 2. that are not

folder=/opt/myfolder

echo > a.txt
find $folder | while read filepath
do
file=`basename "$filepath"`
usedin=`grep -r "$file" $folder`
if [ "$usedin" = "" ]
then
echo "$filepath" >> a.txt
else
echo "$filepath"
echo ======
echo $usedin
fi
done

Sed: to add one space after comma

1. use sed to add a space after comma
2. use sed to replace multiple space(or tab) after comma with one space
3. use sed to perform 1. and 2. using -e option

# cat debug.txt
a, {, 9,L,%

# sed -i.bak -e 's/,/, /g' -e "s/,[ \t]*/, /g" debug.txt

# cat debug.txt
a, {, 9, L, %

Linux commands for set operations

Full explanation at: http://www.catonmat.net/blog/set-operations-in-unix-shell/

Meld: three way merge (manually)

# meld --output o.txt l.txt b.txt r.txt

In general meld displays
l.txt (or local version in case of git, to which version merge is done) in left tab,
b.txt (or base version in case of git, common ancestor to both) in middle tab,
r.txt (or remote version in case of git, from where merge is done) in right tab.

Now make changes to b.txt and save.

Meld saves the changes to o.txt (or working copy in case of git, which is going to be commited).

Files l.txt, b.txt, r.txt all remains unchanged.

How to substitute an old pattern with a new pattern in matched lines of all files inside a directory

Say old pattern is "/old.php",
and new pattern is "/new.php"

# find . -type f -print0 | xargs -0 sed -i 's|/old.php|/new.php|g'
(sed -i for inplace editing of the file)

How to use vim to indent all files in a directory

run vim script indentme.scr to indent all files using vim

# find . -type f -name '*.c' -exec vim -s indentme.scr "{}" \;

[indentme.scr file shall contain vim commands like:
gg=G]

(gg means go to first line
= means auto indent
G means till the last line)

Delete lines containing a pattern from all files inside a directory

# find . -type f -print0 | xargs -0 sed -i '/my_pattern/d'
(sed -i is for inplace editing of the file)

Mysql: forcibly drop a table having foreign constraints

# /opt/lampp/bin/mysql -u root -p -D mydb -e "SET FOREIGN_KEY_CHECKS=0; drop table my_table; SET FOREIGN_KEY_CHECKS=1;"

How to add vim plugin manually

To manually add a plugin for php language to vim

0. vim plugins are of different types, (i) syntax (ii) indent etc.
1. create a folder like ~/.vim/indent or ~/.vim/syntax
2. collect the plugin for php.
Plugins generally have a name like php.vim.
Two different php.vim shall be available, one for syntax and one for indent.
3. put respective php.vim in respective folder.
4. when vim package is installed, it has its plugins in /usr/share/vim/ folder.
5. more info here (http://vimdoc.sourceforge.net/htmldoc/filetype.html)

Command find with exec

The below command would find any files with the extension '.doc' and copy them to your /tmp directory

# find / -name '*.doc' -exec cp '{}' /tmp/ ';'

The curly brackets are used in find to represent the current file which has been found. ie. If it found the file shopping.doc then {} would be substituted with shopping.doc. It would then continue to substitute {} for each file it finds. The brackets are normally protected by backslashes (\) or single-quotation marks ('), to stop bash expanding them (trying to interpret them as a special command eg. a wildcard). This ';' is the symbol used by find to signal the end of the commands. It's usually protected by a backslash (\) or quotes to stop bash from trying to expand it.

This finds all c-files and python files in the euler directory.
# find euler/ -iname "*.c*" -exec echo {} \; -or -iname "*.py" -exec echo {} \;

Delete empty lines from a file using vi editor

Use either of the following commands to delete all empty lines:

:g/^$/d
:v/./d

If you want to delete all lines that are empty or that contain only white space characters (spaces, tabs), use either of:

:g/^\s*$/d
:v/\S/d

In the second command, v operates on lines that do not match, and \S matches anything that is not a white space, and d deletes the flagged lines (all lines that have no characters, or that have only white space characters).

Hexdump with output format

# hexdump -n 10 -s 512 -v -e '"x" 1/1 "%02X" " "' untitled.txt

-n for number of bytes.
-s for offset
-v for not showing a * mark for repetition
-e for output format

Qemu: redirect serial port data to stdio or a file, read it in text editor

redirect serial port data to stdio
# qemu-system-i386 -m 64 -serial stdio -hda ./harddisk.img

redirect serial port data to a file
# qemu-system-i386 -m 64 -serial file:a.txt -hda ./harddisk.img

redirect serial port data to a file (another way)
# qemu-system-i386 -m 64 -serial stdio -hda ./harddisk.img | tee a.txt

Now, a.txt can't be opened in a text editor.
Because it contains 0x00 (NULL character) in place of '\n' (new line character).

So use the following command:
# cat a.txt | xargs -0 echo > b.txt

Now b.txt is an ascii file, and can be read by text editors.

Some essential linux commands

to unrar into current folder
# unrar x a.rar

to unrar into a different folder
# mkdir a; unrar x a.rar ./a/

to zip a folder
#zip -r abc abc/

Remote debugging with gdb: debugging a kernel with qemu

1. in one terminal, run
#qemu -no-kqemu -m 64 -fda ./floppy.img -s -S
[floppy.img contains kernel.bin which is loaded by GRUB]

2. in other terminal, run
#gdb ./kernel.bin
[kernel.bin is an ELF executable]

(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x0000fff0 in ?? ()

(gdb) break _start
Note: breakpoint -1 also set at pc 0x1208a0.
Breakpoint 1 at 0x1208a0

(gdb) c
Continuing.
Stopped due to shared library event

(gdb)

3. Enjoy from here!

Check what is being installed: installwatch command on make install

# installwatch -o /tmp/pkginstall.list make install

Similarities and differences between spinlock, mutex and semaphore.

spinlock
========
1. better to use when contention is heavy
2. when one task works in critical section, other tasks don't go to sleep
3. critical section can be used by at most one task
4. useful in multi-processor system but not in single processor system
5. useful when critical section is very small
6. if not acquired, spinlock doesn't make the task sleep, so it doesn't force a context switch

mutex ( ~ binary semaphore)
=====
1. better to use when contention is not heavy
2. when one task works in critical section, other tasks go to sleep
3. critical section can be used by at most one task
4. useful in both multi-processor system and in single processor system
5. useful when critical section is not small
6. if not acquired, mutex makes the task sleep, so it forces a context switch

semaphore ( = counting semaphore)
=========
1. better to use when contention is not heavy
2. when one task works in critical section, other tasks go to sleep
3. critical section can be used by at most N tasks
4. useful in both multi-processor system and in single processor system
5. useful when critical section is not small
6. if not acquired, semaphore makes the task sleep, so it forces a context switch

How to compact virtualbox vdi file.

# /opt/VirtualBox/VBoxManage modifyhd my_vbox.vdi --compact

Linux commands to assemble and link a.asm file written in nasm syntax.

# nasm -f elf32 -g a.asm
# gcc -g a.o -o a.out

How to set up and compile a SDL application.

Steps (Linux commands):

# tar vfxz SDL-1.2.15.tar.gz
# cd SDL-1.2.15
# ./configure
# make
# make install
# cd -
# /usr/local/bin/sdl-config --cflags --libs
# g++ a.cpp `/usr/local/bin/sdl-config --cflags --libs`
# ./a.out

Good link on c++ vtable vptr structure

http://sourcery.mentor.com/public/cxx-abi/cxx-vtable-ex.html

Steps to program 8051 (P89V51RD2) microcontroller by ISP method using RS232

After long discussions and try, I was able to successfully able to program P89V51RD2 by In Situ Programming (ISP) method using RS232. In a hope that it shall be useful to others, I would like to post my experience with simple steps. For my success, I shall thank all our friends, who have helped me clearing my doubts and have provided their help and suggestions.

Here are the steps to program P89V51RD2 by ISP method using RS232.

My Need:
--------
1. I had to find a microcontroller, which is self programmable, do not need a separate programmer.
2. Circuit should be simple, even a novice can make it and learn.
3. Other tools should be simple and freely available.

So, I choose:
-----------
1. P89V51RD2 microcontroller from Philips. Specifically P89V51RD2FN.
2. Circuit diagram from http://www.ece.ubc.ca/~jesusc/P89V51RD2_System.pdf
3. SDCC for compiling C programs and FlashMagic for programming the microcontroller.

I made the circuit on a veroboard.
Connected the circuit to PC using serial cable(RS232).


vbox (winxp guest, linux host) setting:
---------------------------
check "enable serial port"
port number: com1
port mode: host device
port path: /dev/ttyS0
---------------------------


Test code:
----------
//test.c
#include<p89v51rd2.h>
void DeadDelay(unsigned int delay)
{
unsigned int indexI,indexJ;

for(indexI=0; indexI<delay; indexI++)
for(indexJ=0; indexJ<1275; indexJ++);
}
void main(void)
{
while (1)
{
/* Blink LED on Port 0 */
P0=0x55;
DeadDelay(25);
P0=0x00;
DeadDelay(25);

}
}

SDCC commands:
--------------
C:\>sdcc -I"c:\Program Files\SDCC\include\mcs51" test.c

C:\>packihx test.ihx > test.hex
packihx: read 25 lines, wrote 17: OK.

Flash Magic setting:
-------------------
com port: com1
baud rate: 9600
device: 89v51rd2
interface: none(isp)
hex file: C:test.hex
check "Verify..."

DO NOT check the box near to "Erase all Flash".
DO NOT check the box near to "Erase Flash used by Hexfile".
It may damage the bootloader!
I didn't check these two boxes and programmed my P89V51RD2 twice, hence confirming that my bootloader was in safe condition.

Now click on "Start".
When it asks to reset the device, press reset button on circuit board and get p89v51rd2 programmed!

Source: http://www.edaboard.com/thread259155.html

Securing puppy linux: Set password for root

After you boot up do the following:

1. open console type 'passwd root'. enter your new password twice.

2. run 'lock' on desktop and enter password from step 1

You may want to select 'blank' from the config to save on processor usage

3. edit /etc/inittab to look like this:

::sysinit:/etc/rc.d/rc.sysinit
tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
::ctrlaltdel:/sbin/reboot


This keeps someone from killing lock with ctrl+alt+backspace and
logging back in automatically and also gives the option on bootup to
enter 'root' and 'password'.

4. run the firewall wizard at Menu->Setup->Linux-Firewall Wizard.
automagic works fine if you don't have to set up any local services.

5. shutdown and select 'heavy encryption' for save file.

Source: http://www.murga-linux.com/puppy/viewtopic.php?t=18639

Popular science books list

Mathematical recreations
http://libcat.dartmouth.edu/search~S1?/dMathematical+recreations./dmathematical+recreations/-3,-1,0,B/exact&FF=dmathematical+recreations&1,-1,/indexsort=r

Popular Science Collection
http://libguides.ucsd.edu/popsci

Symbol visibility in ELF shared library

Details on symbol visibility
http://www.macieira.org/blog/2012/01/sorry-state-of-dynamic-libraries-on-linux/

Why symbol visibility is good
https://www.technovelty.org/code/why-symbol-visibility-is-good.html


Position Independent Executable

Very good presentation on this from OpenBSD
http://www.openbsd.org/papers/nycbsdcon08-pie/

Stripping shared libraries

Very good link on this
https://www.technovelty.org//linux/stripping-shared-libraries.html

Good links on ELF (Executable and Linkable Format)

Ian Lance Taylor on Linkers
http://www.cs.jhu.edu/~s/musings/linkers.html

ELF format details
http://wiki.osdev.org/ELF


Very good details on ELF linker loader
http://eli.thegreenplace.net/2011/08/25/load-time-relocation-of-shared-libraries/

Load and run DJGPP COFF, Win32 PE COFF, or ELF .o file
http://files.osdev.org/mirrors/geezer/osd/exec/index.htm#snippets


Steps to load ELF
http://wiki.osdev.org/ELF_Tutorial

ELF loader code
http://code.google.com/p/elf-loader/

Code to dynamically link ELF files
http://oslib.cvs.sourceforge.net/viewvc/oslib/

Good code for dynamically linking/loading ELF shared library
http://my.execpc.com/~geezer/

The ELF Object File Format by Dissection
http://www.linuxjournal.com/article/1060

Very detailed description on ELF linking
http://www.cs.stevens.edu/~jschauma/631/elf.html

How to write dynamically loadable libraries
http://www.ibm.com/developerworks/library/l-shobj/

Process address space, compiler stages etc.
http://www.cs.rochester.edu/courses/252/spring2014/notes/07_linking 

Linux linker code flow on last slide
http://www.slideshare.net/JohnTortugo/fisl-xiv-the-elf-format-and-the-linux-loader

Relocation types for i386
ftp://ftp.oregonstate.edu/pub/netwinder/users/p/patb/public_html/elf_relocs.html

On Shared library
http://www.codeproject.com/Articles/70302/Redirecting-functions-in-shared-ELF-libraries

Some links collecting other links:
http://althing.cs.dartmouth.edu/secref/resources/elf-hackery.shtml

When ldd doesn't tell the details...

Sometimes, ldd does not show all the libraries that a program might use. The system call dlopen() can load a dynamic library on demand, and these libraries do not show up in the ldd output.

Then we can use strace command.
More here: http://www.mr-fo.com/node/14

Some good links on Implementing Regular Expression Engine

Implementing Regular Expressions by Russ Cox
http://swtch.com/~rsc/regexp/

A Regular Expression Matcher, Code by Rob Pike, Exegesis by Brian Kernighan
http://genius.cat-v.org/brian-kernighan/articles/beautiful

Knuth-Morris-Pratt string matching algorithm
http://www.ics.uci.edu/~eppstein/161/960227.html