Skip to content

Instantly share code, notes, and snippets.

View jhannah's full-sized avatar

Jay Hannah jhannah

View GitHub Profile
@jhannah
jhannah / gist:727739
Created December 3, 2010 23:52
qwerty -> dvorak
$qwerty = q#\-=qwertyuiop[]asdfghjkl;'zxcvbnm,.\/_+QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?#;
$dvorak = q#[]',.pyfgcrl\/=aoeuidhtns\-;qjkxbmwvz{}"<>PYFGCRL?+AOEUIDHTNS_:QJKXBMWVZ#;
$_ = $ARGV[0];
eval "tr/$qwerty/$dvorak/";
print "DVORAK: $_", "\n";
@jhannah
jhannah / gist:801070
Created January 28, 2011 21:55
use utf8;
# use utf8;
# Wow. Simply including the 'use' statement changes this program's behavior
my $str = 'After School - Someone is You / 애프터스쿨 - Someone is You [Audio]';
printf("[%s]\n", substr($str, 0, 40));
printf("[%s]\n", substr($str, 0, 34));
#print utf8::is_utf8($str) ? "yes\n" : "no\n";
[ps35512]$ ./cpanm Nagios::Plugin
Fetching http://search.cpan.org/CPAN/authors/id/T/TO/TONVOON/Nagios-Plugin-0.35.tar.gz ... OK
!
! Can't write to /usr/local/share/perl/5.10.0 and /usr/local/bin: Installing modules to /home/cm_satin/perl5
! To turn off this warning, you have to do one of the following:
! - run me as a root or with --sudo option (to install to /usr/local/share/perl/5.10.0 and /usr/local/bin)
| - run me with --local-lib option e.g. cpanm --local-lib=~/perl5
! - Set PERL_CPANM_OPT="--local-lib=~/perl5" environment variable (in your shell rc file)
! - Configure local::lib in your shell to set PERL_MM_OPT etc.
!
@jhannah
jhannah / gist:810202
Created February 3, 2011 21:05
vh_finished.pl
mysql> select *
-> from harvester_runs
-> where script_name like '%video_harvester%'
-> and start_time is not null
-> and stop_time is not null
-> and date(start_time) = curdate()
-> limit 1
-> ;
Empty set (0.00 sec)
@jhannah
jhannah / gist:844863
Created February 26, 2011 02:16
Form::Sensible set_selection()
In the Controller...
my $choose1 = Form::Sensible->create_form({
name => 'choose_group',
fields => [
{
field_class => 'Select',
name => 'which_group',
accepts_multiple => 0,
options_delegate => FSConnector( sub { $all_profile_groups } ),
@jhannah
jhannah / gist:848488
Created March 1, 2011 02:27
apt-get install cmake
[ps35512]$ sudo apt-get install cmake
[sudo] password for cm_admin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run `apt-get -f install' to correct these:
The following packages have unmet dependencies:
cmake: Depends: libxmlrpc-c3 but it is not going to be installed
nagios-plugins: Depends: nagios-plugins-basic but it is not going to be installed
nagios-plugins-standard: Depends: nagios-plugins-basic (>= 1.4.5-2) but it is not going to be installed
jhannah@Jay-Hannahs-iMac:~/src/sandbox/jsteele$ ls -al
total 16
drwxr-xr-x 4 jhannah staff 136 Mar 1 14:09 .
drwxr-xr-x 40 jhannah staff 1360 Mar 1 14:08 ..
-rw-r--r-- 1 jhannah staff 464 Mar 1 14:09 MTAPdatabase_test
-rwxr-xr-x 1 jhannah staff 43 Mar 1 14:09 run.sh
jhannah@Jay-Hannahs-iMac:~/src/sandbox/jsteele$ python -m unittest -v MTAPdatabase_test
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 121, in _run_module_as_main
"__main__", fname, loader, pkg_name)
@jhannah
jhannah / gist:855947
Created March 5, 2011 00:07
mylvmbackup
sudo apt-get install lvm2
sudo apt-get install mylvmbackup
jhannah@li202-203:~/src$ sudo mylvmbackup --socket=/home/cm_satin/mysql-repl/mysql.sock
20110304 23:19:14 Info: Connecting to database...
20110304 23:19:14 Info: Running hook 'preflush' as perl module.
20110304 23:19:14 Info: Flushing tables with read lock...
20110304 23:19:14 Info: Taking position record into /tmp/mylvmbackup-backup-20110304_231914_mysql-hfUKiZ.pos...
20110304 23:19:14 Info: Running: lvcreate -s --size=5G --name=data_snapshot /dev/mysql/data
File descriptor 4 (socket:[113294]) leaked on lvcreate invocation. Parent PID 1669: /usr/bin/perl
linode main:
mysql> select username, created from users where date(created) >= '2011-03-01';
+-----------------+---------------------+
| username | created |
+-----------------+---------------------+
| nanaki_rogue | 2011-03-01 00:33:46 |
| monkyt | 2011-03-01 02:25:09 |
| greig.barclay | 2011-03-02 01:16:54 |
| carnaval | 2011-03-03 16:33:30 |
@jhannah
jhannah / gist:859047
Created March 7, 2011 19:30
mysql fun
17:52 <@jhannah> gak. load ground to a halt at 15.8M rows
17:53 <@jhannah> index size is twice the data size, so i'm thinking load then create indexes as next
attempt
17:54 <@jhannah> apparently load velocity is some sort of reverse exponential curve
17:54 <@jhannah> over a few millions rows
17:55 <@jhannah> | table_name | table_rows | data_length | index_length | Size(MB) |
17:55 <@jhannah> +----------------------------+------------+-------------+--------------+----------+
17:55 <@jhannah> | video_stats | 15822097 | 1758461952 | 3214934016 | 4743.00 |
17:57 <@jhannah> oh shit -- amor disk is full
17:58 <@jhannah> Filesystem Size Used Avail Use% Mounted on