Skip to content

Instantly share code, notes, and snippets.

View JeppeLeth's full-sized avatar

Jeppe Leth JeppeLeth

View GitHub Profile
@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 / happy_git_on_osx.md
Created January 2, 2017 13:06 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

@JeppeLeth
JeppeLeth / filter.regexp
Created July 8, 2016 20:15 — forked from stepango/filter.regexp
Filter for logcat
^(?!(NotificationManager|Timeline|SensorManager|Configs|libc-netbsd|art|stetho|Choreographer|CliptrayUtils|BubblePopupHelper|ViewRootImpl|libEGL|System.out|PhoneWindow))
cwebp -pass 10 -mt -alpha_filter best -alpha_cleanup -m 6 -lossless
What do all these arguments do?
-pass 10 Determines the number of passes that will be performed on the image, maximum 10. More = longer processing time, but potentially smaller images. Yum.
-mt Use multi-threading
-alpha_filter best "predictive filtering for alpha plane", tries to optimize the alpha channel. Options are none, fast, and best.
-m 6 Determines compression method. 0=fast, 6=slowest
-lossless Makes this WebP lossless. Image produced will be 100% identical once decompressed.
@JeppeLeth
JeppeLeth / PhantomReferenceLeakDetector.java
Last active May 8, 2016 14:28 — forked from nhachicha/PhantomReferenceLeakDetector.java
Example demonstrating how to use PhantomReference to detect memory leak
// Talk and slides: https://speakerdeck.com/nhachicha/droidcon-sf-advanced-techniques-for-concurrency-and-memory-management
static class Activity {
interface Listener {}
Service service;
Activity(Service service) {
this.service = service;
}
void onStart() {
service.registerListener(new Listener() {});//Listener hold a reference to Activity
@JeppeLeth
JeppeLeth / Synchronizers.java
Last active May 8, 2016 14:28 — forked from nhachicha/Synchronizers.java
Examples using synchronizers (CountDownLatch, CyclicBarrier, Phaser)
// Talk and slides: https://speakerdeck.com/nhachicha/droidcon-sf-advanced-techniques-for-concurrency-and-memory-management
// ********************************************************************* //
// ************************** CountDownLatch ************************** //
// ********************************************************************* //
public class RandomIntAverage {
CountDownLatch controller = new CountDownLatch(NB_THREADS);
public void randomIntAvg() throws InterruptedException {
for (int i = 0; i < NB_THREADS; i++) {