HN user

101914

129 karma
Posts2
Comments111
View on HN

Use the command line to get the URLs for each chapter?

  Go to conqueringthecommandline.com/book
  Save the page source
  Insert the filename into the script below
  Alternatively, omit filename and pipe the source of the page to the script 

  Works with BSD sed as well as GNU sed; first lesson: portability

   a=$(printf '\004')
   sed 's/s3_url/'"$a"'&/' \
   |tr '\004' '\012' \
   |exec sed '
   s/\\u0026/\&/g;
   s/.*s3_url.:.//g;
   s/\".*//g;
   /https:.*Amz/!d;
   ' filename
I do not recommend this "book". Look at the hoops they make readers jump through. Try grymoire.com; much better and no Javascript required

I guess journalists read HN looking for stories? I was suprised to spitbol mentioned on HN and now there is a story on Vice news?

Alas, the interviewer asked no technical, interesting questions. There is a portable assembly language called MINIMAL that is used in spitbol. This could be a topic for an entire story itself.

This is from 2012.

He's wrong of course about being the only user.

I love this software, along with k/q. I admire the work Mr. Shields has put into this project. I especially like the use of musl and provision of static binaries.

I do not use Perl, Java, Python, Javascript, Go, Rust, Closure, etc., etc. Whatever the majority of people are recommending, that is generally not what I use. It just does not appeal to me.

I guess I am stubborn and stupid: I like assembly languages, SPITBOL, k/q, and stuff written by djb. Keep it terse. Ignore the critics.

Yet this is now on the front page of HN. Maybe because it is the weekend? I really doubt that the software I like with ever become popular. But who knows? Maybe 10 years from now I will look at this post and marvel at how things turned out.

There is no "structured programming" with spitbol. No curly braces. Gotos get the job done. Personally, I do not mind gotos. It feels closer to the reality of how a computer operates.

Would be nice if spitbol was ported to BSD in additon to Linux and OSX. As with k/q I settle for Linux emulation under BSD.

Beautiful response to a recurrent misunderstanding.

"Shell languages are defined by their terseness."

It is common to see people put a layer of verbosity on top of the Bourne shell (or system(3)) to make "a new shell".

It is also very common to see people put a layer of abstraction on top of a large, verbose scripting language and claim the result to be a new, "terse" language (with all the power of the shell).

But what I like about the Bourne shell is that it is built from only C. And it does not add too much verbosity. It is, as you say, defined by its terseness.

There is also terseness in the roff-like typesetting languages, assembly languages, FORTH, k/q, etc.

Compared to k/q, sh is verbose.

For me, verbosity means loss of power and loss of time.

I am glad there are terse languages.

They may never again be popular but I think they will always exist.

"The worst parts of the shell are the flow control structures..."

For some reason I dislike if/then/else. Instead I make heavy use return values, ||, test(1) and case/esac.

I always wished Bourne's shell (cf. Joy's C shell) made use of more C operators. There's a file called arith_lex.l in the Almquist sh source but these operators are not used in the sh language.

I would switch to the Plan 9 shell but Bourne sh remains more useful due to its ubiquity.

I wrote my own. I can change it faster when YouTube changes something than waiting for someone else. YouTube makes downloading very straightforward. No need for Perl, Python or any interpreter except sh.

  # requirements:
  # sh, sed (BSD ok), tr, openssl, ftp or some other httpclient

  curl=ftp 
  file=${2-1.mp4} # default outfile

  # itag #s are on the wikipedia page for youtube

  case $# in
  [12])
  {
  sed 's/http:/https:/' \
  |while read a;
  do

  b=${a#*://}; 
  c=${b%%/*}; 
  {
  printf "%b" "GET /${a#https://*/} HTTP/1.0\r\n";
  printf "Host: $c\r\n";
  printf "User-Agent: OK, Google.\r\n";
  printf "Connection: close\r\n\r\n";
  } \
  |openssl s_client -ign_eof -connect $c:443 -verify 9 
  done \
  |sed '
  s,http,\
  &,g;
  ' \
  |sed '
  /%3A%2F/!d;
  /videoplayback/!d; 
  s,%3D,=,g;
  s,%3A,:,g;
  s,%2F,/,g;
  s,%3F,?,g;
  s/^M//g;
  ' \
  |sed -e '
  s/&itag=5//;t1
  s/&itag=1[78]//;t1
  s/&itag=22//;t1
  s/&itag=3[4-8]//;t1
  s/&itag=4[3-6]//;t1
  s/&itag=1[346][0-9]//;t1
  ' -e :1 \
  |sed '
  s,%26,\
  ,g;
  s,&,\
  ,g;
  ' \
  |sed 's/%25/%/g' \
  |tr '\012' '&' \
  |sed 's/&$//'; 
  echo 
  } \
  |sed '
  s,%3D,=,g;
  s,%3A,:,g;
  s,%2F,/,g;
  s,%3F,?,g;
  s/^M//g;
  ' \
  |sed '
  s/&https/\
  \
  https/g;' \
  |sed 's/\\u0026.*//' \
  |sed '/itag='"${1-.}"'/!d;'|{ 
  read a;
  exec $curl -4o $file $a;}
  ;;
  *)
  exec echo \
  "usage:   $0 itagno [outfile]
  outfile: $file"
  esac
