Skip to content

Instantly share code, notes, and snippets.

package main
import (
"errors"
"fmt"
"log"
"math/rand"
"sync"
"time"
)
docker image ls --format '{{.CreatedAt}}\t{{.ID}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}' | sort -k4 -t $'\t'
#!/bin/sh
set -eu
input=$1
output=$2
time=$3
fade_out_duration=0.5
fade_in_duration=0.5
@knzm
knzm / main.go
Last active August 2, 2018 16:01 — forked from podhmo/main.go
package main
import (
"fmt"
"sort"
)
func formatIntPtr(fmtstr, nilstr string, p *int) string {
if p == nil {
return nilstr
#titlebar-buttonbox {
display: block !important;
vertical-align: top !important;
}
.tabbrowser-arrowscrollbox scrollbox {
overflow: visible !important;
}
.tabbrowser-arrowscrollbox scrollbox > box {
display: block !important;
}
.PHONY: target clean clean-video-objs clean-audio-objs metadata pass1 pass2
video_width := 432
# video_crf := 23
video_bitrate := 192000
# video_2pass = no
ifeq ($(video_2pass),)
ifdef video_bitrate
video_2pass = yes
@knzm
knzm / cf-cloudfront-template.yml
Created April 19, 2018 13:28
CloudFormation template for CloudFront distribution, where a custom domain is used only in one environment (prod)
AWSTemplateFormatVersion: 2010-09-09
Parameters:
Env: {Type: String, Default: dev, AllowedValues: [dev, stg, prod]}
CanonicalName:
Type: String
Description: CNAME for the distribution.
CloudFrontDefaultCertificate:
Type: String
AllowedValues: [true, false]
Default: true
@knzm
knzm / index.md
Created February 16, 2018 11:49
本日の yak shaving

久しぶりに vagrant を使うので、 box を update しようとしたら変なエラーが出た。

$ vagrant box outdated --global
* 'ubuntu/xenial64': Error loading metadata: The requested URL returned error: 404 Not Found
* 'ubuntu/trusty64': Error loading metadata: The requested URL returned error: 404 Not Found
* 'centos/6': Error loading metadata: The requested URL returned error: 404 Not Found
* 'centos/7': Error loading metadata: The requested URL returned error: 404 Not Found
package main
import (
"encoding/json"
"fmt"
)
type Response struct {
Status string `json:"status"`
Error string `json:"error"`
$ go run json_ordered2.go
==== map[string]interface{} ====
Unmarshal: &map[string]interface {}{"bbb":10, "abc":20, "aaa":30}
{"aaa":30,"abc":20,"bbb":10}
==== FieldMap ====
Unmarshal: &main.FieldMap{"bbb":main.Field{Order:0x1, Value:10}, "abc":main.Field{Order:0x2, Value:20}, "aaa":main.Field{Order:0x3, Value:30}}
{"bbb":10,"abc":20,"aaa":30}