Thursday, November 13, 2014

IPv6 Supernetting Subnetting Ruby

#!/usr/local/bin/ruby -w
require 'ipaddr' 

# /32 CIDR -> /40's (LONG)
(0..255).each { |x|  puts"1234:5678:#{sprintf("%02x",x)}00::0").to_i }

# /32 CIDR -> /48's (LONG)
(0..255).each { |x|  puts"1234:5678:00#{sprintf("%02x",x)}::0").to_i }


$addr = inet_pton($ip);
$unpack = unpack('H*hex', $addr);
$hex = $unpack['hex'];
$arpa = implode('.', array_reverse(str_split($hex))) . '';

Wednesday, September 24, 2014

Kill All Processes In Linux Via Search GREP

Sometimes killall -9 simply doesn't work with all processes and as a result you are left searching/GREPing for process names to kill them off.

This Simplifies this task by killing all processes that are the result of that search:
kill -9 `ps -ef | grep processname | grep -v grep | awk '{print $2}'`

Monday, September 8, 2014

Change Clock Date Time Sync On Xen Linux VPS

Set the following in sysctl.conf on your VPS. This will allow your VPS to have a clock that is not forcibly synced with the host node.
xen.independent_wallclock = 1

Tuesday, July 8, 2014

Cannot Sync Subscription To Service Plan In Plesk

This could be caused by a myriad of issues however as of version 12 there is a limit of 50 subscriptions per service plan. If you have more than 50, it will not sync.

There is a bug report for this under "PPPM-1379".

The solution to the problem is to simply not use Plesk.

Wednesday, July 2, 2014

How To Fix Permissions On Home Directory

This will ensure the user and group match the username in /home (non-recursively)
for i in `ls`; do { chown $i:$i $i; }; done;

Thursday, March 13, 2014

Cannot find or open table wp_kstats_raw

This error usually occurs because the table has crashed or some other INNODB error. Usually its best to just recreate the table from scratch
DROP TABLE IF EXISTS `wp_kstats_raw`;
CREATE TABLE `wp_kstats_raw` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL,
  `ip` int(10) unsigned NOT NULL,
  `url` varchar(1024) NOT NULL,
  `referrer` varchar(1024) NOT NULL,
  `user_agent` varchar(1024) DEFAULT NULL,
  `os` varchar(255) DEFAULT NULL,
  `browser` varchar(255) DEFAULT NULL,
  `search_engine` varchar(255) DEFAULT NULL,
  `search_terms` varchar(255) DEFAULT NULL,
  `spider` varchar(255) DEFAULT NULL,
  `user` varchar(255) DEFAULT NULL,
  `preserved` enum('1') DEFAULT NULL,
  UNIQUE KEY `id` (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `ip` (`ip`),
  KEY `url` (`url`(255))