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 / 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 //;
}
#include <unistd.h>
#include <curses.h>
char *sl[] = {
" o o o",
" o ",
" o ____ ",
" -- |OO| ",
" _||__| | ",
" | | ",
@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 / temp var declaration
Last active March 12, 2019 09:35
1行しか必要でない変数をどうやって宣言するかという話。カッコいい書き方はないものだろうか。
## なんとなく嫌だ
my %seen;
@opt_icode = grep { not $seen{$_}++ } @opt_icode;
## ダサい
{
my %seen;
@opt_icode = grep { not $seen{$_}++ } @opt_icode;
}
@kaz-utashiro
kaz-utashiro / App::Greple::diff.pm
Last active March 27, 2018 01:13
Greple command module for colorise diff output.
package App::Greple::diff;
1;
=head1 NAME
diff - greple module for diff command output
=head1 SYNOPSIS
@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;