Skip to content

Instantly share code, notes, and snippets.

View hbasria's full-sized avatar

Basri hbasria

  • base9.tech
  • ///soak.massing.glory
View GitHub Profile
@hbasria
hbasria / postgres_queries_and_commands.sql
Created June 16, 2020 21:56 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

ffmpeg -i input.mp4 -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls index.m3u8

kubectl apply -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.8/deploy/manifests/00-crds.yaml
kubectl create namespace cert-manager
kubectl label namespace cert-manager certmanager.k8s.io/disable-validation="true"
helm repo add jetstack https://charts.jetstack.io
helm repo update
@hbasria
hbasria / cattle-system-patch.sh
Created April 10, 2020 21:19
Cattle-Cluster-Agent: (Could not resolve host: rancher.<server-name>.com)
kubectl -n cattle-system patch deployments cattle-cluster-agent --patch '{
"spec": {
"template": {
"spec": {
"hostAliases": [
{
"hostnames":
[
"{{ rancher_server_hostname }}"
],
@hbasria
hbasria / .gitignore
Created November 14, 2019 08:29 — forked from chrisdone/.gitignore
Linux + BusyBox + QEMU/VirtualBox/USB boot recipe
output/
@hbasria
hbasria / keybase.md
Last active September 13, 2019 13:45

Keybase proof

I hereby claim:

  • I am hbasria on github.
  • I am hbasria (https://keybase.io/hbasria) on keybase.
  • I have a public key ASAzGNiQsLhlHqgmTff9X8Z1GvuBnZ1XXCNMZ-WtO0eOYgo

To claim this, I am signing this object:

@hbasria
hbasria / delete-evicted-pods-all-namespaces.sh
Created July 19, 2019 21:01 — forked from svx/delete-evicted-pods-all-namespaces.sh
Delete evicted pods from all namespaces (also ImagePullBackOff and ErrImagePull)
#!/bin/sh
# based on https://gist.github.com/ipedrazas/9c622404fb41f2343a0db85b3821275d
# delete all evicted pods from all namespaces
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff state from all namespaces
kubectl get pods --all-namespaces | grep 'ImagePullBackOff' | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# delete all containers in ImagePullBackOff or ErrImagePull or Evicted state from all namespaces
@hbasria
hbasria / sqlite_custom_function.py
Created July 18, 2019 14:46
python SQLite custom function
import sqlite3
from netaddr import IPNetwork
def is_private_ip(value):
return IPNetwork(value).is_private()
connection = sqlite3.connect(':memory:')
cur = connection.cursor()
cur.execute("""
SELECT
pgClass.relname AS tableName,
pgClass.reltuples AS rowCount
FROM
pg_class pgClass
LEFT JOIN
pg_namespace pgNamespace ON (pgNamespace.oid = pgClass.relnamespace)
WHERE
pgNamespace.nspname NOT IN ('pg_catalog', 'information_schema') AND
pgClass.relkind='r'
@hbasria
hbasria / smtptest.py
Created April 24, 2018 06:15
smtp test
#!/usr/bin/python
"""smtptest.py: command-line smtp test mail sender
https://github.com/turbodog/python-smtp-mail-sending-tester
Usage: python smtptest.py [options] fromaddress toaddress serveraddress
Examples:
python smtptest.py bob@example.com mary@example.com mail.example.com
python smtptest.py --debuglevel 1 --usetls -u bob -p xyzzy "Bob <bob@example.com>" mary@example.com mail.example.com
At verbose == False and debuglevel == 0, smtptest will either succeed silently or print an error. Setting verbose or a debuglevel to 1 will generate intermediate output.
See also http://docs.python.org/library/smtplib.html
"""