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
println "Hello" |
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 java.security.* | |
import javax.crypto.* | |
import javax.crypto.spec.* | |
def source = new File('input.dat').text | |
def cipher = Cipher.getInstance('DES') | |
cipher.init(Cipher.ENCRYPT_MODE, SecretKeyFactory.getInstance('DES').generateSecret(new DESKeySpec('secret12'.getBytes('UTF-8')))) | |
def target = cipher.doFinal(source.bytes).encodeBase64() |
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
//中文字型 | |
BaseFont.createFont('MHei-Medium', 'UniCNS-UCS2-H', BaseFont.NOT_EMBEDDED) | |
//檔案加密 | |
def stamper = new PdfStamper(reader, response.outputStream) | |
stamper.setEncryption(null, OWNER, ~(PdfWriter.ALLOW_PRINTING|PdfWriter.ALLOW_COPY|PdfWriter.ALLOW_MODIFY_CONTENTS|PdfWriter.ALLOW_MODIFY_ANNOTATIONS), PdfWriter.ENCRYPTION_AES_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA) |
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
@echo off | |
set path=C:\Program Files (x86)\Git\bin;%path% | |
git pull | |
pause |
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
mongodb 0.9.7 dependency break the "npm install connect-mongodb" installation on win32 platform. | |
newer mongodb like 1.0.2 will fix this problem | |
thanks | |
npm ERR! error rolling back [email protected] Error: ENOTEMPTY, rmdir 'C:\project\node_modules\connect-mongodb' | |
npm ERR! Unsupported | |
npm ERR! Not compatible with your operating system or architecture: [email protected] | |
npm ERR! Valid OS: linux,darwin,freebsd | |
npm ERR! Valid Arch: any |
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 express = require('express') | |
, routes = require('./routes') | |
, cache = require('connect-cache'); | |
// all urls contains "cached" will be cached for 1min. e.g. /services/cached/list.json | |
var app = module.exports = express.createServer( | |
cache({rules: [ | |
{regex: /\/cached\/.*/, ttl: 60 * 1000} | |
]}) |
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
// refer http://www.bishen.org/content/35579925757 | |
var express = require('express') | |
, ejs = require('ejs') | |
, routes= require('./routes') | |
, cache = require('connect-cache'); | |
var app = module.exports = express.createServer( | |
cache({rules: [ | |
{regex: /.*/, ttl: 21600000}, |
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 mongo = require('mongoskin') | |
, db = mongo.db('localhost/collection') | |
, mongoStore = require('connect-mongodb'); | |
//... | |
db.open(function(err, db) { | |
app.configure(function() { | |
//... | |
app.use(express.cookieParser()); |
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
/** | |
* InputTextMask script used for mask/regexp operations. | |
* Mask Individual Character Usage: | |
* 9 - designates only numeric values | |
* L - designates only uppercase letter values | |
* l - designates only lowercase letter values | |
* A - designates only alphanumeric values | |
* X - denotes that a custom client script regular expression is specified</li> | |
* All other characters are assumed to be "special" characters used to mask the input component. | |
* Example 1: |
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 zlib = require('zlib'); | |
var compress = function(req, res, result) { | |
var acceptEncoding = req.headers['accept-encoding']; | |
if (!acceptEncoding) { acceptEncoding = ''; } | |
if (acceptEncoding.match(/\bdeflate\b/)) { | |
zlib.deflate(result, function(err, result) { | |
if (!err) { | |
res.writeHead(200, { 'content-encoding': 'deflate' }); | |
res.send(result); |