Skip to content

Instantly share code, notes, and snippets.

View armand1m's full-sized avatar

Armando Magalhães armand1m

View GitHub Profile
@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 / 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 / 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 / .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 / 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 / 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 / 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 / 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 / fix-stale-drone-stage.sql
Last active March 4, 2020 14:22
Fixes a stale drone stage state in Drone CI database directly.
-- You can use either 'error', 'failure' or 'success' as a status on each of these.
UPDATE stages SET stage_status = 'success' WHERE stage_id = $stage_id;
UPDATE builds SET build_status = 'success' WHERE build_id = $build_id;
UPDATE steps SET step_status = 'success' WHERE step_id = $step_id;
-- This timestamp must be bigger than the step_started field of the steps table.
UPDATE steps SET step_stopped = 1583330000 WHERE step_id = $step_id;
@armand1m
armand1m / .skhdrc
Last active May 4, 2025 12:02
⚙️ My yabai and skhd configuration files.
# open terminal
cmd - return : open -n -a "Terminal"
# open chrome
cmd + shift - return : open -n -a "Google Chrome"
# moves focus between windows in the current focused display
alt - h : yabai -m window --focus west
alt - j : yabai -m window --focus south
alt - k : yabai -m window --focus north