Skip to content

Instantly share code, notes, and snippets.

View mustafaturan's full-sized avatar

Mustafa Turan mustafaturan

View GitHub Profile
@mustafaturan
mustafaturan / list-open-ports.md
Created May 17, 2019 04:02
List open ports with programs/pids

List open ports

Long version

netstat --tcp --listening --programs --numeric

Short version

netstat -tlpn
@mustafaturan
mustafaturan / ssh-key-login-on-pie.md
Created May 17, 2019 03:24
Login via private ssh key on Raspberry Pi
cd
mkdir ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
sh -c 'echo "ssh-rsa ... sample@example.com" >> ~/.ssh/authorized_keys'
chmod 600 ~/.ssh/authorized_keys
@mustafaturan
mustafaturan / docker-on-pi-rootless.sh
Last active January 19, 2024 01:34
Install docker and run without sudo on Raspberry Pi
#!/bin/bash
curl -fsSL https://get.docker.com/rootless | sh
# Content to be added to .bashrc
content='export PATH="$HOME/bin:$PATH"'
# Check if content already exists in .bashrc
if grep -Fxq "$content" ~/.bashrc; then
echo "Content for bin path already exists in .bashrc. Skipping addition."
@mustafaturan
mustafaturan / go-tips.md
Last active April 14, 2019 01:05
Go lang tips

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@mustafaturan
mustafaturan / chunk.go
Created February 5, 2019 07:00
Go / Chunk Slice
# https://play.golang.org/p/JxqibtHkuO-
func chunkBy(items []string, chunkSize int) (chunks [][]string) {
for chunkSize < len(items) {
items, chunks = items[chunkSize:], append(chunks, items[0:chunkSize:chunkSize])
}
return append(chunks, items)
}
@mustafaturan
mustafaturan / setup-protobuf-mac.sh
Created February 2, 2019 05:48
Install protobuf on Mac
#!/bin/bash
wget https://github.com/protocolbuffers/protobuf/archive/v3.7.0rc2.tar.gz
tar -zxvf protobuf-3.7.0rc2.tar.gz
cd protobuf-3.7.0rc2
./autogen.sh
./configure
make
make install
@mustafaturan
mustafaturan / json.ex
Last active August 6, 2018 17:48
Wrapper for the fastest Elixir JSON encode/decode library
defmodule JSON do
@moduledoc false
@encode_opts [:use_nil]
@decode_opts [:return_maps, :use_nil]
alias :jiffy, as: Jiffy
@doc """
Encode and return tuple
@mustafaturan
mustafaturan / base62.ex
Created June 25, 2018 06:02
Base62 in Elixir
defmodule Base62 do
@moduledoc """
Base62 encoder
Copied from: https://github.com/otobus/event_bus/commit/956ffd93d854fb3a721aa7763c3da509cffedd41#diff-31f9094877d525a1b8387d4135042006R1
"""
@mapping '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
@doc """
Converts given integer to base62
@mustafaturan
mustafaturan / multiple-redis-setup.sh
Created May 30, 2018 07:01
Multiple Redis servers on one Centos machine
#!/bin/bash
################################################################################
# Second Redis server with port 49263
################################################################################
# Create dir for storage
sudo mkdir /var/lib/redis/49263
# Copy conf