Skip to content

Instantly share code, notes, and snippets.

View asmallteapot's full-sized avatar
😴
😴

Ellen Teapot asmallteapot

😴
😴
View GitHub Profile
@porglezomp
porglezomp / Denotation.swift
Created June 7, 2019 23:49
Swift has MixFix operators, right?
// Colin Barrett - @cbarrett
// turning a big dial taht says "Mixfix operators like Agda" on it
// and constantly looking back at the audience for approval
// like a contestant on the price is right
// https://twitter.com/cbarrett/status/1137113289593413633
// Here define a mixfix interpreter operator spelled: _ ⊢ ⟦_⟧
prefix operator ⟦
postfix operator ⟧
@stevestreza
stevestreza / DispatchQueueScheduler.swift
Last active June 29, 2023 13:06
A basic implementation of a Scheduler for Combine. Probably not a great implementation. Useful only as a toy, do not ship this.
//
// DispatchQueueScheduler.swift
//
import Combine
import Foundation
// DO NOT USE THIS IN PRODUCTION
struct DispatchQueueScheduler: Scheduler {
let queue: DispatchQueue
@porglezomp
porglezomp / ShitLetsBeSmalltalk.swift
Last active August 21, 2019 21:28
Where we're going we don't need primitive control flow!
/// Like a smalltalk bool, but worse. Just used for control flow, we can use real boolean ops.
class ChitChatBool {
func ifTrue<T>(block: () -> T) -> T? { return nil }
}
class True: ChitChatBool {
override func ifTrue<T>(block: () -> T) -> T? { return block() }
}
class False: ChitChatBool { }
@mKeRix
mKeRix / d6t_44l_06.h
Last active March 12, 2023 09:34
ESPHome D6T Custom Component
#include "esphome.h"
#include "math.h"
using namespace esphome;
#define I2C_ADDR_D6T 0x0a
#define CMD 0x4c
static const int SOBEL_X[3][3] =
{ { -1, 0, 1 },
@lizthegrey
lizthegrey / attributes.rb
Last active March 27, 2025 02:16
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@benasher44
benasher44 / kn_gtest_to_junit.sed
Last active February 28, 2023 15:45
K/N GTest Output to JUnit XML using sed
# Escape XML characters
s/&/\&amp;/g
s/"/\&quot;/g
s/'/\&apos;/g
s/</\&lt;/g
s/>/\&gt;/g
s/\[==========\] Running ([0-9]+) tests from [0-9]+ test cases./<testsuites><testsuite tests="\1">/g
s/\[ RUN \] ([[:alnum:]_-]+)\.(.+)/<testcase classname="\1" name="\2">/g
s/\[----------\].+//g
@mxcl
mxcl / detweet.swift
Last active August 16, 2024 15:38
Delete all tweets and favorites older than two months ago. Instructions in comment.
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import Swifter // @mattdonnelly == b27a89
let swifter = Swifter(
consumerKey: "FILL",
consumerSecret: "ME",
oauthToken: "IN",
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html"
@douglashill
douglashill / KeyboardTableView.swift
Last active March 30, 2023 22:01
A UITableView that allows navigation and selection using a hardware keyboard.
// Douglas Hill, December 2018
// Made for https://douglashill.co/reading-app/
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit
import UIKit
/// A table view that allows navigation and selection using a hardware keyboard.
/// Only supports a single section.
class KeyboardTableView: UITableView {
// These properties may be set or overridden to provide discoverability titles for key commands.
@SanCoder-Q
SanCoder-Q / synology.startup
Created December 25, 2017 14:29
Synology NAS - How to make a program run at startup
Synology NAS - How to make a program run at startup
The other day I created a little node.js project to keep track of some finances. Synology has a node.js package but that just installs the tools - it has no 'container' or any other support to drop files and have it run automagically. Maybe one day.
In the meantime, you can start your project when you SSH into the NAS. My project has a 'www' script which bootstraps my project, so to start I simply type 'node bin/www' from the project directory. But, it only runs while I'm logged in, and if I log out for any reason, the process dies. That's hardly useful when I'm away from home, or on a different PC. So I decided to have a look at starting my project as a Linux service.
After doing a lot of research into how Synology does services, and a few failed attempts at init scripts, I found that Synology DSM (since version 5 perhaps) bundles Upstart, which is a neat little tool to deal with services on Linux. It's most prevalent on Debian and derivatives (notably Ub
@dentechy
dentechy / WSL-ssh-server.md
Last active October 8, 2024 10:48
A step by step tutorial on how to automatically start ssh server on boot on the Windows Subsystem for Linux

How to automatically start ssh server on boot on Windows Subsystem for Linux

Microsoft partnered with Canonical to create Bash on Ubuntu on Windows, running through a technology called the Windows Subsystem for Linux. Below are instructions on how to set up the ssh server to run automatically at boot.

  1. Edit the /etc/ssh/sshd_config file by running the command sudo vi /etc/ssh/sshd_config and do the following
    1. Change Port to 2222 (or any other port above 1000)
    2. Change PasswordAuthentication to yes. This can be changed back to no if ssh keys are setup.
  2. Restart the ssh server:
    • sudo service ssh --full-restart
  3. With this setup, the ssh server must be turned on every time you run Bash on Ubuntu on Windows, as by default it is off. Use this command to turn it on: