Skip to content

Instantly share code, notes, and snippets.

from dask.distributed import Client, progress
client = Client(threads_per_worker=8, n_workers=2)
client
import urllib
import requests
import aiohttp
from pprint import pprint
import dask
import dask.dataframe as dd
select /*+ 2 buckets */ ora_hash(last_name,1) the_hash, last_name from customers where rownum <= 10;
THE_HASH LAST_NAME
---------- --------------------------------------------------
1 Brown
0 Riddell
0 Lawrence
1 Bartlett
1 Kenny
0 Williams
@tmuth
tmuth / simple-splunk-GET-search.py
Last active May 20, 2021 13:22
Simple get search to pandas data frame
import urllib
import requests
import aiohttp
from pprint import pprint
# disable SSL warnings
import urllib3
urllib3.disable_warnings()
#df = dd.read_csv(filename)
@tmuth
tmuth / nginx.conf
Created June 20, 2019 20:11
nginx Proxy for Splunk HEC
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
CREATE OR REPLACE TYPE clob_rec AS OBJECT (
num_characters number,
the_clob clob
);
CREATE OR REPLACE TYPE clob_tbl AS TABLE OF clob_rec;
select * FROM TABLE(clob_tbl_fn(30000));
@tmuth
tmuth / fio-HEC.sh
Created April 3, 2018 17:09
Run fio and send results to splunk HTTP Event Collector
#!/bin/bash
SPLUNK_HOST=localhost
HEC_PORT=8088
HEC_TOKEN=ba8e11d0-0a1f-4f41-a5c6-c660e8655b02
HEC_PROTOCOL=http
file_name=`hostname`"_"$(date '+%Y-%m-%d_%H.%M.%S')".json"
host_name=`hostname`
epoc_time=`date +%s`
@tmuth
tmuth / docker-bash.sh
Created March 6, 2018 19:21
Docker-Bash-Functions
function docker_exec {
name="${1?needs one argument}"
containerId=$(docker ps | awk -v app="$name" '$2 ~ app{print $1}')
if [[ -n "$containerId" ]]; then
docker exec -it $containerId bash
else
echo "No docker container with name: $name is running"
fi
}
@tmuth
tmuth / export-splunk-apps.sh
Last active December 4, 2017 16:02
Export splunk apps out of docker containers
function get_container_id {
name="${1?needs one argument}"
containerId=$(docker ps | awk -v app="$name" '$2 ~ app{print $1}')
if [[ -n "$containerId" ]]; then
echo ${containerId}
else
echo "No docker container with name: $name is running"
fi
}
@tmuth
tmuth / docker_exec.sh
Last active August 23, 2020 19:05
"Docker exec -it $1 bash" bash function for attaching to a running container
function docker_exec {
name="${1?needs one argument}"
containerId=$(docker ps | awk -v app="$name" '$2 ~ app{print $1}')
if [[ -n "$containerId" ]]; then
docker exec -it $containerId bash
else
echo "No docker container with name: $name is running"
fi
}
@tmuth
tmuth / orcl-1-row-json.sql
Created June 26, 2017 21:47
Oracle get 1 row as JSON
SELECT regexp_replace(xml3,'(.+),.+$','{\1}',1,1,'n') xml4
FROM
(SELECT regexp_replace(xml2,'<(\w+)>(.+)</\1>','"\1" : "\2",',1,0,'n') xml3
FROM
(SELECT regexp_replace(xml,'(^.+<ROW>)(.*)(</ROW>.*)','\2',1,1,'n') xml2
FROM
(SELECT dbms_xmlgen.getXML('SELECT * from soe.customers where rownum=1') xml
FROM dual
)
)