Skip to content

Instantly share code, notes, and snippets.

@leighklotz
leighklotz / how-do-i.el
Created March 5, 2016 00:32
M-X how-do-i -- insert sample code based on StackOverflow search
;;;-*-EMACS-LISP-*-
;;; pip install howdoi
(defun how-do-i (task count)
(interactive "sTask: \np")
(let ((language (replace-regexp-in-string "-mode" "" (symbol-name major-mode))))
(shell-command (format "howdoi -n %d %s %s" count language task) t)))
(provide 'how-do-i)
@leighklotz
leighklotz / onename-leighklotz.txt
Created March 25, 2016 01:01
Verifying that +leighklotz is my blockchain ID. https://onename.com/leighklotz
Verifying that +leighklotz is my blockchain ID. https://onename.com/leighklotz
@leighklotz
leighklotz / nav.p2
Created April 14, 2016 00:05
bare-bones xpath-like navigator for python dict
# -*-PYTHON-*-
from __future__ import print_function
def nav(d, ks):
def nav2(d, ks):
if len(ks) == 0:
return d
if not isinstance(d, dict):
raise KeyError(ks)
@leighklotz
leighklotz / DeferBalance.go
Last active June 1, 2018 19:39
defer and named return values combine to produce different results
package main
import "fmt"
func main() {
fmt.Printf("Named Result is %d\n", named_return_value())
fmt.Printf("Explicit Result is %d\n", explicit_return_value())
}
func named_return_value() (balance int) {
@leighklotz
leighklotz / sshaliases
Last active August 12, 2019 17:04
print or match Host and Hostname aliases from ~/.ssh/config
#!/bin/bash
function usage() {
echo "usage:"
name=`basename $0`
echo "$name: print Host and Hostname aliases from ~/.ssh/config"
echo "$name foo: grep for foo in above output"
echo "$name -e|--exact foo: grep for '^foo ' in above output and print only hostname. example: ping \$(sshaliases --exact foo)"
echo "$name -h|--help: this help"
}
@leighklotz
leighklotz / animal.el
Last active April 9, 2023 02:20
Animal game in Emacs Lisp, written by GitHub Codex
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Leigh Klotz, 2023-04-08
;;;
;;; This section is human-written, mostly :-)
;;;
;;; I created this file with GitHub Codex, mosly from the prompt
;;; of the first two comment lines.
;;;
;;; For Copilot Emacs Integration I followed
;;; https://robert.kra.hn/posts/2023-02-22-copilot-emacs-setup/#copilot-api--integration
@leighklotz
leighklotz / fib.apl
Created April 9, 2023 04:52
Copilot - Emacs blank slate coding in APL: started with modeline, after response gave "calculate fibonacci" comment prompt; the rest is verbatim pruned of repetition
;;;-*-Mode; APL;-*-
⎕IO←0
⎕←'Hello, world!'
⎕←'Hello, world!'⍝ comment
⍝ calculate fibonacci
fib←{⍺⍺⍵⍵-1⍵⍵-2}
fib 10
⍝ 55
@leighklotz
leighklotz / main.c
Created April 10, 2023 01:30
Codex Prompt was main function (interactively written) and first two comment lines; it generated the assembly
#include "main.h"
int main(int argc, char *argv[])
{
printf("Hello World: %d", argc);
for (int i = 0; i < argc; i++)
{
printf("%s", argv[i]);
}
return 0;
export PATH="/usr/local/cuda-11.7/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH"
# ldconfig
klotz@tensor:~$
In Terraform, there is no built-in function to deeply merge two maps. However, you can achieve this by combining multiple functions and applying some custom logic. Here's an example of how you can deeply merge two maps in Terraform:
```hcl
locals {
map1 = {
key1 = "value1"
key2 = {
nested_key1 = "nested_value1"
}
key3 = {