Skip to content

Instantly share code, notes, and snippets.

@maiatoday
maiatoday / gist:6312827
Created August 22, 2013 21:10
Trying to get OpenCV working with gradle and android studio
here is a topic we known as: "https://gist.github.com/khernyo/4226923", But i have try this method in gradle plugin 0.4.0+, it doesn't copy the so libs to apk.
So I'm confused. But I figured out a new way to hack this before gradle support.
The way is: use jar to copy so libs. Is it amazing?right?. Let me show how-to:
If you have the following structure:
project
|---libs
|---armeabi/xxx.so
|---xxx.jar
|---xxx.jar
1.We archive the armeabi folder to zip named:armeabi.zip with the folder in zip like: lib/armeabi/xxx.so
@maiatoday
maiatoday / usbiso
Created August 29, 2013 08:46
Make iso of a usb
#check first if /dev/sdb is correct, this will copy from usb to .iso
sudo dd if=/dev/sdb of=usb-image.iso
#now to copy the iso back onto a disk
sudo dd if=usb-image.iso of=/dev/sdb

Keybase proof

I hereby claim:

  • I am maiatoday on github.
  • I am maiatoday (https://keybase.io/maiatoday) on keybase.
  • I have a public key whose fingerprint is 0911 58E2 03B1 2CBA 7534 C9CA D4FE 1C84 9718 E27F

To claim this, I am signing this object:

@maiatoday
maiatoday / getdb
Last active December 7, 2015 10:10
getdb - little shell script to pull the db for an app on an android emulator or device.
#!/bin/bash
display_usage() {
echo -e "\nUsage:\n`basename $0` -p [package] -n [dbname] \n"
}
# if less than two arguments supplied, display usage
if [ $# -le 2 ]
then
display_usage
class ArrayMapAdapter extends BaseAdapter {
private final ArrayMap<String, String> mData;
public ArrayMapAdapter(ArrayMap<String, String> map) {
mData = map;
}
@Override
public int getCount() {
return mData.size();
@maiatoday
maiatoday / gist:2df1e24224b9def4fa0b11cd2d5a6ff6
Last active April 26, 2017 15:20
android signing config solution

in ~/.gradle/gradle.properties APP.signing=/home/user/.signing/appname/prefix

in /home/user/.signing/appname put 2 files prefix.keystore the keystore and a gradle snippet with name prefix.gradle prefix.gradle:

android {
    buildTypes {
        debug {
            buildConfigField 'String', 'BASE_URL', '"https://api-debug.example.com"'
@maiatoday
maiatoday / ContrivedParams.kt
Created January 26, 2018 13:15
ContrivedParams
@Parcelize data class ContrivedParams(val title:String,
val starCount:Int,
val colour:String) : Parcelable
@maiatoday
maiatoday / intended.kt
Created January 26, 2018 13:16
intendedTest
intended(allOf(
hasComponent(StarActivity::class.java.name),
hasExtras(
hasEntry(StarActivity.EXTRA_PARAMS, allOf(isA(ContrivedParams::class.java),
equalTo(expectedParams))))))
@maiatoday
maiatoday / hasStarCount.kt
Created January 26, 2018 13:17
starcountCustomMatcher
fun hasStarCount(i: Int): Matcher<ContrivedParams> {
return object : TypeSafeMatcher<ContrivedParams>() {
override fun describeTo(description: Description) {
description.appendText("starCount should return ").appendValue(i)
}
override fun describeMismatchSafely(item: ContrivedParams, mismatchDescription: Description) {
mismatchDescription.appendText(" was ").appendValue(item.starCount)
}
@maiatoday
maiatoday / doggoDonations.js
Created March 29, 2018 18:12
Root code to donate to the animal welfare when I drink a coffee
// This runs before the deduct
function beforeTransaction(transaction) {
return true; // Approve transaction
}
// This runs after the deduct
function afterTransaction(transaction) {
var amountString = zarString(transaction.amount);
var balanceString = zarString(root.account().balance);
var shopString = transaction.merchant.name;