Skip to content

Instantly share code, notes, and snippets.

View fk128's full-sized avatar

Fahdi Kanavati fk128

View GitHub Profile
@fk128
fk128 / autoFadeEase.jsx
Created June 18, 2017 09:42
After Effects Expressions
//Autofade: Add to opacity
// If there are two markers on the layer, then they are used to set the duration; otherwise, a default value is used.
transition = 15; // transition time in frames
var v = transform.opacity;
if (marker.numKeys<2){
tSecs = transition / ( 1 / thisComp.frameDuration); // convert to seconds
ease(time, inPoint, inPoint + tSecs, 0, v) - ease(time, outPoint - tSecs, outPoint, 0, v)
}else{
ease(time, inPoint, marker.key(1).time, 0, v) - ease(time, marker.key(2).time, outPoint, 0, v)
}
#!/bin/bash
FILENAME=$1
ffmpeg -i ${FILENAME}.ts -c:v libx264 -c:a copy -bsf:a aac_adtstoasc ${FILENAME}.mp4
var filename = "test.aep";
var my_file = new File(filename);
app.open(my_file);
app.executeCommand(3841);
@fk128
fk128 / rebuild.sh
Created November 1, 2017 15:19
Rebuild CMake project
#!/bin/bash
# rebuild CMake project
if [ -f build/CMakeCache.txt ]; then
rm -r build
mkdir build
cd build
cmake ..
make
else
@fk128
fk128 / recmake.sh
Created November 2, 2017 11:25
execute make on all sub-directories that have a make file
#!/bin/bash
# execute make on all sub-directories that have a make file
find . -type f -name Makefile -exec echo -e "\v\v+--- {}" \; -execdir make \;
@fk128
fk128 / jrnl
Created December 1, 2017 13:59
jrnl bash completion for listing journals
# place file in /etc/bash_completion.d/
_jrnl()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="`jrnl -ls`"
if [ "$COMP_CWORD" -eq 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
@fk128
fk128 / InputParser.py
Last active August 19, 2019 10:02
Combined use of argparser and configparser.
import configparser
import os
from argparse import ArgumentParser
"""Example
# Reads configs from a config file using configparser. Use -c or --config to specify path to file.
# Arguments are overridden based on order of priority:
# defaults < config file < command line arguments
#!/bin/bash
# add border to image for 4x5 aspect ratio using imagemagick
# add_border.sh image.jpg
infile=$1
outfile=${1%.jpg}_border.jpg
bgcolor="white"
hh=`convert $infile -ping -format "%h" info:`
ww=`convert $infile -ping -format "%[fx:0.8*h]" info:`
@fk128
fk128 / generate_random_colormap_itksnap.py
Created April 6, 2018 16:58
generate a random colormap for itk-snap. Useful for supervoxels.
import random
import sys
def print_xml_format(color, index, value):
if value == 0 or value == 1:
ctype = 'Discontinuous'
else:
ctype = 'Continuous'
print('''<folder key="ControlPoint[{}]" >
@fk128
fk128 / respliceVideoAE.jsx
Created April 28, 2018 14:06
re-splice video file in after effects given time stamps
{
// create an undo group
app.beginUndoGroup("respliceScript");
var curItem = app.project.activeItem;
var selectedLayers = curItem.selectedLayers;
var times = ["00.10-00.24", "00.34-01.03", "01.25-01.37"];