Skip to content

Instantly share code, notes, and snippets.

@pfn
pfn / keypath.txt
Created January 5, 2016 04:26
sbt keypath output for multi-project dependencies
[pfnguyen@GALACTICA sbtm] $ sbt "keypath b/compile a/compile"
[info] Loading global plugins from C:\Users\pfnguyen\.sbt\0.13\plugins
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[info] Loading project definition from C:\Users\pfnguyen\src\sbtm\project
[info] Updating {file:/C:/Users/pfnguyen/src/sbtm/project/}sbtm-build...
[info] Resolving org.eclipse.jgit#org.eclipse.jgit.archive;3.7.0.201502260915-r [info] Resolving com.hanhuy.sbt#key-path;0.3-SNAPSHOT ...
[warn] Host repo.scala-sbt.org not found. url=https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.hanhuy.sbt/key-path/scala_2.10/sbt_0.13/0.3-SNAPSHOT/ivys/ivy.xml
[info] You probably access the destination server through a proxy server that is not well configured.
@Override
public boolean onNestedFling(final CoordinatorLayout coordinatorLayout, final AppBarLayout child, View target, float velocityX, final float velocityY, boolean consumed) {
if (target instanceof RecyclerView && velocityY < 0) {
final RecyclerView recyclerView = (RecyclerView) target;
final long start = System.currentTimeMillis();
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
@pfn
pfn / file.rb
Created December 8, 2015 14:49
Android created Gist
> inspect libraryDependencies
[info] Setting: scala.collection.Seq[sbt.ModuleID] = List()
[info] Description:
[info] Declares managed dependencies.
[info] Provided by:
[info] {file:/cifs/pfnguyen/src/sample/}com-foo/*:libraryDependencies
[info] Defined at:
[info] (sbt.Classpaths) Defaults.scala:1142
[info] Dependencies:
[info] *:scalaOrganization
@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