Skip to content

Instantly share code, notes, and snippets.

View sequoiap's full-sized avatar

Sequoia sequoiap

View GitHub Profile
@sequoiap
sequoiap / klayout_screenshot.py
Last active January 2, 2024 21:07
How to take a screenshot/image of a GDS file with colors defined by a layer properties file using the Klayout Python API.
"""
Example taken from https://www.klayout.de/forum/discussion/2246/clip-gds-to-image
This example images the full GDS and saves it to some shape specified.
"""
from klayout import lay
in_file = "path/to/some.gds"
out_file = "out.png"
layer_file = "path/to/some/layers.lyp"
@sequoiap
sequoiap / .pre-commit-config.yaml
Last active October 24, 2023 23:54
Canonical pre-commit configuration for a Python project
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: check-json
- id: check-merge-conflict
- id: mixed-line-ending
- id: end-of-file-fixer
types: [python]
@sequoiap
sequoiap / laptop_web_scraper.py
Created May 3, 2023 15:57
Variations on a script I used with a cron job to see if a laptop was on sale yet.
import os
import sys
import requests
from bs4 import BeautifulSoup
def notify(title, text):
os.system("""
osascript -e 'display notification "{}" with title "{}"'
@sequoiap
sequoiap / light_sensor_led.ino
Created October 30, 2020 02:14
Simple code to light up a set of four LED's attached to an arduino depending on the intensity measured by the photodiode.
const int P25 = 2;
const int P50 = 3;
const int P75 = 4;
const int P100 = 5;
const int SENSOR = A0;
void setup()
{
pinMode(P25, OUTPUT);
pinMode(P50, OUTPUT);
@sequoiap
sequoiap / hb.sh
Last active October 7, 2020 22:00
cd ~
mkdir -p hummingbird_ws/src
cd hummingbird_ws/src
catkin_init_workspace
git clone https://magiccvs.byu.edu/gitlab/hummingbird/hb_student.git
git clone https://magiccvs.byu.edu/gitlab/hummingbird/hb.git
cd hb
git checkout --track origin/fall_2020
@sequoiap
sequoiap / ros_setup.sh
Last active January 10, 2020 15:42
A script for setting up the ros workspace for the BYU UAS team
# For Ubuntu 18.04 Melodic
# INSTALL ROS
# Setup your sources.list
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
# Set up your keys
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
# Installation
sudo apt update
sudo apt install ros-melodic-desktop-full
@sequoiap
sequoiap / install_astrometry_on_linux.sh
Created December 13, 2019 04:20
Install astromery.net on Ubuntu-based Linux
#!/bin/sh
WORKSPACE_DIR="/tmp"
# basic linux install/build libs, python, and other support
cd $WORKSPACE_DIR && \
apt install -y make && \
apt-get update && \
apt-get install -y build-essential python python-pip netpbm zlib1g-dev libcairo2-dev libjpeg-dev libcfitsio-dev && \
pip install numpy scipy pyfits && \
@sequoiap
sequoiap / solve.sh
Created December 5, 2019 02:29
Gets the RA and DEC from a star image using astrometry.net without creating other files except the output.
#! /usr/bin bash
# Using python to get the RA, DEC from a wcs file: https://groups.google.com/d/msg/astrometry/0ICnBUecOx8/S1to9wayBQAJ
# Physical meaning of "Field rotation angle": https://groups.google.com/d/msg/astrometry/KEPzYd7fHis/hGDGMUwMBgAJ
# Possible program flaw of rotation near poles: https://groups.google.com/d/msg/astrometry/Uicir_i1E_o/nJsjjDeEBwAJ
solve-field \
--no-plots \
--no-verify \
@sequoiap
sequoiap / get_docker.sh
Last active February 16, 2021 06:25
Install docker on Ubuntu
#!/usr/bin/env bash
# Convenience script for setting up docker and docker-compose on Ubuntu.
# Steps essentially copied and pasted from:
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
# https://docs.docker.com/compose/install/
# Uninstall any existing docker installations
sudo apt-get remove docker docker-engine docker.io containerd runc
@sequoiap
sequoiap / ubuntu.sh
Last active November 22, 2020 17:03
#!/usr/bin/env bash
# A script to run every time I set up a new personal Ubuntu machine to get it the way I want it.
# Many of these come from https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/
# Update the system and add other package sources
sudo apt update && sudo apt upgrade
sudo apt install snapd
# Install media codecs
sudo apt install ubuntu-restricted-extras