Skip to content

Instantly share code, notes, and snippets.

View alecjacobson's full-sized avatar

Alec Jacobson alecjacobson

View GitHub Profile
// via https://stackoverflow.com/a/22885856/148668
#include <cereal/cereal.hpp>
#include <cereal/archives/binary.hpp>
#include <igl/writeDMAT.h>
#include <Eigen/Dense>
#include <fstream>
namespace cereal
{
template <class Archive, class _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> inline
@alecjacobson
alecjacobson / papers_most_often_cited_in_specific_author_papers.py
Created August 31, 2022 15:05
Frequency Count of Papers Most Cited in a Specific Authors Publications
#!/usr/bin/env python
from semanticscholar import SemanticScholar
from collections import defaultdict
sch = SemanticScholar(timeout=2)
# Replace with author id found in url like
# https://www.semanticscholar.org/author/E.-Catmull/3132499
author = sch.author(3132499)
paperId_counts = defaultdict(int)
paperId_short_recs = {}
for authors_paper_short_rec in author['papers']:
@alecjacobson
alecjacobson / main.cpp
Created April 30, 2022 16:13
glfw mini-app to demonstrate how fps counter is lying
// On mac, first install eigen and glfw
//
// brew install glfw eigen
//
// Compile with something like:
//
// clang++ -O3 -DNDEBUG -o mini-glfw main.cpp -std=c++11 \
// -I /opt/homebrew/include/eigen3 \
// -I /opt/homebrew/include/ -L/opt/homebrew/lib -lglfw -framework OpenGL
//
{
"TGCs attended or watched": 0
}
@alecjacobson
alecjacobson / build-x86_64-gmp-mpfr-libigl.sh
Created February 18, 2022 06:57
bash script proof of concept showing how to build libigl using rosetta on m1 mac
#!/bin/bash
# arch -x86_64 ./build-x86_64-gmp-mpfr-libigl.sh
if [[ $(arch) == *arm64* ]]; then
#echo "int main(){}" | clang++ -x c++ - -o test.o
echo "Re-issue as `arch -x86_64 ./build-x86_64-gmp-mpfr-libigl.sh`"
exit 1
fi
#!/bin/bash
if [ "$#" -lt 2 ] ; then
echo "mine [username] [file/folder]"
echo "or"
echo "mine [username] [file/folder] [action]"
exit 1
fi
if [ "$#" -ne 3 ] ; then
action="list,add_file,search,delete,add_subdirectory,delete_child,file_inherit,directory_inherit,read,write,delete,append,execute"
else
@alecjacobson
alecjacobson / ascii2fixedwith.rd
Created April 12, 2021 17:24
Convert ascii text from standard input into fixed-width unicode characters.
#!/usr/bin/env ruby
#
# Convert ascii text from standard input into fixed-width unicode characters.
#
# http://xahlee.info/comp/unicode_full-width_chars.html
fixedWidth = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,.:;!?"'`^~ ̄_&@#%+-*=<>()[]{}⦅⦆|¦/\¬$£¢₩¥ '
ascii = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,.:;!?"\'`^~‾_&@#%+-*=<>()[]{}«»|¦/\\¬$£¢₩¥ '
input = STDIN.read
output = input.split('').map do |c|
i = ascii.index(c)
@alecjacobson
alecjacobson / solve_quadprog.h
Created December 30, 2020 19:49
Templated C-Style wrapper for Luca Di Gaspero's QuadProg++ https://github.com/liuq/QuadProgpp
// MIT License
//
// Copyright (c) 2020 Alec Jacobson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@alecjacobson
alecjacobson / dark_mode.m
Created December 28, 2020 23:45
Dark mode from matlab
function dark_mode(use_dark_mode)
% DARK_MODE Switch command and figures windows to dark background with light
% text.
%
% dark_mode
% dark_mode(flag)
%
% Optional input:
% flag whether to switch to dark mode {false} or back to default (true)
%
#!/bin/bash
# This will download and run readme2tex on the given README.tex.md, commit the
# resulting svgs and README.md file to the repo and push the changes
if [ $# -eq 0 ]; then
echo "Usage:
./readme2tex.sh path/to/repo/with/README.tex.md"
exit 1
fi