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

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 / 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
@pmatseykanets
pmatseykanets / README.md
Created April 21, 2018 03:30 — forked from sieyip/README.md
Installing Kafka on Mac OS X

Installing Kafka on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@pmatseykanets
pmatseykanets / free_email_provider_domains.txt
Created February 22, 2018 16:52 — forked from tbrianjones/free_email_provider_domains.txt
A list of free email provider domains. Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
1033edge.com
11mail.com
123.com
123box.net
123india.com
123mail.cl
123qwe.co.uk
150ml.com
15meg4free.com
163.com
@pmatseykanets
pmatseykanets / gist:3c1b373dd9f810779d228418aee69bf7
Created December 7, 2017 16:25 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@pmatseykanets
pmatseykanets / gist:c5c40eaf0db594f8a715691c3963ddbb
Created August 28, 2017 12:58 — forked from liunian/gist:9338301
Human Readable File Size with PHP
<?php
# http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
echo human_filesize(filesize('example.zip'));
@pmatseykanets
pmatseykanets / states_hash.json
Created October 19, 2016 22:28 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@pmatseykanets
pmatseykanets / str_putcsv.php
Last active August 29, 2015 14:22 — forked from johanmeiring/gist:2894568
Format line as CSV
<?php
/* Forked from https://gist.github.com/johanmeiring/2894568 */
if (! function_exists('str_putcsv'))
{
function str_putcsv($input, $delimiter = ',', $enclosure = '"')
{
// Open a memory "file" for read/write
$memory = fopen('php://temp', 'r+');
// Write the $input array to the "file" using fputcsv()
$length = fputcsv($memory, $input, $delimiter, $enclosure);