codesnippets
To share, link to, and discuss bits of code that actually do DH-y things, or at least try to. And to ask questions along the lines of, "What's the best script-y way to <fill in short short task here>."
2015-10-23
2015-10-24
2015-10-25
2015-10-26
2015-10-27
2015-10-28
Hey, soupy people, can I ask a Beautiful Soup question? What would you use to grab the paragraph beginning with “Cast:” on a page like this? I can’t figure out how to grab content by using the thing it starts with and I don’t seem to be Googling the right thing. http://silentera.com/PSFL/data/S/SymbolOfTheUnconquered1920.html
@miriamposner: it’s been a while since i’ve used Beautiful Soup and I’m sure there is a better way, but here is a quick and dirty way for a one-off
>>> soup = BeautifulSoup(html_doc, 'html.parser')
>>> paragraphs = soup.find_all('p')
>>> for p in paragraphs:
... if "Cast" in str(p):
... print p
...
<p>Cast: Iris Hall [Evon Mason], Walker Thompson [Hugh Van Allen], Lawrence Chenault, Jim Burris, Mattie Wilkes, E.G. Tatum, Leigh Whipper, James Burrough, George Catlin</p>
@jay.varner: Yes! That’s exactly what I needed. Thanks so much! I really appreciate it.
glad i could help
2015-10-29
@sfsheath: testing github/gist integration. A little wonky but seems work ok.
Wonky is good.
2015-11-02
2015-11-03
2015-11-04
2015-11-05
2015-11-06
2015-11-10
2015-11-12
has anyone ever written A Big Book Of Escaping Rules? Because I’d buy it.
@mdlincoln: For strings? Doesn’t it vary from language to language?
“Doesn’t it vary from language to language?” precisely
though really, what are you looking for from that kind of document?
mappings between escaping rules in various languages?
At the moment: trying to interleave a perl regex substitution within a makefile
I’ve fixed it (turns out you need to use double $$ when calling perl from make
just idly wondering how one might design some tool that helps map out escaping issues when calling different languages
here’s one that’s got a few languages: http://www.codecodex.com/wiki/Escape_sequences_and_escape_characters
doesn’t really seem that much use though, and I think it’s less about escaping rules and more about string handling quirks across languages
2015-11-13
kind of unrelated but I found this infinitely useful when transitioning from java to python or when I’m just super lazy http://txt2re.com