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
| package main | |
| import ( | |
| "encoding/base64" | |
| "fmt" | |
| "net/mail" | |
| "net/smtp" | |
| "os" | |
| "strings" | |
| ) |
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
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net" | |
| "net/mail" | |
| "net/smtp" | |
| "crypto/tls" | |
| ) |
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
| #Install dpkg-dev and package dependencies | |
| sudo apt-get install dpkg-dev | |
| sudo apt-get install software-properties-common | |
| sudo apt-get install python-software-properties | |
| sudo apt-get install init-system-helpers | |
| #Add repository: | |
| sudo add-apt-repository ppa:nginx/stable | |
| #Edit /etc/apt/sources.list.d/nginx-stable-lucid.list, add dpkg-src (no need if ubuntu verson >= 12.04): |
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
| # to generate your dhparam.pem file, run in the terminal | |
| openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
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 key = 'password'; | |
| $.encAjax = function (url, options) { | |
| options.data = options.data || {}; | |
| var data = JSON.stringify(options.data); | |
| var encryptedData = sjcl.encrypt(key, data); | |
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
| from time import sleep | |
| import tornado | |
| from multiprocessing.pool import ThreadPool | |
| _workers = ThreadPool(10) | |
| class BackgroundMix(tornado.web.RequestHandler): | |
| """将block任务放入线程池中执行 | |
| EXAMPLE: | |
| # blocking task like querying to MySQL |
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 App = angular.module('App', []); |
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
| from flask import Flask, render_template_string, request | |
| class CustomFlask(Flask): | |
| jinja_options = Flask.jinja_options.copy() | |
| jinja_options.update(dict( | |
| block_start_string='<%', | |
| block_end_string='%>', | |
| variable_start_string='%%', | |
| variable_end_string='%%', | |
| comment_start_string='<#', |
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
| package main | |
| // Create a directed graph based on the words in a text file. | |
| // For example the sentences "This is some text. What is this good for?" would produce the following digraph: | |
| // digraph graph { | |
| // This -> is | |
| // is -> some | |
| // some -> text | |
| // What -> is |
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
| #!/usr/bin/env python | |
| """Simple HTTP Server With Upload. | |
| This module builds on BaseHTTPServer by implementing the standard GET | |
| and HEAD requests in a fairly straightforward manner. | |
| """ |