Skip to content

Instantly share code, notes, and snippets.

View rcketscientist's full-sized avatar

Anthony Mandra rcketscientist

View GitHub Profile
import androidx.lifecycle.LiveData
import androidx.paging.DataSource
import androidx.room.*
import androidx.sqlite.db.SupportSQLiteQuery
@Dao
abstract class MetadataDao {
@get:Query("SELECT * FROM meta")
abstract val allImages: LiveData<List<MetadataEntity>>
import androidx.lifecycle.LiveData
import androidx.paging.DataSource
import androidx.room.*
import androidx.sqlite.db.SimpleSQLiteQuery
import androidx.sqlite.db.SupportSQLiteQuery
import com.anthonymandra.content.Meta
import com.anthonymandra.rawdroid.XmpFilter
import com.anthonymandra.util.DbUtil
import java.util.*
package com.anthonymandra.rawdroid.data
import android.arch.persistence.room.Delete
import android.arch.persistence.room.Insert
import android.arch.persistence.room.RawQuery
import android.arch.persistence.room.Update
abstract class PathDao<T : PathEntity> {
protected abstract val database: String
private val PATH_DELIMITER = "/"
package com.anthonymandra.rawdroid.data
import android.arch.lifecycle.LiveData
import android.arch.paging.DataSource
import android.arch.persistence.db.SimpleSQLiteQuery
import android.arch.persistence.db.SupportSQLiteQuery
import android.arch.persistence.room.*
import com.anthonymandra.content.Meta
import com.anthonymandra.rawdroid.XmpFilter
import com.anthonymandra.util.DbUtil
@rcketscientist
rcketscientist / Dao.java
Last active December 31, 2017 21:27
Quick glance that demonstrates generating a proper Room object model including an M:N junction table. This could probably be done more efficiently. Ideally @relation could walk through ForeignKey avoiding all this nonsense. M:N "List<String>" is GROUP_CONCAT to reduce the result to single entities, then the keyword is split with a TypeConverter.
@Dao
public abstract class MetadataDao {
@Query("SELECT id, name, type, height, width, orientation, " +
"(SELECT GROUP_CONCAT(name) " +
"FROM meta_subject_junction " +
"JOIN xmp_subject " +
"ON xmp_subject.id = meta_subject_junction.subjectId " +
"WHERE meta_subject_junction.metaId = meta.id) AS keywords, " +
"(SELECT documentUri " +
"FROM image_parent " +
package com.keysight.hbase
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.spark.HBaseContext
import org.apache.spark.sql.{DataFrame, SQLContext}
import org.apache.spark.{SparkConf, SparkContext}
object AverageSensorOverTime1 /*extends App*/ {
def main(args:Array[String]) {
@rcketscientist
rcketscientist / java7install.sh
Created September 18, 2017 12:59 — forked from mikakoivisto/java7install.sh
Ubuntu 14.04 Java 7 automated install script
cat - <<-EOF >> /etc/apt/sources.list.d/webupd8team-java.list
# webupd8team repository list
deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
# deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
EOF
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xEEA14886
echo debconf shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | /usr/bin/debconf-set-selections
package com.drew.metadata;
public interface Key<T>
{
String getTagName();
String getTagType();
String getSummary();
String getDescription(T storedValue);
Object getValue();
}
@rcketscientist
rcketscientist / PanasonicRawDistortionDirectory.java
Last active February 21, 2017 15:21
Example generic enum directory
/*
* Copyright 2002-2017 Drew Noakes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@rcketscientist
rcketscientist / scv_examples.java
Created November 11, 2015 13:41
SCV examples
//TODO: Hack for showcase appearing behind nav bar
public int getNavigationBarHeight(int orientation) {
try {
Resources resources = getResources();
int id = resources.getIdentifier(
orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape",
"dimen", "android");
if (id > 0) {
return resources.getDimensionPixelSize(id);
}