Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@echosa
echosa / UserAssignment.php
Created March 12, 2014 22:55
User class for an assignment I was given
<?php
/**
* A few notes on this code.
*
* First, I installed PHPUnit via composer to run the tests. This is the reason for the
* require_once.
*
* Second, I made this all one file (multiple classes) in order to make it easier to
* post to a gist. Normally, of course, I'd have separate paths/files for different
* classes. If you put this all into one file to check/run with phpunit, you'll need to
@echosa
echosa / core.typed-deprecated-warning.clj
Created March 12, 2014 15:12
This results in a deprecated warning for fn>. Posting here to link to a Jira ticket.
(ann get-number-of-cleared-spaces
[(IPersistentVector (IPersistentVector Any))
->
AnyInteger])
(defn get-number-of-cleared-spaces
"Returns the number of cleared spaces in the grid."
[grid]
(inc (reduce (fn> [[cleared :- AnyInteger]
[row :- (IPersistentVector Any)]]
(let [result (inc (reduce (fn> [[row-cleared :- AnyInteger]
@echosa
echosa / zero-path-between.clj
Created March 12, 2014 14:15
This is a function I can't annotate correctly. The given annotation is how the function is currently used.
(ann zero-path-between
[(IPersistentVector (IPersistentVector Any)) Symbol (Vector* Number Number)
(Vector* Number Number)
->
(IPersistentVector (IPersistentVector Any))])
(defn zero-path-between
"Traverses the path between start and end and changes each position to 0."
[grid direction start end]
(let [next (get-next-coordinate grid start direction)]
(if (and next (not= next end))
@echosa
echosa / typed clojure issue.clj
Created March 5, 2014 00:41
An issue I'm having with typed Clojure
(ns greed.coords
(:require [clojure.core.typed :refer [ann]]))
(ann get-next-coordinate-northeast
[NonEmptySeqable (Option Number) (Option Number) -> (Option (IPersistentList Number))])
(defn get-next-coordinate-northeast [grid x y]
(when-not (or (nil? x) (nil? grid) (>= x (- (count (first grid)) 1))
(nil? y) (<= y 0))
(list (+ x 1) (- y 1))))
(defn set-thing-at-grid-position [grid position thing]
"Sets the position of grid to THING, then returns the new grid."
(let [x (first position)
y (nth position 1)]
(into (conj (subvec grid 0 y)
(into (conj (subvec (first (subvec grid y (inc y))) 0 x)
thing)
(subvec (first (subvec grid y (inc y))) (inc x))))
(subvec grid (inc y)))))
;; GRID is a vector of vectors that represents a game board
;; Example:
;; [[1 3 4 9 5] [5 1 2 4 7] [1 "@" 0 0 5] [4 2 3 9 1] [1 2 3 4 5]]
;; should print out
;; 13495
;; 51247
;; 1@ 5
;; 42391
;; 12345
;;
on findTurntableTab()
set AppleScript's text item delimiters to "/"
set foundTab to "no"
tell application "Google Chrome"
set theWindows to get every window
repeat with theWindow in theWindows
repeat with theTab in every tab in theWindow
set theURL to URL of theTab
set baseURL to text item 3 of theURL
@echosa
echosa / brew --config
Created July 30, 2012 17:17
Mac OS X Homebrew doctor error on par2tbb.rb formula
$ brew --config
HOMEBREW_VERSION: 0.9.2
HEAD: 2814e3a9fa88acf262062a26af15d87dc9f572d6
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit sandybridge
OS X: 10.8-x86_64
Xcode: 4.4
CLT: 4.4.0.0.1.1249367152
GCC-4.0: N/A