Skip to content

Instantly share code, notes, and snippets.

@kepano
kepano / obsidian-web-clipper.js
Last active May 5, 2024 23:29
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
console.log(Number(Math.round(1.005 + "e2") + "e-2")) // 1.01
const roundAccurately = (number, decimalPlaces) => Number(Math.round(number + "e" + decimalPlaces) + "e-" + decimalPlaces)
console.log(roundAccurately(1.005, 2)) // 1.01
@yyscamper
yyscamper / jsonb_remove_keys.sql
Created February 26, 2018 09:49
PostgreSQL: Remove Multiple Keys From JSONB
CREATE OR REPLACE FUNCTION jsonb_remove_keys(
jdata JSONB,
keys TEXT[]
)
RETURNS JSONB AS $$
DECLARE
result JSONB;
len INT;
target TEXT;
@danielneal
danielneal / eqt.sh
Created March 10, 2017 16:26
Command line tool for pretty-printing transit
#!/usr/local/bin/planck
(ns eqt.core
(:require [cljs.pprint :refer [pprint]]
[cljs.reader :as edn]
[planck.core :as planck]
[clojure.string :as string]
[cognitect.transit :as transit]))
(->> (repeatedly planck/read-line)
@amark
amark / allDone.js
Created November 16, 2014 10:26
parallel async JS micro library in 25LOC
var allDone = function(done){ // takes a callback that will be called as callback(errors, values) when all async parallel operations are finished.
var context = {task: {}, data: {}};
context.end = function(e,v){ return done(e,v), done = function(){} }; // this can always be called if you want to terminate early, like because an error.
context.add = function(fn, id){ // if the async operation you are doing replies with standard fn(err, value) then just pass in a string ID, else your own callback and ID.
context.task[id = (typeof fn == 'string')? fn : id] = false;
var next = function(err, val){
context.task[id] = true; // good, we're done with this one!
if(err){ (context.err = context.err || {})[id] = err } // record errors.
context.data[id] = val; // record the values.
for(var i in c.task){ if(c.task.hasOwnProperty(i)){ // loop over the async task checker