Skip to content

Instantly share code, notes, and snippets.

Kiss, György kissgyorgy

View GitHub Profile
kissgyorgy / ternary.go
Created Sep 30, 2019
Ternary operator in Go
View ternary.go
package main
import "fmt"
type ternary struct {
conditionIsTrue bool
trueValue interface{}
func If(condition bool) *ternary {
kissgyorgy /
Created Sep 26, 2019
Bash: Run go tests with rakyll/gotest
# Run gotest with the module name found in go.mod in the current directory
# gotest is:
gote () {
# run in a subshell, so errexit will exit the subshell, not the terminal shell
set -eo pipefail
local options
local test_path
local module_name
kissgyorgy / plex.conf
Last active Sep 5, 2019
nginx configuration for Plex
View plex.conf
server {
listen 443 ssl http2;
location / {
include proxy_params;
# This is for proxying websocket connections for the web interface
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
kissgyorgy /
Last active Mar 29, 2020
List movies from Plex database
import sqlite3
from urllib.parse import unquote, parse_qs
PLEX_DB = '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db'
conn = sqlite3.connect(PLEX_DB)
res = conn.execute('SELECT hints FROM media_items WHERE library_section_id = 1;')
kissgyorgy /
Created Aug 21, 2018 — forked from denji/
NGINX tuning for best performance

Moved to git repository:

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

kissgyorgy /
Created May 25, 2018 — forked from rbarrois/
Django uWSGI warmup
# -*- coding: utf-8 -*-
import io
import os
import sys
import time
import wsgiref.util
import uwsgidecorators
kissgyorgy /
Last active Feb 21, 2018
Python: CPython integer optimization
>>> import copy
>>> copy.deepcopy(257) is copy.deepcopy(257)
>>> a = copy.deepcopy(257)
>>> b = copy.deepcopy(257)
>>> a is b
kissgyorgy /
Last active Jan 22, 2018
Python3: load multiple SQLite rows into one NamedTuple object
import sqlite3
from typing import namedtuple
class Environment(NamedTuple):
conn = sqlite3.connect('config.db')
conn.row_factory = sqlite3.Row
View parse_cert_pem.go
certPem := result.Data["certificate"]
certString := certPem.(string)
certBytes := []byte(certString)
block, _ := pem.Decode(certBytes)
cert, err := x509.ParseCertificate(block.Bytes)
kissgyorgy / go_version.go
Created Jun 5, 2017
Python vs Go HTTP Request
View go_version.go
func (b *vaultBackend) Version() string {
r := b.client.NewRequest("GET", "/v1/sys/health")
resp, err := b.client.RawRequest(r)
if err != nil {
defer resp.Body.Close()
var result struct {
Version string
You can’t perform that action at this time.