Skip to content

Instantly share code, notes, and snippets.

View armand1m's full-sized avatar

Armando Magalhães armand1m

View GitHub Profile
@armand1m
armand1m / fetch_tags_dockerhub.sh
Last active February 29, 2020 01:50
Fetch tags from dockerhub for a specific image
fetch_tags_dockerhub() {
curl -s "https://hub.docker.com/v2/repositories/$1/tags/?page_size=25&page=1" | jq -r '.results[]["name"]'
}
@armand1m
armand1m / search_dockerhub.sh
Last active February 29, 2020 01:41
Search through docker hub community in a single line bash function
search_dockerhub() {
curl -s "https://hub.docker.com/api/content/v1/products/search?source=community&q=$1&page=1&page_size=10" | jq -r '.summaries[]["name"]'
}
@armand1m
armand1m / install-prettier.sh
Last active March 26, 2022 10:41
Add prettier to a node project in one script
yarn add -D prettier
cat > ./.prettierrc <<EOL
{
"printWidth": 70,
"singleQuote": true,
"trailingComma": "es5"
}
EOL
npx add-project-script -n "lint" -v "prettier --check './src/**/*.{tsx,ts,js,json}'"
npx add-project-script -n "lint:fix" -v "prettier --write './src/**/*.{tsx,ts,js,json}'"
@armand1m
armand1m / kubernetes.yaml
Last active July 8, 2019 12:35
Generated kubernetes manifest from "kubectl run my-webapp-deployment --image=my-webapp --dry-run -o yaml"
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: my-webapp-deployment
name: my-webapp-deployment
spec:
replicas: 1
selector:
@armand1m
armand1m / .dockerignore
Last active July 6, 2019 17:42
Docker ignore file for CRA-generated applications
.gitignore
.dockerignore
README.md
Dockerfile
./build
./node_modules
./coverage
./**/*.js.snap
@armand1m
armand1m / Dockerfile
Last active July 6, 2019 17:41
Dockerfile for serving static assets from a CRA-generated application build
# Stage 1 - prepare application dependencies and bundle it
FROM node:dubnium as build-assets
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci
COPY . ./
RUN npm run build
# Stage 2 - serve only build assets through a static server
FROM node:dubnium
@armand1m
armand1m / nominatim-geocoder.ts
Last active June 19, 2019 07:46
Geocoder Implementation using OSM Nominatim
import fetch from "node-fetch";
interface Location {
place_id: number;
licence: string;
osm_type: string;
osm_id: number;
boundingbox: string[];
lat: string;
lon: string;
@armand1m
armand1m / geocoder-snippet.js
Last active June 18, 2019 14:14
snippet on how to use geocoder
const NodeGeocoder = require('node-geocoder');
const { geocode } = NodeGeocoder({
provider: 'google',
apiKey: 'YOUR_API_KEY',
});
(async () => {
const location = await geocode('29 champs elysée paris');
@armand1m
armand1m / debug-nm-l2tp-service.sh
Created April 10, 2019 08:38
stupid script to remind me how to debug network manager
sudo /usr/lib/NetworkManager/nm-l2tp-service --debug
@armand1m
armand1m / Dockerfile
Created February 21, 2019 16:08
Dockerfile with pre configured environment for playing with Fable F#
FROM mono:latest
RUN apt-get update
RUN apt-get install -y apt-transport-https
RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
RUN mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
RUN curl -slO https://packages.microsoft.com/config/debian/8/prod.list
RUN mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
RUN chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
RUN chown root:root /etc/apt/sources.list.d/microsoft-prod.list