Skip to content

Instantly share code, notes, and snippets.

View mustafaturan's full-sized avatar

Mustafa Turan mustafaturan

View GitHub Profile
@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
@mustafaturan
mustafaturan / rename.sh
Created August 24, 2017 09:33
Copy all .example files in a folder with removal of .example extension.
for f in *.example; do
cp -- "$f" "${f%.example}"
done
@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);
@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
def flatten(list, root = [])
list.each do |item|
item.is_a?(Array) ? flatten(item, root) : root.push(item)
end
root
end
test ".flatten" do
list = [[1,2,[3]],4, [9], 11]
assert_equal list.flatten, flatten(list)
@mustafaturan
mustafaturan / network-tweak.md
Last active June 17, 2025 21:44
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 / cerficate-fetcher.sh
Created February 28, 2017 00:46
Fetch Certificate From A Web Page
#!/usr/bin/env bash
openssl s_client -connect {hostname}:{port} -showcerts
@mustafaturan
mustafaturan / Procfile
Last active July 2, 2018 18:20
Configurations for Phoenix Framework 'Deploy To Heroku' button
web: MIX_ENV=prod mix phoenix.server