Skip to content

Instantly share code, notes, and snippets.

View roam-capture-bookmarklet.md

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.

View roam-bookmarklet.md

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.
View postgres-pctDisplay.sql
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 Mar 31, 2018
An implementation of Option and Result in cfml as a closure. Works on ACF 10, 11 and 2016, Lucee 4.5 and 5.
View Option.cfm
<cfscript>
function Option () {
var NIL = "__NIL__";
var _isNil = function (input) {
return (isNull(input) || (isSimpleValue(input) && input == Nil));
};
var _isSome = false;
View cf-destructure.cfm
<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 Nov 10, 2021
Example of postgres pivot using jsonb_object_agg for variable columns in output. To play with this yourself in an online repl, click here: http://dbfiddle.uk/?rdbms=postgres_9.6&fiddle=5dbbf7eadf0ed92f8d6a49fc5be8f3f2
View postgres-pivot.md
/*
================================================================================
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.
*/

DROP TABLE IF EXISTS invoice;
View keybase.md

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:

View map-and-filter-array.js
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);
View arrayDistinct.cfm
<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);
View sql-formatting.md
SELECT
	  pri.lorem
	, pri.ipsum
	, pri.dolar orci
	, pri.sit
	, pri.amet
	, CASE
		WHEN erat = 'vitae'
		THEN 'suscipit'