Skip to content

Instantly share code, notes, and snippets.

View gregturn's full-sized avatar

Greg L. Turnquist gregturn

View GitHub Profile
Table of Contents

<#assign project_id="gs-rest-service"> <#assign spring_version="3.2.4.RELEASE"> <#assign spring_boot_version="0.5.0.M4"> This guide walks you through the process of creating a "hello world" [RESTful web service][u-rest] with Spring.

What you’ll build

You’ll build a service that will accept HTTP GET requests at:

@gregturn
gregturn / fix
Created July 19, 2013 13:52
This script will parse a markdown file and replace any lines that look like <@snippet path="pom.xml" prefix="complete"/> with <@snippet path="pom.xml" prefix="initial"/>. It writes the new files into <file>.new first, and then moves it to replace the existing file. See comments for more details
#!/usr/bin/env python
import os
import re
import sys
if len(sys.argv) < 2:
print "Usage: %s <file>" % sys.argv[0]
sys.exit(1)
@gregturn
gregturn / EiulLimits.scala
Created April 6, 2012 00:54
Finance app with scala part 3
/** apply allows it to sort the right value into the middle, and then pick it
* For example, EiulLimits(0.0, 15.0)(4.0) would become List(0.0, 4.0, 15.0), with 4.0 being in the middle
* EiulLimits(0.0, 15.0)(-2.4 would become List(-2.4, 0.0, 15.0), with 0.0 being in the middle
* EiulLimits(0.0, 15.0)(22.5) would become List(0.0, 15.0, 22.5), with 15.0 being in the middle
*/
case class EiulLimits(lower:Double, upper:Double) {
def apply(x: Double) = List(x, lower, upper).sorted.apply(1)
}
@gregturn
gregturn / closing.scala
Created April 6, 2012 00:41
Finance app with scala part 2
}
@gregturn
gregturn / git-lg
Created December 5, 2011 15:40
Pretty git "railroad track" log report
git log --graph --pretty=\"format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset'\" --abbrev-commit --date=relative
@gregturn
gregturn / ScalaCompilationUnit.java
Created August 24, 2011 17:55
Embedding scala compiler in java
try {
Settings settings = new Settings();
settings.usejavacp().tryToSetFromPropertyValue("true");
settings.stopAfter().tryToSetColon(Nil.$colon$colon("dce")); // same as "dce" :: Nil in scala
settings.debug().tryToSetFromPropertyValue("true");
System.out.println("About to compile " + new String(sourceUnit.getContents()));
PrintWriter out = new PrintWriter("output.txt");
IMain main = new IMain(settings, out);
@gregturn
gregturn / recipe32.story
Created October 27, 2010 06:33
PyCukes BDD story
Story: Shopping cart
As a shopper
I want to load up items in my cart
So that I can check out and pay for them
Scenario 1: Empty cart
Given an empty cart
Then looking up the fifth item causes an error
And looking up a negative price causes an error
And the price with no taxes is $0.00
import doctest
class BddDocTestRunner(doctest.DocTestRunner):
"""
This is a customized test runner. It is meant
to run code examples like DocTestRunner,
but if a line preceeds the code example
starting with '#', then it prints that
comment.
$ python recipe21_report.py recipe21
===============================
== Processing module recipe21
===============================
Documentation for module recipe21
-------------------------------
This is documentation for the this entire recipe.
With it, we can demonstrate usage of the code.
from springpython.context import *
from springpython.config import *
from pika_client import *
from ticker_system import *
from buy_low_sell_high import *
class AppContext(PythonConfig):
def __init__(self):
PythonConfig.__init__(self)