Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pi0's full-sized avatar

Pooya Parsa pi0

View GitHub Profile
@pi0
pi0 / git_commit.js
Last active November 18, 2019 14:48
Get git commit in one line!
const gitCommit = process.env.GIT_COMMIT || require('child_process')
.spawnSync('git', ['rev-parse', '--short', 'HEAD'], { encoding: 'utf8' })
.stdout.slice(0, -1)
console.log(gitCommit)
{
// Editor
"diffEditor.renderSideBySide": true,
"editor.fontFamily": "Anonymous, InputMono, Menlo, Monaco, 'Courier New', monospace",
"editor.find.autoFindInSelection": true,
"editor.fontLigatures": true,
"editor.formatOnSave": false,
"editor.formatOnType": true,
"editor.formatOnPaste": true,
function substractIdArrays(a, b) {
return a.filter(x => !b.find(y => y + '' === x + ''))
}
async function updateArea(areaCode) {
const area = await Area.findOne({ areaCode })
const associatedHotels = await Hotel.find({ areaCode }).then(hotels => hotels.map(h => h._id))
const hotelsInArea = await Hotel.find({
@pi0
pi0 / clean-node-modules.sh
Last active May 26, 2019 16:52
Clean all `node_modules` to save disk space
for d in `find -name node_modules -type d` ; do [ -d "$d" ] && echo "$d" && rm -rf "$d" ; done
const Agent = require('agentkeepalive')
require('http').globalAgent = new Agent()
require('https').globalAgent = new Agent.HttpsAgent()
{
// Editor
"diffEditor.renderSideBySide": true,
"editor.fontFamily": "Anonymous, InputMono, Menlo, Monaco, 'Courier New', monospace",
"editor.find.autoFindInSelection": true,
"editor.fontLigatures": true,
"editor.formatOnSave": false,
"editor.formatOnType": true,
"editor.formatOnPaste": true,
@pi0
pi0 / pagespeed_nginx_ubuntu.sh
Last active July 6, 2023 21:58
Install PageSpeed on Ubuntu Nginx Extras
# Deps
sed -i "s|# deb-src|deb-src|" /etc/apt/sources.list
apt update
export DEPS=" \
build-essential zlib1g-dev libpcre3-dev unzip uuid-dev \
debhelper po-debconf libexpat-dev libgd-dev libgeoip-dev libhiredis-dev \
libluajit-5.1-dev libmhash-dev libpam0g-dev libperl-dev libssl-dev libxslt1-dev quilt"
apt install -y $DEPS
# NXG Pagespeed
@pi0
pi0 / ssh-proxy.sh
Created September 20, 2018 16:06
SSH-SSH
ssh -vo ProxyCommand='ssh -W %h:%p root@proxy_host' root@dst_host
@pi0
pi0 / create_root.js
Last active September 19, 2018 09:29
Mongo Shell Commands
use admin
db.createUser({ user: "root", pwd: "root", roles: [ "root" ] })
@pi0
pi0 / centos.sh
Last active September 27, 2019 11:10
Setup CentOs -- The pro way ;)
# Updates
yum update -y
# Optional deps
yum install -y vim zsh pv nc zip unzip aria2 curl wget rsync
# EPEL
wget dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm -O /tmp/epel.rpm && rpm -ihv /tmp/epel.rpm && rm /tmp/epel.rpm
yum update -y
yum install -y htop