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 / README.md
Created June 14, 2018 21:42
Change Maker

Change Maker

Description

Makes change for configured currencies.

Usage

# Initialize your changemaker

String#my_to_i

Description

Custom implementation of String's to_i method

Usage

require_relative 'string'
@mrryanjohnston
mrryanjohnston / components.my-component.js
Last active February 8, 2019 08:25
Delete items with Animation
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
delete () {
this.delete();
}
}
});
@mrryanjohnston
mrryanjohnston / components.proxy-list.js
Last active February 8, 2019 17:53
Proxy Array with Record Fadeout
import Ember from 'ember';
import { copy } from '@ember/object/internals';
import { later } from '@ember/runloop';
import { set } from '@ember/object';
export default Ember.Component.extend({
didReceiveAttrs () {
this._super(...arguments);
if (!this.recordsProxy) {
this.recordsProxy = copy(this.records);
@mrryanjohnston
mrryanjohnston / whatismyip.sh
Last active May 18, 2019 15:12
Script to return your public IP from duckduckgo
#!/bin/bash
curl -fs "https://api.duckduckgo.com/?q=ip&format=json" | jq -r '.Answer' | awk '{print $5}'
@mrryanjohnston
mrryanjohnston / components.hidden-attribute.js
Last active July 31, 2019 14:06
attributeBindings hidden
import Ember from 'ember';
export default Ember.Component.extend({
attributeBindings: ['hidden'],
hidden: true
});
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
@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))
@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
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...