Skip to content

Instantly share code, notes, and snippets.

@goliatone
goliatone / exclude.sql
Created June 15, 2023 20:14 — forked from fphilipe/exclude.sql
PostgreSQL EXCLUDE constraint
View exclude.sql
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)
@goliatone
goliatone / meeting-note.md
Created February 12, 2023 23:34 — forked from zsviczian/meeting-note.md
Daily note taking scripts
View meeting-note.md

<%* /*

*/
const view = app.workspace.activeLeaf.view;
const editor = view.editor;
const curLineNum = editor.getCursor().line;
const curLineText = editor.getLine(curLineNum);
const title = tp.file.title;
const today = title.match(/\d{4}\-\d{2}\-\d{2} .+/) //are we on the DNP?
@goliatone
goliatone / Dashboard.md
Created February 12, 2023 22:34 — forked from beet/Dashboard.md
Obsidian Templater script to convert the current line to a Tasks plugin task
View Dashboard.md

Today

due today
not done
done today
@goliatone
goliatone / README.md
Created February 12, 2023 11:25 — forked from lenalebt/README.md
"Rollover Daily Todos" for Obsidian Templater
View README.md

Rollover Daily Todos for Obsidian, but with the Templater Plugin

Rollver daily todos is a really nice extension for Obsidian.md that takes TODOs from yesterdays daily notes and rolls them over to today's notes. It has support for Obsidians built-in templates, but does - to my understanding - not really work well with the Templater Plugin. At least, I was unable to get it to work :-). Also, I wished it had some way to tell me that TODOs have been rolled over a few times already. Doing it this way is my way of working around these limitations.

I took some of the code of that "rollover daily todos" plugin and made it into a templater user script.

@goliatone
goliatone / DailyNoteTemplate.md
Created February 12, 2023 10:45 — forked from panahi/DailyNoteTemplate.md
Obsidian Templates Collection
View DailyNoteTemplate.md

<%* var fileDate = moment(tp.file.title); // moment dates are mutable let prevDay = moment(fileDate).subtract(1, 'd').format('YYYY-MM-DD'); let nextDay = moment(fileDate).add(1, 'd').format('YYYY-MM-DD'); let prevDayWeek = moment(fileDate).subtract(1, 'd').format('gggg-[W]ww'); let nextDayWeek = moment(fileDate).add(1, 'd').format('gggg-[W]ww'); let yearLink = fileDate.format('YYYY'); let quarterLink = fileDate.format('YYYY [Q]Q'); let monthLink = fileDate.format('YYYY-MM');

@goliatone
goliatone / dailyNoteTemplate.txt
Created February 12, 2023 10:02 — forked from bennewton999/dailyNoteTemplate.txt
My current Daily Note Template in Obsidian utilizing Templater and DataView Plugins
View dailyNoteTemplate.txt
---
creation date: <% tp.file.creation_date() %>
tags: DailyNote <% tp.file.title.split('-')[0] %>
---
modification date: <%+ tp.file.last_modified_date("dddd Do MMMM YYYY HH:mm:ss") %> // This doesn't currently work in front matter, hoping that gets fixed.
# <% tp.file.title %>
<< [[<% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>]] | [[<% tp.date.now("YYYY-MM-DD", 1, tp.file.title, "YYYY-MM-DD") %>]]>>
@goliatone
goliatone / query_builder.go
Created October 16, 2022 18:48 — forked from paragtokopedia/query_builder.go
Query Builder
View query_builder.go
package query_builder
import (
"strings"
"strconv"
"html/template"
"fmt"
)
type DynamicQueryBuilder string
@goliatone
goliatone / base64_to_uuid.sql
Created March 29, 2022 21:52
[Snowflake base64 to UUID] #sql #snowflake Snowflake function to encode a base64 encoded UUID as a string formatted UUID
View base64_to_uuid.sql
DROP FUNCTION _BASE64_UUID(VARCHAR);
CREATE OR REPLACE FUNCTION _BASE64_UUID(INPUT VARCHAR)
RETURNS varchar
LANGUAGE javascript
strict
AS
$$
try {
var stmt = snowflake.createStatement({
sqlText: `SELECT TO_VARCHAR(TRY_BASE64_DECODE_BINARY(?), 'HEX');`,
@goliatone
goliatone / github-proxy-client.js
Created March 15, 2022 17:51 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
View github-proxy-client.js
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@goliatone
goliatone / postgres-pivot.md
Created November 9, 2021 22:50 — forked from ryanguill/postgres-pivot.md
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;