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
abstract class MenuItem { | |
private String item; | |
public abstract void run(); | |
public String getItem() { | |
return this.item; | |
} | |
public MenuItem(String item) { |
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
UiApplication.getUiApplication().invokeAndWait(new Runnable() { | |
public void run() { | |
int response; | |
response = Dialog.ask(Dialog.D_YES_NO, "An update to Grooveshark Mobile is available. Upgrade now?"); // FIXME: translate | |
if (response == Dialog.YES) { | |
Logger.log("push upgrade"); | |
_upgradeScreen = new Upgrade(); | |
pushScreen(_upgradeScreen); | |
}}}); |
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
public class Z { | |
private volatile boolean valSet = false; | |
private volatile int val; | |
public void fun() { | |
final Object localThis = this; | |
Thread t = new Thread(new Runnable() { | |
public void run() { | |
synchronized (localThis) { |
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
travis@travis-desktop:/tmp$ cat testr.sh | |
#!/bin/sh | |
sh exitr.sh | |
if [ "$?" -ne 0 ]; then echo "command failed"; exit 1; fi | |
travis@travis-desktop:/tmp$ cat exitr.sh | |
#!/bin/sh | |
exit 1 |
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
travis@travis-desktop:/tmp$ cat dier.php | |
#!/usr/bin/php | |
<?php | |
die(1); | |
?> | |
travis@travis-desktop:/tmp$ cat testr.sh | |
#!/bin/sh | |
php dier.php |
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
import java.util.Vector; | |
public class ByteBucket { | |
public final int bucketSize = 10; // how many bytes to store per bucket | |
private int writePos = 0; // total bytes written | |
private int readPos = 0; // total bytes read | |
private int bucketIndex = 0; // byte position in current bucket | |
private AtomicReference bucket; // thread-safe byte array container | |
private final Vector data; // holds an arbitrary number of atomic refs |
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
import java.io.File; | |
import java.io.IOException; | |
import java.util.Vector; | |
public class ByteBucket { | |
public final int bucketSize = 128000; // how many bytes to store per bucket | |
private int writePos = 0; // total bytes written | |
private int readPos = 0; // total bytes read | |
private int bucketIndex = 0; // byte position in current bucket | |
private AtomicReference bucket; // thread-safe byte array container |
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
import java.io.File; | |
import java.io.IOException; | |
import java.util.Vector; | |
public class ByteBucket { | |
public final int bucketSize = 128000; // how many bytes to store per bucket | |
private int writePos = 0; // total bytes written | |
private int readPos = 0; // total bytes read | |
private int bucketIndex = 0; // byte position in current bucket | |
private AtomicReference bucket; // thread-safe byte array container |
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
import java.io.File; | |
import java.io.IOException; | |
import java.util.Vector; | |
public class ByteBucket { | |
public final int bucketSize = 128000; // how many bytes to store per bucket | |
private int writePos = 0; // total bytes written | |
private int readPos = 0; // total bytes read | |
private int bucketIndex = 0; // byte position in current bucket | |
private AtomicReference bucket; // thread-safe byte array container |
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
public synchronized void write(byte[] b, int off, int len) { | |
int partialLen = 0; | |
boolean partialWrite = false; | |
byte[] bytes = (byte[]) bucket.get(); | |
// if requested length exceeds the current bucket size | |
// perform a partial write and save the rest for the next write | |
if (bucketIndex + len > bucketSize) { | |
partialLen = bucketSize - bucketIndex; | |
System.arraycopy(b, off, bytes, partialLen); |