Skip to content

Instantly share code, notes, and snippets.

View nohupped's full-sized avatar
:octocat:

0x80 nohupped

:octocat:
View GitHub Profile
@nohupped
nohupped / alter-kafka-partitions.sh
Created March 21, 2023 17:31 — forked from xsqian/alter-kafka-partitions.sh
How to alter kafka partitions
# create a topic with specified partitons
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --create --partitions 2 --topic test-partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --describe --topic test-partitions
# create a topic with default partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --create --topic test-def-partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --describe --topic test-def-partitions
# alter the number of partitions of an existing topic
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --alter --topic test-def-partitions --partitions 3
@nohupped
nohupped / busctl-example-systemd.sh
Created February 15, 2023 10:44 — forked from anonymouse64/busctl-example-systemd.sh
Get systemd unit property's from busctl
# Get the object path for a service with the "easy name"
sudo busctl --verbose --system call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager GetUnit s snap.docker.dockerd.service
# get the ActiveState d-bus property of the Unit object
sudo busctl --verbose --system get-property org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/snap_2edocker_2edockerd_2eservice org.freedesktop.systemd1.Unit ActiveState
# get the OOMScoreAdjust d-bus property of the Service object
sudo busctl --verbose --system get-property org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/snap_2edocker_2edockerd_2eservice org.freedesktop.systemd1.Service OOMScoreAdjust
// Please find the full, tested version in
// https://github.com/influxdata/influxdb_iox/blob/fe155e15fb2ad166aee66b0458e63c24a8128dd4/query/src/exec/task.rs#L101-L118
pub struct DedicatedExecutor {
state: Arc<Mutex<State>>,
}
/// Runs futures (and any `tasks` that are `tokio::task::spawned` by
/// them) on a separate Tokio Executor
struct State {
@nohupped
nohupped / autorepair.sh
Created October 1, 2021 08:58 — 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
@nohupped
nohupped / zsh_to_fish.py
Created May 4, 2021 08:40 — forked from dvdbng/zsh_to_fish.py
Migrate zsh history to fish
import os
import re
def zsh_to_fish(cmd):
return (cmd.replace('&&', '; and ')
.replace('||', '; or '))
def is_valid_fish(cmd):
@nohupped
nohupped / slog-logging-middleware.rs
Created September 1, 2020 15:45 — forked from dimfeld/slog-logging-middleware.rs
Simple actix-web middleware for custom KV logging with slog
use actix_service::{Service, Transform};
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error};
use futures::future::{ok, FutureResult};
use futures::{Future, Poll};
use slog::info;
// There are two step in middleware processing.
// 1. Middleware initialization, middleware factory get called with
// next service in chain as parameter.
// 2. Middleware's call method get called with normal request.
@nohupped
nohupped / Retrieve all EC2 instance userData
Created September 25, 2019 09:06 — forked from dagrz/Retrieve all EC2 instance userData
Retrieve all EC2 instance userData
#!/usr/bin/env python
from __future__ import print_function
import boto3
import base64
client = boto3.client(service_name='ec2', region_name='us-east-1')
for region in client.describe_regions()['Regions']:
ec2 = boto3.resource(service_name='ec2', region_name=region['RegionName'])
for instance in ec2.instances.all():
response = instance.describe_attribute(Attribute='userData')
@nohupped
nohupped / main.go
Created June 7, 2019 02:19 — forked from filewalkwithme/main.go
Listening multiple ports on golang http servers (using http.Handler)
package main
import (
"net/http"
)
func main() {
go func() {
http.ListenAndServe(":8001", &fooHandler{})
}()
@nohupped
nohupped / gist:caa45c252e5cceab37e32502e2a3d3ff
Created February 27, 2019 13:39 — forked from ctgswallow/gist:3409231
Create a template within a ruby block
ruby_block "create ssh key" do
block do
k = SSHKey.generate(:type => 'RSA', :bits => 1024, :comment => "Postgres Master")
node.set[:postgresql][:pubkey] = k.ssh_public_key
node.save
# Much of the DSL disappears in ruby blocks. Here's how to create a template.
rc = Chef::RunContext.new(node, node.cookbook_collection)
t = Chef::Resource::Template.new "/var/lib/postgresql/.ssh/id_rsa"
t.source("id_rsa.erb")
@nohupped
nohupped / Run Visual Studio Code for Linux from WSL.md
Created December 14, 2018 16:28 — forked from fedme/Run Visual Studio Code for Linux from WSL.md
Run Visual Studio Code for Linux from WSL on Windows 10

Run Visual Studio Code for Linux from WSL

Thanks a lot to mredbishop and others for their insturctions posted here. This is just a recap of what they figured out.

This process was tested on WSL Ubuntu 18.04.

Install VcXsrv on Windows

  1. Dowload the VcXsrv installer from https://sourceforge.net/projects/vcxsrv/
  2. Install the software on Windows

Add VS Code repositories