Here's yet another CSE398 tutorial. This time it's about how to dynamically load code, or to otherwise create extensions that expand the behavior of a program. I realized that while students have heard of "DLL Hell", they don't know how to make DLLs (or their Unix equivalent, "shared objects").
DLLs are like lambdas (did you like yesterday's post?): if you don't know how to use them, you end up doing an outrageous amount of work to get an effect that would otherwise be simple. The tutorial starts by showing how to load and use a shared object in C++, which lets me introduce my basic Makefile template, function pointers, and C++ name mangling. Then it shows how to do dynamic class loading in Java. We move from there to using exec or spawn to do inter-process communication (IPC) between Node.js and Java or C++ programs.
I tried to make the tutorial a little bit more fun, by hiding the code for a Java Pig Latin converter. This was also an attempt to get people to look at the HTML code for my tutorials. I don't think students realize how easy it is to do clean web design by hand, once you know a little CSS and jQuery.
As with all of my CSE398 tutorials, I wrap up with next steps, this time involving the use of existing Node.js packages to load C++ and Java code directly into a running node server.
Showing posts with label Hacking. Show all posts
Showing posts with label Hacking. Show all posts
Monday, February 16, 2015
Saturday, February 14, 2015
Fun with Google Forms
Here's a link to another of my tutorials for CSE398. I figured this out in the course of making a registration page for an elementary school's after-school enrichment program. We wanted the convenience of a Google Form, with all results going to a shared spreadsheet, but we also wanted to be able to keep people from registering for activities that were either (a) not available based on their child's grade level, or (b) already at capacity.
The trick is to make a separate worksheet in the Google Spreadsheet that is attached to the form, set it up to summarize the data in the main sheet of the spreadsheet, publish the second worksheet, and only the second worksheet, and then consume it as JSON. Then it's just a matter of using JavaScript on the client side to fetch the JSON, parse it, and use the resulting data to drive the UI.
Somewhere along the way, I realized that the Google Form is really two components with a straightforward API connecting them. We can't change the API, but we can have a different front-end that interacts with the same back-end, as long as we respect the API. Once I realized that, it seemed worthwhile to make a tutorial about it.
The link to the tutorial is here. Hopefully it is easy to follow. As with my other CSE398 tutorials, there are "next steps" that I leave up to the student.
Disclaimer: there are ways to hack the technique I present, so don't use it for anything mission-critical. You'll still get the safety that Google Forms provides, but people can get around the JavaScript-based validation.
The trick is to make a separate worksheet in the Google Spreadsheet that is attached to the form, set it up to summarize the data in the main sheet of the spreadsheet, publish the second worksheet, and only the second worksheet, and then consume it as JSON. Then it's just a matter of using JavaScript on the client side to fetch the JSON, parse it, and use the resulting data to drive the UI.
Somewhere along the way, I realized that the Google Form is really two components with a straightforward API connecting them. We can't change the API, but we can have a different front-end that interacts with the same back-end, as long as we respect the API. Once I realized that, it seemed worthwhile to make a tutorial about it.
The link to the tutorial is here. Hopefully it is easy to follow. As with my other CSE398 tutorials, there are "next steps" that I leave up to the student.
Disclaimer: there are ways to hack the technique I present, so don't use it for anything mission-critical. You'll still get the safety that Google Forms provides, but people can get around the JavaScript-based validation.
Subscribe to:
Posts (Atom)