Skip to content

Instantly share code, notes, and snippets.

View mrryanjohnston's full-sized avatar
😎
Set your status

Ryan Johnston mrryanjohnston

😎
Set your status
View GitHub Profile
@mrryanjohnston
mrryanjohnston / Makefile
Last active February 19, 2021 05:27
ezpzPubSub
all: publish resubscribe server subscribe unsubscribe
publish:
gcc publish.c -lrt -o publish
resubscribe:
gcc resubscribe.c -lrt -o resubscribe
server:
gcc server.c -lpthread -lrt -o server
subscribe:
gcc subscribe.c -lrt -o subscribe
@mrryanjohnston
mrryanjohnston / Makefile
Created February 13, 2021 05:11
Learning C: pthread and mqueue
all:
gcc main.c -lpthread -lrt
body {
display: flex;
height: 100%;
margin: 0;
}
nav {
background-color: #aaa;
flex: 25%;
height: 100%;
zethus begins casting walk (1 seconds)
ryjo begins casting eat (5 seconds)
zethus walks forward. (cooldown 1 seconds)
zethus moves from (0, 0) to (0, 1)
zethus cooled down 1 seconds after performing walk and will now decide what to do next...
zethus begins casting breath (1 seconds)
zethus breaths. (cooldown 1 seconds)
zethus's hp is currently 95/100
zethus's hp goes up by 3!
zethus cooled down 1 seconds after performing breath and will now decide what to do next...
Character zethus begins casting walk (1 seconds)
Character zach begins casting breath (1 seconds)
Character ryjo begins casting breath (1 seconds)
Character ryjo breaths. (cooldown 1 seconds)
Character ryjo's hp is currently 85/100
Character ryjo's hp goes up by 3!
Character zach breaths. (cooldown 1 seconds)
Character zach's hp is currently 90/100
Character zach's hp goes up by 3!
Character zethus walks forward. (cooldown 1 seconds)
Character zethus begins casting breath (1 seconds)
Character zach begins casting breath (1 seconds)
Character ryjo begins casting breath (1 seconds)
Character ryjo breaths. (cooldown 1 seconds)
Character ryjo's hp is currently 80/100
Character ryjo's hp goes up by 3!
Character zach breaths. (cooldown 1 seconds)
Character zach's hp is currently 90/100
Character zach's hp goes up by 3!
Character zethus breaths. (cooldown 1 seconds)
Character ryjo begins casting breath (1 seconds)
Character ryjo breaths. (cooldown 1 seconds)
Character ryjo's hp is currently 80/100
Character ryjo's hp goes up by 3!
Character ryjo cooled down 1 seconds after performing breath and will now decide what to do next...
Character ryjo begins casting breath (1 seconds)
Character ryjo breaths. (cooldown 1 seconds)
Character ryjo's hp is currently 83/100
Character ryjo's hp goes up by 3!
Character ryjo cooled down 1 seconds after performing breath and will now decide what to do next...
@mrryanjohnston
mrryanjohnston / Rakefile
Last active September 10, 2020 17:41
ruby c extension
require "bundler/gem_tasks"
require "rake/testtask"
require "rake/extensiontask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end
@mrryanjohnston
mrryanjohnston / index.rb
Last active September 9, 2020 17:11
CLIPS via Ruby using FFI
module Clips
extend FFI::Library
ffi_lib 'clips/libclips.so'
attach_function :create_environment, :CreateEnvironment, [], :pointer
attach_function :reroute_stdin, :RerouteStdin, [:pointer, :int, :pointer], :pointer
attach_function :command_loop, :CommandLoop, [:pointer], :void
end
the_env = Clips.create_environment
Clips.reroute_stdin(the_env, 0, FFI::MemoryPointer.new(:pointer))
require 'durable'
Durable.ruleset :circle do
when_all(
c.point = (+m.x) & (+m.y),
c.circle = m.radius_squared == ( point.x * point.x ) + ( point.y * point.y )
) do
puts "point (#{point.x}, #{point.y}) " \
"is on the edge of circle #{circle.name}"
end