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 / 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()
}
}
@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 / 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 / dotmatrixforntlink
Created April 7, 2014 05:09
Nice Dot Matrix font
@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 / build.gradle
Created July 15, 2014 04:59
Simple gradle build file for legacy structure library projects
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
@mediavrog
mediavrog / build.gradle
Created July 16, 2014 09:25
Evernote library build.gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
// Create the Global class in your /app folder root package:
import play.api.{GlobalSettings, Play}
import play.api.Play.current
import play.api.mvc._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
/**
@mediavrog
mediavrog / bound_greeting.js
Created February 10, 2015 08:29
JS bound greeting
/*
* Assuming we have some object with properties and methods
*/
var me = {
first_name: 'Ahikar',
last_name: 'Grilka',
race: 'Klingon',
email: 'AhikarGrilka@jourrapide.com',
occupation: 'Commander of Defence',
greet: function(other_person){
import com.github.aselab.activerecord.{PlayConfig, ActiveRecordTables}
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
import play.api.Play
import play.api.test.FakeApplication
trait ActiveRecordAutoRollback extends BeforeAndAfterEach with BeforeAndAfterAll {
self: ApiBaseSpec =>
def schema: Seq[ActiveRecordTables] = Seq(ActiveRecordTables.find("models.Tables"))