Skip to content

Instantly share code, notes, and snippets.

View kellylougheed's full-sized avatar

Kelly Lougheed kellylougheed

View GitHub Profile
@kellylougheed
kellylougheed / quiz3.rb
Last active October 7, 2016 22:39
Builds a class for a book and a textbook class that inherits from it. (Firehose Project Quiz #3)
class Book
attr_accessor :title, :author
def initialize(title, author)
@title = title
@author = author
end
def read
puts "I'm reading #{@title} by #{@author}"
@kellylougheed
kellylougheed / imageblur2.rb
Created October 14, 2016 23:02
Image Blur #2 solution
class Image
attr_accessor :data
def initialize(data)
@data = data
end
def blur
# Empty array to hold x, y coords with values of "1"
to_be_changed = Array.new
@kellylougheed
kellylougheed / colorEveryOther.js
Created December 5, 2016 02:23
Colors every other word in a string by wrapping <span> tags around it.
function colorEveryOther(str) {
var arr = str.split(" ");
for (var i = 0; i < arr.length; i++) {
if (i % 2 === 0) {
arr[i] = "<span>" + arr[i] + "</span>";
}
}
var newStr = arr.join(" ");
return newStr;
}
@kellylougheed
kellylougheed / color-every-other.xsl
Created December 5, 2016 02:24
Colors every other word in a string by tokenizing the string and wrapping every other word in <span> tags.
<xsl:template match="your-html-element">
<div class="color-every-other">
<xsl:variable name="content" select="path-to-content"/>
<xsl:for-each select="tokenize($content, ' ')">
<xsl:choose>
<xsl:when test="position() mod 2 != 0">
<span><xsl:value-of select="concat(., ' ')"/></span>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(., ' ')"/>
@kellylougheed
kellylougheed / dropdown_search.rb
Created December 5, 2016 02:58
Creates a dropdown menu to search for examples by the literary device they illustrate.
# Dropdown search for examples categorized by their device
<%= form_tag(examples_path, :method => "get") do %>
<%= select("example", "device", Example.all.map{ |e| e.device }.uniq.sort, selected: 'alliteration') %>
<%= submit_tag "Go!" %>
<% end %>
# The home page checks to see if a device has been selected in the dropdown search, and shows examples of that device if so
def index
@kellylougheed
kellylougheed / cleanTitles.js
Created February 25, 2017 21:30
JS for a friend's SquareSpace page to clean up titles beginning with "Category//"
window.onload = function() {
cleanTitles();
function cleanTitles() {
var arr = document.getElementsByClassName("index-item-title-text");
for (var i = 0; i < arr.length; i++) {
var element = arr[i];
element.innerText = stripCategory(element.innerText);
}
}
function stripCategory(str) {
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dictionary App</title>
<!-- Link to CSS goes below -->
</head>
<body>
window.onload = function() {
// Your JavaScript goes below
}
window.onload = function() {
// Your JavaScript goes below
var submitButton = document.getElementById("submitButton");
var inputBox = document.getElementById("inputBox");
var wordSearched = document.getElementById("wordSearched");
var results = document.getElementById("results");
var results2 = document.getElementById("results2");
}
submitButton.addEventListener("click", function() {
// Do stuff!
});