Skip to content

Instantly share code, notes, and snippets.

View lbguilherme's full-sized avatar

Guilherme Bernal lbguilherme

View GitHub Profile
@lbguilherme
lbguilherme / sum.cpp
Created September 27, 2023 23:44
Sum all numbers of a file, separated by "\n"
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
off_t total_size = 0;
char* mmap_file(const char* name) {
@lbguilherme
lbguilherme / todo-html2.cr
Last active March 4, 2022 13:09
Crystal front-end app, what would it look like?
# This is a sample of what a front-end Crystal application could look like, for code review.
# The design was inspired by React, Angular and Flutter and it should be very performing and compact.
# If this is ever implemented, it will use WebAssembly to run Crystal code, together with
# some JavaScript bindings to access the DOM.
class TodoData
property text : String
property? done = false
def initialize(@text)
@lbguilherme
lbguilherme / todo-html.cr
Last active March 4, 2022 11:08
Crystal front-end app, what would it look like?
# This is a sample of what a front-end Crystal application could look like, for code review.
# The design was inspired by React, Angular and Flutter and it should be very performing and compact.
# If this is ever implemented, it will use WebAssembly to run Crystal code, together with
# some JavaScript bindings to access the DOM.
class TodoData
property text : String
property? done = false
def initialize(@text)
@lbguilherme
lbguilherme / todo-elm.cr
Last active March 3, 2022 14:42
Crystal front-end app, what would it look like? (Elm-style)
# This is a sample of what a front-end Crystal application could look like, for code review.
# The design was inspired by Elm and it should be very performing and compact.
# If this is ever implemented, it will use WebAssembly to run Crystal code, together with
# some JavaScript bindings to access the DOM.
# 1. Define a data model.
class Model < BaseModel
getter todos = [] of TodoModel
getter new_todo_text = ""
@lbguilherme
lbguilherme / todo.cr
Created March 3, 2022 12:14
Crystal front-end app, what would it look like?
# This is a sample of what a front-end Crystal application could look like, for code review.
# The design was inspired by React and Flutter and it should be very performing and compact.
# If this is ever implemented, it will use WebAssembly to run Crystal code, together with
# some JavaScript bindings to access the DOM.
class TodoData
property text : String
property? done = false
def initialize(@text)

Keybase proof

I hereby claim:

  • I am lbguilherme on github.
  • I am lbguilherme (https://keybase.io/lbguilherme) on keybase.
  • I have a public key ASD4ShhM8cZhTXdXL1blQ1IGd19Vld2D3tnAMJqQS7jNbQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am guilhermebernal on github.
  • I am lbguilherme (https://keybase.io/lbguilherme) on keybase.
  • I have a public key ASD4ShhM8cZhTXdXL1blQ1IGd19Vld2D3tnAMJqQS7jNbQo

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am guilhermebernal on github.
* I am lbguilherme (https://keybase.io/lbguilherme) on keybase.
* I have a public key ASD4ShhM8cZhTXdXL1blQ1IGd19Vld2D3tnAMJqQS7jNbQo
To claim this, I am signing this object:
check every key 6.28M (±28.48%) 1.39× slower
trie lookup 8.7M (± 4.72%) fastest
check every key 5.14 (± 2.82%) 16.03× slower
trie lookup 82.47 (± 1.80%) fastest