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
from sqlglot import exp, parse_one | |
expression_tree = parse_one("SELECT a FROM x") | |
def transformer(node): | |
if isinstance(node, exp.Column) and node.name == "a": | |
return parse_one("FUN(a)") | |
return node | |
transformed_tree = expression_tree.transform(transformer) |
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 "minitest/autorun" | |
require 'yaml' | |
`make test-render` | |
def flatten_hash(object, current_path = [], result = {}) | |
case object | |
when Hash | |
object.each do |key, value| | |
flatten_hash(value, current_path + [key], result) |
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
./s5cmd ls s3://mybucket/* | parallel --pipe -N 1000 'clickhouse client --query "insert into some_table FORMAT TSVRaw settings async_insert=1"' |
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
sed 's/,/,:/g' my_file.csv | column -t -s: |
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
#!/usr/bin/env ruby | |
require 'bundler/inline' | |
begin | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'tty-prompt', '~> 0.23.1', require: false | |
end | |
rescue => e |
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
func parallelMap[T any, V any](input []T, f func(T) (V, error)) ([]V, error) { | |
outChan := make(chan V, len(input)) | |
errChan := make(chan error, len(input)) | |
for i, val := range input { | |
go func(i int, val T) { | |
out, err := f(val) | |
if err != nil { | |
errChan <- err | |
} else { |
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
import { h, ChildNode, FunctionalComponent, FunctionalUtilities } from "@stencil/core"; | |
function vnodeToSource(elem: ChildNode, utils: FunctionalUtilities, output = "", level = 0): string { | |
if (elem.vchildren) { | |
let childOutput: string[] = []; | |
utils.forEach(elem.vchildren, (child) => { | |
childOutput.push(vnodeToSource(child, utils, output, level + 1)); | |
}); |
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
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c | |
--- a/ext/openssl/ossl_ssl.c | |
+++ b/ext/openssl/ossl_ssl.c | |
@@ -107,6 +107,18 @@ | |
OSSL_SSL_METHOD_ENTRY(TLSv1), | |
OSSL_SSL_METHOD_ENTRY(TLSv1_server), | |
OSSL_SSL_METHOD_ENTRY(TLSv1_client), | |
+#if defined(HAVE_TLSV1_2_METHOD) && defined(HAVE_TLSV1_2_SERVER_METHOD) && \ | |
+ defined(HAVE_TLSV1_2_CLIENT_METHOD) | |
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2), |
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
# Put this in config/initializers | |
module ActiveRecord | |
class Base | |
def self.removed_columns(*names) | |
@@removed_columns = Set.new(names.map(&:to_s)) | |
instance_eval do | |
def columns | |
cols = super | |
cols.reject { |col| @@removed_columns.include?(col.name) } |
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 'benchmark/ips' | |
carts = 10.times.map { Cart.create! account: Account.first } | |
carts.each { |cart| | |
items = Account.first.product_options.sample(5) | |
items.each { |item| cart.line_items.create product_option_id: item.id, quantity: 1 } | |
} | |
def all_at_once(carts, &blk) |
NewerOlder