Skip to content

Instantly share code, notes, and snippets.

View lorenzo's full-sized avatar

José Lorenzo Rodríguez lorenzo

View GitHub Profile
@lorenzo
lorenzo / .zshrc
Created November 1, 2021 16:41
llvm flags for GCH on Apple M1
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

StringDistance

A library to calculate a metric indicating the string distance between two strings.

This library was extracted from the Elm implementation of mailcheck http://package.elm-lang.org/packages/rluiten/mailcheck/latest.

The lcs and lcsLimit functions are more general and support more than just Char as list elements.

---
conf_version: 1
conf_layout:
lconfig_indentAmount: 4
lconfig_cols: 100
lconfig_alignmentLimit: 30
lconfig_indentListSpecial: true
lconfig_alignmentBreakOnMultiline: true
lconfig_indentPolicy: IndentPolicyLeft
lconfig_indentWhereSpecial: true
FROM fpco/stack-build:lts-12.9 AS stack-build
RUN stack setup --resolver=lts-12.9
COPY ./stack.yaml ./package.yaml ./
RUN stack build --only-dependencies
COPY . .
RUN stack install
FROM ubuntu:16.04 as base
@lorenzo
lorenzo / choose.hs
Last active September 1, 2018 22:19
module Main where
import qualified Data.Char
main = print go
go =
let l = ['a', 'b', 'a', 'A', 'b', 'B']
in foldr choose [] l
where
fib :: Int -> Int
fib n =
let fib = 0:1:zipWith (+) fib (tail fib)
in fib!!n
sitesQuery :: Query
sitesQuery = "select id, name from sites"
queryUsersAndCreateCheckpoints :: IO ()
queryUsersAndCreateCheckpoints = do
conn <- mysqlConnect -- my own helper function
statement <- prepareStmt conn sitesQuery
results <-
queryStmtResults conn statement [] >>= -- Query all the sites so they can be processed concurrently
Streams.toList -- The list is small, so we need no streaming
import qualified Data.HashMap.Strict as HM
import qualified Data.Vector as V
case a of
Array objs -> mapMaybe (HM.lookup key) (V.toList objs)
_ -> []
<?php
namespace App\ORM;
use Cake\Error\Debugger;
use Cake\ORM\Query;
class DebuggingQuery extends Query
{
public function __construct($connection, $table)
@lorenzo
lorenzo / Dockerfile
Created April 30, 2018 08:42
Fast multi-stage docker builds for haskell
FROM base-haskell:lts-11.7 AS builder
# Copy all local files and build the app
COPY . .
RUN stack install
FROM debian:stretch-slim AS distro
ENV LC_ALL=C.UTF-8
# Copy the executable from the builder stage