You can add all conventional comments Labels to Github as a saved replies by following the following steps:
- Go to https://github.com/settings/replies
- Open Developer Tools
- Copy/Paste above code in JavaScript console
- Press enter
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
// 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> |
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 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] |
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
// 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" |
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
# 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 } |
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
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: | |
# |
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
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile do | |
source "https://rubygems.org" | |
gem "json_pure" | |
gem "benchmark-ips" | |
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
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') |
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 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 |
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
module Susurro | |
def subscribe(handler) | |
subscribers << {name: nil, handler: handler} | |
self | |
end | |
def on(event_name, &handler) | |
subscribers << {name: event_name, handler: handler} |
NewerOlder