Quickies

[categories] [index] [all (527)] [latest]

PostScript
  1. systemdict (product) get
    
  2. connect on port 9100:

    nc 192.168.1.10 9100
    

    type this:

    %
    executive
    

    get that:

    PostScript(r) Version 3018.102
    (c) Copyright 1984-2004 Adobe Systems Incorporated.
    Typefaces (c) Copyright 1981 Linotype-Hell AG and/or its subsidiaries.
    All Rights Reserved.
    PS>
    
  3. /printUsage {
        (Usage:) =
        (  a - some stuff) =
        (  b - other stuff) =
        (  q - quit) =
    } def
    
    printUsage
    
    {    
        /userInput 128 string def
        (>) print flush
        (%lineedit) (r) file userInput readline
        pop % bool
    
        token not { () } if
    
        {
            dup (q) eq { quit } if
    
            dup (a) eq {
                pop token pop
                (a) =
                exit
            } if
    
            dup (b) eq {
                pop token pop
                (b) =
                exit
            } if
    
            clear
            printUsage
    
            exit
    
        } loop
    } loop
    
  4. MyDict {
        /v exch def
        /k exch def
    } forall
    
  5. (=======================================) ==
    pstack
    (=======================================) ==
    quit
    
  6. /userInput 128 string def
    (>) print flush
    (%lineedit) (r) file userInput readline
    pop % bool
    
    { token not{exit}if == } loop
    
  7. %!PS-Adobe-2.0
    
    % gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="output-%d.pdf" m.ps
    
    /Courier findfont 12 scalefont setfont
    
    50 700 moveto
    1 20 string cvs show
    showpage
    
    50 700 moveto
    2 20 string cvs show
    showpage
    
    50 700 moveto
    3 20 string cvs show
    showpage
    
  8. 65 1 string dup 0 4 -1 roll put
    

    or

    /s ( ) def
    s 0 65 put
    
  9. /MyDict
    <<
        /MyKey1 (asd)
        /MyKey2 { (sdf) }
    >> def
    
    MyDict (MyKey1) get == % (asd)
    
    MyDict (MyKey2) get == % { (sdf) }
    
    MyDict (MyKey3) get == % undefined
    
  10. bind def: add lookup occurs once at definition:

    save
    /foo { add } bind def
    1 2 foo ==            % 3
    /add { mul } def
    1 2 foo ==            % 3, uses original add
    restore
    

    def alone: add lookup occurs each time:

    save
    /foo { add } def
    1 2 foo ==            % 3
    /add { mul } def
    1 2 foo ==            % 2, uses redefined add
    restore
    
JavaScript
  1. data:text/html,
    
    <canvas id=x>
    
    <script>
    
        X = x.getContext("2d");
    
        X.fillRect(10, 10, 20, 20)
    
    </script>
    
PostScript
  1. %!PS
    
    % nc 172.16.158.21 9100
    
    /Courier findfont 12 scalefont setfont
    32 740 moveto
    
    /s 100 string def
    
    (>) print flush
    
    (%lineedit) (r) file s readline
    
    pop
    
    show
    
    showpage
    
netcat
  1. nc -l 5000
    
PostScript
  1. 999 3 string cvs print