Skip to content

Instantly share code, notes, and snippets.

View jnewman12's full-sized avatar
🎯
Focusing

James Newman jnewman12

🎯
Focusing
  • Santa Monica, CA
View GitHub Profile
@jnewman12
jnewman12 / Analyze.rb
Last active December 16, 2015 18:09
Basic text analyzer from Peter Cooper's Book; Beginning Ruby
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 April 28, 2013 04:14
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
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 23:01
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…
<?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 December 17, 2015 23:49
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.
<!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 June 2, 2013 05:40
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.
<!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 June 18, 2013 06:12
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.
<!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 June 26, 2013 00:00
Animates boxes. Made this in Last Week, forgot to upload.
<!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 June 26, 2013 00:06
Makes the pretty boxes move when you click on them.
<!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 June 26, 2013 00:08
More loops. Still not where I want to be, but getting better.
// The exercises we did as part of the code challenege on Wednesday 6/19
people = [
{
firstname : 'Natalia',
lastname : 'Fiero',
height: 63,
interests : [
'golf',
'dressage'
@jnewman12
jnewman12 / rails_testing.md
Last active September 25, 2015 02:08
Quick guide to get up to speed in Rspec

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