Skip to content

Instantly share code, notes, and snippets.

View skyler's full-sized avatar

Skyler Slade skyler

  • SharpSpring Inc.
  • Gainesville, FL
View GitHub Profile
private void login(String username, String password)
{
LoginCredentials creds = new LoginCredentials(username, password);
AsyncAPI.getInstance().login(creds, new ITaskCallback() {
@Override
public void onResult(AbstractRunnable task)
{
boolean success = task.getResult();
if (success) {
Login.this.runOnUiThread(new Runnable() {
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Login Failed!").setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id)
{
dialog.dismiss();
}
});
import java.text.DecimalFormat;
import java.text.NumberFormat;
public static String formatBytes(long numBytes)
{
NumberFormat formatter = new DecimalFormat("#.00");
StringBuffer buffer = new StringBuffer();
if (numBytes > 1024) {
if (numBytes >= 1073741824D) {
buffer.append(formatter.format((double) numBytes / 1073741824D)).append("GB");
private void login(String username, String password)
{
LoginCredentials creds = new LoginCredentials(username, password);
AsyncAPI.getInstance().login(this, creds, new ITaskCallback<Boolean>() {
@Override
public void onResult(AbstractRunnable<Boolean> task)
{
handler.sendEmptyMessage(DISMISS_LOGIN_DIALOG);
boolean accountOK = false;
@Override
public void onResume()
{
super.onResume();
FavoritesController controller = FavoritesController.getInstance()
synchronized (controller) {
if (controller.isLoading()) {
try {
controller.wait();
} catch (InterruptedException e) {
public class T
{
private static final String FOO;
static {
FOO = "baz";
}
public static void main(String[] args)
{
System.out.println(FOO);
$mobileID = 0;
if ($mobileID == 'beta') {
error_log("shit bricks: " . $mobileID);
}
...
php test.php
shit bricks: 0
@skyler
skyler / gist:736593
Created December 10, 2010 18:46
try without catch--finally block will execute
public class T
{
public static void main(String[] args)
{
try {
dontCatchIt();
} catch (IOException ioe) {
System.out.println("Caught IOException: " + ioe.getMessage());
} catch (Exception e) {
System.out.println("Caught Exception: " + e.getMessage());
class PrimeRun implements Runnable {
long minPrime; <!-- note not final!
PrimeRun(long minPrime) {
this.minPrime = minPrime;
}
public void run() {
// compute primes larger than minPrime
. . .
}
public String getAddress()
{
try {
readyLatch.await();
} catch (InterruptedException inte) {
interrupt();
}
synchronized (this) {
return address;
}