Skip to content

Instantly share code, notes, and snippets.

@TfTHacker
TfTHacker / canvas.ts
Created December 6, 2022 04:29
Obsidian Canvas JSON format (TypeScript definition)
export type Side = 'top' | 'right' | 'bottom' | 'left';
export interface CanvasData {
nodes: (CanvasFileData | CanvasTextData | CanvasLinkData)[];
edges: CanvasEdgeData[];
}
export interface CanvasNodeData {
id: string;
x: number;
@bassemawhoob
bassemawhoob / cohort.sql
Last active April 12, 2024 18:15
Revenue Retention Cohort Analysis - PostgreSQL
-- Based on: https://medium.com/quick-code/how-to-write-sql-to-calculate-user-cohort-retention-a1b3b57c7a2f
-- Uses DATE_PART instead of DATE_DIFF as it is not supported by PostgreSQL
-- (branch_id, scheduled_for, total_cents)
WITH activities AS (
SELECT branch_id, scheduled_for, total_cents
FROM orders
WHERE orders.status = 'complete'
),
-- (branch_id, cohort_month): cohort month is the first order date
@michaelrog
michaelrog / MyPlugin.php
Created March 2, 2018 06:14
Search Plus custom mapping example
class MyPlugin extends BasePlugin
{
// ...
public function searchPlus_addAlgoliaMapping()
{
return [
[
'name' => 'My Basic Mapping',