Skip to content

Instantly share code, notes, and snippets.

View santileortiz's full-sized avatar

Santiago León santileortiz

  • Mexico
View GitHub Profile
@santileortiz
santileortiz / nocache_server.py
Created September 12, 2021 06:46
Python 3.8 no cache simple server
#!/usr/bin/python3
import http.server
class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_my_headers()
http.server.SimpleHTTPRequestHandler.end_headers(self)
def send_my_headers(self):
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
@santileortiz
santileortiz / awk_split_join.txt
Last active June 24, 2020 09:09
Example of split/join of fields with AWK
This example shows how $0 and the other $n fields change during the execution
of an AWK script. In a sense this is what using AWK is all about.
Consider the following awk script, with " 1 2 3 4 5" as input.
{
print_fields();
$1 = "";
$3 = "";
@santileortiz
santileortiz / Building Burr Tools
Created May 3, 2020 03:04
Procedure for building Burr Tools in elementary OS
- Install dependencies
$ sudo apt-get install libfltk1.3-dev install libboost-all-dev libxmu-dev
- Go to src/Makefile.am and add -lboost_system to LDADD, should be
LDADD= $(GUI_LD_ADD) $(XML_LD_ADD) $(PTHREAD_LD_ADD) -lboost_system
- Run regeneate makefiles with
$ aclocal; automake
- Run configure
@santileortiz
santileortiz / CountryCoodrinates
Last active April 4, 2020 04:23
Wikidata query that returns country coordinates
SELECT ?code ?countryLabel ?coordinates WHERE
{
?country wdt:P31 wd:Q3624078 ;
p:P625 ?location .
#not a former country
FILTER NOT EXISTS {?country wdt:P31 wd:Q3024240}
#and no an ancient civilisation (needed to exclude ancient Egypt)
FILTER NOT EXISTS {?country wdt:P31 wd:Q28171280}
# This doesn't bring all countries. It misses Armenia for example.
@santileortiz
santileortiz / C_conditional_macro.c
Created March 29, 2020 19:47
Conditional macro based on number of passed arguments
// This is a way of executing a different macro based on the number of argument
// passed to a macro with variable arguments. Essentially this is a way of
// executing macros conditionally even though C doesn't support using #if inside
// a macro definition.
//
// Source: https://stackoverflow.com/questions/3046889/optional-parameters-with-c-macros
// The multiple macros that you would need anyway [as per: Crazy Eddie]
#define XXX_0() <code for no arguments>
#define XXX_1(A) <code for one argument>
@santileortiz
santileortiz / gist:08724683e74270efd3a5ac22788b694f
Last active March 13, 2019 04:56
Unexpected behavior of GTree
When using GTree I made the mistake of keeping pointers to keys and overwriting
them. I expected this would only affect the overwritten keys, and make lookups
for them return NULL. What actually happened was that other keys not related to
these became unaccessible. I am puzzled as to why this happened, it may be
interesting to dig inside GTree's implementation and see what's going on.
My guess is doing this breaks the sorted invariant of the tree, then things
will go crazy next time it tries to balance it, maybe for some reason it tries
to fix it by replacing existing keys?. Or, maybe the result of the string
comparison function does not really check for equallity, and instead has an
Information on how to create a custom layout
https://medium.com/@damko/a-simple-humble-but-comprehensive-guide-to-xkb-for-linux-6f1ad5e13450
https://github.com/damko/xkb_kinesis_advantage_dvorak_layout
Information about the RMLVO configuration format and syntax of the 'rules' file
http://who-t.blogspot.com/2008/09/rmlvo-keyboard-configuration.html
Very detailed description of how to configure XKB, it includes information about the syntax of .xkb files.
https://www.charvolant.org/doug/xkb/html/xkb.html
@santileortiz
santileortiz / xkb keymap testing
Created October 16, 2018 15:15
commands I use to study/debug keymaps in Linux
Current (unresolved) keymap file
================================
The following command prints one include statement for each component of the
current keymap:
$ setxkbmap -print
Note that this is not a resolved keymap file!. Quite the opposite, it shows
what will be passed to xkbcomp as components so that it resolves them to an
The syntax for setting up a third level key in a .xkb file seems to be vey
picky, I still need to explore more xkbcomp's source code to know how things
work.
I noticed this because recently the way I used to define the AltGr key in my
custom layout stopped working. I'm not sure which commit in which project
caused this to stop working, could have been libxkbcommon (xkbcomp), xserver,
Gdk among others. What I do know is that suddenly pressing AltGr would set
GDK_MOD1_MASK in the received key release event. This modifier is treated by
Gdk (Together with GDK_CONTROL_MASK) as one that will NEVER serve to translate
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.