Skip to content

Instantly share code, notes, and snippets.

View nobuoka's full-sized avatar

Nobuoka Yu nobuoka

View GitHub Profile
@nobuoka
nobuoka / java-for-android-app.markdown
Last active May 14, 2023 14:47
Android アプリ開発勉強会のために書いた Java の入門文書

Android アプリ開発のための Java 入門

MEMO

  • declaration は 「宣言」 と訳しているが、「定義」 の方が適しているような気がしなくもない。
  • 「インスタンス」 と 「オブジェクト」 という言葉を使うことがあるが、本文書中ではどちらも同じ意味で使用している。
  • String オブジェクト」 という表現は、「String クラスのインスタンス」 を意味している。 (Java に限らず一般的な表現だと思う。)

はじめに

@nobuoka
nobuoka / ExceptionWithEither.kt
Last active February 10, 2023 06:56
Kotlin における、呼び出し側に処理して欲しい例外の扱い方を検討する。
import javax.ws.rs.WebApplicationException
import javax.ws.rs.core.Response
// 使う側の例。
fun main(args: Array<String>) {
FooApplicationService.fetchFoo("taro", "").then {
when (it) {
is Either.Right -> Response.ok().entity(it.value)
is Either.Left -> when (it.value) {
@nobuoka
nobuoka / GoogleHttpJavaClientExample.java
Created November 8, 2014 11:20
google-http-java-client を使用するサンプルコード
import java.io.IOException;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
public class GoogleHttpJavaClientExample {
@nobuoka
nobuoka / generic_test_coverage.ja.markdown
Last active March 24, 2021 08:27
generic_test_coverage.rb (fastlane action)

generic_test_coverage.rb

概要

  • fastlane のアクション
  • iOS プロジェクトのビルド結果である result bundle (.xcresult 拡張子) に含まれるカバレッジ情報から SonarQube の Generic Coverage を生成する
  • 内部では xccov コマンドが使用される
@nobuoka
nobuoka / commit-built-files-to-gh-pages-branch.markdown
Last active November 22, 2019 15:38
The way to commit built files in subdirectory to gh-pages branch from an arbitrary branch

Committing a subfolder to the gh-pages branch from the other branch

Sometimes you want to commit a subfolder on an arbitrary branch (rather than gh-pages branch) as the root directory to the gh-pages branch. You will want to do so when, for example, the files to be published on GitHub Pages are generated by a build system.

This document shows the way to commit a build/gh-pages directory to the gh-pages branch by using Git plumbing commands. In the following example, Windows PowerShell is used as a shell environment.

Step 1 : Create a tree object

// === ドメインレイヤ ===
sealed class FizzBuzzValue {
abstract val expression: String
data class Number(override val expression: String) : FizzBuzzValue()
object Fizz : FizzBuzzValue() { override val expression: String = "Fizz" }
object Buzz : FizzBuzzValue() { override val expression: String = "Buzz" }
object FizzBuzz : FizzBuzzValue() { override val expression: String = "FizzBuzz" }
}
@nobuoka
nobuoka / build.gradle
Last active August 6, 2018 10:49
Android アプリ開発における複数スレッドでの SQLite 使用に関する調査。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
tasks.withType(JavaCompile) {
@nobuoka
nobuoka / JavaAptPlugin.groovy
Last active September 28, 2017 09:23
Java Annotation Processing Task for Gradle
// buildSrc/src/main/groovy/JavaAptPlugin.groovy
class JavaAPT extends DefaultTask {
private File _destinationDir
def getDestinationDir(dir) { _destinationDir }
void setDestinationDir(dir) {
_destinationDir = dir
outputs.dir _destinationDir
}
package info.vividcode;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* すぐに実行終了するコマンド (外部プロセス) を実行するクラス。
@nobuoka
nobuoka / bootstrap.js
Last active April 29, 2016 08:43
ブートストラップ型の XUL ベースの Firefox 拡張としてのサンプル。
var Cc = Components.classes;
var Ci = Components.interfaces;
var PromptService = Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService);
// インストール時に呼び出される
function install(aData, aReason) {
PromptService.alert(null, "Bootstrapped Extension Sample", "Install");
}