This file contains hidden or 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
| // Call from Activity | |
| String url; | |
| public void loadUrl(String url) { | |
| if (mWebView == null) return; | |
| if (this.url == null) { | |
| mWebView.loadUrl(url); | |
| this.url = url; | |
| } | |
| } |
This file contains hidden or 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
| #かなり雑だけどこんな書き方もできる | |
| 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 |
This file contains hidden or 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
| 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'}}, |
This file contains hidden or 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
| # 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) |
This file contains hidden or 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
| tr = log --graph --all --format=\"%x09%C(cyan bold)%an%Creset%x09%C(yellow)%h%Creset %C(magenta reverse)%d%Creset %s\" |
This file contains hidden or 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
| ;; | |
| ;; init.el | |
| ;; | |
| ;; -*- mode: emacs-lisp; coding: utf-8; indent-tabs-mode: nil -*- | |
| ;; Language | |
| (set-language-environment 'Japanese) | |
| ;; Set alt as Meta key |
This file contains hidden or 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" | |
| "github.com/kokardy/listing" | |
| "runtime" | |
| "sync" | |
| ) | |
| func main() { |
This file contains hidden or 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
| 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 } |
This file contains hidden or 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
| 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 'キ・ヨ・シ!' |
This file contains hidden or 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
| def zundoko(history = []) | |
| return puts 'キ・ヨ・シ!' if history == ['ズン', 'ズン', 'ズン', 'ズン', 'ドコ'] | |
| zundoko(history.last(4) << ['ズン', 'ドコ'].sample.tap { |x| puts x }) | |
| end | |
| zundoko |