Skip to content

Instantly share code, notes, and snippets.

View hbasria's full-sized avatar

Basri hbasria

View GitHub Profile
@hbasria
hbasria / raw_as_qs.py
Created January 29, 2016 14:03 — forked from carymrobbins/raw_as_qs.py
Django - convert RawQuerySet to QuerySet
from django.db import connection, models
class MyManager(Manager):
def raw_as_qs(self, raw_query, params=()):
"""Execute a raw query and return a QuerySet. The first column in the
result set must be the id field for the model.
:type raw_query: str | unicode
:type params: tuple[T] | dict[str | unicode, T]
:rtype: django.db.models.query.QuerySet
"""
@hbasria
hbasria / remove-cluster.sh
Last active October 5, 2022 18:41
Proxmox VE Removing cluster configuration
systemctl stop pve-cluster
systemctl stop corosync
pmxcfs -l
rm -rf /etc/pve/corosync.conf
rm -rf /etc/corosync/*

Client Side Config

Open up your vpn.ovpn config file, it should add nobind and look something like this:

.....

nobind

.....

-- 1. Create a group
CREATE ROLE readaccess;
-- 2. Grant usage on schema:
GRANT USAGE ON SCHEMA schema_name TO readaccess;
-- 3.1 Grant select for a specific table:
GRANT SELECT ON table_name TO readaccess;
-- 3.2 Grant select for multiple tables:
@hbasria
hbasria / nginx_google_analytics
Created September 21, 2021 08:12 — forked from srstsavage/nginx_google_analytics
google analytics in nginx
# send logs for all traffic (including non-html) to google analytics
#
# in server block:
# set $google_analytics_id "UA-THECORRECT-ID";
# include /srv/nginx/google_analytics;
#
# in location blocks:
# post_action @ga;
#
# notes: post_action has been referred to by nginx devs as a "dirty hack" and this approach may stop working one day.
@hbasria
hbasria / check-mysql-database-table-sizes.sql
Last active September 8, 2021 11:37
How to check MySQL database and table sizes
SELECT table_schema AS "Database",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
FROM information_schema.TABLES
WHERE table_schema = "database_name"
@hbasria
hbasria / redis_bulk.sh
Created October 27, 2015 07:24 — forked from egemenyildiz/redis_bulk.sh
[LUA] Redis bulk/batch operation scripts (rename, delete)
# Bulk deletes keys start with "prefix"
EVAL "for i, name in ipairs(redis.call('KEYS', 'prefix*')) do redis.call('DEL', name); end" 0
# Bulk renames keys start with "prefix" to "postfix".
# e.g. prefixwithtail -> postfixwithtail
EVAL "for i, name in ipairs(redis.call('KEYS', 'prefix*')) do local x = string.gsub(name, 'pre', 'post'); redis.call('RENAME', name, x); end" 0
@hbasria
hbasria / gist:c2cb6451b29eefe083d1e34808f1047a
Created March 21, 2021 16:31
FreeIPA Password Expiry Notification Script for Red Hat Identity Management
#!/bin/bash
# https://gosysop.com/freeipa-password-expiry-notification-script-for-red-hat-identity-management/
# notifies people a set number of days before expiry, once via email
# open a kerberos ticket using keytab authentication
# the following keytab file was made using ktutil with rc4-hmac
/usr/bin/kinit admin@YOURDOMAIN.COM -k -t /sextoys/admin.keytab
ext_if="vtnet0"
icmp_types = "{ echoreq unreach }"
table <bruteforce> persist
table <rfc6890> { 0.0.0.0/8 10.0.0.0/8 100.64.0.0/10 127.0.0.0/8 169.254.0.0/16 \
172.16.0.0/12 192.0.0.0/24 192.0.0.0/29 192.0.2.0/24 192.88.99.0/24 \
192.168.0.0/16 198.18.0.0/15 198.51.100.0/24 203.0.113.0/24 \
240.0.0.0/4 255.255.255.255/32 }
@hbasria
hbasria / README.md
Created June 22, 2020 23:31 — forked from mrbar42/README.md
Secured HLS setup with Nginx as media server

Secured HLS setup with Nginx as media server

This example is part of this article.

This is an example for an HLS delivery with basic security. Nginx compiled with nginx-rtmp-module & secure-link is used as media server. Features:

  • Domain filtering
  • Referrer filtering
  • Embed buster