Skip to content

Instantly share code, notes, and snippets.

import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'gatsby'
import styled from '@emotion/styled'
import { Layout, Listing, Wrapper, Title, SEO, Header } from '../components'
import website from '../../config/website'
const Hero = styled.header`
padding-top: 1rem;
padding-bottom: 4rem;
@flying3615
flying3615 / TestOptional.java
Created May 21, 2019 22:01
UT for Some&None
public class OptionTest {
private List<Option<String>> names = null;
@Before
public void setup() {
names = new ArrayList<Option<String>>();
names.add(new Some<String>("Dean"));
names.add(new None<String>());
names.add(new Some<String>("Wampler"));
}
@Test
@flying3615
flying3615 / None.java
Created May 21, 2019 21:49
Null for Optional
public final class None<T> extends Option<T> {
public static class NoneHasNoValue extends RuntimeException {}
public None() {}
public boolean hasValue() { return false; }
public T get() { throw new NoneHasNoValue(); }
@flying3615
flying3615 / Some.java
Last active May 21, 2019 21:47
Some of something
public final class Some<T> extends Option<T> {
private final T value;
public Some(T value) { this.value = value; }
public boolean hasValue() { return true; }
public T get() { return value; }
@flying3615
flying3615 / ListModule.java
Created May 21, 2019 03:42
Create again, for the FP version of List for java
public class ListModule {
public static interface List<T> {
public abstract T head();
public abstract List<T> tail();
public abstract boolean isEmpty();
public List<T> filter(Function1<T, Boolean> f);
@flying3615
flying3615 / Example.java
Created May 12, 2019 22:45
Dirty check when inserting POJO into DB
//Anotation for fields need to check
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ModifiableField {
}
public abstract class PersistedObject {
public static final long UNSET_PRIMARY_KEY = 0L;
@flying3615
flying3615 / cloudSettings
Last active September 22, 2019 21:03
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-09-22T20:45:43.031Z","extensionVersion":"v3.2.9"}
@flying3615
flying3615 / CustomerDAO.java
Created February 28, 2019 00:57
Generate resultset stream for getting all customers
/**
* @return a lazily populated stream of customers. Note the stream returned must be closed to
* free all the acquired resources. The stream keeps an open connection to the database till
* it is complete or is closed manually.
*/
@Override
public Stream<Customer> getAll() throws Exception {
Connection connection;
try {
@flying3615
flying3615 / .tmux.conf
Created December 19, 2018 03:43
my tmux conf
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
@flying3615
flying3615 / tmux-cheatsheet.markdown
Created December 19, 2018 03:01 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname