Skip to content

Instantly share code, notes, and snippets.

View shadow7's full-sized avatar

Evan Denerley shadow7

  • NEU
  • Boston MA
View GitHub Profile
@shadow7
shadow7 / SavedManager-Architecture.md
Created February 19, 2026 17:01
SavedManager Architecture: Room as Single Source of Truth

SavedManager Architecture Documentation

Executive Summary

This document defines the optimal architecture for saved articles sync and display in android-phoenix, addressing parallel batch downloading, Room persistence, Kotlin coroutines state management, and Compose loading patterns across multiple cache layers.


Flow Charts

@shadow7
shadow7 / okio.java
Created August 16, 2017 13:42
Okio helper method
/**
* Convert a file to a String.
*
* @param fileName the filename to read
* @return the file formatted as a String
*/
public static String readFile(@NonNull Context context, @NonNull final String fileName) {
BufferedSource source;
try {
InputStream inputStream = context.openFileInput(fileName);
//Error: bind EADDRINUSE null:3777
//How do I change this to a port that isn't in use
// Include the cluster module
var cluster = require('cluster');
// Count the machine's CPUs
var cpuCount = require('os').cpus().length;
var http = require('http');
var net = require('net');
//#Main Repository link: https://github.com/ProxyApp/ProxyApi/blob/youtube_middlware/
//#File: https://github.com/ProxyApp/ProxyApi/blob/youtube_middlware/middleware/userMiddleware.js
//User middleware function can reference res and next inside the firebase 'function(error)'
//callback and return a response status or call 'next(error)'
modifyUserGroups: function (userId, groups, res, next) {
firebaseStore.child(vals.USERS).child(userId).child(vals.GROUPS)
.update(groups, function (error) {
if (error) {
//these get called correctly
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_card_icon_alpha_30" android:gravity="left"/>
<item android:drawable="@drawable/ic_card_icon_alpha_70"
android:gravity="left"
android:left="20dp"/>
<item android:drawable="@drawable/ic_card_icon" android:left="50dp"/>
</layer-list>
@shadow7
shadow7 / enumWithValues.java
Created March 7, 2016 22:28
Enum with default values
public enum NotificationCard {
WHOOPS(0, KEY_DISMISSED_WHOOPS, R.string.notification_safe_info_title,
R.string.notification_safe_info_message, R.raw.ic_alien,
R.color.common_deep_purple, R.string.ok),
SAFE_INFO(1, KEY_DISMISSED_SAFE_INFO, R.string.notification_safe_info_title,
R.string.notification_safe_info_message, R.raw.ic_chameleon_framed,
R.color.common_proxy_purple, R.string.ok),
SHARE_PROFILE(2, KEY_DISMISSED_SHARE_PROFILE, R.string.notification_share_profile_title,
"use strict";
const _ = require('underscore'),
middleware = require('../middleware/common'),
sharedMiddleware = require('../middleware/sharedLinkMiddleware'),
vals = require('../middleware/middlewareGlobals');
var UserMiddleware = function (store) {
this._firebaseStore = store;
};
/**
* Ensure authorization with firebase before requesting any data.
* @param req request
* @param res response
* @param next call next
*/
middleware.ensureAuthenticated = function (req, res, next) {
var authToken = req.query.auth;
if (authToken == null) {
console.log("Null firebase token");
var express = require('express');
var Firebase = require('firebase');
var router = express.Router();
//var firebaseUsersRef = new Firebase('https://dazzling-torch-1917.firebaseio.com/users');
var firebaseUsersRef = new Firebase('https://proxy-test.firebaseio.com/users');
//var galen = {id: "google:101993683995198877055", name: "galen"};
//var evan = {id: "google:109993703609292176173", name: "evan"};
//var sUsers = ["google:101993683995198877055", "google:101993683995198877055"];
/**
* I use the BaseCommand class to encapsulate data used to make an Rx Observable call.
* An Rx call usually combines the action of saving a model object to firebase,
* converting the model to a RealmObject and also saving to Realm into one atomic function flow with
* an EventCallback. BaseCommands are posted from any Fragment or Activity with ProxyApplication.java's
* getRxBus().post() method. The BaseCommand is then processed in ProxyApplication which creates an
* IntentService to call the posted BaseCommand's interface ExecuteCommand, "execute()" method.
* This returns a list of events, List<EventCallback>, which contain the updated user data to
* post to subscribers of the event type.
*/