Skip to content

Instantly share code, notes, and snippets.

Dan Tanner dtanner

Block or report user

Report or block dtanner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
from __future__ import print_function
from math import ceil, log
print("\n Welcome to Up-To-9-Cards Game!")
def get_cards():
valid_count = 0
View game-example.kt
import java.lang.Math.ceil
import java.lang.Math.pow
import kotlin.math.log2
fun main() {
println("\n Welcome to Up-To-9-Cards Game!")
View game-example.c
#include <stdio.h>
#include <math.h>
#include <string.h>
#define NUMCARDS 9
#define PRODUCTION 1 /** 0=debug-mode | 1=production mode **/
int getCards(int *);
void displayCards(int *, int);
int getSuit(int codedNumber);
dtanner / ratpack-config-usage.groovy
Created Apr 18, 2016
Example of bad vs good ratpack configuration usage
View ratpack-config-usage.groovy
// a config class with a default value
class LogConfig {
boolean logRequestBody = false
// in ratpack, the LogConfig is bound with a prefix of `/logging`
Ratpack.groovy {
bindings {
bindInstance(serverConfig.get('/logging', LogConfig))
dtanner / DateManipulation.groovy
Created Apr 12, 2016
Example showing some java.time date manipulation
View DateManipulation.groovy
import java.time.LocalDate
import java.time.temporal.TemporalAdjusters
LocalDate localDate =
println localDate // 2016-04-12
println localDate.plusMonths(1).withDayOfMonth(1) // 2016-05-01
println localDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()) // 2016-03-31
View LocalAndZonedDates.groovy
import java.time.LocalDate
import java.time.ZonedDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.time.temporal.TemporalAdjusters
// If you have a date without time information, use a LocalDate. e.g. someone's birthday
LocalDate localDate = new LocalDate(2016, 4, 12)
println localDate.toString() // 2016-04-12
dtanner /
Last active Mar 20, 2016 — forked from kevinelliott/
Clean Install – Mac OS X 10.9 Mavericks

Install Homebrew / Cask

ruby -e "$(curl -fsSL"
brew install caskroom/cask/brew-cask

todo - replace this with brewfile

Install common applications via Homebrew

dtanner / RemoteConfigService.groovy
Created Apr 30, 2015
Example of a basic utility class to interact with etcd
View RemoteConfigService.groovy
import com.foog.util.TomcatDatasourceUtil
import groovy.json.JsonSlurper
* Application service to get and set values from a centralized remote configuration service.
class RemoteConfigService {
dtanner / Config.groovy
Created Apr 30, 2015
Example of loading a Grails configuration value from etcd
View Config.groovy
import groovy.json.JsonSlurper
dataSource {
// most properties are directly set
pooled = true
// ...
// the url is retrieved from etcd...make sure the etcd resource is properly protected
def jsonSlurper = new JsonSlurper()
def catalogUrlConfig = jsonSlurper.parseText(new URL("http://etcdlocation:2379/v2/keys/dataSource/url").text)
dtanner / TomcatDatasourceUtil.groovy
Last active Aug 29, 2015
Grails Tomcat Datasource Utility
View TomcatDatasourceUtil.groovy
import groovy.util.logging.Log4j
import org.apache.tomcat.jdbc.pool.ConnectionPool
import org.codehaus.groovy.grails.commons.GrailsApplication
class TomcatDatasourceUtil {
static void ensureCurrentDatasources(GrailsApplication application, List datasourceNames) {
You can’t perform that action at this time.