January 07, 2020

Test with Quotes and Code Snippets

This is the paragraph where you can write more details about your product. Keep you user engaged by providing meaningful information. Remember that by this time, the user is curious, otherwise he wouldn't scroll to get here. Add a button if you want the user to see more. We are here to make life better.

And now I look and look around and there’s so many Kanyes I've been trying to figure out the bed design for the master bedroom at our Hidden Hills compound... and thank you for turning my personal jean jacket into a couture piece.

And thank you for turning my personal jean jacket into a couture piece.

Embedding code on a blog

Rust

The only fizzbuzz implementation we all need.

1mod fizz {
2    /// prints 0..100 or fizz or buzz if multiples of 3, 5 instead
3    pub fn fizzbuzz() {
4        for counter in 0..101 {
5            match (counter % 3, counter % 5) {
6                (0, 0) => println!("FIZZBUZZ"),
7                (0, _) => println!("FIZZ"),
8                (_, 0) => println!("BUZZ"),
9                (_, _) => println!(counter)
10            }
11        }
12    }
13}

js

1
2"Answer to life the universe and everything"
3
4    .length
5
6// => 42
7

A Clojure Code Snippet

I love Clojure.

1(defn gen-equation
2  "Given a number string and a result, inserts + or - anywhere to generate an equation for result.
3   Returns vector of all expressions that equal desired result.
4
5   Example inputs: "123456789" and 100
6   Sample item from output: 123 + 4 - 5 + 67 - 89; output is a vector of possibly many expressions, where 1 of
7   them is the above sample, which equals 100"
8  ([^java.lang.String num-string
9    ^java.lang.Long desired-result]
10   (gen-equation num-string desired-result []))
11
12  ([num-string desired-result acc]
13   ;; end condition
14   (if (empty? num-string)
15     (when (= (parse acc) desired-result)
16       [acc])
17     ;; else, branch out to 1, -1, next-num, + or -
18     (let [[next-num queue] (split-seq num-string)
19           branches (if (empty? acc)
20                      [[next-num] [(* -1 next-num)]]
21                      [(merge-last-num acc next-num) (conj acc '+ next-num) (conj acc '- next-num)])]
22
23       (mapcat #(gen-equation queue desired-result %) branches)))))
Avatar for Joel Quiles

Joel Quiles

Software Engineer

Divergent thinker who adapts to various technologies and environments regardless of project stage: from prototypes, to high-quality releases. Pragmatic test-driven development practicioner.