Threads for susam

  1. 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.

    1. 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 😕

      1. 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!

        1. 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.

          1. 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.

            1. 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.

              1. 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:\>
                  
                1. 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.

                  1. 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.

                    1. 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)

                      1. 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.

                          1. 3

                            Thanks.

                        1. 1

                          Gearing up for the second edition of our Offbeat Computation Club meetings. The first series of meetings was about analytic number theory. After 120 meetings across 7 months, it was finally concluded in the beginning of this month. The next series of meetings is going to be on solving the CSES Problem Set. The book club meetings will focus on going through a few pages of the CSES handbook together in each meeting as well as on discussing techniques to solve each problem in the problem set. This topic was chosen by popular demand from the current members of the club.

                          I have always been fond of puzzles (mathematical, programming, or otherwise) since my childhood days despite being a considerable time sink and despite having very little utility in life. Nevertheless, I enjoy doing it, so one of the things I am specifically interested in this series of meetings is to look at the same problem from multiple perspectives thus gaining a deeper appreciation of the underlying patterns that lead to interesting mathematical properties related to the problem. I am noting down some of these interesting patterns and observations as virtual boards at https://offbeat.cc/cses/boards/#problem-notes.

                          I have been working on our club website and the schedule for the last few days. I am hoping to make the website completely ready in this weekend. If this kind of club activity sounds like fun to you and you want to participate in our meetings, see https://offbeat.cc/cses/ for more details.

                          1. 1

                            Hi, I’m potentially interested in attending, but the website isn’t very clear on what section of the book and/or what problems will be discussed at the meet. Could you clarify, please?

                            1. 1

                              Thank you for your interest in the book club! It is very likely that we will read the entire book and discuss all the problems in the problem set.

                              The format of the meetings is going to be quite similar to how it was for our previous series of meetings on analytic number theory. The blog post “Our 100th Meeting” offers a glimpse into our meeting style and format.

                              The meeting log of previous meetings shows that we read about 2-3 pages of the book in every meeting. It is very likely going to be similar for this new series of meetings on the CSES problem set and handbook. However, in this new series of meeting we will also focus a lot on solving problems and seeing a problem from different perspectives. We have decided to spend about 20% time reading the book and 80% time discussing the problems.

                              1. 1

                                Ah, so you read the book during the meeting rather than in advance? And solving the problems during the meeting, too?

                                I am more used to clubs where you read a set text (a book, or a chapter, or an article) in advance and then discuss together, but I am still interested, maybe see you on Tuesday :)

                                1. 1

                                  The most serious participants do read the book in advance. As a meeting host, I too read the book in advance. But we read the book together once again line by line during the meetings. We pause at the end of every section to give everyone a chance to add their comments and insights about the section.

                                  So essentially the meeting host and the serious participants do a second pass over the chapters of the book during the meetings. The first pass is typically done privately in advance. For something like analytic number theory where the textbook was very dense, I think a two pass detailed reading approach like this was very helpful in thoroughly understanding the material. I am not yet sure if the same approach would work well for a less dense material like the CSES problem set and handbook. We will see what works well in our meetings and what does not as we make progress. We will then fine tune the meeting style accordingly.

                            2. 1

                              What (coding) language do you speak in the meeting itself? C++?

                            1. 19

                              Gopher Protocol was created at the University of Minnesota for searching and retrieving documents. Its original design featured green text on a black background.

                              Isn’t that the colour of a green monochrome monitor? Pretty sure it would have appeared white on white monochrome and amber on amber monochrome. I see the same problem a couple of paragraphs later.

                              Linux used white text on a black background.

                              A green monochrome monitor would have displayed green text instead.

                              1. 26

                                Yeah, this article is… not exactly well-researched. For instance, it gets the date of the WWW’s beginning wrong by about three years (1987 vs. 1990, or even 1989 at the earliest, if you take the date when the proposal was submitted).

                                It also gets the timeline on the “evolution of the color blue” (!?) backwards, stating (about its use in Windows 3.1, in 1992), that “Microsoft uses the “hyperlink blue” for active states when a user clicks on different drives, folders and icons. This is incredibly important because it shows the slow evolution of this blue from being a layout color to being an interactive color, preceding the time when blue would have been added to Mosaic by almost exactly a year.” But it was already used as the active selection colour in some interface elements (menus, in particular) as early as Windows 1.01 and, of course, in Windows 3.0, almost two years before Windows 3.1. In that sense, its use as an “interactive colour” in Windows 3.0 precedes the entire WWW by a few months (its use in 1.01 should probably be discounted – probably due to palette limitations, there is no single active state colour in Windows 1.01). As with many other things in history, it may well be that this idea of “evolution” from B&W everything to blue as an “interactive” colour to blue as the interactive colour is just our wishful thinking because we want to make history neat and digestible.

                                Also in terms of methodology: it misses a bunch of important questions about Viola, which supported stylesheets (albeit not CSS), such as whether Viola’s stylesheets gained sufficient traction or not. It may well be that no particular browser made the hyperlinks blue, it just turned out to be a popular colour in early stylesheets, or a common user customisation in TkWWW or Viola, and it was made into the default by other browsers, not as a conscious decision, but as a de-facto process. In this case, it’s not that anyone made it blue, it’s just that it slowly become to be accepted as being supposed to be blue, and browsers slowly followed suit.

                                I’m also not very convinced that the original Mosaic interface was black-and-white. I know the screenshot shows it that way but if it’s from an SGI machine, and the dithering on the titlebar makes me think that it is, then it may not be the original colour, as even the earliest IRIS 4D models had colour output. In that case, the changelog for the default anchor representation is somewhat less definitive (e.g. hyperlinks may have been blue and dark purple, respectively, even before that, just without the underline, or there may have been no differentiation between visited and unvisited links etc.)

                                1. 2

                                  The edit period has passed but in case anyone reaches this via Google way later, there is a point that I want to add, since nobody called me on it, and I don’t want it to unwittingly become e-folklore.

                                  I was partly misremembering the “interactive” colour in Windows 3.0. In its default theme (see Note 1), Windows 3.0 did use blue as the active window colour, and as the active selection colour in some programs (e.g. Program Manager), but not in others, like the File Manager, where the active selection colour was still black, much like Windows 2.x. It was also not quite the dark shade of blue that we’ve come to associate with hyperlinks nowadays, but closer to the default background colour in Windows 2000. Of course, the hyperlinks in the help system were green.

                                  The waters of history are muddy and they don’t always align neatly. More often than not, the primary reason why we discern a pattern of evolution is that we simply discard the messy details. This, IMHO, is one of these cases. Do we take blue to have been an “interactive colour” in Windows 1.01, even though it was only used as the active selection colour in some parts of the interface? Does its use as active window indicator count, in which case we also ought to count Amiga Workbench 2.0’s use of blue, in 1990? Do we take colour themes into account – modern systems don’t really support it (or any kind of customisation, for that matter), but this wasn’t always the case. What about systems that used more indicators to signal “interactivity” – Motif, for example, used selections for text boxes, bevels for menus and so on?

                                  Note 1: It’s worth remembering that Windows 3.x supported a lot of them and that, besides the funny/eye-scorching ones like Hotdog Stand, this may have actually been useful in the era of low colour count and poor-quality monitors.

                              1. 10

                                Reading Chapter 8 - Periodic Arithmetical Functions of Gauss Sums from the book Introduction to Analytic Number Theory (Apostol, 1976).

                                A bunch of us who met each other on IRC networks began meeting once everyday for 40 minutes and reading through a couple pages of this book. In the last 3 months, we have covered more than half of the book and we are now reading chapter 8. The two very interesting functions this chapter introduces are Ramanujan’s sum and Gauss sum. While some of us were familiar with Ramanujan’s sum, none of us had any prior knowledge of Gauss sum, so this whole chapter has been a fun ride.

                                1. 6

                                  I was inspired by this to play hooky and implement a tiny Forth core inspired by Wasm3’s clever interpreter. The basic NEXT / DUP / DROP / etc. stuff is about 80LOC, under 200 bytes. I called it Tails because it tail-recurses and it runs fast.

                                  https://lobste.rs/s/wmuvxw/tails_tiny_forth_core_written_as_hack_for

                                  1. 7

                                    I called it Tails because it tail-recurses and it runs fast.

                                    My greatest ambition is to write a Forth and name it Sally. (I don’t have a lot going on.)

                                    1. 5

                                      This is quite nicely done! Thank you for sharing it here.

                                      Off-topic: I noticed that you have named your C++ file with the .cc extension. Your GitHub repo too shows that you and your workplace uses .cc and .hh extensions for C++ source and header files. Do you remember how you ended up using the .cc extension for the first time? Did you pick up this style from another code base you were working on? I ask this because I don’t see this style very often these days. I did a poll on Twitter sometime back about it. It turns out 9 out of 10 use the .cpp extension these days!

                                      1. 2

                                        Huh. I don’t remember why, or when, I started. The work projects I contribute to tend to be repos that I created, and we don’t have any strong company-wide standard I’m aware of, so I wasn’t following someone else’s lead.

                                        I might have picked up this naming convention at Apple, but I don’t remember what I was naming files back then. If WebKit or Chrome uses .cc, that may well have been the seed crystal I picked it up from.

                                        1. 1

                                          You forgot .C…. I’ve seen that way too often.

                                        2. 1

                                          wow - this is impressive, thanks for sharing! :)

                                        1. 1

                                          Update: The post URL containing the demo page has now moved to https://susam.github.io/texme/examples/demo.html.

                                          1. 2

                                            Working on https://muboard.net/.

                                            I wrote this tool initially for our analytic number theory book club. We meet roughly once everyday and study a couple of pages of an analytic number theory book together. During the meeting sessions, I often share my screen and use this tool to scribble some mathematics to expand some steps not explained in the book or illustrate a new theorem we are trying to understand with some examples. The tool also supports archiving the scribbled mathematics snippets as distributable, self-rendering board files too.

                                            After a couple of weeks of using this tool, I released it as an open source project at https://github.com/susam/muboard and received good feedback on the tool. In this weekend, I intend to expose some of the internal properties of the tool as configurable options to the user and expand the documentation to explain these configurable options in detail.

                                            1. 2

                                              Nice work, I love seeing new tools for writing math on the web! My side project recently has been prosemirror-math, which is my attempt to make wysiwyg math editing on the web a little more tolerable. It’s a plugin for ProseMirror that others can hopefully use / modify to add better math support to their markdown editors, etc..

                                              1. 1

                                                ProseMirror Math looks great. Thanks for sharing. Good luck with your project!

                                              2. 2

                                                Interesting. I just finished basic IntelliSense support for MathJaX for a vscode extension that I use with my SSG to render math on the server side. Unfortunately, most of my math is handwritten, and it’s too painful to typeset it, so I’m currently investigating a way to convert handwriting from my tablet to the MathJaX subset of LaTeX automatically.

                                                1. 2

                                                  For OCR, there’s some freemium software called MathPix, which does a pretty great job. However they limit your monthly snips on the free version.

                                              1. 1

                                                Cool! A very minor glitch: in the example document you have a_1 = a_2 = dots = a_k = 1, which renders “dots” literally where you wanted an ellipsis “…”. I’ve long since forgotten all the TeX I knew, but adding a backslash before “dots” fixed it.

                                                1. 1

                                                  Hi @snej! That was indeed an error. Thanks for reporting it. Fixed it now.

                                                1. 3

                                                  Sorry for having the first comment you receive be a (minor) complaint about a platform you likely weren’t targeting. On Firefox on Android, attempting to type ,help makes the help text briefly appear before quickly vanishing. This makes it a tad difficult to understand what this does without resorting to finding it on your GitHub. :P

                                                  (Without having looked into it from a computer, and therefore meaning I don’t know what’s actually happening, my guess would be that this is something to do with changing content when the cursor position changes?)

                                                  1. 6

                                                    Hi @zgrep, Thank you for reporting this issue with detailed information. It helped me to reproduce the issue with Firefox on Android. The issue was caused by a second input event being fired when the text input field was being changed by the tool itself. Apparently, this behaviour seems to occur only with Firefox on Android. This behaviour does not seem to occur with the other browsers I had earlier tested with like Firefox on macOS, Chrome on macOS, iOS, and Android.

                                                    I have now pushed a fix to resolve this issue. The issue you faced should be resolved now. Thanks, once again, for taking a close look at this tool, reporting this issue, and helping me to improve it!

                                                  1. 1

                                                    Working on fixing a bug submitted to me two years ago: https://github.com/susam/uncap/issues/10. This is a tiny and lightweight key remapping tool for Windows, primarily used by Vim and Emacs users. This issue got introduced in the last release (0.3.0) which broke backward compatibility with an earlier release (0.2.2). Here is how the timeline looked:

                                                    • Version 0.2.2 and earlier did not remap injected key strokes. For example, the on-screen keyboard injects keys. Extended keys like “Start Mail” or “Select Media” also cause injected key strokes. This tool ignored injected key strokes to avoid a remap loop (more details here).
                                                    • Version 0.3.0 began remapping injected key strokes. This became problematic for users who want to remap non-injected key strokes but don’t want to map injected key strokes. For example, a user who wants to map actual ctrl of the keyboard to something else but do not want to map ctrl injected by an advanced configurable mouse (an example here).

                                                    My plan is to disable the injected-key-remapping feature by default, so that the default behaviour becomes the same as that of version 0.2.2, and then make the injected-key-mapping feature available via a command-line option. Now, this would still be problematic for users of version 0.3.0 who have become used to injected-key-remapping by default. That is unfortunate. Either way, I am going to create problems for one set of users. If I don’t fix this, version 0.2.2 users see a different default behaviour in version 0.3.0. If I fix this, version 0.3.0 users will now see a different default behaviour.

                                                    Lesson learnt: Even if it is a personal hobby project, as long as it has got at least one other user, do not alter the default behaviour. Introduce any changes to default behaviour with an optional flag or CLI option.