Skip to content

Instantly share code, notes, and snippets.

--For Euler Problem 17
onesNames = ["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"]
teenNames = ["Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"]
tensNames = ["", "","Twenty","Thirty","Forty","Fifty","Sisty","Seventy","Eighty","Ninety"]
numberToName x = (thousands x) ++ (hundreds x) ++ (addAnd x) ++ (tens x) ++ (ones x)
thousands x =
if digit > 0
then (onesNames !! digit) ++ "Thousand"
first (x,_,_) = x
second (_,x,_) = x
third (_,_,x) = x
triangle =
[
[75],
[95,64],
[17,47,82],
@quietsamurai98
quietsamurai98 / html5_template.html
Created March 28, 2017 19:40 — forked from nathansmith/html5_template.html
Simple HTML5 Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge, chrome=1" />
<title>untitled</title>
<link rel="stylesheet" href="" />
</head>
<body>
@quietsamurai98
quietsamurai98 / index.html
Created April 4, 2017 17:56
Blank html file
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TITLE</title>
<body>
<!-- HTML ELEMENTS HERE -->
<script>
@quietsamurai98
quietsamurai98 / main.rb
Created September 23, 2020 04:58
DragonRuby Ray Marching
# Hold b to show squares (circles stay hidden)
# Press space to reset
# @param [GTK::Args] args
def tick(args)
args.outputs.lines << args.state.lines if args.state.lines
init(args) unless args.state.initialized && !args.inputs.keyboard.key_down.space
rerender(args) unless args.state.render_ready && !args.inputs.keyboard.key_down.space && !args.inputs.keyboard.key_down.b && !args.inputs.keyboard.key_up.b
pos = args.inputs.mouse.position
pos ||= [640, 360]
@quietsamurai98
quietsamurai98 / main.rb
Created September 23, 2020 05:09
DragonRuby Boids
# l to toggle lines
# space to reset
# left click to attract
# right click to repel
$TIME_FACTOR = 1.0
$X_WRAP = true
$Y_WRAP = true
# @param [GTK::Args] args
def tick(args)
@quietsamurai98
quietsamurai98 / main.rb
Created September 30, 2020 23:41
3D Wireframe
def tick(args)
unless args.state.model
args.state.model = Object3D.new('data/lowpoly_teapot.off')
args.state.model.fast_3x3_transform!(rotate3D(0.2, 0.0, 0.0))
args.state.spin_mtx = rotate3D(0.00, 0.00, 0.01)
args.outputs.static_lines << args.state.model.edges
end
args.state.model.fast_3x3_transform!(args.state.spin_mtx)
end
@quietsamurai98
quietsamurai98 / draw_tri.rb
Created October 3, 2020 05:31
Draws any triangle using only two sprites
# @return [Array<Hash>]
# @param [Float] x1
# @param [Float] y1
# @param [Float] x2
# @param [Float] y2
# @param [Float] x3
# @param [Float] y3
# @param [Float] r
# @param [Float] g
# @param [Float] b
@quietsamurai98
quietsamurai98 / menu.rb
Created November 6, 2020 17:01
Right click drop down menu system
def tick args
args.state.menu ||= [
{
label: "Place black square",
action: lambda {args.outputs.static_solids << [args.state.rmb_click.x-10, args.state.rmb_click.y-10, 20, 20, 0, 0, 0, 255]}
},
{
label: "Place red square",
action: lambda {args.outputs.static_solids << [args.state.rmb_click.x-10, args.state.rmb_click.y-10, 20, 20, 255, 0, 0, 255]}
},