Posterous theme by Cory Watilo

Filed under: hack

Awesome

Tassilo Horn: A quick pop-up shell for emacs

Some file managers provide a shortcut to quickly embed some terminal that’s initialized with the current directory as cwd. Wouldn’t that be cool to have in emacs?

For example, you edit some file, and then you want to quickly commit it. Using the code below, you can do that like this:

  • Edit the file and save: C-x C-s
  • Popup a shell: F12
  • Check changes and commit (using svn):
    $ svn diff | colordiff
    $ svn ci -m "some changes" RET
  • Close the popup shell again: F12
  • Here’s the code:

    (defvar th-shell-popup-buffer nil)
    
    (defun th-shell-popup ()
      "Toggle a shell popup buffer with the current file's directory as cwd."
      (interactive)
      (unless (buffer-live-p th-shell-popup-buffer)
        (save-window-excursion (shell "*Popup Shell*"))
        (setq th-shell-popup-buffer (get-buffer "*Popup Shell*")))
      (let ((win (get-buffer-window th-shell-popup-buffer))
            (dir (file-name-directory (or (buffer-file-name)
                                          ;; dired
                                          dired-directory
                                          ;; use HOME
                                          "~/"))))
        (if win
            (delete-window win)
          (pop-to-buffer th-shell-popup-buffer nil t)
          (comint-send-string nil (concat "cd " dir "\n")))))
    
    (global-set-key (kbd "<f12>") 'th-shell-popup)

    Using that, hitting F12 will popup a *Popup Shell* buffer, initialized in the directory containing the file your are currently editing. If the current buffer is not associated with a file, then the shell’s cwd is your HOME directory.

    Hitting F12 while the popup shell buffer is visible will hide it again. So you can use it as a simple toggle.

    The code ensures that the same shell buffer is reused over and over again (unless you kill it), so that you don’t end up with hundredth of them.

    And here’s a screenshot:

    UPDATES:

    Nyilván (NYILVÁN) megtérek most már, de azért szeretnék ilyent Vim-ben is. Most.

    Awesome

    The Qlobe

    My Quines are sometimes specialized for Japanese. But to attend RubyConf, I should write "global" Quines.

    v=0000;eval$s=%q~d=%!^Lcf<LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
    4ZojjV)O>qIH1/n[|2yE[>:ieC       "%.#%  :::##"       97N-A&Kj_K_><wS5rtWk@*a+Y5
    yH?b[F^e7C/56j|pmRe+:)B     "##%      ::##########"     O98(Zh)'Iof*nm.,$C5Nyt=
    PPu01Avw^<IiQ=5$'D-y?    "##:         ###############"    g6`YT+qLw9k^ch|K'),tc
    6ygIL8xI#LNz3v}T=4W    "#            #.   .####:#######"    lL27FZ0ij)7TQCI)P7u
    }RT5-iJbbG5P-DHB<.   "              ##### # :############"   R,YvZ_rnv6ky-G+4U'
    $*are@b4U351Q-ug5   "              #######################"   00x8RR%`Om7VDp4M5
    PFixrPvl&<p[]1IJ   "              ############:####  %#####"   EGgDt8Lm#;bc4zS^
    y]0`_PstfUxOC(q   "              .#############:##%   .##  ."   /,}.YOIFj(k&q_V
    zcaAi?]^lCVYp!;  " %%            .################.     #.   "  ;s="v=%04o;ev"%
    (;v=(v-($*+[45,  ":####:          :##############%       :   "  ])[n=0].to_i;)%
    360)+"al$s=%q#{  "%######.              #########            "  ;;"%c"%126+$s<<
    126}";d.gsub!(/  "##########.           #######%             "  |\s|".*"/,"");;
    require"zlib"||  "###########           :######.             "  ;d=d.unpack"C*"
    d.map{|c|n=(n||  ":#########:           .######: .           "  )*90+(c-2)%91};
    e=["%x"%n].pack   " :#######%           :###### #:          "   &&"H*";e=Zlib::
    Inflate.inflate(   "  ######%           .####% ::          "   &&e).unpack("b*"
    )[0];22.times{|y|   "  ####%             %###             "   ;w=(Math.sqrt(1-(
    (y*2.0-21)/22)**(;   " .###:             .#%             "   ;2))*23).floor;(w*
    2-1).times{|x|u=(e+    " %##                           "    )[y*z=360,z]*2;u=u[
    90*x/w+v+90,90/w];s[(    " #.                        "    ;y*80)+120-w+x]=(""<<
    32<<".:%#")[4*u.count((     " .                   "     ;"0"))/u.size]}};;puts\
    s+";_ The Qlobe#{" "*18+ (       "#  :#######"       ;"Copyright(C).Yusuke End\
    oh, 2010")}";exit~;_ The Qlobe                  Copyright(C).Yusuke Endoh, 2010

    This quine turns 45 degrees when executed; thus, it will come around when executed eight times (see below). You can make it any-degree turn by giving an integer as an command-line argument.

    v=0416;eval$s=%q~d=%!^Lcf<LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
    4ZojjV)O>qIH1/n[|2yE[>:ieC       ".#####%.#% "       97N-A&Kj_K_><wS5rtWk@*a+Y5
    yH?b[F^e7C/56j|pmRe+:)B     "    .#####%##%      :"     O98(Zh)'Iof*nm.,$C5Nyt=
    PPu01Avw^<IiQ=5$'D-y?    "       #####%###:         #"    g6`YT+qLw9k^ch|K'),tc
    6ygIL8xI#LNz3v}T=4W    "        %########            #."    lL27FZ0ij)7TQCI)P7u
    }RT5-iJbbG5P-DHB<.   "          :#######              ###"   R,YvZ_rnv6ky-G+4U'
    $*are@b4U351Q-ug5   "            ###:  :              ####"   00x8RR%`Om7VDp4M5
    PFixrPvl&<p[]1IJ   "              %#...               #####"   EGgDt8Lm#;bc4zS^
    y]0`_PstfUxOC(q   "                %###               .#####"   /,}.YOIFj(k&q_V
    zcaAi?]^lCVYp!;  "                    :. %%            .#####"  ;s="v=%04o;ev"%
    (;v=(v-($*+[45,  "                      :####:          :####"  ])[n=0].to_i;)%
    360)+"al$s=%q#{  "                      %######.             "  ;;"%c"%126+$s<<
    126}";d.gsub!(/  "                      ##########.          "  |\s|".*"/,"");;
    require"zlib"||  "                      ###########          "  ;d=d.unpack"C*"
    d.map{|c|n=(n||  "                      :#########:          "  )*90+(c-2)%91};
    e=["%x"%n].pack   "                      :#######%          "   &&"H*";e=Zlib::
    Inflate.inflate(   "                      ######%          "   &&e).unpack("b*"
    )[0];22.times{|y|   "                     ####%           "   ;w=(Math.sqrt(1-(
    (y*2.0-21)/22)**(;   "                   .###:           "   ;2))*23).floor;(w*
    2-1).times{|x|u=(e+    "                 %##           "    )[y*z=360,z]*2;u=u[
    90*x/w+v+90,90/w];s[(    "               #.          "    ;y*80)+120-w+x]=(""<<
    32<<".:%#")[4*u.count((     "            .        "     ;"0"))/u.size]}};;puts\
    s+";_ The Qlobe#{" "*18+ (       " .#####  :#"       ;"Copyright(C).Yusuke End\
    oh, 2010")}";exit~;_ The Qlobe                  Copyright(C).Yusuke Endoh, 2010
    
    v=0341;eval$s=%q~d=%!^Lcf<LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
    4ZojjV)O>qIH1/n[|2yE[>:ieC       "#% .#####%."       97N-A&Kj_K_><wS5rtWk@*a+Y5
    yH?b[F^e7C/56j|pmRe+:)B     " :        %#####%##. "     O98(Zh)'Iof*nm.,$C5Nyt=
    PPu01Avw^<IiQ=5$'D-y?    "              #####%###:   "    g6`YT+qLw9k^ch|K'),tc
    6ygIL8xI#LNz3v}T=4W    "                %########      "    lL27FZ0ij)7TQCI)P7u
    }RT5-iJbbG5P-DHB<.   "                   :#######        "   R,YvZ_rnv6ky-G+4U'
    $*are@b4U351Q-ug5   "                     :###   :        "   00x8RR%`Om7VDp4M5
    PFixrPvl&<p[]1IJ   "                        %#...          "   EGgDt8Lm#;bc4zS^
    y]0`_PstfUxOC(q   "                          .###:          "   /,}.YOIFj(k&q_V
    zcaAi?]^lCVYp!;  "                               :. %%       "  ;s="v=%04o;ev"%
    (;v=(v-($*+[45,  "                                 :####:    "  ])[n=0].to_i;)%
    360)+"al$s=%q#{  "                                 %######.  "  ;;"%c"%126+$s<<
    126}";d.gsub!(/  "                                 ##########"  |\s|".*"/,"");;
    require"zlib"||  "%                                ##########"  ;d=d.unpack"C*"
    d.map{|c|n=(n||  "                                 :#########"  )*90+(c-2)%91};
    e=["%x"%n].pack   "                                 ########"   &&"H*";e=Zlib::
    Inflate.inflate(   "#.                              ######%"   &&e).unpack("b*"
    )[0];22.times{|y|   "##                            :####. "   ;w=(Math.sqrt(1-(
    (y*2.0-21)/22)**(;   "#.                          .###:  "   ;2))*23).floor;(w*
    2-1).times{|x|u=(e+    "%    .                   %##   "    )[y*z=360,z]*2;u=u[
    90*x/w+v+90,90/w];s[(    "   .                  #.   "    ;y*80)+120-w+x]=(""<<
    32<<".:%#")[4*u.count((     "                 :   "     ;"0"))/u.size]}};;puts\
    s+";_ The Qlobe#{" "*18+ (       "#.  .##### "       ;"Copyright(C).Yusuke End\
    oh, 2010")}";exit~;_ The Qlobe                  Copyright(C).Yusuke Endoh, 2010
    
    v=0264;eval$s=%q~d=%!^Lcf<LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
    4ZojjV)O>qIH1/n[|2yE[>:ieC       "####% .####"       97N-A&Kj_K_><wS5rtWk@*a+Y5
    yH?b[F^e7C/56j|pmRe+:)B     "#####  :       .#####"     O98(Zh)'Iof*nm.,$C5Nyt=
    PPu01Avw^<IiQ=5$'D-y?    "######.              #####%"    g6`YT+qLw9k^ch|K'),tc
    6ygIL8xI#LNz3v}T=4W    "####:  .                %######"    lL27FZ0ij)7TQCI)P7u
    }RT5-iJbbG5P-DHB<.   "####  .                     :######"   R,YvZ_rnv6ky-G+4U'
    $*are@b4U351Q-ug5   "####%                          ###:  "   00x8RR%`Om7VDp4M5
    PFixrPvl&<p[]1IJ   "###                               %#..."   EGgDt8Lm#;bc4zS^
    y]0`_PstfUxOC(q   "##  ..                               %###"   /,}.YOIFj(k&q_V
    zcaAi?]^lCVYp!;  ":#.  .                                    :"  ;s="v=%04o;ev"%
    (;v=(v-($*+[45,  ":   : :                                    "  ])[n=0].to_i;)%
    360)+"al$s=%q#{  "% %#:                                      "  ;;"%c"%126+$s<<
    126}";d.gsub!(/  "#::#.:  %#%                                "  |\s|".*"/,"");;
    require"zlib"||  "  :      :#%                               "  ;d=d.unpack"C*"
    d.map{|c|n=(n||  "       :% :                                "  )*90+(c-2)%91};
    e=["%x"%n].pack   "     %###%%                              "   &&"H*";e=Zlib::
    Inflate.inflate(   "   ########.                           "   &&e).unpack("b*"
    )[0];22.times{|y|   "   ########.                         "   ;w=(Math.sqrt(1-(
    (y*2.0-21)/22)**(;   "   ##:%###.                        "   ;2))*23).floor;(w*
    2-1).times{|x|u=(e+    "       %%    .                 "    )[y*z=360,z]*2;u=u[
    90*x/w+v+90,90/w];s[(    "          .                "    ;y*80)+120-w+x]=(""<<
    32<<".:%#")[4*u.count((     "                     "     ;"0"))/u.size]}};;puts\
    s+";_ The Qlobe#{" "*18+ (       "####.  .###"       ;"Copyright(C).Yusuke End\
    oh, 2010")}";exit~;_ The Qlobe                  Copyright(C).Yusuke Endoh, 2010
    
    v=0207;eval$s=%q~d=%!^Lcf<LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
    4ZojjV)O>qIH1/n[|2yE[>:ieC       "#######% .#"       97N-A&Kj_K_><wS5rtWk@*a+Y5
    yH?b[F^e7C/56j|pmRe+:)B     "##########: :        "     O98(Zh)'Iof*nm.,$C5Nyt=
    PPu01Avw^<IiQ=5$'D-y?    "#############.             "    g6`YT+qLw9k^ch|K'),tc
    6ygIL8xI#LNz3v}T=4W    "############:  .               "    lL27FZ0ij)7TQCI)P7u
    }RT5-iJbbG5P-DHB<.   "#############  .                   "   R,YvZ_rnv6ky-G+4U'
    $*are@b4U351Q-ug5   "##############                       "   00x8RR%`Om7VDp4M5
    PFixrPvl&<p[]1IJ   "#  %#########                          "   EGgDt8Lm#;bc4zS^
    y]0`_PstfUxOC(q   "    %#:  %##:  :                         "   /,}.YOIFj(k&q_V
    zcaAi?]^lCVYp!;  "     #.   .:#.  .                          "  ;s="v=%04o;ev"%
    (;v=(v-($*+[45,  "      :    :   : :                         "  ])[n=0].to_i;)%
    360)+"al$s=%q#{  "          :% %#:                           "  ;;"%c"%126+$s<<
    126}";d.gsub!(/  "           #::#.:  %#%                     "  |\s|".*"/,"");;
    require"zlib"||  "             :      :#%                    "  ;d=d.unpack"C*"
    d.map{|c|n=(n||  "                  :% :                     "  )*90+(c-2)%91};
    e=["%x"%n].pack   "               .###%#                    "   &&"H*";e=Zlib::
    Inflate.inflate(   "             ########.                 "   &&e).unpack("b*"
    )[0];22.times{|y|   "            :########                "   ;w=(Math.sqrt(1-(
    (y*2.0-21)/22)**(;   "            ##:%###.               "   ;2))*23).floor;(w*
    2-1).times{|x|u=(e+    "               %%    .         "    )[y*z=360,z]*2;u=u[
    90*x/w+v+90,90/w];s[(    "                 .         "    ;y*80)+120-w+x]=(""<<
    32<<".:%#")[4*u.count((     "                     "     ;"0"))/u.size]}};;puts\
    s+";_ The Qlobe#{" "*18+ (       "#######.  ."       ;"Copyright(C).Yusuke End\
    oh, 2010")}";exit~;_ The Qlobe                  Copyright(C).Yusuke Endoh, 2010
    
    v=0132;eval$s=%q~d=%!^Lcf<LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
    4ZojjV)O>qIH1/n[|2yE[>:ieC       ":::#######%"       97N-A&Kj_K_><wS5rtWk@*a+Y5
    yH?b[F^e7C/56j|pmRe+:)B     "################  :  "     O98(Zh)'Iof*nm.,$C5Nyt=
    PPu01Avw^<IiQ=5$'D-y?    "####################.      "    g6`YT+qLw9k^ch|K'),tc
    6ygIL8xI#LNz3v}T=4W    "  .####:############:  .       "    lL27FZ0ij)7TQCI)P7u
    }RT5-iJbbG5P-DHB<.   "# # :#################  .          "   R,YvZ_rnv6ky-G+4U'
    $*are@b4U351Q-ug5   "#######################%             "   00x8RR%`Om7VDp4M5
    PFixrPvl&<p[]1IJ   "######:####  %#########                "   EGgDt8Lm#;bc4zS^
    y]0`_PstfUxOC(q   "#######:##%   .##  .###  ..              "   /,}.YOIFj(k&q_V
    zcaAi?]^lCVYp!;  "##########.     #.   .:#.  .               "  ;s="v=%04o;ev"%
    (;v=(v-($*+[45,  "#########%       :    :   : :              "  ])[n=0].to_i;)%
    360)+"al$s=%q#{  "#########            :% %#:                "  ;;"%c"%126+$s<<
    126}";d.gsub!(/  "#######%              #::#.:  %#%          "  |\s|".*"/,"");;
    require"zlib"||  ":######.                :      :#%         "  ;d=d.unpack"C*"
    d.map{|c|n=(n||  ".######: .                   :% :          "  )*90+(c-2)%91};
    e=["%x"%n].pack   ":###### #:                %###%%         "   &&"H*";e=Zlib::
    Inflate.inflate(   ".####% ::              ########.       "   &&e).unpack("b*"
    )[0];22.times{|y|   " %###                 ########.      "   ;w=(Math.sqrt(1-(
    (y*2.0-21)/22)**(;   " .#%                 ##:%###.      "   ;2))*23).floor;(w*
    2-1).times{|x|u=(e+    "                       %%    . "    )[y*z=360,z]*2;u=u[
    90*x/w+v+90,90/w];s[(    "                        .  "    ;y*80)+120-w+x]=(""<<
    32<<".:%#")[4*u.count((     "                     "     ;"0"))/u.size]}};;puts\
    s+";_ The Qlobe#{" "*18+ (       "##########."       ;"Copyright(C).Yusuke End\
    oh, 2010")}";exit~;_ The Qlobe                  Copyright(C).Yusuke Endoh, 2010
    
    v=0055;eval$s=%q~d=%!^Lcf<LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
    4ZojjV)O>qIH1/n[|2yE[>:ieC       "%  :::#####"       97N-A&Kj_K_><wS5rtWk@*a+Y5
    yH?b[F^e7C/56j|pmRe+:)B     "   .:################"     O98(Zh)'Iof*nm.,$C5Nyt=
    PPu01Avw^<IiQ=5$'D-y?    "     ######################"    g6`YT+qLw9k^ch|K'),tc
    6ygIL8xI#LNz3v}T=4W    "     #.   .####:############:  "    lL27FZ0ij)7TQCI)P7u
    }RT5-iJbbG5P-DHB<.   "     ##### # :#################  . "   R,YvZ_rnv6ky-G+4U'
    $*are@b4U351Q-ug5   "    :############################    "   00x8RR%`Om7VDp4M5
    PFixrPvl&<p[]1IJ   "    ############:####  %#########      "   EGgDt8Lm#;bc4zS^
    y]0`_PstfUxOC(q   "    %############:###    %#:  %##:  :    "   /,}.YOIFj(k&q_V
    zcaAi?]^lCVYp!;  "    .################.     #.   .:#.  .    "  ;s="v=%04o;ev"%
    (;v=(v-($*+[45,  "     :##############%       :    :   : :   "  ])[n=0].to_i;)%
    360)+"al$s=%q#{  "           #########            :% %#:     "  ;;"%c"%126+$s<<
    126}";d.gsub!(/  "           #######%              #::#.:  %#"  |\s|".*"/,"");;
    require"zlib"||  "           :######.                :      :"  ;d=d.unpack"C*"
    d.map{|c|n=(n||  "           .######: .                   :% "  )*90+(c-2)%91};
    e=["%x"%n].pack   "           ######%:#                .###%"   &&"H*";e=Zlib::
    Inflate.inflate(   "          .####% ::              ######"   &&e).unpack("b*"
    )[0];22.times{|y|   "          .###:                :#####"   ;w=(Math.sqrt(1-(
    (y*2.0-21)/22)**(;   "          .#%                 ##:%#"   ;2))*23).floor;(w*
    2-1).times{|x|u=(e+    "                               "    )[y*z=360,z]*2;u=u[
    90*x/w+v+90,90/w];s[(    "                           "    ;y*80)+120-w+x]=(""<<
    32<<".:%#")[4*u.count((     "                     "     ;"0"))/u.size]}};;puts\
    s+";_ The Qlobe#{" "*18+ (       ":##########"       ;"Copyright(C).Yusuke End\
    oh, 2010")}";exit~;_ The Qlobe                  Copyright(C).Yusuke Endoh, 2010
    
    v=0000;eval$s=%q~d=%!^Lcf<LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
    4ZojjV)O>qIH1/n[|2yE[>:ieC       "%.#%  :::##"       97N-A&Kj_K_><wS5rtWk@*a+Y5
    yH?b[F^e7C/56j|pmRe+:)B     "##%      ::##########"     O98(Zh)'Iof*nm.,$C5Nyt=
    PPu01Avw^<IiQ=5$'D-y?    "##:         ###############"    g6`YT+qLw9k^ch|K'),tc
    6ygIL8xI#LNz3v}T=4W    "#            #.   .####:#######"    lL27FZ0ij)7TQCI)P7u
    }RT5-iJbbG5P-DHB<.   "              ##### # :############"   R,YvZ_rnv6ky-G+4U'
    $*are@b4U351Q-ug5   "              #######################"   00x8RR%`Om7VDp4M5
    PFixrPvl&<p[]1IJ   "              ############:####  %#####"   EGgDt8Lm#;bc4zS^
    y]0`_PstfUxOC(q   "              .#############:##%   .##  ."   /,}.YOIFj(k&q_V
    zcaAi?]^lCVYp!;  " %%            .################.     #.   "  ;s="v=%04o;ev"%
    (;v=(v-($*+[45,  ":####:          :##############%       :   "  ])[n=0].to_i;)%
    360)+"al$s=%q#{  "%######.              #########            "  ;;"%c"%126+$s<<
    126}";d.gsub!(/  "##########.           #######%             "  |\s|".*"/,"");;
    require"zlib"||  "###########           :######.             "  ;d=d.unpack"C*"
    d.map{|c|n=(n||  ":#########:           .######: .           "  )*90+(c-2)%91};
    e=["%x"%n].pack   " :#######%           :###### #:          "   &&"H*";e=Zlib::
    Inflate.inflate(   "  ######%           .####% ::          "   &&e).unpack("b*"
    )[0];22.times{|y|   "  ####%             %###             "   ;w=(Math.sqrt(1-(
    (y*2.0-21)/22)**(;   " .###:             .#%             "   ;2))*23).floor;(w*
    2-1).times{|x|u=(e+    " %##                           "    )[y*z=360,z]*2;u=u[
    90*x/w+v+90,90/w];s[(    " #.                        "    ;y*80)+120-w+x]=(""<<
    32<<".:%#")[4*u.count((     " .                   "     ;"0"))/u.size]}};;puts\
    s+";_ The Qlobe#{" "*18+ (       "#  :#######"       ;"Copyright(C).Yusuke End\
    oh, 2010")}";exit~;_ The Qlobe                  Copyright(C).Yusuke Endoh, 2010

    translated from mamememo in Japanese (2010-09-05).

    És ha 10 millió majom használna AWK-t?

    Cross posted from Proggit. Though they don't show self-posts there, so it is good as dead. Copy and paste to terminal and enjoy!

    awk 'function wl() {rate=4000; return int((rate/160)*(0.87055^(int(rand()*10))))}; BEGIN {srand(); wla=wl(); while(1) {wlb=wla; wla=wl(); if (wla==wlb) wla*=2; d=(int(rand()*10+5)*rate/4); a=0; b=0; c=128; ca=40/wla; cb=20/wlb; de=rate/10; di=0; for (i=0;i<d;i++) {a++; b++; di++; c+=ca; c+=cb; if (a>wla) {a=0; ca*=-1}; if (b>wlb) {b=0; cb*=-1}; if (di>de) {di=0; ca*=0.9; cb*=0.9}; printf("%c",c)}; c=int(c); while(c!=128) {c<128?c+=1:c-=1; printf("%c",c)};};}' > /dev/dsp

    If you run OSSv4, use rate=64000 Someone with a better sense of pitch might want to find rate numbers that are more in tune. If it stutters on your computer (though you'd need to have a Pentium 2 for this to happen) use mawk instead.

    It uses a pentatonal scale, so it'll probably sound slightly out of tune no matter what you do.

    It is also my first awk script, go easy on me. Improvements welcome.

    Edit: formatted for your viewing pleasure.

    awk 'function wl() {\
            rate=4000; \
            return int((rate/160)*(0.87055^(int(rand()*10))))}; \
        BEGIN {\
            srand(); \
            wla=wl(); \
            while(1) {\
                wlb=wla; \
                wla=wl(); \
                if (wla==wlb) \
                    wla*=2; \
                d=(int(rand()*10+5)*rate/4); \
                a=0; b=0; c=128; \
                ca=40/wla; cb=20/wlb; \
                de=rate/10; di=0; \
            for (i=0;i<d;i++) {\
                a++; b++; di++; c+=ca; c+=cb; \
                if (a>wla) \
                    {a=0; ca*=-1}; \
                if (b>wlb) \
                    {b=0; cb*=-1}; \
                if (di>de) \
                    {di=0; ca*=0.9; cb*=0.9}; \
                printf("%c",c)}; \
            c=int(c); \
            while(c!=128) {\
                c<128?c+=1:c-=1; \
                printf("%c",c)};};}' > /dev/dsp