Skip to content

Instantly share code, notes, and snippets.

View webhacking's full-sized avatar
👻
Hyper focusing

hax0r webhacking

👻
Hyper focusing
View GitHub Profile
package:
exclude:
- node_modules/**/*
include:
handler.ts
import { Handler, Context, Callback } from 'aws-lambda';
interface HelloResponse {
statusCode: number;
body: string;
}
const hello: Handler = (event: any, context: Context, callback: Callback) => {
const response: HelloResponse = {
statusCode: 200,
@webhacking
webhacking / deploy.py
Last active November 28, 2018 09:11
Deployment with aws codedeploy
from __future__ import print_function
import os
import sys
from time import strftime, sleep
import boto3
from botocore.exceptions import ClientError
VERSION_LABEL = strftime("%Y%m%d%H%M%S")
BUCKET_KEY = os.getenv('APPLICATION_NAME') + '/' + VERSION_LABEL + \
'-bitbucket_builds.zip'
@webhacking
webhacking / ie-placeholder.js
Created September 28, 2018 06:02
Support html5 placeholder attribute for IE without using jquery or any dependencies.
window.initPlaceHolder = (textField) => {
const addEvent = document.addEventListener ? 'addEventListener' : 'attachEvent';
const eventPrefix = document.addEventListener ? '' : 'on';
const placeHolderClassName = 'usingPlaceHolder';
const $trim = (string) => {
return string.trim ? string.trim() : string.replace(/^\s+|\s+$/g, "");
};
const $addClassName = (element, className) => {
var elClassName = element.className;
if(elClassName)
@webhacking
webhacking / gist:564923de96b718440a78cd1afd8a1e45
Created September 18, 2018 09:27
Node latest release, add this PPA
Add below ppa and then install node and npm
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
@webhacking
webhacking / f
Created September 10, 2018 13:04
Easily get toeic words using js
let translate = "";
const nodes = document.querySelectorAll('.SetPage-term');
nodes.forEach(node => {
const en = `#${node.querySelector('.TermText.lang-en').textContent}`;
const ko = `#${node.querySelector('.TermText.lang-ko').textContent}`;
translate += `${en} ${ko}\n`;
})
@webhacking
webhacking / specifically-for-pca-api-instance
Created July 25, 2018 08:12
specifically-for-pca-api-instance
server {
listen 20170;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;

#How to fast nginx? user www-data; worker_processes auto; pid /run/nginx.pid;

events {
        worker_connections 4000;
        # optmized to serve many clients with each thread, essential for linux
        use epoll;

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 400,000 to 500,000 requests per second (clustered), most what i saw is 50,000 to 80,000 (non-clustered) requests per second and 30% CPU load, course, this was 2xIntel Xeon with HT 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.

First, you will need to install nginx, my way to install nginx is compiling it from source, but for now we will use apt-get