Skip to content

Instantly share code, notes, and snippets.

View kellydavid's full-sized avatar

David Kelly kellydavid

View GitHub Profile
@kellydavid
kellydavid / git_prompt_bash_profile.txt
Last active March 23, 2017 16:25
git bash prompt
# This just a few lines to add to a bash '~/.bashrc' configuration. This will add git
# command completion as well as display the current working branch. I like the format
# of the prompt that this produces so I want to document it here. The git completion
# scripts were obtained from https://github.com/git/git/tree/master/contrib/completion
# Set up git bash support
source ~/.git_bash/git-completion.bash
source ~/.git_bash/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1='\e[0;33m\u@\H\e[m:\e[0;32m\W\e[m\e[0;34m$(__git_ps1 " (%s)")\e[m\$ '
@kellydavid
kellydavid / gridlabd_ubuntu_readme.md
Created March 28, 2017 23:07
Building gridlab-d on ubuntu

Building gridlab-d on ubuntu (tested on 16.04.2 LTS)

  1. First install the following packages using apt-get :
  • autoconf
  • libtool
  • libxerces-c-dev
  • libcppunit-dev
  • libncurses5-dev
  • doxygen
@kellydavid
kellydavid / node_lambda_ssm_parameter.js
Created December 11, 2017 02:14
getting ssm parameter in node lambda
var AWS = require('aws-sdk');
var ssm = new AWS.SSM();
exports.handler = function(event, context) {
// TODO implement
console.log('What is the secret??');
console.log(process.env.secret1);
getParameterFromSystemManager(function(){
console.log('done');
@kellydavid
kellydavid / AlpakkaKinesisTest.scala
Created May 2, 2018 10:51
A quick test run for getting started with the Alpakka Kinesis Connector
import akka.NotUsed
import akka.actor.ActorSystem
import akka.stream.alpakka.kinesis.ShardSettings
import akka.stream.alpakka.kinesis.scaladsl.KinesisSource
import akka.stream.scaladsl.{Keep, Sink, Source}
import akka.stream.{ActorMaterializer, Materializer}
import com.amazonaws.regions.{Region, Regions}
import com.amazonaws.services.kinesis.model.{Record, ShardIteratorType}
import com.amazonaws.services.kinesis.{AmazonKinesisAsyncClientBuilder, AmazonKinesisClient}
import org.scalatest.FunSuite
@kellydavid
kellydavid / retry.scala
Created August 14, 2019 22:39
trying out zio retry mechanism
package ziowork
import zio._
import zio.clock.Clock
import zio.clock._
import zio.duration._
import zio.random.Random
object MyApp extends scala.App {
@kellydavid
kellydavid / retry2.scala
Created August 15, 2019 09:48
zio retry update with ref
import zio._
import zio.clock._
//def foo(number: Int): IO[Int, String] =
// for {
// _ <- UIO(println(s"foo=$number"))
// res <- number match {
// case 5 => ZIO.succeed("five")
// case 2 => ZIO.succeed("two")
// case _ => ZIO.fail(number - 1)
@kellydavid
kellydavid / file_print.scala
Created November 20, 2019 11:54
Print lines of file using ZStream
import zio._
object PrintBytes extends App {
import zio.stream._
import zio.console._
import zio.duration._
val fileName = "src/main/resources/world-cities_csv.csv"
def fileStream: StreamChunk[IOException, Byte] =
@kellydavid
kellydavid / refined.scala
Created November 23, 2019 11:14
Refined Types Scala
import eu.timepit.refined.api.Refined
import eu.timepit.refined.string.{Url, Uuid}
import eu.timepit.refined.auto._
case class MyId(value: String Refined Uuid)
val invalidUrl: String Refined Url = "htp://example.com"
val validUuid: String Refined Uuid = "61f33e31-5ef6-4aac-b7e2-c8374c19c366"
val validProductId = MyId(validUuid)
@kellydavid
kellydavid / ZioProvideDemo.scala
Last active November 28, 2019 16:43
ZioProvideDemo.scala
import zio._
import zio.console._
object ZioProvideDemo extends App {
trait HelloService {
val helloService: HelloService.Service
}
object HelloService {
@kellydavid
kellydavid / fpinscala_chapter04.scala
Created February 20, 2020 10:55
fpinscala_chapter04.scala
package com.dvdkly.fpinscala
import scala.annotation.tailrec
object Chapter04 {
/**
* Exercise 4.2
*/
object option {