Skip to content

Instantly share code, notes, and snippets.

View marcelitocs's full-sized avatar
🎯
Focusing

Marcelito Costa marcelitocs

🎯
Focusing
View GitHub Profile
@marcelitocs
marcelitocs / idle-shutdown.sh
Created May 19, 2022 14:23 — forked from JustinShenk/idle-shutdown.sh
Google Cloud Platform (GCP) instance idle shutdown
#!/bin/bash
# Add to instance metadata with `gcloud compute instances add-metadata \
# instance-name --metadata-from-file startup-script=idle-shutdown.sh` and reboot
# NOTE: requires `bc`, eg, sudo apt-get install bc
# Modified from https://stackoverflow.com/questions/30556920/how-can-i-automatically-kill-idle-gce-instances-based-on-cpu-usage
threshold=0.1
count=0
wait_minutes=60
while true
@marcelitocs
marcelitocs / server.js
Created August 22, 2020 21:12 — forked from ryanoglesby08/server.js
A node.js SPA server that serves static files and an index.html file for all other routes.
/*
Incredibly simple Node.js and Express application server for serving static assets.
Given as an example from the React Router documentation (along with examples
using nginx and Apache):
- https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md#browserhistory
*/
const express = require('express');
const path = require('path');
@marcelitocs
marcelitocs / limitConcurrentGoroutines.go
Created January 26, 2019 18:37 — forked from AntoineAugusti/limitConcurrentGoroutines.go
Limit the maximum number of goroutines running at the same time
package main
import (
"flag"
"fmt"
"time"
)
// Fake a long and difficult work.
func DoWork() {
@marcelitocs
marcelitocs / update-golang.md
Created January 24, 2018 01:34 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Ubuntu 14.04 (Trusty Tahr)

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@marcelitocs
marcelitocs / convert_coord_to_dms.js
Created January 15, 2018 20:58 — forked from fernandosavio/convert_coord_to_dms.js
Convert float coordinates to DMS (degree, minutes, seconds). Ex.: convert_coord_to_dms(e.g. 21.305728, -157.859647) -> 21° 18' 20.6208" N, 157° 51' 34.7292" E
function convert_coord_to_dms (lat, lon) {
/*
Se Lat é positivo é Norte, senão Sul
Se Long é positivo é Leste, senão Oeste
*/
var lat_orientation = lat < 0 ? "S" : "N",
lon_orientation = lat < 0 ? "W" : "E";
function get_dms(decimal) {
@marcelitocs
marcelitocs / golang-on-rpi.md
Last active July 1, 2023 22:24 — forked from konradko/golang_on_rpi.md
Install Golang 1.8 on Raspberry Pi
wget https://storage.googleapis.com/golang/go1.8.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.8.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin