Skip to content

Instantly share code, notes, and snippets.

@denji
denji / nginx-tuning.md
Last active August 7, 2025 09:49
NGINX tuning for best performance

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.

@unisys12
unisys12 / compassless-vertical-carousel.scss
Last active January 3, 2016 02:09
This is the SCSS used to run the vertical carousel on the landing page of raycocopiers.com. At this moment, it requires Compass. Hoping to rewrite it to be a lot more agnostic for future use.
@woozyking
woozyking / cache_mongo_ids.py
Last active December 23, 2019 22:38
Cache MongoDB Document IDs in Redis SET with Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pymongo import MongoClient
from bson import ObjectId
import redis
def cache_ids(db, cache, cache_key, reset=True, limit=1000):
if reset:
@nolanlawson
nolanlawson / completion-for-gradle.md
Last active September 25, 2024 12:51
Gradle tab completion for Bash. Works on both Mac and Linux.

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]
// webpack is a module bundler
// This means webpack takes modules with dependencies
// and emits static assets representing those modules.
// dependencies can be written in CommonJs
var commonjs = require("./commonjs");
// or in AMD
define(["amd-module", "../file"], function(amdModule, file) {
// while previous constructs are sync
// this is async
var express = require('express'),
app = express(),
server = require('http').createServer(app);
io = require('socket.io').listen(server),
jwt = require("jwt-simple"),
secret = "dgv33rggr3ewsfsf23gf2grwrf",
crypto = require('crypto'),
uuid = require('node-uuid'),
geoip = require('geoip-lite'),
storeStats = require('./storeStats.js'),
@milingo
milingo / bash.md
Last active April 21, 2017 08:19
Useful shell commands

###tcpdump: tcpdump -lnnvi any -w tcpdump-xvm18.out -s 0

###To list all open ports and their processes: sudo netstat -lpAinet

###To get ips without hostnames: sudo netstat -lpnAinet

###To list only what's using tcp port 443:

@zwacky
zwacky / better-git-log.sh
Created March 4, 2014 10:15
Beautified and better git log history output
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
# usage: git lg
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active June 8, 2025 15:03
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@thomasfr
thomasfr / iptables.sh
Last active October 17, 2024 07:55
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers