diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-03-21 02:34:10 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-03-21 02:34:10 -0400 |
commit | 395aad915a98aaeea721fcf8d24baec989a13154 (patch) | |
tree | 357d143c105fe8c3905d65b44d2ad68cca7469ab | |
parent | 1c0b9859061de48b3246a6b274cb33b506217e53 (diff) |
fix formatting on a couple of pages
-rw-r--r-- | public/make-memoize.html | 15 | ||||
-rw-r--r-- | public/make-memoize.md | 61 | ||||
-rw-r--r-- | public/purdue-cs-login.html | 24 | ||||
-rw-r--r-- | public/purdue-cs-login.md | 12 |
4 files changed, 51 insertions, 61 deletions
diff --git a/public/make-memoize.html b/public/make-memoize.html index f67c5c5..6dcc7fc 100644 --- a/public/make-memoize.html +++ b/public/make-memoize.html @@ -22,13 +22,13 @@ rest = $(wordlist 2,$(words $1),$1) # How to use: Define 2 variables (the type you would pass to $(call): -# `_<var>NAME</var>_main` and `_<var>NAME</var>_hash`. Now, `_<var>NAME</var>_main` is the function getting -# memoized, and _<var>NAME</var>_hash is a function that hashes the function arguments +# `_<var>NAME</var>_main` and `_<var>NAME</var>_hash`. Now, `_<var>NAME</var>_main` is the function getting +# memoized, and _<var>NAME</var>_hash is a function that hashes the function arguments # into a string suitable for a variable name. # # Then, define the final function like: # -# <var>NAME</var> = $(foreach func,<var>NAME</var>,$(memoized)) +# <var>NAME</var> = $(foreach func,<var>NAME</var>,$(memoized)) _main = $(_$(func)_main) _hash = __memoized_$(_$(func)_hash) @@ -40,16 +40,17 @@ rest = $(wordlist 2,$(words $1),$1) # How to use: # -# _<var>NAME</var>_main = <var>your main function to be memoized</var> -# _<var>NAME</var>_hash = <var>your hash function for parameters</var> -# <var>NAME</var> = $(memoized) +# _<var>NAME</var>_main = <var>your main function to be memoized</var> +# _<var>NAME</var>_hash = <var>your hash function for parameters</var> +# <var>NAME</var> = $(memoized) # # The output of your hash function should be a string following # the same rules that variable names follow. _main = $(_$0_main) _hash = __memoized_$(_$0_hash) -memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash)))</code></pre> +memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash)))</pre> +<p></code></p> <p>Now, I'm pretty sure that should work, but I have only actually tested the first version.</p> <h2 id="tldr">TL;DR</h2> <p>Avoid doing things in Make that would make you lean on complex solutions like an external memoize function.</p> diff --git a/public/make-memoize.md b/public/make-memoize.md index 03bb2dc..64f4f5f 100644 --- a/public/make-memoize.md +++ b/public/make-memoize.md @@ -3,6 +3,7 @@ A memoization routine for GNU Make functions --- date: "2014-11-20" license: WTFPL-2 +markdown_options: "-markdown_in_html_blocks" --- I'm a big fan of [GNU Make][make]. I'm pretty knowledgeable about it, @@ -29,21 +30,21 @@ unsuitable for my needs. So, I implemented my own, more flexible memoization routine for Make. - # This definition of `rest` is equivalent to that in GMSL - rest = $(wordlist 2,$(words $1),$1) - - # How to use: Define 2 variables (the type you would pass to $(call): - # `_<var>NAME</var>_main` and `_<var>NAME</var>_hash`. Now, `_<var>NAME</var>_main` is the function getting - # memoized, and _<var>NAME</var>_hash is a function that hashes the function arguments - # into a string suitable for a variable name. - # - # Then, define the final function like: - # - # <var>NAME</var> = $(foreach func,<var>NAME</var>,$(memoized)) - - _main = $(_$(func)_main) - _hash = __memoized_$(_$(func)_hash) - memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash))) +<pre><code># This definition of `rest` is equivalent to that in GMSL +rest = $(wordlist 2,$(words $1),$1) + +# How to use: Define 2 variables (the type you would pass to $(call): +# `_<var>NAME</var>_main` and `_<var>NAME</var>_hash`. Now, `_<var>NAME</var>_main` is the function getting +# memoized, and _<var>NAME</var>_hash is a function that hashes the function arguments +# into a string suitable for a variable name. +# +# Then, define the final function like: +# +# <var>NAME</var> = $(foreach func,<var>NAME</var>,$(memoized)) + +_main = $(_$(func)_main) +_hash = __memoized_$(_$(func)_hash) +memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash)))</code></pre> However, I later removed it from the Makefile, as I [re-implemented][reimplement] the bits that it memoized in a more efficient way, such that memoization @@ -53,21 +54,21 @@ Later, I realized that my memoized routine could have been improved by replacing `func` with `$0`, which would simplify how the final function is declared: - # This definition of `rest` is equivalent to that in GMSL - rest = $(wordlist 2,$(words $1),$1) - - # How to use: - # - # _<var>NAME</var>_main = <var>your main function to be memoized</var> - # _<var>NAME</var>_hash = <var>your hash function for parameters</var> - # <var>NAME</var> = $(memoized) - # - # The output of your hash function should be a string following - # the same rules that variable names follow. - - _main = $(_$0_main) - _hash = __memoized_$(_$0_hash) - memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash))) +<pre><code># This definition of `rest` is equivalent to that in GMSL +rest = $(wordlist 2,$(words $1),$1) + +# How to use: +# +# _<var>NAME</var>_main = <var>your main function to be memoized</var> +# _<var>NAME</var>_hash = <var>your hash function for parameters</var> +# <var>NAME</var> = $(memoized) +# +# The output of your hash function should be a string following +# the same rules that variable names follow. + +_main = $(_$0_main) +_hash = __memoized_$(_$0_hash) +memoized = $(if $($(_hash)),,$(eval $(_hash) := _ $(_main)))$(call rest,$($(_hash)))</pre></code> Now, I'm pretty sure that should work, but I have only actually tested the first version. diff --git a/public/purdue-cs-login.html b/public/purdue-cs-login.html index d047d29..b756096 100644 --- a/public/purdue-cs-login.html +++ b/public/purdue-cs-login.html @@ -33,24 +33,12 @@ SessionDesktopDir=/usr/local/share/xsessions/</code></pre> <p>If you look at the GDM login screen, it has a "Sessions" button that opens a prompt where you can select any of several sessions:</p> <ul> <li>Last session</li> -<li><ol type="1"> -<li>MATE (<code>mate.desktop</code>; <code>Exec=mate-session</code>)</li> -</ol></li> -<li><ol start="2" type="1"> -<li>CS Default Session (<code>default.desktop</code>; <code>Exec=default</code>)</li> -</ol></li> -<li><ol start="3" type="1"> -<li>Custom Session (<code>custom.desktop</code>; <code>Exec=custom</code>)</li> -</ol></li> -<li><ol start="4" type="1"> -<li>FVWM2 (<code>fvwm2.desktop</code>; <code>Exec=fvwm2</code>)</li> -</ol></li> -<li><ol start="5" type="1"> -<li>gnome.desktop (<code>gnome.desktop</code>; <code>Exec=gnome-session</code>)</li> -</ol></li> -<li><ol start="6" type="1"> -<li>KDE (<code>kde.desktop</code>, <code>Exec=startkde</code>)</li> -</ol></li> +<li>1. MATE (<code>mate.desktop</code>; <code>Exec=mate-session</code>)</li> +<li>2. CS Default Session (<code>default.desktop</code>; <code>Exec=default</code>)</li> +<li>3. Custom Session (<code>custom.desktop</code>; <code>Exec=custom</code>)</li> +<li>4. FVWM2 (<code>fvwm2.desktop</code>; <code>Exec=fvwm2</code>)</li> +<li>5. gnome.desktop (<code>gnome.desktop</code>; <code>Exec=gnome-session</code>)</li> +<li>6. KDE (<code>kde.desktop</code>, <code>Exec=startkde</code>)</li> <li>Failsafe MATE (<code>ShowGnomeFailsafeSession=true</code>)</li> <li>Failsafe Terminal (<code>ShowXtermFailsafeSession=true</code>)</li> </ul> diff --git a/public/purdue-cs-login.md b/public/purdue-cs-login.md index 81111ca..43bcd68 100644 --- a/public/purdue-cs-login.md +++ b/public/purdue-cs-login.md @@ -46,12 +46,12 @@ If you look at the GDM login screen, it has a "Sessions" button that opens a prompt where you can select any of several sessions: - Last session - - 1. MATE (`mate.desktop`; `Exec=mate-session`) - - 2. CS Default Session (`default.desktop`; `Exec=default`) - - 3. Custom Session (`custom.desktop`; `Exec=custom`) - - 4. FVWM2 (`fvwm2.desktop`; `Exec=fvwm2`) - - 5. gnome.desktop (`gnome.desktop`; `Exec=gnome-session`) - - 6. KDE (`kde.desktop`, `Exec=startkde`) + - 1\. MATE (`mate.desktop`; `Exec=mate-session`) + - 2\. CS Default Session (`default.desktop`; `Exec=default`) + - 3\. Custom Session (`custom.desktop`; `Exec=custom`) + - 4\. FVWM2 (`fvwm2.desktop`; `Exec=fvwm2`) + - 5\. gnome.desktop (`gnome.desktop`; `Exec=gnome-session`) + - 6\. KDE (`kde.desktop`, `Exec=startkde`) - Failsafe MATE (`ShowGnomeFailsafeSession=true`) - Failsafe Terminal (`ShowXtermFailsafeSession=true`) |