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
class Game | |
attr_gtk | |
def current_level_name | |
# used by level editor to figure out which data file to save/load | |
state.levels[state.current_level_index] || :todo | |
end | |
# helper method to move rect within the camera | |
def to_screen_space target |
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
class Probe | |
def queue_story!(predicate: nil, entries:, completion_action: nil, completion_checkpoint:, completion: nil) | |
raise "Either completion_action or completion must be provided." if !completion_action && !completion | |
return if @action == :story | |
return if @current_story_items.length > 0 | |
return if checkpoint_reached?(completion_checkpoint) | |
should_queue = if predicate.is_a? Proc | |
predicate.call | |
elsif predicate.is_a? FalseClass |
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 file sets up the main game loop (no need to modify it) | |
# play game here: https://samples.dragonruby.org/samples/99_genre_lowrez/nokia_3310_snake/index.html | |
require "app/nokia_emulation.rb" | |
class Game | |
attr :args, :nokia_mouse_position | |
def tick | |
# create a new game on frame zero | |
new_game if Kernel.tick_count == 0 |
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
class Game | |
attr_gtk | |
# get solution for hanoi tower | |
# https://youtu.be/rf6uf3jNjbo | |
def solve count, from, to, other | |
solve_recur(count, from, to, other).flatten | |
end | |
# recursive function for getting solution |
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
class Game | |
attr_gtk | |
def tick | |
defaults | |
render | |
input | |
calc | |
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
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}; | |
use bevy::prelude::*; | |
use bevy::window::close_on_esc; | |
const WW: f32 = 1200.0; | |
const WH: f32 = 900.0; | |
const BG_COLOR: (u8, u8, u8) = (25, 20, 43); | |
fn main() { | |
App::new() |
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
# Based on TinyWM by Nick Welch | |
require 'X11' | |
dpy = X11::Display.new | |
root = dpy.screens.first.root | |
# OK, so pure-x11 *really* badly needs built in keysym lookup, | |
# but I don't want to add that without doing it properly, so this |
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
# frozen_string_literal: true | |
# Inspiration: https://brandnewbox.com/notes/2021/03/form-builders-in-ruby/ | |
# | |
# Example: | |
# | |
# f.input :field, options | |
# | |
# possible options: | |
# - as: symbol (:boolean, :data, :float, :radio, :select, :string, :text, :file, :time) |
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
# ActiveJob natively captures constructor arguments in an `@arguments` instance variable | |
# which is also exposed as an `arguments` property on each job instance. | |
# | |
# Calls to `perform_now` and `perform_later` both forward arguments to the constructor. | |
# | |
# For example, all of these invocation styles work. | |
# | |
# result = DoStuffJob.new("foobar").perform # sync | |
# result = DoStuffJob.new.perform("foobar") # sync | |
# result = DoStuffJob.perform_now("foobar") # sync |
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
module Referrable | |
extend ActiveSupport: :Concern | |
included do | |
has_one referral, foreign_key: "referred_user_id", dependent: : destroy has_one referring_user, through: :referral alias_method :referred_by, :referring_user | |
has_many :referrals, foreign_key: "referring_user_id", dependent: :nullify has_many :referred_users, through: referrals | |
validates :referral_code, uniqueness: true, allow_nil: true | |
end | |
end |
NewerOlder