Skip to content

Instantly share code, notes, and snippets.

View chhetripradeep's full-sized avatar
🏠
Working from home

Pradeep Chhetri chhetripradeep

🏠
Working from home
View GitHub Profile
@chhetripradeep
chhetripradeep / autorepair.sh
Created October 1, 2021 13:05 — forked from blemmenes/autorepair.sh
bash script to repair PGs
#!/bin/bash
# from https://github.com/cernceph/ceph-scripts/blob/master/tools/scrubbing/autorepair.sh
for PG in $(ceph pg ls inconsistent -f json | jq -r .pg_stats[].pgid)
do
echo Checking inconsistent PG $PG
if ceph pg ls repair | grep -wq ${PG}
then
echo PG $PG is already repairing, skipping
continue
✔︎ ~ python3 game.py 'a' 'b' 'c'
[ ] Received parameters: repr=['a', 'b', 'c']
[+] Great! Well done
Level 2: Run me with parameters: repr=['$$', '$RANDOM']
✔︎ ~ python3 game.py \$\$ \$RANDOM
[ ] Received parameters: repr=['$$', '$RANDOM']
[+] Great! Well done
Level 3: Run me with parameters: repr=['!b']
✔︎ ~ python3 game.py \!b
[ ] Received parameters: repr=['!b']

Lets say i want to rebalance my-sample-topic topic on my kafka cluster

Create topcis.json

{
  "version": 1,
  "topics": [
 { "topic": "my-sample-topic" 
--------------------------------------------------------------------------------------------- benchmark: 4 tests --------------------------------------------------------------------------------------------
Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_concat_rust 145.2740 (1.0) 541.5140 (1.0) 208.1202 (1.0) 70.6213 (1.05) 196.9000 (1.0) 131.0497 (3.36) 28;1 4.8049 (1.0) 113 1
test_concat_comprehensions 308.8310 (2.13) 849.9930 (1.57) 341.7398 (1.64) 67.2811 (1.0) 310.2720 (1.58) 39.0078 (1.0) 271;274 2.9262 (0.61) 3077
------------------------------------------------------------------------------------------ benchmark: 4 tests -----------------------------------------------------------------------------------------
Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_concat_rust 30.1850 (1.0) 34.3350 (1.0) 30.3329 (1.0) 0.4555 (1.0) 30.2800 (1.0) 0.0478 (1.0) 2;3 32.9675 (1.0) 81 1
test_concat_comprehensions 32.5590 (1.01) 159.3540 (4.64) 33.2932 (1.10) 8.4885 (18.64) 30.8100 (1.02) 0.1530 (3.20) 1430;4583 30.0362 (0.91) 22609 1
test_concat_basic
import libmyrustlib
iterations = 100
def test_concat_basic(benchmark):
benchmark(concat_basic, iterations)
def test_concat_join(benchmark):
benchmark(concat_join, iterations)
@chhetripradeep
chhetripradeep / cargo-build
Created May 1, 2019 17:08
Output of cargo build
## cargo build --release
Compiling memchr v2.2.0
Compiling ucd-util v0.1.3
Compiling regex v1.1.6
Compiling lazy_static v1.3.0
Compiling utf8-ranges v1.0.2
Compiling libc v0.2.53
Compiling num-traits v0.2.6
Compiling cpython v0.2.1
Compiling thread_local v0.3.6
@chhetripradeep
chhetripradeep / lib.rs
Created May 1, 2019 17:02
Rust Python Bindings
#[macro_use] extern crate cpython;
use cpython::{PyResult, Python};
py_module_initializer!(libmyrustlib, initlibmyrustlib, PyInit_libmyrustlib, |py, m| {
m.add(py, "__doc__", "This module is implemented in Rust.")?;
m.add(py, "rust_concat", py_fn!(py, rust_concat(val: i64)))?;
Ok(())
});
------------------------------------------------------------------------------------------- benchmark: 3 tests ------------------------------------------------------------------------------------------
Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_concat_comprehensions 30.6030 (1.0) 245.6720 (1.0) 34.4128 (1.0) 9.0401 (1.0) 30.9300 (1.0) 3.9240 (1.0) 2152;2712 29.0590 (1.0) 26594 1
test_concat_basic 36.1660 (1.18) 1,597.7350 (6.50) 47.6731 (1.39) 32.1664 (3.56) 40.8035 (1.32) 10.8160 (2.76) 1006;3951 20.9762 (0.72) 21426 1
test_concat_jo
@chhetripradeep
chhetripradeep / benchmark.py
Created May 1, 2019 16:48
Python Benchmarks
iterations = 100
def test_concat_basic(benchmark):
benchmark(concat_basic, iterations)
def test_concat_join(benchmark):
benchmark(concat_join, iterations)
def test_concat_comprehensions(benchmark):
benchmark(concat_comprehensions, iterations)