Skip to content

Instantly share code, notes, and snippets.

View joelabair's full-sized avatar
💭
I may be slow to respond.

Joel Bair joelabair

💭
I may be slow to respond.
View GitHub Profile
@joelabair
joelabair / moment-intro
Last active August 29, 2015 14:11
Moment.js - intro
<html>
<head>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"></script>
</head>
<body>
<script type="text/javascript">
document.write ("Today's date is " + moment().format("MMMM Do, YYYY h:mm a"));
</script>
</body>
</html>
@joelabair
joelabair / verify ssl cert matches key
Created October 7, 2014 15:33
Verify SSL Cert and Key match
-- the MD5 hashes must match --
openssl rsa -noout -modulus -in server.key | openssl md5
openssl x509 -noout -modulus -in server.crt | openssl md5
@joelabair
joelabair / logreport.awk
Last active August 29, 2015 14:05
HTTP log file Summary Reporting (awk)
#!/usr/bin/awk -f
BEGIN {
start = strftime("%s");
print "";
print "HTTP Requests Report";
printf "start - %s\n", strftime("%a, %d %b %Y %I:%M:%S %p %Z");
}
{
match($10, /http:\/\/([^\/]+)/, arr);
@joelabair
joelabair / gist:4d7aef6285fbe77732a9
Last active August 29, 2015 14:05
GridFS Node Example
var mongoose = require('mongoose'),
db = mongoose.connection.db,
GridStore = mongoose.mongo.GridStore,
stringifyObject = require('stringify-object'),
debug = require('debug')('myApp:MongoDB-GridFS');
var collectionRoot = "TestArchive";
var defaultQuery = {
"metadata.author": "Joel A. Bair",
"filename": "Summer Vacation.MOV"
@joelabair
joelabair / avg-http-req-size-bytes
Last active January 15, 2018 08:52
Average Request Size from apache log file (common log format) in AWK. (one line)
awk 'BEGIN { t = 0; c = 0 } { if($10 ~ /[[:digit:]]/) { t = t + $10; c++; } } END { print t / c}' /var/log/httpd/access_log