HNHacker News
TopNewBestAskShowJobs

McUsr

83 karma · joined February 17, 2013

submissionscomments
McUsr··on Show HN: C library of generic, reference-counted data structures
Hello. May I suggest looking for some code by tptacek for the red-black trees. I am looking too, but so far , I haven't been able to find it. I read about it first in this link: <https://news.ycombinator.com/item?id=4455225>.

I think your project looks very interesting. Reference counted datastructures is a great convenience.

Thanks, and Good Luck further.

McUsr··on A response to Linus Torvalds on C++ (2007)
I don't code a line of C++ if I don't have to.

Apple uses C++ in their kernel in a nice way, they don't use virtual methods and templates.

I agree totally that C++ looks good and all, and that there might be bright sides to it. But to me, it is not as discernible as C at least. And I do enjoy programming in C, I need to feel I am in control, and C gives me that.

McUsr··on Ask HN: So, I need regular expressions...
Hello.

Use sed in a do shell script. short example (on the fly).

  set mytext to "sise" & LineFeed
  set fixed to do shell script "sed -n 's/size/sise/g' <<<" & mytext

I have written a script, for letting you first copy your terminal commandline, when you have figured it all out, so that you can paste it into a do shell script, it can be found here <http://macscripter.net/viewtopic.php?pid=163300#p163300>; And Macscripter.net is a great forum for AppleScript questions.
McUsr··on C-source to deal with OS X Finder aliases
Hello.

I just want to make a point of the fact the code doesn't use Carbon, so it should work with the next releases of OS X.

McUsr··on Your top 100 unix commands, for science
I believe I have set HISTFILESIZE TO 2000 or something, I still need to compact it, and have commands like ls pruned by HISTIGNORE.

I use the awkscript below to compact it:

# histsort.awk --- compact a shell history file # Thanks to Byron Rakitzis for the general idea

     {
         if (data[$0]++ == 0)
             lines[++count] = $0
     }
     
     END {
         for (i = 1; i <= count; i++)
             print lines[i]
     }
McUsr··on A rant about some of the nice things in the NT kernel
"You call BSD a kernel, it technically is a set of APIs" If you read that in context of the Mac Os X operating system, then it would be true, as there is a BSD "layer" or "part" in the XNU kernel. So if it had been written in that aspect/context, it would have been correct.
McUsr··on How zsh is more useful than bash
I think the pipe was the issue.

Nice to know that bash doesn't fork loops that are being used with redirection, and not piping!

McUsr··on How zsh is more useful than bash
I thought every shell that is sh compatible would fork a while, and a for loop, as a matter of fact any loop into a sepearate process.

This comment however reminds me of some behaviour of bash 2.03 or earlier, where this behaviour was flawed, if you suddenly changed execution path during a recursion in a shell script. Sorry I can't describe it better, and that bash version, that was before 2.03 is long gone now!

