Skip to content

Instantly share code, notes, and snippets.

@alexellis
alexellis / timelapse.md
Created March 9, 2017 08:48 — forked from porjo/timelapse.md
ffmpeg time-lapse

Convert sequence of JPEG images to MP4 video

ffmpeg -r 24 -pattern_type glob -i '*.JPG' -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4

  • -r 24 - output frame rate
  • -pattern_type glob -i '*.JPG' - all JPG files in the current directory
  • -i DSC_%04d.JPG - e.g. DSC_0397.JPG
  • -s hd1080 - 1920x1080 resolution

Slower, better quality

@simonjpartridge
simonjpartridge / cycle2-progress.js
Created September 1, 2015 14:47
Small script to add progress bar to cycle2 http://jquery.malsup.com/cycle2/ slideshows, supports multiple slideshows on one page
//Author Simon Partridge http://simonjpartridge.co.uk
//Supports multiple slideshows on one page
//Simply add <div class="cycle-progress"></div> within the cycle-slideshow div and style as you wish
$('.cycle-slideshow').each(function(){
var slideshow = $(this);
var progress = $(this).children('.cycle-progress');
slideshow.on( 'cycle-initialized cycle-before', function( e, opts ) {
progress.stop(true).css( 'width', 0 );
@ALenfant
ALenfant / yen_igraph.py
Last active October 26, 2022 19:39
Yen's algorithm for igraph, adapted from Wikipedia's pseudocode. The arguments are: graph: your igraph graph object (warning: the edge's id will change by using this function, so make a copy with gcopy if you want to keep them intact); source: source vertex; target: target vertex; num_k: number of shortest paths you want; weights: name of the ed…
def path_cost(graph, path, weights=None):
pathcost = 0
for i in range(len(path)):
if i > 0:
edge=graph.es.find(_source=path[i-1], _target=path[i])
if weights != None:
pathcost += edge[weights]
else:
#just count the number of edges
pathcost += 1