Thursday, September 5, 2013

Useful commands with ffmpeg

Converting mp4 to flv:

ffmpeg -i INPUT.mp4  -vcodec copy -acodec aac -strict experimental -ac 2 -ar 44100 -ab 192k OUTPUT.flv



Deleting logo from video:

ffmpeg -sameq -i INPUT.flv -vf "delogo=x=10:y=10:w=80:h=60:band=80:show=0" -vcodec flv -acodec copy OUTPUT.flv

this command deletes the logo which exists at x=10 and y=10 (x=0 and y=0 is top left). h is height and w is width. You can use show=1 to see the location of deleted logo.

Crop video:
ffmpeg -sameq -i INPUT.flv -vf "crop=WIDTH:HEIGHT"
OUTPUT.flv


Thursday, July 11, 2013

Amazon AWS - Changing dynamically Apache Log File name based on Hostname

Change your vhost apache config as follow (the LogFormat writes correct client IPs to log):


LogFormat "\"%{X-Forwarded-For}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_new
CustomLog "|cat >> /shared/log/apache2/`hostname`-access.log" combined_new

Tuesday, July 2, 2013

Mysqldump only tables with certain prefix / Mysqldump wildcards

This commans will dump the tables with prefix PREFIX:

mysql DATABASE -u USERNAME -p -e 'show tables like "PREFIX%"' | grep -v Tables_in | xargs mysqldump DATABASE -u USERNAME -p > DUMP.sql

Monday, June 17, 2013

Install ia32-libs in Debian Wheezy

Since Wheezy introduces multiarch, the ia32-libs package in now deprecated. It is now possible to install 32bit packages directly:
 
dpkg --add-architecture i386 # enable multi-arch
apt-get update
apt-get install libc6:i386 # install base 32bit libraries

Monday, May 13, 2013

Delete files older X days or minutes

This command deletes all files /PATH/TO/FOLDER/YOUR_FILENAME_PATTERN
those older than 45 days:

find /PATH/TO/FOLDER/ -name YOUR_FILENAME_PATTERN -type f -mtime +45  -delete

and this for deleting files older than 30 minutes:

find /PATH/TO/FOLDER/ -name YOUR_FILENAME_PATTERN -type f -mmin +30  -delete

Tuesday, April 30, 2013

How to free Port 80 that already used in Windows 8

Solution 1:
  • Launch RegEdit
  • Find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
  • Change the value of "start" to 4 (disabled)
  • Reboot your computer

Solution 2:

  • Go to Device Manager, select “show hidden devices” from menu/view, go to “Non-Plug and Play Driver”/HTTP, double click it to disable it (and disable or manual some services depended on it).
  • Reboot and use

Tuesday, April 16, 2013

Nagios PNP Warning after upgrade php to 5.3

I got these error and warnings from Nagios after I upgrade my PHP:


Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/nagios/share/pnp/include/function.inc.php on line 1032

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europa/Berlin' for 'Debian/Squeeze' instead in /usr/local/nagios/share/pnp/include/function.inc.php on line 557


Deprecated: Function eregi() is deprecated in /usr/local/nagios/share/pnp/include/function.inc.php 

 To solve this problem you must edit this file: usr/local/nagios/share/pnp/include/function.inc.php

line 556: date_default_timezone_set('UTC');

line 1033: $pdf = new PDF('P', 'mm', 'A4');

line 1543: if($level == 2 && $type == "complete" && preg_match("/^NAGIOS_/",$tag)){






Friday, February 1, 2013

MySQL comparing timestamp with date


To find records older than 30 days using timestamp field:

Select from TableName where from_unixtime(tstamp) < (NOW() - INTERVAL 30 day);



Thursday, January 31, 2013

Extracting the string between two patterns in a file

Supose the file contains this phrase: That is just a test for you

I need to extract the patterns between the words is and test:


 sed -e 's/.*is//' -e 's/test.*$//' /Path-To-Your-File/yourfile.txt

and the result is:

  just a

Tuesday, January 22, 2013

Find out MySQL Time & Zone

for global and session time zone run this query:


mysql> SELECT @@global.time_zone, @@session.time_zone;


for get current time from MySQL Server run this query:

mysql> select now() ;

Monday, December 17, 2012

Find Files By Date

If you need a specific date range, than consider using the find command.

In this example find files modified between 15 December 2012 and 16 December 2012, in /var directory:
 
touch --date "2012-12-15" /tmp/start
touch --date "2012-12-16" /tmp/end
find /var -type f -newer /tmp/start -not -newer /tmp/end

Thursday, December 13, 2012

Forcing qmail to process the queue

Run this command:

kill -ALRM `ps ax | grep qmail-send | grep -v grep | awk '{print $1}'`

Adjusting qmail queue time / lifetime

if you want to adjust how long e-mails will spend in the qmail queue before they're bounced, simple set the queuelifetime:

# echo "86400" > /var/qmail/control/queuelifetime
# /etc/init.d/qmail restart


The above example is for 1 day (qmail needs the time length in seconds). Just take the days and multiply by 86,400 seconds to get your result.