Write formula in html - html

How to write formula in html page?
For example I need to write square root of x power 2 minus y. I know only one way, LaTex. But I need easier way. I'm writing quiz testing system. Students should write answer, that contains formula. How could I do this?

Check out MathJax, which is used on math.stackexchange.com.

The only two answers I know of for that are using images:
http://www.cs.tut.fi/~jkorpela/math/
...or using HTML math notation for that (although it is not that simple to use)
http://www.unics.uni-hannover.de/nhtcapri/mathematics.html
You also have this alternative, but it seems rather experimental...
http://www.w3.org/MarkUp/HTMLPlus/htmlplus_45.html
http://meta.wikimedia.org/wiki/Help:Displaying_a_formula
Still, I hope it helps...

This is a utility to write math (using LaTeX syntax) in HTML, but you also need to have LaTeX installed on your machine to generate the images of the formulas.

If you do not need to render the answer, just make it is correct, then the best way to go is probably to allow them to use something like sqrt(), ^ for power, etc..
I find this is the easiest way of writing if the input is for a machine.
You could just provide a small list of allowed functions with examples.
The bonus here would be that you can probably look around for a lib and use it to evaluate the answer.
So your example would be written like: sqrt(x^2)-y
Of course this can get very messy if you need to write complex equations but for the level you presented it should work fine.

Related

Factsheets from R - cat(), flexdashboard() or Markdown?

I am looking to create Factsheets to demonstrate standardized information for about 20 projects. I want this information to be updated weekly (to observe progress) and be an HTML file. I was thinking of creating something like this: http://htaindex.cnt.org/fact-sheets/?focus=cbsa&gid=741
I have three options I could use:
The frenkenstein approach: I could write all the html for a dummy factsheet, then mush my data into it in R and output the file with cat(). If I really wanted to be fancy I could even define custom functions that would elegantly mush the data together with html so that the implementers wouldn't have a heart attack at the wall of html and css.
The limited approach: I could use flexdashboards which allows for assets to be placed in row or column orientation but not really a combination. This would limit my creative options, but is much faster and more reproducible, debuggable, etc
The correct approach: I guess people will say that I should build a markdown template as documented here, but that seems incredibly time-intensive and it looks as though I would have to get very familiar with pandoc, which I'm not looking forward to.
My question (hopefully not too wide) then is: Why shouldn't I just use the Frankenstein approach?

Is there something like profile-guided dead code removal?

When building applications, especially when using static linking and having a lot of dependences, I often feel that most of this 50-megabyte executable is just unused bloat, especially if consider only the mode I want.
Is there something that lets you run the program in various scenarious, collect data and build the program again (or tinker already compiled code) to remove the unvisited code (replacing things with abort)? If yes, how is it correctly called and where is it implemented?
I'm perfectly willing to use techniques, rather than tools.
What I've done for your problem is get a map file and just look through it.
There may well be a lot of methods for classes you doubt you need. Find out what references put them in there. Chances are it's just because somewhere something fancy was coded, like a bells-and-whistles container class, when something simple would do. Or a whole math library when all you needed was max.
After fixing that, the map file is smaller, and something else is the biggest thing in it, so you can do it all again.
And again...
This can cut out gobs of bloated binary.

What are people using for html form generation?

There is a similar question from 2009 which mentions Wufoo and FormAssembly services. Are there any other services you would recommend for generating html forms?
I simply want to generate the code for the forms (some with a lot of fields) for my php application. I don't want a hosted solution or anything such as those mentioned above. What do you use for this tedious process?
Thanks.
You could check out Zend_Form. It generates HTML for you but you have to write quite a lot of php - with the reward of contained validation rules and decoration (container elements etc).
Or are you looking for a solution that let's you use a GUI to generate the form? In that case Wufoo seems like a good choice, I guess.
Just found what I was looking for. Must be newly indexed because it didn't turn up in my search the first time. In case anyone else is looking for something similar:
http://www.phpform.org/

google's use of class names

i noticed a very strange way of naming classes in G+ and gmail..
example: a-b-h-Jb a-b-Rf-dB a-Rf-dB d-s-r (see G+'s code for yourself!)
who the hell does that? impossible to keep track of what you did in future.. same for gmail.
it is a known way of doing css that i am unfamiliar with? is it OOCSS? if a googler is reading this, can you please explain? Or if you are not the one who wrote the code, then please share your thoughts or prove that i am a dumb ass and don't know about a fairly common css naming 'good practice' (can i even call it that?)
Google uses something called the Google Web Toolkit (or simply GWT) to compile Java "applications" into their Javascript/HTML/CSS counterparts. GWT was used for GMail and Google Wave and my assumption is that it was also used for G+.
The GWT "compiler" (CS purists would never call GWT a compiler but the term fits) programatically names Javascript functions, CSS classes, HTML form IDs, etc. so they are almost never something legible.
At a guess, they probably have everything written out nicely in full at some point, and then put it through some program to compress it (reduce the length of variables). This reduces readability but also reduces file size, improving load times in theory.

"Encrypted" html code for google search?

When I view the page source of google search, for example http://www.google.com/search?q=test,
the html code looks messy and I can't understand a thing from it (see below).
Is it on purpose?
What is this "encryption" called and how do I create it for normal html?
Thanks!
function _tvn(a,b){var c=parseInt(a,10);
return isNaN(c)?b:c}function _tvf(a,b){var c=parseFloat(a);
return isNaN(c)?b:c}function _tvb(a,b){return a=="true"?e:a=="false"?k:b}function _tvv(a)
{return!!a}function n(a,b,c){(c||m) aa=function(){return m.bv.m==1};n("sb",aa);
The HTML isn't encrypted, it's just minified, or in fact, its just the JS that is minified. The HTML is there, in normal format, just need to look for it in the right place. Direct copy of the html from that page, from the source code.
This is not HTML, it's javascript.
And it's not "Encrypted", it's compressed (minified), they change all the function names to be as short as possible, all the variable names to be as short as possible, and just compress it as much as possible by removing lines spaces and everything that is not useful...
There are many internet applications and methods to do that...
It's done to reduce the page size and to reduce loading time... there are many applications that reverse that compression...
Google has a library called Closure Compiler that it uses to optimize ("minify") JavaScript. This has the side effect of making it difficult to read ("obfuscated") and to copy. The library is free, so you can use it with your code, and alternatives are also available (see the other answers).
Google run their JS through an optimiser to increase speed of download and execution.
The JavaScript has been compressed and obfuscated, which makes it difficult to read and understand, while decreasing the file size to optimise loading times.
If you'd like to do something similar with your JavaScript have a look at YUI Compressor.
jsbeautifier at http://jsbeautifier.org can unminify, unpack, and unobfuscate.