McUsr··on How zsh is more useful than bash
That seems like a good reason for switching to zsh!
McUsr··on How zsh is more useful than bash
Path expansion, can easily be fixed with something like this in bash: CDPATH=".:..:~:~/Desktop:~/Documents:~/Documents/Prj:~/bin:/usr/local:/usr/local/share:/opt/local"

     for realm in ~/Library/Caches/temporaryitems ~/* ~/Desktop/* ~/Documents/* ~/Documents/Prj/* ~/Library/* ~/Library/Scripts/* ~/Library/
     do
         for folder in $realm
         do
                 if [ -d ${folder} ] 
                 then 
    *             CDPATH="$CDPATH":"$folder"
                 fi
         done
     done
As for completions of git and such, that relies totally upon where you got your completion from. There gotta be better arguments than this, and I am really sure there is.

I am on Mac OsX, and I downloaded and installed bash 4.2, and I have never experienced any problems with that.

McUsr··on A regular expression matcher By Rob Pike and Brian Kernighan (2007)
Thanks for posting this, and thanks to the OP for posting the link as well. :) I must shamefully admit that I haven't read the book, but it is now on top of my reading list!

This was really a most pleasurable and insightful read. True elegance!

McUsr··on Survey of Commonly Available C System Header Files
Hello.

All I see that is that it is a survey, I wonder what kind of tests that are used to draw the conclusions. I also see for instances that the regexp.h file is absent for OS X Lion, which is reworked to work wide wide characters. But, the header files may fail in ways I don't know about, that is why I ask for the tests that makes up for the results.

McUsr··on Survey of Commonly Available C System Header Files
Hello.

This is really nice, I just have one question, ( maybe I have overlooked it), where is the test-suite for gathering the data?´, as to which headerfiles are workable or not? Is there a configure script there? I mean, I am on Snow Leopard, and I have no trouble using unistd.h which is marked as flawed on the graph.

McUsr··on The Sed FAQ
Hello. It is always nice with more stuff on sed, Here is a nice link for those wanting to learn the basics: http://www.grymoire.com/Unix/Sed.html
McUsr··on List out of Lambda
Seriously, what I need in a programming language depends on what I intend to achieve with it.

I use blocks in Objective-C and "closures" in Applescript.

    to lambda(aStatment)
    	script intern
    		say aStatment
    	end script
    end lambda
    set a to lambda("applescript…")
    set b to lambda("knows how to …")
    set c to lambda("make a closure if not a lambda…")
    tell a to run
    tell b to run
    tell c to run
McUsr··on A lot of free ebooks
Thanks for sharing this, Now this was a great link!

I want to recommend Eric S. Raymonds books for those that haven't read them.

McUsr··on Some dark corners of C
I am glad we all aren't experts like you then, some of the stuff I knew from before, some were really relieving.

So I am glad it was posted, it helped, me, and this comment page was also, something to both smile/laugh and learn something from. Thanks

McUsr··on Unix tricks
This was a nice very timely page sitting with my private repo in mercurial, and the other one at github…

I discovered help <builtin> some months ago, and that was a great boon really. Like help "test" so I didn't have to go the rather large bash man page.

Here is a little shellscript for displaying a man page on Mac Os X (gman). (If you then click on on of the links on the man-page, it may pop up in your default browser).

  #!/bin/bash
  if [ $# -lt 1 ] ; then
  	echo "gman takes a man page, if found and formats it into html."
  	echo "Usage: gman [manfile]"
  	exit 2
  fi
  a=`man -aw $* |head -1`
  if test  x$a = x ; then
  	echo "Can't find $1"
  	exit 1
  fi
  # Figures out if it is a normal man page or something else (gz).
  b=`man -aw $* |head -1 |grep "gz"`
  echo $b
  if test  x$b = x ; then
  	groff -man $a -Thtml >|/tmp/tmp.html
  else
  	gzcat $b |groff -man -Thtml >|/tmp/tmp.html
  fi
  qlmanage -p /tmp/tmp.html >/dev/null 2&>1
McUsr··on How I ended up with Mac
I'd say the opposite, forget about Homebrew and keep Macports. The whole thing may not be so easy to use at first, but when you have read the docs for the port system, it all makes much more sense.
McUsr··on How I ended up with Mac
I just want to add, that once you want packages and such, for a tool chain, you'll at least discover some problems, as there is a package anarchy out there compared to GNU/Linux! But http://macports.org has a solid repository of packages. When it comes to "private packages" packages I have found outside repos, I do install them as "account installs", that is ~/opt/bin, ~/opt/man/man1 .. and so on, so it is easier to upgrade the OS, and less conflicts with the different packet managers.

Having said that, most things do work, and people are friendly and easy to reach.

Most GNU packages just work, shouldn't you find what you are looking for elsewhere.

I think Mac Os X, (or just OS X now adays), is the greatest platform for free software ever!

My reason for starting out with a Mac was Applescript (http://macscripter.net) and inter application communication IPC. I haven't regretted that a single day.

McUsr··on Show HN: Increase your productivity with ambient noise
I liked this webservice! :)
McUsr··on Ask HN: Webdevs, designers: what devtools should we (Mozilla) build in Firefox?
Hello. I think first and foremost FireFox should build in support for disabilities, so that one can get to its UI Elements. The nice side-effect is that governments, which has laws regulating software for the benefit of disabled workers, then are able to use it.
McUsr··on Index soon to be portable "database-file program" for OS X
I am slorry for the lowercased "x", a typo.

This software should however work on Mac Os X from 10.5 onwards as it will then use the ICU libraries that shipped with Mac Os X from that version. Ncurses 5.9 you'll have to get from http://macports.org, or directly from the source.

McUsr··on Why Use Make
I just want to inform you that GNU make indeed is very good for c projects as it can read the dependency files made by gcc (and clang), so you get very small very readable makefiles, that takes care of tracking the dependencies for you. http://wiki.osdev.org/Makefile
McUsr··on Why Use Make
Yes, this is something I have thought through, though I may have been lucky/unlucky with my pick of projects. But generally speaking, installs I have installed based on GNU autotools, seems to install with less fuzz than those with C-Make. So, that, and the fact that there is full free documentation of GNU Autotools, even books out there, have made my personal choice easy.

For me the overall factor is the ease for any of my users, installing something I have written.

McUsr··on Index soon to be portable "database-file program" for OS X
It is Os X only at the moment, I have to adjust the buffer calculations, as widechars, utf-16 and ordinary bytes are involved. I have used 64-bit wchar_t. So I have to go over the calculations. But other than that, I think it should compile on other *nix'es, provided you have access to the Ncurses library, and ICU, both downloadable and open source.
McUsr··on Index soon to be portable "database-file program" for OS X
I am very tired a the moment, it is passed bed time here. But you are so right.

Here is the short version.

You are a person that uses the commandline. You are doing some activity, either reading a text book, or gathering some information, debugging, or are having some ideas you'd like to structure, basically you are having a need for a structured information collection. At the time it pops into your head; hey it would be nice to have a "database" to register this stuff into, so that I later can retrieve it.

Then you fire up index, and enter a filename that you haven't used before. Index then fires up your editor, and you write the fieldnames you need, (up to 16). You close the editor, and you are sent to the "main menu" from where you can start entering records. It uses ncurses, and is really fast; you move between the fields with ctrl-n and ctrl-p, and are asked if you want to save the record when you press Esc.

Later on you can just enter the name from the main menu, and search and edit/delete/add new records.

You can make make index sort and print the records in a variety of ways through command line options. You can also have small filter files, based on awk or perl, to filter by a field if you like. I have modified it slightly from the original, so it is possible for a lot of files to share a single label file, so that you can have one "database" file per subdirectory, sharing the same "field-layout" if that suits your purpose (for modules for instance).

It should also work well with UTF-8, and collation ordering according to locale settings. (This includes reg-exp patterns thanks to IBM and their ICU library.)

Thanks for your feedback!

McUsr··on Index soon to be portable "database-file program" for OS X
Hello.

Maybe I should, but I have just linked in the html version of the man file, which has an example.

But I will really consider adding more examples.

McUsr··on Interactive Vim Tutorial
This was a nice intro to vim, showing the concepts fast. I was just wondering about the match braces commands. I propose that you show off the yank registers, and the @ macro function as well, along with the marks. Another great command is q: and q/. Another area is movement with marks, and filtering, maybe filtering isn't that easy to implement in your tutorial.
← PreviousPage 4 of 4