Skip to content

Instantly share code, notes, and snippets.

@mdemare
mdemare / wrapping-3.clj
Created November 1, 2022 16:19
Normal function called by wrapping function
(defn load-entities
[f loader {:keys [::ooapi/type] :as request}]
(if (= "relation" type)
(f request)
(when-result [entity (loader request)
offerings (load-offerings loader request)
education-specification (if (= type "education-specification")
entity
(loader (assoc request
::ooapi/type "education-specification"
@mdemare
mdemare / wrapping-2.clj
Last active November 1, 2022 16:18
Normal function, wrap using partial or anonymous function at caller
(defn load-entities
[f loader {:keys [::ooapi/type] :as request}]
(if (= "relation" type)
(f request)
(when-result [entity (loader request)
offerings (load-offerings loader request)
education-specification (if (= type "education-specification")
entity
(loader (assoc request
::ooapi/type "education-specification"
@mdemare
mdemare / wrapping-1.clj
Last active November 1, 2022 16:17
Function creating function
(defn wrap-load-entities
[f ooapi-loader]
(let [loader (validating-loader ooapi-loader)]
(fn [{:keys [::ooapi/type] :as request}]
(if (= "relation" type)
(f request)
(when-result [entity (loader request)
offerings (load-offerings loader request)
education-specification (if (= type "education-specification")
entity
### Keybase proof
I hereby claim:
* I am mdemare on github.
* I am michieldemare (https://keybase.io/michieldemare) on keybase.
* I have a public key ASAz-vEjCrX1BPU7oqdjczUtCvl6jEUl5mMvEU8UP5sspwo
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am mdemare on github.
  • I am mdemare (https://keybase.io/mdemare) on keybase.
  • I have a public key ASDeETC7-6yQi9tvE1Z4_RY2d3kWwG_6KPVwPHXsRRFhSwo

To claim this, I am signing this object:

C!
# Backends
backend F_addr_api_example_com {
.connect_timeout = 1s;
.dynamic = true;
.port = "443";
.host = "api.example.com";
.first_byte_timeout = 15s;
.max_connections = 200;
@mdemare
mdemare / gist:53ae2e178931fa35def5
Created May 9, 2015 11:04
unused locale items
fname = ARGV[0]
missing = []
lines = File.read(fname).lines.map(&:chomp).map {|l| l =~ /(\w+): .+/ && $1 }.compact.sort.uniq
for l in lines
puts l
q = `ag -w -s #{l} translators/app/`.lines.select do |x|
x =~ /#{l}['"]/
end
if q.empty?
missing << l
@mdemare
mdemare / fishmakeerror
Created July 6, 2012 08:55
fishfish make error
./internalize_scripts.py
g++ -g -O2 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -fno-optimize-sibling-calls -Wall -DLOCALEDIR=\"/usr/local/share/locale\" -DPREFIX=L\"/usr/local\" -DDATADIR=L\"/usr/local/share\" -DSYSCONFDIR=L\"/usr/local/etc\" -c -o function.o function.cpp
g++ -g -O2 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -fno-optimize-sibling-calls -Wall -DLOCALEDIR=\"/usr/local/share/locale\" -DPREFIX=L\"/usr/local\" -DDATADIR=L\"/usr/local/share\" -DSYSCONFDIR=L\"/usr/local/etc\" -c -o builtin.o builtin.cpp
In file included from builtin.cpp:385:
builtin_set.cpp: In function ‘void erase_values(wcstring_list_t&, const std::vector<long int, std::allocator<long int> >&)’:
builtin_set.cpp:288: warning: comparison between signed and unsigned integer expressions
In file included from builtin.cpp:386:
builtin_commandline.cpp: In function ‘int builtin_commandline(parser_t&, wchar_t**)’:
builtin_commandline.cpp:445: warning: comparison between signed and unsigned integer expressions
builtin.cpp: In func
@mdemare
mdemare / nokogiri libxml homebrew lion
Created June 6, 2012 11:07
How to fix: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
FIXME:
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
or
libxml_ruby.bundle: dlsym(0x10fde1900, Init_libxml_ruby): symbol not found
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
@mdemare
mdemare / gist:1003131
Created June 1, 2011 19:46
/etc/init.d/thin
#!/bin/sh
### BEGIN INIT INFO
# Provides: thin
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: thin initscript
# Description: thin
### END INIT INFO