This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyApplication extends Application { | |
public static final PushConfig.Environment ENVIRONMENT = PushConfig.Environment.PROD; // can also be .QA | |
private static final String TAG = "MyApplication"; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
final PushConfig pushConfig = ENVIRONMENT.getPushConfig(); | |
String appId = pushConfig.etAppId; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<receiver | |
android:name=".DownloadBroadcastReceiver" | |
android:exported="true"> | |
<intent-filter> | |
<action android:enabled="true" android:name="android.intent.action.DOWNLOAD_COMPLETE" /> | |
</intent-filter> | |
</receiver> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.androidfu.nowplaying.app.api; | |
import android.content.Context; | |
import com.androidfu.nowplaying.app.util.Log; | |
import com.androidfu.nowplaying.app.util.Preconditions; | |
import com.jakewharton.byteunits.DecimalByteUnit; | |
import com.squareup.okhttp.Cache; | |
import com.squareup.okhttp.OkHttpClient; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import com.androidfu.nowplaying.app.util.Log; | |
import com.androidfu.nowplaying.app.util.Preconditions; | |
import com.jakewharton.byteunits.DecimalByteUnit; | |
import com.squareup.okhttp.Cache; | |
import com.squareup.okhttp.OkHttpClient; | |
import java.io.File; | |
import java.io.IOException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is the implementation Haversine Distance Algorithm between two places | |
* @author ananth | |
* R = earth’s radius (mean radius = 6,371km) | |
Δlat = lat2− lat1 | |
Δlong = long2− long1 | |
a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2) | |
c = 2.atan2(√a, √(1−a)) | |
d = R.c | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@DebugLog | |
public class Movie { | |
@Expose | |
public Object runtime; | |
// ... | |
public Integer getMovieRuntime() { | |
if (runtime instanceof String && !TextUtils.isEmpty((String) runtime)) { | |
return Integer.valueOf((String) runtime); | |
} else if (runtime instanceof Integer) { | |
return (Integer) runtime; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Parcel | |
@DebugLog | |
public class Movie { | |
@Expose | |
public String id; | |
@Expose | |
public String title; | |
@Expose | |
public Integer year; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.TimeZone; | |
/** | |
* Formats dates to sortable UTC strings in compliance with ISO-8601. | |
*/ | |
public class PrettyDate { | |
public static String ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS zzz"; | |
public static String LEGACY_FORMAT = "EEE MMM dd hh:mm:ss zzz yyyy"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Search & Replace contents of a file -- in this case we're searching for jb4ASDK@ in all files and replacing with ~! | |
grep -IRlr jb4ASDK@ . | xargs sed -i "" -e 's/jb4ASDK@/~!/g' | |
# Human readable folder utilization from current folder | |
sudo du -sh $(ls -d $(pwd)/*) | |
# When git doesn't know who we are: | |
eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_rsa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<!-- Add this as a debug manifest so the permissions won't be required by your production app --> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |
<uses-permission android:name="android.permission.WAKE_LOCK" /> | |
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | |
</manifest> |