Skip to content

Instantly share code, notes, and snippets.

@brandhill
brandhill / EachDirectoryPath.md
Created March 21, 2016 04:15 — forked from granoeste/EachDirectoryPath.md
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

@brandhill
brandhill / debug_push.py
Created November 16, 2016 06:56
Test APN push notification certificates (PEM key)
# How do I test my APN push notification certificates (PEM key)?
# https://www.pubnub.com/knowledge-base/discussion/234/how-do-i-test-my-pem-key
# You can test your PEM key using the following command, which should hang if successful until you press enter:
# openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem
# The above tests the PEM Key in sandbox mode. For production mode, use the following command:
# openssl s_client -connect gateway.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem
# You can also test your PEM Key by running the Python script below using the script below. The usage would be:
# python push_debug.py <CERT_PATH> <DEVICE_TOKEN>
@brandhill
brandhill / iosLocalizationPayload.json
Created November 23, 2016 03:09
a sample for push localization payload
{
"aps":{
"alert":{
"loc-key":"My Localized String",
"loc-args":[
"First argument",
"Second argument"
]
},
"badge":1,
@brandhill
brandhill / Android Privacy Policy Template
Created February 13, 2017 14:45 — forked from alphamu/Android Privacy Policy Template
A template for creating your own privacy policy for Android apps. Look for "[" and "<!--" to see where you need to edit this app in order to create your own privacy olicy.
<html>
<body>
<h2>Privacy Policy</h2>
<p>[Individual or Company Name] built the [App Name] app as a [open source | free | freemium | ad-supported | commercial] app. This SERVICE is provided by [Individual or company name] [at no cost] and is intended
for use as is.</p>
<p>This page is used to inform website visitors regarding [my|our] policies with the collection, use, and
disclosure of Personal Information if anyone decided to use [my|our] Service.</p>
<p>If you choose to use [my|our] Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that [I|we] collect are used for providing and
improving the Service. [I|We] will not use or share your information with anyone except as described
-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
// Call or write any code necessary to get new data, process it and update the UI.
// The logic for informing iOS about the fetch results in plain language:
if (/** NEW DATA EXISTS AND WAS SUCCESSFULLY PROCESSED **/) {
completionHandler(UIBackgroundFetchResultNewData);
}
if (/** NO NEW DATA EXISTS **/) {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];
return YES;
}
{
"aps":{
"alert":{
"loc-key":"My Localized String",
"loc-args":[
"First argument",
"Second argument"
]
},
"badge":1,
{
"aps": {
"sound": "",
"content-available": 1
},
"custom_key": {
"custom_key_1": "custom_value_1",
"custom_key_2": "custom_value_2"
}
}
{
"applinks": {
"apps": [],
"details": [
{
"appID": "9JA89QQLNQ.com.apple.wwdc",
"paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
},
{
"appID": "ABCD1234.com.apple.wwdc",
@brandhill
brandhill / update-jenkins.sh
Created March 4, 2017 08:22
the script to update jenkins
#!/bin/bash
DEFAULT_URL=http://updates.jenkins-ci.org/current/latest/jenkins.war
TMP_PATH=/tmp/jenkins.war
APP_PATH=/Applications/Jenkins/jenkins.war
PLIST_PATH=/Library/LaunchDaemons/org.jenkins-ci.plist
url=${1-$DEFAULT_URL}
echo 'Downloading WAR package...'