Skip to content

Instantly share code, notes, and snippets.

View scoiatael's full-sized avatar

Lukasz Czaplinski scoiatael

View GitHub Profile
@scoiatael
scoiatael / convert.rb
Last active November 16, 2022 15:18
glide2nix - convert `glide.lock` into `deps.nix` for `buildGoPackage` nix format
#!/usr/bin/env ruby
file = 'helm/glide.lock'
require 'yaml'
lockfile = YAML.load_file(file)
# Obtained via `go get -v #{url}`, looking for 'found meta tag get.metaImport'
REPLACED_REPOS = {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"basics" : {
"location" : {
"city" : "Wrocław",
"countryCode" : "PL"
},
"name" : "Łukasz Czapliński",
"label" : "Web Developer / Architect",
"email" : "lukasz@czaplin.ski",
"summary" : "I'm a fullstack with a focus on delivering & evolving products, not simply building features according to schedule. I'm open to working both remotely and on-site.",
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@scoiatael
scoiatael / jason_transport_serializer.ex
Created January 24, 2019 13:46
Using Jason for Phoenix.Transport.Websocket in Phoenix 1.3.4
defmodule JasonChannelSerializer do
@behaviour Phoenix.Transports.Serializer
require Protocol
alias Phoenix.Socket.{Message, Broadcast, Reply}
Protocol.derive(Jason.Encoder, Message)
Protocol.derive(Jason.Encoder, Reply)
@scoiatael
scoiatael / main.go
Last active September 15, 2018 11:58
TCP server for IoT
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"net"
"net/http"
"strings"
let exchange (a : int, b : int) : Move =
fun circle ->
let valA = circle.[a] in
circle.[a] <- circle.[b];
circle.[b] <- valA;
circle
let partner (a : char, b : char) : Move =
fun circle ->
let idxA = Array.findIndex ((=) a) circle in
> Dancers.solve Dancers.input
val it : System.String = "olgejankfhbmpidc"
let partner (a : char, b : char) : Move =
let swap (a, b) = (b, a) in
let toKV arr = Map.ofArray (Array.map swap (Array.indexed arr))
let ofKV map = Array.map snd (Array.sortBy fst (Array.map swap (Map.toArray map))) in
let withKV f arr = ofKV(f (toKV arr)) in
withKV (fun kv ->
let valA = (Map.find a kv) in
let valB = (Map.find b kv) in
Map.add b valA (Map.add a valB kv))
> Dancers.partner ('e', 'p') Dancers.startingPattern
val it : Dancers.Circle =
[|'a'; 'b'; 'c'; 'd'; 'p'; 'f'; 'g'; 'h'; 'i'; 'j'; 'k'; 'l'; 'm'; 'n'; 'o'; 'e'|]