Skip to content

Instantly share code, notes, and snippets.

View kaz-utashiro's full-sized avatar

Kazumasa Utashiro kaz-utashiro

View GitHub Profile
@kaz-utashiro
kaz-utashiro / cdif.el
Created April 3, 2014 08:04
Emacs のバッファに対して cdif を実行する関数。本当は、コマンドの実行にした場合のエラー処理を入れたいんだが、やり方がわからない。失敗したら undo してください。
;;; cdif.el --- cdif and ansi-color interface
;;; Code:
(autoload 'ansi-color-apply-on-region "ansi-color" nil t)
(defun cdif-buffer (&optional prefix)
"Execute cdif command on current buffer and apply ansi-color."
(interactive "P")
(if prefix
@kaz-utashiro
kaz-utashiro / file0.txt
Created April 26, 2014 08:21
Perl の @- と @+ のペナルティが高すぎる ref: http://qiita.com/kaz-utashiro/items/2facc87ea9ba25e81cd9
while (/pattern/g) {
my($s, $e) = ($-[0], $+[0]);
...
@kaz-utashiro
kaz-utashiro / file0.txt
Last active August 29, 2015 14:07
Mavericks コマンドラインキッチンタイマー「ゴージャスラーメン」オプション ref: http://qiita.com/kaz-utashiro/items/72f9e4c089c46210dec4
tir -rGRc10
@kaz-utashiro
kaz-utashiro / Golden Ratio Superellipse by Gnuplot
Last active December 29, 2015 09:39
Golden Ratio Superellipse by Gnuplot
set border lw 0.1
set samples 1000
set title "x^2.8 + (y/1.6)^2.8 = 1"
n = 2.8
h = 1.6
unset key
set size ratio h
set xr[0:1.0]
set yr[0:h]
@kaz-utashiro
kaz-utashiro / supereellipse.pl
Created November 26, 2013 01:06
スーパー楕円の座標を計算する
use Math::Trig;
my $m = 1.6;
my $b = 2.8;
for (my $theta = 90; $theta >= 0; $theta -= 5 ){
my $x = cos($theta / 180 * pi);
$y = $m * (1 - $x ** $b) ** (1/$b);
printf "x=%f, %f, %f\n", $x, $x * 300, $y * 300;
}
@kaz-utashiro
kaz-utashiro / greplerc-ical-data
Last active December 30, 2015 02:19
.greplerc to search iCal data by greple command
# ~/.greplerc
option --ical_data \
--chdir ~/Library/Calendars/*.caldav/*.calendar/Events \
--glob *.ics
@kaz-utashiro
kaz-utashiro / greplerc-ical-byline
Last active December 30, 2015 02:28
.greplrc definition to search iCal data and display in single line
######################################################################
# iCal
######################################################################
option --ical_data \
--chdir ~/Library/Calendars/*.caldav/*.calendar/Events \
--glob *.ics
help --ical Search iCal data
option --ical \
--all \
#!/usr/bin/perl
use strict;
my %freq;
while (<>) {
chomp;
map { $freq{$_}++ } split //;
}
@kaz-utashiro
kaz-utashiro / App::Greple::perl.pm
Created December 15, 2013 08:40
Greple module to handle perl script.
=head1 NAME
perl - Greple module for perl script
=head1 SYNOPSIS
greple -Mperl [ options ]
=head1 SAMPLES
@kaz-utashiro
kaz-utashiro / print_wdiff.pl
Last active January 1, 2016 13:59
print function to remove wdiff control sequence for greple command
sub print_wdiff {
my %arg = @_;
my @matched = @{$arg{matched}};
for (my $i = $#matched; $i >= 0; $i--) {
my($s, $e) = @{$matched[$i]};
my $t = substr($_, $s, $e - $s);
if ($t =~ s/\A (?:\{\+|\[\-) (.*) (?:\+\}|\-\]) \Z/$1/sx) {
substr($_, $s, $e - $s) = $t;
$matched[$i][0] = $s - $i * 4;