Skip to content

Instantly share code, notes, and snippets.

View alecjacobson's full-sized avatar

Alec Jacobson alecjacobson

View GitHub Profile
@alecjacobson
alecjacobson / HandbrakeCLI-recursive
Last active June 28, 2017 13:17 — forked from yig/HandbrakeCLI-recursive
Give HandbrakeCLI a path to a file or a directory and it will generate better-compressed "{.}-handbrake.mp4" files next to each video.
#!/bin/bash
# brew install handbrake parallel ffmpeg
usage()
{
echo 1>&2 "Usage:" "$0" 'path/to/video/dir1 [path/to/video/dir2 ...]'
exit -1
}
@alecjacobson
alecjacobson / real-time-latex-in-browser.html
Last active September 26, 2020 03:49
Real-time LaTeX web application using MathJaX (e.g., for doing math during a Skype call)
<!DOCTYPE html>
<html>
<head>
<title>Real-time LaTeX in browser</title>
<!-- https://github.com/mathjax/MathJax/blob/master/test/sample-dynamic-2.html -->
<!-- Copyright (c) 2012-2015 The MathJax Consortium -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
@alecjacobson
alecjacobson / viewmesh.cpp
Last active January 11, 2019 07:40
Command line program to view 3D meshes from files, standard input and pipes
#include <igl/guess_extension.h>
#include <igl/read_triangle_mesh.h>
#include <igl/viewer/Viewer.h>
#include <Eigen/Core>
#include <iostream>
#include <string>
#include <cstdio>
#include <unistd.h>
int main(int argc, char * argv[])
@alecjacobson
alecjacobson / fail.cpp
Last active December 16, 2016 04:30
Failing to recognize output types
#include <Eigen/Core>
#include <tuple>
template <
typename DerivedO0,
typename DerivedO1,
typename DerivedI0,
typename DerivedI1>
std::tuple<
Eigen::MatrixBase<DerivedO0>,
@alecjacobson
alecjacobson / example.cpp
Last active January 7, 2017 20:49
Find a parameter in argc/argv
#include "find_param.h"
#include <iostream>
// http://stackoverflow.com/a/868894/148668
int main(int argc,const char *argv[])
{
// Default values:
double tol = std::numeric_limits<double>::max();
std::string msg = "nothing to say";
// Process flags/parameter-pairs of the form: -f, -p val
#!/usr/bin/python
from __future__ import print_function, division
from math import *
from numpy import *
import numpy.linalg
try:
from PIL import Image
@alecjacobson
alecjacobson / concat_mp3s_to_m4b.sh
Last active January 7, 2018 19:09
Concatenate mp3s in a directory and subdirectories into a .m4b file
# https://gist.github.com/alecjacobson/b4e8f59bbd251ed81df4c5fe8441f630
#
# brew install ffmpeg --with-fdk-aac
OLDPWD=$( pwd )
cd "$1"
paths=$( find . -name "*.mp3" | sed 's/\([0-9]\)/;\1/' | sort -n -t\; -k2,2 | tr -d ';')
echo "$paths"
concat_paths=$( echo "$paths" | tr '\n' '|' )
ffmpeg -i "concat:$concat_paths" -c:a libfdk_aac -b:a 128k -f mp4 "$2"
cd "$OLDPWD"
@alecjacobson
alecjacobson / concat_mp3s.sh
Created January 7, 2018 19:10
Concatenate all mp3s in a directory and subdirectories into a single mp3
# https://gist.github.com/alecjacobson/b4e8f59bbd251ed81df4c5fe8441f630
#
# brew install ffmpeg --with-fdk-aac
OLDPWD=$( pwd )
cd "$1"
# Sort files so that ./Disc 10/1.mp3 is after ./Disc 9/1.mp3
paths=$( find . -name "*.mp3" | sed 's/\([0-9]\)/;\1/' | sort -n -t\; -k2,2 | tr -d ';')
echo "$paths"
concat_paths=$( echo "$paths" | tr '\n' '|' )
ffmpeg -i "concat:$concat_paths" -c:a copy -f mp3 "$2"
@alecjacobson
alecjacobson / rewrite_as_binary_dmat.cpp
Created May 31, 2018 19:14
Converte .dmat to binary .dmat
#include <igl/writeDMAT.h>
#include <igl/readDMAT.h>
#include <cstdlib>
#include <iostream>
int main(int argc, char *argv[])
{
if(argc == 1)
{
std::cout<<R"(
@alecjacobson
alecjacobson / github-add-user
Last active January 15, 2021 15:37 — forked from miraculixx/github-add-user
batch adding users to github accounts
#!/bin/bash
# Collaborator list, add, remove from a repository
# (c) 2015 miraculixx
# Author: github.com/miraculixx
# MIT License, see below
function help {
echo "Add collaborators to one or more repositories on github"
echo ""
echo "Syntax: $0 -H GITHUB_OAUTH_TOKEN [-l] [-D] -r repo1,repo2 <collaborator id1>,<collaborator id2>"