Skip to content

Instantly share code, notes, and snippets.

View Ryouku's full-sized avatar
💭
I may be slow to respond.

Zy Ryouku

💭
I may be slow to respond.
View GitHub Profile
@Ryouku
Ryouku / nginx.toml
Created April 28, 2025 06:19 — forked from yellow1912/nginx.toml
Sample Vector configuration for nginx
# be careful, you will gets tons of logs
# you may want to skip access logs or use sampling only here
[sources.nginx_access_logs]
type = "file"
include = ["/var/log/sites/*/*/*/*/nginx/access.log"] # supports globbing
ignore_older = 86400 # 1 day
# I'm configuring my nginx to use json logs, if you use another logging format you need to change this
[transforms.nginx_access_logs_json]
type = "json_parser"
@Ryouku
Ryouku / README.md
Created February 23, 2021 07:38 — forked from zytek/README.md
Terraform to manage AWS RDS PostgreSQL databases, users and owners

Terraform vs PostgreSQL RDS

Thanks to new resources (postgresql_default_priviledges) and some fixes Terraform can now add new databases and manage ownership / access to them.

This example creates new database and two users. You can use owner to create new tables and run migrations and user for normal read/write access to database.

@Ryouku
Ryouku / Howto convert a PFX to a seperate .key & .crt file.md
Created November 5, 2020 16:05 — forked from junxy/Howto convert a PFX to a seperate .key & .crt file.md
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]

@Ryouku
Ryouku / asp.sh
Created November 5, 2020 07:54 — forked from mgoodness/asp.sh
Bash/Zsh function for switching AWS profiles (supports sts assume-role)
function asp {
if [[ -z "$1" ]]; then
if [[ -z "$AWS_DEFAULT_PROFILE" ]]; then
echo "No profile set"
else
asp "$AWS_DEFAULT_PROFILE"
echo "$AWS_DEFAULT_PROFILE"
fi
else
if ! fgrep -q "[profile $1]" ~/.aws/config; then
#!/usr/bin/env python2.7
from __future__ import print_function
import commands
import os
import stat
from gitlab import Gitlab
def get_clone_commands(token, repo_root):
con = Gitlab("http://gitlab.your.domain", token)
@Ryouku
Ryouku / backpressure.go
Created April 11, 2018 06:35 — forked from marianogappa/backpressure.go
Example backpressure implementation in Go
/*
This snippet is an example of backpressure implementation in Go.
It doesn't run in Go Playground, because it starts an HTTP Server.
The example starts an HTTP server and sends multiple requests to it. The server starts denying
requests by replying an "X" (i.e. a 502) when its buffered channel reaches capacity.
This is not the same as rate-limiting; you might be interested in https://github.com/juju/ratelimit
or https://godoc.org/golang.org/x/time/rate.
@Ryouku
Ryouku / ordered_parallel.go
Created April 11, 2018 06:35 — forked from marianogappa/ordered_parallel.go
Parallel processing with ordered output in Go
/*
Parallel processing with ordered output in Go
(you can use this pattern by importing https://github.com/MarianoGappa/parseq)
This example implementation is useful when the following 3 conditions are true:
1) the rate of input is higher than the rate of output on the system (i.e. it queues up)
2) the processing of input can be parallelised, and overall throughput increases by doing so
3) the order of output of the system needs to respect order of input
- if 1 is false, KISS!
@Ryouku
Ryouku / round.go
Created January 5, 2018 13:48 — forked from pelegm/round.go
package main
import (
"log"
"math"
)
func Round(val float64, roundOn float64, places int ) (newVal float64) {
var round float64
pow := math.Pow(10, float64(places))
@Ryouku
Ryouku / Makefile
Created December 27, 2017 09:43 — forked from turtlemonvh/Makefile
Golang Project Makefile Template
# Borrowed from:
# https://github.com/silven/go-example/blob/master/Makefile
# https://vic.demuzere.be/articles/golang-makefile-crosscompile/
BINARY = superdo
VET_REPORT = vet.report
TEST_REPORT = tests.xml
GOARCH = amd64
VERSION?=?
@Ryouku
Ryouku / README.md
Created December 14, 2017 12:47 — forked from magnetikonline/README.md
Nginx FastCGI cache configuration example.

Nginx FastCGI cache

Example /etc/nginx/nginx.conf using FastCGI (e.g. to PHP-FPM) with FastCGI cache enabled. This will capture returned data and persist it to a disk based cache store for a configurable amount of time, great for robust full page caching.

Will need to create a directory to hold cache files, for the example given here that would be:

$ sudo mkdir -p /var/cache/nginxfastcgi
$ chown www-data: /var/cache/nginxfastcgi