Skip to content

Instantly share code, notes, and snippets.

View billmote's full-sized avatar

Bill Mote billmote

  • Boca Raton, FL
  • 00:21 (UTC -05:00)
View GitHub Profile
@billmote
billmote / copyfiles.sh
Created September 8, 2014 14:42
A script to pull data from old HDDs
#!/bin/bash
echo Making Directories
mkdir -p ~/backup/docs
mkdir -p ~/backup/pictures
mkdir -p ~/backup/music
mkdir -p ~/backup/movies
echo Copying images ...
@billmote
billmote / forkproject.sh
Last active August 29, 2015 14:06
A quick find-and-replace script in support of forking projects.
#!/bin/bash
# chmod +x ./forkproject.sh # make this file executable
# Search and replace {NewRepoName}, {newappname} and {NewAppName}
# NOTE: this will mess up 1 URL in res/values/build_properties.xml, but you'll want your own API endpoint anyway ;)
cd ~/git/{NewRepoName}/app
mv ~/git/{NewRepoName}/app/src/main/java/com/androidfu/foundation ~/git/{NewRepoName}/app/src/main/java/com/androidfu/{newappname}
@billmote
billmote / SpannableStringBuilderActivity.java
Last active August 29, 2015 14:07
A SpannableStringBuilder used, in this case, to bold parts of a result while typing in a search field.
// ...
final String contactName = this.contact.getFullname();
final SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(contactName);
final StyleSpan boldSpan = new StyleSpan(android.graphics.Typeface.BOLD);
if (!TextUtils.isEmpty(searchTerm) && contactName.toLowerCase().contains(searchTerm.toLowerCase())) {
int startIndex = contactName.toLowerCase().indexOf(searchTerm.toLowerCase());
int endIndex = startIndex + searchTerm.length();
spannableStringBuilder.setSpan(boldSpan, startIndex, endIndex, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
this.fullname.setText(spannableStringBuilder);
@billmote
billmote / strip_play_services.gradle
Last active August 29, 2015 14:07 — forked from dmarcato/strip_play_services.gradle
Additions to build.gradle that will strip out parts of google play services
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
@billmote
billmote / AndroidManifest.xml
Last active August 29, 2015 14:08
Simple GCM Implementation
<!-- GCM permissions -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
<permission
android:name="com.example.android.app.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
@billmote
billmote / EventBus.java
Last active August 29, 2015 14:09
Otto Bus wrapper that allows posting from any thread as well as unregistering without crashing for multiple calls to unregister.
public class EventBus {
private static final Handler mainThread = new Handler(Looper.getMainLooper());
private static EventBus mInstance;
private final Bus mBus;
@DebugLog
private EventBus() {
// Don't let this class get instantiated directly.
mBus = new Bus();
@billmote
billmote / link.html
Last active August 29, 2015 14:09
Battery saving overlay in its simplest form.
import android.graphics.Rect;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.CheckBox;
/**
* Enlarges the effective hit target of a checkbox to more closely match the dimensions of the
* provided root view. If the provided root isn't actually an ancestor view of the checkbox, bad
* things will happen.
@billmote
billmote / MySingletonManager.java
Last active August 29, 2015 14:10
A singleton manager class that counts on being initialized but saves the call to getInstance() from every accessor. Downside: you have static methods that rely on internal state.
public class MySingletonManager {
public static final String TAG = MySingletonManager.class.getSimpleName();
private static MySingletonManager mInstance;
private Application mContext;
private ArrayList<PickleData> mSavedPickles = new ArrayList<PickleData>();
@DebugLog
private MySingletonManager() {
// Don't let this class get instantiated directly.
@billmote
billmote / bounce_wifi_hourly.sh
Last active August 29, 2015 14:11 — forked from patrickhammond/bouncewifi.sh
Starbucks has started bumping you off their WiFi every 60 minutes. This will quickly toggle your WiFi off/on to avoid unexpected interruptions. #FWP
#!/bin/sh
while true; do
sleep 3300 # 55 min * 60 sec
echo "Bouncing the wifi at `date`"
# You might need to change en1 to something else.
# ifconfig can tell you what network adapter to use
networksetup -setairportpower en1 off
sleep 2