Skip to content

Instantly share code, notes, and snippets.

@ppurang
ppurang / gist:5768047
Last active December 18, 2015 10:19
spray coffee payment web-service somewhat more complicated example
//from https://github.com/ppurang/spray-example
//below retreive(id) always returns Option[Order]
trait CoffeePaymentService extends HttpService with LiftJsonSupport {
self: PersistenceCoffee =>
override implicit def liftJsonFormats: Formats = Order.format
val paymentRoute =
pathPrefix("payment"/"order") {
@ppurang
ppurang / livescript.html
Created August 14, 2013 07:43
Livescript on the client - an html file and a test script
<!DOCTYPE html>
<html lang="en">
<head>
<title>livescript</title>
</head>
<body>
<h1>
Livescript - check the browser's console
</h1>
<h2>
// Run this with scala <filename>
/**
* A Two-phase commit Monad
*/
trait Transaction[+T] {
def map[U](fn: T => U): Transaction[U] = flatMap { t => Constant(fn(t)) }
def flatMap[U](fn: T => Transaction[U]): Transaction[U] =
FlatMapped(this, fn)
@ppurang
ppurang / gist:6864736
Created October 7, 2013 08:57
getFileExtension from You Can't JavaScript Under Pressure
//caution this is a very bad idea for a function even in javascript!
function getFileExtension(i) {
// i will be a string, but it may not have a file extension.
// return the file extension (with no period) if it has one, otherwise false
var x;
if(i.lastIndexOf(".") > -1)
x = i.substring(i.lastIndexOf(".")+1, i.length);
import akka.actor.Actor.Receive
import akka.actor.ActorContext
import akka.actor.ActorLogging
import akka.actor.Actor
import akka.event.LoggingAdapter
object MyLoggingReceive {
def apply(log: LoggingAdapter)(r: Receive)(implicit context: ActorContext): Receive = r match {
case _: MyLoggingReceive ⇒ r
/*
* Copyright (c) 2012, Lawrence Livermore National Security, LLC. Produced at
* the Lawrence Livermore National Laboratory. Written by Keith Stevens,
* kstevens@cs.ucla.edu OCEC-10-073 All rights reserved.
*
* This file is part of the S-Space package and is covered under the terms and
* conditions therein.
*
* The S-Space package is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
@ppurang
ppurang / build.sbt
Last active August 29, 2015 13:56
sbt prompt with git branch and git status for modifications etc.
// the following results in
// superduperproject : master : 0.1.0 : MD??>
// where M => Modified, D => Deleted, ?? => not tracked
// and might include (not tested :))
// !, R, C, U for details check https://www.kernel.org/pub/software/scm/git/docs/git-status.html#_short_format
// if you see superduperproject : master : 0.1.0 : -?-> ... well then oops and happy debugging and do tell...
shellPrompt in ThisBuild := ShellPrompt.buildShellPrompt("0.1.0")
@ppurang
ppurang / charscounter.scala
Last active August 29, 2015 14:07
count chars in a file
// see also http://piyush.purang.net/blog/Reading_Type_Signatures_5e999531-595f-4348-b44c-e239be962885
import java.io.File
// following is the goal
type CountCharsInAFile = String => Int
type PathToFile = String => File
def pathToFile : PathToFile = new File(_)
type FileToLines = File => List[String]
@ppurang
ppurang / LandingFestival Berlin 2018 CFP.md
Last active January 24, 2018 20:41
Pitch for LandingFestival Berlin 2018

#CallForSpeakers pitch for #LandingFestival Berlin 2018

Considered leveraging your technical debt?

Description

How often do you hear the term MVP (minimum viable product) bandied around in startup land? It’s often a necessary evil. Technical debt, or the implied cost of the additional work caused by choosing an easy option now, rather than opting for a better solution which may take more time, is commonplace in almost every engineering team and its products. As engineers, we need to aggressively manage our technical debt, but also open our eyes to the opportunity it can provide. It’s akin to financial leverage, and has future value.

Key takeaway

I'll debunk the myths around technical debt, share how to aggressively manage it, and how to leverage it for the good of the product, the team, the company and the end user.