Skip to content

Instantly share code, notes, and snippets.

View juuh42dias's full-sized avatar
👩‍💻
working from (coworking || café)

Juliana Dias juuh42dias

👩‍💻
working from (coworking || café)
View GitHub Profile
@VictorTaelin
VictorTaelin / HVML.c
Last active November 9, 2024 20:55
$10k bounty - make HVML.c 50% faster on Apple M3
// Post: https://x.com/VictorTaelin/status/1854326873590792276
// Note: The atomics must be kept.
// Note: This will segfault on non-Apple devices due to upfront mallocs.
#include <stdint.h>
#include <stdatomic.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
@mauricioabreu
mauricioabreu / invert_binary_tree.py
Last active November 3, 2023 18:14
Invert binary tree
class Node:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def invert_binary_tree(root):
if root:
stack = [root]
@leandronsp
leandronsp / background_job_test.go
Created August 5, 2023 02:15
A dead simple background processor in Go, using a double-ended queue based on a doubly linked list
// go mod init queues
// go mod tidy
// go get github.com/stretchr/testify/assert
// go mod tidy
// go test background_job_test.go
package queues
import (
"fmt"
@leandro
leandro / versatile_methods.rb
Created April 13, 2023 00:23
A different approach, compared to using `Module#module_function`
# The idea here is to make all the methods below accessible through the module
# itself and through the classes including the module, but having the methods
# publicly available both as instance and as class methods.
module A
def self.abc = 123
def self.xyz = 456
def self.append_features(klass)
methods_being_added = singleton_methods - [:append_features]
delegation_setter = ->(mod, methods) { delegate *methods, to: mod }
@leandro
leandro / lib__graphql__utils.rb
Created April 5, 2023 13:28
Retrieving the queried fields from a GraphQL operation request (when using `graphql-ruby` gem)
module Graphql
class Utils
CONTEXT_CLASS = GraphQL::Query::Context
FIELD_CLASS = GraphQL::Language::Nodes::Field
FRAGMENT_CLASS = GraphQL::Language::Nodes::FragmentSpread
# Given a GraphQL context (literally, the +context+ method from inside any GraphQL field
# method), this method will return all the fields requested in the operation request.
# So, considering the following query example:
#
@kddnewton
kddnewton / json.rb
Last active August 7, 2023 19:54
Faster JSON parser in Ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "json_pure"
gem "benchmark-ips"
end
@frankyston
frankyston / app.rb
Last active October 4, 2022 09:56
Apurar os resultado da eleições de 2022 para Presidente
require 'net/http'
require 'json'
require 'cgi'
def delimiter(number)
number.reverse.scan(/.{1,3}/).join(',').reverse
end
while (true) do
uri = URI('https://resultados.tse.jus.br/oficial/ele2022/544/dados-simplificados/br/br-c0001-e000544-r.json')
@serradura
serradura / mecha_basic.rb
Last active July 31, 2022 11:57
mecha.rb - a minimalist finite state machine implemented using Ruby 3.1 (basic = 34 LOC, enhanced = 53 LOC)
class Mecha
private attr_accessor(:states_map, :callbacks, :transitions, :current_state)
public :transitions, :current_state
def initialize(initial_state:, transitions:)
self.states_map = transitions.parameters.select { |(type, _)| type == :keyreq }.to_h { [_2, _2] }
self.callbacks = Hash.new { |hash, key| hash[key] = [] }
self.transitions = transitions.call(**states_map).transform_values(&:freeze).freeze
@serradura
serradura / pub_sub.rb
Created May 11, 2022 15:18
Implementação do pub/sub na mão equivalente a gem Wisper
module Susurro
def subscribe(handler)
subscribers << {name: nil, handler: handler}
self
end
def on(event_name, &handler)
subscribers << {name: event_name, handler: handler}
@pauloportella
pauloportella / conventional-comments.md
Last active November 4, 2024 20:53
How to setup conventional comments on Github

Conventional comments

Source

You can add all conventional comments Labels to Github as a saved replies by following the following steps:

  1. Go to https://github.com/settings/replies
  2. Open Developer Tools
  3. Copy/Paste above code in JavaScript console
  4. Press enter