Skip to content

Instantly share code, notes, and snippets.

View graysonarts's full-sized avatar
🍑
language hunting

Grayson graysonarts

🍑
language hunting
View GitHub Profile
@graysonarts
graysonarts / string_value_type_macro.rs
Last active November 21, 2023 18:21
Helpful Macros for common rust things I run into
macro_rules! string_value_type {
($TypeName:ident $(~$derive_name:ident)*) => {
#[derive($($derive_name),*)]
pub struct $TypeName(String);
impl From<&str> for $TypeName {
fn from(value: &str) -> Self {
Self(value.to_owned())
}
}
@graysonarts
graysonarts / otel.yaml
Created March 24, 2023 14:19
Adding an attribute in the otel pipeline
processors:
attributes/env:
actions:
- key: deployment.environment
value: production
action: insert
service:
pipelines:
traces:
@graysonarts
graysonarts / observable.h
Created September 30, 2015 14:44
A simple observable implemented using std::weak_ptr
#include <set>
#include <memory>
#include <vector>
template <typename T>
class IObservable;
template <typename T>
class IObserver
{
// Fails to compile in vs
using ErrorPair = struct ErrorPairStruct
{
int id;
std::string message;
}
using ExceptionErrorMap = std::map <ExceptionType, ErrorPair>;
const ExceptionErrorMap errorsMap {
{ NotFoundException, { IDS_NOT_FOUND, Lookup(IDS_NOT_FOUND) } },
...
@graysonarts
graysonarts / merge.py
Created February 9, 2015 21:57
merge csv files into a single csv file with a column for the filename
import sys
import glob
import os.path
import os
import argparse
import csv
def usage(args):
parser = argparse.ArgumentParser()
parser.add_argument("--delim", "-d", default="|")
@graysonarts
graysonarts / gist:ba0f19d11cdb5e0f86c3
Created December 30, 2014 21:58
In progress parachute system
#include "Bounce2.h"
#include "Servo.h"
#define SERVO_PIN 9
#define READY_PIN 13
#define ARM_PIN 12
#define SERVO_READY 0
#define SERVO_DEPLOY 180
@graysonarts
graysonarts / sample.led
Created December 15, 2014 18:54
small example of the intermediate langauge that I'm considering building for my arduino led vm
%version 1
%numleds 5
%require imu
%green RGB(0,128,0)
%red RGB(128,0,0)
states {
state foo {
skipif imu.accel.x > 1
setall %green
#!/usr/bin/env zsh
BASE=${0%/*}
SQLITE=/usr/bin/sqlite3
echo "Extracting from OmniFocus"
$BASE/of-store --debug --out=$BASE/finished.db
$BASE/kanban-fetch --debug --out=$BASE/inprogress.db
echo "Exporting to tasks.csv"
@graysonarts
graysonarts / of_to_csv
Created October 26, 2014 02:13
ZSH script to use of-store to export CSV files for loading into Tableau
#!/usr/bin/env zsh
BASE=${0%/*}
SQLITE=/usr/bin/sqlite3
echo "Extracting from OmniFocus"
$BASE/of-store --debug --out=$BASE/finished.db
echo "Exporting to tasks.csv"
$SQLITE $BASE/finished.db <<!
@graysonarts
graysonarts / collab.pde
Last active August 29, 2015 14:07 — forked from anonymous/collab.pde
Example Code for metaglitch's processing collaboration: http://metaglitch.com/post/99004417350/call-for-processing-collab-submissions
// Code by @MetaGlitch
float fps = 16.666;
int inFrames = 15;
int outFrames = 15;
int otherFrames = 60;
int numFrames = inFrames + otherFrames + outFrames;
float t1 = inFrames * 1.0/numFrames;