Skip to content

Instantly share code, notes, and snippets.

@kingargyle
kingargyle / End GCode
Last active February 9, 2024 10:35
Prusa Slicer Anycubic Kobra Neo
M117 Cooling down...
M104 S0 ; turn off extruder
M107 ; Fan off
M140 S0; Turn bed off
M84 ; disable motors
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 ;X-20 Y-20 F240 ;move Z up a bit and retract filament even more
G28 X0 ;move X to min endstops, so the head is out of the way
G90 ;Absolute positionning
@kingargyle
kingargyle / SchoolViewHolder.java
Last active June 1, 2022 12:52
Example of Unit Testing classes with Hilt @EntryPoints
public class SchoolViewHolder extends RecyclerView.ViewHolder {
private ItemSchoolBinding binding;
// @VisibleForTesting
// protected EventBus eventBus = EventBus.getDefault();
private EventBus eventBus;
public SchoolViewHolder(@NonNull View itemView) {
@kingargyle
kingargyle / CoroutinesRule.kt
Created July 31, 2020 19:27
A JUnit 4 test rule for working with testing coroutines.
package com.abercrombie.testing.ui.rules
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineScope
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.test.setMain
import org.junit.rules.TestRule
@kingargyle
kingargyle / spotless.gradle
Created May 16, 2020 23:53
Configure XML formatting for Android Layout files
subprojects {
apply plugin: "com.diffplug.gradle.spotless"
spotless {
format 'xml', {
target '**/layout*/*.xml'
indentWithSpaces(2)
eclipseWtp('xml').configFile rootProject.file('spotless.xml.prefs')
}
}
@kingargyle
kingargyle / gist:460bd53b5c6096fc43866020a9bde4d9
Created October 12, 2019 01:29
Capture Image from HLS stream using FFMPeg
ffmpeg -loglevel 99 -i "https://webcamstream.multivista.com/live/amlst:dal_59169_1.stream/chunklist_w95623917_b300000.m3u8" -ss 00:00:14.435 -vframes 1 -strftime 1 "%Y-%m-%d_%H-%M-%S_crew_stadium.png"
@kingargyle
kingargyle / commit-msg
Created April 19, 2019 14:10 — forked from williamdenton/commit-msg
Git hooks
#!/bin/sh
commit_regex='^(PP-[0-9]+|fixup!)'
error_msg="Aborting commit. Your commit message is missing a JIRA ticket ('PP-1234')"
if ! grep -iqE "$commit_regex" "$1";
then
echo "$error_msg" >&2
exit 1
@kingargyle
kingargyle / PlainAndroidRunner.kt
Created February 19, 2019 13:56
A bare bones RobolectrictTestRunner that only starts up a sandbox and does not attempt to load any resources. This is good for non-ui tests where you still need portions of the android library but not any of the resources. Reduces robolectric startup time to 2 seconds. This comes from the following google group post: https://groups.google.com/fo…
package us.nineworlds.serenity.testrunner
import org.junit.runners.model.FrameworkMethod
import org.junit.runners.model.InitializationError
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.internal.SandboxTestRunner
import org.robolectric.internal.bytecode.Sandbox
import java.lang.reflect.Method
@kingargyle
kingargyle / MediaCodecInfoUtil.kt
Created January 13, 2019 23:06
Detect Media Codecs on Device
package us.nineworlds.serenity.common.android.mediacodec
import android.media.MediaCodecList
import android.util.Log
class MediaCodecInfoUtil {
val supportedContainers = hashMapOf<String, Boolean>("video/mkv" to true, "video/mp4" to true, "video/avi" to false, "video/webm" to true, "video/ogg" to true, "video/mv4" to true)
/**
@kingargyle
kingargyle / BindingAdapter.java
Created November 29, 2018 21:16 — forked from JakeWharton/BindingAdapter.java
An adapter base class that uses a new/bind pattern for its views.
// Apache 2.0 licensed.
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */
public abstract class BindableAdapter<T> extends BaseAdapter {
@kingargyle
kingargyle / AnimatingDialogFragment.kt
Last active November 18, 2018 03:26
A DialogFragment that support Animations useful for TV development
/**
* Dialog Fragment with hide animations
*/
class AnimatingDialogFragment : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.TvTheme_Dialog)
}