Skip to content

Instantly share code, notes, and snippets.

@knikolla
knikolla / get_users_from_keycloak.py
Last active May 22, 2023 21:36
Query all Keycloak Users from the HTTP API
import json
import logging
import requests
from requests.auth import HTTPBasicAuth
logger = logging.getLogger()
def get_client_token():
client_token = None
@jthodge
jthodge / universal-switcher
Created September 6, 2020 22:07
Show macOS app switcher across all monitors
defaults write com.apple.Dock appswitcher-all-displays -bool true
killall Dock
@anvk
anvk / psql_useful_stat_queries.sql
Last active April 16, 2024 22:45
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
anonymous
anonymous / emacs-disable-zone-serial-increment
Created July 11, 2017 16:38
Minimal emacs config to disable auto incrementing serials in zone files.
(setq inhibit-startup-message t)
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
;; Bootstrap `use-package'
@simonw
simonw / recover_source_code.md
Last active January 16, 2024 08:13
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@ipbastola
ipbastola / jq to filter by value.md
Last active April 12, 2024 05:36
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@carsongee
carsongee / private.py
Last active August 29, 2015 14:03
private.py for developing on devstack
from .devstack import * # pylint: disable=wildcard-import, unused-wildcard-import
from .common import INSTALLED_APPS, MIDDLEWARE_CLASSES
FEATURES['ENABLE_SYSADMIN_DASHBOARD'] = True
MODULESTORE = {
'default': {
'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
'OPTIONS': {
"collection": "modulestore",
@tamoyal
tamoyal / gist:10441108
Created April 11, 2014 04:39
Create super user and database user in Mongo 2.6
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
@alerque
alerque / pre-commit
Last active August 29, 2015 13:57 — forked from anl/pre-commit
git pre-commit hook (make executable at .git/hooks/pre-commit) to check dns zones
#!/bin/zsh
# Fail the hook if anything isn't 100% copacetic
set -e
# If anything goes wrong, try to show what and clean up after ourselves
function show_log () {
cat $tmpfile |
grep -v 'ignoring out-of-zone data' |
grep -v 'loaded serial' |
#!/bin/bash
echo '#!/bin/bash'
echo ''
echo 'failed_items=""'
echo 'function install_package() {'
echo 'echo EXECUTING: brew install $1 $2'
echo 'brew install $1 $2'
echo '[ $? -ne 0 ] && $failed_items="$failed_items $1" # package failed to install.'
echo '}'