crystal wasm.cr
php -S localhost:3000
- open your browser
- open dev tool js console
crystal.add(1, 2)
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
alias CustomID = String | |
module Avram::Migrator::Columns::PrimaryKeys | |
class CustomIDPrimaryKey < Avram::Migrator::Columns::PrimaryKeys::Base | |
def initialize(@name) | |
end | |
def column_type : String | |
"character varying(18)" | |
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
abstract class StoragePageLayout | |
include Lucky::HTMLBuilder | |
getter view = IO::Memory.new | |
abstract def content | |
def render | |
html_doctype | |
html do |
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
# in src/app_server.cr | |
def middleware : Array(HTTP::Handler) | |
[ | |
Lucky::ForceSSLHandler.new, | |
Lucky::HttpMethodOverrideHandler.new, | |
Lucky::LogHandler.new, | |
Lucky::ErrorHandler.new(action: Errors::Show), | |
CORSHandler.new, | |
Lucky::RemoteIpHandler.new, | |
Cable::Handler.new(ApplicationCable::Connection), |
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 'httparty' | |
require 'nokogiri' | |
class Scraper | |
attr_accessor :parse_page | |
def initialize | |
doc = HTTParty.get("http://store.nike.com/us/en_us/pw/mens-nikeid-lifestyle-shoes/1k9Z7puZoneZoi3") | |
@parse_page ||= Nokogiri::HTML(doc) | |
end | |
def get_names | |
names = item_container.css(".product-name").css("p").children.map { |name| name.text }.compact |
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
<!DOCTYPE html> | |
<html> | |
<head><title>Paper Rock Scissor</title></head> | |
<body> | |
<h2>Play This Game!</h2> | |
<span id="playerScore">You: <strong>0</strong></span> | |
<span id="computerScore">It: <strong>0</strong></span> | |
<div> | |
<button value="paper">🧻</button> | |
<button value="rock">🤘</button> |
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 Basket | |
attr_accessor :items | |
def initialize | |
self.items = [] | |
end | |
def total | |
self.items.sum(0.0) { |item| item[:price] } | |
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
We develop locally on MacOS. Due to some issues with cross compilation, we build the crystal binary on docker locally, | |
then zip that up and ship that along with the docker stuff to elasticbeanstalk. |
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
// can't use SomeLib here unless I require it in this file | |
// even if I run my program from main.js | |
class A extends SomeLib { | |
} | |
module.exports = A |
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
def initialize | |
@tile_x = 9 | |
@tile_y = 7 | |
@fine_x = 0 | |
@fine_y = 0 | |
end | |
def draw(renderer) | |
renderer.copy(sprite, dstrect: SDL::Rect[ | |
@tile_x * 64 + @fine_x, |
NewerOlder