Skip to content

Instantly share code, notes, and snippets.

View hepcat72's full-sized avatar

Robert Leach hepcat72

View GitHub Profile
@hepcat72
hepcat72 / logProjectActivity.osa
Created February 28, 2024 14:39
Log project time by mission control desktop
-- Mission Control Desktop Time Tracker
-- What is this: This is a script intended to be run via a cron job that logs your current desktop name, cursor position, monitor, app, window name, and other customizable data to a project log file.
-- Purpose: Track time spent on projects that are organized by desktop (or custom-set app). See this stack post: https://apple.stackexchange.com/a/470628/55021
-- Author: Robert Leach, Genomics Group, Princeton, rleach@princeton.edu
-- Version: 7.0 (released on 2/28/2024)
-- Installation:
-- Put a Stickies.app sticky note on each desktop containing a single-word desktop name (as the first word on the first line of the sticky). The first line must also contain the string "dtop" (without the quotes). Be sure that Stickies.app is not assigned to any desktop.
-- Create a cron job
-- Command: `osascript logCurrentDesktop.osa >> desktop_log.txt`
-- Example expression: "* * * * MON-FRI" Runs once a minute of every weekday
@hepcat72
hepcat72 / sendText.osa
Last active December 8, 2023 22:36
Send SMS or iMessages via AppleScript
#!/usr/bin/env osascript
-- Version 2, now with attachments!
-- Note, the first couple times you run this script, the Messages app may prompt you to approve a couple things, one of which will be the ability to send SMS messages through your phone
-- Run via osascript on the command line like this:
-- osascript sendText.scpt --to ########## "this is" "a text message" --attachment "/path/to/image.png" "sent via applescript"
-- Where ########## is the phone number to send to
-- If you leave out `--to ##########`, it defaults to the value of an environment variable named MYPHONE in your .bashrc file (add the line "export MYPHONE=##########" to ~/.bashrc, entering your default phone number in place of ##########)
-- The 3 quoted strings will appear on separate lines and the image will be inserted between the lines "a text message" and "sent via applescript"
on run argv
--What is this?: This is a pair of scripts to provide a "Service" in any application in macOS that can wrap selected text to a specified line length (with an optional leader string (e.g. a comment character or indent)). Note, it does not remove existing hard-returns in the selected text.
--Installation: 1. Save the companion perl script (wrap.pl) on your computer. 2. Create an Automator service and paste this code into a "Run AppleScript" action. 3. Select (at the top of the workflow) "Workflow receives current text in any application". 4. Edit the `wrap_script` variable below to the location of the wrap.pl script. 5. Save. 6. Use the service (described below) and address any permissions issues that pop up. You may need to do this once for every app in which you run the service.
--How to use it: 1. Select entire lines of text you want to limit the line length of. 2. Right-click the selection and select this service. 3. Edit the line length, add a leader string if desired (e.g. a comment character such as
@hepcat72
hepcat72 / completion_notifier.scpt
Last active April 2, 2020 22:46
Applescript to post webhooks triggered by newly completed iOS reminders in specific list(s)
--Look for newly completed reminders (since the last check) and if there is a new one, make a webhook post with date, title, and list JSON values
--by Robert W. Leach, based on scripts by Craig Eley, Samantha Hilton, and Nick Morris
--This is not foolproof. If you have more than 1 device you use to "complete" reminders and a reminder is completed while offline, after which, a reminder is completed from a second online device, the completion of the reminders in the offline device (once it comes online) will be missed. However, it's done this way so that the script doesn't take forever looking at all reminders each time.
--Schedule it to run as frequently as you would like using osascript in a cron job and forget about it. Run once manually in order to "allow" this script to run in the security settings by responding to the resulting dialog.
--Cron job every 30 minutes looking for newly completed reminders in list "MyReminders" example (execute `crontab -e` in terminal and enter): */30 * * * * osascript /Us
#!/bin/bash
#Run once for each sample to gather sequences from multiple sequencing runs that belong to that sample. Sample name must be exactly the same as in each sequencing run.
#USAGE: ./splitseq_combine.sh run1 v1 reference_directory "splitseq_all_out_directories" "sample_name A1:B6"
all_args=("$@")
run_id=$1
chemistry=$2 #v1 or v2
@hepcat72
hepcat72 / splitseq_run.sh
Created January 8, 2020 22:17
Sample SPLiT-Seq command shell scripts for running split-seq at Princeton
#!/bin/bash
#USAGE: ./splitseq_run.sh run1 mrna.fq bcumi.fq v1 reference_directory "sample_name A1:B6" "sample2_name B7:C12" ...
all_args=("$@")
run_id=$1
mrna_fq=$2
bcumi_fq=$3
chemistry=$4 #v1 or v2
{"tests": [{"data": {"status": "failure", "tool_id": "barcode_splitter", "time_seconds": 38.440266132354736, "inputs": {"runinterface|seqfiles_0|nameinterface|readtype": "single", "runinterface|seqfiles_1|nameinterface|readtype": "singleindex", "runinterface|seqfiles_1|nameinterface|readname": "read2", "barcodes_at_end": false, "runinterface|seqfiles_0|input": {"src": "hda", "id": "5729865256bc2525"}, "runinterface|seqfiles_0|nameinterface|readname": "read1", "bcfile": {"src": "hda", "id": "2891970512fa2d5a"}, "runinterface|seqfiles_1|input": {"src": "hda", "id": "54f2a3a23292eb07"}, "runinterface|seqfiles_2|input": {"src": "hda", "id": "8155e4b4bf1581ff"}, "mismatches": "2", "runinterface|run_type": "flexible", "split_all": true, "runinterface|seqfiles_2|nameinterface|readname": "index2", "runinterface|seqfiles_2|nameinterface|readtype": "index"}, "tool_version": "0.18.4.0", "output_problems": [""], "job": {"inputs": {"runinterface|seqfiles_2|input": {"src": "hda", "id": "8155e4b4bf1581ff", "uuid": "0e1a53f5
@hepcat72
hepcat72 / Galaxy-Workflow-ChIP-Seq_Single_End_-_Step_2__Peaks_and_Motifs.ga
Created October 24, 2018 15:14
This workflow crashes the galaxy workflow editor, so I'l sharing it for debug purposes
{
"uuid": "b658f22b-96c9-46fb-9337-9beba3798044",
"tags": [],
"format-version": "0.1",
"name": "ChIP-Seq Single End - Step 2: Peaks and Motifs",
"steps": {
"0": {
"tool_id": null,
"tool_version": null,
"outputs": [],
--Purpose: Calculate the result of a highlighted equation and append the result.
--How to use it:
-- 1. Highlight an equation in an editable text area.
-- 2. Right click the selection and select Services->Calculate & Append Result
--Author: Robert Leach, Genomics Group, Princeton, rleach@princeton.edu
on run {input, parameters}
tell application "System Events"
--Bring up spotlight
keystroke " " using {command down}
@hepcat72
hepcat72 / Count Nucleotides.scpt
Last active May 19, 2021 20:24
Automator services for frequent bioinformatics tasks
--What is this: This is an applescript to use in an automator service that allows you to get the nucleotide and alignment length of a sequence, along with stats on the numbers of individual characters.
--Purpose: Determine the length of a selected nucleotide and alignment string in any application.
--Installation: Create an Automator service, paste this code into a "Run AppleScript" action, and save.
--How to use it: 1. Select a nucleotide string (newlines, numbers, spaces, and any other character are allowed). 2. Right-click the selection and select this service.
--Author: Robert Leach, Genomics Group, Princeton, rleach@princeton.edu
--Note, this counts "DNA characters"
on run {input, parameters}
tell application "System Events"