Skip to content

Instantly share code, notes, and snippets.

View tarcisiozf's full-sized avatar

Tarcísio Zotelli Ferraz tarcisiozf

View GitHub Profile
v = new Set(); do { v.add(Math.floor(Math.random() * 60) + 1) } while(v.size < 6); v
({ HFS }) => async (state = {}, update = {}) => {
const { price, mts } = update
const position = HFS.getPosition(state)
if (position) {
return HFS.closePositionMarket(state, { price, mtsCreate: mts })
}
return HFS.openLongPositionMarket(state, {
mtsCreate: mts,
@tarcisiozf
tarcisiozf / REASONING.md
Created November 10, 2021 13:20
Should I add a new language?
  • team knowledge
    • number of team-members and knowledge scoring for each member (beginner/intermediate/expert)
    • integrations with other teams?
    • N/A
  • goal/type
    • web? cli? database connectors? gui? mobile?
  • reuse of code
    • is there any legacy code that must be used?
    • rewrite cost?
  • language interop (JVM, native bindings)
#include <sys/mman.h>
#include <fcntl.h>
unsigned char* shared(const char* path) {
int fd = open(path, O_RDWR | O_CREAT, (mode_t) 0600);
posix_fallocate(fd, 0, 65536);
return (unsigned char*) mmap(0, 65536, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
}
// double 12345.67 -> int 1234567
struct Trie {
std::array<int, (size_t) 1.1e7> cnt, sum;
void update(int price, int qty) {
int cnt_delta = qty ? (cnt[price] ? 0 : +1) : (cnt[price] ? -1 : 0);
int sum_delta = qty - sum[price];
for (int node = 0, tmp = price, p10 = 1e7; p10; tmp %= p10, p10 /= 10) {
node = 10 * node + tmp / p10;
package main
import (
"fmt"
"sync"
)
func TrySend[T any](ch chan T, item T) bool {
select {
case ch <- item:
@tarcisiozf
tarcisiozf / app.js
Last active August 16, 2021 23:17
easier dom components in js (without jsx), inspired by h
const { ul, li } = require('./html')
const list = ul({ title: 'awesome list' },
li({ title: 'interactive', onclick: () => alert(1) }, 'first'),
li('second')
)
document.body.appendChild(list)
@tarcisiozf
tarcisiozf / guide.md
Last active June 17, 2021 19:12
Webstorm > Settings > Build, Execution, Deployment > Debugger > Stepping
  • Always do smart step into
  • Do not step into library scripts
  • Do not step into scripts:
  • /home/<USER>/.config/JetBrains/WebStorm2021.1/javascript/nodejs/**
  • node:internal/*
  • /**
@tarcisiozf
tarcisiozf / SEGFAULT.md
Last active October 29, 2021 15:40
Error handling