Skip to content

Instantly share code, notes, and snippets.

@danclien
danclien / add_partition.sql
Last active August 11, 2017 19:03
Queries I used to import ALB logs into AWS Athena. Based off of https://medium.com/@robwitoff/athena-alb-log-analysis-b874d0958909
ALTER TABLE your_table_name_here
ADD PARTITION (year='2017', month='*', day='*')
LOCATION 's3://your-alb-log-bucket/processed/AWSLogs/00000-change-with-your-account-id/elasticloadbalancing/us-east-1-change-with-your-region/2017/'
@danclien
danclien / Main.hs
Created February 10, 2015 18:56
Using Aeson without type classes.
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-
build-depends: base >=4.7 && <4.8
, aeson
, aeson-qq
, bytestring
, text

Run from ghci. Must have attoparsec available via cabal repl.

:set -XOverloadedStrings

import Prelude
import Control.Applicative
import Data.Attoparsec.Text

data IPAddress = IPAddress Int Int Int Int deriving (Eq, Show)
#!/bin/bash
SINK_INDEX=$(pacmd list-sinks | grep index | sed -e 's/^.* //')
if [[ $1 == "internal" ]]; then
pactl set-card-profile 0 output:analog-stereo+input:analog-stereo
elif [[ $1 == "hdmi" ]]; then
pactl set-card-profile 0 output:hdmi-stereo-extra1+input:analog-stereo
elif [[ $1 == "down" ]]; then
echo "Volume down 5%"

Here are some local Austin places worth checking out that's somewhat near the hotel. I'll add more to the list when I have time.

FYI: There's no Uber or Lyft in Austin, but Fasten is a decent replacement.

Downtown Austin

// data Foo = Bar Int | Baz String
public abstract class Foo
{
public sealed class Bar : Foo
{
public int Value { get; set; }
}
public sealed class Baz : Foo
{
@danclien
danclien / hkt.scala
Last active January 3, 2016 04:18
An attempt to use higher kinded types to "extend" the List and Option classes.
// Enter :paste mode
trait Length[M[_]] {
def length[A](xs: M[A]): Int
}
object Length {
implicit val LengthList: Length[List] = new Length[List] {
def length[A](xs: List[A]): Int = {
xs.length
@danclien
danclien / site.hs
Created December 30, 2015 22:18
Example usage of `hakyll-sass`
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid (mappend)
import Hakyll
import Hakyll.Web.Sass (sassCompiler)
main :: IO ()
main = hakyll $ do
match "scss/*" $ do
route $ setExtension "css"
compile sassCompiler
@danclien
danclien / spray_routing.scala
Last active December 30, 2015 13:09
Cleanest way I've found so far to divide Spray's routing into separate files.
/* Routing trait for mixing in routes */
trait RoutingService extends Directives { this: HttpServiceActor =>
private val EmptyRoute: Route = { context => Unit }
def routes: Route = EmptyRoute
/* Used to concatenate `Route`s together */
def concatRoutes(superRoutes: Route)(routes: Route): Route = superRoutes match {
case EmptyRoute => routes
case _ => superRoutes ~ routes
}
@danclien
danclien / scala_start.md
Last active December 30, 2015 05:29
Personal notes on starting a new Scala project
  • Use GitHub's default .gitignore file for Scala
    • Add .DS_Store/ to .gitignore
  • Use ./project/Build.scala over ./Build.sbt
  • Add to ./project/plugins.scala with latest version numbers
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.10.1")

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.2")