Skip to content

Instantly share code, notes, and snippets.

srayhunter /
Last active April 26, 2024 20:22
Android - Get phone number and email address from Contacts
private class FetchContacts extends AsyncTask<Void, Void, ArrayList<Contact>> {
ContactsContract.Contacts.DISPLAY_NAME_PRIMARY : ContactsContract.Contacts.DISPLAY_NAME;
private final String FILTER = DISPLAY_NAME + " NOT LIKE '%@%'";
private final String ORDER = String.format("%1$s COLLATE NOCASE", DISPLAY_NAME);
srayhunter /
Created January 6, 2016 06:59
Android - Convert DP to Pixels

Android - Convert DP to Pixels

Convert 32dp to pixels

Resources r = getResources();
float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, r.getDisplayMetrics());
srayhunter /
Created December 30, 2015 05:16
Retrofit Callback String Example
// notice the callback here
git.getFeed(new Callback<String>() {
	public void success(String result, Response response) {
		Log.d("success" , "Data received: " + result);

public void failure(RetrofitError error) {

srayhunter /
Last active June 22, 2022 16:41
Android ADB over Wifi

Android ADB over Wifi

Here is a simple way to use ADB over wifi with your device. Make sure that ADB can reach your device over the network.

  1. Connect device to usb

  2. Restart the ADB daemon to listening on TCP port

adb tcpip 5555

srayhunter /
Last active September 18, 2023 13:13
Android - Update Android SDK from the commandline

Android - Update Android SDK from the commandline

Update the installed packages

sdkmanager --update

List all items (--all is needed to show obsolete, build tools and other items)

sdkmanager --list
srayhunter /
Created August 29, 2015 05:38
Android Gradle Build Properties for Mac OSX
# project by srayhunter@github
# run the daemon on builds
org.gradle.jvmargs=-Djava.awt.headless=true -Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
srayhunter / listlayer.xml
Created August 29, 2015 05:32
Android List-Layer Drawable with VectorDrawable Text
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="">
<item android:state_checked="true">
<solid android:color="@android:color/white"/>
<corners android:radius="5dp"/>
<item android:drawable="@drawable/vector"/>
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C

Keybase proof

I hereby claim:

  • I am srayhunter on github.
  • I am srayhunter ( on keybase.
  • I have a public key whose fingerprint is BC4A 7F1D 19EF F5A9 D37E D7D9 A48E 7049 D73A B026

To claim this, I am signing this object:

srayhunter /
Last active April 27, 2022 12:56
Configure Apache on Mac OSX with Environment Variables

Configure Apache Path Environment Variable on Mac OSX

Problem: Apache2/PHP did not find a program to execute on its configured path

Solution: Add a new path of /usr/local/bin to Apache2's path where the program was installed

  1. Edit the Apache2 plist file with whatever editor you like (example using vim):

     $ sudo vim /System/Library/LaunchDaemons/org.apache.httpd.plist