Skip to content

Instantly share code, notes, and snippets.

View tmountain's full-sized avatar

Travis Whitton tmountain

View GitHub Profile
abstract class MenuItem {
private String item;
public abstract void run();
public String getItem() {
return this.item;
}
public MenuItem(String item) {
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);
}}});
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) {
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
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
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
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
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
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
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);