A Tiny NTP client 11 years ago

Here's a portable version for those of us who do not use Bash:

  a=$(printf '\xb%-47.s' \
  |nc -uw1 ntp.metas.ch 123 \
  |exec xxd -s40 -l4 -p) 
  b=$(printf %d\\n 0x"$a")
  c=$((b-2208988800))
  date -r$c
There is a way to do the xxd step using original netcat. Included with nc was a short program called nc-data. It converts from btoa and atob for shoveling data to nc.

Slower than xxd but still useful. It also shows octal, decimal and byte number.

Another exercise might be a one-liner for the TAICLOCK protocol: http://cr.yp.to/proto/taiclock.txt (Alternative to SNTP with smaller packets and support for leap seconds.)

Q: "... why aren't you using youtube-dl?"

A: "holy crap that is convuluted"

I do not use Python nor a Javascript-enabled web browser to download video.

Both are big, convoluted, slow(!) and unnecessary.

But I do agree with using mplayer for playback.

For me there are generally 3 steps to the process of watching a youtube video.

1. Get the video id. Retrieve HTML containing youtube /watch?v= urls or other urls that contain the video id. Extract the urls from the HTML or other markup garbage.

2. Retrieve the video. Feed the /watch?v= url to a script that does some "find and replace" on the absurdly long googlevideo urls. Below I have given an example of such a script. Complaints welcome. It takes a /watch?v= url on stdin and retrieves the video in the format specified on the command line.

3. Play the video. ffmpeg libraries, mplayer, etc.

Whatever it is Flash does in the process of watching youtube videos (I am quite sure it is not step 3), I do not need it.

