Skip to content

Instantly share code, notes, and snippets.

@robbytx
robbytx / controllers.application\.js
Created February 25, 2022 20:05
ManyArrayFlatMap
import Controller from '@ember/controller';
import { computed } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@computed
get root() {
const root = this.store.createRecord('test', { name: 'root' });
for (let i = 0; i < 5; i++) {
@robbytx
robbytx / SerializedFunction.java
Created January 7, 2021 02:58
SerializedFunction to introspect Java 8 Lambdas (especially method references)
import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
import java.util.function.Function;
/**
* This interface decorates the standard {@link Function} interface with the {@link Serializable} interface
* to introspect method references (and other lambdas) that are bound to this type.
*
* @see #serialized()
@robbytx
robbytx / macos_notify.sh
Created December 11, 2020 17:20
Bash function for MacOS Notification when CLI command ends
#
# This function can be prepended to any single Bash command to display a notification when it completes.
#
# Examples:
# notify sleep 1
# notify false
#
function notify() {
COMMAND=$(echo "$@" |sed -Ee 's/([\"])/\\\1/g') # capture and escape the command for osascript
if "$@" # execute the command
@robbytx
robbytx / JsonNodeStreamSupport.java
Created November 25, 2020 16:18
Convert Jackson JsonNode to Java 8 Stream
import com.fasterxml.jackson.databind.JsonNode;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
* This interface contains utility methods for processing {@link JsonNode}'s using Java 8 {@link Stream}s.
*/
@robbytx
robbytx / application.controller.js
Created March 23, 2016 21:47
IE option selected issue
import Ember from 'ember';
var firstValue = 'A';
var otherValue = 'B';
var defaultValue = 'C';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
values: [