Skip to content

Instantly share code, notes, and snippets.

View caseykulm's full-sized avatar
🔲

Casey Kulm caseykulm

🔲
View GitHub Profile
@caseykulm
caseykulm / aesdecrypt.txt
Created October 30, 2013 13:24
AES Decryption order of steps
Encrypting plaintext with key in 128-bit mode.
The Expanded Key:
00000000 62626262 9BF99BF9 9069F20B EE87757E 7FF88DF3 EC14996A 2135ACC6 0E3B9751 B18A1D4C B43E236F
00000000 63636363 98FB98FB 976CF40F 066A9E91 2E44DA4B 6125FFB4 7550AF1B F9A9061D D47D7B66 EF92E98F
00000000 63636363 98FB98FB 34CF57AC DA1542EE 2B3E7C92 4B75099B 17626BF0 03610AFA D8B9B349 5BE25118
00000000 63636363 C9AAC9AA 50FA3399 7B81B22B 8809BB90 858C37A7 870B3C9B 3338049F E2DADE41 CB11CF8E
After addRoundKey(0):
00000000000000000000000000000000
@caseykulm
caseykulm / SpinnerNoSpinner.java
Last active August 30, 2015 03:10
Spinner for Asynchronous and no spinner for Synchronous Observables
public class DataStore {
public static Observable<Something> getSomethingObservable() {
Something cachedSomething = MyCache.getCachedSomething();
if (cachedSomething != null) {
return Observable.just(cachedSomething); // still on same thread so returned to subscriber synchronously
}
return myRestService.getSomething(); // on separate Retrofit worker thread so returned to subscriber asynchronously
@caseykulm
caseykulm / SharingObservableInstance.java
Last active August 29, 2015 14:27
How to share one instance of an Observable
ConnectableObservable<Foo> connectableFooObservable = fooObservable.share();
Observable
.combineLatest(connectableFooObservable, obsA, (foo, a) -> { // do something })
.subscribe();
Observable
.combineLatest(connectableFooObservable, obsB, (foo, b) -> { // do something })
.subscribe();
@caseykulm
caseykulm / android_accept_license.sh
Created April 11, 2016 17:51 — forked from eyal-rounds/android_accept_license.sh
shell script that accept the license of android sdk update --no-ui
#!/usr/bin/expect -f
# Usage example:
# ./accept-licenses "android update sdk --no-ui --all --filter build-tools" "android-sdk-license-bcbbd656|intel-android-sysimage-license-1ea702d1"
set timeout 1800
set cmd [lindex $argv 0]
set licenses [lindex $argv 1]
spawn {*}$cmd
@caseykulm
caseykulm / EventView.java
Last active July 21, 2016 20:21
FrameLayout that knows when it first becomes visible on screen
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
@caseykulm
caseykulm / EventView.java
Last active August 4, 2016 16:08
New and improved helper class to determine when view enter/exits the visible viewport
public class EventView {
public interface EventViewListener<ViewType extends View> {
/**
* @param onScreen When the view enters/exits the viewport. Not to be confused with {@link View#VISIBLE}.
*/
void onVisibleOnScreenStateChanged(boolean onScreen);
/**
* Verbose method that is called every time the view hierarchy has the potential to
* move this view in/out of the viewport. Useful for debugging, but will be called
@caseykulm
caseykulm / ViewUtil.java
Created August 12, 2016 15:48
isVisibleOnScreen
public class ViewUtil {
static boolean isVisibleOnScreen(View view, Rect rect, Point globalOffset) {
if (view == null) {
throw new IllegalArgumentException("view must not be null");
}
boolean isVisibleOnScreen = view.getGlobalVisibleRect(rect, globalOffset);
return isVisibleOnScreen;
}
@caseykulm
caseykulm / SystemWindowUtil.java
Created May 16, 2017 14:32
Helper to get System Window permission
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
public class SystemWindowUtil {
private final Context appContext;
public SystemWindowUtil(Context appContext) {
this.appContext = appContext;
@caseykulm
caseykulm / SerialDelayUtil.java
Created June 2, 2017 15:29
Serial Delay Util
public class SerialDelayUtil {
private final SerialDelayHandler serialDelayHandler;
public SerialDelayUtil() {
this.serialDelayHandler = new SerialDelayHandler(Looper.getMainLooper());
}
/**
* <p>
* Runs the runnable after millisDelay, but every time this function is called
@caseykulm
caseykulm / OkioExtensions.kt
Created June 22, 2017 16:50
Okio Extensions
// TODO: Actually convert the below to Kotlin
/**
* Reads file and returns a String.
*
* @param file the file to read
* @return the string with file content or null
*/
@Nullable
public static String tryReadFile(@NonNull final File file) {