Skip to content

Instantly share code, notes, and snippets.

View jschmid's full-sized avatar
📱

Jonas Schmid jschmid

📱
View GitHub Profile
{
"$schemaTransformation" : "http://buzzword.org.uk/2008/jCard/transformation.js" ,
"id" : "jCard" ,
"version" : "0.1.0" ,
"title" : "jCard" ,
"description" : "This document defines the jCard data format for representing and exchanging a variety of information about an individual (e.g., formatted and structured name and delivery addresses, email address, multiple telephone numbers, photograph, logo, audio clips, etc.)." ,
"type" : "object" ,
"seeAlso" :
[
"http://microformats.org/wiki/jcard" ,
@jschmid
jschmid / gist:5368a49c50f08f45895f
Created July 23, 2014 10:53
Objective-C URL encoding
+ (NSString *)encodedString:(NSString *)unescaped {
NSString *charactersToEscape = @"!*'();:@&=+$,/?%#[]\" ";
NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet];
NSString *encodedString = [unescaped stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
return encodedString;
}
@jschmid
jschmid / prune.sh
Created December 2, 2016 10:00
Git prune branches not on origin anymore
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@jschmid
jschmid / image_link.md
Created March 3, 2013 14:31
Image with a link using Markdown
@jschmid
jschmid / email.java
Created February 11, 2013 19:54
Android send an email Intent
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("message/rfc822");
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"you@gmail.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "subject");
email.putExtra(Intent.EXTRA_TEXT, "message");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
@jschmid
jschmid / version.java
Created February 11, 2013 18:27
Get android version code and version name
PackageManager manager = this.getPackageManager();
PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
Toast.makeText(this,
"PackageName = " + info.packageName + "\nVersionCode = "
+ info.versionCode + "\nVersionName = "
+ info.versionName + "\nPermissions = " + info.permissions, Toast.LENGTH_SHORT).show();
@jschmid
jschmid / Activity.java
Created February 5, 2013 10:53
Android Activity with a custom protocol
// In the onCreate()
Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
Log.i(TAG, "Started by a user clicking " + urlStr);
doSomethingWithTheUrl(uri.toString(););
}
@jschmid
jschmid / AndroidManifest.xml
Last active December 12, 2015 04:18
Android keep screen on
<uses-permission android:name="android.permission.WAKE_LOCK" />
@jschmid
jschmid / AndroidManifest.xml
Created February 1, 2013 07:09
Poll the currently running Android Activity then replace it by our own
<uses-permission android:name="android.permission.GET_TASKS" />
@jschmid
jschmid / SecureActivity.java
Created February 1, 2013 07:27
Secure Android Activity that does not allow clicks when in the background, and prevents screenshots.
package pro.schmid.android.secureapp;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;