Skip to content

Instantly share code, notes, and snippets.

View 46bit's full-sized avatar
🏳️‍🌈

Miki Mokrysz 46bit

🏳️‍🌈
View GitHub Profile
@46bit
46bit / snake.ino
Created March 30, 2022 20:52
Arduino program to render a basic Snake effect on an Adafruit Matrix Portal attached to a 32x64 LED matrix
#include <Adafruit_SleepyDog.h>
#include <Adafruit_Protomatter.h>
#define HEIGHT 32
#define WIDTH 64
#define LED_COUNT (HEIGHT*WIDTH)
uint8_t rgbPins[] = {7, 8, 9, 10, 11, 12};
uint8_t addrPins[] = {17, 18, 19, 20};
uint8_t clockPin = 14;
export PASSWORD="$1"
export CURL_FLAGS=( -H 'Cookie: popup=1; key=value' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36' -L )
function md5_then_sha512() {
echo -n "$1" | md5sum | tr -d '[:space:]-' | shasum --algorithm 512 - | sed 's/[^a-z0-9]//g' | tr -d '[:space:]'
}
function extract_tn() {
echo -n "$1" | pup 'img[src^="data:"] attr{src}' | cut -c 79- | base64 -d
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
apiVersion: v1
kind: ServiceAccount
metadata:
name: grafana-agent
namespace: ${NAMESPACE}
---
kind: ConfigMap
metadata:
name: grafana-agent
namespace: ${NAMESPACE}
use std::mem;
use rand::prelude::*;
#[derive(Copy, Clone, Debug, Default)]
pub struct Vector {
pub x: f32,
pub y: f32,
}
impl Vector {
import { Vector } from '../../vector';
export interface IEntity2 {
id: string;
player?: Player;
positioning: IPositioning;
lifecycle?: ILifecycle;
behaviour?: IBehaviour;
engineering?: IEngineering;
sidecars?: {[name: string]: IEntity2};
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets: []
scheme: http
timeout: 10s
@46bit
46bit / oh-wow-mixins.ts
Created January 21, 2020 09:24
TypeScript's built-in mixins don't allow the mixin to have a useful constructor. I came across https://github.com/Microsoft/TypeScript/issues/14126#issuecomment-503940323 and wanted to check that it really works. It does!
type ComposableConstructor<T, U> =
[T, U] extends [new (a: infer O1) => infer R1,new (a: infer O2) => infer R2] ? {
new (o: O1 & O2): R1 & R2
} & Pick<T, keyof T> & Pick<U, keyof U> : never
function MixA<T extends new (o: any) => any>(Base: T) {
class MixA extends (Base as new (...a: any[]) => {}) {
a_value: number;
constructor(options: { a_value: number }) {
super(options)
@46bit
46bit / hug-me
Created June 2, 2018 18:51
This script `*huuug*`s. I include this in my shell profile `.zshrc` to print hugs at the top of each new terminal.
#!/usr/bin/env ruby
u_count = 1 + Random.rand(9)
puts "*h" + ("u" * u_count) + "g*"
if ARGV.include? "lovingly" then
puts "I fucking love you <3"
end