Skip to content

Instantly share code, notes, and snippets.

@dector
dector / index.ts
Created August 31, 2023 11:36
Send email from Cloudflare Worker
/*
Also requires DNS setup for domain:
TXT
_mailchannels
v=mc1 cfid=<YOUR_WORKER_DOMAIN_IN_CLOUDFLARE>.workers.dev
Also DKIM:
https://developers.cloudflare.com/pages/platform/functions/plugins/mailchannels/
import Surreal from "https://deno.land/x/surrealdb@v0.2.1/mod.ts"
const db = new Surreal('http://localhost:8000/rpc')
await db.signin({ user: 'root', pass: 'root' })
await db.use('test', 'test')
console.log("Fetching #1")
console.log(await db.query(`select * from posts`))
console.log("Fetching #2")
/** @jsx h */
import { h, json, jsx, serve } from "https://deno.land/x/sift@0.5.0/mod.ts";
import { ssr } from "https://crux.land/nanossr@0.0.5";
const App = () => (
<div>
<h1>Hello world!</h1>
</div>
);
@dector
dector / PrettyPrint.kt
Created December 11, 2020 12:56
Pretty-print HTML
// Dependency: https://github.com/jtidy/jtidy
import org.w3c.tidy.Tidy
import space.dector.glow.engine.HtmlWebPageContent
import java.io.StringWriter
fun HtmlWebPageContent.prettyPrint(): HtmlWebPageContent {
val tidy = Tidy().apply {
quiet()
@dector
dector / stylus.min.js
Created August 12, 2020 21:40
Stylus WEB
if(Function.prototype.name===undefined&&Object.defineProperty!==undefined){Object.defineProperty(Function.prototype,"name",{get:function(){var regex=/function\s([^(]{1,})\(/,match=regex.exec(this.toString());return match&&match.length>1?match[1].trim():""}})}if(String.prototype.trimRight===undefined){String.prototype.trimRight=function(){return String(this).replace(/\s+$/,"")}}var stylus=function(){function require(p){var path=require.resolve(p),mod=require.modules[path];if(!mod)throw new Error('failed to require "'+p+'"');if(!mod.exports){mod.exports={};mod.call(mod.exports,mod,mod.exports,require.relative(path))}return mod.exports}var bifs="called-from = ()\n\nvendors = moz webkit o ms official\n\n// stringify the given arg\n\n-string(arg)\n type(arg) + ' ' + arg\n\n// require a color\n\nrequire-color(color)\n unless color is a 'color'\n error('RGB or HSL value expected, got a ' + -string(color))\n\n// require a unit\n\nrequire-unit(n)\n unless n is a 'unit'\n error('unit expected, got a ' + -strin
name: dev
on:
push:
branches:
- dev
jobs:
build:
@dector
dector / punched_card.js
Last active October 25, 2019 08:53
:: punched_card :: (ported to p5js)
/*
* :: punched_card :: (ported to p5js)
*
* Try it online:
* https://editor.p5js.org/dector/sketches/mDzY1uL-s
*
* https://gist.github.com/dector/e3891c91230963c3cb347b7b6a64c0cd
*/
SCALE = 4
@dector
dector / HeavyObject.kt
Last active May 13, 2019 23:23
Heavy object for more sensitive memory leaking detection
package io.github.dector.tools
import android.util.Log
import java.lang.ref.WeakReference
/**
* Usage example: `class Foo : HeavyObject by HeavyObject.new() {`.
*/
interface HeavyObject {
@dector
dector / userContent.css
Created November 11, 2018 19:11
Firefox userContent.css
@-moz-document domain("youtube.com") {
#video-title {
max-height: none !important;
}
}
mv ic_about.png about.png
rm ic_account_linking.png
mv ic_challenges.png challenges.png
mv ic_club_check_in.png clubCheckIn.png
mv ic_club_finder.png clubFinder.png
mv ic_connected_apps.png connectedApps.png
mv ic_deals.png deals.png
rm ic_default.png
mv ic_email_preferences.png emailPrefs.png
mv ic_find_a_class.png findAClass.png