Skip to content

Instantly share code, notes, and snippets.

@clartaq
clartaq / 0_reuse_code.js
Last active August 29, 2015 14:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@clartaq
clartaq / WikiLinkAttributesTest.clj
Last active September 5, 2018 14:06
Wikilink Attributes Extension for flexmark written in Clojure
(ns cwiki.test.util.WikiLinkAttributesTest
(:require [clojure.test :refer :all]
[cwiki.util.wikilink-attributes])
(:import (com.vladsch.flexmark.util.options MutableDataSet)
(com.vladsch.flexmark.parser Parser Parser$Builder)
(com.vladsch.flexmark.html HtmlRenderer HtmlRenderer$Builder)
(com.vladsch.flexmark.ext.wikilink WikiLinkExtension)
(cwiki.util WikiLinkAttributeExtension)
(java.util ArrayList)))
@clartaq
clartaq / CWikiLinkRenderer.java
Created December 16, 2018 22:53
Custom flexmark-java LinkRenderer for CWiki (not used)
package cwiki.extensions;
import com.vladsch.flexmark.ext.wikilink.WikiLink;
import com.vladsch.flexmark.ext.wikilink.internal.WikiLinkOptions;
import com.vladsch.flexmark.html.CustomNodeRenderer;
import com.vladsch.flexmark.html.HtmlWriter;
import com.vladsch.flexmark.html.renderer.*;
import com.vladsch.flexmark.util.options.DataHolder;
import com.vladsch.flexmark.util.sequence.BasedSequence;
@clartaq
clartaq / font-detection.cljs
Last active June 6, 2019 19:57
Detecting Installed Fonts with ClojureScript
;;;;
;;;; Utilities to help with determining what if particulare fonts are
;;;; installed on the client system.
;;;;
(ns cwiki-mde.font-detection
(:require [clojure.string :as string]))
;; Filled in during loading of namespace.
(def measured-font-widths (atom {}))
@clartaq
clartaq / wc.clj
Created June 15, 2020 20:00
Clojure Namespace to Count Words in Markdown Text
;;;;
;;;; This namespace includes utility functions to count the number of words
;;;; in a file of Markdown text.
(ns cwiki.util.wc
(:require [clojure.string :as s]))
(defn strip-html-comments
"Return a version of the input text with HTML comments removed."
[text]
@clartaq
clartaq / cljkeycodecombination.clj
Created November 1, 2015 22:18
A demo of using a JavaFX keycode combination in Clojure.
(ns cljkeycodecombination.core
(:gen-class
:extends javafx.application.Application)
(:import
[javafx.application Application Platform]
[javafx.event EventHandler]
[javafx.scene Scene]
[javafx.scene.control Menu MenuBar MenuItem]
[javafx.scene.input KeyCode KeyCodeCombination KeyCombination KeyCombination$Modifier]
[javafx.scene.layout BorderPane]
@clartaq
clartaq / printscaling.clj
Created November 9, 2015 21:47
Print a JavaFX Node at a Specific Size
(ns printscaling.core
(:gen-class
:extends javafx.application.Application)
(:import
[javafx.application Application]
[javafx.beans.value ChangeListener]
[javafx.event EventHandler]
[javafx.geometry Insets Pos]
[javafx.print PrinterJob]
[javafx.scene Scene]
@clartaq
clartaq / DeleteAlertDemo.java
Last active November 23, 2020 18:02
Creating an Alert Box that Always Appears over the Primary Stage.
package deletealertdemo;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
@clartaq
clartaq / sorting.scm
Created October 30, 2020 13:50
Some Sorting Methods in Scheme
;; Uncomment the following line to run in racket.
;; #lang scheme/base
;;;;
;;;; A series of sorting algorimthms implemented in Scheme. The work in this
;;;; gist was inspired by the article "8 Must-Know Sorting Algorithms" by
;;;; Mangabo Kolawole at
;;;; https://dev.to/koladev/8-must-know-sorting-algorithms-5ja
;;;;
;;;; All of the examples shown here are non-destructive, that is, they leave
@clartaq
clartaq / direct_tty.ss
Last active August 11, 2022 18:13
Raw Terminal Input in Chez Scheme
;;
;; direct_tty.ss
;;
;; This is a demonstration program using some of the Chez Scheme FFI
;; to put the terminal into "raw" mode, read a line of characters,
;; possibly containing control characters that would normally
;; terminate input, without echoing the characters typed. Once the
;; user presses the line termination character, (user defined, see the
;; `quit?` procedure), the program displays the line.
;;