This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| v_bytes=`varnishstat -1 | grep s0.g_bytes | awk '{print $2}'` | |
| v_space=`varnishstat -1 | grep s0.g_space | awk '{print $2}'` | |
| v_total=$(( v_bytes + v_space )) | |
| v_percent=$(( 100 * v_bytes / v_total )) | |
| v_total_mb=$(( v_total/1024/1024 )) | |
| v_bytes_mb=$(( v_bytes/1024/1024 )) | |
| echo $v_percent % \($v_bytes_mb / $v_total_mb MB\) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| /usr/bin/varnishadm quit >/dev/null 2>&1 | |
| RETVAL=$? | |
| if [ $RETVAL -eq 2 ] | |
| then | |
| /etc/init.d/varnish restart | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| root@rescue:~# mkdir --parent /dev/md | |
| root@rescue:~# mdadm --assemble --scan --auto=yes --symlink=no | |
| mdadm: /dev/md/le02:1 has been started with 1 drive (out of 2). | |
| mdadm: /dev/md/le02:0 has been started with 1 drive (out of 2). | |
| root@rescue:~# cat /proc/mdstat | |
| Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] [faulty] | |
| md126 : active raid1 sdb1[1] | |
| 40957880 blocks super 1.2 [2/1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pytz | |
| from datetime import datetime, timedelta | |
| time_cet = datetime(2013,04,18, 6,0,0, tzinfo=pytz.utc) | |
| for tz in pytz.all_timezones: | |
| print tz.ljust(30), time_cet.astimezone(pytz.timezone(tz)).strftime('%Y %B %d, %H:%M') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int r; | |
| int g; | |
| int b; | |
| if (point <= 128) // 1/8 | |
| { | |
| r = 0; | |
| g = 0; | |
| b = 127 + point; // 0.5 ... 1 | |
| } | |
| else if (point <= 384) // 3/8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [program:redmine] | |
| command = /usr/bin/ruby /path/to/redmine/script/fastcgi | |
| process_name = redmine | |
| autostart = true | |
| startsecs = 40 | |
| user = www-data | |
| redirect_stderr = true | |
| stdout_logfile = /var/log/redmine.log | |
| environment = RAILS_ENV=production |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Run me from scripts/ | |
| require File.dirname(__FILE__) + "/../config/environment" | |
| require 'fcgi_handler' | |
| require 'ruby_version_check' | |
| require 'initializer' | |
| require 'dispatcher' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Add noatime option to fstab for all ext* filesystems | |
| # | |
| sed -i -r 's/(ext[2-4]\s+)defaults\s/\1defaults,noatime /g' /etc/fstab |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # mass change prefixes in Joomla database | |
| # massivescale.net 2012 | |
| # | |
| echo "SELECT concat('rename table ', table_name, ' to ', 'iddqd', substr(table_name,4), ';') FROM information_schema.tables WHERE table_name like 'jos%';" | mysql | tail -n +2 | mysql `grep db\ /var/www/configuration.php | awk -F"'" '{print $2}'` | |
| sed -i -e 's/jos_/iddqd_/' /var/www/configuration.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # | |
| # Some command in the system being called in mysterious conditions? | |
| # Use the logging wrapper! | |
| # It will log all calls of a command along with process tree | |
| # ("stack trace" of all calling processes) | |
| # | |
| # Usage: | |
| # pip install psutil | |
| # mv /usr/bin/snoopedcommand /usr/bin/snoopedcommand_wrapped |