Skip to content

Instantly share code, notes, and snippets.

View asmaloney's full-sized avatar
👽
Support Ukraine

Andy Maloney asmaloney

👽
Support Ukraine
View GitHub Profile
@estan
estan / notarize-macos.py
Created July 11, 2019 07:59
Python script for notarizing an app (e.g. a .dmg)
#!/usr/bin/env python3
#
# Notarize a file (e.g. a .dmg)
#
# Usage: notarize-macos.py <Apple ID username> <Apple ID password> <file>
#
# Note: The --primary-bundle-id flag is hard-coded below, so you'll want to
# change that!
#
# See https://developer.apple.com/documentation/security/notarizing_your_app_before_distribution#3087727
@leiless
leiless / find_LC_VERSION_MIN_MACOSX.c
Last active June 5, 2020 01:30
Find LC_VERSION_MIN_MACOSX load command and change SDK version to 10.9.0 if it's too old
/*
* Created 190528
*
* see:
* https://gist.github.com/landonf/1046134
*
* test:
* time find / -type f -perm -0111 -exec ./this_prog {} \;
*/
@baiwfg2
baiwfg2 / CMakeLists.txt
Created September 29, 2018 12:42
How to use add_custom_target and add_custom_command correctly in cmake
# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990
# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://blog.csdn.net/gubenpeiyuan/article/details/51096777
cmake_minimum_required(VERSION 3.10)
@vicrucann
vicrucann / CMakeLists.txt
Created June 14, 2016 18:08
OpenSceneGraph + QOpenGLWidget - minimal example
cmake_minimum_required(VERSION 2.8.11)
project(qtosg)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Gui OpenGL)
find_package(OpenSceneGraph REQUIRED COMPONENTS osgDB osgGA osgUtil osgViewer)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
@ssylvan
ssylvan / gist:0309be58e5448e3c7989
Last active March 14, 2016 18:05
Ray-point optimization

I would've derived it differnetly. Rather than explicitly setting up the equation for squared distances then finding the solution that minimizes it, I would've just used the normal equations to do the least squares part for me. IMO this makes it a bit more "mechanical" in figuring out the soluion (I just need to figure out what equation I'm trying to solve, the normal equation can be memorized and will figure out how to compute the least squares solution to it).

So we already have the equation from the stackexchange thing for computing the "offset vector" from a point to the line. You can express this in different ways, but they way they did it is fine. Basically the 3D vector telling us how far a point x is from the line described by an origin o and a direction u.

ray_to_point_offset = (I - u*ut)*x - (I-u*ut)*o

That first term is "x projected onto a plane with normal u", and the second term is "ray origin projected to the same plane". So the difference between the two is just finding the perpendicu