Skip to content

Instantly share code, notes, and snippets.

@shunsugai
shunsugai / event_type_wave_type_stats.sql
Created February 16, 2021 12:06
イベント・潮位別成功率
WITH all_waves AS (
SELECT
CONCAT(
CAST(job_id AS VARCHAR),
'-',
CAST(details.quota_num AS VARCHAR)
) AS wave_id,
job_id,
details.quota_num,
details.event_type.name AS event,
@shunsugai
shunsugai / create_table_for_salmon_run.sql
Created February 16, 2021 11:46
サーモンランの結果をAmazon Athenaで分析するためのCREATE TABLE文
CREATE EXTERNAL TABLE IF NOT EXISTS {your_table_name_here} (
job_score int,
job_result struct<failure_wave: int,
failure_reason: string,
is_clear: boolean
>,
wave_details array<struct<golden_ikura_pop_num: int,
ikura_num: int,
golden_ikura_num: int,
quota_num: int,
z,d=a=%W|ズン ドコ|;s="";until s[z*4+d] do puts c=a.sample;s+=c end;puts "キ・ヨ・シ!"
def zundoko(history = [])
return puts 'キ・ヨ・シ!' if history == ['ズン', 'ズン', 'ズン', 'ズン', 'ドコ']
zundoko(history.last(4) << ['ズン', 'ドコ'].sample.tap { |x| puts x })
end
zundoko
history = []
while history != [0, 0, 0, 0, 1] do
n = rand(2)
history.push(n)
history.shift if history.size > 5
puts n == 0 ? 'ズン' : 'ドコ'
end
puts 'キ・ヨ・シ!'
@shunsugai
shunsugai / read-fingerprint-service.txt
Created June 29, 2015 12:52
FingerprintServiceを読んで気になったこと
http://tools.oesf.biz/android-MNC/xref/com/android/server/fingerprint/FingerprintService.java
=====
532 @Override
533 // Binder call
534 public void authenticate(final IBinder token, final long opId, final int groupId,
535 final IFingerprintServiceReceiver receiver, final int flags, String opPackageName) {
536 checkPermission(USE_FINGERPRINT);
537 if (!canUserFingerPrint(opPackageName)) {
538 return;
539 }
@shunsugai
shunsugai / perm.go
Created December 25, 2014 14:59
Decrypt gesture.key with Golang.
package main
import (
"fmt"
"github.com/kokardy/listing"
"runtime"
"sync"
)
func main() {
@shunsugai
shunsugai / init.el
Created June 3, 2014 15:22
emacs settings
;;
;; init.el
;;
;; -*- mode: emacs-lisp; coding: utf-8; indent-tabs-mode: nil -*-
;; Language
(set-language-environment 'Japanese)
;; Set alt as Meta key
tr = log --graph --all --format=\"%x09%C(cyan bold)%an%Creset%x09%C(yellow)%h%Creset %C(magenta reverse)%d%Creset %s\"
@shunsugai
shunsugai / lazy_demo.rb
Last active December 15, 2015 00:49
Ruby2.0の新機能、lazyを調査中。
# Benchmark of Enumerable#lazy.
# 'production.log' is a log of Rails application that size is 43.6MB.
require 'benchmark'
Benchmark.bm do |x|
x.report('normal') do
100.times do
File.open("./production.log") do |f|
f.each_line.select { |line| line =~ /RoutingError/ }.first(10)