Threads for susam

    1. 1

      We know that b_a = 0 for distinct a,b in H because a and b are basis vectors.

      The linear algebra in this post is a bit imprecise. Basis vectors need not be orthogonal but this article assumes they are.

      1. 2

        We know that b_a = 0 for distinct a, b in H because a and b are basis vectors.

        The linear algebra in this post is a bit imprecise. Basis vectors need not be orthogonal but this article assumes they are.

        It is not clear to me why you think that this article assumes orthogonal basis vectors. Regarding the part you quoted, i.e., b_a = 0, it follows directly from the properties of basis vectors alone.

        Since b belongs to the vector space ℝ with basis ℋ, we can write b as unique finite linear combination of elements of ℋ. Therefore write

                 b = sum_{a ∈ H} b_a ∙ a      (1)

        where b_a ∈ ℚ and b_a ≠ 0. Now let

                 b_a = 1 when b = a,

                 b_a = 0 when b ≠ a.

        This satisfies the equality in (1). Since the expansion of the RHS in (1) is unique, b_a = 0 must hold.

        1. 1

          Thanks for that, you are correct. I assumed b_a would be the projection of b onto a as it would be if they were orthogonal but that isn’t true generally.

    2. 2

      I use the command rg with the Emacs package dumb-jump. This is probably not the most popular way of using rg with Emacs but I have been quite happy with the results. All I need to do is package-install the dumb-jump package and configure the following hook:

      (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
      

      Now the familiar Xref key sequences and commands work fine with it. For example, if I type M-. (or C-u M-.) to find definitions of an identifier in a Python project, dumb-jump runs a command like the following, processes the results, and displays the results in an Xref buffer.

      rg --color never --no-heading --line-number -U --pcre2 --type py '\s*\bfoo\s*=[^=\n]+|def\s*foo\b\s*\(|class\s*foo\b\s*\(?' /path/to/git/project/
      

      Note how it automatically restricts the search to Python files and the current project directory. If no project directory is found, it defaults to the home directory.

      It supports the silver searcher tool ag too which happens to be quite fast as well. If neither ag nor rg is found, it defaults to grep which as one would expect can be quite slow while searching the whole home directory.

      1. 2

        Addendum to my above comment: rg can be used quite easily with the project.el package too that comes out of the box. This is especially useful when we do not want a package like dumb-jump to perform smart things (ironical?) like restricting searches to a specific file type. We need to configure the following first otherwise it defaults to 'grep which can be quite slow on large directories:

        (setq xref-search-program 'ripgrep)
        

        Then a project search with C-x p g foo RET ends up executing a command like the following on the current project directory:

        rg -i --null -nH --no-heading --no-messages -g '!*/' -e foo
        

        The results are displayed in an Xref buffer again which in my opinion is the best thing about using Emacs with external search tools.

        1. 2

          wow, I really liked your solution, I did not know that how to configure project.el to default to ripgrep it definitely makes my life easier, I’ve never used dumb-jump before, but I bet it’s an interesting tool

          thanks for sharing your experience

    3. 16

      Hello! I wrote this tiny software last night. This was written as a fun exercise. No practical usage is intended.

      There are some demos available here: #0, #1, #2, #3, #4, #5, #6, #7.

      More details and background about this software are available here: https://github.com/susam/cfr

      If you end up creating some interesting demos, please share them!

      1. 2

        Very cool little language, and love the web based implementation.

        A fun challenge is to try to golf a full canvas grid with 4x4 squares.

        My first two attempts:

        1. [[[[[[[[[[[[[[FFFFRR]]FFFF]]]]]][RRR]FFFFRR]]]]]]
        2. [[[[[[[[[[[[[FFFFRR]RRRR]]]]]]FFFF]]]]]]
      2. 1

        Seeing some of the examples here, it would be nice if you could add a button that would give people a link with the program URL encoded so that they could easily share their creations without requiring people to copy and paste.

        1. 1

          This works already! You can just put your code in the URL as an anchor (i.e. after the #). It’s just that lobsters mangles these.

          1. 2

            Thanks for closely observing how this tool works and for sharing these details. To work around the issue of mangled URLs while posting in forums like this, I have updated the tool to encode the input code in a simpler format that is going to be resistant to such mangling.

            Further the fragment identifier part of the URL is now updated live as we type code, so the URL is always in a form that can be distributed with others.

            Here is an example of a distributable link: https://susam.net/cfr.html#B15F2E7R2FBR3E6CE3

    4. 1

      On mobile, there seems to be no way to run the program (I guess hitting enter on a keyboard will)?

      1. 1

        Just tired and I didn’t need to « run » anything, the canvas was being drawn on while I was adding instructions.

      2. 1

        The code executes automatically as we type each command. For example, if we enter FFFF, a column of cells are painted automatically as we type each F. However, the output may look too small on a mobile display.

        What happens, for example, when you enter [[[[FF]]]]? Do you see a column of painted cells that gets taller and taller as you type each closing ]?

        1. 3

          Ah, I pressed CFR and nothing appeared to happen (I didn’t know what was meant to happen, but I didn’t see anything that looked like drawing). I pressed C and R a few more times, but since they change colour and rotate, I didn’t see anything. If I press F a bunch of times, I see a line. It would be nice to have a little bit of text explaining what the things do. It made a lot more sense after reading the first paragraph of your readme.

    5. 2

      I first learnt about the <guid> element in RSS while validating my feed on https://validator.w3.org/feed/.

      For each <item> element that is missing the <guid> element, the validator complains like this:

      line 22, column 0: item should contain a guid element (3 occurrences) [help]

      The help link in the error message has this to say:

      It’s recommended that you provide the guid, and if possible make it a permalink. This enables aggregators to not repeat items, even if there have been editing changes.

      A frequently asked question about <guid>s is how do they compare to <link>s. Aren’t they the same thing? Yes, in some content systems, and no in others. In some systems, <link> is a permalink to a weblog item. However, in other systems, each <item> is a synopsis of a longer article, <link> points to the article, and <guid> is the permalink to the weblog entry.

    6. 2

      The first programming language I learnt to program in was Logo, specifically IBM/LCSI PC Logo that I encountered in the computer laboratory of our primary school. It too did not have any command to draw curves or circles. However, we were taught to draw a “circle” using code like this:

      REPEAT 360 [FD 1 RT 1]

      But alas, circles did not exist! It is easy to realise that the above code does not attempt to draw a circle. These instructions specify a triacosiahexeacontagon instead.

      Here is a screenshot of what the actual output looked like: https://susam.net/blog/fd-100.html#circles. The rendered output in fact has lesser number of sides than 360 due to rounding errors involved while translating the logical lines to pixels on the canvas.

    7. 14

      Some more news about it here: https://www.linuxfoundation.org/press/announcing-opentofu

      Today, the Linux Foundation announced the formation of OpenTofu, an open source alternative to Terraform’s widely used infrastructure as code provisioning tool. Previously named OpenTF, OpenTofu is an open and community-driven response to Terraform’s recently announced license change from a Mozilla Public License v2.0 (MPLv2) to a Business Source License v1.1, providing everyone with a reliable, open source alternative under a neutral governance model.

    8. 4

      There is also set a region, C-u M-| sort to run sort on the region and replace them with the output but maybe that’s not inside Emacs.

      1. 4

        Good point! I do use C-u M-| for other filter commands, although not for sorting. However I have gone ahead and added this to my post and explained how C-u M-| too may be used to sort a region (or in general, run any arbitrary filter command on the region) because I think this is useful information for the readers of the post. Thanks for the nice comment!

      2. 3

        Correct, which means it’s slower and (in theory) less portable (though, even on Windows, Emacs usually has access to MSYS, so you’ll still have sort). In practice, since I had to know how to use sort anyway, I tended to use that over the sort-<foo> commands in Emacs, but I’ll also confess that I learned quite a few neat tricks in this article that might’ve sent me the other direction.

    9. 21

      Very well written! Sorry you had to go through this. Also, I’m glad you could get this issue resolved.

      Here is my own DNS horror story where the domain name I was using was taken away from me without any warning or due process: https://susam.net/blog/sinkholed.html.

      The underlying cause of the issue in my story was a false-positive during anti-malware operation too. What really surprised me was that an anti-malware foundation had the authority to remove me as the registrant of the domain name and assign someone else without any form of notification to me or the domain name reseller.

      Here is yet another story where someone’s domain name was lost due to a registrar bug: https://medium.com/thisiscala/the-duct-tape-holding-the-internet-together-12118be60ff1.

      1. 7

        Wow… I got lucky by comparison — at least I didn’t lose control of anything, merely got inaccessible for a part of the user base. Extra-judicial domain seizure is really extreme.

    10. 2

      Some of you may recall Devil from another announcement a few weeks ago that introduced it as a twisted key sequence translator for Emacs. It began as a personal project. For several years, I kept it private because I felt that the community members may find some of the design decisions and the default choices to be outrageous. But after sharing it with the Emacs community recently, I was pleasantly surprised by the warm and supportive feedback received from many kind and generous community members.

      This package is now available in MELPA and NonGNU ELPA. Thanks to the Emacs community for code reviews, feedback, discussions, and patches prior to inclusion in the package archives. One of the patches helped with separating out the documentation in the my original README into a separate manual. This post links to the manual rendered as HTML. I hope you find it useful in case you are curious to try Devil mode with Emacs. In case you are not, I hope you’ll at least find the manual intriguing.

        1. 1

          This looks really nice! Thanks for sharing. By the way, I first experimented with comma-based editing commands mixed right within “insert mode” editing in one of my other projects named Muboard. In Muboard, for example, while typing regular text, one can type ,d to insert display mathematics, or type ,i to insert inline mathematics, etc. I liked the ergonomics of that editing style and that’s what soon led to devil.

    11. 1

      Have always been interested in trying to get past beginner. Will have to check out the recordings to catch up. Any incentives on the book purchase for the book club attendees?

      1. 3

        The recordings are available for 7 days only. This is long enough to allow participants who have missed a particular meetup to watch it later but not so long that it undermines the hard work and copyright of the author. Therefore the attendees who want to revisit the concepts might want to purchase the book.

        1. 1

          Ah 😕

    12. 1

      Hello Lobsters! I have posted this game here on this forum earlier. This is a tiny hobby project of mine.

      While I have received good feedback on this game in the earlier posts, many people have also complained that the levels get too difficult too quickly. Despite the apparent steep rise in the difficulty level, I have found that it is possible to reach level 5 with some practice and level 11 after a lot of practice. I don’t know anyone who has reached level 12 yet.

      Today I decided to add an autoplay feature to the game where the game program plays the game on its own. If I remember correctly, some DOS games of the 1980s era used to have such a feature. So this “show” post is meant to show this autoplay feature in action. The autoplay algorithm is quite rudimentary. It sometimes makes mistakes. However, it has been found to reach level 12 a few times. That is better than my friends and I can play this game. Despite the primitive nature of the algorithm, I find it quite fun to watch. I hope you find it fun too!

    13. 1

      I love Codepage 437 too. I understand what the project does, but what do you see as its intended use? Line why would I use this instead of VileR’s woff fonts?

      1. 3

        I use a subset of this project to write text on the game canvas here: susam.net/invaders.html (see also the project source at github.com/susam/invaders).

        In the first iteration of this game, I used CanvasRenderingContext2D.fillText() to draw text using regular fonts. However, I was not happy with the results. The web browsers introduce antialiasing and subpixel rendering that smoothens the jagged, crisp edges of the text. While I could get rid of similar antialiasing artefacts in the game graphics by using the CSS declaration image-rendering: pixelated, the web browsers would still introduce antialiasing for any text rendered with CanvasRenderingContext2D.fillText().

        So I took the matter of rendering text on canvas into my own hands by drawing the text myself using filled squares. For every pixel that needs to be plotted with the foreground colour of the glyph, a filled square is drawn on the canvas now. This meant that I needed to maintain bitmap arrays of the glyphs I wanted to draw on the game canvas. This project, PC Face, was born out of that activity. I shared the work as a separate self-contained project, so that if anyone else needs to do what I had to do, they could use these bitmap arrays or the scripts shared in the project to create their own bitmap arrays.

        1. 1

          Fair enough, I ran into this problem myself trying to scale CP437 fonts nicely. Eventually I realised it’s impossible and restricted myself to integer scaling only.

    14. 3

      Well done! Nice that it fits in so little code. :)

      A tiny note on the game design: In normal invaders, the alien ships come closer to you, increasing the tensions as the level goes on. In this game, it’s basically the hardest in the first 3 seconds of a new level, and after that gets easier. That makes the ending of each level pretty anticlimactic.

      1. 2

        Thank you for the nice feedback! I have now updated the game to make the ships gradually descend as each game level progresses. The lesser is the number of ships remaining on the screen, the faster is the rate of descent. Ultimately, if a ship manages to descend to the same level as that of the player, the ship moves rapidly towards the player, collides with the player, and ends the game. I am hoping this would keep the player on their toes all the time because a ship coming too close would result in the player losing immediately.

    15. 35

      Pretty ironic to see this post hosted on a .sh domain name. Yes, .io domains are harmful but so are .sh domains!

      1. 16

        true!! I wish someone had informed me before I hitched my life to a .sh domain. i hope my post helps someone avoid similar regrets.

        1. 1

          Well the web isn’t (yet) hotel california, domains can move hinthint

          1. 3

            easier said than done when my email is hosted on that domain as well & everyone polling my RSS feed would need redirection 😥 plus, all my historical links would break. i would like to move but it’s a lot of work and churn for a site that i’ve built up for years.

            1. 5

              I hosted my website, RSS feeds, and email on a .in domain for 16 years. Then I decided to move everything to a .net domain. Since my entire setup is version controlled, it took only a few commits to move my website and email from the old .in domain to the new .net domain:

              The migration went well without any issue. There has been no loss of RSS feed subscribers. The web server access logs show that all the RSS clients and aggregators were successfully redirected to the new domain.

              1. 5

                receive emails for both old and new domains

                I agree with you that it’s not hard to switch domains (I’ve also done it myself), but, because I used my old domain for email, I’m essentially forced to keep paying for it. Otherwise, someone could just buy up my old domain and start receiving my emails. I’ve gone through the process of updating my email for just about every service I know, but even after four years I still get the occasional email sent to my old domain. Maybe if I can go five years without receiving any emails for my old domain I’d feel more comfortable giving it up, bit even then it still feels like a security risk.

                Switching domains for ethical reasons seems moot if you still have to keep paying for it.

    16. 4

      You could also get there by jumping to a null pointer?

      1. 3

        Yes!

        C:\>DEBUG
        -A
        1165:0100 JMP 0
        1165:0103
        -G
        
        Program terminated normally
        -
        

        And then

        -N JUMPER.COM
        -R CX
        CX 0000
        :3
        -W
        Writing 00003 bytes
        -Q
        
        C:\>JUMPER
        
        C:\>
        
    17. 2

      why not use asdf or something like that?

      1. 4

        Some of the scaffolding (Makefile, test macros, etc.) in the project is more than a decade old which I have copied from project to project over these years. Back then I was not aware of ASDF. Since this old scaffolding has been working fine for me, when I began rewriting MathB.in in Common Lisp, I just copied the same scaffolding over to this project. As a result, the thought of introducing ASDF for building and packaging never occurred to me. I might consider it though in future depending on my available leisure time and priorities.

    18. 6

      I don’t use Vim a lot these days but several years ago, when I was an avid Vim user, one of my favourite Vim features was the blockwise-visual mode that can be started with the Vim key sequence ctrl-v. It is very nifty for making rectangular selections and move around columns of text.

      I use Emacs these days which offers a very similar functionality in the form of rectangular-mark-mode that can started with the Emacs key sequence C-x SPC.

      1. 2

        Long ago I installed a plugin named visualDrag.vim. I still have it installed and bound to my arrow keys in visual mode. It lets you use ctrl-shift-v to go into rectangular visual mode and then shift just the selected characters around, shift everything else to make it work.

    19. 2

      Hey, I’d add an && break to make it stop once a success is reached:

      for ttl in {1..30}; do ping -4 -c 1 -t $ttl example.com && break; done | grep -i from | nl -s ' ' -w 2
      
      1. 2

        Thanks! This makes the output much neater. I have updated this command in my post to include the && break now.

        1. 4

          I don’t know if this was happening before I suggested improvements, but grep is buffering more than a single line and doesn’t output til the end. This made it much more real time:

          for ttl in {1..30}; do ping -4 -c 1 -t $ttl example.com && break; done | grep --line-buffered -i from | nl -s ' ' -w 2
          

          (https://unix.stackexchange.com/a/293289)

    20. 3

      What’s the agenda for the meeting this Tuesday?

      1. 2

        On Tuesday, we will read the first couple of pages of the handbook and discuss the first few introductory problems in the problem set. We will keep an updated schedule and study plan available here: https://offbeat.cc/cses/. Right now it says,

        Current plan: Problems 1-6; Pages 3-11 (Oct 19-21)

        In case that looks like a slow schedule, indeed our reading sessions tend to be slow-paced most of the time. We pick only about one or two topics in most meetings. As a meeting host, I focus on spending a decent amount of time with each concept with the intention of developing good intuition for the subject matter, as opposed to covering too many items in the same meeting.