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 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 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 / 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
@mustafaturan
mustafaturan / linked_list_stack_impl.rb
Last active June 8, 2021 21:07
Ruby Stack Implementation With Linked List
# Mustafa Turan
# coded at 30.11.2015 with NO LICENSE
# Feel free to use/modify/distribute/reimplement
# node.rb
class Node
attr_accessor :node_ref
attr_reader :val
def initialize(node_ref, val)
@mustafaturan
mustafaturan / gitignore
Created January 16, 2015 20:38
remove gitignored files
# remove gitignored files
git rm . -r --cached
git add .
git commit -m "fixed untracked files"
@mustafaturan
mustafaturan / redis-setup.sh
Last active August 29, 2015 14:13
redis setup
#!/usr/bin/env bash
cd /usr/local/src
version=2.8.19
wget http://download.redis.io/releases/redis-$version.tar.gz
tar xzf redis-$version.tar.gz
cd redis-$version
make