Skip to content

Instantly share code, notes, and snippets.

View seanconaty's full-sized avatar

Sean Conaty seanconaty

View GitHub Profile

Keybase proof

I hereby claim:

  • I am seanconaty on github.
  • I am seanconaty (https://keybase.io/seanconaty) on keybase.
  • I have a public key whose fingerprint is 75B5 7148 0262 63C3 9EFB 6A05 E309 2D52 5D05 78DF

To claim this, I am signing this object:

@seanconaty
seanconaty / gist:34552342e864139f32ca
Last active August 29, 2015 14:04
Escape From HyperText

Escaping HTML can be tricky. There are may different ways to do it and many different ways to send the browser HTML whether it's part of the original document or a string in Javascript tag, a template script tag or a string in an AJAX response. Srings can also be user generated or not and you should be aware of which ones are an which ones aren't. Below I talk about different ways HTML can be escaped using our technology stack.

If you are going to put JSON in embedded <script> tags like:

Case 1

<html>
<script>
var myJson = {{ json }};
@seanconaty
seanconaty / whitespace.md
Created May 3, 2012 17:46
Whitespace in HTML

Whitespace in HTML—It Matters

Every so often I see text nodes in HTML where the author uses the ancient convention of putting 2 spaces between sentences. This looks nice on type-written documents and perhaps, too, in terminals, which also use a monospace font. But, in fact, your two spaces will not be visible to the user who is viewing it through an HTML browser. She will see only one space. Do I think this is such a big deal? Not at all, but I think it highlights an important property of whitespace in HTML that can sometimes affect the layout of your page.

All whitespace, between <tags> and text nodes will collapse into a neatly packed single space. Let's look at a few examples.

So I want to quote Lenore by Edgar Allen Poe in my blog

<div class="poem">

AH, broken is the golden bowl!

@seanconaty
seanconaty / gist:2483505
Created April 24, 2012 20:35
Squashing Commits

Squashing Commits

Sure we look at a PR's total diff, but sometimes it's nice to look at commits. They're a way to organize your changes. As you know, your changes change as you develop. These changes, however, can be abstracted away so that everyone thinks you write immaculate code. Here's how I do it:

My Good Work

# I'm beginning work on a new poem
echo -e "Roses are green\nViolets are blue" > static/love_poem.txt
git commit -am "writing a new love poem about git"