Skip to content

Instantly share code, notes, and snippets.

View Songmu's full-sized avatar

Masayuki Matsuki Songmu

View GitHub Profile
@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 August 8, 2021 04:39
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)
};
runtime: garbage collector found invalid heap pointer *(0xc08207e720+0x18)=0xf s=nil
runtime: found *(0xc082043988+0x8) = 0xc08207e720+0x0
fatal error: bad pointer
runtime stack:
runtime.throw(0x918359)
c:/go/src/runtime/panic.go:491 +0xad fp=0x2aef9e8 sp=0x2aef9b8
scanblock(0xc082043988, 0x128, 0x813714)
c:/go/src/runtime/mgc0.c:415 +0x990 fp=0x2aefb28 sp=0x2aef9e8
scanframe(0x2aefc30, 0x0, 0x101)