Skip to content

Instantly share code, notes, and snippets.

View mediavrog's full-sized avatar

Maik B mediavrog

  • @shackersNFT
  • Germany / Japan
View GitHub Profile
@mediavrog
mediavrog / JapaneseCharacter.java
Last active August 26, 2020 09:03
Simple string conversion from Hiragana to Katakana and vice versa. Uses the JapaneseCharacter class from Duane J. May and combines it with a simple Utility class method to perform the actual conversion.
/**
* JapaneseCharacter contains static functions to do various tests
* on characters to determine if it is one of the various types of
* characters used in the japanese writing system.
* <p/>
* There are also a functions to translate between Katakana, Hiragana,
* and Romaji.
*
* @author Duane J. May <djmay@mayhoo.com>
* @version $Id: JapaneseCharacter.java,v 1.2 2002/04/20 18:10:24 djmay Exp $
@mediavrog
mediavrog / .bash_profile
Created April 7, 2014 09:22
Improved shell for github
export ANDROID_HOME=/Applications/AndroidStudio.app/sdk
export PATH=$HOME/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH
source git-completion.bash
# add current git branch to prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\[\033[00m\]\u@\h\[\033[01;34m\] \W \[\033[31m\]\$(parse_git_branch) \[\033[00m\]$\[\033[00m\] "
@mediavrog
mediavrog / dotmatrixforntlink
Created April 7, 2014 05:09
Nice Dot Matrix font
@mediavrog
mediavrog / NetworkUtils.java
Created March 18, 2014 08:54
When adding Authorization header for use with HttpConnection, beware of the WRAPPING. A wrapped Authorization header will always return 401./..
// the flag Base64.NO_WRAP is essential
public String generateBasicAuthString() {
return "Basic " + Base64.encodeToString(String.format("%s:%s", Utils.deobfuscate(BuildConfig.USER), Utils.deobfuscate(BuildConfig.PW)).getBytes(), Base64.URL_SAFE | Base64.NO_WRAP);
}
@mediavrog
mediavrog / gist:9363908
Created March 5, 2014 09:18
Tip: Add a junk object to your possibly leaking Listeners, Activities, whatever to make them spottable easier when MATing
private byte[] junk = new byte[10*1024*1024];
@mediavrog
mediavrog / IconizedMenu.java
Last active September 17, 2022 13:17
Android Compatibility popup menu with icons (requires support library v7)
/**
* Seems like the only way to use it currently (as of 10/2018) is through reflection
* see https://resocoder.com/2018/02/02/popup-menu-with-icons-android-kotlin-tutorial-code/
**/
package com.vuzz.snapdish.ui;
import android.content.Context;
import android.support.v7.internal.view.SupportMenuInflater;
import android.support.v7.internal.view.menu.MenuBuilder;
@mediavrog
mediavrog / build.regen_config.gradle
Created February 5, 2014 05:23
Always rebuild / regenerate the BuildConfig file to reflect changes made to buildConfigField
// always rebuild our build config
tasks.whenTaskAdded { task ->
if (task.name ==~ /generate[\w\W]+BuildConfig/) {
task.dependsOn "clean" + task.name.capitalize()
}
}
package com.yokogoshi.line_intent_test;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
@mediavrog
mediavrog / DecoratedRequestQueue.java
Created October 23, 2013 09:27
Make Volley RequestQueue / ThreadPool work with Espresso Testing library
package com.vuzz.snapdish.test.functional;
import android.os.Handler;
import com.android.volley.Cache;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.google.android.apps.common.testing.ui.espresso.contrib.CountingIdlingResource;
/**
* A dummy request queue which enables us to use the Volley Library properly with Espresso.
@mediavrog
mediavrog / init_crittercism.java
Last active December 24, 2015 01:19
Setup Crittercism
/*######################
* Crittercism
* crittercism.com
######################*/
JSONObject crittercismConfig = new JSONObject();
JSONObject crittermeta = new JSONObject();
try {
crittermeta.put("screen_name", "" + screen_name);
crittermeta.put("user_id", "" + user_id);