Skip to content

Instantly share code, notes, and snippets.


Chetan Kunte ckunte

View GitHub Profile
ckunte /
Created Nov 2, 2020
SACS commands common across its modules
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Find most common sacs commands across modules, 2020 ckunte
import re
from collections import Counter
# read a file containing all sacs commands
commands = re.findall(r'\w+', open('sacs-commands-all.txt').read())
# print 85 most common commands across all sacs modules
mcom = Counter(commands).most_common(85)
for com, nos in mcom:
ckunte / tlp.csv
Created Oct 21, 2020
Tension leg platforms
View tlp.csv
Platform Operator Displacement (t) Topside weight (t) Water depth (m) Year installed
Hutton ConocoPhillips 61500 20792 147 1984
Jolliet MC Offshore Petroleum 16602 1950 536 1989
Snorre A StatOil 106000 43700 335 1992
Auger Shell 66224 21772 873 1994
Heidrun StatOil 290610 89000 345 1995
Mars Shell 49099 6532 894 1996
Ram-Powell Shell 49100 8100 980 1997
Morpeth Eni 10605 2817 518 1998
Ursa Shell 88451 20321 1159 1999
ckunte /
Last active Sep 6, 2020
Getting USFOS to run on linux is pretty breezy. Give it a try.

USFOS on linux

As a commercial (engineering) software, [USFOS][u] needs to be manually installed. I tried this today on [elementary OS][e], powered by frugal hardware, and USFOS runs just fine. At minimum, the following are needed:

  1. usfos, xact binary, and usfos_etc files.
  2. A valid license usfos.key file.
  3. A computer with Linux 64-bit OS to run on.

As each binary needs to be separately downloaded from USFOS site, I’ve automated this via [wget][]. Here are the commands to run in a terminal:

ckunte /
Last active Jul 14, 2020
Generate formatted model data from CSV file
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""Generate formatted model data from CSV file
2020 ckunte
Usage: --fn=filename.ext --help --version
ckunte /
Created Jun 14, 2020
Brother HL-L2321D as a network-enabled AirPrint printer

Brother HL-L2321D as a network-enabled AirPrint printer

Brother HL-L2321D is a delightful bare bones printer. It's fast, prints duplex, and is lean on cartridge usage. HL-L2320D drivers are readily available for Windows 10 and MacOS, and installing this printer is a breeze.

Since connection to the printer is only via USB-A interface, it is not a network printer, since it has no LAN port and no built-in WiFi. For those that want their printers to work with their iOS devices, no AirPrint support out of the box either. But that said, making this printer accessible over network is pretty easy with any of the following two ways:

  1. Connect it to a router that has a USB-A port.
  2. Connect it to a Mac, PC, or a Raspberry Pi, and share this printer to be accessible for printing.

Setup on a Raspberry Pi

ckunte /
Created Jun 11, 2020
Getting rid of these pesky per-folder-setting files (.DS_Store)
#!/usr/bin/env bash
sudo find / -depth -name ".DS_Store" -exec rm {} \;
# Run these periodically via a cronjob. Type `sudo crontab -e` in
# a Terminal and enter the following job.
# 0 9 * * * root find / -name ".DS_Store" -depth -exec rm {} \;
# What this job does:
# At 9AM everyday (in the example below), root looks for .DS_Store
ckunte / atom.xml
Created Mar 6, 2020
Atom feed template in Jinja
View atom.xml
{% from 'site_settings.jinja2' import site_title, site_author, site_url -%}
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="">
<title>{{ site_title }}</title>
<link rel="alternate" type="text/html" href="{{ site_url }}"/>
<link rel="self" type="application/atom+xml" href="{{ site_url }}/atom.xml"/>
{%- for entry in entries -%}
{%- if loop.index < 1 + 1 %}
<updated>{{ entry.year }}-{{ entry.month }}-{{ }}T{{ entry.hour }}:{{ entry.minute }}:{{ entry.second }}Z</updated>
ckunte / feed.json
Last active Mar 7, 2020
JSON feed template in Jinja
View feed.json
{% from 'site_settings.jinja2' import site_title, site_author, site_url -%}
"version": "",
"title": "{{ site_title }}",
"description": "Description of the website",
"home_page_url": "{{ site_url }}",
"feed_url": "{{ site_url }}/feed.json",
"author": {
"name": "{{ site_author }}",
"url": "{{ site_url }}"
ckunte /
Created Feb 21, 2020
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.


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

  window.onload = scotf;
ckunte /
Created Feb 19, 2020
S-N Curves for tubular joints (TJ) for both air and seawater with cathodic protection, ref: Table 16.11-1, ISO 19902:2007
#!/usr/bin/env python
# encoding: utf-8
""" -- 2016 ckunte
May 7: Initial commit.
Feb 10, 2020: Comparing seawater and air provisions
import numpy as np
import matplotlib.pyplot as plt
You can’t perform that action at this time.