This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using group-by | |
# no extra step definition is required | |
PiecePipe::Pipeline.new. | |
source([{region: region}]). | |
step(FetchPowerPlantsByRegion). | |
group_by(:region). | |
to_enum | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CURRENT | |
has_behavior animated: {:frame_update_time => 900} | |
has_behavior collidable: {shape: :polygon, cw_local_points: [[4,4],[44,4],[44,44],[4,44]]} | |
has_behavior projectile: {speed: 0.01, direction: vec2(1,0)} | |
has_behavior :reversable_direction | |
has_behavior increasing_speed: { accel: 0.001 } | |
has_behavior drops: { fall_amount: 25} | |
has_behavior shooter: {shoots: :alien_missile, direction: vec2(0,-1)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# src/actors/alien.rb | |
define_actor :alien do | |
has_attributes action: :march, view: :graphical_actor_view | |
has_behaviors do | |
animated frame_update_time: 900 | |
collidable shape: :polygon, cw_local_points: [[4,4],[44,4],[44,44],[4,44]] | |
projectile speed: 0.01, direction: vec2(1,0) | |
reversable_direction | |
increasing_speed accel: 0.001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if !File.exist?(bs_file) or headers.any? { |h| File.mtime(h) > File.mtime(bs_file) } | |
includes = headers.map { |p| "-I" + File.dirname(p) }.uniq.join(' ') | |
# ! gen_bridge_metadata DOES NOT support --no-64-bit | |
#sh "/usr/bin/gen_bridge_metadata --format complete --no-64-bit --cflags \"-I. #{includes}\" #{headers.join(' ')} -o \"#{bs_file}\"" | |
sh "/usr/bin/gen_bridge_metadata --format complete --cflags \"-I. #{includes}\" #{headers.join(' ')} -o \"#{bs_file}\"" | |
end | |
bs_files << bs_file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.using = (namespaces..., block) -> | |
context = {} | |
for ns in namespaces | |
for k, v of ns | |
if context[k]? | |
throw "Unable to import namespace: symbol [#{k}] already imported!" | |
context[k] = v | |
block(context) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the primary element in an AABBTree. | |
# It acts as both containing elements and leaf elements. Leaves have an @object, | |
# containers have @a and @b nodes. All leaf nodes have a cached list of | |
# collisions that contain references to other nodes in the tree. | |
class AABBNode | |
include AABBNodeDebugHelpers | |
attr_accessor :bb, :a, :b, :parent, :object, :cached_collisions | |
def initialize(parent, object, bb) | |
@parent = parent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace "MyWidget.Expander", (exports) -> | |
template = JST["thingers/widget"] | |
exports.expand = (model) -> | |
template({ | |
'$.name': "#{model.get('first_name')} #{model.get('last_name')}" | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "\nGARBAGE COLLECTION" | |
# Not even close to exact, but gives a rough idea of what's being collected | |
old_objects = ObjectSpace.count_objects.dup | |
ObjectSpace.garbage_collect | |
new_objects = ObjectSpace.count_objects | |
old_objects.each do |k,v| | |
diff = v - new_objects[k] | |
puts "#{k} #{diff} diff" if diff != 0 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pry(main)> cd Document.first/@attributes | |
pry(#<Hash>):2> keys.sort | |
=> ["actual_finish_at", | |
"actual_start_at", | |
"adjusted_planned_finish_at", | |
"adjusted_planned_start_at", ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HELLO? | |
class Foo | |
include Mongoid::Document | |
field :stats, :type => Hash | |
end |