Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View plumpNation's full-sized avatar
🤓

Gavin King plumpNation

🤓
View GitHub Profile
@plumpNation
plumpNation / .pomodoro.sh
Created February 8, 2023 12:15
Simple bash script to implement a linux pomodoro timer
#!/bin/bash
# based on https://gist.github.com/bashbunni/3880e4194e3f800c4c494de286ebc1d7?permalink_comment_id=4445592#gistcomment-4445592
# Requires https://github.com/caarlos0/timer to be installed.
# Requires lolcat (should be a simple apt/yum install)
# spd-say should ship with your distro
declare -A pomo_options
pomo_options["work"]="25"
@plumpNation
plumpNation / optional_chaining.java
Created December 16, 2021 14:31
A quick demo of opportunities for chaining from optionals, through nested classes, and onto streams from the result
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class Scratch {
public static void main(String[] args) {
Optional<Schmoochies> schmoochies = Optional.of(new Schmoochies());
@plumpNation
plumpNation / Safe constructor
Created November 2, 2013 14:42
Reading the code in the wonderful Lawnchair library by Brian Leroux, the first thing I see is this great little pattern. All it does is make damn sure that 'new' is used to instantiate the object, as it must not be used as a Singleton.
var YourObject = function () {
// ensure YourCobject was called as a constructor
if (!(this instanceof YourObject)) {
return new YourObject();
}
// do your thing now, it's safe!!
};