Enable forwarding:
sysctl -w net.ipv4.ip_forward=1Create this script eg sudo nano iptables.sh
eth=$1
proto=$2Enable forwarding:
sysctl -w net.ipv4.ip_forward=1Create this script eg sudo nano iptables.sh
eth=$1
proto=$2| exports.knex = require('knex')({ | |
| client: 'pg', | |
| connection: { | |
| host : '127.0.0.1', | |
| user : 'your_database_user', | |
| password : 'your_database_password', | |
| database : 'myapp_test' | |
| } | |
| }); |
| # coding: utf-8 | |
| # | |
| # 台灣 OSM 圖資自動更新程式,會自動檢查更新,有更新時下載,並且匯入到 PostGIS | |
| # | |
| # 系統需求: | |
| # * wget | |
| # * osm2pgsql 並且內含 PBF 圖資格式支援 | |
| # | |
| # 測試環境: | |
| # * Ubuntu 14.04.1 LTS |
| <div><a href="http://jsforcats.com/">JS for cats</a></div> | |
| <div><a href="https://github.com/maxogden/art-of-node#the-art-of-node">Art of Node</a></div> | |
| <div><a href="http://github.com/substack/node-browserify"><img src="talk/browserify.png"></a></div> | |
| <div>javascript should run everywhere</div> | |
| <div><img src="talk/require.png"></div> | |
| <div><img src="talk/venn.png"></div> | |
| <div>browserify + npm = ♥</div> | |
| <div>npm = client side + server side modules in one registry</div> | |
| <div><a href="http://github.com/substack/browserify-handbook">browserify-handbook</a></div> | |
| <div><a href="http://npmjs.org/browserify-adventure">browserify-adventure</a></div> |
| // Restify Server CheatSheet. | |
| // More about the API: http://mcavage.me/node-restify/#server-api | |
| // Install restify with npm install restify | |
| // 1.1. Creating a Server. | |
| // http://mcavage.me/node-restify/#Creating-a-Server | |
| var restify = require('restify'); |
| 'use strict'; | |
| // simple express server | |
| var express = require('express'); | |
| var app = express(); | |
| var router = express.Router(); | |
| app.use(express.static('public')); | |
| app.get('/', function(req, res) { | |
| res.sendfile('./public/index.html'); |
| // | |
| // AppDelegate.swift | |
| // pushtest | |
| // | |
| // Created by sawapi on 2014/06/08. | |
| // Copyright (c) 2014年 sawapi. All rights reserved. | |
| // | |
| // iOS8用 | |
| import UIKit |
Node.js擅长数据密集型实时(data-intensive real-time)交互的应用场景。然而数据密集型实时应用程序并不是只有I/O密集型任务,当碰到CPU密集型任务时,比如要对数据加解密(node.bcrypt.js),数据压缩和解压(node-tar),或者要根据用户的身份对图片做些个性化处理,在这些场景下,主线程致力于做复杂的CPU计算,I/O请求队列中的任务就被阻塞。
Node.js主线程的event loop在处理所有的任务/事件时,都是沿着事件队列顺序执行的,所以在其中任何一个任务/事件本身没有完成之前,其它的回调、监听器、超时、nextTick()的函数都得不到运行的机会,因为被阻塞的event loop根本没机会处理它们,此时程序最好的情况是变慢,最糟的情况是停滞不动,像死掉一样。
一个可行的解决方案是新开进程,通过IPC通信,将CPU密集型任务交给子进程,子进程计算完毕后,再通过ipc消息通知主进程,并将结果返回给主进程。
和创建线程相比,开辟新进程的系统资源占用率大,进程间通信效率也不高。如果能不开新进程而是新开线程,将CPU耗时任务交给一个工作线程去做,然后主线程立即返回,处理其他的I/O请求,等到工作线程计算完毕后,通知主线程并将结果返回给主线程。那么在同时面对I/O密集型和CPU密集型服务的场景下,Node的主线程也会变得轻松,并能时刻保持高响应度。
| # to generate your dhparam.pem file, run in the terminal | |
| openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.
These are the steps I went through to set up an SSL cert.