Skip to content

Instantly share code, notes, and snippets.

View nfrasser's full-sized avatar
🕺

Nick Frasser nfrasser

🕺
View GitHub Profile
@nfrasser
nfrasser / recover_local_motion.py
Last active November 16, 2023 19:40
Sample script to recover a failed Local Motion Correction job in CryoSPARC. Make the noted substitutions before running.
import numpy as n
from cryosparc.tools import CryoSPARC
from cryosparc.dataset import Dataset
from cryosparc.util import first
cs = CryoSPARC(
# INSERT INSTANCE/CREDENTIALS HERE
license="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
email="nick@example.com",
password="...",
@nfrasser
nfrasser / restore_gridfs_files.py
Last active October 24, 2022 20:13
Restore missing GridFS files in CryoSPARC database using job directories
"""
Restore missing GridFS files for a given project (or job)
Usage:
eval $(cryosparcm env)
python -m restore_gridfs_files --project <puid> [ --job <juid> ]
"""
from io import BytesIO
@nfrasser
nfrasser / linkify-demo.js
Last active May 2, 2021 22:45
Linkify.js Demo
const beforeEl = document.getElementById('linkify-demo-before')
const afterEl = document.getElementById('linkify-demo-after')
const options = {
rel: 'nofollow noreferrer noopener',
formatHref: {
hashtag: (val) => `https://www.twitter.com/hashtag/${val.substr(1)}`,
mention: (val) => `https://github.com/${val.substr(1)}`
}
}
@nfrasser
nfrasser / .zshrc
Created May 28, 2017 19:35 — forked from bmhatfield/.zshrc
OSX Keychain Environment Variables
# If you use bash, this technique isn't really zsh specific. Adapt as needed.
source ~/keychain-environment-variables.sh
# AWS configuration example, after doing:
# $ set-keychain-environment-variable AWS_ACCESS_KEY_ID
# provide: "AKIAYOURACCESSKEY"
# $ set-keychain-environment-variable AWS_SECRET_ACCESS_KEY
# provide: "j1/yoursupersecret/password"
export AWS_ACCESS_KEY_ID=$(keychain-environment-variable AWS_ACCESS_KEY_ID);
export AWS_SECRET_ACCESS_KEY=$(keychain-environment-variable AWS_SECRET_ACCESS_KEY);
@nfrasser
nfrasser / quick-promise.js
Created March 22, 2017 13:18
Converts a JavaScript callback-style async function call into a promise.
export default (fn, ...args) => new Promise((resolve, reject) =>
fn(...args, (err, result) => err ? reject(err) : resolve(result))
);
@nfrasser
nfrasser / atom-keymap.cson
Created July 11, 2016 16:32
Nick's Atom keybindings
'body':
'alt-cmd-down': 'window:focus-pane-below'
'alt-cmd-left': 'window:focus-pane-on-left'
'alt-cmd-right': 'window:focus-pane-on-right'
'alt-cmd-up': 'window:focus-pane-above'
@nfrasser
nfrasser / hash.js
Created August 13, 2015 03:20
A promise-based bcrypt hashing module for Node.js/io.js. Written in ES6.
import bcrypt from 'bcrypt';
import {Promise} from 'rsvp';
// Functions from this module return RSVP.js Promises
/**
Given a string, resolves to the string's hashed value.
*/
export function make(str) {
return new Promise((resolve, reject) =>
@nfrasser
nfrasser / promise.js
Last active March 22, 2017 13:22
Promise helper method which can be used to convert any Node.js/io.js async function into a Promise. Written in ES6.
import {isArray} from 'lodash';
import {Promise} from 'rsvp';
/**
Make an RSVP promise out of a generic node function that takes a callback as
its last argument.
First argument is either (a) the function to call or (b) an array where the
first element is the context, and the second is the function to call.
jQuery("#issue_body").val(`As a ___ I did ___ and expected ___ but experienced ___.
Steps to reproduce:
1.
2.
3.
URL where bug was observed:
@nfrasser
nfrasser / useful-commands.md
Last active January 2, 2016 16:19
Useful terminal commands

Useful Terminal/Command Line Commands

Mac/Unix

General

Define a word