A Pen by Po-Ying Chen on CodePen.
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 fs = require('fs'); | |
var path = require('path'); | |
http.createServer(function (request, response) { | |
console.log('request ', request.url); | |
var filePath = '.' + request.url; | |
if (filePath == './') | |
filePath = './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
# | |
# CORS header support | |
# | |
# One way to use this is by placing it into a file called "cors_support" | |
# under your Nginx configuration directory and placing the following | |
# statement inside your location block(s): | |
# | |
# include cors_support; | |
# | |
# A limitation to this method is that Nginx doesn't currently send headers |
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
function serialize(form) { | |
var field, l, s = []; | |
if (typeof form == 'object' && form.nodeName == "FORM") { | |
var len = form.elements.length; | |
for (var i=0; i<len; i++) { | |
field = form.elements[i]; | |
if (field.name && !field.disabled && field.type != 'file' && field.type != 'reset' && field.type != 'submit' && field.type != 'button') { | |
if (field.type == 'select-multiple') { | |
l = form.elements[i].options.length; | |
for (var j=0; j<l; j++) { |
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
export class HttpClient { | |
constructor(defaults) { | |
this.defaults = defaults; | |
this.interceptors = []; | |
this.activeRequestCount = 0; | |
this.isRequesting = false; | |
} | |
addInterceptor(interceptor) { | |
this.interceptors.push(interceptor); |
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
# limit the number of connections per single IP | |
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m; | |
# limit the number of requests for a given session | |
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s; | |
# zone which we want to limit by upper values, we want limit whole server | |
server { | |
limit_conn conn_limit_per_ip 10; | |
limit_req zone=req_limit_per_ip burst=10 nodelay; |
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
'use strict'; | |
const util = require('util'); | |
const net = require('net'); | |
const cares = process.binding('cares_wrap'); | |
const _getaddrinfo = cares.getaddrinfo; | |
class DNSHijacking { | |
constructor(hosts) { |
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
// require('babel-runtime/core-js/promise').default = require('bluebird'); | |
// global.Promise = require('bluebird'); // extra override | |
var path = require('path'); | |
var webpack = require('webpack'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
var modulesPath = path.join(__dirname, 'node_modules'); | |
var reactPath = path.join(modulesPath, 'react', 'react.js') | |
, reactDOMPath = path.join(modulesPath, 'react', 'lib', 'ReactDOM.js') |
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 _ = require('underscore'); | |
function repeat(n, options) { | |
/* jshint validthis: true */ | |
var isNumber = function(n) { | |
var type = typeof(num); | |
if (type === 'string') { | |
if (!num.trim()) return false; | |
} else if (type !== 'number') { | |
return false; | |
} |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2015 Fedia <[email protected]> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |