Skip to content

Instantly share code, notes, and snippets.

View michiakig's full-sized avatar

aki michiakig

  • Rent the Runway
  • Brooklyn, NY
View GitHub Profile
@michiakig
michiakig / IO.java
Created November 19, 2012 20:28
CheckThread blog post IO.java
@ThreadConfined("other")
public final class IO {
//…
}
@michiakig
michiakig / analyze1
Created November 19, 2012 20:29
CheckThread blog post analyze1
analyze:
[checkthread] ****
[checkthread] Error in class com/flurry/example/hnreader/HackerNewsActivityV1Buggy.java on line 29
[checkthread] The method 'onCreate' has a 'MAIN' thread policy, but the invoked method 'getHttp' has a 'other' thread policy.
@michiakig
michiakig / HackerNewsActivityV2Buggy.java
Created November 19, 2012 20:30
CheckThread blog post HackerNewsActivityV2Buggy.java
new Thread() {
@ThreadConfined("other")
public void run()
{
try
{
// doing IO off the UI thread -- ok
String feed = IO.getHttp(kHackerNewsRssUrl);
List<String> titles = HackerNewsRSSParser.parseTitles(feed);
for (String t : titles)
@michiakig
michiakig / analyze2
Created November 19, 2012 20:31
CheckThread blog post analyze2
analyze:
[checkthread] ****
[checkthread] Error in class com/flurry/example/hnreader/HackerNewsActivityV2Buggy.java on line 43
[checkthread] The method 'run' has a 'other' thread policy, but the invoked method 'setText' has a 'MAIN' thread policy.
@michiakig
michiakig / HackerNewsActivityV3LessBuggy.java
Created November 19, 2012 20:31
CheckThread blog post HackerNewsActivityV3LessBuggy.java
new Thread() {
@ThreadConfined("other")
public void run()
{
try
{
String feed = IO.getHttp(kHackerNewsRssUrl);
final List<String> titles = HackerNewsRSSParser.parseTitles(feed);
HackerNewsActivityV3LessBuggy.this.runOnUiThread(new Runnable()
{
@michiakig
michiakig / Chain.java
Created November 19, 2012 20:32
CheckThread blog post Chain.java
public class Chain
{
@ThreadSafe
public void threadSafeMethod()
{
middleman();
}
public void middleman()
{
notThreadSafeMethod();
@michiakig
michiakig / init.el
Last active October 13, 2015 23:38
;; package.el stuff
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar my-packages '(color-theme-solarized magit smex sml-mode))
(dolist (p my-packages)
(when (not (package-installed-p p))
structure Set : ORD_SET = IntListSet
structure Map : ORD_MAP = ListMapFn(
struct
type ord_key = Set.set
val compare = Set.compare
end)
val m = Map.insert(Map.empty, Set.singleton 1, 2)
datatype Sexp = Satom of string | Scons of Sexp * Sexp | Snil
(* returns a string representation of an Sexp *)
fun showSexp s =
let
(* if fresh, Sexp is the head of a new list, not an inner cons cell *)
fun showSexp' Snil _ = "nil"
| showSexp' (Satom a) fresh =
if not fresh
then ". " ^ a (* dotted tail notation *)
(add-hook 'sml-mode-hook (lambda () (defun sml-smie-rules (kind token) 7))))))