Skip to content

Instantly share code, notes, and snippets.

View pmatseykanets's full-sized avatar
💻
Probably writing some Go code

Peter Matseykanets pmatseykanets

💻
Probably writing some Go code
View GitHub Profile
@pmatseykanets
pmatseykanets / merge_zsh_history.md
Created May 2, 2022 03:57
Merge zsh histtory files
builtin fc -R -I /path/to/history/file1
...
builtin fc -R -I /path/to/history/fileN
# write the loaded history to HISTFILE
builtin fc -W "$HISTFILE"

Vagrant and VMWare Tech Preview on Apple M1 Pro

This document summarizes notes taken while to make the VMWare Tech preview work on Apple M1 Pro, it originated from discussions in hashicorp/vagrant-vmware-desktop#22

Installing Rosetta

First install Rosetta if not already done, this is needed to run x86 code:

@pmatseykanets
pmatseykanets / gist:a15062a7dac2229249256ff311138467
Created May 22, 2020 19:10 — forked from junegunn/gist:f4fca918e937e6bf5bad
Browsing git commit history with fzf
# fshow - git commit browser (enter for show, ctrl-d for diff, ` toggles sort)
fshow() {
local out shas sha q k
while out=$(
git log --graph --color=always \
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
fzf --ansi --multi --no-sort --reverse --query="$q" \
--print-query --expect=ctrl-d --toggle-sort=\`); do
q=$(head -1 <<< "$out")
k=$(head -2 <<< "$out" | tail -1)
@pmatseykanets
pmatseykanets / getPassword.go
Created June 10, 2019 19:38 — forked from jlinoff/getPassword.go
Go code to prompt for password using only standard packages by utilizing syscall.ForkExec() and syscall.Wait4(), recovers from ^C gracefully.
// License: MIT Open Source
// Copyright (c) Joe Linoff 2016
// Go code to prompt for password using only standard packages by utilizing syscall.ForkExec() and syscall.Wait4().
// Correctly resets terminal echo after ^C interrupts.
package main
import (
"bufio"
"fmt"
"os"
@pmatseykanets
pmatseykanets / random_string.go
Created June 10, 2019 18:52
Random string in Go
package main
import (
"math/rand"
"strings"
"time"
)
const (
letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$^*(){}[]|?%&~.,:;"

Keybase proof

I hereby claim:

  • I am pmatseykanets on github.
  • I am pmatseykanets (https://keybase.io/pmatseykanets) on keybase.
  • I have a public key ASBo0Xyy-gP0W8yc8eBDGLwAH_ZtzRq1daPLPMU3dpp70wo

To claim this, I am signing this object:

@pmatseykanets
pmatseykanets / rdstail_start.sh
Created December 29, 2018 21:52
Start rdstail
docker run -dit --rm --restart unless-stopped --env-file /home/user/rdstail/.env --name rdstail rdstail -i dbname papertrail -p logsX.papertrailapp.com:YYYYY --app postgres --hostname rds-dbanme
@pmatseykanets
pmatseykanets / app.service
Created December 29, 2018 21:50
Systemd config for a Go app
[Unit]
Description=App Name
After=network.target
[Service]
EnvironmentFile=-/usr/local/app/.env
ExecStart=/usr/local/app/current/app
WorkingDirectory=/usr/local/app/current
User=nobody
Group=nogroup
@pmatseykanets
pmatseykanets / laravel_read_gzip_from_s3.php
Last active October 23, 2018 16:47
Read the contents of a gzip file from an AWS S3 bucket
<?php
$file = Storage::disk('s3')->readStream('bucket/file.csv.gz');
// gzip format ZLIB_ENCODING_GZIP
// ['window' => 15 + 16]
// auto-detect ZLIB_ENCODING_ANY
// ['window' => 15 + 32]
// See https://github.com/php/php-src/blob/master/ext/zlib/tests/zlib_filter_inflate2.phpt
stream_filter_append($file, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]);
@pmatseykanets
pmatseykanets / php_unserialize_to_json.sql
Created October 22, 2018 20:33 — forked from storeman/php_unserialize_to_json.sql
PHP unserialize in Postgresql to json
/**
Decode a php serialized value to json. This function only supports basic
data types:
- arrays (will always become a json object)
- booleans
- integers
- floats
- strings
- NULL