Thanh navigation

Thứ Năm, 21 tháng 12, 2017

Nhúng Latex

Cách nhúng Latex vào website hỗ trợ mã HTML để gõ các công thức toán, lý, hóa phức tạp.

1. Bật chế độ cho phép soạn thảo mã HTML
2. Đặt đoạn mã sau vào phía trên cùng của trang.

<script type="text/x-mathjax-config">   MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); </script> <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"> </script>

3. Gõ công thức theo cú pháp lệnh của LaTex và đặt trong cặp dấu $$.

$$Lệnh LaTex$$

4. Một số ví dụ:

Ví dụ 1:

$$ I = \int_{0}^{1} \frac{4}{1+x^{2}}dx $$

Ví dụ 2:

$$\frac{df}{dx} = \frac{1}{2} \left(\frac{ab \textrm{ sech}^2(b \sqrt{x})}{x} - \frac{a \tanh(b \sqrt{x})}{x^{3/2}} \right)$$

Ví dụ 3:

$$E=mc^2$$

Ta được kết quả ở trang phía dưới.

Thứ Tư, 20 tháng 12, 2017

Ví dụ nhúng LaTex

Một số kết quả nhúng LaTex

Ví dụ 1:

$$ I = \int_{0}^{1} \frac{4}{1+x^{2}}dx; E=mc^2$$ $$\forall x \in X, \quad \exists y \leq \epsilon$$ $$\cos (2\theta) = \cos^2 \theta - \sin^2 \theta$$ $$k_{n+1} = n^2 + k_n^2 - k_{n-1}$$ $$f(n) = n^5 + 4n^2 + 2 |_{n=17}$$ $$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$ $$\frac{\frac{1}{x}+\frac{1}{y}}{y-z}$$ $$x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } }$$ $$\sqrt{\frac{a}{b}}$$ $$\sqrt[n]{1+x+x^2+x^3+\dots+x^n}$$ $$\sum_{i=1}^{10} t_i$$ $$\displaystyle\sum_{i=1}^{10} t_i$$ $$\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x$$ $$\left(\frac{x^2}{y^3}\right)$$ $$f(n) = \begin{cases} n/2 & \quad \text{if } n \text{ is even}\\ -(n+1)/2 & \quad \text{if } n \text{ is odd} \end{cases}$$ Lệnh của Latex có thể xem ở đây.

Thứ Hai, 20 tháng 11, 2017


How to embed a live Google Docs spreadsheet into a webpage

Let’s say you have a set of data in an Excel document or Google spreadsheet* and you want to share it with the public by posting it on your webpage. You no longer have to create a static HTML table; in fact, Google allows for embedding a table on a webpage that is updated as the original Google Doc is updated. The way to do it is by creating what is called a “live” spreadsheet.
The process is very simple and the results will definitely save you a lot of time.
  • First, import your Excel file in Google Docs or open your Google spreadsheet;
  • File > Publish to the Web...;
  • Check the box that says “Automatically republish when changes are made”;
  • Click "Start Publishing";
  • Change “Get a link to the published data” from “Web page” to “HTML to embed in a page”;
  • Copy and paste the HTML code generated (should start in "<iframe") in an HTML-enabled space on your webpage.
At this point, you would just need to make changes on your Google spreadsheet to see the table on your website edited as well. In my testing, the automatic update always worked flawlessly; however, if that does not happen:
  • Open your Google Doc;
  • File > Publish to the Web... > Republish now.
  • Magic! You should see the table data updated on your website.
You can now adjust width, height and frameborder by changing the values in the <iframe> code in HTML mode.

Linking to the original Google Doc
Now, what if you also want users to be able to access your original table?
The way to do this is also very easy and I found it here (theBioBucket).
In your webpage, in HTML mode, write a code using the standard HTML notation to create a link <a href=”URL”> YOUR TEXT HERE </a>
The URL you will have to plug in is your Google doc one, found under “Share...”:

Once you’ve done that, you can simply write something like “Click here to access the Google document for this table” in the YOUR TEXT HERE space, and... all done!
A Google account is not necessary to view the original Google Doc. Any user on the web can access the original Google spreadsheet in view-only mode. They won't be allowed to alter the original table in any way, but they will have access to a spreadsheet downloadable in different formats  (e.g. .pdf, .csv, .txt). To download, simply click File > Download as... and save the document on your computer in all the formats available in Google Docs.
--------------
Source: Sara Camnasio

