Skip to content

Instantly share code, notes, and snippets.

@johnzeringue
johnzeringue / HelloWorld.java
Last active August 29, 2015 14:01
A simple hello world program in Java to test GitHub Gists
/**
* A basic hello world in Java
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
@johnzeringue
johnzeringue / matches.py
Last active August 29, 2015 14:02 — forked from fmasanori/jogos.py
import requests
for match in requests.get('http://worldcup.sfg.io/matches').json():
if match['status'] == 'completed':
print('{home[code]} {home[goals]}, {away[code]} {away[goals]}' \
.format(home=match['home_team'], away=match['away_team']))
@johnzeringue
johnzeringue / printf.py
Created June 20, 2014 20:59
printf in Python with Python 3-style format strings
def printf(format, *args, **kwargs):
"""printf in Python with Python 3-style format strings"""
print(format.format(*args, **kwargs), end='')
@johnzeringue
johnzeringue / colors.sh
Created July 1, 2014 19:04
A bash script to print a table showing all shell colors
#!/bin/bash
#
# This file echoes a bunch of color codes to the terminal to demonstrate
# what's available. Each line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a test use of that color
# on all nine background colors (default + 8 escapes).
#
# Source:
# http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux
#
@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.
@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 / 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 / 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();
}
}
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 / 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
// ---------------------------
//