Skip to content

Instantly share code, notes, and snippets.

View tiqwab's full-sized avatar

Naohisa Murakami tiqwab

View GitHub Profile
import System.Environment
import Text.Parsec
import Text.ParserCombinators.Parsec hiding (try)
{-
Implement calculator with `Parsec` package.
-}
{-
# EBNF
import System.Environment
import Text.Parsec
import Text.Parsec.Expr
import qualified Text.Parsec.Language as L
import qualified Text.Parsec.Token as T
import Text.ParserCombinators.Parsec hiding (try)
{-
Implement calculator with `Text.Parsec.Expr`.
Use `Text.Parsec.Token` to make parsing simple.
class Node:
def __init__(self, x, parent=None):
self.key = x
self.left = None
self.right = None
self.parent = parent
def append_child(self, child):
if self.key > child.key:
self.left = child
# timing of visiting nodes
PRE = 1
IN = 0
POST = -1
'''
Implementation of splay tree
'''
class Node:
@tiqwab
tiqwab / Quote.hs
Created November 29, 2016 23:12
Refs of TemplateHaskell and QuasiQuotes
module HereDoc.Quote (
heredoc
)
where
import Data.Char
import qualified Language.Haskell.TH as TH
import Language.Haskell.TH.Quote
{-
@tiqwab
tiqwab / spring-initializer
Created April 7, 2017 12:03
Spring Initializer
curl https://start.spring.io/starter.tgz -d dependencies=web,security,lombok -d type=gradle-project -d groupId=com.tiqwab artifactId=boot-with-security packageName=com.tiqwab name=boot-with-security | tar -xzvf -
@tiqwab
tiqwab / default.rb
Last active September 23, 2017 05:05
td-agent::default recipe
# The recipe to install td-agent3.
# This is tested only for Ubuntu 14.04 LTS.
# Install td-agent
# Should be td-agent3
# TODO: Avoid to execute `apt-get update` in the recipe?
execute 'install td-agent' do
command "curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-trusty-td-agent3.sh | sh"
action :run
end
@tiqwab
tiqwab / StateMachineReaderCats.scala
Last active April 1, 2018 10:27
StateMachineReader with scalaz and cats
package example
object SampleMain {
import cats._
import cats.data._
import cats.instances.option._
type StateMachine = StateT[Option, Int, String]
@tiqwab
tiqwab / how-to-configure-keymap-in-windows.md
Last active June 11, 2018 14:11
How to configure key map in windows (CapsLock -> Ctrl and Ctrl-Space -> IME ON/OFF)
@tiqwab
tiqwab / setupdb.sh
Created August 10, 2018 13:18
Simple script to setup mysql with Docker
#!/bin/sh
set -eu
docker container run -d -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=password \
--name scalacheck-mysql mysql:5.7
# Wait for setup
set +e
for i in $(seq 20)