Skip to content

Instantly share code, notes, and snippets.

@skinnyjames
skinnyjames / test_cli.cr
Last active March 12, 2024 15:37
test.cr
require "socket"
require "./format"
module Test
Log.setup do |log|
dispatcher = Log::DispatchMode::Direct
backend = Log::IOBackend.new(dispatcher: dispatcher, formatter: Format)
log.bind "*", :trace, backend
end
@skinnyjames
skinnyjames / test.md
Created February 28, 2024 17:55
idea

The premise for the layouting is using sane defaults. Ignoring the propositions of css and html for a while, imagine a whitespace significant template.

{{ template }}
root
  hblock
    text {:content="first"}
    vblock
      text {:content="second"}
 text {:content="third"}
@skinnyjames
skinnyjames / generator.rb
Created May 9, 2023 14:57
start of winole.cr
require "json"
ole = JSON.parse(File.read("./ole.json"))
def payload_to_pointers(payload, str = "")
if payload["Kind"] == "PointerTo"
str << "*"
return payload_to_pointers(payload["Child"], str)
elsif payload["Kind"] == "ApiRef"
@skinnyjames
skinnyjames / server.rb
Created February 15, 2022 16:13
server
require "sinatra/base"
require "json"
module Stuff
class App < Sinatra::Base
s = Mutex.new
@@last_address = nil
@@first_address = nil
@skinnyjames
skinnyjames / chat.cr
Last active February 15, 2022 16:03
chat
require "socket"
module Chat
def self.init(url : String, port : Int32 = 80)
tcp = TCPSocket.new
tcp.reuse_address = true
tcp.reuse_port = true
tcp.connect url, port
tcp << "GET /connect HTTP/1.1\r\nHost: #{url}\r\nUser-Agent: curl/1.0\r\nConnection: Keep-Alive\r\nAccept: */*\r\nContent-Length: 0\r\n\r\n"
me = tcp.local_address.address
module Boxy
def self.create
end
def self.remove(container : AbstractContainer)
end
def self.containers : Array(AbstractContainer)
end
require "../spec_helper"
describe SeleniumWebdriver do
with_browser("http://localhost:8083/selectors.html") do |browser|
describe "Basic selectors" do
it "selects by class" do
link = browser.a(class: "link-destination")
link.text.should eq "Link"
end
@skinnyjames
skinnyjames / point.rb
Last active May 31, 2021 18:01
valueobject.rb
class Point
attr_reader :x, :y
def self.clone_from(point, x: nil, y: nil)
new(x || point.x, y || point.y)
end
def initialize(x=0, y=0)
@x = x
@y = y
@skinnyjames
skinnyjames / index.html
Last active September 6, 2020 12:04
erd.html
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.12.11/paper-full.min.js" integrity="sha512-ehNJ9gpOQJn8EYlA3P1zUtfrh97G/6WNsjfPfpnMxbo6PX6UXHRj8Ny5MCd36w2eTPlvOSVuXLZmY+/VLVhI4A==" crossorigin="anonymous"></script>
</head>
<body>
<div id="erd" style="width: 100vw; height: 100vh">
<canvas id="erd-canvas" style="width: 100vw; height: 100vh"></canvas>
</div>
</body>
@skinnyjames
skinnyjames / 1-sales.dep
Last active September 4, 2020 23:15
deps
-- sales.dep
@import common from 'commmon/deps'
@import billing from 'billing/deps'
@import preferences from 'preferences/deps
!scenario/edit-customer
description: editing a customer
deps:
>api/load-customer
>api/save-customer