Skip to content

Instantly share code, notes, and snippets.

View MoyTW's full-sized avatar

Travis Moy MoyTW

  • San Francisco, CA
View GitHub Profile
@MoyTW
MoyTW / xhrio_examples.cljs
Last active July 16, 2016 15:14
Some basic examples of how to use XhrIo. Server is at: https://github.com/MoyTW/BlogSnippets/tree/master/XhrIoExamples
(ns xhrio-examples.examples
(:require [goog.net.XhrIo :as xhrio]
[goog.structs :as structs]
[goog.Uri.QueryData :as query]))
(def get-text-url "http://localhost:3000/get-text")
(def get-json-url "http://localhost:3000/get-json")
(def post-url "http://localhost:3000")
(def post-form-url "http://localhost:3000/post-form")
(def post-json-url "http://localhost:3000/post-json")
@MoyTW
MoyTW / mchain.clj
Created March 16, 2014 22:48
Extremely Primitive Markov Chain
;;; Extremely Primitve Markov Chain
;;; Doesn't try to handle punctuation, capitalization, or anything; just
;;; generates text as-is from the corpus.
;;; Corpus I used was: http://www.shakespeares-sonnets.com/all.php
;;; Considering how important capitalization, plurals, and punctuation is to
;;; sonnets, I think it might work a little better this way...I should check
;;; that out, later.
;; This is so you can create the same chain multiple times.
;; Basically, it fixes the seed.
@MoyTW
MoyTW / scraper-4clojure.clj
Last active August 29, 2015 13:57
4Clojure Solution Scraper
(ns scraper-4clojure.core
(:require [clojure.string :as s])
(:import (org.openqa.selenium By WebDriver WebElement)
(org.openqa.selenium.htmlunit HtmlUnitDriver)))
(defn selenium-example []
(let [browser (HtmlUnitDriver.)]
(.get browser "http://www.google.com")
(let [element (.findElement browser (By/name "q"))]
(.sendKeys element (into-array ["Cheese!"]))
@MoyTW
MoyTW / 4Clojure-117.clj
Created February 24, 2014 05:52
4Clojure Problem #117, comments and explanations. See also: https://github.com/MoyTW/4clojure
;;;; 117 - For Science!
;;; Scratch:
;; https://github.com/MoyTW/4clojure/blob/master/ScratchPaper/117-wip.clj
;; Original:
(fn for-science [coll]
(letfn [(mark-next [coll]
(->> (conj coll \#)
(reduce (fn [[out p c] n]
(if (and (contains? #{\space \C} c) (or (= p \F) (= n \F)))
[(conj out \N) \N n]