Skip to content

Instantly share code, notes, and snippets.

View bil-bas's full-sized avatar

Bil Bas bil-bas

View GitHub Profile
@bil-bas
bil-bas / keybase.md
Last active May 31, 2021 14:53
keybase.md

Keybase proof

I hereby claim:

  • I am bil-bas on github.
  • I am bilbas (https://keybase.io/bilbas) on keybase.
  • I have a public key ASDBnuzkXv-AF1XWz46fwPGADqxjcqc0ktfZCFWUTMhdcQo

To claim this, I am signing this object:

@bil-bas
bil-bas / laser.md
Last active October 12, 2017 21:15
LAMM laser usage

Load into InkScape

  • Start InkScape
  • Load .SVG file
  • Ensure all objects are converted to paths and check scales using mm sizes.
  • Export as .DXF

Download to Laser

@bil-bas
bil-bas / logger.gd
Last active April 23, 2021 02:39
Simple logger for Godot Game Engine (godotgameengine.org)
# GodotLogger by Spooner
# ======================
#
# logger.gd is a simple logging system. It allows for more formatted logging,
# logging levels and logging to a file.
#
# Installation
# ------------
#
# Place this file somewhere (for example, 'res://root/logger.gd')
@bil-bas
bil-bas / gist:6107183
Last active May 6, 2019 01:51
Ruby quicksort
module Enumerable
def quicksort()
if size <= 1
self
else
pivot = shift
lower, greater = partition {|x| x < pivot }.map(&:quicksort)
lower.push(pivot).concat(greater)
end
end
@bil-bas
bil-bas / gist:5939750
Last active December 19, 2015 10:19 — forked from anonymous/gist:5939682
puts 'What is the name and path of the file?'
filename = gets.chomp
text = File.read(filename)
freqs = text.scan(/[a-zA-Z]+/).each.with_object(Hash.new(0)) { |word, freqs| freqs[word] += 1 }
freqs = freqs.sort_by {|x,y| -y }
freqs.each {|word, freq| puts "#{word} #{freq}" }
module Collatz
class << self
attr_reader :lengths
def length_recursive(current, counter=0)
counter += 1
if current == 1
counter
elsif @lengths.key? current
@lengths[current] + counter # Take advantage of already working out the length from this number.
@bil-bas
bil-bas / map_find.rb
Last active December 17, 2015 01:58
module Enumerable
def map_find(default=nil)
return enum_for(:map_find, default) unless block_given?
each do |e|
mapped = yield e
return mapped if mapped
end
default
def __getattr__(self, name):
# _children is a list of strings referring to properties in the wrapper object.
for child in self._children:
child = getattr(self, child)
if hasattr(child, name):
return getattr(child, name)
return AttributeError("No attribute '%s' in any children of %s" % (name, self))
@bil-bas
bil-bas / foo_spec.rb
Last active December 15, 2015 21:29 — forked from arwagner/gist:5289895
def foo1 obj
obj.bar(1)
obj.bar(2)
end
def foo2 obj
obj.bar(2)
end
describe "foo1" do
@bil-bas
bil-bas / ruby_array_insert_every.rb
Last active December 14, 2015 14:58 — forked from pmarreck/ruby_array_insert_every.rb
Yay for ugly, inefficient one-liners!
# Using insertion
class Array
# Insert into the array.
def insert_every!(skip, str)
(skip...size).step(skip).with_index {|n, i| insert(n + i, str) }
self
end
# Create a new array and insert into it.
def insert_every(skip, str)