Skip to content

Instantly share code, notes, and snippets.

@jaffarc
jaffarc / gist:3045707e752730b67fb49b32eff5d627
Last active April 26, 2016 01:36
check modified files. Nodejs
var fs = require('fs'),
path = require('path'),
caminho = path.resolve("..\\content\\");
var Config = function () {};
Config.prototype.modification = function (){
var arr = [],
Data = [{
itens : []
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul>
<li>aaa</li>
<li>bbb</li>
@jaffarc
jaffarc / mongo_backup.sh
Created April 22, 2018 02:19 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@jaffarc
jaffarc / start-mongo-replset.sh
Created September 12, 2018 18:39 — forked from leetreveil/start-mongo-replset.sh
Shell scripts to create a mongodb replica set and sharded cluster locally
#!/bin/bash
# shell script to create a simple mongodb replica set (tested on osx)
set -e
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
default=$(tput sgr0)
@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;
@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 / 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 / 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 / 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 / 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