Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

James Newman jnewman12

🎯
Focusing
Block or report user

Report or block jnewman12

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jnewman12
jnewman12 / rails_testing.md
Last active Sep 25, 2015
Quick guide to get up to speed in Rspec
View rails_testing.md

Getting set up and up to speed with Rspec

This is a quick guide to get up to speed with rspec in rails. This was made as a guide while building this repo for reference.

What testing accomplishes

Other than some of the more obvious benefits of testing, when you look at a rspec test suite, you see how things are named and modeled. For example, a test for a user model might look something like this

# sample user_spec.rb
@jnewman12
jnewman12 / Analyze.rb
Last active Dec 16, 2015
Basic text analyzer from Peter Cooper's Book; Beginning Ruby
View Analyze.rb
stopwords = %w{ the a by on for of are with just but and to the my I has some in}
lines = File.readlines("text.txt")
line_count = lines.size
text = lines.join
#Count the Characters
character_count = text.length
character_count_nospaces = text.gsub(/\s+/, '').length
#Count the words, sentences & paragraphs
@jnewman12
jnewman12 / Summarize.rb
Created Apr 28, 2013
This is used for summarizing text. For the time being, just insert your own text into the text variable. I will see if I can add more to it
View Summarize.rb
text = %q{
#insert your text here
}
sentences = text.gsub(/\s+/, ' ').strip.split(/\.|\?|!/)
sentences_sorted = sentences.sort_by {|sentence| sentence.length}
one_third = sentences_sorted.length / 3
ideal_sentences = sentences_sorted.slice(one_third, one_third + 1)
ideal_sentences = ideal_sentences.select { |sentence| sentence =~ /is|are/ }
@jnewman12
jnewman12 / process.php
Created May 14, 2013
Went to General Assembly over the weekend. We covered html, css, a little javascript (wish it could have been more), PHP & MySQL and also got to learn to use cyberduck for a host. The purpose of this was to build a simple contact page that allowed people to fill in a box with their; name, email, and leave a message which would go to my email. It…
View process.php
<?php
$host = 'pfnppublic.pfnp.ccastig.com'; // hostname
$username = 'pfnpclass';//username from HG
$pass = 'ptx!fy8h'; //password from HG
$dbname = 'pfnpclass'; // Database Name
$conn = mysql_connect($host, $username, $pass) or die(mysql_error());
if ($conn)
{
mysql_select_db($dbname) or die(mysql_error());
@jnewman12
jnewman12 / index.html
Last active Dec 17, 2015
This is my code from the GA livestream as apart of our pre-work. I wasn't sure how to "snap-shot" this, so I thought github would be better.
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="keywords" content="cookies, c, monster, Sesame Street">
<meta name="description" content="I love cookies big and small, I love cookies I love them all.">
<title>Cookie Monster</title>
<link rel="stylesheet" href="css/normalize.css">
@jnewman12
jnewman12 / basic.html
Created Jun 2, 2013
This is for testing myself against the w3.org html standard. For whatever reason, I am having a difficult time linking my CSS to my HTML. I will figure it out though.
View basic.html
<!doctype html>
<html lang="en">
<head>
<title> James Newman</title>
<link href="documents/basicstylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container">
<h1> Apprentice Software Engineer in Training</h1>
@jnewman12
jnewman12 / index.html
Created Jun 18, 2013
This is part of what we did at General Assembly for the first day of WDI. It is a focus on how all html documents are boxes, squares, and how we can manipulate them. Thanks to @machikoyasuda for helping me out with this.
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body style="">
@jnewman12
jnewman12 / bouncey.html
Created Jun 26, 2013
Animates boxes. Made this in Last Week, forgot to upload.
View bouncey.html
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<style>
.root {
background: grey;
padding: 40px;
}
@jnewman12
jnewman12 / example.html
Created Jun 26, 2013
Makes the pretty boxes move when you click on them.
View example.html
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<style>
.root {
background: grey;
padding: 40px;
}
@jnewman12
jnewman12 / moarloops.js
Created Jun 26, 2013
More loops. Still not where I want to be, but getting better.
View moarloops.js
// The exercises we did as part of the code challenege on Wednesday 6/19
people = [
{
firstname : 'Natalia',
lastname : 'Fiero',
height: 63,
interests : [
'golf',
'dressage'
You can’t perform that action at this time.