Joho the Blogprograms Archives - Joho the Blog

March 26, 2015

Searching for news media that support Schema.org

Let’s say you have the weird desire to see if a particular online news site is producing news articles that support the Schema.org standard. I just posted a tiny little site — even uglier than usual — that lets you search for a particular news media site. It will return the items on that site that have been classified by that site as newsArticles in the Schema.org standard.

Thanks to a suggestion from Dan Brickley, it’s using a custom search engine from Google. One of the parameters permitted by custom search engines is to only return items that are one of Schema.org’s types. (I’m sure I’m messing up the standards lingo.) All I’ve done is specify newsArticle as the type, and prepended “site:” to whatever search you’re doing, saving you five keystrokes. You’re welcome!

If you get back a bunch of articles, then presumably the site is supporting Schema.org. I think.

2 Comments »

July 5, 2014

Convert Javascript to an HTML table

I was writing a long-ish tutorial about how to use LibraryCloud that refers to bunches of Javascript. I wanted a way to refer to that code in the HTML document. So I wrote a converter that turns Javascript code (and maybe others) into HTML tables you can just plunk into your document.

Here’s an example of some code:

function init(){
// get textarea to accept tab key
// thank you http://stackoverflow.com/questions/6140632/how-to-handle-tab-in-textarea
	$("#rawjs").keydown(function(e) {
		if(e.keyCode === 9) { // tab was pressed
			// get caret position/selection
			var start = this.selectionStart;
			var end = this.selectionEnd;

			var $this = $(this);
			var value = $this.val();

			// set textarea value to: text before caret + tab + text after caret
			$this.val(value.substring(0, start)
						+ "\t"
						+ value.substring(end));

			// put caret at right position again (add one for the tab)
			this.selectionStart = this.selectionEnd = start + 1;

			// prevent the focus lose
			e.preventDefault();
		}
	});
}

And here’s what it looks like once converted into an HTML table:

1

function init(){

2

// get textarea to accept tab key

3

// thank you http://stackoverflow.com/questions/6140632/how-to-handle-tab-in-textarea

4

$(“#rawjs”).keydown(function(e) {

5

if(e.keyCode === 9) { // tab was pressed

6

// get caret position/selection

7

var start = this.selectionStart;

8

var end = this.selectionEnd;

 

9

var $this = $(this);

10

var value = $this.val();

 

11

// set textarea value to: text before caret + tab + text after caret

12

$this.val(value.substring(0, start)

13

+ “\t”

14

+ value.substring(end));

 

15

// put caret at right position again (add one for the tab)

16

this.selectionStart = this.selectionEnd = start + 1;

 

17

// prevent the focus lose

18

e.preventDefault();

19

}

20

});

21

}

There’s definitely some clunkiness to this. For example, if you click on the “toggle line numbers” button it hides or shows the line numbers for every such table in your document. (I’ll fix this eventually.) By the way, the “Toggle” button is there so your readers can select the code and not get the lline numbers.

Also, in order to get the formatting totally encapsulated within your document, I clunkily add a “<style>” section before each table. I couldn’t figure out any other way to do it without making your HTML document dependent on my server being up.

The utility is here: http://hyperorg.com/programs/convertJStoTable/convertJStoTable.html. The code itself is up at Github (but not quite up to date at the moment).

Please let me know all the ways it’s broken and sucks, although I don’t promise to do anything about it. It worked for me.

1 Comment »

July 7, 2010

Extracting speakers notes from Keynote

[NOTE: A couple of weeks after posting this, Bruno Amaral wrote an Apple Script that does a far better job of it. Check the comments for his script and instructions. Thanks, Bruno!]

Here’s a very simple Automator script that extracts the speakers notes from a Keynote file and writes them into a text file on your desktop. The text file it makes is very ugly, and I’m sure someone better at this than I am (= everyone) could have Automator do some cleanup of it.

To install it, download it (duh), unzip it, and then put it into MacHD/your_account/Library/Services (where MacHD and your_account reflect the actual names of your setup).

To run it, in Finder select the name of the Keynote file, and right click for the context menu. Go to Services > extract_keynote_notes.

8 Comments »

April 24, 2010

ImpotentPoint: Text into online slides

I know this is ridiculous, and it’s undoubtedly been done before and well. But, I had fun doing this, so leave me alone.

When I was in Saudi Arabia, not only did Open Office eat the slides I’d made, it also then itself crashed into little tiny pieces. I have no idea what the problem was, but I didn’t have a reliable Net connection, and I didn’t have any other presentation software, so I quickly recreated my slides in HTML and wrote a little Javascript so I could click to go from one slide to another in my browser. So, then I thought it might be useful to have a little program that let you write your slides with a text editor, using a very simple markup language (simpler than HTML), and that would then display your text as slides.

Welcome to ImpotentPoint. The site explains the markup, but basically you begin a new slide by beginning a line with four or more dashes. A line that begins with a = is taken as a head (<h1>). You can use up to six =’s to get six levels of heads. A bullet point begins with a *. A bullet point that will build begins with a +. Unfortunately, you have to use HTML markup to get a graphic in. And that’s about it.

I like the idea of writing slides in plain text, but I’m afraid that the markup required to make this actually useful would turn out to be as complex as just writing them in html.

If you want to see a tutorial click on this button and paste the text into the first text box at ImpotentPoint.

4 Comments »