Skip to content

Instantly share code, notes, and snippets.

View trueheart78's full-sized avatar
💖

Josh Mills trueheart78

💖
View GitHub Profile
@trueheart78
trueheart78 / web-servers.md
Created May 28, 2021 20:17 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
// ==UserScript==
// @name SludgeHammer
// @namespace gamerswithjobs
// @description Replaces marketing speak with English
// @exclude /github/
// @author Chris Doggett
// ==/UserScript==
// Special thanks to Jeremy Banks at http://stackoverflow.com/a/6834930/64203
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})};
#!/usr/bin/env ruby
# Helpful link: http://httpd.apache.org/docs/2.4/logs.html
require 'date'
line_count = 0
File.open(ARGV[0]).readlines.each do |line|
line_count += 1
result = /^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).*\[(.*)\].*(GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT)\s(.*)\"\s(\d+)\s(\d+)(.*)$/.match(line)