Skip to content

Instantly share code, notes, and snippets.

View vbratkev's full-sized avatar

Valeriy Bratkevich vbratkev

View GitHub Profile
@vbratkev
vbratkev / pool.go
Created October 15, 2021 15:29 — forked from bodokaiser/pool.go
Request worker pool written in Go.
package pool
import (
"fmt"
"net/http"
"sync"
)
var (
MaxPoolQueue = 100
package main
import (
"errors"
"sync"
)
func test(i int) (int, error) {
if i > 2 {
return 0, errors.New("test error")
@vbratkev
vbratkev / protobuf_struct_converter.go
Created October 4, 2021 07:59 — forked from dschowta/protobuf_struct_converter.go
golang: grpc: interface or map type conversion to protobuf struct using protojson .
// Conversion of interface{} or map[string]interface{} types to protobuf struct ("google/protobuf/struct.proto").
package codec
import (
"encoding/json"
structpb "github.com/golang/protobuf/ptypes/struct"
"google.golang.org/protobuf/encoding/protojson"
)
#!/bin/bash
# Write given argument into current iterm session. (useful if running commands from another application).
osascript - "$@" <<EOF
on run argv
tell application "iTerm2"
tell current session of current window
repeat with arg in argv
write text arg
end repeat
end tell
@vbratkev
vbratkev / nginx-cors.conf
Created June 28, 2021 20:35 — forked from algal/nginx-cors.conf
nginx configuration for CORS (Cross-Origin Resource Sharing), with an origin whitelist, and HTTP Basic Access authentication allowed
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests
@vbratkev
vbratkev / iam-terraform-create-policy.tf
Created May 31, 2021 08:31 — forked from arsdehnel/iam-terraform-create-policy.tf
AWS IAM policies for running Terraform from an EC2 instance.
resource "aws_iam_policy" "terraform_create_policy" {
name = "terraform_create_policy"
path = "/"
policy = "${data.aws_iam_policy_document.terraform_create_policy.json}"
}
data "aws_iam_policy_document" "terraform_create_policy" {
statement {
sid = "1"
actions = [
{
"Version": "2012-10-17",
"Statement": [{
"Action": "ec2:*",
"Effect": "Allow",
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:Region": [
"us-east-1",
@vbratkev
vbratkev / AnsibleVaultDiff.md
Created April 6, 2021 08:44 — forked from leedm777/AnsibleVaultDiff.md
Ansible vault diff in Git

Normally, when you diff an [Ansible vault][], all you see is gibberish.

$ git diff -- group_vars/all/vault.yml
diff --git a/group_vars/all/vault.yml b/group_vars/all/vault.yml
index 245ccf4..90bf9ee 100644
--- a/group_vars/all/vault.yml
+++ b/group_vars/all/vault.yml
@@ -1,111 +1,111 @@
 $ANSIBLE_VAULT;1.1;AES256
@vbratkev
vbratkev / android-client.ovpn
Created September 30, 2020 16:08 — forked from renatolfc/android-client.ovpn
A sample OpenVPN client configuration file in the unified format
client
dev tun
remote example.com
resolv-retry infinite
nobind
persist-key
persist-tun
ca [inline]
cert [inline]
key [inline]
@vbratkev
vbratkev / wipe.sh
Created September 4, 2020 12:02 — forked from UmbrielSecurity/wipe.sh
wipe.sh - a disk zeroing utility
#!/bin/bash
# Tool declarations, modify as needed.
AWK="/usr/bin/awk"
CAT="/bin/cat"
COMM="/usr/bin/comm"
CUT="/usr/bin/cut"
DATE=`/bin/date +%Y/%m/%d`
DD="/bin/dd"
GREP="/bin/grep"