Skip to content

Instantly share code, notes, and snippets.

View joebasirico's full-sized avatar

Joe Basirico joebasirico

View GitHub Profile
#!/bin/sh
LOGPATH="/usr/share/nginx/website/log"
PRODLOG="$LOGPATH/production.log"
TMPLOG="$LOGPATH/nginx_prod_$(date +"%Y_%m_%d_%H_%M_%S")"
cp "$PRODLOG" "$TMPLOG.log"
tar -P -czf "$TMPLOG.tar.gz" "$TMPLOG.log"
var fs = require('fs');
var markov = require('markov');
var m = markov(2);
var s = fs.createReadStream(__dirname + '/input.txt');
m.seed(s, function() {
var line = '';
var res = m.respond(line.toString()).join(' ');
console.log(res);
@joebasirico
joebasirico / new.sh
Last active August 8, 2018 22:58
creates a new post, then launches the Hugo server, the browser and Visual Studio Code for editing
# creates a new post and starts the hugo server
if [ -z $1 ]
then
echo 'please supply a name for the new post in the form this-is-a-long-name.md'
else
echo "Created new post at posts/$1"
if [[ ${1:${#1}-3} == '.md' ]]
then
#Create new post
@joebasirico
joebasirico / build.sh
Last active August 8, 2018 22:58
builds a Hugo site, uses the optimize_images.js script and publishes the public directory to a server
#builds site
echo 'Building Hugo Site'
hugo
#optimize images
echo 'Optimizing Images'
node optimize_images.js -c -vv static/Uploads/ public/Uploads/
while true; do
@joebasirico
joebasirico / optimize_images.js
Last active December 7, 2019 00:11
A command line image optimizer written in node.
#!/usr/bin/env node
const sharp = require('sharp');
const fs = require('fs');
const program = require('commander');
const chalk = require('chalk');
function increaseVerbosity(v, total) {
return total + 1;
}
### Keybase proof
I hereby claim:
* I am joebasirico on github.
* I am joebasirico (https://keybase.io/joebasirico) on keybase.
* I have a public key whose fingerprint is 642C 85E7 1A6F 451F 8ECE A832 1DBA F07A 53AF 0E57
To claim this, I am signing this object:
#!/usr/bin/env python
## Attempts to get a domain transfer from the nameservers for the given domain
## Requires dnspython http://www.dnspython.org/
import sys
import socket
from dns import resolver, query, exception
def do_axfr(nameserver, domain):
ns = str(resolver.query(nameserver, 'A')[0])