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 / caching-https-creds.markdown
Created June 6, 2012 21:42
Fix Username/Password prompting for github repos cloned via https scheme

github recently switched to an https scheme as the default for cloning repos. as a side effect you may suddenly be prompted for a 'Username' and 'Password' when you push where, previously, you were able to do so without typing in credentials. the solution is to cause git to cache https credentials which is easy, since git uses curl under the covers

in your home directory create a file called '.netrc', for example

/Users/ahoward/.netrc

in it put these contents

#! /usr/bin/env ruby
Main {
name 'gist'
description <<-__
command line script for writing and reading to http://gist.github.com/
__
examples <<-__
@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)
@ahoward
ahoward / rpc.rb
Last active January 2, 2023 19:02
clean rpc based javascript helpers for rails' controllers
=begin
ref: https://gist.github.com/ahoward/5752290
web apps nearly always end up needing a plethora of little javascript helper methods: you know, auto-complete forms, populating defaults, validations, etc. these aren't API calls properly, just little tidbits of functionality needed to make the views work.
there is always a question of which controller to hang these methods off of. do you make a global helper controller for all this stuff? do you hang them off the controller in question? how to do share the backend of javascript helper methods across controllers?
step one
@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.
<!--
doing a large chunked upload of content using html5's file input feature is tricky.
this simple example should help you out.
-->
<br>
<br>
@ahoward
ahoward / net-http-debug.rb
Created December 10, 2010 20:06
a simple way to debug tons of libs that use ruby's net/http
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)
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 / polluted.rb
Created November 8, 2012 16:15
ruby libs have *got* to stop doing this...
libs = ARGV.size == 0 ? all_gems : ARGV
list =
libs.
forkify(16){|lib| puts "#{ lib }..."; [lib, polluted_by(lib)]}.
sort_by{|pair| pair.last}
list.each do |lib, polluted|
puts "polluted_by('#{ lib }') #=> #{ polluted }"