Skip to content

Instantly share code, notes, and snippets.

@DayoOliyide
DayoOliyide / order-query.lua
Last active February 27, 2020 07:07
Generate dynamic wrk/wrk2 requests
--[[
This is an example of a wrk/wrk2 script to dynamically generate a range of GET requests for load testing.
you can run it by tying something similar to the following
./wrk -t15 -c 15 -d 600s -R1 -s order-query.lua http://localhost:8080
NOTE: Noticed that the requests are dynamically generated once, given to all the threads
i.e you see request-a t times, then request-b t times.
Ideally i'd like each thread to send a dynamically generated request for each request,
What I see now is the group of threads getting a dynamically generated request.
@DayoOliyide
DayoOliyide / thread-info.clj
Last active July 30, 2022 15:50
Get all thread information in clojure
(defn print-threads [& {:keys [headers pre-fn]
:or {pre-fn identity}}]
(let [thread-set (keys (Thread/getAllStackTraces))
thread-data (mapv bean thread-set)
headers (or headers (-> thread-data first keys))]
(clojure.pprint/print-table headers (pre-fn thread-data))))
(defn print-threads-str [& args]
(with-out-str (apply print-threads args)))
;; Write a function that takes a string and does a partial replacement on the string.
;; By partial replacement, I mean if the string is 3 characters or more replace all the
;; characters (except the first and last with X), if the string is less than 3 replace
;; with all characters with X
;; E.g
;; (partial-replacement "IamASecretPassword") => "IXXXXXXXXXXXXXXXXd"
;; (partial-replacement "YES") => "YXS"
;; (partial-replacement "NO") => "XX"
@DayoOliyide
DayoOliyide / dot_ctags
Created November 7, 2012 11:35 — forked from awl/dot_ctags
scala regular expressions for ctags and tagbar in vim
--langdef=Scala
--langmap=Scala:.scala
--regex-Scala=/^[ \t]*(((implicit|private|public)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*class[ \t]*([a-zA-Z0-9_]+)/\5/c,classes/
--regex-Scala=/^[ \t]*(((implicit|private|public)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*object[ \t]*([a-zA-Z0-9_]+)/\5/o,objects/
--regex-Scala=/^[ \t]*trait[ \t]*([a-zA-Z0-9_]+)/\1/t,traits/
--regex-Scala=/^[ \t]*case[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/r,cclasses/
--regex-Scala=/^[ \t]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/a,aclasses/
--regex-Scala=/[ \t]*(((implicit|override|lazy|private|public)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*def[ \t]*([a-zA-Z0-9_=]+)[ \t]*.*[:={]/\5/m,methods/
--regex-Scala=/[ \t]*(((override|lazy|private|public)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\5/V,values/
--regex-Scala=/[ \t]*(((override|lazy|private|public)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*var[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\5/v,variables/