Skip to content

Instantly share code, notes, and snippets.

View cnocon's full-sized avatar
:octocat:
Professionally developing

Cristin O'Connor cnocon

:octocat:
Professionally developing
View GitHub Profile
@cnocon
cnocon / Ch.10 Sorting Exercise
Last active December 11, 2015 02:59
Sorting exercise (Ch. 10) from "Learning to Program" by Chris Pine (2nd Edition)
puts 'Please enter a list of words, separated by commas, that you would like to sort alphabetically.'
unsorted = gets.chomp.downcase.split(',')
sorted = []
def sorter unsorted, sorted
if unsorted.length == 0
return sorted
else
smalls = unsorted.pop #Biggie, Biggie, Biggie, can't you see? Sometimes your words just hypnotize me...
@cnocon
cnocon / Ch. 10 Shuffle Exercise
Last active December 11, 2015 05:28
Ch. 10 Shuffle Exercise From "Learning to Program" by Chris Pine.
#still trying to figure out why my shuffled array returns one too few words
puts 'Please enter a list of comma separated words that you would like to shuffle.'
unshuffled = gets.chomp.downcase.split(',')
shuffled = []
indeces = []
def shuffler unshuffled, shuffled, indeces
@cnocon
cnocon / index.html
Created January 27, 2013 11:43
A CodePen by Cristin O'Connor. Style only certain words with jQuery - I had to do this for a recent site cut I did. I borrowed from Chris Coyier but lightened up the code a bit for my purposes.
<div class="beta">
<nav id="nav" class="site-nav" role="navigation">
<ul class="depth_1">
<li class="first" id="nav_41633"><a href="/about-rop/">About ROP</a></li>
<li id="nav_41635"><a href="/editorial-advisory-board/">Editorial Advisory Board</a></li>
<li id="nav_41636"><a href="/editors-and-staff/">Editors and Staff</a></li>
<li id="nav_41637"><a href="/submit-a-manuscript/">Submit a Manuscript</a></li>
<li id="nav_41638"><a href="/book-reviews/">Book Reviews</a></li>
<li id="nav_41639"><a href="/subscriptions/">Subscriptions</a></li>
<li id="nav_41640"><a href="/back-issues-and-archives/">Back Issues and Archives</a></li>
@cnocon
cnocon / screenshot-rename.rb
Created February 10, 2013 19:00
A small variation made to Chris Pine's batch photo re-namer example from Chapter 11 in Learning to Program.
puts 'Where do you store your screenshots? Please paste the entire directory path.'
store = gets.chomp
Dir.chdir store
pic_names = Dir["#{store}/Screen Shot*.{png}"]
puts 'What would you like to call this batch?'
@cnocon
cnocon / image captions
Created May 14, 2013 23:31
The caption code we use in our CSS. Authored by Erik Runyon.
$(window).load(function() {
$('.image-right img,.image-left img,.image-default img').each(function(i,e){
var $this = $(this), /*1*/
$parent = $this.parent('p'); /*2*/
if($parent.text().trim().length > 0) { /*3*/
$parent.addClass('captioned').css({ width: $this.outerWidth() }); /*4*/
}
});
});
/***********************
***********@media queries
************************/
@media screen and max-width(60em) {
.container {width:80%;} /*etc…*/
def length_finder(input_array)
input_array.each {|element| element.length}
end
def length_finder(input_array)
input_array.map {|element| element.length}
end
puts "This is the deaf grandma extended problem. Type something for your Grandma."
words = gets.chomp
bye_count = 1
words_prev = words
while bye_count <= 3
if bye_count == 3 #I HAD THIS SET AS 3 FOR THE LONGEST TIME, UNTIL I REMEMBERED THE ITERATIONS ARE ZERO-INDEXED, DUR
puts "Bye sweetie!"
Gallery = new function(){...} //function expression via variable assignment