Skip to content

Instantly share code, notes, and snippets.

View image72's full-sized avatar

image72 image72

View GitHub Profile
@image72
image72 / agent.js
Created July 19, 2017 03:42 — forked from TooTallNate/agent.js
Node.js `http.Agent` class implementations...
/**
* Module dependencies.
*/
var net = require('net');
var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter;
/**
@image72
image72 / Promiser.js
Last active February 5, 2018 07:39 — forked from jasuperior/Promiser.js
An ES6 async/promise proof of concept using Proxies.
// maybe that can compose graphql api?
/*
Using Es6 Proxies, I created an object that can resolve promises from a chained object accessor pattern.
simply await the values, or supply a callback to .then() and watch the magic.
*/
Symbol.queue = Symbol("queue"); //using Symbols to hide properties from being used or altered
Symbol.data = Symbol("data");
function Promiser( obj ) {
return new Proxy(obj, {
@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;
@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 / 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 / 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 / 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 / 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 / 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 / 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);
});