Thứ Tư, 22 tháng 3, 2017

Geocoding with Google Spreadsheets

Update: Google is deprecating Google Spreadsheets gadgets, as they announced in this post, so I am no longer updating or supporting them. If you're a developer, you can try Apps Script or the Spreadsheets Data API to see if you can accomplish the same thing. If you're a user, sorry, sometimes Google shuts down little used features.
Recently, quite a few people pointed me out to Tony Hirst's post on "Data Scraping Wikipedia with Google Spreadsheets". This was a really cool post because it demonstrated alot of features about Google Spreadsheets that people don't take advantage of (but should, because they're awesome): importing data from webservices or websites, publishing spreadsheets, creating charts of data, etc. But, I was sad to see that Tony had to go through so much pain to just geocode the data. Most people I know wouldn't be able to create a Yahoo! Pipe to parse the CSV and geocode spreadsheet data.. there should be an easier way. Well, there is, and that's what this post will show.
Google Spreadsheets now lets people embed gadgets, just like they can on iGoogle, Orkut (OpenSocial), Google Maps (Mapplets), and other containers. Those gadgets can live within the spreadsheet, access un-published data from a worksheet, and manipulate that data into some useful or visual output. There are gadgets for creating timelines, motion charts, word clouds, and now, courtesy of me, a gadget for geocoding data. This is my secret weapon for geocoding small sets of data, and can hopefully help other people out there.
Here are the steps for geocoding a spreadsheet with the gadget:
  1. Create a new spreadsheet, and put the addresses into rows. If your address is composed of multiple columns, just concatenate those into one single column using the "&" operator. The image below shows a spreadsheet of Australian beaches:

  2. Click on the "Insert" menu and then select "Gadget...":

  3. This presents you with various categories of gadgets to choose from (similar to the iGoogle directory). My gadget isn't yet in the gallery, so you'll need to select "Custom" and then type in the URL to the gadget:

  4. The gadget will appear embedded in the current worksheet, and it will prompt you to select a range of data to send to the gadget. Select all the rows for the column with your address data, and you should see the Range text field update with the range. If it doesn't work, you can always manually type it in. After doing that, click the Apply button:

  5. Since I always hate having charts or gadgets cluttering my sheets (and I like taking advantage of screen real estate), I then usually select the "Move to own sheet" option from the gadget menu. If you don't opt to do that, atleast resize the gadget to give it a decent amount of space in the worksheet. (Image omitted because I accidentally wrote over it :).
  6. When the gadget loads, it will present instructions, a blank map area, and a "Find Addresses" button. Click the "Find Addresses" button. It will start sending geocoding calls using the Maps API, and filling in the sidebar and map with results. It will stop at 99 results, for both technical and legal reasons (just use the gadget multiple times if you have more data than that). Any addresses that failed to geocode will have a red marker and show up in the bottom left of the map. All the markers are draggable, so you can move them around to tweak the location (this was a really important feature to me- geocodes can often use a nudge or two). In this step, you may notice some of the data didn't geocode at all, and perhaps you'll go back to your spreadsheet, edit the address a bit, and do this step again. For example, I had to add "Australia" to some of the beaches in my spreadsheet for disambiguation with other beaches.

  7. When you're satisfied with the marker locations, then select all in the text field below the map, and copy the text. The text contains the latitude/longitudes in row-order for all the markers, and is formatted so that it's easy to paste into spreadsheet columns.

  8. Finally, create two empty columns in your worksheet, and paste that text into the cells. If you put your cursor in the first row/column, then it should paste perfectly and align with the address data.

  9. You're done! Now you can use the latitude/longitude data in your Google Maps API mashup, perhaps by using the Spreadsheets -> Map Wizard or the Spreadsheets Mapper.
For those of you intrigued by Google Spreadsheets Gadgets, you may also want to check out my Spreadsheets -> JSON/SQL/XML converter, Spreadsheets based Flashcards, and State-Based Cluster Map. And the code is open-source, so you might want to modify and improve them, too. :)

Nguồn: 
http://blog.pamelafox.org/2008/11/geocoding-with-google-spreadsheets-and.html