Skip to content

Instantly share code, notes, and snippets.

View koalahamlet's full-sized avatar
㊙️
shhhh

Michael Alan Huff koalahamlet

㊙️
shhhh
View GitHub Profile
@koalahamlet
koalahamlet / notWorkingWell.java
Last active August 29, 2015 14:11
Fragments, how do they work?
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
FragmentManager manager = getFragmentManager();
FragmentTransaction fts = manager
.beginTransaction();
// lazy instantiation for the win
if (tab.getTag() == "PoiListFragment") {
openers_to_closers_map = {
'(' : ')',
'{' : '}',
'[' : ']'
}
openers = openers_to_closers_map.keys()
closers = openers_to_closers_map.values()
def is_valid(code):
openers_stack = []
for (var i = 1; i < 13; i++) {
var str = "";
for (var j = 1; j < 13; j++) {
var num = i*j;
var spacer;
if (num <= 9) {
spacer = " "
}
else if (num <= 99 ){
spacer = " "
@koalahamlet
koalahamlet / MetricDetailFragment.java
Last active August 29, 2015 14:08
general patter for custom loader animation
private WebView webView;
private ImageView loaderImage;
private AnimationDrawable frameAnimation;
...
alias yolo="git commit -am '(•_•) ( •_•)>⌐■-■ (⌐■_■) DEAL WITH IT' && git push -f origin master"
private void setAccountName(String name) {
mAccountName = name;
SharedPreferences settings = getSharedPreferences(SHARED_PREFS, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString(ACCT_NAME, mAccountName);
editor.commit();
}
public ArrayList<String> getGooglePlusToken() {
ArrayList<String> accessTokens = new ArrayList<>();
try {
String accountName = Plus.AccountApi.getAccountName(googleApiClient);
String scope = "audience:server:client_id:" + Constants.GOOGLE_PLUS_SERVER_CLIENT_ID;
accessTokens.add(GoogleAuthUtil.getToken(context, accountName, scope));
Object[] scopes = {
Scopes.PLUS_LOGIN
};
@koalahamlet
koalahamlet / gist:4db8a946562c4daf9ba2
Created August 14, 2014 21:37
revoke android access G+
private void revokeGplusAccess() {
if (mGoogleApiClient.isConnected()) {
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
Plus.AccountApi.revokeAccessAndDisconnect(mGoogleApiClient)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status arg0) {
Log.e(TAG, "User access revoked!");
mGoogleApiClient.connect();
updateUI(false);
var troll = prompt("You're walking through the forest, minding your own business, and you run into a troll! Do you FIGHT him, PAY him, or RUN?").toUpperCase();
switch(troll) {
case 'FIGHT':
var strong = prompt("How courageous! Are you strong (YES or NO)?").toUpperCase();
var smart = prompt("Are you smart?").toUpperCase();
if(strong === 'YES' || smart === 'YES') {
console.log("You only need one of the two! You beat the troll--nice work!");
} else {
console.log("You're not strong OR smart? Well, if you were smarter, you probably wouldn't have tried to fight a troll. You lose!");
package advanced;
import com.sandwich.koan.Koan;
import static com.sandwich.util.Assert.fail;
public class AboutMocks {
static interface Collaborator {
public void doBusinessStuff();
}