Skip to content

Instantly share code, notes, and snippets.

View ethnt's full-sized avatar
🐢

Ethan Turkeltaub ethnt

🐢
View GitHub Profile
@ethnt
ethnt / limbo.sql
Last active August 29, 2015 13:56
Limbo SQL seeding.
# Assignment 2
# Creates and populates a database for Limbo.
# Authors: Ethan Turkeltaub and Matt Maffa
# Version: 0.1.0
# Create and use the limbo_db database
drop database if exists limbo_db;
create database limbo_db;
use limbo_db;
<?php
# helpers.php
# Ethan Turkeltaub, Matt Maffa
$debug = true;
# Shows the records in prints
function show_records($dbc) {
# Create a query to get the name and price sorted by price
<?php
function outputHTML ( $content )
{
echo '<P FONT-SIZE="14px">' . $content . '</P>' ;
}
?>
<video width="320" height="240" controls autoplay loop>
<source src="movie.mp4" type="video/mp4">
</video>
@ethnt
ethnt / csl_fields.rb
Created May 9, 2014 20:30
A Ruby script to get the fields needed to build a form for a citation using Citation Styles.
# a script to get the fields necessary to build forms for a citation
# using citation styles
# to-do: name-parts, date-parts, punctuation (delimiters), comments
require 'citeproc'
require 'csl/styles'
TYPES = [
'article',
⌘ ~/Workspace/kjaniszewski be siteleaf s
[2014-06-11 22:53:28] INFO WEBrick 1.3.1
[2014-06-11 22:53:28] INFO ruby 2.0.0 (2013-11-22) [x86_64-darwin12.5.0]
[2014-06-11 22:53:28] INFO WEBrick::HTTPServer#start: pid=9713 port=9292
127.0.0.1 - - [11/Jun/2014 22:53:40] "GET / HTTP/1.1" 200 7 0.3370
[2014-06-11 22:53:40] ERROR Rack::Lint::LintError: Content-Length header was 7, but should be 0
/Users/ethan/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb:20:in `assert'
/Users/ethan/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb:631:in `verify_content_length'
/Users/ethan/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb:655:in `each'
/Users/ethan/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
length' xs = lengthHelper xs 0 -- We're passing in the full list and 0 as the starting value for rsf
where lengthHelper (x:xs) rsf -- Separate xs into x (head) and xs (tail)
| xs == [] = rsf -- If the tail is empty, we're at the end. At this point, return rsf — we're done
| otherwise = lengthHelper xs (rsf + 1) -- If the tail isn't empty, pass in the tail (the rest of the list) and rsf + 1, since we're counting the head (x) right now
*Sudoku> let firstTwo = zipWith (\x y -> [x, y]) (testPuzzle !! 0) (testPuzzle !! 1)
*Sudoku> firstTwo
["67","00","38","76","12","94","49","53","81"]
*Sudoku> let firstThree = zipWith (\x y -> x ++ y) (firstTwo) (group 1 (testPuzzle !! 2))
*Sudoku> firstThree
["674","009","381","768","120","943","492","537","816"]
@ethnt
ethnt / harness.rb
Created July 10, 2015 20:43
Include arbitrary modules with Ruby.
# Use this class to test an arbitrary module.
class Harness
def initialize(_module)
self.class.include _module
end
end
###
# The module being tested
<?xml version="1.0" ?>
<remote>
<site id="1">
<name>Example Site</name>
<url>http://example.com</url>
<ftp>
<host>example.com</host>
<username>someuser</username>
<password>password</password>
</ftp>