Skip to content

Instantly share code, notes, and snippets.

@gld1982ltd
gld1982ltd / gencert
Created April 18, 2016 04:18
Automate Let's Encrypt Certification
#!/bin/sh
#
# Wrapper script for the letsencrypt client to generate a server certificate in
# manual mode. It uses openssl to generate the key and should not modify the
# server configuration. It can be called off-side, i.e. not on the destination
# server.
#
# usage: gencert DOMAIN [DOMAIN...]
#
# This is free and unencumbered software released into the public domain.
server {
server_name example.com;
root /var/www/drupal8; ## <-- Your only path reference.
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
var fs = require('fs');
var util = require('util');
var writer = fs.createWriteStream('../log.txt');
fs.watch('.', function (event, filename) {
writer.write('================\nEvent: ' + event + '\n');
if (filename) {
@gld1982ltd
gld1982ltd / gist:d0d7ac835011d1f9bef2
Created January 29, 2016 03:33 — forked from yuanchuan/gist:2586540
Watch a directory recursively
/**
* Watch a directory recursively
*
* @param {String} dir
* @param {Function} cb
*
* watchRecursive('directory', function(current) {
* console.log(current, ' changed');
* });
*/
@gld1982ltd
gld1982ltd / combinejs.js
Created January 29, 2016 03:19 — forked from dobesv/combinejs.js
Combine, minify, and compress javascript files. Supports "watching" the files for automatic updates
#!node
var fs = require('fs'),
path = require('path'),
gzip = require('./gzip');
function process(fileBody, options, cb) {
if(typeof(fileBody) === 'object') {
options = fileBody;
fileBody = undefined;
cb = options;
@gld1982ltd
gld1982ltd / gist:112015db2ed16b957fb7
Created January 23, 2016 18:23 — forked from Gomah/gist:7364945
Static webserver @node.js
// Variables dc (http://nodejs.org/api/)
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
port = process.argv[2] || 1337, // Array ex -> http://nodejs.org/docs/latest/api/process.html#process_process_argv
mimeTypes = {
// Basic mimes
'asc' : 'text/plain',
// 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');
@gld1982ltd
gld1982ltd / simple-mms-server.js
Created January 23, 2016 17:44 — forked from vitapluvia/simple-mms-server.js
MMA CTF 2015 - Stream... Single File Server
m=require; m('http').createServer(function(_, r) {r.end(m('fs').readFileSync("extracted"))}).listen(4444);
@gld1982ltd
gld1982ltd / server.js
Created January 22, 2016 18:51 — forked from iuliaL/server.js
node http.createServer
// node server instead of xampp ;
var http = require('http');
var fs = require('fs');
http.createServer(function (request, response) {
var filePath = '.' + request.url;
console.log(request.url);
fs.readFile(filePath, function(error, content) {
response.writeHead(200);
@gld1982ltd
gld1982ltd / server.js
Last active January 20, 2016 04:25 — forked from nariatan/server.js
Simple node.js server (livereload)
/*
* 1) run node server.js in root category where installed node
* 2) install browser extention
* 3) http://localhost:3000/index.html
*/
//server settings
var serveStatic = require('serve-static');
var connect = require('connect');
var http = require('http');