Skip to content

Instantly share code, notes, and snippets.

@groundh0g
Created April 29, 2018 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groundh0g/1a6a2b1a1ffddf173e4839b6688e99a7 to your computer and use it in GitHub Desktop.
Save groundh0g/1a6a2b1a1ffddf173e4839b6688e99a7 to your computer and use it in GitHub Desktop.
Configurable string mangling; String as an array; Generate search keywords
# Treating a String as an Array in Liquid
## Example - Output Each Character
{% assign someProperty = "!#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~" | append: '"' %}
{% assign len = someProperty | size | minus: 1 %}
{% for i in (0..len) %}{{ someProperty | slice: i }}{% endfor %}
## Example - Extracting Keywords for Searches
{% capture bio %}
Joe Hall has been a professional software developer for more than 25 years.
He worked as a programmer for [Microsoft](https://www.microsoft.com/){:target="_blank"}, [IBM](https://www.ibm.com/){:target="_blank"}, and [ThoughtWorks](https://www.thoughtworks.com/){:target="_blank"}; and he was the software architect for a [Fortune 500 bank](https://www.regions.com/){:target="_blank"}. He was the CTO of a [ticket sales and servicing company](https://www.ticketbiscuit.com/){:target="_blank"} and he started his own consulting company in 2006.
Joe makes his living writing desktop, web, and mobile device applications for businesses and governmental agencies, but game programming is his passion, and it was gaming that got him into programming in the first place.
He was a member of the original Xbox team and he joined the Visual Studio .NET team just after the Xbox was released in 2001. Joe is the author of [XNA Game Studio Express: *Developing Games for Windows and the Xbox 360*](https://www.amazon.com/dp/1598633686/){:target="_blank"}, published in 2007, and [Fauxcabulary: *Fake definitions. Real funny.*](http://www.lulu.com/shop/joseph-hall/fauxcabulary/paperback/product-22179468.html){:target="_blank"}, self-published in 2015.
Joe also [dabbles](https://groundh0g.deviantart.com/){:target="_blank"} in sketching, cartooning, and creating 3D models. When you see his artistic creations, you'll understand why he makes his living as a programmer.
{% endcapture %}
{% assign someProperty = "!#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~" | append: '"' %}
{% assign len = someProperty | size | minus: 1 %}
{% for i in (0..len) %}{% assign char = someProperty | slice: i %}{% assign bio = bio | replace: char, " " %}{% endfor %}
{{ bio | strip_newlines | downcase | split: " " | sort | uniq | join: " " }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment