Skip to content

Instantly share code, notes, and snippets.

View JeppeLeth's full-sized avatar

Jeppe Leth JeppeLeth

View GitHub Profile
@JeppeLeth
JeppeLeth / keybase.md
Last active October 10, 2017 19:03
Letbane proof

Keybase proof

I hereby claim:

  • I am jeppeleth on github.
  • I am jeppeleth (https://keybase.io/jeppeleth) on keybase.
  • I have a public key ASA6DAMkGUk4G0wq8agDWO5JW5qxOJV9vfGgkGtW3gdtHwo

To claim this, I am signing this object:

@JeppeLeth
JeppeLeth / JavaNetCookieJar
Created September 11, 2017 08:13
JavaNetCookie - A cookie jar that delegates to a java.net.CookieHandler
/**
* A cookie jar that delegates to a {@link java.net.CookieHandler}.
* Copied from https://github.com/square/okhttp/blob/master/okhttp-urlconnection/src/main/java/okhttp3/JavaNetCookieJar.java
*/
public class JavaNetCookieJar implements CookieJar {
private final CookieHandler cookieHandler;
public JavaNetCookieJar(CookieHandler cookieHandler) {
this.cookieHandler = cookieHandler;
}
@JeppeLeth
JeppeLeth / android_demo_mode.sh
Created August 10, 2017 06:36
Android Demo mode activation using ADB
#!/bin/sh
CMD=$1
if [[ $ADB == "" ]]; then
ADB=adb
fi
if [[ $CMD != "on" && $CMD != "off" ]]; then
echo "Usage: $0 [on|off] [hhmm]" >&2
exit
@JeppeLeth
JeppeLeth / fix_strings.md
Created June 9, 2017 07:01 — forked from Superbil/fix_strings.md
Fix *.strings can't diff in git
@JeppeLeth
JeppeLeth / clear-android-things-apps.sh
Created April 18, 2017 18:28 — forked from blundell/clear-android-things-apps.sh
Uninstall all apps on an Android Device that have the intent-filter category IOT_LAUNCHER
#!/bin/bash
sp="/-\|"
sc=0
spin() {
printf "\b${sp:sc++:1}"
((sc==${#sp})) && sc=0
}
endspin() {
printf "\r"
}
@JeppeLeth
JeppeLeth / LocalizeStringsFromAndroid.rb
Created April 15, 2017 09:24 — forked from ebaker355/LocalizeStringsFromAndroid.rb
Translate Android strings.xml files to iOS Localizable.strings files
#!/usr/bin/env ruby
# gist: https://gist.github.com/3217498
# This script can be called from an Xcode 'Run Script' build phase at the
# beginning of the build process, like this:
#
# ${PROJECT_DIR}/LocalizeStringsFromAndroid.rb ${PROJECT_NAME}
#
# This script should be placed in the same directory as your .xcodeproj
@JeppeLeth
JeppeLeth / convertLocalizable.rb
Created April 15, 2017 09:03 — forked from florianmski/convertLocalizable.rb
Convert your Localizable.strings (iOS) to strings.xml (Android)
#!/usr/bin/ruby
# based on https://github.com/tmurakam/cashflow/blob/0a01ac9e0350dfb04979986444244f8daf4cb5a8/android/convertStrings.rb
# support comments and Converter such as "%@", "%d", "%0.1f"...
# in your directory : ./main.rb Localizable.strings
file = File.open("strings.xml", "w");
file.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
file.puts "<resources>"
@JeppeLeth
JeppeLeth / gist:224e75abe56160a1f0e31ede0b807804
Last active April 15, 2017 07:56 — forked from paour/gist:11291062
Android String Weblate, Replacing values in arrays.xml with @string/ links
#! /usr/bin/python
import argparse
import os.path
import glob
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description='''\
Replacing values in arrays.xml with @string/ links. Generates three new files for each locale:
@JeppeLeth
JeppeLeth / build_android_sdk_version.gradle
Created April 14, 2017 07:43
Android gradle: Lastest buildToolsVersions and sdkVersion
import org.codehaus.groovy.runtime.StackTraceUtils
int[] sdksAvailable() {
def sdks = new ByteArrayOutputStream()
exec {
commandLine 'android', 'list'
standardOutput = sdks
}
sdks = sdks
// get the output
@JeppeLeth
JeppeLeth / Getter Ignore m Prefix
Created February 5, 2017 13:43
Android Studio Getter/Setter Ignore m Prefix Templates
#if($field.modifierStatic)
static ##
#end
$field.type ##
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
#if ($field.boolean && $field.primitive)
#if ($StringUtil.startsWithIgnoreCase($name, 'is'))
#set($name = $StringUtil.decapitalize($name))
#else
is##