Skip to content

Instantly share code, notes, and snippets.

@schacon
schacon / better-git-branch.sh
Created January 13, 2024 18:41
Better Git Branch output
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
@johnhungerford
johnhungerford / getEither.scala
Last active October 15, 2024 07:21
Kotlin/TypeScript -like syntax for accessing nested optional types
//> using scala 3.3
import scala.util.{Failure, NotGiven, Success, Try, boundary}
import boundary.{Label, break}
import scala.annotation.targetName
/**
* Proof of concept implementation of a syntax similar to Kotlin and
* typescript. Within the context provided by [[getEither]], you can call
* `?` on any optional/failable type (currently supports [[Option]],
@zry98
zry98 / digoo-station.yaml
Created June 29, 2023 19:22
Digoo weather station sensor component for ESPHome
substitutions:
device_name: 'Digoo Station'
external_location: 'Balcony'
rf_receiver_pin: '4'
digoo_sensor_channel: '2'
digoo_sensor_id: '9'
esphome:
name: digoo-station
comment: 'ESP station for environment monitoring'
@david-lev
david-lev / sai.sh
Last active May 2, 2025 11:56
This script allows you to install split-apks with one adb shell command!
#!/system/bin/sh
# Split APKs Installer | SAI #
: '
This script allows you to install splits-apk with one adb shell command! push this script to your device with adb and run it:
usage: sh sai.sh [path/to/folder/with/the/apks] [installer pkg (optional)] [originating-uri (optional)]
example: sh sp_installer.sh "/data/local/tmp/wa_app/" "com.android.vending" "171faa8c8918"
Author: David Lev (github.com/david-lev)
'
echo "<<< Split APKs Installer | github.com/david-lev >>>\n"
@tobiaslins
tobiaslins / worker.js
Last active July 30, 2024 20:11
Notion Custom Domain using Cloudflare Workers + Splitbee Analytics
const MY_DOMAIN = "help.splitbee.io"
const START_PAGE = "https://www.notion.so/splitbee/Help-Center-bbf26e2b70574901b9c98e5d11e449de"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, HEAD, POST,PUT, OPTIONS",
@runarorama
runarorama / day1.markdown
Last active December 8, 2019 12:42
Advent of Code (Unison Edition), day 1

Advent of Code 2019, in Unison

Spoilers for Advent of Code 2019 follow.

Day 1: The Tyranny of the Rocket Equation

Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.

This describes a simple function. There seems to be an oversight in the problem statement that modules with very low mass have a negative fuel requirement. I'm going to assume that's not right, and that instead of integer subtraction, we want natural number subtraction (sometimes called "monus"). In Unison, we can use the Nat type instead of integers, so we don't have to consider negatives. The subtraction operation is called drop:

@mayneyao
mayneyao / notion2blog.js
Last active April 6, 2025 01:54
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@lrytz
lrytz / usability-summer.md
Last active July 11, 2019 09:18
Summer of Usability

Summer of Usability

Dear Community

We from the Scala team at Lightbend have decided to take some time this summer to work on usability improvements that are always falling through the cracks while we're busy working on the hard features of the next Scala release. Here is a summary of our project proposals.

REPL usability improvements

@som-snytt already implemented the JLine 3 upgrade (scala/scala#8036) which gives multi-line history and editing. We are planning to add further improvements (many of them pioneered by Ammonite and/or the Dotty REPL) on top of this, for example syntax highlighting and import library dependencies.

@isyufu
isyufu / TryDoobie.scala
Created June 16, 2018 03:02
Doobie with SQLite
/* library dependecies
"org.xerial" % "sqlite-jdbc" % "3.23.1",
"org.tpolecat" %% "doobie-core" % "0.5.3",
"org.tpolecat" %% "doobie-hikari" % "0.5.3", // HikariCP transactor.
"org.tpolecat" %% "doobie-specs2" % "0.5.3", // Specs2 support for typechecking statements.
"org.tpolecat" %% "doobie-scalatest" % "0.5.3", // ScalaTest support for typechecking statements.
*/
object TryDoobie extends App {
import doobie._
@patriknw
patriknw / LinearStageLogic.scala
Created June 13, 2018 15:22
Prototype LinearStage
/**
* Copyright (C) 2018 Lightbend Inc. <http://www.lightbend.com>
*/
package akka.stream.stage
import scala.collection.immutable
import scala.concurrent.duration.FiniteDuration
import akka.NotUsed
import akka.annotation.InternalApi