Skip to content

Instantly share code, notes, and snippets.

@mekaneck
mekaneck / sump-pump.yaml
Last active May 18, 2024 11:56
ESPHome YAML code for monitor of sump pump & battery-powered backup sump pump
substitutions:
# Device Naming
devicename: sump-pump
friendly_name: Sump Pump
device_description: Sump Pump Level Sensor, Counter, and Alarm
# Limits for pump levels and alarm levels
primary_pumpout_below_height: '0.100' #meters; the primary pump will empty the sump to below this level
primary_pumpout_reset_height: '0.140' #meters; primary pump counter is reset when water rises above this level (enabling it to be triggered again)
primary_pumpout_duration_limit: '60.0' #seconds; maximum duration for the primary pump to drop the level from 'reset_height' to 'below_height' (otherwise the sump level dropped by some other means e.g. evaporation)
@duairc
duairc / net.nix
Last active April 16, 2024 00:28
IP address arithmetic and validation in Nix
{ lib ? null, ... }:
let
net = {
ip = {
# add :: (ip | mac | integer) -> ip -> ip
#
# Examples:
@martijnvermaat
martijnvermaat / nixos.md
Last active July 13, 2024 09:08
Installation of NixOS with encrypted root
@fpillet
fpillet / Results+Rx.swift
Created February 13, 2016 17:23
turn Realm auto-updating Results into an RxSwift Observable sequence
//
// Results+Rx.swift
//
// Make Realm auto-updating Results observable. Works with Realm 0.98 and later, RxSwift 2.1.0 and later.
//
// Created by Florent Pillet on 12/02/16.
// Copyright (c) 2016 Florent Pillet. All rights reserved.
//
import Foundation
@rnapier
rnapier / NSData.bytesView.swift
Last active January 30, 2019 00:40
Bytes collection for NSData
import Foundation
// Why bytesView rather than just extending NSData directly?
// Because this way we can keep our extension internal and not conflict
// with someone who imports us and has also extended NSData.
// If you're top-level code, you can just hoist everyting up to NSData directly.
internal extension NSData {
var bytesView: BytesView { return BytesView(self) }
}
@imjasonh
imjasonh / markdown.css
Last active May 24, 2024 22:56
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@debasishg
debasishg / gist:8172796
Last active July 5, 2024 11:53
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&rep=rep1&t
@martinwinter
martinwinter / Open Safari tabs in Google Chrome
Last active November 20, 2020 11:33
Opens all Safari windows and tabs in Google Chrome.
tell application "Safari"
repeat with theSafariWindow in windows
tell application "Google Chrome" to set theChromeWindow to make new window
repeat with theSafariTab in theSafariWindow's tabs
set theURL to URL of theSafariTab
tell application "Google Chrome"
set theChromeTab to make new tab at end of tabs of theChromeWindow
set URL of theChromeTab to theURL
end tell
end repeat

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
@mislav
mislav / _readme.md
Last active June 28, 2024 15:16
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work: