Skip to content

Instantly share code, notes, and snippets.

View lestrrat's full-sized avatar

lestrrat lestrrat

View GitHub Profile
// https://github.com/lestrrat-go/jwx/blob/129e8b1d3bc86038ded5b41e8720b120194074f8/examples/jwk_parse_key_example_test.go
package examples_test
import (
"encoding/json"
"fmt"
"os"
"github.com/lestrrat-go/jwx/v2/jwk"
)
// https://github.com/lestrrat-go/jwx/blob/129e8b1d3bc86038ded5b41e8720b120194074f8/examples/jwt_builder_example_test.go
package examples_test
import (
"encoding/json"
"fmt"
"os"
"github.com/lestrrat-go/jwx/v2/jwt"
)
package examples_test
import (
"fmt"
"net/http"
"net/url"
"strings"
"github.com/lestrrat-go/jwx/v2/jwt"
)
@lestrrat
lestrrat / ripple.pl
Last active September 27, 2021 05:09
"Ripple" shift the contents of an SBV file
#!perl
# perl ripple.pl $ref $delta file.sbv
use strict;
use POSIX qw(floor);
# $ref is the time code (in seconds) where the ripple should start
my $ref = shift @ARGV;
lestrrat@finch bench % benchstat -sort -delta stdlib.txt v0.4.2.txt
name old time/op new time/op delta
JWK/Serialization/RSA/PrivateKey/jwk.Parse-8 50.0µs ± 1% 15.8µs ± 8% -68.40% (p=0.008 n=5+5)
JWK/Serialization/RSA/PrivateKey/jwk.ParseString-8 50.4µs ± 1% 18.5µs ±15% -63.23% (p=0.008 n=5+5)
JWK/Serialization/EC/PrivateKey/jwk.Parse-8 15.6µs ± 1% 5.8µs ± 5% -63.11% (p=0.008 n=5+5)
JWK/Serialization/EC/PrivateKey/jwk.ParseString-8 15.9µs ± 3% 5.9µs ± 2% -62.64% (p=0.008 n=5+5)
JWK/Serialization/RSA/PrivateKey/jwk.ParseReader-8 50.9µs ± 1% 19.2µs ± 6% -62.31% (p=0.008 n=5+5)
JWK/Serialization/EC/PrivateKey/jwk.ParseReader-8 15.7µs ± 1% 6.0µs ± 4% -61.50% (p=0.008 n=5+5)
JWS/Serialization/JSON/jws.Parse-8 21.1µs ± 1% 8.3µs ± 2% -60.65% (p=0.008 n=5+5)
JWS/Serialization/JSON/jws.ParseString-8 21.3µs ± 2%
@lestrrat
lestrrat / translation2srt.pl
Last active November 17, 2020 23:23
開始時間/終了時間/英語/日本語 の4つのカラムのTSVファイルから、日本語訳文をSRTファイル形式に整形するツール。1行目にヘッダがある想定。使い方はコメントの中に。
#
# Preparation:
#
# 1. Install perl5, cpanm
# 2. cpanm -L local -n Text::CSV_XS
#
# Execution:
#
# perl script.pl source.tsv
#
@lestrrat
lestrrat / rename.pl
Created December 20, 2019 00:44
卒園式のDVD作るのに特定の命名規則に沿った写真ファイルを送ってこいって指令があったので…
use strict;
use lib "local/lib/perl5";
use Data::Dumper;
use Image::ExifTool qw(:Public);
use Time::Piece;
my $name = "___CHILD'S_NAME___";
my @files;
for my $file (glob("*.jpg")) {
#!/bin/bash
# Installs mariadb in Debian 9 GCP VM, creates self-signed certificates,
# sets up the server config, and restarts the mysql server
set -e
set -x
apt-get update
apt-get install -y mysql-server
# App Engine Standard Go 1.9 migration to Go 1.11
tag:["google-app-engine", "Go"]
Migrating from Go 1.9 to 1.11 in App Engine Standard isn't just a matter of updating Go itself -
it introduces a major update in the runtime itelf. Because of this, you can't just change your
code to work on Go 1.11 and expect it to be deployed properly. You will need to work on a few
more issues.
This article describes the new runtime known as the Google App Engine Standard 2nd Gen,
@lestrrat
lestrrat / update-healthcheck.sh
Created October 30, 2018 04:54
Ever wanted to make health checks for GCP LBs (created from GKE ingress objects) to look at Cloud Endpoint's ESP server's alternate health check port? Well you're in luck, my friend.
#!/bin/bash
set -e
# Script to configure the healthcheck for ESP
# (ESP listens on a separate port from the main port for healthchecks)
SERVICE_NAME="This the name of your service that you proxy your requests to"
ESP_HEALTH_CHECK_PORT_NAME="This is the name of the port that ESP listens for health checks."
ESP_MAIN_PORT_NAME="This is the name of the port that ESP listens for the actual service."