Skip to content

Instantly share code, notes, and snippets.

🚲
Tant que je respire, j’attaque

Nic Doye nicdoye

View GitHub Profile
@nicdoye
nicdoye / lc.sh
Created Jul 23, 2018
Rename files to lowercase, and change spaces to dashes.
View lc.sh
#!/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 Jun 11, 2018
Docker image sizes (for a medium post)
View docker-java-tomcat.csv
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 Jun 8, 2018
Finding a docker image's size
View docker-size.sh
docker inspect openjdk:8-jdk-alpine | jq '.[] | "\(.Size) \(.RepoTags[0])"'
View hgweb.config
[paths]
/hg/ = /srv/hg/repos/*
[web]
style = gitweb
staticurl = /hg/static
allow_push = *
@nicdoye
nicdoye / uwsgi.ini
Created May 16, 2018
uWSGI config for mercurial
View uwsgi.ini
[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
nginx conf for Mercurial with uWSGI
View nginx-hg.conf
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 Aug 9, 2017
Minutes and Seconds from milliseconds
View time.sh
# 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 Jul 31, 2017
macOS ISO8601 dates
View my_date.sh
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 Jul 27, 2017
Finding your IP in Perl
View get-ip.pl
#!/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 Jul 2, 2017
Perl Integer Division Module
View IntegerDivision.pm
package Math::IntegerDivision;
use Carp;
use Moose;
has 'numerator' => (
is => 'rw',
isa => 'Int'
);
You can’t perform that action at this time.