Skip to content

Instantly share code, notes, and snippets.

SD = argo_graphql_service_document:from_string(
"type Query {\n"
" hero: Character\n"
"}\n"
"interface Character { id: ID! }\n"
"type Droid implements Character {\n"
" id: ID!\n"
" properties: DroidProperties!\n"
"}\n"
"type DroidProperties {\n"
#!/usr/bin/env ruby
#
# Originally written by http://redartisan.com/tags/csv
# Added and minor changes by Gavin Laking
# Rewritten by Andrew Bennett for Ruby 1.9
#
# Usage: ruby csv_to_fixture.rb file.csv [--json]
#
# "id","name","mime_type","extensions","icon_url"
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif"
% Setup
tab = ets:new(tab, [set, named_table, public]),
true = ets:insert(tab, {foo, 0}).
% Slow: O(N) operation
Key = foo,
Threshold = 100,
NewVal = 101,
MatchSpec = ets:fun2ms(fun({K, V})
when K =:= Key
rebar3 proper --module=prop_find_broken_maps --numtests 10000 --max_shrinks 250 --constraint_tries 1000 --start_size 33
===> Verifying dependencies...
make: Nothing to be done for `all'.
===> Analyzing applications...
===> Compiling erldist_filter
=ERROR REPORT==== 14-Oct-2022::14:59:33.585605 ===
Module rebar3_proper_prv must be purged before deleting
===> Testing prop_find_broken_maps:prop_find_broken_maps()
.PHONY: all clean watch
CURDIR := $(shell pwd)
BASEDIR := $(abspath $(CURDIR))
SRCDIR := $(abspath $(BASEDIR)/src/)
core_find = $(if $(wildcard $1),$(shell find $(1:%/=%) -type f -name $(subst *,\*,$2)))
SOURCE_MMD := $(sort $(foreach pat,*.mmd,$(call core_find,$(SRCDIR)/,$(pat))))
OUTPUT_MMD_SVG = $(addsuffix .svg, $(basename $(SOURCE_MMD)))

Scripts for building Erlang/OTP

I have Erlang/OTP cloned into ~/local/otp and I have my PATH setup with ~/local/otp-install/bin at the front, so I can quickly test out full installs locally.

You can change the INTERESTING_TARGETS variable to point to whatever other flavors you're interested in building.

Usage

You may need to set ERL_TOP to pwd:

#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int
main(void)
{
@potatosalad
potatosalad / dsu.erl
Last active March 4, 2022 21:19
Disjoint Set Union in Python3
-module(dsu).
-export([
new/0,
find/2,
insert/2,
union/3,
groups/1
]).
@potatosalad
potatosalad / hashquiz.rb
Created December 31, 2010 04:36
Ruby quiz for convert hash "dot paths" into actual hash hierarchy.
#require 'rubygems'
require 'pp'
#require 'ap' # Awesome Print
class Object
# expects [ [ symbol, *args ], ... ]
def recursive_send(*args)
args.inject(self) { |obj, m| obj.send(m.shift, *m) }
end
end

There's something out of whack with the consistent hash algorithm used by swarm (libring):

Add 4 nodes all weighted equally (should be 4 x 25%) libring

iex> ring = HashRing.new()
iex> ring = HashRing.add_node(ring, :a@nohost)
iex> ring = HashRing.add_node(ring, :b@nohost)
iex> ring = HashRing.add_node(ring, :c@nohost)
iex&gt; ring = HashRing.add_node(ring, :d@nohost)