All posts by Tomislav Vlahović
List of freely available programming books
PHP catch fatal errors
function catch_fatal_error(){ // Getting Last Error $last_error = error_get_last(); // Check if Last error is of type FATAL if(isset($last_error['type']) && $last_error['type']==E_ERROR){ // Fatal Error Occurs // Do whatever you want for FATAL Errors } } register_shutdown_function('catch_fatal_error');
source: http://www.xpertdeveloper.com/2013/01/catch-fatal-errors-in-php/
MySQL log queries
SET GLOBAL general_log = 1
Zapisuje sve upite u bazu.
Lokacija loga: C:\wamp\bin\mysql\mysql5.5.24\data\ime-kompa.log
How to check jQuery version?
// Returns string Ex: "1.3.1" $().jquery; // Also returns string Ex: "1.3.1" jQuery.fn.jquery;
Bookmarks 2013-01-15
2013 – Books read
01-mjesec
Wool Omnibus Edition (Wool 1 – 5) (Silo Saga)
03-mjesec
2013-03-10
No Easy Day: The Firsthand Account of the Mission That Killed Osama Bin Laden
06-mjesec
2013-06-29
Ender’s Game
Bookmarks 2013-01-14
Quilt.js – Declarative Views for Backbone.
The Pragmatic Programmer: From Journeyman to Master
The Exceptional Beauty of Doom 3’s Source Code
Bookmarks 2013-01-13
Common JavaScript “Gotchas”
web.py – Ima interesantan library za baze, probaj iskoristi za SQL Anywhere
http://ak.net84.net/
WordPress Widget Tutorial
Creating a Simple WordPress Widget
Linux Cheat Sheet
PROCESS BASICS
ps auxww -H
All processes, with params + hierarchy
pgrep -fl $PROCESS_NAME
Filtriraj procese
strace -f -p $PID
What is a process doing?
lsof -p $PID
What files does a process have open?
watch 'ps aux | grep $PROCESS_NAME'
Keep an eye on a process
MEMORY
free -m cat /proc/meminfo
How much mem is free?
vmstat 1
Are we swapping?
ps aux --sort=-resident|head -11
List the top 10 memory hogs
DATABASES
pt-query-digest --processlist h=localhost --print --no-report --user xxxx --password *****
“Tail” all queries hitting mysql. More
ssh -L 3307:localhost:3306 user@hostname -N
Connect to production mysql locally on port 3307 via ssh
DISK/FILES
iostat -xnk 5
Check reads/writes per disk
find . -size +100M
Find files over 100MB
find . -mtime -7
Find files created within the last 7 days
find . -mtime +14 -type f -name '*.gz'
Find files older than 14 days
find *.gz -mtime +14 -type f -exec rm {} \;
Delete files older than 14 days
tail -f file.log | grep 192.168.1.1
Monitor a log file for an IP or anything else
NETWORK
lsof -nPi tcp
TCP sockets in use
ip addr ifconfig iwconfig
Get IP/Ethernet info
mtr google.com
Traceroute with stats over time (top for traceroute)
tcptraceroute google.com
Traceroute using TCP to avoid ICMP blockage
iftop
Show traffic by port
netstat -tlnp
Show all ports listening with process PID
Izvor: http://rubytune.com/cheat