This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Module dependencies. | |
| */ | |
| var net = require('net'); | |
| var inherits = require('util').inherits; | |
| var EventEmitter = require('events').EventEmitter; | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user www-data; | |
| http { | |
| ## | |
| # Basic Settings | |
| ## | |
| sendfile on; | |
| tcp_nopush on; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| }); |