Skip to content

Instantly share code, notes, and snippets.

View justinpitts's full-sized avatar

Justin Pitts justinpitts

View GitHub Profile
@justinpitts
justinpitts / main.py
Created October 8, 2019 17:24
Corrected listing 11.1 for Google Cloud Platform In Action
import webapp2
class HelloWorld(webapp2.RequestHandler):
def get(self):
self.response.write('Hello from App Engine!');
app = webapp2.WSGIApplication([
('/', HelloWorld),
])
@justinpitts
justinpitts / Foo.scala
Created April 25, 2019 20:06
scalariform failure to obey format directive
package foo
// format: OFF
case class Foo(
a: Map[String, String], // Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
b: Map[String, String], // Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum ipsum
c: Map[String, String], // Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
d: Map[String, String], // Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum ipsum
e: String) // Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem
@justinpitts
justinpitts / RemoteIteratorWrapper.scala
Created April 10, 2019 20:10 — forked from timvw/RemoteIteratorWrapper.scala
scala wrapper for hadoop remote iterator
case class RemoteIteratorWrapper[T](underlying: org.apache.hadoop.fs.RemoteIterator[T]) extends scala.collection.AbstractIterator[T] with scala.collection.Iterator[T] {
def hasNext = underlying.hasNext
def next() = underlying.next()
}
object Conversions {
implicit def remoteIterator2ScalaIterator[T](underlying: org.apache.hadoop.fs.RemoteIterator[T]) : scala.collection.Iterator[T] = RemoteIteratorWrapper[T](underlying)
}
import $ivy.`org.tpolecat::doobie-core:0.4.4`
import $ivy.`org.tpolecat::doobie-postgres:0.4.4`
import java.time._
import java.sql.Timestamp
import java.util.TimeZone
import scala.sys.process._
import scala.xml.XML
import doobie.imports._
import scalaz._, scalaz.effect.IO, Scalaz._, scalaz.concurrent.Task, scalaz.stream.Process
@justinpitts
justinpitts / springer-free-maths-books.md
Created December 28, 2015 21:41 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@justinpitts
justinpitts / lambda-dynamo.js
Last active August 29, 2015 14:25 — forked from markusklems/lambda-dynamo
Short aws lambda sample program that puts an item into dynamodb
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
console.log("Event data:");
console.log(JSON.stringify(event, null, ' '));
dynamodb.listTables(function(err, data) {
console.log(JSON.stringify(data, null, ' '));
diff --git a/foo.java b/foo.java
index eb7e2d8..0c5161d 100644
--- a/foo.java
+++ b/foo.java
@@ -29,6 +29,8 @@ import com.example.FooUtil;
public class foo implements DB {
private static final String THING_ONE = "1";
+ private static final String THING_TWO = "2";^M
+ private static final String THING_THREE = "3";^M
@justinpitts
justinpitts / findMissingIndexes.sql
Created March 20, 2012 14:04 — forked from AndreasLazar/findMissingIndexes.sql
lists all missing indexes of the current SQL Server
SELECT
DB_NAME(d.database_id) AS database_name
, LEFT (PARSENAME(d.statement, 1), 32) AS table_name
, ISNULL (d.equality_columns , '') AS equality_columns
, ISNULL (d.inequality_columns , '') AS inequality_columns
, ISNULL (d.included_columns , '') AS include_columns
, s.avg_total_user_cost -- This column represent the average total user cost each time when the user query was executed
, s.avg_user_impact -- This column represents the value in percentages. It informs us the amount of improvement which you can get if the index is created.
, s.unique_compiles
@justinpitts
justinpitts / generate_series.sql
Created December 14, 2011 20:21
t-sql function to generate a series of integers
--Attribution is due elsewhere; I didn't come up with this.
CREATE function dbo.generate_series
(
@pStartValue int = 1,
@pEndValue int = 1000000
)
returns table
as
return
(
@justinpitts
justinpitts / untitled
Created December 7, 2011 13:38
list all used deprecated features
-- Listing 7.9: Which deprecated features are still in use?
DECLARE @object_name SYSNAME
SET @object_name = CASE WHEN @@servicename = 'MSSQLSERVER' THEN 'SQLServer'
ELSE 'MSSQL$' + @@serviceName
END + ':Deprecated Features'
DECLARE @PERF_COUNTER_LARGE_RAWCOUNT INT
SELECT @PERF_COUNTER_LARGE_RAWCOUNT = 65792
SELECT object_name ,
counter_name ,