Skip to content

Instantly share code, notes, and snippets.

@MichaelMonashev
MichaelMonashev / warn.go
Created May 18, 2020 18:33
Golang async logger
package warn
import (
"errors"
"fmt"
"io"
"log"
"os"
"path/filepath"
"runtime"
@tavinus
tavinus / nextcloud-onlyoffice.md
Last active November 2, 2023 20:27
debian 8 + nextcloud + onlyoffice + nginx + mariadb + redis + rabbitmq

debian 8 + nextcloud + onlyoffice + nginx + mariadb + redis + rabbitmq

How to run everything on a single Debian install

About

This guide was compiled from the notes and logs of two re-installs
I made on Debian 8 (Jessie) servers running Owncloud on Apache.

I have basically removed and reinstalled everything except the database
contents and the users files, while also migrating from owncloud to nextcloud.

@drewchapin
drewchapin / bash_coproc_example.sh
Last active January 3, 2024 11:13
Example of how to use the COPROC feature of Bash by showing a progress bar with zenity and updating it.
#!/bin/bash
on_exit() {
echo "#The script has quit unexpectidly on line $1" >&$z
echo "The script has quit unexpectidly on line $1" >&2
exit
}
on_error() {
echo "Error on line $1"
#!/bin/bash
# a tool to extract data from those MS Winsoze "web-archives" arrived as a ".DOC" file...
# run as ```splitmime.sh < /tmp/where-it-is.doc``` and check for "./C_/" directory.
div=''
typeset -i nl=0
typeset -i ol=0
file_header='yes'
header='no'
@ergo70
ergo70 / notify.py
Created November 13, 2016 17:54
psycopg2 asynchronous notifications w. LISTEN/NOTIFY
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 13 00:00:06 2016
@author: ergo
"""
import select
import psycopg2
import psycopg2.extensions
@drmalex07
drmalex07 / README-python-service-on-systemd-activated-socket.md
Last active July 4, 2024 07:29
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at /opt/foo/serve.py.

@kgriffs
kgriffs / sample.py
Last active March 26, 2017 01:33
Falcon Web Framework (http://falconframework.org)
# sample.py
import falcon
import json
class QuoteResource:
def on_get(self, req, resp):
"""Handles GET requests"""
quote = {
'quote': 'I\'ve always been more interested in the future than in the past.',
'author': 'Grace Hopper'
@dtheodor
dtheodor / listen_sqla.py
Last active August 7, 2023 11:38
Listen for pg_notify with SQL Alchemy + Psycopg2
import select
import datetime
import psycopg2
import psycopg2.extensions
from sqlalchemy import create_engine, text
engine = create_engine("postgresql+psycopg2://vagrant@/postgres")
@typehorror
typehorror / Flask-SQLAlchemy Caching.md
Last active February 15, 2024 14:44
Flask SQLAlchemy Caching

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.

Usage

retrieve one object

# pulling one User object

user = User.query.get(1)

@TemporaryJam
TemporaryJam / Howto convert a PFX to a seperate .key & .crt file
Last active April 4, 2024 10:52
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`