Thus even if by not using Flash or a complex "modern" web browser to watch youtube videos somehow were to reduce my exposure to vulnerabilities that routinely occur in such software, I would not care. Because the reason I do not use Flash is.... because I do not need it.

   # proof of concept: video retrieval
   
   # requirements:
   # sh, sed, tr, openssl, ftp
   
   # Adobe Flash not required
   # HTML5 not required
   # Python not required
   # Awk not required
   # web browser not required
   
   
   curl=ftp 
   file=1.mp4 # default outfile 
   url=www.youtube.com # example
   
   
   # itag #s are on the wikipedia page for youtube
   
   
   
   f061(){
   sed '
   s,%3D,=,g;
   s,%3A,:,g;
   s,%2F,/,g;
   s,%3F,?,g;
   s/
//g; ' }
   f060(){
   sed -e '
   s/&itag=5//;t1
   s/&itag=1[78]//;t1
   s/&itag=22//;t1
   s/&itag=3[4-8]//;t1
   s/&itag=4[3-6]//;t1
   s/&itag=1[346][0-9]//;t1
   ' -e :1
   }
   
   f062(){
   sed '
   s,http,\
   &,g' 
   }
   
   f063(){
   sed '
   /%3A%2F/!d;
   /videoplayback/!d' 
   }
   
   f064(){
   sed '
   s,%26,\
   ,g;
   s,&,\
   ,g;
   ' 
   }
   
   f065(){
   sed 's/&https/\
   \
   https/g;' 
   }
   
   f066(){
   sed 's/\\u0026.*//' 
   }
   
   f067(){
   sed '/itag='"${1-.}"'/!d;' 
   }
   
   f068(){
   sed 's/%25/%/g' 
   }
   
   
   f069(){
   tr '\012' '&' 
   }
   
   f070(){
   sed 's/&$//'; echo 
   }
   
   f071(){
   local a061 a062 a063;
   while read a; do 
   case $a in 
   https://*)a061=${a#https://*/} ;; 
   http://*)a061=${a#http://*/} ;; 
   *)a061=${a#*/} ;; 
   esac; 
   a062=${a#*://}; 
   a063=${a062%%/*}; 
   printf "%b" "${1-GET} /${a061} HTTP/1.0\r\n" 
   printf "Host: ${a063}\r\n";
   printf "User-Agent: GoogleAnalytics 1.5.1\r\n";
   printf "Connection: Close\r\n";
   printf "\r\n";
   done;
   }
   
   f072(){
   openssl s_client -ign_eof -connect $1:${2-443} -verify 9 
   }
   
   
   
   
   
   
   
   case $# in
   [12])
   {
   f071 \
   |f072 $url \
   |f062 \
   |f063 \
   |f061 \
   |f060 \
   |f064 \
   |f068 \
   |f069 \
   |f070
   } \
   |f061 \
   |f065 \
   |f066 \
   |f067 $1 \
   |{ 
   read a;
   exec $curl -4o ${2-$file} $a ;
   }
   
    ;;
   *)
   exec echo \
   "usage:   $0 itagno [outfile]
   outfile: $file"
   esac

The shell I use on x86 returns the value in ax as the shell variable $?.

I have always thought about the idea of a shell that could return values from other registers.

I guess there are reasons this would be a stupid experiment. Or maybe I am the only one could see the utility of it.

Did anyone see Bourne's keynote at BSDCan about how sh was developed? I only looked at the slides.

Meanwhile I use a debgger for asm programs called ald to trace register values. I found a nasty bug in this program but I am not aware of any similar debuggers aimed at asm (cf. C).

Opinion: Some not so quietly; in any case, most of them are not worth reusing. But there are exceptions, e.g., stralloc.h

Opinion: Personally, because I strive to learn more than to be "productive", I prefer languages that force the author to write her own libraries. As I see it, the alternative is languages that discourage this, effectively coercing the author to use other people's libraries, the quality over which she has no control.

Opinion: For me, the bad part is that there are so many poorly thought out C functions in the wild (even including the "standard" ones); the good part is that the C language encourages authors to write their own libraries.

Given the choice, I still prefer assembly to C. I guess this is because I prefer to write small programs; perhaps I am not smart enough to write large ones.

"In summary, the answer is to write lean, efficient and small pieces of code..."

What if the user could avoid "non trivial" programs, i.e. the ones that purportedly make it impossible to avoid shared libraries?

To put it another way, what if a user could have a system containing only trivial programs that each do one thing and then use them in combination to do "complex" tasks?

The term "non trivial software" is one I see continuously used as an underlying assumption and hence a justification for maintaining the status quo of all manner of existing software problems.

I do not want more "non trivial" software. I want simplicity and reliability. Not to mention comprehensibility. I get those things from so-called "trivial" software.

When some the "non trivial software" I am forced to use becomes too reliant on too much resources or too many dependencies, I stop using it and find an alternative.

This strategy has worked beautifully for me over the years.

Shared libraries was a useful concept in its day.

In my humble opinion, those days have passed. GB of memory is more than enough for me personally.

I like to use crunched binaries in my systems. As such, I do not seek out "non-trivial" software and am always looking to eliminate any existing dependencies on it.

"Who thinks in terms of CPU registers these days..."

That's pretty much the only way I think these days, but I guess assembly does not qualify as "modern language" even though it can and is used to control the lion's share of the world's "modern" computers. Matters little to me; I'm hooked.

I do not write in Lua, and I am sure I will be quickly corrected by someone who does, but isn't it considered both (virtual) "register-based" and "modern"? My sincerest apologies to the Lua experts if I am wrong.

My kdb is behind haproxy; just using kdb's built-in HTTP/1.0 webserver for now. I am still experimenting with stored procedures and haproxy's regexp filtering/rewriting.

Has anyone ever compared the performance of kdb+ on Linux versus BSD? It works under compatibility mode under the latter but I have never benchmarked it against some other OS. Apparently there is Kx customer demand for a Solaris version but none for BSD?

Isn't this one listed in 86LIST04.LST?

That list is still easy to find via Google? I believe it is bundled with the Ralph Brown interrupt list.

What "doesn't feel right to me" is Google's treatment of Usenet archives.

It should still be possible to download these messages in their original plain text format, in bulk using only the internet... i.e., without using the www and all the cruft that comes with it.

x86 Disassembly 11 years ago

This comment validates all the time I have "wasted" reading HN over the years.

It does not suprise me that something so simple would be so well overlooked (or, at least, "forgotten"). I wonder if I ever would have figured this out from my own readings and experiments. Doubtful.

Great tip!

Your point is understood.

For something like that, I have always thought they should be disseminating their cert via some other means besides an untrusted computer network (i.e., the internet). Or at least give customers another option.

Perhaps making their cert available at branches (e.g., printed on business cards), mailing it to customers with an expository cover letter, or even publishing it in a newspaper or some publicly available printed source.

Maybe these printed copies would be OCR-friendly, maybe not. I think two blobs of text can be compared to each other for differences without using a computer, and I can think of a few ways to make that easier. In any event, this does not seem an insurmoutable problem by any stretch of the imagination, at least for me, and in my mind the benefit outweighs the cost.

Not sure about others, but I still get plenty of "official" notifications via postal mail. And with increasing frequency they relate to computer issues.

This makes me wonder why certs "must" to be obtained and verified using (a) an untrusted computer network (the internet) and (b) why we need the aid of untrusted third parties often with obvious conflicts of interest to decide for us who else we can trust.

Are these not the two things that that "SSL" authentication and encryption is designed to protect against?

How do the commercial CA's verify customers before issuing certs?

Perhaps she does what they do.

I imagine for example she knows her banker, her lawyer, etc. and can contact them by phone or meet with them in person.

Maybe she also uses her friends to help her decide who to trust.

She only has to verify a relatively small number of hosts compared to a commercial CA.