Skip to content

Instantly share code, notes, and snippets.

View nicdoye's full-sized avatar
🚲
All shall be well, and all shall be well, and all manner of thing shall be well

Nic Doye nicdoye

🚲
All shall be well, and all shall be well, and all manner of thing shall be well
View GitHub Profile
@nicdoye
nicdoye / lc.sh
Created July 23, 2018 10:24
Rename files to lowercase, and change spaces to dashes.
#!/bin/bash
lc() {
for i in * ; do j="$(echo $i | tr '[:upper:]' '[:lower:]' | tr ' ' '-' )" ; [ "$i" != "$j" ] && mv "$i" "$j"; done
}
@nicdoye
nicdoye / docker-java-tomcat.csv
Last active June 11, 2018 08:31
Docker image sizes (for a medium post)
Name Base OS Java Vendor JRE/JDK Tomcat Size (MiB)
alpine:3.7 Alpine 4
gcr.io/distroless/base distroless 16
openjdk:8-jre-alpine Alpine OpenJDK JRE 78
openjdk:8-jdk-alpine Alpine OpenJDK JDK 97
tomcat:8.5-alpine Alpine OpenJDK JRE 8.5 101
nicdoye/micro-tomcat-jre distroless OpenJDK JRE 8.5 142
nicdoye/micro-tomcat-jdk distroless OpenJDK JDK 8.5 179
tomcat:8.5-slim Debian Slim OpenJDK JRE 8.5 213
alfresco/alfresco-base-java:8 CentOS Oracle JDK 468
@nicdoye
nicdoye / docker-size.sh
Created June 8, 2018 18:40
Finding a docker image's size
docker inspect openjdk:8-jdk-alpine | jq '.[] | "\(.Size) \(.RepoTags[0])"'
@nicdoye
nicdoye / hgweb.config
Created May 16, 2018 17:35
hgweb config
[paths]
/hg/ = /srv/hg/repos/*
[web]
style = gitweb
staticurl = /hg/static
allow_push = *
@nicdoye
nicdoye / uwsgi.ini
Created May 16, 2018 17:28
uWSGI config for mercurial
[uwsgi]
uid = uwsgi
gid = uwsgi
pidfile = /run/uwsgi/uwsgi.pid
emperor = /etc/uwsgi.d
stats = /run/uwsgi/stats.sock
chmod-socket = 660
emperor-tyrant = true
cap = setgid,setuid
; https://www.mercurial-scm.org/wiki/PublishRepositoriesOnNginx
@nicdoye
nicdoye / nginx-hg.conf
Last active May 16, 2018 17:20
nginx conf for Mercurial with uWSGI
location /hg/ {
uwsgi_pass unix:/run/uwsgi/hgweb.sock;
include uwsgi_params;
auth_basic "Mercurial repository";
auth_basic_user_file /etc/nginx/htpasswd;
client_max_body_size 0;
}
@nicdoye
nicdoye / time.sh
Created August 9, 2017 15:37
Minutes and Seconds from milliseconds
# Contains a rounding error, but we didn't need the accuracy
# Check if $response is an empty string or not a number
if [ -z ${response} ] || [ $(( ${response} + 0 )) == 0 ]
then
mins=undef
secs=undef
then
else
mins=$(( ${response} / 1000 / 60 ))
secs=$(( ${response} / 1000 - 60 * ${mins} ))
@nicdoye
nicdoye / my_date.sh
Created July 31, 2017 10:43
macOS ISO8601 dates
my_date () {
local date_cmd
local date
# Check if GNU date installed as gdate
: type gdate 2> /dev/null
[ $? == 0 ] && date_cmd=gdate || date_cmd=date
# Attempt GNU date - date will be unset if this fails
date=$(${date_cmd} --iso-8601=second 2> /dev/null)
@nicdoye
nicdoye / get-ip.pl
Created July 27, 2017 10:06
Finding your IP in Perl
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw/say/;
use WebService::IFConfig::Client;
my $client = WebService::IFConfig::Client->new();
say $client->get_ip;'
@nicdoye
nicdoye / IntegerDivision.pm
Last active July 2, 2017 19:51
Perl Integer Division Module
package Math::IntegerDivision;
use Carp;
use Moose;
has 'numerator' => (
is => 'rw',
isa => 'Int'
);