Skip to content

Instantly share code, notes, and snippets.

@adrianlungu
adrianlungu / go-stream-http-resp-01.go
Created December 6, 2017 13:17
Golang streaming to http response #01
buf := make([]byte, 4096)
for {
n, err := gReader.Read(buf)
if err != nil {
if err == io.EOF {
_, err = c.Response().Write(buf[:n])
if err != nil {
@adrianlungu
adrianlungu / go-stream-http-resp-02.go
Created December 6, 2017 13:19
Golang streaming to http response #02
for {
_, err := io.CopyN(c.Response(), gReader, 4096)
if err == io.EOF {
c.Response().Flush()
break
} else if err != nil {
return err
}
@adrianlungu
adrianlungu / gist:67a5e349e16252e0b9cbe89aced51c84
Created October 2, 2019 07:52
Bash History per iTerm Tab/Session
# Unique history file per shell session.
export HISTSIZE=1000
export HISTFILE=~/.bash-history-${ITERM_SESSION_ID}
# export HISTFILE=$HOME/.bash_hist_${HOSTNAME/.*/}_$(basename $(tty))
export SAVEHIST=1000
# New - remove if not working properly
export HISTCONTROL=ignoreboth
# export HISTCONTROL=ignoredups
# For iTerm2 to show the directory it's in
@adrianlungu
adrianlungu / .bash_profile
Created November 1, 2019 14:19
Bash history for iTerm - 2019
# ITERM SESSION ID seems to have puctuation in it, replace with slash
export SESSION_ID=${ITERM_SESSION_ID//:/-}
# Unique history file per shell session.
export HISTSIZE=500
# Get only the window/tab indices as ID (w0t0p0) as the Session ID can change
# after updates/restarts/etc...
export HISTFILE="${HOME}/.bash-history-${SESSION_ID:0:6}"
# export HISTFILE="~/bash_history/.bash-history"
### Keybase proof
I hereby claim:
* I am adrianlungu on github.
* I am adrianlungu (https://keybase.io/adrianlungu) on keybase.
* I have a public key ASBaYoW_4AgyOvC14u2ZcWkFfiw8isJ4Jxmv59IMmfFaUgo
To claim this, I am signing this object:
@adrianlungu
adrianlungu / gist:cfaeabd87cb2c5eb52b7138e0227e58c
Created June 29, 2020 13:55
IntelliJ Placeholder Find and Replace
Find: .Prepare\("(.*)"
Replace: .PrepareContext("$1"
package testing
import (
"fmt"
"github.com/google/go-cmp/cmp"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
@adrianlungu
adrianlungu / clear_space.sh
Created December 3, 2020 00:29
Delete oldest directory in another directory when hdd is out of space
#!/bin/bash
#
# prune_dir - prune directory by deleting files if we are low on space
#
DIR=$1
CAPACITY_LIMIT=$2
if [ "$DIR" == "" ]
then
echo "ERROR: directory not specified"
@adrianlungu
adrianlungu / LeagueOfLegends.sh
Created October 2, 2021 19:22
Start League of Legends on BigSur to get Voice Permission
#!/bin/bash
cd '/Applications/League of Legends.app/Contents/LoL/'
./LeagueClient.app/Contents/MacOS/LeagueClient
@adrianlungu
adrianlungu / gist:fb055c4d8cee026bbb2792d86553b119
Created June 22, 2022 18:36
M1 Pro coreaudiod console logs while audio interruptions happen
default 21:27:34.904306+0300 coreaudiod CAReportingClient.mm:480 stopping (
409946038468614
)
default 21:27:34.904433+0300 coreaudiod CAReportingClient.mm:508 message {
"session_duration" = "13.56053006649017";
}: (
409946038468614
)
default 21:27:34.905257+0300 coreaudiod IO Stopped Context 478 after 648192 frames.
default 21:27:34.905338+0300 coreaudiod HALS_IOContext_Legacy_Impl::IOThreadEntry: 478 AppleUSBAudioEngine:Focusrite:Scarlett 2i2 USB:1100000:1,2 (AppleUSBAudioEngine:Focusrite:Scarlett 2i2 USB:1100000:1,2): stopping with error 0