Skip to content

Instantly share code, notes, and snippets.

View quantixed's full-sized avatar

Stephen Royle quantixed

View GitHub Profile
@quantixed
quantixed / WordCount.scpt
Created October 4, 2018 12:08
AppleScript to get word and character count from TextEdit
tell application "TextEdit"
set wc to count words of document 1
set cc to count characters of document 1
if wc is equal to 1 then
set txt to " word, "
else
set txt to " words, "
end if
if cc is equal to 1 then
set txtc to " character."

Keybase proof

I hereby claim:

  • I am quantixed on github.
  • I am sjroyle (https://keybase.io/sjroyle) on keybase.
  • I have a public key ASCWCcNewPuFelX38VrKNO9CBVZh967DT85XKS9rN7Hwjgo

To claim this, I am signing this object:

@quantixed
quantixed / lut2tsv.ijm
Last active June 3, 2019 14:33
Export all look-up tables (LUTs) in FIJI to four column text format
function lutValuesToTable(filePath) {
getLut(reds, greens, blues);
tableTitle = "lutValueTable";
eightBit = 256;
run("Table...", "name=["+tableTitle+"] width=600 height=250");
print("["+tableTitle+"]", "\\Headings:Index\tRed\tGreen\tBlue");
for (i = 0; i < eightBit; i ++) {
rowString = d2s(i,0) + "\t" + reds[i] + "\t" + greens[i] + "\t" + blues[i];
print("["+tableTitle+"]", rowString);
}
@quantixed
quantixed / spindleSaver.ijm
Last active March 9, 2020 14:52
short macro to save a cell of interest (one frame from a two channel movie)
/*
* Short routine to save a single timepoint from a 2 channel movie
* Used for knocksideways spindle analysis
* Best done with "click ROI" square ROI over cell of interest
*/
dir = getDirectory("home")+"Desktop"+File.separator
winName = getTitle();
sliceNo = round(getSliceNumber() / 2);
s = "title=[tempwin] duplicate frames=" + d2s(sliceNo,0);
run("Duplicate...", s);
@quantixed
quantixed / r_project_setup.R
Created June 10, 2020 08:59
Preferred directory structure for R projects
## Setup preferred directory structure in wd
ifelse(!dir.exists("Data"), dir.create("Data"), "Folder exists already")
ifelse(!dir.exists("Output"), dir.create("Output"), "Folder exists already")
ifelse(!dir.exists("Output/Data"), dir.create("Output/Data"), "Folder exists already")
ifelse(!dir.exists("Output/Plots"), dir.create("Output/Plots"), "Folder exists already")
ifelse(!dir.exists("Script"), dir.create("Script"), "Folder exists already")
@quantixed
quantixed / ExportDocsAsPNG.jsx
Last active August 29, 2020 07:05
Export ai files to PNG with our preferred settings for manuscript figures
/****************************************************************
* Script to save a directory of ai files to PNG
* Options are: white bakcground, 300 dpi and clipped to artboard
*****************************************************************/
var folder = Folder.selectDialog();
if (folder) {
var files = folder.getFiles("*.ai");
for (var i = 0; i < files.length; i++) {
var currentFile = files[i];
app.open(currentFile);
@quantixed
quantixed / config.ini
Created August 29, 2020 08:31
TexStudio v3.0.0 excerpt of config.ini file before [texmaker] - puts back zenburn coloring on macOS in dark mode
[General]
IniMode=true
[formats]
data\align-ampersand\bold=true
data\align-ampersand\fontFamily=
data\align-ampersand\foreground=#dc8cc3
data\align-ampersand\italic=false
data\align-ampersand\overline=false
data\align-ampersand\pointSize=0
@quantixed
quantixed / haversine.ipf
Last active October 6, 2020 05:45
Calculates distance between two points using latitude and longitude in decimal degrees - IGOR Pro
// calculates spherical distance between two points on earth given coords in decimal degrees
// uses haversine formula
// radius of earth is taken to be 6371 km (IUGG/WGS-84 mean)
Function SphericalDistanceBetweenTwoPoints(lat1, long1, lat2, long2)
Variable lat1, long1, lat2, long2
// convert inputs in degrees to radians
lat1*= pi/180
long1*= pi/180
lat2*= pi/180
@quantixed
quantixed / pngSizeForOverleaf.ijm
Created April 22, 2021 15:22
Deduce the page width size needed for a 300 dpi png
/*
* Figure out the width of png images for Overleaf
* png are 300 dpi and page width is 170 mm
*/
#@ File (label = "Input directory", style = "directory") input
#@ String (label = "File suffix", value = ".png") suffix
setBatchMode(true);
processFolder(input);
@quantixed
quantixed / FitCircleTo2DCoords.ipf
Created May 24, 2022 09:08
Igor function to fit a circle to 2D coords (sparse, irregular, arc). Returns the radius in units of xy
Function FitCircleTo2DCoords(w)
Wave w
// requires 2D numeric wave with two columnns corresponding to xy coords
if(Dimsize(w,1) != 2)
return -1
endif
// make two 1D waves for x and y coords
SplitWave/O/NAME="xW;yW;" w
Wave xW,yW
// solve in terms of u and v coordinates