Skip to content

Instantly share code, notes, and snippets.

David Whitman davidwhitman

  • Vermont, USA
Block or report user

Report or block davidwhitman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davidwhitman
davidwhitman / _Starsector_CI.md
Last active Dec 27, 2019
CI setup to create ready-to-eat Starsector mods
View _Starsector_CI.md

CircleCI

Description

This setup will automate Github releases by creating a new release with a ready-for-users zipfile of your mod every time a git tag is pushed to your GitHub repository.

Steps

  1. Create a folder called .circleci in your mod directory. Add the two text files config.yml and zipMod.sh to it.
  2. Open .circleci/zipmod.sh with a text editor (e.g. VS Code, Notepad++). Change the value for modFolderName. This will be the name of the mod folder.
View Bitbucket_OnPrem_UserCss.user.css
/* ==UserStyle==
@name Bitbucket Blue Reskin by dwhitman
@namespace github.com/openstyles/stylus
@version 1.0.2
@description A blue userstyle
@author Dwhitman
==/UserStyle== */
@-moz-document domain("stash.mywebgrocer.com") {
.look-and-feel-custom-theme .aui-header {
View Jira_OnPrem_UserCss.user.css
/* ==UserStyle==
@name JIRA Blue Reskin dwhitman
@namespace github.com/openstyles/stylus
@version 1.0.1
@description A blue userstyle
@author David Whitman
==/UserStyle== */
@-moz-document domain("jira.mywebgrocer.com") {
.aui-header {
background-color: #333333 !important;
View Scan.kt
/**
* Applies the latest result of `scan` to each item received in order to emit a new result (which is then provided to the next `scan` item).
*
* So, given an initial seed of 10 and the function `{ previous, input -> previous + input }`, we will get the following outputs for the specified inputs:
* In -> Out
* 1 -> 11
* 6 -> 17
* 1 -> 18
* 2 -> 20
*
View CiceroneSupportAppNavigator.kt
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import ru.terrakok.cicerone.android.SupportFragmentNavigator
import ru.terrakok.cicerone.commands.BackTo
import ru.terrakok.cicerone.commands.Command
View KotlinEpoxyModel.kt
import android.view.View
import androidx.annotation.CallSuper
import androidx.annotation.LayoutRes
import com.airbnb.epoxy.EpoxyModel
/**
* Represents a `EpoxyRecyclerView` item model.
* This class allows us to use epoxy models with Kotlin without needing annotation processing or code generation.
*/
abstract class KotlinEpoxyModel(
@davidwhitman
davidwhitman / ViewOnceData.kt
Last active Oct 3, 2018
A class that encapsulates data, adding ability to know when the data has already been viewed. Useful for putting one-shot events, like "display dialog", into a State object that can be reapplied to a view.
View ViewOnceData.kt
import java.util.concurrent.atomic.AtomicBoolean
/**
* Wraps some data that should track when it has been viewed and allow future viewers to avoid a second showing.
* Useful for showing messages in the app that auto-hide because this class can exist in the app's state.
*/
data class ViewOnceData<T>(private val data: T) {
val wasViewed = AtomicBoolean(false)
/**
@davidwhitman
davidwhitman / ObservableActivityForResult.java
Last active Jun 24, 2019
RxJava wrapper for startActivityForResult and onActivityResult flow. Don't break the chain!
View ObservableActivityForResult.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.mywebgrocer.util.ActivityResultData;
import java.util.Random;
View Barker.kt
class Barker : NoiseMaker {
override fun makeSound() {
println("Bark!")
}
}
@davidwhitman
davidwhitman / Preferences.kt
Last active Jan 26, 2020
Android SharedPreferences helper class for Kotlin. Easy-to-use delegated properties, automatic database creation, and listening for property changes.
View Preferences.kt
import android.content.Context
import android.content.SharedPreferences
import kotlin.reflect.KProperty
/**
* Represents a single [SharedPreferences] file.
*
* Usage:
*
* ```kotlin
You can’t perform that action at this time.