1. 3

    I find these blog posts from you really uninspiring. This is information that should just be in documentation. I don’t feel you’re adding any value.

    1. 2

      So, hide it and move on?

      1. 1

        Exactly :) Well said. I’ll also have more to say tomorrow.. Busy now.

    1. 2

      I recently had a curious bug….

      I have a build system that sniffed /proc/cpuinfo to guess how many compiles to run simultaneously.

      On my own box it shows I have 8 processors… So I tried running 9 (8+1) compiles.

      I also note it says cpu cores: 4.

      So I benchmarked and found number of cores + 1 was the fastest for compiling. The CPU I have has “hyperthreading” which may help with threads sharing the same cached data within the same process, but doesn’t help with compiles.

      Then we ran it on a 40 CPU Monster Server.

      Alas, cpuinfo tells me “cpu cores: 1”, so my build system ran only two compiles on the monster server!

      The program lscpu solved the mystery for me…

      CPU(s):                40
      On-line CPU(s) list:   0-39
      Thread(s) per core:    1
      Core(s) per socket:    1
      Socket(s):             40
      

      The monster server had 1 core per socket and 40 sockets!

      Whereas my hyperthreading desk top had

      CPU(s):                8
      On-line CPU(s) list:   0-7
      Thread(s) per core:    2
      Core(s) per socket:    4
      Socket(s):             1
      

      So where does the utility lscpu get it’s information?

      Strace reveals it gets it from /proc/cpuinfo AND /sys/devices/system/cpu

      I think it is probably just easier to parse the output of lscpu.

      1. 1

        Interesting. I had only tested my program on Windows. Will run it on Linux too and compare with your results from the proc file system and so on. Using strace was a good idea.

      1. 1

        This post is really poor. You don’t even have the source code linked.

        1. 2

          Oh heck. That happened accidentally. I proof read my posts and code, before publishing. In fact I don’t write them directly in Blogger nowadays - I write them first in a text editor (vim), and check things before pasting into the Blogger new post window. Even then I preview first, a couple of times, before publishing, then again after publishing, check all the links, text, etc. (because sometimes links don’t show on hovering over them in the preview). Might have got distracted by something today and missed out one or two of those steps. Sorry for inconvenience / annoyance caused to readers.

          Thanks for mentioning this.

          Adding the source code to the post now, and will comment here again when done.

          1. 1

            Adding the source code to the post now, and will comment here again when done.

            Done. See the OP.

        1. 2

          porting an app from ocaml+gtk to fsharp + eto.forms, in the hope of getting a cross-platform ui for free.

          1. 1

            Interesting. How are you finding the latter two to be for GUI app work?

            1. 2

              very pleasant so far. F# is similar enough to ocaml that i have very little difficulty translating the code. most of the problems have dealt with setup issues - e.g. this is my third try at using it and the first two times i abandoned it because i couldn’t get the latest f# working on linux. this time around i got everything compiled, but the documentation for doing things from the command line is pretty sparse (i’ve started a collection of fsharp-quickstart shell scripts to help with that). i did run into one problem i haven’t yet been able to solve (details here), but i’ve kicked that down the road and will continue developing the app and assuming i’ll find a solution once i’m more familiar with .net.

          1. [Comment removed by author]

            1. 1

              I don’t know a lot about this area, but was checking it out a while ago, and read that EXEs packed with packers like UPX can have that issue - some anti-virus softwares wrongly detect them as malware. I think I read the same about some apps created with Delphi too, but don’t remember if the reason was mentioned.

              What are you writing your Podcast Downloader in?

            1. 3

              This simple joke bot in Python as an example for Python programming beginners (some of whom I’m teaching, and also for fun).

              1. 4

                Definitely for beginners. The program in this blog reminds me of those books in the 80s that I could get from the library about 25 or 50 simulation games in basic. I think they were also printed in 3-2-1 Contact magazine for a while. Are people producing those materials still for people just starting out?

                1. 1

                  Are you thinking of these books, by any chance? :)

                  1. 1

                    The program in this blog reminds me of those books …

                    I used to read a lot of those books (and magazines) too. Good fun and learning. In those days resources were limited, so you had to do more with less. E.g. I remember buying a book about the assembly language of a personal computer (Commodore 64); it had the entire listing of an assembler (in BASIC, using POKE statements). (Also, the book was written by a teenager, IIRC :) I spent some days manually entering the entire listing into the PC. Had to restart from the middle a couple of times due to typos. Finally got it done and could write and run some small assembly language programs.

                    Are people producing those materials still for people just starting out?

                    Probably. I do, on a small scale, via some of my blog posts.

                    Here’s a guy who writes such books:

                    https://inventwithpython.com/

                  1. 1

                    Mostly customer related stuff this week, but I did create this text ruler for the console .

                    1. 1

                      Third in a series of command line utilities in Python - a binary file split utility:

                      http://jugad2.blogspot.in/2016/04/bsplit-binary-file-split-utility-in.html

                      The previous two - a (text) file split utility and a file compare utility - are linked to from the above post.

                      1. 3

                        Last week I got pretty side tracked with the farm. I attended a conference on sustainable living, and sat in on a couple of talks about low maintenance sheep raising systems, which doubled my desire to raise a small flock of my own.

                        This week, I’m planning to finish those data structures. I’ve already wasted enough time, and I shouldn’t have too many distractions outside work/side work/animals, this week.

                        1. 4

                          This is the most intriguing comment I’ve seen on this thread. Farming and data structures seems like a rare mix of activities. I’d be interested to know more of how that came about.

                          1. 2

                            I’m not sure that this thread is the best place to talk about it. If someone’s interested, shoot me a message and I’ll get back to you.

                          2. 2

                            Doing anything like permaculture? Saw some of that and an earthship recently.

                            1. 2

                              I’ve been keeping myself pretty busy with other projects, but one of the things on my list is to get cattails growing near where some of our drain water runs off to act as a filter before it collects in a small basin we’ve dug out. Hopefully it’ll cut down on how much we have to actively water all the animals.

                          1. 4

                            Daughter is out of school for term break this week and next, so we’re doing a bit of travel. Spending a couple of days in Bangkok now, then probably go to Amphawa for 1-3 days tomorrow, then back home. This weekend, we’ll head out to visit father-in-law near the border with Cambodia.

                            For a change of pace, I was wondering about some aspects of Ted Nelson’s Xanadu. I thought that maybe a good way to understand some of it better would be to run some of their open sourced code. So … I imported udanax-green into git and started fiddling with it.

                            I haven’t actually gotten it to work yet. The first issue was that sbrk doesn’t work on Mac OS X, but that was readily worked around. Now, there’s an issue with some of the file I/O code that results in lseek failing.

                            I’d forgotten how bad really old C is. This is K&R C, so pre-ANSI … and it lacks anything resembling modern best practices for C at all. Now, I’m a bit less sure that this is a viable way to come to understand Xanadu better.

                            I’d welcome any assistance with getting this running.

                            Our maid decided to return home, so we’re looking to hire someone new.

                            1. 1

                              I’d forgotten how bad really old C is. This is K&R C, so pre-ANSI … and it lacks anything resembling modern best practices for C at all.

                              That reminds me of using old versions of Microsoft C on DOS, pre-ANSI. And then later versions which were ANSI. IIRC the pre-ANSI MS C versions had a flag (/Zg ?) that could output prototypes for all functions defined in your code, to stdout, and then I used to add them at the top of the .c files. Workaround, but helped, if I remember right.

                              1. 1

                                The lack of prototypes is only one of the many issues. :)

                                If I stick with it (unlikely), I can use cproto and clang-format to clean the formatting and things up a lot … but it would still require substantial changes to fix tons of warnings … much less deal with how it uses globals and all sorts of other issues.

                                And my goal wasn’t to maintain this … I just want to understand parts of it better as I think some things apply to other work that I’m doing.

                            1. 1

                              The previous week I had done a Unix-like split file command line utility in Python. I was going to add an interesting (IMO) twist to it, but that got put on hold (though it is part done), because I thought of writing a file compare utility to test the split utility. Here it is:

                              http://jugad2.blogspot.in/2016/03/a-basic-file-compare-utility-in-python.html

                              and then thought of this one-liner that implements a limited file compare - in memory:

                              http://jugad2.blogspot.in/2016/03/python-one-liner-to-compare-two-files.html

                              A few other things going on, but not enough progress to mention yet.

                              1. 6

                                Battery life on devices is infuriating, a device that can last for weeks sounds like heaven.

                                1. 6

                                  I find myself thinking that if my kindle (non-fire) had an email client and decent web browser (which would necessitate a better screen refresh rate), I’d ditch my phone.

                                  My Droid turbo lasts about two days most of the time, but my kindle lasts for literally weeks. I came back from a two week vacation without charging my kindle, picked it up and started reading without issues. If I could do that with my phone or – even better – my laptop, I would be very very happy.

                                  1. 6

                                    The kindle doesn’t even have to refresh the whole screen it can flip parts of the screen. I’d love to have a e-ink ssh terminal.

                                    1. 4

                                      I bought something along these lines last year - a device called an Onyx Boox i86 which has access to the Play Store, supports Bluetooth keyboards, has a button to switch into eink’s A2 refresh mode for temporary smooth scrolling, etc.

                                      The device isn’t perfect (has a small battery when using wifi/scrolling, shipped with an old Android version (but is now updated)). I haven’t been actively using it but these comments are making me think about trying to make it my primary device for a week.

                                      If yer curious about this stuff I’d check out the mobileread.com forums which seems to be the most active community of eink ereader power users.

                                      1. 3

                                        Oh yeah. Something like this + keyboard and battery would be a dream device for working on a beach.

                                      2. 2

                                        I’m not sure you’d get the same battery in that case though. You’d actually be using the wifi and CPU instead of letting them idle. The screen on most devices certainly uses quite a bit of power, but not all of it.

                                      3. 3

                                        I still use feature phones for exactly this reason. Smart phones are for kids.

                                        I always have to laugh when people compare their smartphones' speed to old mainframes. You know what they also have in common? Being useless a useless brick when not near a power outlet.

                                        PS: The Nokia 100/200 are pretty great. 3-4 weeks without charging.

                                        1. 2

                                          Do you use a separate device for IM, GPS, browsing, etc? Just curious

                                          1. 1

                                            No.

                                          2. 1

                                            That’s actually a good point. I guess the reason the smartphone makers don’t try for better battery life is because not enough people complain or walk away from their products. Wouldn’t be surprised if the scene changed pretty fast if people actually voted with their feet.

                                          3. 2

                                            I wonder how much it would cost to build a mono-functionality device like this today.

                                            1. 4

                                              It’s not even monofunctionality, IMHO (workflow and UI is one side of his equation though) - it’s the fact we have giant backlit colour screens and massive cores. Put a super-low power SoC/CPU and a nice ePaper screen and you have a general purpose computer running whatever normal software. Then you can build whatever constrained (in whatever ways you like) software.

                                              1. 4

                                                I’ll be honest my end goal is a SSH on a chip with e-ink screen and a keyboard. The ultimate terminal.

                                          1. 4

                                            Middle of Nowhere, Finland.

                                            1. 3

                                              You have good Internet there?

                                              1. 3

                                                Debatable. The land lines are all held by a monopoly, so the prices are outrageous. Last time I used these, the connection was unstable as hell and the company wouldn’t lift a pinky to diagnose let alone fix the issue. Bad old copper down under, I guess. So now I’m stuck with mobile (4G). I never come close to one fourth of the advertised speed, and I need to pay hefty extra to avoid the CGN and get a public IP. And apparently using that APN puts me in the minority of customers that the company doesn’t take notice of when things go down. A mere month after first getting the connection, I had a 24 hour outage. The company thought they had fixed things much much earlier…

                                                I’m not super happy, but when things work, they work reasonably well.

                                            1. 3

                                              India. Lived in both the southern and the central part.

                                              1. 3

                                                Stockholm, Sweden, Scandinavian Peninsula, Europe, Eurasia, Earth (the third planet from the star Sol), Solar System, Orion-Cygnus Arm, Milky Way.

                                                1. 3

                                                  He he, I used to say that sort of thing as a kid (that fully qualified address), except that I didn’t mention Sol, and used to add Universe at the end.

                                                1. 3

                                                  Unix-like file split utility in Python (last week, really, but doing more on it this week.)

                                                  With some differences from the Unix one, and simpler, but with an interesting idea or two (for the parts to come).

                                                  http://code.activestate.com/recipes/580620-unix-like-split-command-in-python-simple-version/?in=lang-python

                                                  1. 2

                                                    Really makes me wish I’d held onto my Palm IIIe I had as a kid.

                                                    1. 1

                                                      Almost the same thought here, about my Palm devices. Except in my case both of mine got damaged after a year or two of use. My first was a Palm V, and later I had a Palm Zire.

                                                      Not sure, but it seems like that they don’t make such interesting and good devices nowadays, even though the hardware power and specs keep increasing.

                                                    1. 9

                                                      The newton’s handwriting recognition was legendary - how did they do that with 640k/150k RM and 4 Mb of ROM? That technology needs to be brought back to life and used in modern devices.

                                                      1. 6

                                                        OneNote will probably be the closest you’ll see today. The problem is most devices don’t have pen input and the fact everyone is used to keyboards anyways.

                                                        1. 3

                                                          The newton’s handwriting recognition was legendary

                                                          I had a rare chance to see and try out (a bit) a Newton, soon after they first came out. Happened because a friend who worked at a hardware dealer brought one over to our office when he came to meet some of us. I remember that some of the features were amazing, though cannot remember too well what they were now.

                                                        1. 1

                                                          I had seen the “More shell, less egg” post in 2012 and found it interesting, also the comments there. So I wrote a Python program for it and also a shell (bash) script. (My solutions do not exactly match the problem definition, though, w.r.t. the definition of a word.) They are here:

                                                          http://jugad2.blogspot.in/2012/07/the-bentley-knuth-problem-and-solutions.html