Skip to content

Instantly share code, notes, and snippets.

@bomsn
bomsn / highlight-active-links-on-scroll.html
Created Feb 11, 2021
Highlight active links for one-page navigation
View highlight-active-links-on-scroll.html
@bomsn
bomsn / geolocation.js
Last active Feb 2, 2021
Get User Postal Code ( Zip Code ) with Browser Geolocation & Google API
View geolocation.js
// jQuery must be loaded before calling this function ( for AJAX )
let getUserPostcode = () => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
let lat = position.coords.latitude,
long = position.coords.longitude,
url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + long + "&key=YOUR_GOOGLE_API_KEY";
$.ajax({
type: "GET",
@bomsn
bomsn / cronjob_automation.sh
Created Jan 21, 2021
Sample code for cron job automation ( Create a certbot auto-renewal cron job )
View cronjob_automation.sh
#!/bin/bash
# If our cron job already exists, bail out.
if ! crontab -l &> /dev/null | grep -q "/usr/bin/certbot renew"; then
# Copy the existing cron jobs into a temporary file
crontab -l &> /dev/null > cronjobs.txt
# Add our new cron job to the file
echo "15 3 * * * /usr/bin/certbot renew --quiet" >> cronjobs.txt
# Replace content of current user crontab with the content from our cron jobs file
cat cronjobs.txt > /var/spool/cron/crontabs/"$USER"