Skip to content

Instantly share code, notes, and snippets.

View kitlangton's full-sized avatar
🤠

Kit Langton kitlangton

🤠
View GitHub Profile
@kitlangton
kitlangton / HList.scala
Last active July 16, 2021 05:27
HListery
// HList
sealed trait HList
object HList {
type ::[H, T <: HList] = HCons[H, T]
type HNil = HNil.type
implicit final class HNilOps(private val self: HNil) extends AnyVal {
def ::[A](a: A): A :: HNil = HCons(a, self)
/** A fancy, functional graph encoding taken from here:
* https://github.com/snowleopard/alga-paper
*/
sealed trait Graph[+A] { self =>
import Graph._
def toStandardGraph[A1 >: A]: StandardGraph[A1] =
fold[StandardGraph[A1]](
empty = StandardGraph(Set.empty, Set.empty),
vertex = value => StandardGraph(Set(value), Set.empty),
@kitlangton
kitlangton / HMR.scala
Created June 11, 2021 05:57
Example of basic HMR with Scala.js & Laminar
object Main {
val css: Css.type = Css
println(s"PRODUCTION MODE: ${scala.scalajs.LinkingInfo.productionMode}")
def main(args: Array[String]): Unit =
waitForLoad {
val appContainer = dom.document.querySelector("#app")
appContainer.innerHTML = ""
unmount()
package hlist
import hlist.HList.HNil
import meetup.TupleExtractor
sealed trait HList
case class ::[H, T <: HList](head: H, tail: T) extends HList
case object HNil extends HList { self =>
def ::[H](that: H): H :: HNil = new ::(that, self)
import Aggregator.AggregationSyntax
import io.getquill.context.ZioJdbc.{QConnection, QDataSource}
import io.getquill.{PostgresZioJdbcContext, Query, SnakeCase}
import zio._
import zio.blocking.Blocking
import zio.console.putStrLn
object QuillContext extends PostgresZioJdbcContext(SnakeCase)
import QuillContext._
@kitlangton
kitlangton / idea-live-templates.xml
Last active July 16, 2023 21:33
IDEA Live Templates
<template name="fr" value="for {&#10; $VARIABLE$ &lt;- $VALUE$&#10;} yield $FINISH$" description="for comprehension" toReformat="false" toShortenFQNames="true">
<variable name="VALUE" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="VARIABLE" expression="" defaultValue="&quot;x&quot;" alwaysStopAt="true" />
<variable name="FINISH" expression="" defaultValue="VARIABLE" alwaysStopAt="true" />
<context>
<option name="SCALA" value="true" />
</context>
</template>
<template name="FR" value="for {&#10; $VARIABLE$ &lt;- $SELECTION$&#10;} yield $FINISH$" description="for comprehension" toReformat="false" toShortenFQNames="true">
<variable name="VARIABLE" expression="" defaultValue="&quot;x&quot;" alwaysStopAt="true" />
@kitlangton
kitlangton / animator.scala
Created April 19, 2020 22:09
Laminaranimator
package animator
import com.raquo.airstream.eventstream.EventStream
import com.raquo.airstream.signal.{Signal, Var}
import magnolia.{CaseClass, Magnolia}
import org.scalajs.dom
import scala.language.experimental.macros
object Time {
@kitlangton
kitlangton / vim.py
Last active February 14, 2020 06:29
Talon vim grammar
from talon import Context, actions
import webbrowser
ctx = Context("vim")
ctx.lists["self.commands"] = {
"change": "c",
"delete": "d",
"yank": "y",
"copy": "y",
@kitlangton
kitlangton / Lib.hs
Last active September 19, 2018 20:11
Amazon Scraper
{-# LANGUAGE OverloadedStrings #-}
module Lib where
import Text.HTML.Scalpel
import Data.Maybe (fromMaybe)
import Data.Char
import Control.Applicative
import Text.Read (readMaybe)
import Ember from 'ember';
export default Ember.Controller.extend({
session: Ember.inject.service('session'),
sessionAccount: Ember.inject.service(),
actions: {
authenticate() {
let {email, password} = this.getProperties('email', 'password');
this.get('session').authenticate('authenticator:devise', email, password)