Skip to content

Instantly share code, notes, and snippets.

@jaffarc
jaffarc / mongodb_iptables.sh
Created December 15, 2020 22:51 — forked from joebarbere/mongodb_iptables.sh
mongodb iptables
#!/bin/bash
# Flush all current rules from iptables
iptables -F
# Allow established connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow MongoDB
iptables -A INPUT -s 10.182.226.217 -p tcp --dport 27017 -j ACCEPT
@jaffarc
jaffarc / gen-ssh-config-for-multipass.fish
Created November 10, 2020 01:19 — forked from shuuji3/gen-ssh-config-for-multipass.fish
Generate a dynamic SSH config file to ssh Multipass using fish shell.
function gen-ssh-config-for-multipass --description "Generate a SSH config for multipass."
echo 'Include ~/.ssh/config
Host mp-*
User multipass
'
set -l vms (multipass ls --format csv | grep Running)
for vm in $vms
set name (echo $vm | awk -F , '{ print $1 }')
set ip (echo $vm | awk -F , '{ print $3 }')
@jaffarc
jaffarc / Setup MongoDB on localhost as Replica Set
Created October 22, 2020 19:42 — forked from davisford/Setup MongoDB on localhost as Replica Set
Setup MongoDB replica set on local host with only a single primary
Add the `replication` section to the mongod.conf file:
```
$cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
engine: mmapv1
@jaffarc
jaffarc / README.md
Created October 11, 2020 23:30 — forked from StefanWallin/README.md
nginx ssl config with multiple SNI vhosts and A+ SSL Labs score as of 2014-11-05

Configuring nginx for SSL SNI vhosts

Gotchas

Remarks

  • My version of konklones SSL config does not have SPDY support(my nginx+openssl does not support it)
  • You need a default ssl server (example.org-default.conf).
  • Some SSL-options have to be unique across your instance, so it's easier to have them in a common file(ssl.conf).
@jaffarc
jaffarc / mongodb_initd.sh
Created August 26, 2020 17:57
MongoDB init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: mongod
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the MongoDB database server
# Description: Starts the MongoDB database server
@jaffarc
jaffarc / gitignore_per_git_branch.md
Created August 13, 2020 20:59 — forked from wizioo/gitignore_per_git_branch.md
HowTo have specific .gitignore for each git branch

How to have specific .gitignore for each git branch

Objective

My objective is to have some production files ignored on specific branches. Git doesn't allow to do it.

Solution

My solution is to make a general .gitignore file and add .gitignore.branch_name files for the branches I want to add specific file exclusion. I'll use post-checkout hook to copy those .gitignore.branch_name in place of .git/info/exclude each time I go to the branch with git checkout branch_name.

@jaffarc
jaffarc / nginx-tuning.md
Created July 4, 2020 23:37 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@jaffarc
jaffarc / gh-rename-master
Created June 12, 2020 15:31 — forked from mislav/gh-rename-master
Rename the default branch of a repository using GitHub CLI https://github.com/cli/cli/releases/tag/v0.10.0
#!/bin/bash
# Usage: gh-rename-master <newbranch> [<remote>]
#
# Renames the "master" branch of the current repository both locally and on GitHub.
#
# dependencies: GitHub CLI v0.10
set -e
newbranch="${1?}"
remote="${2:-origin}"
@jaffarc
jaffarc / log.js
Created May 6, 2020 03:12 — forked from vikas5914/log.js
Custom Logger Library with winston
const { createLogger, format, transports } = require('winston')
const moment = require('moment')
// set default log level.
const logLevel = 'info'
var logger = createLogger({
level: logLevel,
levels: {
fatal: 0,
@jaffarc
jaffarc / domain.tld.conf
Created October 25, 2018 13:33 — forked from natanfelles/domain.tld.conf
Nginx Virtual Host example to work on localhost
# Location: /etc/nginx/sites-available/domain.tld.conf
server {
listen 80;
# listen 443 ssl;
# include snippets/snakeoil.conf;
root /var/www/domain.tld/public;
index index.html index.php;