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/'
#!/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 / 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
import Control.Lens
import Control.Lens.Fold
data FooBarBaz = Foo
| Bar { name :: String }
| Baz { name :: String, age :: Int }
deriving (Eq, Show)
_Name :: Fold FooBarBaz String
_Name = folding f
@danclien
danclien / MonadMaybe.hs
Last active August 29, 2015 14:25
Example of using the `Monad` instance from `Maybe`.
data Person = Person { personId :: PersonId, personName :: Name }
parseInt :: String -> Maybe PersonId
getById :: PersonId -> Maybe Person
-- Accepts a raw string from the user
-- Attempts to parse it as an `Int`
-- Attempts to get a `Person` by that ID
-- Returns the `Name` of the Person
f :: String -> Maybe Name

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)
@danclien
danclien / newtype_io.hs
Last active August 29, 2015 14:19
`newtype` IO
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Applicative
-- Don't export the 'MyIO' constructor
newtype MyIO a = MyIO { runMyIO :: IO a
} deriving (Functor, Applicative, Monad)
myGetLine :: MyIO String
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module A where
import Control.Lens.TH
newtype UserId = UserId Int deriving (Eq, Show)