Category: Quick Tip
Quick optimization of jpeg files in a directory (Linux bash)
Firstly install jpegoptim. You can do this on Debian like systems using apt: sudo apt-get update && sudo apt-get install jpegoptim Then go to directory with jpeg files and use this command: find . -name ‘*.jpg’ -exec jpegoptim -m70 -o -f –strip-all {} \; It will find all jpg files recursively and optimize with following settings: m70 […]
How to remove non ASCII chars from filenames in current directory?
That’s easy: find ./ -depth -exec rename -v ‘s/[^[:ascii:]]/_/g’ {} \; | cat -v
How to find network device using it’s manufacturer name?
I’ve previously posted a note about finding Raspberry Pi without knowing it’s ip address. Well, basically it’s the same… Only you need to change MAC prefix to find other manufacturer. To wrap this is up, this is a command to find device by MAC prefix: sudo nmap -sP 192.168.100.0/24 | awk ‘/^Nmap/{ip=$NF}/00:D0:23/{print ip}’ And here […]
Simple backup script for your web projects
If you want to archive your project quickly with additional MySQL dump you can use this simple Bash script.
PHP reading problem with files larger than 2 GB
If you’ll ever have problem with opening (fopen) and reading (fread) files larger than 2 GB in your PHP script. Check your version of scripting engine. In my case switching to 64 bit solved the problem. Please mind that this error is very hard to debug because PHP does not log anything (same as MS […]
How to count computers and users in Active Directory?
This is really quick tip (cmd commands): dsquery user -limit 10000 | find /c /i “OU=” To count users. dsquery computer -limit 10000 | find /c /i “OU=” Here you can find how to create paths.
How to view two logs in one window?
In this example I will show you how to view Yii framework based app log and MySQl queries, both in realtime.
How to list all PostgreSQL databases and their sizes in MB
You must provide proper database name and user: File: gistfile1.txt ——————- psql -c “SELECT pg_database.datname, pg_database_size(pg_database.datname), pg_size_pretty(pg_database_size(pg_database.datname)) FROM pg_database ORDER BY pg_database_size DESC;” -d
How to find Raspberry Pi using MAC address
When you want to find your headless but networked Raspberry Pi and you’re lazy like me use nmap: sudo nmap -sP 192.168.1.0/24 | awk ‘/^Nmap/{ip=$NF}/B8:27:EB/{print ip}’ Mask /24 means that addresses from 192.168.1.0 to 192.168.1.254 will be searched. You can extend that to /16 if you don’t know subnet of your device.
How to obscure your WordPress version and troll the attacker a little…
One of my company’s WordPress installations has been hacked by Turkish hackers recently. After quick investigation I’ve found that script version was little bit old (not a very popular website, mea culpa, not updated very often). In case you didn’t know, WordPress is bundled with readme file by default. I’ve found that malicious scripts or […]