Skip to content

Instantly share code, notes, and snippets.

Roam Capture Bookmarklet

Building on the work of the +Roam bookmarklet, here is a version that allows you to capture text from webpages and articles in a few different ways:

  • It will copy the text automatically. A red "copied!" pill will show in the top right of the page to let you know it worked.
  • If you do not select anything it will give you only a markdown link to the page
  • If you select something it will give you the selected text in italics with a markdown link to the page
  • If you select more than one thing (firefox only I believe) it will give you a markdown link to the page with the selected text as child blocks nested underneath.

To try it, drag this link to your bookmarks and then select text on a page and then click the bookmark.

Roam Snippet Bookmarklet

Building on the work of the +Roam bookmarklet, here is a version that allows you to capture text from webpages and articles in a few different ways:

  • It will copy the text automatically. A red "copied!" pill will show in the top right of the page to let you know it worked.
  • If you do not select anything it will give you only a markdown link to the page
  • If you select something it will give you the selected text in italics with a markdown link to the page
  • If you select more than one thing (firefox only I believe) it will give you a markdown link to the page with the selected text as child blocks nested underneath.
  • If you select things, your selection will be restored after copying.
CREATE OR REPLACE FUNCTION pctDisplay (pct numeric, ch text = '|', length int = 20, includeLabel boolean = TRUE) RETURNS text AS $$
DECLARE x TEXT;
BEGIN
IF length < 1 OR length > 100 THEN
length = 20;
END IF;
IF pct < 0 THEN
pct = 0;
@ryanguill
ryanguill / Option.cfm
Last active March 31, 2018 00:41
An implementation of Option and Result in cfml as a closure. Works on ACF 10, 11 and 2016, Lucee 4.5 and 5.
<cfscript>
function Option () {
var NIL = "__NIL__";
var _isNil = function (input) {
return (isNull(input) || (isSimpleValue(input) && input == Nil));
};
var _isSome = false;
<cfscript>
/*
this is what im actually working on, but isnt really the point of this discussion,
but for clarity, I have a process where I am needing to (conditionally) map
from one uuid to another, so I am making a litle closure to keep track. If
I ask for an ID that hasnt been seen yet then it just creates a new uuid for me and
then keeps track of it going forward.
*/
function makeIdMapper () {
@ryanguill
ryanguill / postgres-pivot.md
Last active June 29, 2022 14:08
Example of postgres pivot using jsonb_object_agg for variable columns in output. To play with this yourself in an online repl, click here: https://dbfiddle.uk/?rdbms=postgres_14&fiddle=39e115cb8afd6e62c0101286ecd08a3f
/*
================================================================================
Pivot example with variable number of columns in the output.
================================================================================

example data is straight forward, imagine a table with a customer identifier, 
an invoice date and an amount.
*/

Keybase proof

I hereby claim:

  • I am ryanguill on github.
  • I am ryanguill (https://keybase.io/ryanguill) on keybase.
  • I have a public key ASDx3QP87adqS2sn1aGdqOAIoFi2aPc-cgev_1OrBC8GUwo

To claim this, I am signing this object:

import _ from 'lodash';
import map from "lodash/fp/map";
import filter from "lodash/fp/filter";
import flow from "lodash/fp/flow";
const input = ["a", "b", "c", "d", "e", "f", "g"];
const vowels = ["a", "e", "i", "o", "u"];
const isNotVowel = (char) => !vowels.includes(char);
<cfscript>
function arrayDistinct (required array data) {
var output = arrayNew(1);
output.addAll(createObject("java", "java.util.HashSet").init(arguments.data));
return output;
}
data = [1,2,3,4,5,4,3,2,1];
result = arrayDistinct(data);
SELECT
	  pri.lorem
	, pri.ipsum
	, pri.dolar orci
	, pri.sit
	, pri.amet
	, CASE
		WHEN erat = 'vitae'
 THEN 'suscipit'