Skip to content

Instantly share code, notes, and snippets.

@anolivetree
anolivetree / QueryView.java
Last active September 11, 2015 14:29
Custom view with CursorLoader
package com.example.myapplication;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.widget.CursorAdapter;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@anolivetree
anolivetree / Retain.java
Last active September 14, 2015 08:23
Activityの再生成にまつわる処理の煩雑さを解消するクラス
package com.example.retain;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Bundle;
import android.os.Parcelable;
import java.io.Serializable;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicLong;
(ns org.stuff.events.main
(:require [neko.activity :refer [defactivity set-content-view!]]
[neko.debug :refer [*a]]
[neko.ui :refer [on-ui]]
[clojure.string :refer [join]]
[neko.find-view :refer [find-view]]
[neko.threading :refer [on-ui]])
(:import android.widget.TextView
(java.util Calendar)
(android.app Activity)
package com.example.clojureequivalent2;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;
@anolivetree
anolivetree / main.go
Created December 10, 2015 08:18
Androidのscreenshotの上部のnotificationエリアと下部のボタンエリアを削除したPNGを作る
package main
import (
"fmt"
"image"
"image/png"
_ "image/png"
"os"
)
Subscription subscribe = orma.selectFromToDo().executeAsObservable().map(new Func1<ToDo, Integer>() {
@Override
public Integer call(ToDo toDo) {
Log.i(TAG, "map called");
throw new RuntimeException("map error");
//return 0;
}
}).subscribe(new Action1<Integer>() {
@Override
public void call(Integer toDo) {
// (column1=0 OR column=1) AND (column2=3)
TODO_Selector a = orma.selectFromTODO().column1Eq(0).or().column1Eq(1);
Cursor cursor = orma.selectFromTODO()
.where(a).and().column2Eq(3)
@anolivetree
anolivetree / README
Last active July 14, 2016 09:14
IntelliJ-like key binding for Eclipse
File->Import->General->Preferences->Import Keys Preferences
@anolivetree
anolivetree / clojure.clj
Created October 3, 2017 11:57
上のコードをみて、下のコードをみて、再度上のコードを見ると、Lispの括弧が気にならなくなる(かもしれない)
(defn gray-encode [x]
(bit-xor x (unsigned-bit-shift-right x 1)))
(defn gray-decode [x]
(loop [mask 0x80000000
b 0]
(if (= mask 0)
b
(recur (unsigned-bit-shift-right mask 1)
(bit-or b
@anolivetree
anolivetree / widenscrollbar.js
Last active November 1, 2017 14:13
Widen the scrollbar on Google developer sites.
// ==UserScript==
// @name scrollbar widen
// @namespace https://developer.android.com/
// @version 0.1
// @description try to take over the world!
// @author You
// @include https://developer.android.com/*
// @include https://developers.google.com/*
// @grant GM_addStyle
// ==/UserScript==