Skip to content

Instantly share code, notes, and snippets.

View bsingr's full-sized avatar

bsingr

  • @coliquio - former Sophos, Git Tower, Inovex, 1&1
  • Lake Constance, Germany
View GitHub Profile
@bsingr
bsingr / demo.yml
Created November 7, 2023 10:23
k8s nginx demo
kind: Namespace
apiVersion: v1
metadata:
name: demo
labels:
name: demo
---
apiVersion: apps/v1
kind: Deployment
metadata:
@bsingr
bsingr / rename-computer-jamf.py
Created October 10, 2023 10:10
rename-computer-jamf.py
#!/usr/bin/env python3
'''
Rename computer from remote CSV using Jamf binary
Pass in the URL to your remote CSV file using script parameter 4
The remote CSV could live on a web server you control, OR be a Google Sheet
specified in the following format:
https://docs.google.com/spreadsheets/u/0/d/<document ID>/export?format=csv&id=<document ID>&gid=0
'''
@bsingr
bsingr / aws_s3_last_modified_buckets.sh
Created July 28, 2023 07:15
aws_s3_last_modified_buckets
#!/bin/bash
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_DEFAULT_REGION=
buckets_wsv=$(aws s3api list-buckets --query "Buckets[].Name" --output text)
echo $buckets_wsv
echo
echo "---"
@bsingr
bsingr / christmas_quest_de.rb
Created December 24, 2021 19:06
Weihnachtsrätsel
require "base64"
question, hints, solution = DATA.read.split("__END__")
puts Base64.decode64(hints)
puts question
__END__
Frage: Wer bin ich?
@bsingr
bsingr / delete-rabbitmq-queues-browser.js
Last active October 29, 2021 12:10
rabbitmq amqp delete queues
const filter = 'node.1.response.queue' // e.g. when someone used foo-foo-mq with replyQueue:true defaults
const baseUrl = 'http://rabbitmq:15762'
let pageIdx = 1
let shouldFetchAnotherPage = true
while (shouldFetchAnotherPage) {
console.log('Fetching queues page ' + pageIdx)
const queues = await (await fetch(`${baseUrl}/api/queues?page=1&page_size=500&name=${filter}&use_regex=false&pagination=true`)).json()
shouldFetchAnotherPage = queues.page_count > 1
for (const queue of queues.items) {
if (queue.name.match(new RegExp(filter))) {
@bsingr
bsingr / gist:e3ff80534e9e4f7d50ba6b240e932c80
Last active August 25, 2023 16:53 — forked from crittermike/gist:7b654d3d686a4e434eda
Run a single specific Drupal update hook using Drush
drush php-eval "module_load_install('MYMODULE'); MYMODULE_update_NUMBER();"
# or
drush php:cli
require 'core/modules/taxonomy/taxonomy.post_update.php';
taxonomy_post_update_add_unpublished_nodes_to_taxonomy_index($sandbox);
@bsingr
bsingr / sign.php
Created November 18, 2020 07:48
cloudinary signing urls
<?php
function urlSafeBse64Encode($string) {
$data = base64_encode($string);
# base64 strings can end in several = chars. These need to be translated into a number
$no_of_eq = substr_count($data, "=");
$data = str_replace("=", "", $data);
$data = $data.$no_of_eq;
# then replace all non-url safe characters
$data = str_replace(array('+','/'), array('-','_'), $data);
@bsingr
bsingr / README.md
Last active September 9, 2020 14:58
Postgres TRIGGER to call NOTIFY with a JSON payload for Node.js
@bsingr
bsingr / FlatTransformerLoop.rb
Last active December 6, 2019 09:40
flatten deep hash/array/scalar data structure into flat list with jsonpath keys
module FlatTransformer
# @param [Hash, Array, String, Fixnum]
# @return [Enumerator, #to_a] enumerator, call #to_a to get it as array
def self.deep_flatten_jsonpath(data, max_depth=nil)
Enumerator.new do |enum|
depth = 0
queue = [{ path: [], value: data }]
while queue.length > 0
current = queue.shift
is_allowed_to_go_deeper = (!max_depth || depth < max_depth)
@bsingr
bsingr / nodejs-transform-stream.js
Created November 20, 2019 11:37
streams experiment
const { Readable, Transform, pipeline } = require('stream')
const createCounterReader = () => {
let count = 0;
return new Readable({
objectMode: true,
read() {
count += 1;
console.log('read', count)
this.push({count});