Skip to content

Instantly share code, notes, and snippets.

@jehaby
jehaby / xtdb-lucene.clj
Created December 9, 2022 10:02
xtdb-lucene
;; dataset size: 10 users, 200 clients, 30k invoices
(time
(let [client-ids
(->>
(xt/q (db)
'{:find [?client]
:where [[(lucene-text-search
"client\\/first-name: %1$s* OR client\\/last-name: %1$s* OR client\\/company-name: %1$s*"
?s-str)
@jehaby
jehaby / jsonb_key_size_bench.sql
Last active May 4, 2021 10:36
jsonb storage size bench
-- Check "JSONB storage does not deduplicate the key names in the JSON. This can result in considerably larger storage footprint.. " from https://scalegrid.io/blog/using-jsonb-in-postgresql-how-to-effectively-store-index-json-data-in-postgresql/
create table jt_1 (a integer, b numeric, c text);
create table jt_2 (data jsonb);
create table jt_3 (data jsonb);
create table jt_4 (data jsonb);
-- 10 million records for jt_1 and jt_2
insert into jt_1 SELECT (random() * 100000)::integer,
(random() * 1000000)::numeric,
@jehaby
jehaby / contains_test.go
Last active November 27, 2018 08:13
testify Contains
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
type eee struct{}
@jehaby
jehaby / remove_keys.yml
Created August 8, 2017 16:29 — forked from sgargan/remove_keys.yml
Removing unknown keys from authorized keys with Ansible
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: add a couple of keys to an authorized_keys file
authorized_key: path='./keys' user=sgargan key="{{ lookup('file', './ansible.pub') }}"
- authorized_key: path='./keys' user=sgargan key="{{ lookup('file', './sgargan.pub') }}"
/*
go test str_conc_test.go -bench . -benchtime 10s
BenchmarkConcatOne-4 2000000 7684 ns/op
BenchmarkConcatTwo-4 5000000 2883 ns/op
BenchmarkConcatThree-4 5000000 2933 ns/op
PASS
ok command-line-arguments 56.982s
*/
package main
@jehaby
jehaby / wtf.go
Created April 3, 2017 14:49
proof
This file has been truncated, but you can view the full file.
-*- mode: grep; default-directory: "/usr/local/go/src/" -*-
Grep started at Mon Apr 3 17:48:57
find . -type d \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path \*/MCVS -o -path \*/.svn -o -path \*/.git -o -path \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) -prune -o \! -type d \( -name .\#\* -o -name \*.o -o -name \*\~ -o -name \*.bin -o -name \*.lbin -o -name \*.so -o -name \*.a -o -name \*.ln -o -name \*.blg -o -name \*.bbl -o -name \*.elc -o -name \*.lof -o -name \*.glo -o -name \*.idx -o -name \*.lot -o -name \*.fmt -o -name \*.tfm -o -name \*.class -o -name \*.fas -o -name \*.lib -o -name \*.mem -o -name \*.x86f -o -name \*.sparcf -o -name \*.dfsl -o -name \*.pfsl -o -name \*.d64fsl -o -name \*.p64fsl -o -name \*.lx64fsl -o -name \*.lx32fsl -o -name \*.dx64fsl -o -name \*.dx32fsl -o -name \*.fx64fsl -o -name \*.fx32fsl -o -name \*.sx64fsl -o -name \*.sx32fsl -o -name \*.wx64fsl -o -name \*.wx32fsl -o -name \*.fasl -o -name \*.ufsl -o -name \*.fsl -o -name \
@jehaby
jehaby / docker_install_ru.md
Last active August 9, 2017 15:07
docker_install_ru.md
  1. Ставим по инструкции с офсайта
  2. Для линуксов: добавляем юзера в группу докера sudo usermod -aG docker $USER
  3. Ставим докер-композ: https://docs.docker.com/compose/install/
@jehaby
jehaby / array_replace_recursive_overwrite.php
Created May 10, 2016 10:06
Enchantment of PHP's array_replace_recursive
<?php
if (!function_exists('array_replace_recursive_overwrite')) {
function array_replace_recursive_overwrite($array, $array1)
{
$recurse = function ($array,$array1) use (&$recurse)
{
foreach ($array1 as $key => $value) {
@jehaby
jehaby / README.md
Last active January 25, 2024 14:43 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \