Skip to content

Instantly share code, notes, and snippets.

@SeanCline
SeanCline / clear_notification.yaml
Last active July 9, 2023 17:45
A pair of scripts to provide a consistent API around sending and clearing notifications on Android, iPhone, and Dashboard.
alias: "Notification: Clear Notification"
mode: queued
max: 10
icon: mdi:bell-minus
fields:
tag:
name: Tag
description: A string identifying the message to clear/dismiss.
example: laundry_done_0F14AB
required: true
@SeanCline
SeanCline / Send infrared commands from the Arduino to the iRobot Roomba
Created August 2, 2021 13:54 — forked from probonopd/Send infrared commands from the Arduino to the iRobot Roomba
Send infrared commands from the Arduino to the iRobot Roomba. Use a transistor to drive the IR LED from pin D3 for maximal range.
#include <IRremote.h>
/*
Send infrared commands from the Arduino to the iRobot Roomba
by probono
2013-03-17 Initial release

Raspberry PI (cli):

  $ DST_HOST=nc_machine_addr
  $ SDSIZE=`sudo blockdev --getsize64 /dev/mmcblk0`;sudo pv -tpreb /dev/mmcblk0 -s $SDSIZE | nc $DST_HOST 19000

Netcat machine | "nc_machine_addr" (srv):

@SeanCline
SeanCline / windbg-comcall.md
Last active April 25, 2022 17:10
WinDbg: Getting COM Call target from SendReceive2 stack frame.

Looking at a callstack that is making a COM call to another apartment, look for the SendReceive2 stack frame.

  0:053> kb
  # ChildEBP RetAddr  Args to Child              
  00 1532ed98 752e0ca9 00000002 1532ef44 00000001 ntdll!NtWaitForMultipleObjects+0xc
  01 1532ef1c 756dc2a0 1532eef4 1532ef44 00000000 KERNELBASE!WaitForMultipleObjectsEx+0xdc
  02 1532ef74 75bec1db 00000000 1532efcc 000003e8 user32!MsgWaitForMultipleObjectsEx+0x159
  03 1532efac 75beb438 1532efcc 00000001 1532efd0 combase!CCliModalLoop::BlockFn+0x101
 04 (Inline) -------- -------- -------- -------- combase!ModalLoop+0x50
#pragma once
#include <string>
#include <codecvt>
Platform::String^ to_PlatformString(const char* from)
{
std::wstring_convert<std::codecvt<wchar_t, char, mbstate_t>> convert;
auto wide = convert.from_bytes(from);
return ref new Platform::String(wide.c_str(), static_cast<unsigned int>(wide.size()));
@SeanCline
SeanCline / main.cpp
Last active June 10, 2016 12:36
transacted<T> - Stores a copy of a type and writes the result back to the original unless an exception is thrown.
#include "transacted.h"
#include <iostream>
#include <stdexcept>
using namespace std;
int x = 1;
long y = 2;
float z = 3;
void doSomething()
#pragma once
#include <string>
// Why can't MFC and ATL just get along?
#if defined(_AFX) || defined(_AFXDLL)
# include <cstringt.h>
#else
# include <atlstr.h>
#endif
@SeanCline
SeanCline / hrm.h
Last active August 13, 2017 21:53
Implementing the assembly-like language syntax in Human Resources Machine using the C preprocessor.
#pragma once
#include <iostream>
#include <deque>
#include <vector>
struct hrm_num {
static int validate(int n)
{
if (n < -999 || n > 999)
@SeanCline
SeanCline / clone_ptr.h
Last active April 27, 2016 17:38
A quick (mostly untested) go at a `clone_ptr` implementation that keeps from slicing polymorphic objects by type erasing their copy constructor and storing them in the clone_ptr.
#pragma once
#include <memory>
#include <utility>
#include <type_traits>
#include <functional> // TODO: Stop using functional.
template <class T>
struct default_clone {
T* operator()(const T* ptr) const
@SeanCline
SeanCline / Signal.js
Last active September 20, 2015 02:10
A minimal Signal class that lets you connect and disconnect handlers.
/*
* File: Signal.js
* Classes: Signal, Signal.Connection
* Author: Sean Cline
* Version: .1
* Description: A minimal Signal class that lets you connect and disconnect handlers to be called when .emit(...) is called.
* License: You may do whatever you please with this file and any code it contains. It is public domain.
* Usage:
* let sig = new Signal();
* let connection1 = sig.connect(function(str) { alert(str + "1") });