Skip to content

Instantly share code, notes, and snippets.

@wheresalice
wheresalice / redisdns.py
Created November 27, 2011 12:56
Python DNS server with Redis backend
# A naive dns server with a Redis backend
# Set keys in Redis you want to be authoritative for (set google.com. 127.0.0.1)
# Tip: Use Redis's ttl functions to have temporary names
# Currently only does A records, feel free to fix that
#
# Licensed under the PSF License
# Thanks to: http://code.activestate.com/recipes/491264-mini-fake-dns-server/
# Author: @Kaerast <alice@kaerast.info>
import socket
@wheresalice
wheresalice / gist:2978019
Created June 23, 2012 11:54
Useful UK Train Tools

Free Tools

@wheresalice
wheresalice / rest_proxy.yaml
Last active April 14, 2022 08:28
Swagger OpenAPI spec for Confluent REST Proxy
openapi: 3.0.1
info:
title: REST Proxy API
description: >-
The Confluent REST Proxy provides a RESTful interface to a Kafka cluster, making it easy to produce and consume messages, view the state of the cluster, and perform administrative actions without using the native Kafka protocol or clients.
<p>Some example use cases are</p>
<ul>
<li>Reporting data to Kafka from any frontend app built in any language not supported by official Confluent clients</li>
<li>Ingesting messages into a stream processing framework that doesn’t yet support Kafka</li>
<li>Scripting administrative actions</li>
@wheresalice
wheresalice / settings.yml
Created March 13, 2022 10:56
Searxh settings
general:
debug : False # Debug mode, only for development
instance_name : "searx" # displayed name
contact_url: False # mailto:contact@example.com
enable_stats: False # activate /stats page - note: it may leak usage data
brand:
git_url: https://github.com/searx/searx
git_branch: master
issue_url: https://github.com/searx/searx/issues
@wheresalice
wheresalice / gist:3780828
Created September 25, 2012 09:26
Show largest tables in MySQL and Postgresql
# MySQL
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
require 'net/http'
require 'json'
# We could just use localhost, but it's nice to print usable urls in debug
@jenkins = `hostname`.strip
# Get the list of jobs on the Jenkins instance
res = Net::HTTP.get_response(URI('http://'+@jenkins+'/api/json'))
jobs = JSON.parse(res.body)['jobs']
version: '2'
services:
zookeeper:
image: "confluentinc/cp-zookeeper:5.4.0"
hostname: zookeeper
ports:
- '32181:32181'
environment:
ZOOKEEPER_CLIENT_PORT: 32181
ZOOKEEPER_TICK_TIME: 2000
#!/bin/bash -xe
# Parse server.properties to get Zookeeper hosts
ZK_HOST=$(grep 'zookeeper.connect=' /etc/kafka/server.properties | cut -d'=' -f 2)
# Find the most newly created directory of Kafka in the /opt directory
KAFKA_PATH=$(find /opt/ -maxdepth 1 -name kafka-2* -print0 | xargs -0 ls -d -1 -t | head -n1)
# Manually configured list of brokers to rebalance across (zero-indexed)
BROKER_LIST="0,1,2"
@wheresalice
wheresalice / ezclone.sh
Last active June 12, 2020 18:23
A shell function for cloning a git repository into a sensible place. `ezclone <repo url>` or `ezclone golang <repo url>`
function ezclone() {
# assumes cloning from a git@ url...
# clone to git_src by default
repo_base=~/git_src
if [[ "$1" == "golang" ]]; then
repo_base=~/go/src
shift
fi
@wheresalice
wheresalice / spec.json
Created June 8, 2020 18:20
NHS England Covid Deaths
{
"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}},
"data": {"name": "data-9f7cabe0332f8f1e8f65ae37f185d2a2"},
"mark": "bar",
"encoding": {
"color": {"type": "nominal", "field": "Condition"},
"column": {"type": "nominal", "field": "Condition"},
"tooltip": {"type": "quantitative", "field": "sum"},
"x": {"type": "nominal", "field": "Age group"},
"y": {"type": "quantitative", "field": "sum"}