Open ~/.bash_profile
in your favorite editor and add the following content to the bottom.
# Git branch in prompt.
parse_git_branch() {
/* | |
* Copyright 2016 Google Inc. | |
* | |
* 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 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
// book keeping so that we can easily animate the two hands for the watchface | |
// .scale/.angle are updated by tween/event handler (see below) | |
var renderState = { | |
minute: {style: 'white', scale: 0.80, angle: 0}, | |
hour: {style: 'red', scale: 0.51, angle: 0} | |
}; | |
// helper function for the draw function (see below) | |
// extracted as a standalone function to satisfy common believe in efficient JS code | |
// TODO: verify that this has actually any effect on byte code level |
/* | |
Source: http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/ | |
USAGE: | |
ItemClickSupport.addTo(mRecyclerView).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() { | |
@Override | |
public void onItemClicked(RecyclerView recyclerView, int position, View v) { | |
// do it | |
} | |
}); |
public static void printPermissions(Context context) { | |
PackageInfo android; | |
try { | |
android = context.getPackageManager().getPackageInfo("android", PackageManager.GET_PERMISSIONS); | |
} catch (PackageManager.NameNotFoundException e) { | |
e.printStackTrace(); | |
return; | |
} | |
PermissionInfo[] permissions = android.permissions; |
/** | |
* Show the activity over the lockscreen and wake up the device. If you launched the app manually | |
* both of these conditions are already true. If you deployed from the IDE, however, this will | |
* save you from hundreds of power button presses and pattern swiping per day! | |
*/ | |
public static void riseAndShine(Activity activity) { | |
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED); | |
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE); | |
PowerManager.WakeLock lock = |
/* | |
* Copyright 2014 Chris Banes | |
* | |
* 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 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import android.content.res.Resources; | |
import android.graphics.drawable.Drawable; | |
import android.text.Spannable; | |
import android.text.SpannableStringBuilder; | |
import android.text.style.ImageSpan; | |
import android.view.View; | |
import android.widget.ImageView; | |
import android.widget.LinearLayout; | |
import android.widget.SearchView; | |
import android.widget.TextView; |