Skip to content

Instantly share code, notes, and snippets.

View bclymer's full-sized avatar

Brian Clymer bclymer

  • Twitch
  • Omaha, NE
View GitHub Profile
@bclymer
bclymer / DiscordSized.bat
Last active April 15, 2023 05:33
Automatically convert a video file into an 8MB file with decent quality to send via Discord.
@ECHO OFF
IF "%~1"=="" (
ECHO No file provided, please drag and drop an MP4 onto this file to run.
EXIT /B
)
IF %~z1 LSS 8388608 (
ECHO File less than 8MB. Exiting.
PAUSE
exit
@bclymer
bclymer / R.generated.swift
Created April 24, 2019 20:17
R.swift Objective-C Support
//
// Compatibility layer so resources can be used in ObjC
//
@objcMembers
@available(swift, obsoleted: 1.0, message: "Use R. instead")
public class RObjc: Foundation.NSObject {
// R.color.keyboardFocusIndicatorColor()
@available(tvOS 11.0, *)
@available(iOS 11.0, *)
@bclymer
bclymer / KotlinRxBug.kt
Last active February 16, 2016 19:18
Kotlin RxJava Nullable Bug
import rx.Observable
data class TestUser(val name: String)
fun getTestUser(): Observable<TestUser> {
return Observable.just(TestUser("Brian")).flatMap { getUser() } // this compiles
}
fun getTestUser2(): Observable<TestUser> {
val observable = Observable.just(TestUser("Brian")).flatMap { getUser() }
@bclymer
bclymer / HttpClient.kt
Created January 21, 2016 19:00
Kotlin Realm Primitive Arrays Workaround
val realmIntArrayType = object : TypeToken<RealmIntArray>() {}.type
val realmLongArrayType = object : TypeToken<RealmLongArray>() {}.type
val realmStringArrayType = object : TypeToken<RealmStringArray>() {}.type
val gson = GsonBuilder()
.setExclusionStrategies(object : ExclusionStrategy {
override fun shouldSkipClass(clazz: Class<*>?): Boolean {
return false
}
override fun shouldSkipField(f: FieldAttributes?): Boolean {
//
// HudlHlsAvPlayerCache.m
// Hudl
//
// Created by Brian Clymer on 3/6/15.
// Copyright (c) 2015 Agile Sports Technologies, Inc. All rights reserved.
//
#import "HudlHlsAvPlayerCache.h"
@bclymer
bclymer / NetworkListenerUtility.java
Last active December 30, 2015 18:19
A utility class that removes the need to have a broadcast receiver listening for `ConnectivityManager.CONNECTIVITY_ACTION` in a number of different classes. Now just register with this class and get updated when the connectivity status changes.
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@bclymer
bclymer / EventBus.java
Last active December 23, 2015 23:19
Manage event subscriptions in Android.
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
@bclymer
bclymer / ThreadManager.java
Last active May 25, 2019 13:16
A class to help you do thread-y things in Java.
package com.example.threadmanagertests;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;