Skip to content

Instantly share code, notes, and snippets.

View spuyet's full-sized avatar
🚀

Sébastien Puyet spuyet

🚀
View GitHub Profile
@spuyet
spuyet / rails-jsonb-queries
Created September 29, 2024 17:33 — forked from mankind/rails-jsonb-queries
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@spuyet
spuyet / mongo_management.js
Created July 13, 2021 08:04
Mongo DB collections management
// Drop all collections starting with the defined pattern
let pattern = 'domain_test#';
db.getCollectionNames().filter((c) => c.startsWith(pattern)).forEach((c) => db[c].drop());
@spuyet
spuyet / gist:b43c5258bedda772bb1280d14479914b
Created February 6, 2019 09:38
AWS t2.micro benchmark
$ sysbench cpu --cpu-max-prime=20000 --time=0 --events=10000 run
sysbench 1.0.11 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 20000
@spuyet
spuyet / gist:2188f06d6a5b489c23786dc637276120
Last active June 29, 2016 12:49
Benchmark XLSX gem wi

With a 1000 rows .xlsx file

Rehearsal ------------------------------------------
rubyXL   0.540000   0.010000   0.550000 (  0.552050)
creek    0.330000   0.000000   0.330000 (  0.327936)
roo      0.410000   0.020000   0.430000 (  0.425322)
--------------------------------- total: 1.310000sec