Skip to content

Instantly share code, notes, and snippets.

View ximeg's full-sized avatar

RKiselev ximeg

  • San Francisco, California
  • 21:08 (UTC -07:00)
View GitHub Profile
@ximeg
ximeg / napari_save_layer.py
Created June 11, 2022 22:32
Save napari layer as displayed at full resolution
LAYER = 'Cy3'
OUT = 'my_exported_image_' + LAYER
from matplotlib import pyplot as plt
import numpy as np
layer = viewer.layers[LAYER]
img = layer.data
@ximeg
ximeg / move_lonely_jpg.py
Last active October 18, 2020 20:03
Move JPG files that do not have a matching raw file
#!/usr/bin/env python
import os
import shutil
raw_ext = '.RAF'
jpg_ext = '.JPG'
destination = 'jpg_only'
for filename in os.listdir('.'):
@ximeg
ximeg / .bashrc-parallel-ffmpeg-video-tools.sh
Last active June 17, 2022 05:04
.bashrc parallel ffmpeg video tools
# Video encoding. Arguments to ffmpeg should be passed in quotes
# Example
# ls *.avi | ff_avi2webm "-filter:v 'crop=in_w-100:in_h/2'"
ff_any2webm(){
parallel ffmpeg -i {} $1 -c:v vp9 {.}.webm
}
ff_whatsapp(){
# Convert specified videos to mp4 that are compatible with whatsapp
@ximeg
ximeg / parallel_avi2webm.sh
Created April 20, 2020 17:38
ffmpeg parallel convert all AVI to VP9 WEBM
ls -1 *.avi | parallel ffmpeg -i {} -c:v vp9 {.}.webm
@ximeg
ximeg / ffmpeg_side_by_side.sh
Created April 20, 2020 17:37
ffmpeg - place two video streams side by side, without audio
ffmpeg -i first.avi -i second.avi -filter_complex "[0:v][1:v]hstack=inputs=2[v]" -map "[v]" side-by-side.webm
@ximeg
ximeg / ffmpeg_avi2webm
Created April 3, 2020 19:42
FFMPEG convert COMSOL avi to webm for embedding into web pages
ffmpeg -i <input>.avi -c:v vp9 <output>.webm
@ximeg
ximeg / knitter
Last active August 17, 2022 10:37
Knitter - command line tool to knit RMarkdown documents
#!/bin/bash
# Adapted from https://stackoverflow.com/a/52543399/6029703
if [ "$#" -gt 2 -o "$#" -lt 1 ]; then
echo "********************************************************************"
echo "* Knitter version 1.1 *"
echo "********************************************************************"
echo -e "This script converts Rmd files into HTML (default) or PDFs. \n"
echo -e "usage: knitter file.Rmd [output_format] \n"
@ximeg
ximeg / openpgp.txt
Created September 1, 2017 12:22
Verknüpfte OpenKeychain-Identität
This Gist confirms the Linked Identity in my OpenPGP key, and links it to this GitHub account.
Token for proof:
[Verifying my OpenPGP key: openpgp4fpr:5eef68f406860ce415623fe9505a5266ffee464d]
@ximeg
ximeg / openpgp.txt
Created September 1, 2017 12:22
Verknüpfte OpenKeychain-Identität
This Gist confirms the Linked Identity in my OpenPGP key, and links it to this GitHub account.
Token for proof:
[Verifying my OpenPGP key: openpgp4fpr:5eef68f406860ce415623fe9505a5266ffee464d]
@ximeg
ximeg / ThresholdingAlgo.py
Created April 20, 2017 07:20
Python implementation of smoothed z-score algorithm from http://stackoverflow.com/a/22640362/6029703
#!/usr/bin/env python
# Implementation of algorithm from http://stackoverflow.com/a/22640362/6029703
import numpy as np
import pylab
def thresholding_algo(y, lag, threshold, influence):
signals = np.zeros(len(y))
filteredY = np.array(y)
avgFilter = [0]*len(y)
stdFilter = [0]*len(y)