Skip to content

Instantly share code, notes, and snippets.

View Songmu's full-sized avatar

Masayuki Matsuki Songmu

View GitHub Profile

ゲストガイド - 趣味でOSSをやっている者だ

この文書はポッドキャスト番組「趣味でOSSをやっている者だ」のゲストガイドです。

番組概要

趣味でOSSをやっている者だ / Someone who develops OSS for fun / #oss4fun

https://oss4.fun

OSS作家のSongmuがゲストを交えながら趣味や仕事について話すポッドキャスト

@Songmu
Songmu / findCaller.go
Created February 2, 2021 17:16
embed comment into sql
func findCaller() (*runtime.Frame, string) {
// skip starts 6. 0: Callers, 1: findCaller, 2: sqlComment, 3: hooks, 4: proxy-funcs, 5: database/sql, and equals or greater than 6: user-funcs
skip := 6
for {
var rpc [8]uintptr
var i int
n := runtime.Callers(skip, rpc[:])
frames := runtime.CallersFrames(rpc[:])
for i = 0; ; i++ {
frame, more := frames.Next()
<?php
$date_str = '2017-07-25T15:26:16.12+02:00';
$date_str = preg_replace('/^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})(?:(\\.\\d{6})\\d*)?(.*)/', '$1$2$3', $date_str);
$d = DateTime::createFromFormat("Y-m-d\TH:i:s.uP", $date_str);
var_dump($d);
#!/usr/bin/env perl
use 5.014;
use warnings;
use utf8;
use autodie;
use Time::HiRes qw/gettimeofday tv_interval/;
# you need `ghg` command to work it
my $workdir = '.tmp';
my $trial = 100;
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use HTTP::Tiny;
use Encode qw/decode_utf8/;
use JSON::PP qw/encode_json decode_json/;
my $access_token = $ENV{PUSHBULLET_TOKEN};
@Songmu
Songmu / mackerel-plugin-chars.sh
Created February 13, 2018 04:23
原稿の文字数をカウントするMackerelプラグイン
#!/bin/sh
export LANG=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8
words=$(cat /path/to/*.md | wc -m)
echo "writing.chars.hogehoge $words " $(date +%s)
@Songmu
Songmu / rename-nfd.pl
Last active December 11, 2024 09:18
nfdなファイル名をnfcに変換するスクリプト
#!/usr/bin/env perl
use 5.014;
use warnings;
use Encode qw/decode_utf8 encode_utf8/;
use Unicode::Normalize qw/NFC/;
use File::Basename qw/basename dirname/;
use File::Copy qw/move/;
use File::Spec;
for my $file (@ARGV) {
#!/bin/bash
# snow.bash $(date +%s)
set -e
epoch=$1
if ! [[ $epoch =~ ^([0-9]+)$ ]]; then
echo 'Error: valid epoch required'
echo "Usage: $0 \$epoch"
exit 1
fi
echo $(($(expr $epoch \* 1000 - 1288834974657) << 22))
#!/usr/bin/env perl
use 5.014;
use warnings;
use utf8;
use autodie;
use JSON::PP qw/encode_json/;
my $os = shift || 'darwin';
my $cmd = {
darwin => 'brew list --versions',
@Songmu
Songmu / mackerel-graph-builder.html
Last active June 21, 2016 09:27 — forked from stanaka/mackerel-graph-builder.html
save this html as a local file, then open the file.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Mackerel Graph Builder</title>
<script src="https://cdn.jsdelivr.net/lodash/4.13.1/lodash.min.js"></script>
<script type="text/javascript">
var $ = function(id) {
return document.getElementById(id)
};