Skip to content

Instantly share code, notes, and snippets.

View prestongarno's full-sized avatar

Preston Garno prestongarno

View GitHub Profile
swalkinshaw /
Last active November 13, 2023 08:40
Designing a GraphQL API
nsk-mironov /
Last active December 25, 2017 23:27
Delegated properties

Delegated properties is a really nice feature of Kotlin and we are using them a lot in our code base. The entire project contains more than 500 delegated properties. Unfortunatelly, each property compiles to a class with 6 extra methods. While this can be fine if you're running on JVM, this is absolutely unacceptable in case you're targeting Android.

For example, the following class produces 2 more classes, Delegate$bar$1 and Delegate$foo$1:

public class Delegate(private val values: Map<String, Any>) {
  public val bar: String by values
  public val foo: String by values
marshall /
Created February 22, 2011 17:16
A reflection hack to override the APK ClassLoader so you can launch Activities in an external JAR.
// !!WARNING: Not recommended for production code!!
public class ClassLoaderActivity extends Activity
public void onCreate(Bundle savedInstanceState)
// file.jar has a dex'd "classes.dex" entry that you can generate with "dx" from any number of JARs or class files
ClassLoader dexLoader = new DexClassLoader("/path/to/file.jar", getCacheDir().getAbsolutePath(), null, getClassLoader());