Skip to content

Instantly share code, notes, and snippets.

View kellydavid's full-sized avatar

David Kelly kellydavid

View GitHub Profile
@kellydavid
kellydavid / yubikey_ssh.md
Last active September 1, 2023 09:59
Set up Yubikey (5C NFC) for SSH authentication
@kellydavid
kellydavid / github_api.gql
Created May 22, 2020 11:36
Trying out github graphql api
query GetRepositories {
repositoryOwner(login: "kellydavid") {
login
repositories(first: 10, after:"Y3Vyc29yOnYyOpILzg4z6pg=", orderBy: {field: STARGAZERS, direction: DESC}) {
totalCount
totalDiskUsage
edges {
cursor
node {
id
@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 {
@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 / 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 / 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 / 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 / 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 / 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 / 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');