Skip to content

Instantly share code, notes, and snippets.

@jquerius
jquerius / ConvertSpringForm.java
Last active December 16, 2016 21:51
Creates a domain (hibernate) object from a matching form object.
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Creates a domain object from a matching form object.
* Spring parses JSON response into a form, where the
* data from the form can first be validated. Then, the
@jquerius
jquerius / ActivityFragmentExample.kt
Last active May 3, 2021 22:14
Kotlin Fragment to Activity Communication Example
class ExampleFragment : Fragment() {
// this is the instance of our parent activity's interface that we define here
private var mListener: OnFragmentInteractionListener? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
fun onButtonPressed(uri: Uri) {
if (mListener != null) {
mListener!!.onFragmentInteraction(uri)
@jquerius
jquerius / ssb-interop.js
Created September 7, 2018 14:57
Slack Dark Theme
/**
* This is a dark theme for slack.
* Scroll down to line 92 to edit the theme's main colors.
* This file needs to be placed at
* "slack\app-3.2.0\resources\app.asar.unpacked\src\static\ssb-interop.js"
* in order for Slack to load it.
*/
/**
* The preload script needs to stay in regular ole JavaScript, because it is
@jquerius
jquerius / eat.js
Created December 7, 2018 17:11
Can a number eat itself?
/**
* Given a positive integer, output a truthy/falsy value as to whether the number can eat itself.
*
* Rules:
* Leftmost is the head, rightmost is the tail
* If the head is greater than or equal to the tail, the head eats the tail and the new head becomes their sum.
* If sum >= 10 then the head is replaced by sum % 10 sum=0 cannot be ignored, input number will never have any zeroes to the left.
*
* Test Cases:
* True: