- Sep 2023
- Jul 2023
-
gist.github.com gist.github.com
-
```js / * twitter-entities.js * This function converts a tweet with "entity" metadata * from plain text to linkified HTML. * * See the documentation here: http://dev.twitter.com/pages/tweet_entities * Basically, add ?include_entities=true to your timeline call * * Copyright 2010, Wade Simmons * Licensed under the MIT license * http://wades.im/mons * * Requires jQuery /
function escapeHTML(text) { return $('<div/>').text(text).html() }
function linkify_entities(tweet) { if (!(tweet.entities)) { return escapeHTML(tweet.text) }
// This is very naive, should find a better way to parse this var index_map = {} $.each(tweet.entities.urls, function(i,entry) { index_map[entry.indices[0]] = [entry.indices[1], function(text) {return "<a href='"+escapeHTML(entry.url)+"'>"+escapeHTML(text)+"</a>"}] }) $.each(tweet.entities.hashtags, function(i,entry) { index_map[entry.indices[0]] = [entry.indices[1], function(text) {return "<a href='http://twitter.com/search?q="+escape("#"+entry.text)+"'>"+escapeHTML(text)+"</a>"}] }) $.each(tweet.entities.user_mentions, function(i,entry) { index_map[entry.indices[0]] = [entry.indices[1], function(text) {return "<a title='"+escapeHTML(entry.name)+"' href='http://twitter.com/"+escapeHTML(entry.screen_name)+"'>"+escapeHTML(text)+"</a>"}] }) var result = "" var last_i = 0 var i = 0 // iterate through the string looking for matches in the index_map for (i=0; i < tweet.text.length; ++i) { var ind = index_map[i] if (ind) { var end = ind[0] var func = ind[1] if (i > last_i) { result += escapeHTML(tweet.text.substring(last_i, i)) } result += func(tweet.text.substring(i, end)) i = end - 1 last_i = end } } if (i > last_i) { result += escapeHTML(tweet.text.substring(last_i, i)) } return result
} ```
Tags
Annotators
URL
-
- May 2023
-
xnacly.me xnacly.me
- Apr 2023
-
www.oreilly.com www.oreilly.com
- Mar 2023
-
www.youtube.com www.youtube.com
-
-
github.com github.com
Tags
Annotators
URL
-
-
blog.mmyoji.com blog.mmyoji.com
-
deno.com deno.com
Tags
Annotators
URL
-
-
blog.k-nut.eu blog.k-nut.eu
Tags
Annotators
URL
-
-
codepen.io codepen.io
Tags
Annotators
URL
-
-
twitter.com twitter.com
Tags
Annotators
URL
-
-
developer.mozilla.org developer.mozilla.org
-
gist.github.com gist.github.com
Tags
Annotators
URL
-
-
news.ycombinator.com news.ycombinator.com
-
absolute gem of a book, I use it for my compilers class:https://grugbrain.dev/#grug-on-parsing
I didn't realize recursive descent was part of the standard grugbrain catechism, too, but it makes sense. Grugbrain gets it right again.
Not unrelated—I always liked Bob's justification for using Java:
I won't do anything revolutionary[...] I'll be coding in Java, the vulgar Latin of programming languages. I figure if you can write it in Java, you can write it in anything.
https://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/
Tags
Annotators
URL
-
- Feb 2023
-
www.garshol.priv.no www.garshol.priv.no
Tags
Annotators
URL
-
-
www.youtube.com www.youtube.com
Tags
Annotators
URL
-
-
bnfc.digitalgrammars.com bnfc.digitalgrammars.com
-
-
Tags
Annotators
URL
-
-
Tags
Annotators
URL
-
-
Tags
Annotators
URL
-
-
Tags
Annotators
URL
-
- Jan 2023
-
aohorodnyk.com aohorodnyk.com
-
news.ycombinator.com news.ycombinator.com
-
The usefulness of JSON is that while both systems still need to agree on a custom protocol, it gives you an implementation for half of that custom protocol - ubiquitous libraries to parse and generate the format, so the application needs only to handle the semantics of a particular field.
To be clear: when PeterisP says parse the format, they really mean lex the format (and do some minimal checks concerning e.g. balanced parentheses). To "handle the semantics of a particular field" is a parsing concern.
-
- Dec 2022
-
monocle.p3k.io monocle.p3k.ioPreview1
- Nov 2022
-
waterpigs.co.uk waterpigs.co.uk
-
adactio.com adactio.com
Tags
Annotators
URL
-
- Oct 2022
-
stackoverflow.com stackoverflow.com
- Sep 2022
-
blog.cloudflare.com blog.cloudflare.com
Tags
Annotators
URL
-
-
blog.cloudflare.com blog.cloudflare.com
Tags
Annotators
URL
-
- Aug 2022
-
microformats.org microformats.org
Tags
Annotators
URL
-
- Jun 2022
- Dec 2021
-
www.rubensworks.net www.rubensworks.net
- Nov 2021
-
hexdocs.pm hexdocs.pm
Tags
Annotators
URL
-
-
sgt.hootr.club sgt.hootr.club
- Jun 2021
-
medium.com medium.com
-
while (( "$#" )); do case "$1" in -a|--my-boolean-flag) MY_FLAG=0 shift ;; -b|--my-flag-with-argument) if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then MY_FLAG_ARG=$2 shift 2 else echo "Error: Argument for $1 is missing" >&2 exit 1 fi ;; -*|--*=) # unsupported flags echo "Error: Unsupported flag $1" >&2 exit 1 ;; *) # preserve positional arguments PARAMS="$PARAMS $1" shift ;; esacdone# set positional arguments in their proper placeeval set -- "$PARAMS"
-
- Mar 2021
-
www.benawad.com www.benawad.com
- Dec 2020
-
github.com github.com
-
хорошая библиотека для парсинга и автоматизации тестирования "вёрстки с js"
Tags
Annotators
URL
-
- Oct 2020
-
github.com github.com
-
Parsing HTML has significant overhead. Being able to parse HTML statically, ahead of time can speed up rendering to be about twice as fast.
-
-
github.com github.com
- Aug 2020
-
stackoverflow.com stackoverflow.com
-
Sadly, bash can't handle long options which would be more readable, i.e.:
-
- Jul 2020
-
code-examples.net code-examples.net
-
JSON parsing is always pain in ass. If the input is not as expected it throws an error and crashes what you are doing. You can use the following tiny function to safely parse your input. It always turns an object even if the input is not valid or is already an object which is better for most cases.
It would be nicer if the parse method provided an option to do it safely and always fall back to returning an object instead of raising exception if it couldn't parse the input.
-
-
unix.stackexchange.com unix.stackexchange.com
-
It does, however, provide the --porcelain option, which causes the output of git status --porcelain to be formatted in an easy-to-parse format for scripts, and will remain stable across Git versions and regardless of user configuration.
-
Parsing the output of git status is a bad idea because the output is intended to be human readable, not machine-readable. There's no guarantee that the output will remain the same in future versions of Git or in differently configured environments.
-
- May 2020
-
unix.stackexchange.com unix.stackexchange.com
- Feb 2020
-
github.com github.com
- Nov 2019
-
rubykaigi.org rubykaigi.org
-
enqueuezero.com enqueuezero.com
Tags
Annotators
URL
-
-
tomassetti.me tomassetti.me
Tags
Annotators
URL
-
-
Tags
Annotators
URL
-
- Sep 2019
-
www.npmjs.com www.npmjs.comminimist1
Tags
Annotators
URL
-
-
unix.stackexchange.com unix.stackexchange.com
- Aug 2019
- Dec 2016
-
www.thehebrewcafe.com www.thehebrewcafe.com
-
ἀνιάτῳ
This word is composed of the alpha privative and the root for "healing," which is where my name comes from! ἰάομαι (pres mid) takes the future in the active, the participle of which is ἰάσων, meaning something like "being about to heal." Therefore, ἀνίατος is something that is incurable. It may refer to wickedness that cannot be atoned for, to a person who is unforgivably evil.
Tags
Annotators
URL
-