Skip to content

Instantly share code, notes, and snippets.

View mustafaturan's full-sized avatar

Mustafa Turan mustafaturan

View GitHub Profile
@mustafaturan
mustafaturan / rename.sh
Created July 8, 2017 14:18
Rename all js files into jsx
for x in *.js; do mv "$x" "${x%.js}.jsx"; done
@mustafaturan
mustafaturan / network-tweak.md
Last active February 29, 2024 15:08
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@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 / 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 / activate_spark_session.ipynb
Last active August 6, 2023 21:55
Bash script to run jupyter notebook for python3 and pyspark
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mustafaturan
mustafaturan / docker-compose-agent.yaml
Last active July 22, 2023 04:52
Install Monitoring Tools with Docker
# Using this composer in the machines that a specific app runs which opens the port for prometheus
# Using promtail collect logs and publish to external loki
version: '3.8'
networks:
monitoring:
driver: bridge
services:
cadvisor:

Monitoring Libp2p

Libp2p is one of most commonly used libraries across web3 infrasture. It exposes several metrics compatible with Prometheus.

The official github repo has Grafana dashboard json for a quick start.

@mustafaturan
mustafaturan / connected-devices.sh
Created July 17, 2023 00:19
Wifi access point connected devices
#!/bin/bash
ip neigh show dev wlan0
@mustafaturan
mustafaturan / prevent-sleep.md
Last active July 12, 2023 04:28
Prevent raspberry pi 4b to sleep
  1. Set screen blanking: sudo raspi-config nonint do_blanking 0
  2. Set lingering: sudo loginctl enable-linger $(whoami)
  3. If above two does not work sudo setterm -powerdown 0 and sudo setterm -powersave off
@mustafaturan
mustafaturan / postman-pre-script.js
Last active July 9, 2023 04:42
Postman Script for JWT with MD5 request body
var removeIllegalCharacters = function(input) {
return input
.replace(/=/g, '')
.replace(/\+/g, '-')
.replace(/\//g, '_');
};
var base64object = function(input) {
var inputWords = CryptoJS.enc.Utf8.parse(JSON.stringify(input));
var base64 = CryptoJS.enc.Base64.stringify(inputWords);