Permalink
Browse files

Second chapter

  • Loading branch information...
1 parent 617c019 commit b1b11039856d536c1f77c932d6268b11a70c15ce Ben Lynn committed with Ben Lynn Aug 31, 2007
Showing with 140 additions and 17 deletions.
  1. +15 −4 Makefile
  2. +68 −0 basic.txt
  3. +21 −0 custom-html.xsl
  4. +10 −0 custom-nochunks.xsl
  5. +2 −2 intro.txt
  6. +24 −11 wiki2xml
View
19 Makefile
@@ -1,6 +1,17 @@
-target:
- ./bookmake intro.txt > book.xml
- xmlto html-nochunks book.xml
+target: book.html
+
+TXTFILES=intro.txt basic.txt
+
+book.xml: $(TXTFILES)
+ ./bookmake $^ > book.xml
+
+book: book.xml
+ xmlto -m custom-html.xsl -o book html book.xml
+ -ls book/*.html | xargs -n 1 tidy -utf8 -m -i -q
+
+book.html: book.xml
+ xmlto -m custom-nochunks.xsl html-nochunks $^
+ -tidy -utf8 -imq $@
clean:
- -rm book.xml book.html
+ -rm -rf book.xml book.html book
View
68 basic.txt
@@ -0,0 +1,68 @@
+= Basic Git Tricks =
+
+== Instant Backup ==
+
+When I'm about to attempt something drastic I like to save the current state, so I can go back and try again should things go awry.
+
+ $ git-init
+ $ git-add .
+ $ git-commit -m "Initial commit"
+
+to take a snapshot of all files in the current directory.
+Then if something goes wrong type
+
+ $ git-reset --hard
+
+to go back to where you were. To save the state again, type <command>git-commit -a</command> and provide a description.
+
+One benefit to doing this instead of simply copying files is that with Git's hash chaining, you can tell if a backup gets corrupted.
+
+== Undo/Redo History ==
+
+More generally, you can do the above, and every so often "save the game" by typing
+
+ $ git-commit -a -m "description of current state"
+
+Note if you want to keep track of newly added files or forget about deleted files you'll need to first run <command>git-add</command> or <command>git-delete</command> accordingly.
+
+Typing git-log shows you a list of recent commits, and their SHA1 hashes. Then typing
+
+ $ git-commit -a
+ $ git-revert SHA1_HASH
+
+will restore the state to the commit with the given hash. You might like to use something like the following instead:
+
+ $ git-revert "@{10 minutes ago}"
+
+You can undo the undo: type git-log and you'll see that the other commits you made are still there.
+
+Typing
+
+ $ git-checkout SHA1_HASH .
+
+loads a saved state without recording the fact that you've gone back to an old state. This is sometimes what you want.
+
+To take the computer game analogy again, git-checkout is like loading a game, git-revert is like loading a game and recording this fact as another saved game, and git-reset --hard is like loading an old save and deleting all saved games newer than the one just loaded.
+
+== Synchronize Files Between Computers ==
+
+This is the reason I first used Git. I can make tarballs or use rsync to do backups. The problem was sometimes I'd edit on my laptop, other times on my desktop, and they may not have talked to each other in between.
+
+Initialize a Git repository and commit your files as above on one machine. Then on the other:
+
+ $ git-clone git+ssh://other.computer/directory
+
+to get a second copy. From now on,
+
+ $ git-commit -a
+ $ git-pull git+ssh://other.computer/directory
+
+will pull in the state of the files on the other computer into the one you're working on. If you've recently made conflicting edits in the same file, Git will let you know and you should resolve them with another edit and commit.
+
+If you have not committed any changes on the other computer, you may type
+
+ $ git-push git+ssh://other.computer/directory
+
+to push the current state to the other computer. Next time you're there, run git-reset --hard or git-checkout HEAD . to update the files.
+
+That Git does not do the last step automatically is good in case you were in the middle of some uncommitted changes.
View
21 custom-html.xsl
@@ -0,0 +1,21 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ version="1.0">
+<xsl:param name="chunk.section.depth" select="0"></xsl:param>
+<xsl:param name="css.decoration" select="0"></xsl:param>
+<xsl:param name="toc.list.type">ul</xsl:param>
+<xsl:param name="chunker.output.encoding" select="'UTF-8'"></xsl:param>
+<xsl:param name="chunker.output.doctype-public" select="'-//W3C//DTD HTML 4.01 Transitional//EN'"></xsl:param>
+<!-- use tidy instead
+<xsl:param name="chunker.output.indent" select="'yes'"></xsl:param>
+-->
+<xsl:param name="suppress.navigation" select="1"></xsl:param>
+<xsl:param name="generate.toc" select="'book toc'"/>
+<xsl:param name="html.stylesheet" select="'default.css'"/>
+
+<xsl:template name="user.footer.navigation">
+<script type="text/javascript" src="find_selflink.js"></script>
+</xsl:template>
+
+</xsl:stylesheet>
View
10 custom-nochunks.xsl
@@ -0,0 +1,10 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ version="1.0">
+<xsl:param name="html.stylesheet" select="'default.css'"/>
+<xsl:param name="generate.toc" select="'book toc'"/>
+<xsl:output method="html" encoding="UTF-8" indent="no"
+doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+/>
+</xsl:stylesheet>
View
4 intro.txt
@@ -21,7 +21,7 @@ In some computer games, saving the game actually writes a directory full of file
This turns out to be a basic capability of all version control systems. They all have nice interfaces to manage a directory of stuff. You can save its state every so often, and be able to load any one of the saved states later on. They're also smart about using space, by exploiting the fact that only a few of the files usually change between version to version.
-== Sharing Saved Games ==
+== Centralized Versus Distributed ==
Now imagine a very difficult computer game. So difficult to finish that many experienced gamers all over the world decide to team up and share their saved games to try to beat it. Real-life examples of this include doing speedruns of certain games. Players specializing in different levels of the same game collaborate to produce amazing results.
@@ -33,7 +33,7 @@ What if a player wanted to get an older saved game for any reason? Maybe the cur
There could be many reasons to want to see an older revision, but the outcome is the same. They have to ask the central server for that old save. The more saves they want, the more communication that is required.
-The new generation of version control systems are known as distributed systems, and can be thought of as a generalization of the centralized systems. When players download from the main server they get every saved game, not just the latest one. It's as if they're mirroring the central server.
+The new generation of version control systems, to which Git belong, are known as distributed systems, and can be thought of as a generalization of the centralized systems. When players download from the main server they get every saved game, not just the latest one. It's as if they're mirroring the central server.
One immediately obvious benefit is that when an old save is desired for any reason, communication with the central server is unnecessary.
View
35 wiki2xml
@@ -2,19 +2,14 @@
# Converts small subset of MediaWiki to DocBook
# Ben Lynn
-func close_para() {
- in_para = 0
- print "</para>"
-}
-
func open_section(tag) {
stack[stack_i] = tag
stack_i = stack_i + 1
print "<"tag">"
}
func close_section() {
- if (in_para) close_para();
+ close_block();
stack_i = stack_i - 1
print "</"stack[stack_i]">"
}
@@ -25,13 +20,28 @@ func close_until(i) {
}
}
+func close_block() {
+ if (block_state != "") {
+ print "</"block_state">"
+ block_state = ""
+ }
+}
+
+func in_block(s) {
+ if (block_state != s) {
+ close_block()
+ print "<"s">"
+ block_state = s
+ }
+}
+
BEGIN {
stack_i = 0
open_section("chapter")
}
/^ *$/ {
- if (in_para) close_para();
+ close_block()
next
}
@@ -57,11 +67,14 @@ BEGIN {
next
}
+/^ / {
+ in_block("screen")
+ print $0
+ next
+}
+
{
- if (!in_para) {
- print "<para>"
- in_para = 1
- }
+ in_block("para")
print $0
}

0 comments on commit b1b1103

Please sign in to comment.