Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am johnzeringue on github.
  • I am johnzeringue (https://keybase.io/johnzeringue) on keybase.
  • I have a public key whose fingerprint is E9F5 5985 485C 7ADD FAEC 3CAA DDEA 9A3C 4419 3F27

To claim this, I am signing this object:

#!/usr/bin/env ruby
VOWELS = "AEIOUYÅÄÖ"
CONSONANTS = ('A'..'Z').reject { |char| VOWELS.include? char }
def consonant? char
CONSONANTS.include? char or CONSONANTS.include? char.upcase
end
def rovarspraket string

Ramp Number

A Ramp Number is a number whose digits only rise or stay the same; they never fall.

  • 123 is a ramp number.
  • 101 is not a ramp number.
  • 1111000001111 is not a ramp number.
@johnzeringue
johnzeringue / JimfsExample.java
Last active August 29, 2015 14:14
Virtual Filesystems in Java
import com.google.common.jimfs.Configuration;
import com.google.common.jimfs.Jimfs;
// ...
// create filesystem and get a "virtual path"
FileSystem virtualFileSystem = Jimfs.newFileSystem(Configuration.unix());
Path virtualPath = virtualFileSystem.getPath("virtual", "path");
// use the path as you would any other
@johnzeringue
johnzeringue / customchart.js
Last active August 29, 2015 14:13
Ideas for New Topsoil Settings API
//
// Ideas for New Topsoil Settings API
// ==================================
//
//
// Idea #1 - Inline Everything
// ---------------------------
//
import random
def sample(items):
# the first argument can be omitted as it defaults to 0
randomIndex = random.randrange(len(items))
return items[randomIndex]
def promptForGender():
genderList = ["male", "female"]
@johnzeringue
johnzeringue / A.java
Last active August 29, 2015 14:08
Preinitialization Pattern in Java 8 - Example 2
import java.util.function.Consumer;
public class A<T extends A> {
public A(Consumer<T> preinitialization) {
preinitialization.accept((T) this);
initializeUsingSubclassMethod();
}
}
@johnzeringue
johnzeringue / A.java
Last active August 29, 2015 14:08
Preinitialization Pattern in Java 8 - Example 1
public class A {
public A(Runnable preinitialization) {
preinitialization.run();
initializeUsingSubclassMethod();
}
}
@johnzeringue
johnzeringue / sparc-hackathon.md
Last active August 29, 2015 14:05
The plan of attack for SPARC Hackathon 2014

Notes

Add Google Play Services

Add the following line to build.gradle in dependencies.

compile 'com.google.android.gms:play-services:+'

@johnzeringue
johnzeringue / h-99.lhs
Last active August 29, 2015 14:03
My solutions to Ninety-Nine Haskell Problems
H-99: Ninety-Nine Haskell Problems
==================================
Taken from http://www.haskell.org/haskellwiki/H-99:_Ninety-Nine_Haskell_Problems
Problem 1
---------
Find the last element of a list.