Skip to content

Instantly share code, notes, and snippets.

Jamie McDonald jdamcd

Block or report user

Report or block jdamcd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jdamcd
jdamcd / sayrandom.sh
Last active Dec 27, 2015
Say a random word every 7 minutes ^-^
View sayrandom.sh
#!/bin/bash
while true; do sleep 420; perl -e 'open IN, "</usr/share/dict/words";rand($.) < 1 && ($n=$_) while <IN>;print $n' | say; done
@jdamcd
jdamcd / ListPageIndicator.java
Created Oct 5, 2013
Simple ListView page indicator for use with ViewPagerIndicator
View ListPageIndicator.java
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
@jdamcd
jdamcd / 51-android.rules
Created Jul 22, 2013
Full set of Android USB vendor ID rules for Linux
View 51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666", GROUP="plugdev" #Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", GROUP="plugdev" #ASUS
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666", GROUP="plugdev" #Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", GROUP="plugdev" #Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", GROUP="plugdev" #Fujitsu
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", GROUP="plugdev" #Fujitsu Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="091e", MODE="0666", GROUP="plugdev" #Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev" #Google
SUBSYSTEM=="usb", ATTR{idVendor}=="201E", MODE="0666", GROUP="plugdev" #Haier
SUBSYSTEM=="usb", ATTR{idVendor}=="109b", MODE="0666", GROUP="plugdev" #Hisense
@jdamcd
jdamcd / UndoBarController.java
Created May 8, 2013
UndoBarController using NineOldAndroids for animations.
View UndoBarController.java
/*
* Copyright 2012 Roman Nurik
*
* 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
@jdamcd
jdamcd / fullbattery
Last active Dec 14, 2015
Set Android emulator battery full for screenshots
View fullbattery
telnet localhost 5554
power status discharging
power capacity 100
@jdamcd
jdamcd / AndroidManifest.xml
Created Feb 16, 2013
Android snippet for hiding debug screens behind SECRET_CODE broadcasts sent via the dialler.
View AndroidManifest.xml
<receiver android:name=".SecretCodeReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data
android:scheme="android_secret_code"
android:host="1111" />
</intent-filter>
</receiver>
@jdamcd
jdamcd / AllEmailAdapter.java
Last active Dec 12, 2015
Email adapter for AutoCompleteTextView that looks for emails from all account types, not just Google.
View AllEmailAdapter.java
private static final String EMAIL_REGEX = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
private static final Pattern EMAIL_PATTERN = Pattern.compile(EMAIL_REGEX);
private ArrayAdapter<String> getEmailAddressAdapter(Context context) {
Account[] accounts = AccountManager.get(context).getAccounts();
HashSet<String> emailSet = new HashSet<String>();
for (int i = 0; i < accounts.length; i++) {
if (isEmailAddress(accounts[i].name)) {
emailSet.add(accounts[i].name);
}
@jdamcd
jdamcd / EmailAdapter.java
Last active Dec 12, 2015
Email adapter for AutoCompleteTextView
View EmailAdapter.java
private ArrayAdapter<String> getEmailAddressAdapter(Context context) {
Account[] accounts = AccountManager.get(context).getAccountsByType("com.google");
String[] addresses = new String[accounts.length];
for (int i = 0; i < accounts.length; i++) {
addresses[i] = accounts[i].name;
}
return new ArrayAdapter<String>(context, android.R.layout.simple_dropdown_item_1line, addresses);
}
@jdamcd
jdamcd / gist:4224231
Created Dec 6, 2012
Thumbnail scaling for Android notfications
View gist:4224231
public class NotificationThumbnailHelper {
private float targetWidth;
private float targetHeight;
public NotificationThumbnailHelper(Context context) {
targetWidth = getTargetWidth(context);
targetHeight = getTargetHeight(context);
}
View .bash_profile
# Git autocomplete script:
# curl https://github.com/git/git/raw/master/contrib/completion/git-completion.bash -OL
source /Users/jdamcd/git-completion.bash
alias checkout='git checkout'
alias clone='git clone'
alias la='ls -la'
alias gh='github'
alias code='cd /Users/jdamcd/Dropbox/Code'
You can’t perform that action at this time.