Skip to content

Instantly share code, notes, and snippets.

@silviud
silviud / databricks-auth-token.py
Created October 22, 2024 17:56
Databricks access_token
# https://docs.databricks.com/en/dev-tools/auth/oauth-u2m.html#generate-oauth-pair
# the auth is handled via azure cli
# you need to issue `az login` and set the sub name|id where the ws is attached.
import cmd
import uuid, hashlib, base64
def generate_codes():
# Generate a UUID.
@silviud
silviud / telegraf.conf
Created October 3, 2022 14:13 — forked from DrPsychick/telegraf.conf
Telegraf Windows Performance Counters configuration
# Windows Performance Counters plugin.
# These are the recommended method of monitoring system metrics on windows,
# as the regular system plugins (inputs.cpu, inputs.mem, etc.) rely on WMI,
# which utilize more system resources.
#
# See more configuration examples at:
# https://github.com/influxdata/telegraf/tree/master/plugins/inputs/win_perf_counters
# If metrics are missing run `lodctr /r` as Administrator
[[inputs.win_perf_counters]]
@silviud
silviud / pg_uuid.py
Created August 17, 2022 14:16 — forked from lly365/pg_uuid.py
Flask-SQLAlchemy UUID
# -*- coding: utf-8 -*-
"""
pg_uuid
~~~~~~~~~~~~~~~~
<NO DESCRIPTION>.
:copyright: (c) 2018 by WRDLL <[email protected]>
"""
from flask import Flask
@silviud
silviud / gist:dd2caaf018c4d2816b8d82397dd3e768
Created August 31, 2021 14:00
Create postgresql role and database from shell
# create password - note the md5 is the prefix and the value is user + password
$ U=testpg; P=testpg; echo -n md5; echo -n $P$U | md5sum | cut -d' ' -f1
$ md54bb01023735acf990f528fe961df8140
# connect to pg
$ psql
postgres=# CREATE ROLE testpg NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN PASSWORD 'md54bb01023735acf990f528fe961df8140';
postgres=# CREATE DATABASE testpgdb OWNER testpg;
^D
# at this point you can connect to the database `testpgdb` such so
$ psql -U testpg -d testpgdb -h YOURHOST -W
# Regular Colors
| Value | Color |
| -------- | ------ |
| \e[0;30m | Black |
| \e[0;31m | Red |
| \e[0;32m | Green |
| \e[0;33m | Yellow |
| \e[0;34m | Blue |
| \e[0;35m | Purple |
// class
class ClassCar {
drive () {
console.log('Vroom!');
}
}
const car1 = new ClassCar();
console.log(car1.drive());
#!/usr/bin/env bash
# https://betterdev.blog/minimal-safe-bash-script-template/
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
@silviud
silviud / css-selectors.md
Created November 24, 2020 00:06 — forked from magicznyleszek/css-selectors.md
CSS Selectors Cheatsheet

CSS Selectors Cheatsheet

Element selectors

Element -- selects all h2 elements on the page

h2 {
    foo: bar;
@silviud
silviud / kubectl.yml
Created April 4, 2019 16:58
Kubectl ~/.kube/config
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://SERVER:PORT
name: main
contexts:
- context:
cluster: main
user: main
@silviud
silviud / Ansible-Vault how-to.md
Created September 5, 2018 12:32 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

Working with ansible-vault


I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.