Skip to content

Instantly share code, notes, and snippets.

View nam20485's full-sized avatar

Nathan Miller nam20485

View GitHub Profile
@nam20485
nam20485 / round_to_nearest_multiple.py
Last active August 1, 2018 15:42
Round a number x, to the nearest multiple of m
increment = 0.002
decimal_places = -3
def round_to_nearest_multiple(value, increment, decimal_places):
rounded_value = round(x*increment, decimal_places)/increment
return rounded_value
v = 45.901
m = 0.002
d = -3
@nam20485
nam20485 / gen_secret_key.py
Last active June 15, 2023 03:13
Python 3 generate secret key
python -c 'import random; result = "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]); print(result)'
#python -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])'
@nam20485
nam20485 / docker-repository-install.bash
Last active January 30, 2019 10:54
install docker from respository
#! /bin/sh
UBUNTU_RELEASE=bionic
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install -qqy \
apt-transport-https \
ca-certificates \
curl \
@nam20485
nam20485 / Visual Studio solution file headers+
Last active February 16, 2021 14:11
Visual Studio solution file headers - 2003, 2005, 2008, 2010, 2012, 2013, 2015, 2017, 2019
== Visual Studio .NET 2003 (DO NOT COPY THIS LINE) ==
Microsoft Visual Studio Solution File, Format Version 8.00
# Visual Studio .NET 2003
VisualStudioVersion = 7.1
== Visual Studio 2005 (DO NOT COPY THIS LINE) ==
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
VisualStudioVersion = 8.0
_MSC_VER Defined as an integer literal that encodes the major and minor number elements of the compiler's version number. The major number is the first element of the period-delimited version number and the minor number is the second element. For example, if the version number of the Microsoft C/C++ compiler is 17.00.51106.1, the _MSC_VER macro evaluates to 1700. Enter cl /? at the command line to view the compiler's version number. This macro is always defined.
Visual Studio version, _MSC_VER
Visual Studio 6.0 1200
Visual Studio .NET 2002 (7.0) 1300
Visual Studio .NET 2003 (7.1) 1310
Visual Studio 2005 (8.0) 1400
Visual Studio 2008 (9.0) 1500
Visual Studio 2010 (10.0) 1600
@nam20485
nam20485 / Dockerfile
Created February 20, 2021 22:12
Installing node (& npm) on a mongo:4.0-xenial docker base image
# base image uses node latest minor version of 12.m
#FROM node:12-stretch-slim
FROM mongo:4.0-xenial
# create and set cwd
WORKDIR /code
# copy npm's package state files
COPY package.json .
COPY package-lock.json .
@nam20485
nam20485 / Dockerfile
Last active February 21, 2021 02:37
Download & install VS Buildtools in Dockerfile
###
# https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2019
###
# escape=`
# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
# Restore the default Windows shell for correct batch processing.
@nam20485
nam20485 / Dockerfile
Created February 21, 2021 02:34
HEALTHCHECK command in Dockerfile
HEALTHCHECK CMD powershell -command `
try { `
$response = iwr http://localhost:80 -UseBasicParsing; `
if ($response.StatusCode -eq 200) { return 0} `
else {return 1}; `
} catch { return 1 }
@nam20485
nam20485 / Dockerfile
Created February 21, 2021 02:35
Download and install .MSI installer in Dockerfile
RUN Write-Host 'Downloading iisnode' ; \
$MsiFile = $env:Temp + '\iisnode.msi' ; \
(New-Object Net.WebClient).DownloadFile('https://github.com/tjanczuk/iisnode/releases/download/v0.2.21/iisnode-full-v0.2.21-x64.msi', $MsiFile) ; \
Write-Host 'Installing iisnode' ; \
Start-Process msiexec.exe -ArgumentList '/i', $MsiFile, '/quiet', '/norestart' -NoNewWindow -Wait
@nam20485
nam20485 / gist:e5eab6ed2fdc12aab26e96275eda6f82
Created February 21, 2021 02:40
~ Ubuntu vs. Debian Releases
https://askubuntu.com/a/445496
From 10.04 up to 20.04:
Ubuntu Debian
20.04 focal bullseye/ sid - 11
19.10 eoan buster / sid - 10
19.04 disco buster / sid
18.10 cosmic buster / sid
18.04 bionic buster / sid