Skip to content

Instantly share code, notes, and snippets.

;;; -*- Mode:Lisp; Syntax:ANSI-Common-Lisp; Package: ASDF-USER -*-
(in-package :asdf-user)
(defsystem :my-new-system
:description ""
:author "Ed L <edward@elangley.org>"
:license "MIT"
:depends-on (#:alexandria
#:uiop
#:serapeum
(xhtmlambda::def-element <::request)
(defun post-to-endpoint (xml)
(let ((drakma:*text-content-types* (acons "application" "xml" drakma:*text-content-types*)))
(drakma:http-request *endpoint*
:basic-authorization (list *api-key* "X")
:method :post
:content (with-output-to-string (s)
(format s "~w" xml)))))
@jgarte
jgarte / sub-sub-command.py
Created August 16, 2022 04:25 — forked from jirihnidek/sub-sub-command.py
Python example of using argparse sub-parser, sub-commands and sub-sub-commands
"""
Example of using sub-parser, sub-commands and sub-sub-commands :-)
"""
import argparse
def main(args):
"""
Just do something
@jgarte
jgarte / README.md
Created August 10, 2022 01:42 — forked from cellularmitosis/README.md
Gist mirror of "Learn Scheme in 15 Minutes"
@jgarte
jgarte / zig_cache.md
Created July 27, 2022 06:14 — forked from matu3ba/zig_cache.md
Big picture of the Zig caching system.

** Big picture of the Zig caching system. ** This is a big picture of the Zig caching system, mostly motivated for me to understand the necessary bits to solve ziglang/zig#11643. It reflects the status quo of commit fcfeafe99a3ecc694a3475735c81a0d75b6da6d0. The core logic is defined in src/Cache.zig.

zig-cache/h contains the manifest files with varying content. Manifest files hold relevant data from the compilation to decide, if the files at the used paths have changed (ie from editing or git).

@jgarte
jgarte / pudb-add-breakpoint
Created July 24, 2022 22:00 — forked from kjordahl/pudb-add-breakpoint
Emacs lisp code to add pudb breakpoint to a python file (add to .emacs)
;; this location is "~/.pudb-bp" in older versions of pudb
(setq pudb-bp-file (expand-file-name "~/.config/pudb/saved-breakpoints"))
(defun pudb-add-breakpoint ()
(interactive)
(append-to-file
(concat "b " buffer-file-name ":"
(nth 1 (split-string (what-line))) "\n")
nil pudb-bp-file))
(define-key py-mode-map (kbd "C-c C-t") 'pudb-add-breakpoint)
@jgarte
jgarte / easyrpc.py
Created July 5, 2022 01:30 — forked from laanwj/easyrpc.py
Bitcoind RPC example from Python
'''
Convenience utility for connecting to a bitcoind instance through RPC.
'''
# W.J. van der Laan 2021 :: SPDX-License-Identifier: MIT
import base64
import decimal
from http import HTTPStatus
import http.client
import json
import logging
@jgarte
jgarte / grep
Created July 4, 2022 23:58 — forked from aiotter/grep
better grep (silently use ripgrep if available)
#!/usr/bin/env python3
# Copyright 2021 aiotter
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH T
@jgarte
jgarte / gist:6ba7a796365b348d35e23ad5c5f6178c
Created June 21, 2022 02:25 — forked from cky/gist:8500450
Guile implementation of Clojure's `#(...)` reader macro, but using `##(...)` instead to avoid conflicting with vectors.
(use-srfis '(1 69))
(read-hash-extend #\#
(lambda (c port)
(define ht (make-hash-table eqv?))
(define (ht-ref key)
(hash-table-ref ht key (lambda ()
(define sym (gensym))
(hash-table-set! ht key sym)
sym)))
(define (hash-key x)
@jgarte
jgarte / main.py
Created June 14, 2022 04:27 — forked from eoranged/main.py
LibCST example for Moscow Python Conf++ 2021
RESULTS = {}
def add_and_store(a, b, name):
"""Process and save to DB"""
result = a + b
RESULTS[name] = result
def add(a, b):