Skip to content

Instantly share code, notes, and snippets.

View az09's full-sized avatar
🔥
Working from everywhere

Anton Belichkov az09

🔥
Working from everywhere
View GitHub Profile
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 16, 2024 15:14
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%'
@umputun
umputun / pi-radio-mpd.py
Last active October 7, 2018 21:28
pi-radio-mpd - my simple wrapper for mpd to serve rest/json kind of api. working just fine on my RPi.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import web, json, time, mpd, collections
STATIONS = {
"FoxNews" : "mmsh://209.107.209.181:80/D/138/13873/v0001/reflector:24137?MSWMExt=.asf",
"Classic" : "http://radio02-cn03.akadostream.ru:8100/classic128.mp3",
"Jazz": "http://streaming208.radionomy.com:80/A-JAZZ-FM-WEB"
}
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 16, 2024 10:46
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
# install epel repo
sudo yum -y install wget
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh epel-release-latest-7.noarch.rpm
wget http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
sudo rpm -Uvh pgdg*.rpm
# update (again)
sudo yum -y update
@Komzpa
Komzpa / upgrade-postgres-9.4-to-9.5-to-9.6-to-10.md
Last active January 15, 2021 18:04 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.4 to 9.5 to 9.6 to 10 when upgrading Ubuntu 14.10 to 16.04

TL;DR

9.4 -> 9.5:

sudo pg_dropcluster 9.5 main --stop
sudo service postgresql stop
sudo pg_upgradecluster -m upgrade -k 9.4 main
sudo su postgres -c "/usr/lib/postgresql/9.5/bin/vacuumdb --all --analyze-in-stages"
sudo pg_dropcluster 9.4 main
@dideler
dideler / bot.rb
Last active July 15, 2024 06:56
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@Firefishy
Firefishy / gist:928cfb2d4a4bd9d4dcbeb9e6aa5fd8a0
Created January 3, 2019 20:27
% OpenStreetMap Tile Bandwidth Traffic increase over last ~ 6 months
SN: 603.983%
TR: 480.698%
MY: 395.515%
SA: 229.806%
UY: 217.383%
VN: 177.495%
TH: 176.646%
DZ: 158.348%
PK: 156.190%
IR: 147.665%
@broadwaylamb
broadwaylamb / strava_auth.py
Created March 19, 2021 12:24
Automatic High-Res Strava Heatmap TMS link generator
#!/usr/bin/env python3
"""Automatic High-Res Strava Heatmap TMS link generator
This script signs in your Strava account using https://github.com/nnngrach/strava_auto_auth,
extracts the cookies and forms a TMS link that you can use in apps like OsmAnd or JOSM.
On macOS, leverages the keychain, so you don't have to type login and password every time.
Requires Docker.