Skip to content

Instantly share code, notes, and snippets.

@piotr-yuxuan
piotr-yuxuan / math-and-simple-call-in-core-logic.clj
Created January 16, 2016 16:10
Learning try-and-diy: how can I simplify this example?
(ns firstshot.chessknightmove
(:refer-clojure :exclude [== >= <= > < =])
(:use clojure.core.logic
clojure.core.logic.arithmetic))
(defn knight-moves
"Returns the available moves for a knight (on a 8x8 grid) given its current position."
[x y]
(let [xmax 8 ymax 8]
(run* [q]
@jdegoes
jdegoes / fun-with-functions.md
Last active January 8, 2022 00:00
Fun with Functions! - Exercises Only

These exercises were part of a LambdaConf Outpost meetup. You may find the instructions here.

  1. Develop a model for boolean values (Bool), which may be either true or false.

    Think: Do you need an if-then-else construct? Why or why not?

    Bonus: Develop a model for eithers (Either), whih can be one thing ("left") or another ("right"), and model a boolean as a partitioning of a set into two disjoint sets.

  2. Develop a model for optional values (Maybe / Option), which are containers that are either empty ("nothing" / "none") or hold a single value ("just" / "some").

@mjdominus
mjdominus / 2-29.hs
Last active January 17, 2016 21:51
SICP exercise 2.29 in Haskell and Scheme
data Branch = Branch { branch_length :: Int, branch_structure :: Mobile } deriving Show
data Mobile = Weight Int | Mobile { left_branch :: Branch, right_branch :: Branch } deriving Show
total_branch_weight (Branch { branch_structure = str }) = total_weight str
total_weight (Weight wt) = wt
total_weight (Mobile lt rt) =
(total_branch_weight lt) + (total_branch_weight rt)
-- Verbose constructor syntax
@Shaltz
Shaltz / gist:1d65a07a0901a36fb7f1
Created September 16, 2015 09:02
HOW TO fix openLDAP checksum error on config files
(source : http://injustfiveminutes.com/category/openldap)
How to fix “ldif_read_file: checksum error”
Posted on October 28, 2014
15
Well, in spite of you did read a banner saying “# AUTO-GENERATED FILE – DO NOT EDIT!! Use ldapmodify.” you ignored it and made some manual modifications in any of the LDIF files in /etc/ldap/slapd.d/.
Don’t worry it happened to me too :) When you need to quickly setup an openLDAP server for development it is pretty much easier to tweak these files although the recommended way is to use ldapmodify tool. But if you change the LDIF files in cn=config manually, their contents and checksums won’t match, which is not fatal, but is annoying when using tools such as slapcat:
Thank you for extending an invitation to speak at HighLoad++. I
sincerely appreciate your consideration.
I am an outspoken advocate for LGBTQ equality; this position is deeply
woven into my work. Clojure From The Ground Up is adamantly
LGBT-inclusive. Jepsen is named after a gay pop anthem and includes
dozens of references to same-sex relationships and trans identities. My
talk slides are populated with bearded nuns, genderqueer punks, and
trans hackers. My twitter feed is about as gay as it is possible to get.
@ohanhi
ohanhi / frp.md
Last active December 23, 2022 13:06
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Editorial note

autoscale: true build-lists: true slidenumbers: true

Tracing Riak with Redbug

An example of how to use Redbug to trace Riak internals, taking as an example an inexplicably failing secondary index range query.


@andytill
andytill / Covering more with unit tests.md
Created May 25, 2015 15:20
Covering more with unit tests

Covering more with unit tests

Unit tests are quick to run, quick to write in bulk, target a small area of code, are not prone to timing issues and other intermittent failures and have excellent reporting tools.

However, actual usage is often prevented by side effects which require resources such as processes, ports and ets tables to exist or will crash the test.

Separating code into pure and impure functions can help and is typically beneficial. It can also harm readability, and even then not enable full coverage using unit testing. For example:

receive_message(Msg) -&gt;
@jaredmorrow
jaredmorrow / read_write_fifo_erlang.md
Last active April 22, 2023 20:05
Reading and Writing to Fifo (named pipes) in Erlang

edit

@akash-akya pointed out in the comments that the file module supports named pipes since OTP 20. So none of this post is really needed anymore if you are on >= OTP 21.


Erlang and Named Pipes

The intention of this post is to provide a solution (with examples) to a somewhat uncommon issue in Erlang. I hate searching for answers to the same problems over and over, and I had a hard time finding answers to this particular problem, so I wrote it all down once I figured it out. If one day you decide to read and write data through fifo's (named pipes) and then decide you want to read or write the other end of the pipe from Erlang, this post is for you.

@xandkar
xandkar / conditional_singleton.erl
Created March 17, 2015 15:34
Erlang conditional singleton
1>
1> [foo || true].
[foo]
2>
2> [foo || false].
[]
3>
3>