Skip to content

Instantly share code, notes, and snippets.

View ochafik's full-sized avatar

Olivier Chafik ochafik

View GitHub Profile
@ochafik
ochafik / README.md
Last active February 13, 2022 10:17
Building OpenSCAD with remeshing to fix fast-csg's performance on very large models

fast-csg is still a work in progress.

For large models it works best with CGAL/cgal#5461 in CGAL and used in OpenSCAD by openscad/openscad#4107.

If you want a sneak peek of the new world, enable fast-csg-remesh in the following build:

( git clone https://github.com/sloriot/cgal \
    -b PMP-decimation --depth=1 \
    cgal-sloriot-PMP-decimation && \
@ochafik
ochafik / README.md
Created February 5, 2022 00:37
Repro instructions for a CGAL compilation bug that started in 5.3 (PMP::triangulate_faces + Gmp)

Only happens in mingw32 64bit builds (whether building in Windows on a msys2 env, or cross-building from linux w/ the MXE environment).

docker run -it openscad/mxe-x86_64-gui:latest
apt install -y vim cmake

# Then paste the script above
@ochafik
ochafik / pivpn-wg-show.sh
Created December 28, 2021 02:04
Wrapper around `wg show` that uses pivpn configuration names instead of peer ids
#!/bin/bash
#
# Beautifies output of `wg show` using config names from pivpn
#
wg show | awk "BEGIN { $(
# Map peer to preshared key
wg show all preshared-keys | awk '{ print "key[\"" $2 "\"] = \"" $3 "\";" }'
for f in $( ( . /etc/pivpn/wireguard/setupVars.conf ; echo $install_home ) )/configs/* ; do
# Map preshared key to config name

Get your free SSL server certificate semi-manually in 10 minutes w/ Letsencrypt

This script runs certbot in manual mode with a custom adhoc local DNS server (written in node.js using my fork of joyent/node-mname) to respond to its challenge.

The Let's Encrypt non-profit does an amazing job at helping hosting providers provide SSL certificates for free to their customers. This should be your first choice to get one, but maybe your provider prefers charging you for said certificates. That's where we come to play.

If you've just bought a domain and have a Unix machine connected to the internet (laptop, VPS or dedicated instance), you'll get your SSL certificate in 10 minutes chrono. Let's start!

Prerequisites

@ochafik
ochafik / test_pmp.cc
Created February 20, 2021 01:14
Check edge cases of CGAL::Polygon_mesh_processing::corefine_and_compute_union
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
//
/*
https://github.com/openscad/openscad/pull/3641
g++ \
-stdlib=libc++ -std=c++1y \
-I../CGAL-5.2/include \
-lgmp -lmpfr \
@ochafik
ochafik / repair.cc
Created February 19, 2021 19:52
CGAL::Polyhedron_3 repair code with CGAL::Polygon_mesh_processing::repair_polygon_soup
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
//
#include <CGAL/Polygon_mesh_processing/repair_polygon_soup.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
template <typename K>
std::shared_ptr<CGAL::Polyhedron_3<K>> repairPolyhedron(const CGAL::Polyhedron_3<K> &poly)
{
@ochafik
ochafik / README.md
Last active February 22, 2021 15:04
CGAL corefinement vs. potentially-invalid inputs vs. attempts to fall back to Nef: error cases

Here's now to build the branch from openscad/openscad#3641 (see full build instructions)

git clone --depth 1 http://github.com/ochafik/openscad  --single-branch --branch fast_csg ochafik-openscad
cd ochafik-openscad
rm -fR objects/
qmake openscad.pro \
  CONFIG+=debug \
  CONFIG+=experimental \
 CONFIG+=info \
@ochafik
ochafik / cgal-kernels.h
Last active July 26, 2023 12:18
CGAL: convert between CGAL::Cartesian<CGAL::Gmpq> and CGAL::Epeck
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <CGAL/Cartesian.h>
#include <CGAL/Gmpq.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ochafik
ochafik / benchmark results.txt
Last active January 30, 2021 18:38
Experiment w/ fast-union heuristic to break local overlapping barriers
# Context: https://github.com/openscad/openscad/pull/3636
Notice the N=3 vs. N=5 below. All test on a MacBook Pro w/ 2.6GHz Core i7.
# Baseline
time openscad spheres_single_for_loop.scad -o out.stl -DN=3 -Doverlap=true # 52s
time openscad spheres_nested_for_loops.scad -o out.stl -DN=3 -Doverlap=true # 45s
time openscad spheres_single_for_loop.scad -o out.stl -DN=5 -Doverlap=true # 3min32
time openscad spheres_nested_for_loops.scad -o out.stl -DN=5 -Doverlap=true # 2min41