Skip to content

Instantly share code, notes, and snippets.

View gigasquid's full-sized avatar

Carin Meier gigasquid

View GitHub Profile
### Keybase proof
I hereby claim:
* I am gigasquid on github.
* I am carinmeier (https://keybase.io/carinmeier) on keybase.
* I have a public key whose fingerprint is D721 DD0A CB75 F910 8285 B3C5 1B77 54F9 A790 9812
To claim this, I am signing this object:
@gigasquid
gigasquid / intsaparse-into.clj
Last active August 29, 2015 14:20
Instaparse Introduction
(ns coollang.parser
(:require [instaparse.core :as insta]))
;;; Steps to building a language
;;;; Step 1 parse an integer
(def parser
(insta/parser
"number = #'[0-9]+'"))
(ns conversations.datomic
(require [datomic.api :as d]))
;; Hi Datomic! I have been hearing good things about you. I would
;; like to talk to you and get to know you is that alright?
;; Sure - I would be happy to have a conversation with you.
(def uri "datomic:mem://first-conversation")
(d/create-database uri)
@gigasquid
gigasquid / fizzbuzz.clj
Created November 7, 2014 23:36
FizzBuzz without Conditionals
(defn fizzbuzz [n]
(let [all-nums (range 0 n)
folder (fn [fb-str p-num fb-coll]
(mapcat (fn [x] (cons fb-str (rest x)))
(partition-all p-num fb-coll)))
fizz (folder "fizz" 3 all-nums)
buzz (folder "buzz" 5 fizz)
fizzbuzz (folder "fizzbuzz" 15 buzz)]
fizzbuzz))
# An example of Mutual Recursion.
# A simple lexer for our parser. We only return tokens for :numbers
# and +, - and new lines.
class Lexer
attr_reader :token, :type
def initialize(stream)
@stream = stream
@tokens = []
@gigasquid
gigasquid / bowling.clj
Created March 30, 2011 16:17
First Clojure Kata for Bowling
(ns bowling-game.game)
(defrecord Frame [pins-hit-list])
(defrecord Game [frame-list])
(defn construct-frame [pins]
(Frame. [pins]))
(defn construct-empty-frame []
@gigasquid
gigasquid / aprilshowers.clj
Created April 3, 2011 21:02
April Showers Bring May Flowers
;;;;April Showers bring May Flowers
(ns my.april.showers)
(def sleep-time 20)
(def frame (java.awt.Frame.))
(defn show-frame [frame x y]
(doto frame
(.setVisible true)
(.setSize (java.awt.Dimension. x y)) ))
@gigasquid
gigasquid / mymethodTest.js
Created May 5, 2011 16:41
Example Spec File for Ajax Mocking with Jasmine
describe("Mocking Ajax Calls", function() {
beforeEach(function() {
loadFixtures('test.html');
//mocking ajax call with Jasmine Spies
var fakeData = "You can put your return data here";
spyOn($, "ajax").andCallFake(function(params) {
params.success(fakeData);
});
});
@gigasquid
gigasquid / mymethod.js
Created May 5, 2011 16:39
Example File for Ajax Mocking with Jasmine
function mymethod()
{
var url = contextPath + "/bar.ajax";
$.ajax({
type: "POST",
url: url,
data: { type: "test"},
success: function(json){
$('#mydiv').html("Happy Face");
@gigasquid
gigasquid / roman_number_converter.rb
Created May 18, 2011 04:17
Roman Number Calculator
# Given a integer between 1 and 50 convert it to its Roman Numeral
def convert_to_roman (arabic)
ones_translation =
[ 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']
tens_translation =
[ 'X', 'XX', 'XXX', 'XL', 'L']
tens = ""