Skip to content

Instantly share code, notes, and snippets.

View ozgurgul's full-sized avatar

Ozgur Gul ozgurgul

  • London, England
View GitHub Profile
@ozgurgul
ozgurgul / postgres-cheatsheet.md
Created January 6, 2021 15:18 — forked from Kartones/postgres-cheatsheet.md
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)
@ozgurgul
ozgurgul / awesome-python-sorted-by-stars-2019-05-13.md
Created December 1, 2020 11:02 — forked from 5ay3h/awesome-python-sorted-by-stars-2019-05-13.md
awesome-python-sorted-by-stars-2019-05-13.md
pm.sendRequest({
url: 'https://login.microsoftonline.com/' + pm.environment.get("tenantId") + '/oauth2/token',
method: 'POST',
header: 'Content-Type: application/x-www-form-urlencoded',
body: {
mode: 'urlencoded',
urlencoded: [
{key: "grant_type", value: "client_credentials", disabled: false},
{key: "client_id", value: pm.environment.get("clientId"), disabled: false},
{key: "client_secret", value: pm.environment.get("clientSecret"), disabled: false},
@ozgurgul
ozgurgul / ssh-info-docker-vm-windows.sh
Created October 22, 2020 11:32 — forked from jongio/ssh-info-docker-vm-windows.sh
It's not technically SSH, but here's how you can get root access to the VM that runs Docker on your Windows host.
docker run --privileged -it -v /var/run/docker.sock:/var/run/docker.sock jongallant/ubuntu-docker-client
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
chroot /host
@ozgurgul
ozgurgul / flask-mysql-redis-celery.md
Created July 14, 2020 10:03 — forked from bluekvirus/flask-mysql-redis-celery.md
# Develop a Flask Application using MariaDB, Redis and Celery on Ubuntu 14.04+

Develop a Flask Application using MariaDB, Redis and Celery on Ubuntu 14.04

@credit Yan Zhu (https://github.com/nina-zhu)

Introduction

Before you start this guide, you should run through the "How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04" guide. This is necessary in order to set up virtualenv, uWSGI and Nginx. In that guide, we developed a very simple flask application having just 1 file "firstflask.py" with only 9 lines of code, it is a sample for showing you the general steps. In this guide, we will create a complete user session listing application, with login, logout functionality. We will use MariaDB to store the users records, and use Redis to store the session data and background tasks.

Let's get started.

Set Up the MariaDB Server

ON MASTER

$ yum install mariadb-server
$ systemctl restart mariadb
$ systemctl enable mariadb
$ mysql_secure_installation

On /etc/my.cnf, add

@ozgurgul
ozgurgul / ffmpeg-convert-mp3-to-wave
Created June 24, 2020 16:22 — forked from vunb/ffmpeg-convert-mp3-to-wave
Convert mp3 to wave format using ffmpeg
ffmpeg -i input.mp3 -acodec pcm_s16le -ac 1 -ar 16000 output.wav
# To convert all mp3 files in a directory in Linux:
for f in *.mp3; do ffmpeg -i "$f" -acodec pcm_s16le -ac 1 -ar 16000 "${f%.mp3}.wav"; done
# Or Windows:
for /r %i in (*) do ffmpeg -i %i -acodec pcm_s16le -ac 1 -ar 16000 %i.wav
@ozgurgul
ozgurgul / setup_airflow_auth.py
Created June 10, 2020 23:35 — forked from nehiljain/setup_airflow_auth.py
A script to automatically setup a admin user for airflow which can be run at infrastructure setup time.
import os
import airflow
from airflow import models, settings
from airflow.contrib.auth.backends.password_auth import PasswordUser
def create_admin_user(uname, pwd, email):
user = PasswordUser(models.User())
user.username = uname
user.email = email