Skip to content

Instantly share code, notes, and snippets.

@pfn
pfn / extractor.py
Created December 1, 2015 03:40
gradle dependency extractor
#!/usr/bin/python
import re
modulere = re.compile("""\s*compile\s*['"]([^:]+):([^:]+):([^:@]+)(@aar)?['"]""")
repore = re.compile("""\s*maven\s*\{\s*url\s*['"]([^'"]+)['"]\s*\}\s*""")
script = file("mobile/build.gradle", "r")
lines = script.readlines()
def convertlines(acc, l):
repo = re.match(repore, l)
@pfn
pfn / ioapply.scala
Created November 23, 2015 19:19
iota strangeness
IO.apply({
val iota$generatedContainer$1 = iota.IO.apply[android.widget.FrameLayout](new android.widget.FrameLayout(this)).perform.apply();
Seq.apply(iota.IO.apply[android.view.View](new android.view.View(this))).foreach(((iov) => {
val iota$generatedView = iov.perform.apply();
if (iota$generatedView.getParent().$bang$eq(null))
iota$generatedView.getParent().asInstanceOf[ViewGroup].removeView(iota$generatedView)
else
();
iota$generatedContainer$1.addView(iota$generatedView)
}));
@pfn
pfn / createview.scala
Created November 23, 2015 17:12
layout.perform should create a new instance
override def onCreateView(i: LayoutInflater, c: ViewGroup, b: Bundle) = {
adapter foreach (_.context = getActivity)
val v = layout.perform()
def inputHeight = for {
a <- MainActivity.instance
h <- a.inputHeight
} yield h
log.v("view hash: " + System.identityHashCode(v) + " " + System.identityHashCode(this) + " " + System.identityHashCode(layout))
// why is this only occurring on gingerbread?
@pfn
pfn / lint.txt
Created November 20, 2015 01:35
lint errors from VectorDrawables
> android:lint
[error] [NewApi] src\main\res\drawable\ic_add_circle_black_24dp.xml:1:<vector> requires API level 21 (current min is 9) or building with Android Gradle plugin 1.4 or higher
[error] <vector xmlns:android="http://schemas.android.com/apk/res/android"
[error] ^
[error] [NewApi] src\main\res\drawable\ic_add_circle_white_24dp.xml:1:<vector> requires API level 21 (current min is 9) or building with Android Gradle plugin 1.4 or higher
[error] <vector xmlns:android="http://schemas.android.com/apk/res/android"
[error] ^
[error] [NewApi] src\main\res\drawable\ic_history_black_24dp.xml:1:<vector> requires API level 21 (current min is 9) or building with Android Gradle plugin 1.4 or higher
[error] <vector xmlns:android="http://schemas.android.com/apk/res/android"
[error] ^
@pfn
pfn / build.txt
Last active November 20, 2015 01:12
building u2020 with sbt
[pfnguyen@GALACTICA src] $ git clone https://github.com/jakewharton/u2020
Cloning into 'u2020'...
remote: Counting objects: 3519, done.
emote: Total 3519 (delta 0), reused 0 (delta 0), pack-reused 3519
Receiving objects: 100% (3519/3519), 8.96 MiB | 1.28 MiB/s, done.
Resolving deltas: 100% (1598/1598), done.
Checking connectivity... done.
[pfnguyen@GALACTICA src] $ cd u2020/
[pfnguyen@GALACTICA u2020] $ mkdir project
[pfnguyen@GALACTICA u2020] $ echo 'addSbtPlugin("com.hanhuy.sbt" % "android-gradle-build" % "1.1.9")' > project/p.sbt
@pfn
pfn / gist:ec2465ff64a7fd22ab40
Created November 19, 2015 21:06
all tests go
> scripted
[info] :: delivering :: com.hanhuy.sbt#android-sdk-plugin;1.5.9-SNAPSHOT :: 1.5.9-SNAPSHOT :: integration :: Thu Nov 19 12:54:52 PST 2015
[info] delivering ivy file to C:\Users\pfnguyen\src\sbt\target\scala-2.10\sbt-0.13\ivy-1.5.9-SNAPSHOT.xml
[info] Packaging C:\Users\pfnguyen\src\sbt\target\scala-2.10\sbt-0.13\android-sdk-plugin-1.5.9-SNAPSHOT.jar ...
[info] Done packaging.
[info] published android-sdk-plugin to C:\Users\pfnguyen\.ivy2\local\com.hanhuy.sbt\android-sdk-plugin\scala_2.10\sbt_0.13\1.5.9-SNAPSHOT\jars\android-sdk-plugin.jar
[info] published android-sdk-plugin to C:\Users\pfnguyen\.ivy2\local\com.hanhuy.sbt\android-sdk-plugin\scala_2.10\sbt_0.13\1.5.9-SNAPSHOT\srcs\android-sdk-plugin-sources.jar
[info] published android-sdk-plugin to C:\Users\pfnguyen\.ivy2\local\com.hanhuy.sbt\android-sdk-plugin\scala_2.10\sbt_0.13\1.5.9-SNAPSHOT\docs\android-sdk-plugin-javadoc.jar
[info] published ivy to C:\Users\pfnguyen\.ivy2\local\com.hanhuy.sbt\android-sdk-plugin\scala_2.10\sbt_0.13\1.5.9-S
@pfn
pfn / gist:cb87676183d6a77bd4b3
Created November 13, 2015 07:17
Trivial build
pfnguyen@galactica1:~/src/ts$ sbt "gen-android android-22 m.m m"
[info] Loading global plugins from /home/pfnguyen/.sbt/0.13/plugins
[info] Set current project to ts (in build file:/cifs/pfnguyen/src/ts/)
[info] Creating project: m
Created directory /cifs/pfnguyen/src/ts/src/main/java
Created directory /cifs/pfnguyen/src/ts/src/main/java/m/m
Added file ./src/main/java/m/m/MainActivity.java
Created directory /cifs/pfnguyen/src/ts/src/androidTest/java
Created directory /cifs/pfnguyen/src/ts/src/androidTest/java/m/m
Added file ./src/androidTest/java/m/m/MainActivityTest.java
package com.hanhuy.android.airshow
import java.net.{DatagramPacket, InetAddress, InetSocketAddress, DatagramSocket}
import java.nio.ByteBuffer
import java.nio.channels.DatagramChannel
import java.util.concurrent.TimeUnit
import android.content.res.Configuration
import android.graphics.Point
import android.hardware.display.VirtualDisplay
@pfn
pfn / output.txt
Created September 23, 2015 20:25
key-path plugin output
pfnguyen@galactica1:~/src/sbt-key-path-test$ sbt "keypath package test:compile" [info] Loading global plugins from /home/pfnguyen/.sbt/0.13/plugins
[info] Loading project definition from /cifs/pfnguyen/src/sbt-key-path-test/project
[info] Set current project to sbt-key-path-test (in build file:/cifs/pfnguyen/src/sbt-key-path-test/)
[info] Path: compile:package
[info] Looking for: compile:package <- test:compile
[error] No paths found
pfnguyen@galactica1:~/src/sbt-key-path-test$ sbt "keypath package update"
[info] Loading global plugins from /home/pfnguyen/.sbt/0.13/plugins
[info] Loading project definition from /cifs/pfnguyen/src/sbt-key-path-test/project
[info] Set current project to sbt-key-path-test (in build file:/cifs/pfnguyen/src/sbt-key-path-test/)
@pfn
pfn / 00-gradle-generated.sbt
Created August 28, 2015 17:49
generated sbt build definition from gradle
val viewserver = Project(id = raw"""viewserver""", base = file(raw"""C:\Users\pfnguyen\src\vs2\viewserver""")).settings(
android.Plugin.androidBuildAar:_*).settings(
SettingKey[android.Keys.PackagingOptions]("packagingOptions") in config("android") := android.Keys.PackagingOptions(Nil, Nil, Nil),
SettingKey[scala.collection.Seq[sbt.Resolver]]("resolvers") ++= List(raw"""https://jcenter.bintray.com/""" at raw"""https://jcenter.bintray.com/""",
raw"""https://jcenter.bintray.com/""" at raw"""https://jcenter.bintray.com/""",
raw"""file:/C:/Users/pfnguyen/android-sdk-windows/extras/android/m2repository/""" at raw"""file:/C:/Users/pfnguyen/android-sdk-windows/extras/android/m2repository/""",
raw"""file:/C:/Users/pfnguyen/android-sdk-windows/extras/google/m2repository/""" at raw"""file:/C:/Users/pfnguyen/android-sdk-windows/extras/google/m2repository/"""),
SettingKey[java.lang.String]("platformTarget") in config("android") := raw"""android-21""",
SettingKey[java.lang.String]("nam