This file contains 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
require "json" | |
struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] } | |
source = JSON.dump(struct) | |
tokens = [] | |
index = 0 | |
until source.empty? | |
tokens << |
This file contains 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 | |
input | |
calc | |
render | |
end |
This file contains 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
{ | |
inputs: | |
[params[:authenticity_token], request.x_csrf_token].map do |token| | |
Base64.urlsafe_decode64(token) | |
end.map do |token| | |
xor_byte_strings( | |
token[0...AUTHENTICITY_TOKEN_LENGTH], | |
token[AUTHENTICITY_TOKEN_LENGTH..-1] | |
) | |
end, |
This file contains 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
# https://www.youtube.com/watch?v=S-baJwEjUsk&ab_channel=AmirRajan | |
class Game | |
attr_gtk | |
def tick | |
grid.origin_center! | |
defaults | |
calc | |
render |
This file contains 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 breaks when the characters no longer fit on the line. A smarter version would iterate using word/line boundaries | |
# Sample Usage: | |
# rect = args.layout.rect(row: 3, col: 12, w: 6, h: 7, dx: 0, dy: 0) # OBJECTIVE | |
# text = "OBJECTIVE:\n\nMECHs are threatening\nour CITIZENS:\n+ Bring the CITIZENS home.\n+ Destroy the MECHs." | |
# render_text(args, args.outputs.primitives, rect, text, 1, "/fonts/PixeloidSans.ttf") | |
# | |
def render_text(args, pipeline, rect, text, font_size, font) | |
work = "" | |
len = text.length | |
font_h = args.gtk.calcstringbox(text, font_size, font).y |
This file contains 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
{ | |
"go.useLanguageServer": true, | |
"editor.formatOnSave": true, | |
"window.nativeTabs": true, | |
"editor.glyphMargin": false, | |
"editor.renderLineHighlight": "none", | |
"workbench.editor.tabCloseButton": "left", | |
"workbench.startupEditor": "newUntitledFile", | |
"window.autoDetectColorScheme": true, | |
"window.openFilesInNewWindow": "on", |
This file contains 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
# coding: utf-8 | |
module Women | |
def women | |
{ | |
display_name: '≈≈≈ Women ≈≈≈', | |
checkpoint: :women, | |
stage: [ | |
'Unfortunately for Circle, he was cursed with many, many, sides.', | |
page_66, | |
{ loc: ' x ', type: Triangle }, |
This file contains 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 code as it stands at the end of | |
# "Let's make Tetris with DragonRuby Game Toolkit!" Part 1: | |
# https://www.youtube.com/watch?v=xZMwRSbC4rY | |
$gtk.reset | |
class TetrisGame | |
def initialize args | |
@args = args | |
@next_move = 30 |
This file contains 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 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
https://twitter.com/_mdymkowski/status/1371476003789361153 | |
def tick a | |
B=a.outputs[:r].solids<<[A=0,0,1e2,1e4,F=255,F,F] | |
a.solids<<[0,0,2e3,1e3,0,0,0] | |
a.sprites<<http://960.map{[638,360,w=($i+=3).sin*F*1.5,h=$i.sin*F,:r,A+=3,5,F*w,-F*(w+h),-F*h]}; | |
$i+=1; | |
end |
NewerOlder