Skip to content

Instantly share code, notes, and snippets.

View DavidGoodwin's full-sized avatar
🐮

David Goodwin DavidGoodwin

🐮
View GitHub Profile
@DavidGoodwin
DavidGoodwin / lxc_cpu_top.py
Last active April 9, 2017 22:08 — forked from wryfi/lxc_load.py
simple python script to check cpu utilization of lxc containers and print percentage
#!/usr/bin/python
# See https://gist.github.com/wryfi/3902757
# Crude CPU usage thing for container(s).
import multiprocessing, os, re, sys, time
import getopt
cgroup_dir = '/sys/fs/cgroup/lxc/'
SELECT table_schema,
table_name,
data_type,
( CASE data_type
WHEN 'tinyint' THEN 255
WHEN 'smallint' THEN 65535
WHEN 'mediumint' THEN 16777215
WHEN 'int' THEN 4294967295
WHEN 'bigint' THEN 18446744073709551615
end >> IF(Locate('unsigned', column_type) > 0, 0, 1) ) AS MAX_VALUE,
<?php
/*
INSTRUCTIONS: Use at your own risk. Backup your database before continuing.
1. Copy code to a file in the root of your website.
2. Change YOUR_SITE_ROOT to a value that makes sense.
3. Execute by visiting the page. Verify before/after results.
4. Change MAKE_CHANGES_TO_SITE to true and execute it again.
*/
<?php
/*
INSTRUCTIONS:
Use at your own risk. Backup your database before continuing.
1. Copy code to a file in the root of your website.
2. Change YOUR_SITE_ROOT to a value that makes sense.
3. Execute by visiting the page. Verify before/after results.
4. Change MAKE_CHANGES_TO_SITE to true and execute it again.
<?php
/* Original effort: https://gist.github.com/Daniel15/5991193 */
function last($arr)
{
eval('list(' . str_repeat(',', count($arr) - 1) . '$result) = $arr;');
return $result;
}