Skip to content

Instantly share code, notes, and snippets.

@faustinoaq
faustinoaq / stream.cr
Last active February 1, 2019 13:16
Try kemal/crystal stream
require "kemal"
get "/stream" do |env|
env.response.print "START"
env.response.flush
sleep 3
env.response.print "MIDDLE"
env.response.flush
sleep 5
env.response.print "END"
@faustinoaq
faustinoaq / reload.md
Last active December 6, 2017 03:15
Guide to reload client on public file changes.

Amber Reload

Reloading public files on Amber.

Requisites

You need Crystal and Amber::CMD installed

Steps

@faustinoaq
faustinoaq / debug.md
Last active October 29, 2019 16:58
Guide to debug amber application on VSCode.
@faustinoaq
faustinoaq / icosahedron.xml
Created July 28, 2017 00:57
Icosahedron data
<?xml version="1.0"?>
<m> <p x="0.550563524346" y="0.758024984088" z="-0.349682612032"/>
<p x="0.62319582135" y="0.436643142534" z="0.648821804759"/>
<p x="0.975676690271" y="-0.177816333299" z="-0.12820432003"/>
<p x="-0.32007250628" y="0.0780544757795" z="0.944172171553"/>
<p x="0.437594031513" y="-0.598061218782" z="0.671441912732"/>
<p x="0.32007250628" y="-0.0780544757795" z="-0.944172171553"/>
<p x="0.250253520018" y="-0.916161840828" z="-0.313082508502"/>
<p x="-0.437594031513" y="0.598061218782" z="-0.671441912732"/>
<p x="-0.62319582135" y="-0.436643142534" z="-0.648821804759"/>
@faustinoaq
faustinoaq / tictactoe.cr
Last active August 6, 2017 19:40
Tic Tac Toe implemented using Crystal.
# Tic Tac Toe on Crystal based on C implementation https://gist.github.com/MatthewSteel/3158579
def grid_char(i)
case i
when -1
'X'
when 0
' '
when 1
'O'
@faustinoaq
faustinoaq / huffman.rb.cr
Last active August 7, 2017 16:03
Huffman generator example for Ruby and Crystal.
# Huffman Tree generator for Ruby and Crystal
# @faustinoaq
# Jan, 2017
class Element
def initialize(sym = '\0', fr = 1.0)
@ch = nil
if sym != '\0'
@ch = [Element.new]
@faustinoaq
faustinoaq / .vimrc
Last active September 25, 2017 22:47
Minimal Vim configuration
set number
set nowrap
set expandtab
set shiftwidth=2
set tabstop=2
set mouse=a
call plug#begin('~/.vim/plugged')
Plug 'kien/ctrlp.vim'
@faustinoaq
faustinoaq / mini.css
Created September 25, 2017 23:13
Minimal CSS for a website
body {
font-family: Arial, Helvetica, sans-serif;
max-width: 1280px;
margin: 0 auto;
padding: 0 5%;
}
a {
text-decoration: none;
}
@faustinoaq
faustinoaq / init.el
Created September 25, 2017 23:48
Personal Emacs configuration
;; @faustinoaq
;; GNU Emacs 24
;; ~/.emacs.d/init.el
;; MELPA packages
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
@faustinoaq
faustinoaq / untyped.cr
Created September 26, 2017 23:09
Compiled time array
A = [] of Nil
{% A << 0 %}
{% A << "Some String" %}
{% p A[0] %} # => 0
{% p A[1] %} # => "Some String"