Skip to content

Instantly share code, notes, and snippets.

Avatar
😉
Nanchatte

Yasuhiro Yamada greymd

😉
Nanchatte
  • Dublin, Ireland
View GitHub Profile
@greymd
greymd / ddst.md
Last active Mar 31, 2018
Detect daylight saving time with date
View ddst.md
$ echo 20180311" "{01..23}":00:00 JST" | xargs -n3 | TZ=America/New_York gdate -f-
Sat Mar 10 11:00:00 EST 2018
Sat Mar 10 12:00:00 EST 2018
Sat Mar 10 13:00:00 EST 2018
Sat Mar 10 14:00:00 EST 2018
Sat Mar 10 15:00:00 EST 2018
Sat Mar 10 16:00:00 EST 2018
Sat Mar 10 17:00:00 EST 2018
Sat Mar 10 18:00:00 EST 2018
@greymd
greymd / pandoc_gfm.md
Created Dec 11, 2017
pandoc_markdown
View pandoc_gfm.md

[1]{.header-section-number} AAA

AAAの紹介をします

[1.1]{.header-section-number} AAAの背景

これはAAAの背景です

@greymd
greymd / inverse-fizzbuzz.md
Last active Sep 24, 2017
Inverse Fizzbuzz with Egison
View inverse-fizzbuzz.md
@greymd
greymd / collection2array.egi
Created Sep 23, 2017
Convert Collection to Array in Egison
View collection2array.egi
(define $collection2array
1#(generate-array (nth $ %1) [1 (length %1)]))
; > (collection2array {a b c})
; (|a b c|)
View gist:3581be4933ec1c8dc52327d435f49356
愛 11100110 10000100 10011011
$ seq 1 1023 | dec2bin | sed 's/^/0000000000/' | grep -oE '.{12}$' | awk -vFS= -vOFS= '{print 111,$1,$2,11,$3,1,$4,$5,$6,$7,1,$8,$9,1,$10,$11,11,$12,11}' | perl -nle 'print pack ("B*", $_);' | grep 生
$ seq 1 1023 | dec2bin | sed 's/^/0000000000/' | grep -oE '.{12}$' | awk -vFS= -vOFS= '{print 111,$1,$2,11,$3,1,$4,$5,$6,$7,1,$8,$9,1,$10,$11,11,$12,11}' | perl -nle 'print pack ("B*", $_);' | grep 死
@greymd
greymd / gist:cfc37da72e7f2313b70d56eb68e6f0dc
Created Sep 14, 2017
Bmp file analysis with ShellScript
View gist:cfc37da72e7f2313b70d56eb68e6f0dc
# Extract size from information header. 14 is the octet length of file header.
od -tx1 -An flower.bmp \
| tr -dc 'a-z0-9' \
| fold -w 2 \
| sed -n '14,15p' \
| tr -d '\n' \
| sed 's/./\U&/g;s/^/obase=10;ibase=16;/' \
| awk 1 \
| bc \
| awk '{print $1+14}'
View gist:19f08965bda7364dd07b5fdf01fc8fd9
$ convert -background white -fill black -font ~/Library/Fonts/GenEiGothicP-Bold.otf -pointsize 48 label:和歌山 pbm:- | pbmtoascii
oo
ooooMMMo o oooo o oooo ooo oo o MMMMMM MoMMoo
o ooooMoMMMMMMMMMMo MMMMMMMMMMMMMMMMMMMMMMMM MMMMM" MMMMMM
MMMMMMMMMMMMMMMMM""" MMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMMMMMM oMMMMM MMMMMM
"MMMMMMMMMMMM" "MMMMMMMMMMMMMMMMMMM MMMMM MMMMMM o MMMMMM
" MMMMMM MMMMMMMM"M""MMMMMMM MMMMMMMMMMM" MMMMM oMMMMMMMMMMMMMMMMMMM MMMMMM
@greymd
greymd / gist:d89a2fd6605771c2273118b047b7b5ae
Last active Jul 28, 2017
Wikipediaの数の性質を500まで集める
View gist:d89a2fd6605771c2273118b047b7b5ae
# スクレイピング
seq 500 \
| while read n;do echo "$n"; w3m -dump -cols 999 "https://ja.wikipedia.org/wiki/$n" | sed -n '/性質\[編集\]/,/\[編集\]/p' > "$n" ;done
# 最も性質が多い数は。。
seq 500 | while read f; do echo -n "$f "; cat "$f" | grep '•' | grep -c .; done | sort -k2,2n
.
.
.
@greymd
greymd / same2.egi
Created Jul 27, 2017
Filter numbers which has 2 same factors with Egison
View same2.egi
#!/usr/bin/env egison
(define $main
(lambda [$args]
(each display
(farray-same2 farray))))
(define $farray
(filter 1#(eq? (length %1) 3)
(map (p-f $) (take 100 nats))))
@greymd
greymd / make_init.php.bash
Created Jul 25, 2017
Create loading file from multiple php class files under lib directory.
View make_init.php.bash
#!/bin/bash
THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%N}}")"; pwd)"
files=("$(find ${THIS_DIR-}/lib -type f)")
class_lines=("$(printf '%s\n' "${files[@]}" \
| xargs -n 1 grep -m 1 -E '^(abstract )?class' \
| sed -r 's/^.*class ([A-Za-z]+)/\1/')")
class_names=("$(printf '%s\n' "${class_lines[@]}" | awk '{print $1}')")
remove_buildin_classes () {
You can’t perform that action at this time.