Skip to content

Instantly share code, notes, and snippets.

@nuada
nuada / partslist.py
Last active July 21, 2022 21:33
Parts list script for Fusion 360 - components are aggregated by dimensions
import adsk.core
import adsk.fusion
import csv
import os
import os.path
# Inspired by: https://forums.autodesk.com/t5/fusion-360-design-validate/parts-list-with-dimensions/m-p/9642058/highlight/true#M223047
def run(context):
@nuada
nuada / split-by-chromosome.sh
Created October 16, 2019 06:58
Split and compress gzipped tabular files
zcat very-large.gff3.gz | awk '{ print $0 | "gzip > split." $1 ".gff3.gz"; }'
@nuada
nuada / full_df.py
Created March 29, 2018 09:38
Print all rows of a pandas DataFrame
with pd.option_context('display.max_rows', None, 'display.max_columns', 3):
print(df[['sequence', 'mismatches']])
@nuada
nuada / add_to_dock.sh
Last active February 27, 2017 14:04
Add application icon or folder to macOS Dock
#!/bin/bash
# usage: add_to_dock.sh <path to your .app bundle or directory>
defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>${1}</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
killall Dock
@nuada
nuada / reset_launchpad.sh
Created February 27, 2017 13:25
Reset Launchpad configuration
defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
@nuada
nuada / set_icon.sh
Created February 22, 2017 12:12
Set custom icon of Mac OS X folder or file using resource forks.
#!/bin/bash
# usage: set_icon.sh <some.icns or image_file> <folder or file path>
# Based on: http://www.amnoid.de/icns/makeicns.html
icon="$1"
target="$2"
if [[ -d "${target}" ]]; then
target_icon="${target}"/$'Icon\r'
else
target_icon="${target}"
@nuada
nuada / contains.sh
Created January 3, 2017 13:44
Test if script was called with some flag.
#!/bin/bash
if [[ " $* " =~ ' flag ' ]]; then
echo "Flag is present"
else
echo "Flag is missing"
fi
@nuada
nuada / list_ports.sh
Last active May 13, 2019 14:59
List listening TCP ports, equivalent of `netstat -tpln`
lsof -n -P -iTCP -sTCP:LISTEN
@nuada
nuada / format_json.sh
Last active October 3, 2016 13:54
Format and sort JSON file
cat mess.json | python -m json.tool > order.json
@nuada
nuada / cs_load_stats.py
Created July 15, 2016 14:26
CloudStack: pretty table of instance load information.
#!/usr/bin/python
# usage: cs listVirtualMachines | ./load_stats.py
import json
import sys
vms = json.load(sys.stdin)
if vms.get('count', 0) > 0:
output = list()