Skip to content

Instantly share code, notes, and snippets.

View AndyObtiva's full-sized avatar

Andy Maleh AndyObtiva

View GitHub Profile
@AndyObtiva
AndyObtiva / widget_table_data_all_at_once.rb
Created March 18, 2024 01:05
Glimmer DSL for SWT Example loading a lot of table rows from an API all at once relying on data-binding
require 'glimmer-dsl-swt'
require 'net/http'
require 'json'
class Spell
attr_accessor :id, :name, :incantation, :effect, :can_be_verbal, :type, :light, :creator
def initialize(spell_hash)
spell_hash.each do |key, value|
self.send("#{key.underscore}=", value)
@AndyObtiva
AndyObtiva / widget_table_data.rb
Created March 18, 2024 01:05
Glimmer DSL for SWT Example loading table rows from an API one by one relying on data-binding
require 'glimmer-dsl-swt'
require 'net/http'
require 'json'
class Spell
ATTRIBUTES = ['id', 'name', 'incantation', 'effect', 'can_be_verbal', 'type', 'light', 'creator']
attr_accessor *ATTRIBUTES
def initialize(spell_hash)
spell_hash.each do |key, value|
@AndyObtiva
AndyObtiva / widget_content_scrolled.rb
Created March 18, 2024 01:04
Glimmer DSL for SWT Example loading a lot of labels from an API in a scrolled composite (labels could be any widget you want though)
require 'glimmer-dsl-swt'
require 'net/http'
require 'json'
class WidgetContentApp
include Glimmer::UI::Application
after_body do
Thread.new do
spells_json = Net::HTTP.get('wizard-world-api.herokuapp.com', '/Spells')
@AndyObtiva
AndyObtiva / widget_content.rb
Created March 18, 2024 01:03
Glimmer DSL for SWT Example loading labels from an API one by one (labels could be any widget you want though)
require 'glimmer-dsl-swt'
require 'net/http'
require 'json'
class WidgetContentApp
include Glimmer::UI::Application
after_body do
Thread.new do
spells_json = Net::HTTP.get('wizard-world-api.herokuapp.com', '/Spells')
@AndyObtiva
AndyObtiva / glimmer-dsl-web-readme.md
Last active February 9, 2024 19:14
Glimmer DSL for Web (Ruby in the Browser Web Frontend Library)
@AndyObtiva
AndyObtiva / glimmer-libui-cc-graphs_and_charts-basic-bar-chart.rb
Created January 2, 2024 01:41
Basic Bar Chart Example from Graphs and Charts Library (Custom Controls for Glimmer DSL for Libui)
# Source: https://github.com/AndyObtiva/glimmer-libui-cc-graphs_and_charts
require 'glimmer-dsl-libui'
require 'glimmer/view/bar_chart'
class BasicBarChart
include Glimmer::LibUI::Application
body {
window('Basic Bar Chart', 900, 300) { |main_window|
@bar_chart = bar_chart(
@AndyObtiva
AndyObtiva / glimmer-libui-cc-graphs_and_charts-basic-line-graph.rb
Created December 16, 2023 17:50
Basic Line Graph Example from Graphs and Charts Library (Custom Controls for Glimmer DSL for Libui)
# Source: https://github.com/AndyObtiva/glimmer-libui-cc-graphs_and_charts
require 'glimmer-dsl-libui'
require 'glimmer/view/line_graph'
class BasicLineGraph
include Glimmer::LibUI::Application
before_body do
@start_time = Time.now
end
@AndyObtiva
AndyObtiva / glimmer-dsl-libui-basic-custom-shape.rb
Created October 27, 2023 19:02
Glimmer DSL for LibUI - Basic Custom Shape - Example
# Source: https://github.com/AndyObtiva/glimmer-dsl-libui/blob/master/docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md#basic-custom-shape
require 'glimmer-dsl-libui'
# This is the class-based custom shape version of basic_composite_shape
# class-based custom shape using Glimmer::LibUI::CustomShape mixin, which automatically
# augments the Glimmer GUI DSL with the underscored version of the class name: `cube`
# while accepting hash options matching the options declared on the class.
# (e.g. `cube(location_x: 50, location_y: 100)` )
class Cube
@AndyObtiva
AndyObtiva / glimmer-snake-model-apple.rb
Created October 22, 2023 20:36
Glimmer Snake - Model - Apple
# Source: https://github.com/AndyObtiva/glimmer_snake/blob/master/app/glimmer_snake/model/apple.rb
class GlimmerSnake
module Model
class Apple
attr_reader :game
attr_accessor :row, :column
def initialize(game)
@game = game
end
@AndyObtiva
AndyObtiva / glimmer-snake-model-vertebra.rb
Created October 22, 2023 20:35
Glimmer Snake - Model - Vertebra
# Source: https://github.com/AndyObtiva/glimmer_snake/blob/master/app/glimmer_snake/model/vertebra.rb
class GlimmerSnake
module Model
class Vertebra
ORIENTATIONS = %i[north east south west]
# orientation is needed for snake occuppied cells (but not apple cells)
attr_reader :snake
attr_accessor :row, :column, :orientation
def initialize(snake: , row: , column: , orientation: )