Skip to content

Instantly share code, notes, and snippets.

View zakcodez's full-sized avatar

zakcodez zakcodez

View GitHub Profile
@focusaurus
focusaurus / ep_app.js
Last active June 14, 2022 00:06
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
const express = require("express");
const router = express.Router();
router.get('/', function (req, res) {
res.send("This is the '/' route in ep_app");
});
module.exports = router;
@SQLServerIO
SQLServerIO / gist:1757658
Created February 7, 2012 06:24 — forked from rrobe53/gist:976610
Node.js File Extension Content Type
exports.ext = function () {
var extTypes = {
"3gp" : "video/3gpp"
, "a" : "application/octet-stream"
, "ai" : "application/postscript"
, "aif" : "audio/x-aiff"
, "aiff" : "audio/x-aiff"
, "asc" : "application/pgp-signature"
, "asf" : "video/x-ms-asf"
, "asm" : "text/x-asm"
@ddallala
ddallala / simple_secure_server_2.js
Created November 28, 2011 21:52
A very simple HTTPS server that fetches static files for Node 0.4+
// Note the following code works for Node 0.4+
// To run: $ node simple_secure_server.js
// http://nodejs.org/#download
// based on: http://www.silassewell.com/blog/2010/06/03/node-js-https-ssl-server-example/
// based on: http://net.tutsplus.com/tutorials/javascript-ajax/learning-serverside-javascript-with-node-js/
// based on: http://nodejs.org/docs/v0.6.3/api/https.html#https.Server
var domainname = "127.0.0.1"; // array of domain names, in host file all have to point to 127.0.0.1
@csanz
csanz / encrypt_decrypt.js
Created August 30, 2011 16:06
Simple String Encryption & Decryption with Node.js
function encrypt(text){
var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq')
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq')
var dec = decipher.update(text,'hex','utf8')
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
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
@rrobe53
rrobe53 / gist:976610
Created May 17, 2011 14:46
Node.js File Extension Content Type
exports.ext = function () {
var extTypes = {
"3gp" : "video/3gpp"
, "a" : "application/octet-stream"
, "ai" : "application/postscript"
, "aif" : "audio/x-aiff"
, "aiff" : "audio/x-aiff"
, "asc" : "application/pgp-signature"
, "asf" : "video/x-ms-asf"
, "asm" : "text/x-asm"
@stonecobra
stonecobra / sslproxy.js
Created March 8, 2011 22:38
node.js serving the same content on http and https
//our 'imports', for you java fans out there
var connect = require('connect')
,fs = require('fs')
,http = require('http')
,https = require('https');
//the certs that need to be given to the ssl side, ca is optional
var ssl_options = {
ca: fs.readFileSync(__dirname + '/lib/certs/ssl.ca')
,key: fs.readFileSync(__dirname + '/lib/certs/ssl.key')
@ryanflorence
ryanflorence / static_server.js
Last active July 3, 2025 03:26
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@banksean
banksean / mersenne-twister.js
Created February 10, 2010 16:24
a Mersenne Twister implementation in javascript. Makes up for Math.random() not letting you specify a seed value.
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();