Programming


Author: Dmitry Nizhegorodov (dmitrynizh@hotmail.com). My other projects and articles



hacks, semantics, implementation

1.   Emacs and Xemacs Lisp

Package PLS-MODE
Emacs mode for browsing and editing PL/SQL (PLSQL) code. Click To Download.

SXML
SXML is an S-expression forms based markup language I use to write all my web content. It is a lot like XML/HTML except it is lisp-like and is for generating HTML using emacs lisp. Here is the source of the sxml2html translator alone with SXML sources of all pages on my site (sic!). How to use the translator: after loading sxml.el into emacs, open a .sxml buffer (for example, labaffles.sxml) and press M-x sxml2html. The buffer will translate itself to labaffles.html. In case an error occurs, you can go to the original buffer by typing M-x sxml-to-source.

Lisp in JavaScript
Lisp core inplemented in JavaScript plus Lisp to JavaScript translator.
Click to run demos interactively into a web page.

2.   Syntax Macros, Templates, Code Generators

ECOOP 2000 Talk

ECOOP 2002 Talk

3.   JavaScript

Lisp in JavaScript Lisp core inplemented in JavaScript plus Lisp to JavaScript translator. Click to run demos interactively into a web page.

Teaching the Art of Programming and Languages using JavaScript

Here we attempt teaching programming using JavaScript. Why JavaScript? Because it is an elegant and powerful dynamic language readily available under the skin of this web page - inside of your Web Browser. The course is a rather lengthy web page with numerous text-fields with pre-punched examples which you can change and evaluate in real time (but disable your javascript popup-stoppers, please)

4.   Java

Audio Stream Capturing Tool
Recorder is a simple command-line tool capabale of recording large wave files.

Finding Tube Model Parameters
Java Applet/App for finding SPICE tube parameters interactively with textual input.

Java Applet/App for finding SPICE tube parameters interactively with GIF or JPG image as input.

Spice to PTPLOT
As described in Collecting and Plotting Distortion Data, I use an AWK script to convert the data printed by FOURIER to the data file format of PTPLOT plotter. The script re-groups distortion data, performing misc transforms, such as RMS and power-into-load calculations. Here is a jar containing an equivalent Java code, which runs on any platform with Java and does not require AWK. After downloading the jar, do java -jar spice.jar <probefile.out>. Source (Spice.java) is included in spice.jar. The source is fairly elaborate and is in fact an output of a codegen tool. The real 'source' for spice.jar is the following macro code:

  /*
    # usage: java Spice <simdatafile> [lpr] [n]
    #  where l:log p: power r: RMS n: load in ohms
    #  by default: voltage amplitude, percentsh 
    #
    # usage examples:
    #  java Spice simres.out          # V, amplitude, percents
    #  java Spice simres.out l        # V, amplitude, logarithmic
    #  java Spice simres.out lrp 16   # W, RMS, logarithmic, into 16 ohm
   */

  EXTEND Awk5;

  AWK FS(' ');

  DEF boolean rms, watts;
  DEF double signal, load;
  DEF Hashtable spectrum, signals;

  BEGIN String
    options = ARG2,
    type = (INDEX(options,"l") > 0  ? "log" : "%");
  BEGIN int 
    count = 0, order = 1, 
    scale = ((type == "log") ? 1 : 100);

  BEGIN String
    ampl_t =  (INDEX(options,"r") > 0  ? "RMS" : "Amplitude"),
    out_t = (INDEX(options,"p") > 0  ? "W" : "V");

  BEGIN {
    rms = ampl_t == "RMS";
    watts = out_t == "W";
    load = (ARG3 != "" ? (DOUBLE ARG3) : 8);
    ARGN = 1; // only 1st command-line arg is a file
  }

  FUNCTION double rms (double v) { return rms  ? .707 * v : 1 * v; }
  FUNCTION double power (double v) { return watts ? v * v / load : 1 * v; }

  if (EQ(F1,"1")) { 
    count++; 
    double sigVal = DOUBLE F3;
    signal = power(rms(sigVal)); 
    PUT(signals,count, signal);
  }

  if (F1.length() == 1 && INDEX("123456789",F1) > 1) {
    int f1_int = INT F1;
    if (f1_int > order) order = f1_int; 
    PUT(spectrum, signal + ":" + f1_int, (DOUBLE F4) * scale);
  }

  END { 
    PRINT_ "TitleText: Distortion, " type;
    PRINT_  "";
    PRINT_ "Marks: dots";
    PRINT("XLabel: Output Signal,", out_t, ampl_t, (out_t == "W") ? ("into " + load + " ohm") : "");
    PRINT_ "YLabel: Distortion, " type;
    PRINT("NumSets: ", (order-1));

    if (type == "log") PRINT_ "YLog: on";
    for (int j = 2; j <= order; j++) {
      PRINT_ ""; 
      PRINT_ "DataSet: " j " harmonic";
      for (int i = 1; i <= count; i++) {
        String val = (String)GET(spectrum, (GET(signals,i) + ":" + j));
        if (val != "") PRINT(" ", GET(signals,i), ",",  val);
      }
    }
  }

     

Author: Dmitry Nizhegorodov (dmitrynizh@hotmail.com). My other projects and articles