How do SO_REUSEADDR and SO_REUSEPORT differ?

Welcome to the wonderful world of portability… or rather the lack of it. Before we start analyzing these two options in detail and take a deeper look how different operating systems handle them, it should be noted that the BSD socket implementation is the mother of all socket implementations. Basically all other systems copied the … Read more

Use grep –exclude/–include syntax to not grep through certain files

Use the shell globbing syntax: grep pattern -r –include=\*.cpp –include=\*.h rootdir The syntax for –exclude is identical. Note that the star is escaped with a backslash to prevent it from being expanded by the shell (quoting it, such as –include=”*.cpp”, would work just as well). Otherwise, if you had any files in the current working … Read more

How can I convert a Unix timestamp to DateTime and vice versa?

Here’s what you need: public static DateTime UnixTimeStampToDateTime( double unixTimeStamp ) { // Unix timestamp is seconds past epoch DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); dateTime = dateTime.AddSeconds( unixTimeStamp ).ToLocalTime(); return dateTime; } Or, for Java (which is different because the timestamp is in milliseconds, not seconds): public static … Read more

How do I list all cron jobs for all users?

You would have to run this as root, but: for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done will loop over each user name listing out their crontab. The crontabs are owned by the respective users so you won’t be able to see another user’s crontab w/o being them or root. … Read more

How can I exclude directories from grep -R?

Recent versions of GNU Grep (>= 2.5.2) provide: –exclude-dir=dir which excludes directories matching the pattern dir from recursive directory searches. So you can do: grep -R –exclude-dir=node_modules ‘some pattern’ /path/to/search For a bit more information regarding syntax and usage see The GNU man page for File and Directory Selection A related StackOverflow answer Use grep … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)