Skip to content

Instantly share code, notes, and snippets.

View rootcss's full-sized avatar
🎯
Focusing

Shekhar Singh rootcss

🎯
Focusing
View GitHub Profile
@rootcss
rootcss / asyncio_mongo_test.py
Created October 28, 2022 07:38
asyncio mongo script for testing in python
import asyncio
from contextlib import contextmanager
from motor import motor_asyncio
import time
_times = []
_results = []
@contextmanager
import com.google.protobuf.DescriptorProtos;
import com.google.protobuf.Descriptors;
import com.google.protobuf.DynamicMessage;
import com.google.protobuf.Message;
import java.util.HashMap;
/**
* ProtobufEnvelope - allows creating a protobuf message without the .proto file dynamically.
*
// alert if scheduler is down.
stream
|from()
.measurement('prefix_scheduler_heartbeat')
|deadman(0.0, 5m)
.id('AirflowSchedulerDown')
.message('Airflow Scheduler is down')
.log('/tmp/alert_logs.txt')
.trigger_alert_method()
SELECT
sum("mean")
FROM
"monthly"."airflow_dag_duration"
WHERE
"dag_id" =~ /^$dag_id$/
AND $timeFilter
GROUP BY
time($group_interval), "task_id"
fill(none)
> select * from rp.airflow_dag_duration limit 10;
name: airflow_dag_duration
time count dag_id host lower mean metric_type stddev sum task_id upper
---- ----- ------ ---- ----- ---- ----------- ------ --- ------- -----
1587729270000000000 1 sample_dag_name airflow_hostname 1116.553268 1116.553268 timing 0 1116.553268 export_a_table 1116.553268
1587729320000000000 1 sample_dag_name airflow_hostname 423.067092 423.067092 timing 0 423.067092 export_a_temp_table 423.067092
1587729820000000000 1 sample_dag_name airflow_hostname 181.609373 181.609373 timing 0 181.609373 create_summary 181.609373
1587729830000000000 1 sample_dag_name airflow_hostname 1.416052 1.416052 timing 0 1.416052 delete_table 1.416052
1587729830000000000 1 sample_dag_name airflow_hostname 2.528059 2.528059 timing
[
"*.dag.*.*.duration measurement.measurement.dag_id.task_id.measurement",
"*.dagrun.dependency-check.* measurement.measurement.measurement.dag_id",
"*.dag_processing.last_duration.* measurement.measurement.measurement.dag_id",
"*.dagrun.duration.*.* measurement.measurement.measurement.status.dag_id",
"*.dagrun.schedule_delay.* measurement.measurement.measurement.dag_id",
"*.dag_processing.last_runtime.* measurement.measurement.measurement.dag_id",
"*.dag.loading-duration.* measurement.measurement.measurement.dag_id",
"*.operator.*.* measurement.measurement.status.operator"
]
@rootcss
rootcss / jupyter_dark_theme_and_notify.js
Last active August 22, 2019 05:50
Have a dark mode for jupyter and also integrate notify; which notifies when a command is executed. Not a very sophisticated script.
$("head").append(`<style>
body,
body.notebook_app.command_mode {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.CodeMirror pre,
.CodeMirror-dialog,
.CodeMirror-dialog .CodeMirror-search-field,
.terminal-app .terminal {
@rootcss
rootcss / apache_bench.md
Created April 25, 2019 08:57
Apache Bench Examples

Installation:

sudo apt-get install apache2-utils

GET example

ab -n 10 -c 2 http://dummy.restapiexample.com/api/v1/employees
@rootcss
rootcss / postgres_queries_and_commands.sql
Created March 26, 2019 09:57 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@rootcss
rootcss / iterm2-solarized.md
Created October 7, 2018 13:15 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k