Skip to content

Instantly share code, notes, and snippets.

View image72's full-sized avatar

image72 image72

View GitHub Profile
@image72
image72 / dynamic_subdomains
Created April 9, 2022 20:56 — forked from v1shwa/dynamic_subdomains
Dynamically map subdomains to different ports on the server - using Nginx
server {
listen 80;
# maps p8080.example.com -> localhost:8080
server_name ~^p(?<port>[^.]+)\.example\.com$;
location / {
proxy_pass http://localhost:$port;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@image72
image72 / get-keycodes.sh
Created September 18, 2020 14:27 — forked from ryukinix/get-keycodes.sh
A command to get the keycodes of your keyboard and configure your ~/.Xmodmap
#!/usr/bin/env bash
# A command to get the keycodes of your keyboard and configure your ~/.Xmodmap
# I used that for configure my multimedia-keys on XFCE4 @ Manjaro
xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
# [e.g.: ~/.Xmodmap
# keycode 162 = XF86AudioPlay
# keycode 164 = XF86AudioStop
@image72
image72 / syslogd.js
Created August 27, 2020 09:49 — forked from kfox/syslogd.js
Simple syslogd server
var dgram = require('dgram');
var host = process.argv[2] || '0.0.0.0';
var port = process.argv[3] || 514;
var server = dgram.createSocket('udp4');
server.on('message', function(msg, rinfo) {
console.log("received: %s from %s:%s", msg, rinfo.address, rinfo.port);
});
@image72
image72 / httpproxy.js
Created August 27, 2020 09:47 — forked from kfox/httpproxy.js
Simple HTTP proxy for Node.js v0.10.x
var http = require('http');
var host = process.argv[2] || '127.0.0.1';
var port = process.argv[3] || 8080;
http.createServer( function (req, res) {
var proxy = http.request(req.url, function (proxy_res) {
proxy_res.on('data', function (chunk) {
@image72
image72 / nginx.conf
Created June 2, 2020 02:19 — forked from thoop/nginx.conf
Official prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
@image72
image72 / download-file.js
Last active April 28, 2020 09:19 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@image72
image72 / tcpproxy.js
Created December 17, 2018 06:30 — forked from kfox/tcpproxy.js
A basic TCP proxy written in node.js
var net = require("net");
process.on("uncaughtException", function(error) {
console.error(error);
});
if (process.argv.length != 5) {
console.log("usage: %s <localport> <remotehost> <remoteport>", process.argv[1]);
process.exit();
}
@image72
image72 / gunicorn_start.bash
Last active October 26, 2018 03:14 — forked from postrational/gunicorn_start.bash
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application $DIRNAME
DJANGODIR=/webapps/hello_django/hello # Django project directory #$1
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name $DIRNAME
@image72
image72 / axios-timing.ts
Created August 14, 2018 03:57 — forked from forivall/axios-timing.ts
Axios Timing helper POC
import http = require('http')
import https = require('https')
import url = require('url')
import {AxiosInstance, AxiosInterceptorManager} from 'axios'
import {HttpRequestOptions as HttpFollowRequestOptions, http as httpFollow, https as httpsFollow} from 'follow-redirects'
import now = require('performance-now')
import httpAdapter = require('axios/lib/adapters/http')
import InterceptorManager = require('axios/lib/core/InterceptorManager')
@image72
image72 / nginx-webp-sample.conf
Created July 10, 2018 06:55 — forked from uhop/nginx-webp-sample.conf
Serving WEBP with nginx conditionally.
user www-data;
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;