Skip to content

Instantly share code, notes, and snippets.

View xtetsuji's full-sized avatar

OGATA Tetsuji xtetsuji

View GitHub Profile
@xtetsuji
xtetsuji / phs
Created January 15, 2018 04:01
peco -> hostlist -> ssh, simple script. This script is beta quality because now I think this script is dirty.
#!/bin/bash
# phs - popup host ssh
# xtetsuji 2016/11/17
if [ "$1" ] && [ "_$1" = _-h -o "_$1" = _--help ] ; then
exec perldoc $0
fi
declare DEBUG
declare PHS_SCREEN_COMMAND PHS_TMUX_COMMAND PHS_OPEN_MODE PHS_SSH_COMMAND
@xtetsuji
xtetsuji / recursive-sum-digit.pl
Created November 17, 2017 06:37
Recursive sum of each decimal places. This output is in 9 cycle.
#!/usr/bin/perl
use strict;
use warnings;
use constant MAX_NUMBER => 1_000_000;
use List::Util qw(sum);
my %stat;
for (my $i = 1; $i < MAX_NUMBER; $i++) {
@xtetsuji
xtetsuji / pptar
Last active October 30, 2017 06:28
progress printing tar command, alpha quality :)
#!/bin/bash
# xtetsuji 2017/10/30
# pptar - progress printing tar
# This is alpha quality :)
# https://twitter.com/xtetsuji/status/924861905893593088
SLEEP_SECONDS=1
TAR_FILE_LOG=/tmp/tar_file.$$.log
function kill_children {
@xtetsuji
xtetsuji / refsub.pl
Created September 7, 2017 13:49
How to write subroutine which gives reference of its argument.
#!/usr/bin/perl
use strict;
use warnings;
# chomp2
# Is this chomp?
# chomp erases only ONE "\n" on end of scalar.
# chomp2 erases ALL continuous "\n" on end of scalar.
sub chomp2 (\$) {
@xtetsuji
xtetsuji / linux-gdrive-install.sh
Last active August 28, 2017 14:46
gdrive linux command installer
#!/bin/bash
# xtetsuji 2017/08/28
# linux-gdrive-install.sh
#
# e.g.
# curl -L https://git.io/v5GCK | bash
#
# This script is store as
# https://git.io/v5GCK
# and
@xtetsuji
xtetsuji / days_ago.pl
Last active August 21, 2017 21:57
days_ago subroutine sample. confirmation number of arguments for safety.
#!/usr/bin/perl
use strict;
use warnings;
sub days_ago {
# 1引数か2引数かを厳密に見る
my ($time, $n);
if ( @_ == 1 ) {
$time = shift;
@xtetsuji
xtetsuji / wp-cli-install.sh
Last active August 20, 2017 05:18
wp-cli installer. it is simple and tiny.
#!/bin/bash
# e.g.
# ssh server "curl -L git.io/v7xmi | bash"
# This script is stored as
# git.io/v7xmi
# and
# https://gist.github.com/xtetsuji/e620792db74640a81906920b9254ec81
set -eu
@xtetsuji
xtetsuji / libniz-series.pl
Created July 17, 2017 15:51
Trying sum of Libniz series. It convergence is too late.
#!/usr/bin/perl
use strict;
use warnings;
use Math::Trig qw(pi);
use constant MAX_NUMBER => 100_000;
use constant MAX_NUMBER_LENGTH => length MAX_NUMBER;
@xtetsuji
xtetsuji / chrome-wand
Created July 6, 2017 15:45
Google Chrome tab selection via terminal/shell for macOS
#!/usr/bin/env perl
use strict;
use warnings;
use Scalar::Util qw(openhandle);
use IPC::Open2 qw(open2);
use Getopt::Long qw(:config posix_default no_ignore_case bundling auto_help);
use Pod::Usage qw(pod2usage);
@xtetsuji
xtetsuji / bs-code-detect.pl
Last active June 28, 2017 05:45
BS code detecter for Mac Slack (and/or Chromium?)
#!/usr/bin/env perl
# bs-code-detect.pl [--daemon] [--replace [--pasteback]] [--silent]
use strict;
use warnings;
use Term::ANSIColor qw(colored);
use Getopt::Long qw(:config posix_default no_ignore_case bundling auto_help);
use Mac::Pasteboard ();