Jeremiah Parrack

+ Follow
since Apr 10, 2016
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jeremiah Parrack

I have a button called "add_order_items"  Which is used to display a list of products unique to that company. Right now it displays the proper values but it's appending the values to its parents continuously. Let's say a company has two products I click the add order item button it displays the proper 2 values. I click it again the new dropdown has the proper 2 values the first dropdown has appended the last 2 values so now it has 4 values (2 duplicates) I click the button a third time. The last dropdown has the proper 2 values. The middle dropdown has 4 values (2 duplicates) and the first one now has 6 values (4 duplicates). I have tried several approaches to keep this from happening. The first would be to add a counter and a conditional if counter == 0 do the normal append and save the dropdown else return the save dropdown. I could not get this to work Another solution which might be better it to compare the key if the key is already in the dropdown dont add it to the dropdown.


The function updateProducts

I do not know how to edit the post, sorry about the unformatted method create.
3 years ago
I am setting up my app with stripe and i am having a horrible time ha. I have spent close to 10 hours on it.
I finally realized that my token is returning nil.
The error on my logs is

On the second to last line, I am printing out the token but it is not returning anything. This is giving me

My create method is
``` [code=ruby]def create
     @order =
     @listing = Listing.find(params[:listing_id])
     @seller = @listing.user

     @order.listing_id =
     @order.buyer_id =
     @order.seller_id =

     Stripe.api_key ="sk_test_wCVovzzFUCYefEcIDpnCzcNq"
     token = params[:stripeToken]
 logger.debug "TOKEN IS: #{token}"

>>ERROR      charge = Stripe::Charge.create(
         :amount => (@listing.price * 100).floor,
         :currency => "usd",
         :source => token,
       flash[:notice] = "Thanks for ordering!"
     rescue Stripe::CardError => e
       flash[:danger] = e.message
     respond_to do |format|
         format.html { redirect_to root_url, notice: "Thanks for ordering!" }
         format.json { render action: 'show', status: :created, location: @order }
         format.html { render action: 'new' }
         format.json { render json: @order.errors, status: :unprocessable_entity }

I have been reading the docs and countless stackoverflow posts but everything I try does not seem to work.
Any help on this would be great. I know my API keys should be kept private however if I do not do it this way I get errors saying missing API key.
3 years ago

Piet Souris wrote:hi Jeremiah,

the exception arises because in file real2.txt line 55 is empty. This is the relevant part of that file:


I want to hug you right now! thank you so much!!  Such a silly thing i did not nptice! thank you so much!!
3 years ago
I have a program ( ) that creates a directed weighted graph and it implements Dijkstra's algorithm. I do this is by hard coding the vertex edge and weight like this

The output is

"Number of nodes = 8
Number of edges = 14
The shortest distance from node 0 to node 0 is 0
The shortest distance from node 0 to node 1 is 3
The shortest distance from node 0 to node 2 is 1
The shortest distance from node 0 to node 3 is 4
The shortest distance from node 0 to node 4 is 2
The shortest distance from node 0 to node 5 is 4
The shortest distance from node 0 to node 6 is 8
The shortest distance from node 0 to node 7 is 4"

Which is correct.
I even have a small text file ( ) Which works fine. Now when I get it a bunch of numbers ( )  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -2 . Also, it counts the edge wrong on real1.txt I get Edge is: 9468. It should be 8544.
I have tried to just hard code the edge make edgeCount = 8544 this did not work either I get the same out of bounds exception. I cannot find the bug to fix it.
3 years ago

Carey Brown wrote:It gets a bit tricky when you have two different line formats you have to detect. One possible way of dealing with this is to have a Scanner for the file and use hasNextLine() / nextLine() to get a line. Then create a new Scanner for the String returned by nextLine(). The String Scanner can then detect whether it has one or two int values using hasInt() & nextInt().

So after woking on it for awhile i came up with this which prints out if its a node or an edge.

So now I have to save this node as a var then add the edge and weight to the Edge[]. So once I am able to get my source node, edge and weight how to I put it in the Edge[] ?
3 years ago
In my program, I am creating a weighted directed graph. I have done this hard coding the values now I need to get input from a text file.

This is how I'm able to create the graph hardcoding the values.  

Node 0 is connected to 2 with a weight of 1, then node 0 is connected to node 3 with a weight of 4  . . .

The text file I am grabbing from is

With n= the number of nodes and m = number of edges.
What i want to do is this.

I do not know how to do approach this. my initial way was to just put a loop inside of the Edge[]  but you cannot do that. I am just really lost since the values I get must be stored in an Edge[]. Thank you for any help. If there are typos please excuse them I have been working on this for 2 days without much sleep.
3 years ago
For starters I recommend  
3 years ago
I have been trying for hours to add weight to my graph only to really mess things up (luckily I back things up). Any advice to add weights to my graph would be amazing. This program prints out an adjacency list  I want it to print out the adjacency list with the weight next to the node. I would post what I have worked on but I deleted it and I am starting back from the start.

and my main is
3 years ago

Junilu Lacar wrote:On which lines are your friends getting a different number of lexemes than you are?  I can't imagine they'd get more than 1 for the lines where you got 1, so the difference in totals must come from other lines.  If my math is right, your total is 82 lexemes. What are the extra 11 that they counted that you didn't?

The numbers on the side are the amount I think there is. They counted stuff inside quotes unsure what else they counted. ex. "Enter in a value:" I would count this as one he would count this as 7.
3 years ago
Below is the code with a comment on how many lexemes are on each line  I think i am doing this correct however a few of my friends are getting a total of 93 I just want to know if I am doing this wrong or not Thank you:

1. public class CountDigits {   // 4
2. public static void main(String[] args) {  // 11
3. SimpleIO.prompt("Enter an integer: "); // 7
4. String userInput = SimpleIO.readLine(); // 9
5. int number = Integer.parseInt(userInput); // 10
6. int numDigits = 0;  // 5
7. while (number > 0) { // 7
8. number /= 10;   // 5
9. numDigits++; // 4
10. } / 1
11. System.out.println("The number " + userInput + " has " +
12. numDigits + " digits"); // 17
13. } // 1
14. } // 1
3 years ago
I have tried to use Nokogiri just to grab all the data s i could go around saving it into an .csv file. However, I kept getting 503 errors so i had to work around it.

I have an excel file with rows   :name  :address  :phone  :image and i want to import this data into my preexisting database.

My preexisting table in ruby is

I saved my .csv file in my db folder and added import.rake to lib/tasks

when i run rake import i get

it gives this error for each of the rows I tried to import.
I am also worried that I'm doing this wrong and it will mess up my db so any advice would be appreciated.

3 years ago