Skip to content

Instantly share code, notes, and snippets.

View cyakimov's full-sized avatar
🏠
Working from home

Carlos Yakimov cyakimov

🏠
Working from home
  • Falabella
  • Santiago, Chile
View GitHub Profile
@cyakimov
cyakimov / restic_backup.sh
Created November 30, 2021 00:07 — forked from kennethso168/restic_backup.sh
My Backup Solution
#!/bin/bash
# Location of your restic repo
export RESTIC_REPOSITORY=/run/media/kenneth/MyBook/restic
# Password of the restic repo
# Use a keyring to store the password so it isn't stored in plaintext on disk
# Install python-keyring (Arch) to use this command
export RESTIC_PASSWORD=`keyring get restic MyBook`
if ! restic snapshots

📂 Minimize allocations in Go

Working with protobuf in Go puts significant load on the memory subsystem, as protobuf-generated structures often contain a significant amount of pointers.

One way to minimize the number of allocations is to allocate all the fields at the same time, and then use internal pointers to wire them up.

Let's pretend you have (the generated Go code for) four messages A, B, C, and D (note: for clarity this is not really protobuf-generated code, but the technique

A good commit message looks like this:
Header line: explaining the commit in one line
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc etc.
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
@cyakimov
cyakimov / external.go
Created October 31, 2018 18:23 — forked from scholzj/external.go
SASL EXTERNAL in Go
package main
import (
"fmt"
"qpid.apache.org/electron"
"os"
"crypto/tls"
"io/ioutil"
"crypto/x509"
)
@cyakimov
cyakimov / build.sh
Created April 20, 2018 19:01 — forked from bobbytables/build.sh
Protocol Buffer build script for multiple folders
#!/usr/bin/env bash
# This script is meant to build and compile every protocolbuffer for each
# service declared in this repository (as defined by sub-directories).
# It compiles using docker containers based on Namely's protoc image
# seen here: https://github.com/namely/docker-protoc
set -e
REPOPATH=${REPOPATH-/opt/protolangs}
CURRENT_BRANCH=${CIRCLE_BRANCH-"branch-not-available"}

Keybase proof

I hereby claim:

  • I am cyakimov on github.
  • I am cyakimov (https://keybase.io/cyakimov) on keybase.
  • I have a public key ASCuOWo5mg1TfVyIDl3lQD3SHGQ9ShXmardWNfs_wGl5bQo

To claim this, I am signing this object:

@cyakimov
cyakimov / nuke-firebase-db-and-users-referenced-therein.js
Created July 1, 2017 17:14 — forked from cliffhall/nuke-firebase-db-and-users-referenced-therein.js
Nuke a Firebase Database and All User Accounts Referenced Therein
// NOTE: Accounts that are not represented in your /users node will not be deleted!
// BLOG: There are other approaches, see: http://cliffordhall.com/2017/04/nuke-firebase-db-and-all-users/
"use strict";
// Get credentials and initialize firebase app
console.log("With the power vested in the admin user, lay waste the database and all its users!");
let admin = require("firebase-admin");
let serviceAccount = require([__dirname, "service-account-key.json"].join('/'));
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
@cyakimov
cyakimov / default.vcl
Created June 1, 2016 21:29 — forked from reifman/default.vcl
Example Varnish VCL Configuration e.g. /etc/varnish/default.vcl
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
.max_connections = 800;
}
@cyakimov
cyakimov / Ansible-Vault how-to.md
Created May 21, 2016 15:05 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

# file name terraform/modules/aws_vpc/vpc.tf
# first create the VPC.
# Prefix resources with var.name so we can have many environments trivially
resource "aws_vpc" "mod" {
cidr_block = "${var.cidr}"
enable_dns_hostnames = "${var.enable_dns_hostnames}"
enable_dns_support = "${var.enable_dns_support}"
tags {
Name = "${var.env}_vpc"