Skip to content

Instantly share code, notes, and snippets.

Avatar

shunsugai shunsugai

  • non
  • Japan
View GitHub Profile
View zundoko_one.rb
z,d=a=%W|ズン ドコ|;s="";until s[z*4+d] do puts c=a.sample;s+=c end;puts "キ・ヨ・シ!"
View zundoko_recursive.rb
def zundoko(history = [])
return puts 'キ・ヨ・シ!' if history == ['ズン', 'ズン', 'ズン', 'ズン', 'ドコ']
zundoko(history.last(4) << ['ズン', 'ドコ'].sample.tap { |x| puts x })
end
zundoko
View zundoko.rb
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 Jun 29, 2015
FingerprintServiceを読んで気になったこと
View read-fingerprint-service.txt
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 Dec 25, 2014
Decrypt gesture.key with Golang.
View perm.go
package main
import (
"fmt"
"github.com/kokardy/listing"
"runtime"
"sync"
)
func main() {
@shunsugai
shunsugai / init.el
Created Jun 3, 2014
emacs settings
View init.el
;;
;; init.el
;;
;; -*- mode: emacs-lisp; coding: utf-8; indent-tabs-mode: nil -*-
;; Language
(set-language-environment 'Japanese)
;; Set alt as Meta key
View .gitconfig
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 Dec 15, 2015
Ruby2.0の新機能、lazyを調査中。
View lazy_demo.rb
# 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)
@shunsugai
shunsugai / inject.rb
Last active Dec 13, 2015
たぶんこれでOK
View inject.rb
require 'pp'
data = [
{:code => 001, :item => {:name => 'jan'}},
{:code => 001, :item => {:name => 'jan'}},
{:code => 001, :item => {:name => 'aaa'}},
{:code => 002, :item => {:name => 'feb'}},
{:code => 002, :item => {:name => 'aab'}},
{:code => 003, :item => {:name => 'mar'}},
{:code => 003, :item => {:name => 'abb'}},
View define_method.rb
#かなり雑だけどこんな書き方もできる
class Bar
def initialize(options={})
@options = options
end
def method_missing(name, *args)
if name =~ /=$/
@options[name.to_s.chop.to_sym] = args.first
else
You can’t perform that action at this time.