Skip to content

Instantly share code, notes, and snippets.

View santileortiz's full-sized avatar

Santiago León santileortiz

  • Mexico
View GitHub Profile
Compiled libraries from Gtk's Git repositoriy will end up inside <gtk repo>/gtk/.libs/. To run an application with these
libraries use:
LD_LIBRARY_PATH=<git repo>/gtk/.libs/ <app>
I normally call it from inside the repository using
LD_LIBRARY_PATH=./gtk/.libs/ ~/<app path>
NOTE: Gtk moved from Autotools to Meson, maybe this will put resulting libraries somewhere else.
@santileortiz
santileortiz / gnome_shell_env
Created May 14, 2018 08:26
Script to setup a virtual terminal to be able to run a debug version of gnome-shell in Ubuntu
gnome_session=$(pgrep --full -u $USER gnome-session-binary.*ubuntu)
eval export $(sed 's/\o000/\n/g;' < /proc/$gnome_session/environ | grep DISPLAY)
eval export $(sed 's/\o000/\n/g;' < /proc/$gnome_session/environ | grep XAUTHORITY)
eval export $(sed 's/\o000/\n/g;' < /proc/$gnome_session/environ | grep XDG_SESSION_TYPE)
eval export $(sed 's/\o000/\n/g;' < /proc/$gnome_session/environ | grep DBUS_SESSION_BUS_ADDRESS)
@santileortiz
santileortiz / gist:698adbde7b1af1a1e3299886551aa864
Created January 24, 2018 07:40 — forked from ChickenProp/gist:3194723
The Liang-Barsky algorithm for line-rectangle collisions

The Liang-Barsky algorithm is a cheap way to find the intersection points between a line segment and an axis-aligned rectangle. It's a simple algorithm, but the resources I was pointed to didn't have particularly good explanations, so I tried to write a better one.

Consider a rectangle defined by x_min ≤ x ≤ x_max and y_min ≤ y ≤ y_max, and a line segment from (x_0, y_0) to (x_0 + Δ_x, y_0 + Δ_y). We'll be assuming at least one of Δ_x and Δ_y is nonzero.

Image depicting the situation

(I'm working with Flash, so I'll be using the convention that y increases as you go down.)

We want to distinguish between the following cases: