Skip to content

Instantly share code, notes, and snippets.

View grndvl1's full-sized avatar

John Matthews grndvl1

  • Cars.com
  • Chicago
View GitHub Profile
@grndvl1
grndvl1 / gist:c5fc0c4edffeee44b285b88fe751220f
Created November 8, 2023 21:52
Fat Jar or Jar file for Java with all dependencies and Manifest
plugins {
id("java")
id("application")
}
version = "1.0.0"
repositories {
mavenCentral()
maven { setUrl("https://jitpack.io") }
@grndvl1
grndvl1 / pre-commit
Created October 13, 2023 15:59
Pre-Commit File for Android Studio KTLint Check
#!/bin/bash
echo "Validating code format"
./gradlew app:ktlintCheck --daemon
STATUS=$?
# Exit with an error if the linter didn't pass
[ $STATUS -ne 0 ] && exit 1
@grndvl1
grndvl1 / gist:5686203dbf41f7c2d122662468850738
Created October 13, 2023 15:44
CIRCLECI and Not Fail a Run Step Command
# CircleCI I had a time where I wanted the UI tests to not stop the build because I would run another script to do some
# Test case management and report the findings but I still wanted a build to diagnose or triage the issue for devs.
# I finally found out how to do so by making the gradlew build/run tests command always return 0 by a simple
# CircleCI option
commands:
test_ui:
steps:
# running a gradle managed device that by this command starts the emulator and runs the UI tests
# adding the '|| true' makes it always return true
@grndvl1
grndvl1 / gist:794ef538715f1a8c6cc66cc54d8852db
Created October 13, 2023 15:37
Bash Script Async Curl Commands
#!/bin/bash
# when makeing a curl command you can call them asyncly and not have to wait for each one to finish.
# its very simple and took a bit to find by googling it. The searches turned up garbage until I
# stumbled on this solution.
# the '&' sign at the end is what make its run in its own space, daemon if you will
for ((i=0; i<30; i++)); do
curl -X 'POST' \
'https://some url' \
@grndvl1
grndvl1 / RecordVideoInAppium.txt
Last active March 18, 2020 17:55
Record Video Using Appium
// So I found out that its not easy to do this without the right code.
// Funny thing is that it puts a recording on the phone with some random name.mp4
// The hard thing was actually saving it locally.
// When you stop the recording its in a string 64 base you have to decode and then write that byte array to a file.
protected void screenRecordVideo() throws InterruptedException, IOException {
if (platform == OperatingSystem.ANDROID) {
((CanRecordScreen)driver).startRecordingScreen(
new AndroidStartScreenRecordingOptions()
.withVideoSize("1280x720")
@grndvl1
grndvl1 / gist:57150b22f724006bb9303e25a161cc53
Created November 4, 2019 21:02
Marque Title of a Toolbar page
Most code I saw for this was to create custom layout. Project I did not want to do this but do it for only a specific activity. Here is how to do it in the activity in onStart()
override fun onStart() {
super.onStart()
val toolbarViewGroup = findViewById<ViewGroup>(R.id.action_bar) // standard action layout from theme
toolbarViewGroup?.let{ viewGroup ->
// find the textview title since its in combined layout
val textView = viewGroup.children.find { (it is TextView) } as TextView
@grndvl1
grndvl1 / gist:8ab2fdea6e269726a253761571986665
Created April 2, 2019 16:36
Fix JobIntentService Crash for 8.x Phones
1. Create a new package in your app with name android.support.v4.app This is a workaround to override package-private methods.
2. Create or Edit your Own ServiceClass to Override dequeueWork() method and surround super.dequeueWork() call with try/catch block like the coming snippet.
Any code that uses JobIntent Service override with this class
(Important Note: This fix should be tracked from time to time as any change in the support libraries might break it.)
public abstract class MyServiceImpl extends JobIntentService {
// This method is the main reason for the bug and crash
// the dequeueWork method is called only when the worker service is done
@grndvl1
grndvl1 / SectionWithHeader.txt
Last active March 26, 2019 04:08
Custom LinearLayout
This is how you set up a custom layout in kotlin, with a linearlayout and 3 textviews but these are embedded so a little
trick here to get the properties setters and getters needs to be done. May not be the most efficient way but it works
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="DetailSectionHeaderText">
<attr name="title" format="string" />
@grndvl1
grndvl1 / WhiteNotificationBar_BlackIcons
Created February 20, 2018 19:15
Android Notification Bar White with Black Icons - Programatically
Window window = this.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
// finally change the color