Skip to content

Instantly share code, notes, and snippets.

@sh2
sh2 / list.sh
Created February 13, 2014 12:05
List start time of MySQL binary logs
#!/bin/bash
for BINLOG in $@; do
echo $BINLOG $(mysqlbinlog $BINLOG 2>/dev/null | awk '/^#[0-9]/ { print $1, $2 }' | head -1)
done
==
$ ./list.sh mysql/binlog/*
mysql/binlog/mysql-binlog.000001 #140206 18:14:57
@sh2
sh2 / rtail.sh
Created August 8, 2012 01:55
Execute tail -f and watch a specific line on a remote host.
#!/bin/bash
TARGET_HOST=localhost
TARGET_FILE=/tmp/test.log
TARGET_LINE='^CRIT'
ssh $TARGET_HOST perl <<_EOF_
use strict;
use warnings;
@sh2
sh2 / my.cnf
Created August 16, 2012 08:35
my.cnf for a windows laptop computer.
[mysqld]
console
## character set
character_set_server = utf8mb4
collation_server = utf8mb4_general_ci
## sql
sql_mode = TRADITIONAL
transaction_isolation = READ-COMMITTED
@sh2
sh2 / fio_summarize.pl
Created September 5, 2012 05:59
fio test/summarize script
#!/usr/bin/perl
use strict;
use warnings;
my (%sequential, %random);
my ($type, $blocksize, $ratio, $iodepth, $header);
while (my $line = <STDIN>) {
@sh2
sh2 / load_csv.ods
Created October 20, 2012 04:55
Load a CSV file to LibreOffice Calc.
Sub Main
oFilePicker = createUnoService("com.sun.star.ui.dialogs.FilePicker")
oFilePicker.appendFilter("Response Files (*_r.csv)", "*_r.csv")
oFilePicker.appendFilter("All Files (*.*)", "*.*")
If oFilePicker.execute() = com.sun.star.ui.dialogs.ExecutableDialogResults.OK Then
sFiles() = oFilePicker.getFiles()
oSheet = ThisComponent.getSheets.getByName("Data")
oSheet.link(sFiles(0), "", "Text - txt - csv (StarCalc)", "44,34,76,1", com.sun.star.sheet.SheetLinkMode.NORMAL)
oSheet.setLinkMode(com.sun.star.sheet.SheetLinkMode.NONE)
@sh2
sh2 / .screenrc
Last active December 10, 2015 17:18
Config file for screen
escape ^z^z
altscreen on
autodetach on
defscrollback 10000
startup_message off
vbell off
caption always '%?%F%{= bW}%:%{= KW}%?%2n%f%06=%t'
hardstatus alwayslastline '%Y/%m/%d %0c %{= .b}%H%{-} %-w%{= bW}%n %t%{-}%+w'
@sh2
sh2 / head_tail.pl
Last active December 14, 2015 12:38
head + tail command
#!/usr/bin/perl
use strict;
use warnings;
my $count = 0;
while (my $line = <STDIN>) {
print $line;
@sh2
sh2 / RouteSearcher.java
Last active December 17, 2015 00:11
Wikipedia Route Search program
package wikipedia.searcher;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayDeque;
import java.util.ArrayList;
@sh2
sh2 / .vimrc
Last active December 19, 2015 03:59
Config file for Vim to use Python
set nocompatible
set t_Co=256
colorscheme default
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/.vim/bundle/'))
@sh2
sh2 / load.pl
Created October 11, 2013 15:30
Parallel restore script for mysqldump
#!/usr/bin/env perl
use strict;
use warnings;
use File::Temp qw/tempfile/;
my ($state, $nprocs) = (0, 0);
my ($fh, $tempfile, @settings);