Skip to content

Instantly share code, notes, and snippets.

View image72's full-sized avatar

image72 image72

View GitHub Profile
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';
@image72
image72 / nginx.conf
Last active July 22, 2016 07:50 — forked from agouriou/nginx.conf
Example Nginx (> 1.9) configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs. Handle error status (4xx, 5xx) and expose headers. support subdomain
#
# 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
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++) {
@image72
image72 / fetch-client.js
Created August 26, 2016 19:38 — forked from bryanrsmith/fetch-client.js
A thin wrapper library around the fetch API to provide application-wide HTTP client configuration
export class HttpClient {
constructor(defaults) {
this.defaults = defaults;
this.interceptors = [];
this.activeRequestCount = 0;
this.isRequesting = false;
}
addInterceptor(interceptor) {
this.interceptors.push(interceptor);
# 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;
'use strict';
const util = require('util');
const net = require('net');
const cares = process.binding('cares_wrap');
const _getaddrinfo = cares.getaddrinfo;
class DNSHijacking {
constructor(hosts) {
@image72
image72 / webpac.config.prod.js
Last active October 22, 2016 20:02
webpack config for product. with dist min.files alias, relative context resolve.
// 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')
@image72
image72 / repeat.hbs.js
Last active November 2, 2016 06:56
handlebars helper repeat. with data slice
// 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;
}
@image72
image72 / LICENSE.txt
Created November 3, 2016 12:42 — forked from Fedia/LICENSE.txt
John Resig's Micro-Templating in 140 bytes
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