Skip to content

Instantly share code, notes, and snippets.

View rickhull's full-sized avatar

Rick Hull rickhull

View GitHub Profile
begin
require 'flay_task'
FlayTask.new do |t|
t.dirs = ['lib']
t.verbose = true
end
rescue LoadError
warn 'flay_task unavailable'
end
module CompSci
# has a value and an array of children; allows child gaps
class Node
attr_accessor :value
attr_reader :children
def initialize(value, children: [])
@value = value
if children.is_a?(Integer)
@children = Array.new(children)
group "cpu" do
File.readlines("/proc/stat").grep(/^cpu/).each do |l|
name, user, nice, csystem, idle, iowait, irq, softirq = l.split(/\s+/).map(&:to_i)
total = busy + idle
counter "busy", value: busy, mute: true
counter "total", value: total, mute: true
gauge "usage" do
value("busy") / value("total") * 100
end
vagrant@contrib-jessie:~/git/mruby-tools (master)$ ./util.rb hello_world.rb goodbye_world.rb -o myprog
compiling...
created binary executable: myprog
vagrant@contrib-jessie:~/git/mruby-tools (master)$ file myprog
myprog: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=bb9af8c7a3aaedcb51da5b6aca8e0ba68d1f27f2, not stripped
vagrant@contrib-jessie:~/git/mruby-tools (master)$ ./myprog
RANDMAX = 1_000
NUMBERWANG = 1_000
NUMS = (0..(RANDMAX - 1)).to_a.shuffle
def number(num)
if num % NUMBERWANG == 0
NUMS.shift
NUMS.push rand RANDMAX
end
NUMS[num % RANDMAX]
module Foo
def print(msg)
p [msg, self]
end
end
class Bar
include Foo
def initialize
vagrant@contrib-jessie:~/mruby/sleep_world$ cat build_config.rb
puts "BUILD CONFIG: #{__FILE__}"
MRuby::Build.new do |conf|
toolchain :gcc
conf.gem git: 'https://github.com/matsumotory/mruby-sleep'
end
@rickhull
rickhull / test.rs
Last active November 9, 2017 01:21 — forked from Dasms/test.rs
prices = {
"tennis ball" => 4.99,
"beach ball" => 12.99,
"giraffe" => 93.86,
}
print "What is your name? "
name = gets.chomp
require 'minitest/autorun'
def rock(other)
case other
when :rock then 0
when :paper then :paper
when :scissors then :rock
else
raise "unknown value: #{other}"
end
vagrant@contrib-jessie:~/git/mruby (master)$ echo $MRUBY_CONFIG
/home/vagrant/mruby/build_config.rb
vagrant@contrib-jessie:~/git/mruby (master)$ cat $MRUBY_CONFIG
puts "\n" * 20
puts "HELLO WORLD"
puts "\n" * 5
MRuby::Build.new do |conf|
toolchain :gcc