Skip to content

Instantly share code, notes, and snippets.

@swissmanu
swissmanu / index.js
Last active April 20, 2023 06:26
Awtrix Light Countdown App with Node-RED. Paste code to a function node and customize the schedule on line 6 to your liking. Node will execute on any incoming message.
const prefix = "awtrix1";
const appName = "countdown";
const now = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const schedule = [
{
date: { day: 1, month: 1 },
text: "First of January every year",
icon: "14004",
@swissmanu
swissmanu / gist:4284339
Created December 14, 2012 10:27
Draws a smiley face under iOS. Pass a mood value ranging from 0 to 1 for making it happy (or sad :( )
/**
* Draws a smiley inside the given rectangle. The mood value (0...1) is used
* to make the smiley happy or sad.
*
* @param rect Rectangle to draw the smiley into
* @param mood Happy (= 1) or sad (= 0) or anything in between
*/
-(void)drawSmileyInRect:(CGRect)rect withMood:(float)mood {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
@swissmanu
swissmanu / stable.json
Last active February 3, 2022 13:43
Lanes Updates
{
"name": "v0.1.1",
"notes": "Updater Test",
"pub_date": "2021-02-03T10:00:00Z",
"platforms": {
"darwin": {
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVRbzgzUkZ1M2NQWUcveDc5K1M1OXl2MHBvZnlzemkwWUJPTDU5YkNBYWlrbzYxS09VMVE2SlY5ZW8rSW16Tk1lYWREWHNiSlBDVVVCWFBTSkViUkZiOUhKK0Vac1ZNMXc0PQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNjQzODc5NDk2CWZpbGU6L1VzZXJzL3J1bm5lci93b3JrL2xhbmVzL2xhbmVzL3NyYy10YXVyaS90YXJnZXQvcmVsZWFzZS9idW5kbGUvbWFjb3MvTGFuZXMuYXBwLnRhci5negpMOWpLTTVJQjUxdlZaNmNGMlVVQkJLdE1GQyt2bHBZQVlhNmE4TElNTVRackFhdGpVc0VFbGVuZktQYklGbkVaZnlnNjF5aXJsZjdJWEFQRWlLWXhCZz09Cg==",
"url": "https://github.com/swissmanu/lanes/releases/download/v0.1.0/Lanes.app.tar.gz"
},
"linux": {
@swissmanu
swissmanu / apply-prettier.ts
Created March 21, 2019 07:19
Apply Prettier Schematic
import { Rule, Tree } from '@angular-devkit/schematics';
import * as prettier from 'prettier';
import { Observable } from 'rxjs';
export default function(): Rule {
return (tree: Tree) =>
new Observable<Tree>(o => {
prettier.resolveConfig(process.cwd()).then(prettierConfig => {
if (!prettierConfig) {
o.error(new Error('Could not resolve prettier configuration'));
export type Tuple2<A, B> = [A, B];
export type Tuple3<A, B, C> = [A, B, C];
export type Tuple4<A, B, C, D> = [A, B, C, D];
export type Tuple5<A, B, C, D, E> = [A, B, C, D, E];
export type Tuple6<A, B, C, D, E, F> = [A, B, C, D, E, F];
export type Tuple7<A, B, C, D, E, F, G> = [A, B, C, D, E, F, G];
export type Tuple8<A, B, C, D, E, F, G, H> = [A, B, C, D, E, F, G, H];
export type Tuple9<A, B, C, D, E, F, G, H, I> = [A, B, C, D, E, F, G, H, I];
export type Tuple10<A, B, C, D, E, F, G, H, I, J> = [A, B, C, D, E, F, G, H, I, J];
@swissmanu
swissmanu / SketchSystems.spec
Last active November 15, 2019 07:48
Editable Page
Editable Page
Error
Reset -> View
View*
Read
Change Data -> WaitForEdit
Request Edit -> WaitForEdit
WaitForEdit
Ready -> Edit
Error -> Error
@swissmanu
swissmanu / stacktrace.js
Last active June 12, 2019 14:24
Revive a JavaScript stacktrace string with local available source maps.
const fs = require('fs');
const retrace = require('retrace'); // yarn add retrace
const path = require('path');
retrace.resolve = uri => {
// assumes that source maps are in the same directory as this script, but in
// a `maps` folder:
return readFile(path.join(__dirname, 'maps', `${path.basename(uri)}.map`));
};
@swissmanu
swissmanu / SketchSystems.spec
Last active February 28, 2019 10:40
Button
Button
Disabled
enable -> Enabled
Enabled*
disable -> Disabled
Inactive
focus -> Active
mouseEnter -> Hovered
@swissmanu
swissmanu / vpn.sh
Last active January 31, 2019 09:35
A shell script to start/stop Check Point Endpoint VPN/Firewall clients on Mac OS X. No more unreachable machines in your network if no VPN is necessary. Tested with version 80.61
#!/bin/bash
#
# by Manuel Alabor <manuel@alabor.me>
# https://github.com/swissmanu
#
SCRIPT_NAME=`basename $0`
VERSION="0.0.1"
print_help()
function Input<T>({
value,
onChange,
children,
serialize,
deserialize
}: {
value: T;
deserialize: (value: T) => string | null;
serialize: (rawValue: string | null) => T;