Skip to content

Instantly share code, notes, and snippets.

@mlschmitt
mlschmitt / Merlin_Wisdom_Widget_Scriptable.js
Last active May 19, 2023 16:58
Random wisdom from Merlin Mann in a handy widget - https://github.com/merlinmann/wisdom
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: brain;
let items = await loadItems()
if (config.runsInWidget) {
let widget = await createWidget(items)
Script.setWidget(widget)
} else if (config.runsWithSiri) {
let firstItems = items.slice(0, 5)
let table = createTable(firstItems)
import React, { useState, useEffect } from 'react'
import styled from 'styled-components'
import { useCanvas } from 'utils/hooks'
import debounce from 'lodash/debounce'
export default function Glow() {
const [ref, setRef] = useState<HTMLCanvasElement | null>(null)
const [boxes, setBoxes] = useState<Box[]>([])
const [ctx, width, height] = useCanvas(ref)
const moving = useMouseMoving()
@roycoding
roycoding / rss.md
Created May 21, 2020 20:10
It's 2020 and I made an RSS feed for my blog (with Python)

It's 2020 and I made an RSS feed for my blog (with Python)

Roy Keyes

21 May 2020 - This is a post on my blog. Grab the RSS feed here 😉

I was recently telling someone about all of the awesome blog posts I have sitting in my backlog, just waiting to actually be written. They asked if there was a way to subscribe or get notified when my next post was live. The answer was "watch my Twitter", which was admittedly unsatisfactory.

Coincidentally I have been seeing a number of recent articles on the desire for more independent blog content and a return to RSS-based syndication. I think this is all part of a broader push for a (return to a?) m

@jamiesanson
jamiesanson / ViewLifecycleLazy.kt
Last active May 29, 2024 10:43
A Kotlin lazy implementation which automatically clears itself at appropriate times in the View Lifecycle, with a Fragment example
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.Observer
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
fun <T> Fragment.viewLifecycleLazy(initialise: () -> T): ReadOnlyProperty<Fragment, T> =
object : ReadOnlyProperty<Fragment, T>, DefaultLifecycleObserver {
@armanso
armanso / Extention.kt
Last active April 17, 2021 14:14
Part 2 of blog post - Control view's shadow
fun View.setShadow(
@ColorRes shadowColor: Int,
@DimenRes cornerRadius: Int,
@DimenRes elevation: Int,
shadowGravity: Int = Gravity.BOTTOM,
@ColorRes backgroundColorResource: Int = 0
) {
val resource = context.resources
val firstLayer = 0
val ratioTopBottom = 3
@gcmartinelli
gcmartinelli / curlprototype.kt
Last active December 18, 2020 14:59
A Kotlin/Ktor webserver prototype that receives a string and returns an encoded string to be printed - in color - by a terminal using curl
/* A prototype script that creates a webserver that receives a string and returns
an encoded string to be printed - in color - by a terminal using curl.
Dependency: Kotlin and Ktor (www.ktor.io)
*/
import io.ktor.application.call
import io.ktor.response.respondBytes
import io.ktor.routing.get
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
@alisdair
alisdair / intensify.sh
Created May 21, 2019 23:44
intensifies Slack emoji creator
#!/bin/bash
# Generate a `:something-intensifies:` Slack emoji, given a reasonable image
# input. I recommend grabbing an emoji from https://emojipedia.org/
set -euo pipefail
# Number of frames of shaking
count=10
# Max pixels to move while shaking
@objcode
objcode / ConcurrencyHelpers.kt
Last active May 31, 2024 13:31
Helpers to control concurrency for one shot requests using Kotlin coroutines.
/* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@fnky
fnky / ANSI.md
Last active June 9, 2024 19:55
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
# A block is stored as a tuple of
# (parent_hash, transactions, hash_itself)
def get_parent_hash(block):
return block[0]
def get_transactions(block):
return block[1]