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 / 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 / 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 / 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 / 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 / IO.java
Created November 19, 2012 20:28
CheckThread blog post IO.java
@ThreadConfined("other")
public final class IO {
//…
}
@michiakig
michiakig / HackerNewsActivityV1Buggy.java
Created November 19, 2012 20:27
CheckThread blog post HackerNewsActivityV1Buggy.java
package com.flurry.example.hnreader;
import java.io.IOException;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
@michiakig
michiakig / threadpolicy.xml
Created November 19, 2012 20:26
CheckThread blog post threadpolicy.xml
<?xml version="1.0"?>
<threadpolicy version="1.0">
<class name="android.app.Activity">
<policy type="ThreadConfined" threadname="ThreadName.MAIN">
<method pattern="on.*" />
</policy>
</class>
<class pattern="android.*View">
<policy type="ThreadConfined" threadname="ThreadName.MAIN">
<method pattern=".*" />
;; set two global variables
(setq x 'global-x)
(setq y 'global-y)
;; define a function that returns a nested function
(defun return-a-nested-fn (x)
;; the nested function takes no arguments and returns a list of two values
(lambda () (list x y)))
;; call that function, and call the function returned
require 'RMagick'
import Magick
if(ARGV.length < 2)
puts "call with image filename and gcode filename"
exit(1)
end
XSTEP = 5
YSTEP = 5
@michiakig
michiakig / Foo.java
Created August 24, 2011 04:19
Java closures
public class Foo {
final int bar = 6;
final int[] flarp = new int[] {6};
public class Baz {
int bla() {
return bar;
}
int bloo() {