-i - ignore errors
-c - continue
-t - use video title as file name
--extract-audio - extract audio track
| #!/usr/bin/env python2 | |
| # lrdcq | |
| # usage python2 unwxapkg.py filename | |
| import sys, os | |
| import struct | |
| class WxapkgFile(object): | |
| nameLen = 0 |
| import android.app.Activity | |
| import android.app.Service | |
| import android.content.ComponentName | |
| import android.content.Context | |
| import android.content.Intent | |
| import android.content.Intent.EXTRA_SUBJECT | |
| import android.content.Intent.EXTRA_TEXT | |
| import android.net.Uri | |
| import kotlin.properties.ReadWriteProperty | |
| import kotlin.reflect.KClass |
| import groovy.xml.MarkupBuilder | |
| // Task to generate our public.xml file | |
| // See https://developer.android.com/studio/projects/android-library.html#PrivateResources | |
| // We assume resources within res-public are public | |
| task generatepublicxml { | |
| def resDir = project.projectDir.absolutePath + "/src/main/res-public" | |
| // Include the desired res types |
| #!/bin/bash | |
| aria2c -j5 -i list.txt -c --save-session out.txt | |
| has_error=`wc -l < out.txt` | |
| while [ $has_error -gt 0 ] | |
| do | |
| echo "still has $has_error errors, rerun aria2 to download ..." | |
| aria2c -j5 -i list.txt -c --save-session out.txt | |
| has_error=`wc -l < out.txt` | |
| sleep 10 |
| /** | |
| * A Gist proving that Kotlin's nullable type can be made into a monad without wrapping into another | |
| * object and satisfy the Monadic laws | |
| * | |
| * Kotlin has comprehensive null safety built into the language enforced at compile time, using its | |
| * nullable type. | |
| * | |
| * Its language structure makes dealing with nullable values simple and succinct. Unlike other language | |
| * monadic constructs such as Option (scala), Optional(Java8+) and Maybe(Haskell), it is enforced at | |
| * compile time and is compatible with existing non monad aware API (for example, |
| package com.oasisfeng.hack; | |
| import android.support.annotation.CheckResult; | |
| import android.support.annotation.NonNull; | |
| import android.support.annotation.Nullable; | |
| import android.util.Log; | |
| import java.io.IOException; | |
| import java.lang.reflect.AccessibleObject; | |
| import java.lang.reflect.Constructor; |
| public static Action1<Throwable> crashOnError() { | |
| final Throwable checkpoint = new Throwable(); | |
| return throwable -> { | |
| StackTraceElement[] stackTrace = checkpoint.getStackTrace(); | |
| StackTraceElement element = stackTrace[1]; // First element after `crashOnError()` | |
| String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)", | |
| element.getClassName(), | |
| element.getMethodName(), | |
| element.getFileName(), | |
| element.getLineNumber()); |
| public class Pager<I, O> { | |
| private static final Observable FINISH_SEQUENCE = Observable.never(); | |
| private PublishSubject<Observable<I>> pages; | |
| private Observable<I> nextPage = finish(); | |
| private Subscription subscription = Subscriptions.empty(); | |
| private final PagingFunction<I> pagingFunction; | |
| private final Func1<I, O> pageTransformer; |
| import org.gradle.internal.os.OperatingSystem; | |
| String getJavaHome(String version) { | |
| def stdout = new ByteArrayOutputStream() | |
| exec { | |
| commandLine "/usr/libexec/java_home", "-v", version | |
| standardOutput = stdout; | |
| } | |
| return stdout.toString().trim() | |
| } |