Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am awfulcooking on github.
  • I am mooff (https://keybase.io/mooff) on keybase.
  • I have a public key whose fingerprint is 5725 20B6 8109 0F46 C251 BF84 8B79 3879 4908 77EE

To claim this, I am signing this object:

require 'pty'
module BackticksWithPty
def `(cmd)
output = ""
begin
PTY.spawn(cmd) do |stdout, stdin, pid|
for line in stdout
output << line
end
@awfulcooking
awfulcooking / limiter.rb
Created April 29, 2023 22:05
Example of overriding #<< to implement rate limiting (with iirc gem)
module Limiter
def <<(line)
if parse(line).verb == :privmsg
limit_outgoing_msgs!
end
super
end
def limit_outgoing_msgs!
@awfulcooking
awfulcooking / framestep.rb
Created July 4, 2022 13:34
Frame stepping for DragonRuby
# Frame stepping for DragonRuby - MIT License - (c) mooff
#
# 1. Copy to your_game/lib/framestep.rb (and require it)
# 2. Add "return if FrameStep.tick" to your tick method
# 3. Press Ctrl-/ in-game to activate, then / to advance
#
# Version 1.1
# - Keep GTK tick count in step when frozen
module FrameStep
SCREENSHOT_PATH = 'freeze-frame.png'