Skip to content

Instantly share code, notes, and snippets.

View bsnux's full-sized avatar
💭
👨‍💻

Arturo Fernandez bsnux

💭
👨‍💻
View GitHub Profile
@bsnux
bsnux / kexec.sh
Created June 13, 2019 18:12
Getting terminal access on pod
#!/bin/zsh
app=$1
container=$app
cmd="/bin/bash"
if [[ $2 ]]; then container=$2; fi
if [[ $container == "nginx" ]]; then cmd='/bin/sh'; fi
pod=$(kubectl get pods | grep $app | head -1 | ruby -ne 'puts $_.split(" ")[0]')
@bsnux
bsnux / .vimrc
Created May 7, 2019 16:45
Minimal and portable vim configuration with no plugins
set nocompatible
set termguicolors
set background=dark
filetype on
filetype plugin on
syntax on
set omnifunc=syntaxcomplete#Complete
// Reference: https://golangbot.com/channels/
package main
import (
"fmt"
)
// calcSquares returns the sum of the squares of all digits of given number
// i.e input: 123 . output: (1*1) + (2*2) + (3*3) = 14
func calcSquares(number int, squareop chan int) {
package main
import (
"fmt"
)
func hello(done chan bool) {
fmt.Println("I'm goroutine")
// Sends and receives to a channel are blocking by default
done <- true
@bsnux
bsnux / tmux.md
Last active January 31, 2019 19:39
Simple tmux cheatsheet

tmux cheatsheet

SSH

$ssh <server> -t tmux
$ssh  -t tmux a
@bsnux
bsnux / emptyInterface.go
Created December 7, 2018 20:32
Empty interface and Type assertion
// Reference: https://nanxiao.gitbooks.io/golang-101-hacks/content/posts/type-assertion-and-type-switch.html
package main
import "fmt"
func printValue(v interface{}) {
switch v := v.(type) {
case string:
fmt.Printf("%v is a string\n", v)
case int:
@bsnux
bsnux / polymorphism.go
Created December 7, 2018 01:32
Polymorphism in Go
// Reference: https://golangbot.com/polymorphism/
package main
import (
"fmt"
)
type Income interface {
calculate() int
source() string
@bsnux
bsnux / composition.go
Created December 7, 2018 01:31
Composition over Inheritance
// Reference: https://golangbot.com/inheritance/
package main
import (
"fmt"
)
type author struct {
firstName string
lastName string
@bsnux
bsnux / sync_repos.sh
Created October 23, 2018 22:06
Syncing repos with different URL
#!/bin/zsh
set -e
GIT_SRC="/path/repo1/"
GIT_DEST="/path/repo2/"
BRANCH_SRC="src-branch"
BRANCH_DEST="target-branch"
echo "Gonna rsync *$BRANCH_SRC* from $GIT_SRC on *$BRANCH_DEST* on $GIT_DEST"
@bsnux
bsnux / Dockerfile.nettools
Created October 22, 2018 20:29
Dockerfile for useful net tools
# nettools
FROM library/python:2.7.15-slim-stretch
RUN apt-get update \
&& apt-get -y install net-tools inetutils-ping tcpdump inetutils-traceroute \
nmap traceroute netcat dnsutils iperf3 \
vim nano
CMD ["/bin/bash"]