Category: Tips and Tricks

bash singleton process

Here is a simple, yet effective way, to make sure a script runs only once. when the script start it run a simple line that detect if the number of running script does not exceeds more then 1. #!/bin/bash [[

Posted in Tips and Tricks Tagged with: ,

Lock a file on Linux

Here is how to lock a file from write/delete in a dirty way . this trick will work this file system ext2-4 XFS, ReiserFS, JFS and OCFS2. and the trick is to use the command chattr for changing file extended

Posted in Tips and Tricks Tagged with: ,

100-Continue and Google load balancer

This is how to solve 100-continue problem with google http/s load balancer. Currently google HTTP/S load balancer does not support the Expect: 100-continue POST header . as a result clients who sends this header in their request will fail to

Posted in Tips and Tricks Tagged with: , , , ,

Loop trick in bash

For loop in BASH can be written in many ways , it could use a numeric counter or it could use an array . here are some example that may help : 1. Count up loop in BASH, from 0

Posted in Tips and Tricks Tagged with: ,

Overflow /tmp partition

Sometimes your /tmp directory may be mounted to a partition name overflow and the size for this partition may be 1M ,while its a 100% full capacity. This may happen if the root partition got full , and the system

Posted in Tips and Tricks Tagged with: , ,

Splitting Certificate chain

Here is how one can split a certificate chain into individual files . sure this can be done manualy in any text editor , but there comes a time when … well such simple task may consume a lot of

Posted in Tips and Tricks Tagged with: ,

Learn Python

I had a good “administrator” life with Bash and pearl , but I came to see the power of python . learning python is very easy , all you needs to do is replace any script you are about to

Posted in Tips and Tricks Tagged with: ,

Gnome 3 power button shutdown

If you work with the new gnome 3 as your desktop you probably noticed that clicking the power button doesn’t shut the computer , in my case it just restart it . in order to set the power of there

Posted in Tips and Tricks Tagged with: , ,

Redirect to www in php

Here is a simple way to redirect any hit to www using php . and also keep the protocol ( http/https ) if($_SERVER[HTTPS]) { header(‘Location:’ . “http://www.$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]” ,true, 301); } else { header(‘Location:’ . “https://www.$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]” ,true, 301); }

Posted in Tips and Tricks Tagged with: ,

symetric gpg encryption

Symetric encryption is an encryption that uses same key to decrypt. here is a way to encrypt file with symetric key without user interact ( batch ) gpg –batch -q –passphrase ‘<password>’ –cipher-algo AES256 -c <file>

Posted in Tips and Tricks Tagged with: , ,