Skip to content

Instantly share code, notes, and snippets.

View ckunte's full-sized avatar

Chetan Kunte ckunte

View GitHub Profile
@ckunte
ckunte / README-smallcaps.md
Created February 21, 2020 08:43
Turn CAPITALISED words into SMALL CAPS on the fly on web pages

Turn CAPITALISED words into SMALL CAPS on the fly

The in-line script searches contents of the body of the page for capitalised words with two or more characters, and when found, wraps them in abbr opening and closing html tags, which can then be made to look like small caps.

Javascript

This following script can be added to the head section of a page enclosed within opening and closing script tags.

 window.onload = scotf;
@ckunte
ckunte / git-worflow.md
Created February 10, 2020 06:38
Git Work-flow

git work-flow

git work-flow is first and foremost about discipline. A disorganised approach leads a repository becoming unusable over time.

For production

[Chisel] has multiple branches. Since it's forked, my master branch is always at-par with the original developer's code base. Occasionally, I branch-out of master, work-on a feature, and when it's ready, I send a pull request to the developer for merging it into the master branch — this though is exceedingly rare.

To update my site, I use the ck branch, which includes site-specific configuration, custom features, and modifications. I run Chisel as follows:

@ckunte
ckunte / hstp.py
Last active October 7, 2019 02:28
Obtaining Hs and Tp values for a 5-year return period from an array of return period parameters furnished
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Obtaining Hs and Tp values for a 5-year return period from an
array of available return period parameters.
2019 ckunte
"""
import numpy as np
import matplotlib.pyplot as plt
@ckunte
ckunte / srv.py
Last active March 12, 2024 05:50
SimpleHTTPServer script with clean URLs
#!/usr/bin/env python
# http.server script for clean URLs
# Credits: R. Scott-Adams ( https://stackoverflow.com/a/28467686 )
import os
import http.server
class SuffixHandler(http.server.SimpleHTTPRequestHandler):
"""
Overrides the default request handler to assume a suffixless
@ckunte
ckunte / tp.sh
Last active August 3, 2019 12:53
Transperth bus timings
#!/usr/bin/env bash
# tp.sh -- Transperth bus timings from/to near my stop
# 2019 ckunte
if [ -z "$*" ]; then
echo 'Include start hour or min. Examples:'
echo 'sh tp.sh 16'
echo 'sh tp.sh :2'
exit 0
fi
echo 'Transperth bus(es) starting at' $1':'
@ckunte
ckunte / prompt.sh
Created July 26, 2019 05:22
Simple colorful bash prompt with git status
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1='\e[36m\u\e[39m at \e[35m\h\e[39m \e[93m\w\e[39m \e[32m$(git_branch)\e[39m\n$ '
@ckunte
ckunte / tmux-copy-paste.md
Last active August 3, 2019 12:54
Copy and paste in tmux

In Windows (Cygwin, via)

Using mouse (ensure the following is in your .tmux.conf file: set -g mouse on)

  1. Copy text: Hold shift + select text with left-button
  2. Paste text: Hold shift + middle-button

In macOS (Terminal, via)

  1. Copy text: Hold fn + cmd + c
@ckunte
ckunte / nd.sh
Created July 14, 2019 03:44
Count days from start to end dates
#!/usr/bin/env bash
# nd.sh -- count days from start to end dates input inline
# 2019 ckunte
if [ -z "$*" ]; then
echo 'Include "start" "end" dates inline, e.g.,'
echo '$ bash nd.sh "1 Apr 2018" "31 Dec 2018"'
exit 0
fi
start_date=$1
end_date=$2
@ckunte
ckunte / w2w.csv
Created June 16, 2019 04:40
Walk-to-work elevation on platforms
Platform Operator Location Vessel Gangway system Elevation
Solan 205 Premier Oil West of Shetlands Siem Spearfish Ampelmann 24.500m
Corvette CV Shell SNS Kroonberg Ampelmann 21.500m
Gunflint Spar Noble Energy GOM DOF Skandi7 Ampelmann 21.500m
Cutter QC Onegas SNS Kroonberg Ampelmann 21.200m
L13-FI-1 NAM SNS Kroonberg Ampelmann 19.900m
Brigantine BG Shell SNS Kroonberg Ampelmann 19.500m
Brigantine BR Shell SNS Kroonberg Ampelmann 19.500m
Carrack QA NAM SNS Kroonberg Ampelmann 18.900m
Perla field Cardon IV Gulf of Venezuela Boa Deep C Ampelmann 18.100m
@ckunte
ckunte / ddns.sh
Created June 16, 2019 03:55
DDNS setup for IP refresh using DNSimple
#!/bin/bash
#
# setup in /etc/anacrontab:
# 1 5 ping.daily /home/ckunte/.ddns/ddns.sh
#
TOKEN="<add token here>" # The API v2 OAuth token
ACCOUNT_ID="<add id here>" # Replace with your account ID
ZONE_ID="<add domain name here>" # The zone ID is the name of the zone (or domain)
RECORD_ID="<add record id here>" # Replace with the DNS Record ID (corresponds to A record)
IP=`curl -s http://icanhazip.com/`