$ min-interval-exec 5 date
Wed Mar 21 00:08:38 JST 2018
$ sleep 3
$ min-interval-exec 5 date
$ sleep 2
$ min-interval-exec 5 date
Wed Mar 21 00:08:44 JST 2018
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"io" | |
"log" | |
"net" | |
"sync" | |
"time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.12.0; | |
use Benchmark qw/:all/; | |
my @src = 1 .. 1000; | |
cmpthese 0, { | |
push => sub { | |
my @dest; | |
for (@src) { | |
push @dest, $_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -H"X-Mirror1: 127.0.0.1:5000" -H"X-Mirror2: 127.0.0.1:5001" -H"X-Mirror3: 127.0.0.1:5002" localhost:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aws = require('aws-sdk'); | |
const cw = new aws.CloudWatch({region: 'us-east-1'}); | |
const sns = new aws.SNS(); | |
exports.handler = (event) => { | |
const endTime = new Date(); | |
const startTime = new Date(); | |
startTime.setDate(endTime.getDate() - 2); // 2 days ago | |
const param = { | |
MetricName: 'EstimatedCharges', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"mime" | |
"net/http" | |
"net/mail" | |
"net/url" | |
"os" | |
"strings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
repo="$1" # fujiwara/foo | |
tag="$2" # v0.1.0 | |
name="$3" # foo-0.1.1-linux-amd64.zip | |
releases=$(curl -s -H "Authorization: token ${TOKEN}" "https://api.github.com/repos/${repo}/releases/tags/${tag}") | |
url=$(echo "$releases" | jq -r ".assets[] | select(.name == \"${name}\").url") | |
echo $url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main.Config{Foo:main.MaybeBool{b:false, isSet:true}, Bar:main.MaybeBool{b:false, isSet:false}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Benchmark = require('benchmark'); | |
var suite = new Benchmark.Suite; | |
suite.add('indexOf', function() { | |
var s = "time:2017-01-01T11:22:33Z" | |
var i = s.indexOf(":") | |
return [ s.slice(0,i), s.slice(i+1) ]; | |
}) | |
.add("replace\\0", function() { | |
var s = "time:2017-01-01T11:22:33Z" | |
return s.replace(":", "\0").split("\0"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ResovedAddress = make(map[string][]string) | |
var mu sync.RWMutex | |
func Dialer(network, addr string) (net.Conn, error) { | |
host, port, _ := net.SplitHostPort(addr) | |
mu.RLock() | |
addrs, found := ResovedAddress[host] | |
mu.RUnlock() | |
if found { | |
// log.Println("cache hit for", host) |