This file contains 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
static String getDayOfMonthSuffix(final int n) { | |
if (n >= 11 && n <= 13) { | |
return "th"; | |
} | |
switch (n % 10) { | |
case 1: return "st"; | |
case 2: return "nd"; | |
case 3: return "rd"; | |
default: return "th"; | |
} |
This file contains 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 AsyncBus extends Bus { | |
private final Handler mainThread = new Handler(Looper.getMainLooper()); | |
@Override public void post(final Object event) { | |
mainThread.post(new Runnable() { | |
@Override public void run() { | |
AsyncBus.super.post(event); | |
} | |
}); | |
} |
This file contains 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
#!/usr/bin/python | |
''' | |
Copyright 2009, The Android Open Source Project | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 |
This file contains 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
# Sexy Solarized Bash Prompt, inspired by "Extravagant Zsh Prompt" | |
# Customized for the Solarized color scheme by Sean O'Neil | |
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then TERM=gnome-256color; fi | |
if tput setaf 1 &> /dev/null; then | |
tput sgr0 | |
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then | |
BASE03=$(tput setaf 234) | |
BASE02=$(tput setaf 235) | |
BASE01=$(tput setaf 240) |
This file contains 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
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.node_container); | |
mIsDualPane = getResources().getBoolean(R.bool.has_two_panes); | |
nid = getIntent().getIntExtra("nid", 0); | |
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
This file contains 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 void sort(String type){ | |
SharedPreferences prefs = getActivity().getSharedPreferences( | |
getActivity().getPackageName(), Context.MODE_PRIVATE); | |
if(type.equals(ASC)){ | |
prefs.edit().putString(SORT, ASC).commit(); | |
} else { | |
prefs.edit().putString(SORT, DESC).commit(); | |
} |
This file contains 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
private static String parseVals(String key, String val, String prefix) throws InvalidKeyException, NoSuchAlgorithmException, IOException { | |
long ts = System.currentTimeMillis() / 1000; | |
String[] parts = val.split("\\|"); | |
String u_prefix = parts[0]; | |
String u_b64 = parts[1]; | |
String u_sig = parts[2]; | |
String sig = Util.hmacSign(key, u_prefix + "|" + u_b64); | |
if (!Util.hmacSign(key, sig).equals(Util.hmacSign(key, u_sig))) { |
This file contains 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
java.lang.RuntimeException: java.lang.SecurityException: Failed to seed OpenSSL PRNG | |
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:231) | |
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) | |
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) | |
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) | |
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) | |
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) | |
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) |
This file contains 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 void displayNotification() { | |
mNotifyBuilder = new NotificationCompat.Builder(this) | |
.setContentTitle("New Message") | |
.setContentText("You've received new messages.") | |
.setSmallIcon(R.drawable.ic_notify_status) | |
mNotificationManager.notify( | |
notifyID, mNotifyBuilder.build()); | |
} |
This file contains 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 void displayNotificationWithActions() { | |
mNotifyBuilder = new NotificationCompat.Builder(this) | |
.setContentTitle("New Message") | |
.setContentText("You've received new messages.") | |
.setSmallIcon(R.drawable.ic_notify_status); | |
// Create Pending Intent that broadcasts an Intent | |
Intent intent = new Intent(context.getPackageName() + ".READ_MESSAGE"); | |
PendingIntent pendingIntent = | |
PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); |