Skip to content

Instantly share code, notes, and snippets.

View thinmy's full-sized avatar
🎯
Focusing

Thinmy Patrick Alves thinmy

🎯
Focusing
View GitHub Profile
@thinmy
thinmy / create_swap.sh
Created October 9, 2018 10:51
Create swap
#!/bin/sh
export SWAP_SIZE=2G
sudo fallocate -l $SWAP_SIZE /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo bash -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
@thinmy
thinmy / install-node.sh
Created October 9, 2018 10:50 — forked from ndaidong/install-node.sh
Install Node 8.10.0 in Ubuntu 16+
#!/bin/bash
export NODE_VERSION=8.10.0
export NODE_DOWNLOAD_URL=https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.gz
wget "$NODE_DOWNLOAD_URL" -O node.tar.gz
tar -zxvf node.tar.gz
cd node-v$NODE_VERSION
./configure
make
sudo make install
@thinmy
thinmy / install-python.sh
Created October 9, 2018 10:50
Install Python 3.6.5 in Ubuntu 16+
#!/bin/bash
export PYTHON_VERSION=3.6.5
export PYTHON_DOWNLOAD_URL=https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz
sudo apt update
sudo apt install --no-install-recommends -y \
software-properties-common build-essential \
libssl-dev libreadline-dev libbz2-dev libsqlite3-dev zlib1g-dev \
python-minimal
@thinmy
thinmy / websockets-server.js
Created October 9, 2018 10:50
Pure Node.js WebSockets server
/*
* node-ws - pure Javascript WebSockets server
* Copyright Bradley Wright <brad@intranation.com>
*/
// Use strict compilation rules - we're not animals
'use strict';
var net = require('net'),
crypto = require('crypto');
add_header X-Content-Type-Options "nosniff";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Download-Options "noopen";
add_header X-XSS-Protection "1; mode=block";
add_header Expect-CT "enforce; max-age=3600";
add_header Referrer-Policy "origin-when-cross-origin";
add_header Strict-Transport-Security "max-age=2592000; includeSubDomains";
add_header Content-Security-Policy "default-src 'self'; script-src *; style-src *; font-src *; img-src *; child-src 'self'; connect-src *; sandbox allow-same-origin allow-forms allow-scripts; object-src 'self'; form-action 'self'; frame-ancestors 'none';";
# ABOUT PLUBIC KEY PINS https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning
@thinmy
thinmy / gist:3f9f048dacae031456de93a1389f1489
Created September 9, 2018 10:26
Docker Swarm Elasticsearch + Kibana with nginx-proxy
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.0
ports:
- 9200:9200
- 9300:9300
environment:
- "cluster.name=docker-cluster"
# Install Rancher supported Docker version with Kubernetes support
curl https://releases.rancher.com/install-docker/17.03.sh | sh
# Stop all containers:
docker kill $(docker ps -q)
# Remove all containers
docker rm $(docker ps -a -q)
# Remove all docker images
@thinmy
thinmy / git-specify-ssh-key
Created February 25, 2018 20:51 — forked from gskielian/git-specify-ssh-key
Specifying SSH Key within Git Clone
#how to specify an ssh key to use when cloning a repo in Mac
ssh-agent bash -c 'ssh-add /Users/UR_USERNAME/.ssh/UR_PRIVATE_KEY; git clone git@DAS_GIT_URL'
@thinmy
thinmy / gist:f1618df687c906d83303e5309c82c483
Created September 19, 2016 19:17 — forked from perusio/gist:1724301
Workaround in PHP cURL for the 100-continue expectation
<?php
// cURL obeys the RFCs as it should. Meaning that for a HTTP/1.1 backend if the POST size is above 1024 bytes
// cURL sends a 'Expect: 100-continue' header. The server acknowledges and sends back the '100' status code.
// cuRL then sends the request body. This is proper behaviour. Nginx supports this header.
// This allows to work around servers that do not support that header.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
// We're emptying the 'Expect' header, saying to the server: please accept the body right now.
// Read here: http://pilif.github.com/2007/02/the-return-of-except-100-continue/
# Login as root
root@homestead:~# sudo -s
# Update Aptitude
root@homestead:~# apt-get update
# Install Java
root@homestead:~# apt-get install openjdk-7-jre-headless -y
# Download and install Elasticsearch Public Signing Key