Skip to content

Instantly share code, notes, and snippets.

@n2o
n2o / cache-clojure-deps.edn.md
Last active August 8, 2022 09:46
Caching Clojure tools.deps Dependencies when building Docker Images

To cache the layer containing the dependencies from your Clojure project, you can execute a command without starting a REPL. This downloads all common dependencies, which are then be cached.

For example:

FROM clojure:openjdk-14-tools-deps-alpine

# Cache and install Clojure dependencies
COPY deps.edn .
@yogthos
yogthos / clojure-beginner.md
Last active May 6, 2024 08:11
Clojure beginner resources

Introductory resources

@YellowApple
YellowApple / sqlite-test.c
Created September 28, 2019 02:16
Opening and closing a SQLite database in Zig
/* Ripped from https://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm */
#include <stdio.h>
#include <sqlite3.h>
int main(int argc, char* argv[]) {
sqlite3 *db;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open(":memory:", &db);
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 26, 2024 10:15
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

Top picks from StrangeLoop 2016

These are the presentations, which I did like most (and had a chance to watch). Order matters:

  • Idealized commit logs - the best talk IMO. Andrew Shreve shows his approach to better understanding of programs by using technique called program slicing - the idea is to decompose program and its tests in way that every 'commit' contains the smallest part of the code that makes included test pass. This way you get a history of program, which aims at incremental development of understanding. Awesome stuff. https://www.youtube.com/watch?v=dSqLt8BgbRQ&index=4&list=PLcGKfGEEONaDvuLDFFKRfzbsaBuVVXdYa

  • Clojure spec - the technique that is built into the language, allowing you to express the constraints over values as a part of function signature definition. Having those, you are able to validate, auto-document and auto-test (genertively) code. While its not a super innovative idea - it's interesting to see something like this to be implemented as a part of the language (i

@jkstill
jkstill / proc_net_tcp_decode
Last active April 17, 2024 07:03
decode entries in /proc/net/tcp
Decoding the data in /proc/net/tcp:
Linux 5.x /proc/net/tcp
Linux 6.x /proc/PID/net/tcp
Given a socket:
$ ls -l /proc/24784/fd/11
lrwx------ 1 jkstill dba 64 Dec 4 16:22 /proc/24784/fd/11 -> socket:[15907701]
@rgov
rgov / Pages - Actual Size.scpt
Created October 13, 2011 00:31
Zoom Pages document to actual size.
(* Converts hex digits in big endian to an integer. *)
on fromHex(theDigits)
set theValue to 0
repeat with theDigit in theDigits
set theValue to (theValue * 16) + (offset of theDigit in "0123456789ABCDEF") - 1
end repeat
return theValue
end fromHex
(* Does a record have a certain key? (Hack.) *)