Skip to content

Instantly share code, notes, and snippets.

@thespacedoctor
thespacedoctor / gmail.yaml
Last active April 26, 2024 08:47
[Send Gmail from Python] #gmail #python
gmail:
username: "[email protected]"
password: "mypass"
@thespacedoctor
thespacedoctor / open_active_things_projects_in_separate_windows.applescript
Created May 27, 2019 12:23
[Open each active project in Things app in a new window - for review] #things #applescript #project
tell application "Things3"
-- MAKE SURE EVERY PROJECT HAS AT LEAST ONE TASK, OTHERWISE PROCEEDING ACTIONS WON'T FIND THE PROJECTS WITH 0 TASKs
repeat with pr in projects
if status of pr is open then
set thisCount to count of to dos of pr
if thisCount is 0 then
tell pr to make new to do with properties {name:"delete me"}
end if
end if
@thespacedoctor
thespacedoctor / README.md
Last active August 1, 2022 07:14
[Plot lightcurve of source from ZTF avro packet] #lightcurve #avro #ztf

Plotting ZTF Lightcurves from AVRO Packet

Here is the gist for the script and an example AVRO packet.

To generate a lightcurve from the AVRO alert packet for the ZTF object run the plot_ztf_lightcurve_from_avro.py script with the following usage:

python plot_ztf_lightcurve_from_avro [-o] <avrofile> 
@thespacedoctor
thespacedoctor / README.md
Last active May 5, 2021 16:00
[Listen to LVC GCN Notices and Download Localisation Maps] #ligo_virgo #map #gcn

LVC GCN Listener & Map Downloader

This script will continuously listen to the GCN notice stream, filtering only notices originating from Ligo-Virgo. If an event is detected, and a skymap is referenced in the VOEvent packet, the script will immediately download a local copy of the HealPix localisation map.

Python 2.* only at the minute.

Here are the only dependencies you should need to install:

pip install fundamentals requests pygcn
@thespacedoctor
thespacedoctor / preview_filepath.applescript
Created February 15, 2019 21:59
[Filepath from Preview Mac App] #pdf #preview #applescript #filepath
tell application "System Events"
tell process "Preview"
set thefile to value of attribute "AXDocument" of window 1
end tell
end tell
-- macos comes with php installed you can decode this file name using php
return do shell script "php -r 'echo urldecode(\"" & thefile & "\");'"
@thespacedoctor
thespacedoctor / md-addons.js
Last active May 5, 2021 15:59
[markdown preview add-ons for HTML header] #js #markdown
function $$( selector, context ) {
return ( context || document ).querySelectorAll( selector )
}
var highlightCode = function() {
var cssId = 'myCss'; // you could encode the css path itself to generate id..
if (!document.getElementById(cssId))
{
@thespacedoctor
thespacedoctor / generate_hawaii_plantary_moon_position_grid.py
Last active May 5, 2021 15:59
[Generate an Ephemeris Grid of Planets and Natural Satellites in the Solar-System] #solar_system #planet #moon
#!/usr/local/bin/python
# encoding: utf-8
"""
*Generate a 15 year grid of planetary moon positions (from ~Hawaii) for ATLAS HKO and MLO (and PanSTARRS) transient matching *
:Author:
David Young
:Date Created:
January 23, 2019
@thespacedoctor
thespacedoctor / get_filepath_of_document_in_front_window.applescript
Created October 2, 2018 13:05
[Get filepath of front window in any application] #filepath #applescript
property pstrApp : "Typora"
tell application "System Events"
-- GET CURRENT FILEPATH FROM APP
set lstProc to application processes where name contains pstrApp
if lstProc is not equal to {} then
try
set winThoughts to front window of item 1 of lstProc
on error
return
@thespacedoctor
thespacedoctor / open_scrivener_in_marked2.applescript
Last active May 5, 2021 15:59
[Open Current Scivener File in Marked 2] #marked #scrivener #applescript
property myName : "_display"
property pX : missing value
property pY : missing value
-- GRAB FILEPATH
tell application "System Events"
tell process "Scrivener"
activate
set documentPath to value of attribute "AXDocument" of window 1
@thespacedoctor
thespacedoctor / github-wiki-sync.py
Last active May 5, 2021 15:59
[Sync Github Repo Wikis Between Github and Local Filesystem] #wiki #github #sync
#!/usr/local/bin/python
# encoding: utf-8
"""
github-wiki-sync.py
===========================
:Summary:
Sync github wikis between mac and github
:Author:
David Young