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 / order_by.sql
Created October 20, 2013 16:16
ORDER BY狙いのインデックス
CREATE TABLE `customer` (
`c_id` int(11) NOT NULL,
`c_d_id` tinyint(4) NOT NULL,
`c_w_id` smallint(6) NOT NULL,
`c_first` varchar(16) DEFAULT NULL,
`c_middle` char(2) DEFAULT NULL,
`c_last` varchar(16) DEFAULT NULL,
`c_street_1` varchar(20) DEFAULT NULL,
`c_street_2` varchar(20) DEFAULT NULL,
`c_city` varchar(20) DEFAULT NULL,
@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);
@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 / 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 / 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 / .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 / 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 / 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 / tpc-ds_warehouse.sql
Created August 28, 2012 11:58
TPC-DS warehouse table for MySQL
-- dimension tables
CREATE TABLE warehouse (
w_warehouse_sk INT NOT NULL,
w_warehouse_id CHAR(16) NOT NULL,
w_warehouse_name VARCHAR(20),
w_warehouse_sq_ft BIGINT,
w_street_number CHAR(10),
w_street_name VARCHAR(60),
w_street_type CHAR(15),