Skip to content

Instantly share code, notes, and snippets.

View ahoward's full-sized avatar
💭
probably outside if i'm not hacking.

ara.t.howard ahoward

💭
probably outside if i'm not hacking.
View GitHub Profile
@ahoward
ahoward / a.py
Last active November 8, 2023 18:14
# current code. BAD.
import uuid
from uuid import UUID
from typing import cast
from dataclasses import dataclass
@dataclass
class DC:
uuid: UUID
# REF: https://platform.openai.com/docs/guides/rate-limits/overview
class RateLimiter < ApplicationRecord
include Tracing
USAGE = -> do
# a multi-process, mutli-thread, multi-machine (assuming shared db), safe rate limiter
# instance level interface
rl = RateLimiter.for(:some, :api, maximum: 1, window: 3)
s = """Gur Mra bs Clguba, ol Gvz Crgref
Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Syng vf orggre guna arfgrq.
Fcnefr vf orggre guna qrafr.
Ernqnovyvgl pbhagf.
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
Nygubhtu cenpgvpnyvgl orngf chevgl.
@ahoward
ahoward / a.sh
Created April 6, 2020 18:27
fixes "# mesg: ttyname failed: Inappropriate ioctl for device" warnings during docker build
# fixes "# mesg: ttyname failed: Inappropriate ioctl for device" warnings when building docker
#
echo '#! /bin/sh' > /usr/bin/mesg
chmod 755 /usr/bin/mesg
# all this does is replace the 'mesg' command with a no-op that always succeeds.
# do this *early* in your Dockerfile somewhere.
# from a security persprective this is also fine because it relates to multi-user unix systems,
# not single user/contrained docker images.
@ahoward
ahoward / web-servers.md
Created September 25, 2019 16:27 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@ahoward
ahoward / web-servers.md
Created September 25, 2019 16:27 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@ahoward
ahoward / a.rb
Created January 31, 2019 16:36
rails just *cannot* run in threads. doing even simple things will bork it in strange and magical ways
class A
attr_accessor :dsl
attr_accessor :state
def initialize
@state = []
@dsl = self.class.dsl
sleep(rand)
@ahoward
ahoward / example.rb
Created August 16, 2018 18:19
even though i author'd main.rb - which is a really complete cli tool, i 've been yearning for something simpler for writing small cli tools. eg. in a rails ./scripts/ directory...
#! /usr/bin/env ruby
require_relative '../lib/script.rb'
script {
help '
HELP!
'
run {
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
//
import Vue from 'vue'
import App from './App'
import router from './router'
import firebase from 'firebase'
Vue.config.productionTip = false
#
require 'open-uri'
require 'json'
#
module TargetSmartStateDictionary
def TargetSmartStateDictionary.url
@url ||= (
'https://gist.githubusercontent.com/mshafrir/2646763/raw/8b0dbb93521f5d6889502305335104218454c2bf/states_hash.json'
)