Skip to content

Instantly share code, notes, and snippets.

@dnaeon
dnaeon / bar.lisp
Created January 16, 2020 18:49
CL packages
;;;; Path: ~/quicklisp/local-projects/foo/src/bar.lisp
(defpackage foo.bar
(:nicknames :foo.bar)
(:use :cl)
(:export :my-function))
(in-package :foo.bar)
;; :arrows is not imported, but I can still access it
;;
@dnaeon
dnaeon / keywordize-keys-strips-reader-tags.clj
Created May 30, 2018 06:29
walk/keywordize-keys strips reader tags
;;
;; When using clojure.walk/keywordize-keys record reader tags are stipped off
;;
user> (require '[clojure.walk :as walk])
nil
user> (defrecord Foo [x])
user.Foo
user> (def m {:foo (->Foo 1) :bar 2 :qux 3})
#'user/m
user> m
@dnaeon
dnaeon / clojure-make-nested-map.clj
Last active February 17, 2019 23:17
clojure-make-nested-map
;;
;; Making a deeply nested map by following parent-child relations between items
;;
(defn make-items [n]
(concat [{:id 0 :name "item-root"}]
(for [x (range 1 n)] {:id x :parent (dec x) :item (format "item-%d" x)})))
(defn item-children [item coll]
(if-let [children (-> (filter #(= (:parent %) (:id item)) coll) seq)]
@dnaeon
dnaeon / range.scm
Created January 25, 2018 12:48
Scheme - range function
;;; validate-step validates whether a given step is a valid one.
(define validate-step
(lambda (step)
(let ((s
(cond
((and (list? step) (not (null? step))) (car step))
((and (list? step) (null? step)) 1)
((string? step) (string->number step))
((integer? step) step))))
@dnaeon
dnaeon / test-c-program-calling-rust.c
Created July 7, 2015 07:35
test-c-program-calling-rust
#include <stdio.h>
typedef struct
{
const char *key;
@dnaeon
dnaeon / test-rust-lib.rs
Last active August 29, 2015 14:24
test-rust-lib
extern crate libc;
use std::{boxed, ffi, ptr};
use libc::c_char;
@dnaeon
dnaeon / rust-libzmq-helloworld.rs
Created June 30, 2015 09:49
rust-libzmq-helloworld
extern crate libc;
extern crate libzmq;
use std::ffi;
use std::thread;
/* Example C header file for libtest */
...
#define LIB_VERSION 1
...
/* End of header file */
// Example Rust code
extern crate libc;
diff --git a/extra/zabbix/vsphere-import/zabbix-vsphere-import b/extra/zabbix/vsphere-import/zabbix-vsphere-import
index 01cd0c4..3958e6a 100755
--- a/extra/zabbix/vsphere-import/zabbix-vsphere-import
+++ b/extra/zabbix/vsphere-import/zabbix-vsphere-import
@@ -436,8 +436,14 @@ class ZabbixVSphere(object):
host
)
+ # Fix for issue #128
+ # Split the VM name which consists of '<vm> (uuid)'
@dnaeon
dnaeon / vpoller-issue-128.patch
Created May 12, 2015 06:51
vpoller-issue-128
diff --git a/extra/zabbix/vsphere-import/zabbix-vsphere-import b/extra/zabbix/vsphere-import/zabbix-vsphere-import
index 01cd0c4..8f797a8 100755
--- a/extra/zabbix/vsphere-import/zabbix-vsphere-import
+++ b/extra/zabbix/vsphere-import/zabbix-vsphere-import
@@ -436,8 +436,14 @@ class ZabbixVSphere(object):
host
)
+ # Fix for issue #128
+ # Split the VM name which consists of '<vm> (uuid)'