Skip to content

Instantly share code, notes, and snippets.

@dmgerman
dmgerman / testing-node-constructor.org
Last active May 21, 2024 22:24
test a constructor that does not take named parameters

add a constructor that does not take named parameters

(cl-defstruct (org-roam-node (:constructor org-roam-node-create)
                             (:constructor org-roam-node-create-from-db
                                           (title
                                            id file file-title level todo
                                            pos priority scheduled deadline 
                                            properties olp atime  mtime tags
                                            aliases refs))
@dmgerman
dmgerman / test-org-roam-db-query.el
Created May 21, 2024 17:27
Testing only Org Roam Db Query
(defun dmg-test-function ()
(org-roam-db-query
"SELECT
id,
file,
filetitle,
\"level\",
todo,
pos,
@dmgerman
dmgerman / test-db.sh
Created May 21, 2024 07:08
Test org-roam db
#!/bin/bash
time sqlite3 /tmp/org-roam.db | wc <<EOF
SELECT
id,
file,
filetitle,
"level",
todo,
pos,
@dmgerman
dmgerman / improved org-roam-node-list.el
Last active May 20, 2024 21:11
Improved Org Roam Node List
(defun org-roam-node-list ()
(let ((rows (org-roam-db-query
"SELECT
id,
file,
filetitle,
\"level\",
todo,
pos,
priority ,
@dmgerman
dmgerman / memoize-roam-read--to-candidate
Created May 19, 2024 08:49
Improve performance of org-roam-find-node
(setq dmg-roam-candidates-cache (make-hash-table :test 'equal))
(defun org-roam-node-read--to-candidate (node template)
"Return a minibuffer completion candidate given NODE.
TEMPLATE is the processed template used to format the entry."
(let* ((args (list node template))
(cached-result (gethash args dmg-roam-candidates-cache))
)
(if cached-result
@dmgerman
dmgerman / profile.org
Last active May 18, 2024 20:08
raw profile of org-roam db access of all the nodes
(let ((startTime (float-time)))
      (progn
;        (print (length (org-roam-node-read--completions)))
        (print (length (org-roam-node-list)))
        (print (- (float-time) startTime)))))
@dmgerman
dmgerman / switch.lua
Last active May 16, 2024 18:38
hammerspoon, switch to an but issue the hotkey to the app too
function is_front_by_bundle_id(bundleID)
local currentWindow = hs.window.focusedWindow()
local currentBundle = nil
if currentWindow then
currentBundle = currentWindow:application():bundleID()
end
return currentBundle == bundleID
end
#!/usr/bin/bash
# replace the next line with the location of your addon
MDIR=/home/dmg/.local/share/Anki2/addons21/MecabUnidic/support
export LD_LIBRARY_PATH=$MDIR:
export DYLD_LIBRARY_PATH=$MDIR:
#$MDIR/mecab.lin --eos-format='\n' --unk-format='' -d $MDIR -r $MDIR/mecabrc "$1"
# MECAB_NODE_UNIDIC_22_PARTS = ['%f[7]', '%f[10]', '%m', '%f[6]', '%f[0]', '%f[1]']
# i swapped the location of %m to first column
#$MDIR/mecab.lin -P
$MDIR/mecab.lin --eos-format='\t\t\t\tEOS\tEOS\n' --unk-format='%M\t%f[0]\t%M\t%f[1]\tunknown\tunknown\n' --node-format='%f[7]\t%f[10]\t%m\t%f[6]\t%f[0]\t%f[1]\n' -d $MDIR -r $MDIR/mecabrc "$1"
@dmgerman
dmgerman / ln-example.org
Last active December 26, 2016 23:41
example of gists

For example, with org extension we can headers as this:’

This is a header

Tables look like this

AThis is the sea
BAnd this is not
#include <iostream>
#include <vector>
int main()
{
std::vector < // I want a vector
std::vector<double> // each element of the vector is a vector
> variableName // name of the vector
(5, // how many elements in the frist dimension
std::vector<double>(2) // It knows each element is a vector (the subvectors. Here we say exactly
// what size each subvector to create