These are chat archives for FreeCodeCamp/Help

27th
Jan 2015
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 02:48
Ha, i feel really stupid, but I can't seem to copy paste from vim.
Gregory Scheerlinck
@greg-js
Jan 27 2015 02:48
Haha I have the same problem, you need to compile it with clipboard support :/
if you're using tmux, you can use that to copy the text
then echo and pipe into xclip, that's what I do
but i just took a look at my solution. for the insert, the post you need to insert is right above the homework marker, so basically, that's your query
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 02:54
So the query is before the callback, but after the var post?
Gregory Scheerlinck
@greg-js
Jan 27 2015 02:55
You need to change the callback (it starts out returning an error) and call it inside your posts.insert code
and yes, the only lines you need to change are the ones they've marked it with the hw comment
if you think your code is right and it's still not working, try downloading a fresh copy. i struggled with hw2 for a long time and it turned out i'd accidentally changed a line i shouldn't have
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 02:58

Ok. So since posts is defined as the query, we do:

posts.insert(...

and them i'm lost again.

No, my code in nonexistent right now. Really struggling with the syntax for this stuff.
How did you figure out what to do? I really feel like I'm missing something from the course.
Gregory Scheerlinck
@greg-js
Jan 27 2015 03:00
Okay, no problem, i'm looking for the docs to the node driver right now, you can look up the syntax there
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 03:01
Ok. Thanks for you help.
Gregory Scheerlinck
@greg-js
Jan 27 2015 03:02
ah here it is
basically you need to give a query and a typical node callback that takes an error argument and the object you'll insert
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 03:02
So is that something like:
Gregory Scheerlinck
@greg-js
Jan 27 2015 03:02
so it will look a little something like:
```
posts.insert({}, function(err, inserted) {
if ( err ) { throw err; }
// code here
});
eh sorry forgot the closing backticks :)
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 03:03
Haha, no problem. i do the same thing.
So why include the empty document in the insert parameter?
Gregory Scheerlinck
@greg-js
Jan 27 2015 03:05
Ah, this is not the code you need to use, the { } is your query, you need something to identify the post you're goint to insert
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 03:07
Ok, can you just fill with { "permalink" } to call the correct object?
Gregory Scheerlinck
@greg-js
Jan 27 2015 03:09
Oops sorry my bad i was getting confused with the two different ones, for the first one which is an insert, you need to pass in the actual post. and the permalink with the callback. wait let me pull up my code for a second :)
Yep, that's it, i can paste in my solution for the first part if you want
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 03:12
If you're ok with that, it would definitely help me wrap my brain around it.
Gregory Scheerlinck
@greg-js
Jan 27 2015 03:13
this is my answer for inserting the post:
posts.insert(post, function(err, inserted){
  if (err) { throw err; }
  callback(null, permalink);
});
the final part of the homework is a bit trickier, let me know if you still have problems, i'll be back in a little while :)
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 03:15
Ok. Thanks for your help.
Gregory Scheerlinck
@greg-js
Jan 27 2015 03:15
but, to be clear, you only need to change that callback and put it in an update, you don't have to change anything else in the file
Daniel Gameros
@Dgameros
Jan 27 2015 03:58
Hello, i just finished challenge 33,Regular expressions, but i feel like i didnt really learn much. How important are regular expressions?
Gregory Scheerlinck
@greg-js
Jan 27 2015 03:59
Hey @AnthonyIsaacs did you get it working? i'm about to sign off but if you still need a hand i'm happy to help
@Dgameros they're pretty important. they're in just about every programming language and some software too and they're super useful
Daniel Gameros
@Dgameros
Jan 27 2015 04:01
so i could use something like (\d{3}) in normal HTML?
Gregory Scheerlinck
@greg-js
Jan 27 2015 04:01
@Dgameros if you need more training, check out codewars and click the regex tag
No, but you can do it in javascript
Daniel Gameros
@Dgameros
Jan 27 2015 04:01
ah i see. i will check out codewars thank you
Gregory Scheerlinck
@greg-js
Jan 27 2015 04:02
and use regexr it has a lot of info in the side panel too
Daniel Gameros
@Dgameros
Jan 27 2015 04:02
Ill try to get this stuff down before moving on to the next challenge
Gregory Scheerlinck
@greg-js
Jan 27 2015 04:03
Yeah, you'll need regex to do the coderbyte challenges
you don't need to know everything right away though, you can figure out backreferences and lookaheads when you need them
Anthony Isaacs
@AnthonyIsaacs
Jan 27 2015 04:24
@wdgreg Yeah, I was able to figure out the last one after reviewing some of the material from the second week.
@wdgreg Thanks again for all of your help. I would not have known where to start, otherwise!
Christopher Hutchinson
@cshutchinson
Jan 27 2015 13:10
@wdgreg regex101.com helped me alot; I find I use regex in about 25% of the coderbyte challenges
@wdgreg it will all start making sense when you start building test cases to solve a problem and you actually use a regex the first time :) its quite useful
Gregory Scheerlinck
@greg-js
Jan 27 2015 13:41
@cshutchinson that's spot on. reading about regex can get very confusing very quickly but using it is surprisingly easy, despite the crazy looking syntax :)
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:34
does express need to be installed each time a new project is started?
Jordan Wood
@jordanw
Jan 27 2015 22:40
@AdventureBear Yep! Remember the flag --save to add it to the package.json.
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:42
so if I'm just playing and testing my local dev while doing some codeshool projects (I'm on challenge 43, "dive deeper") should i set up a new directory, and just do npm install express like the first video starts out?
And what if you forget to do --save, can you add it later or do you need to manually add it?
Jordan Wood
@jordanw
Jan 27 2015 22:43
Yeah you just have to add it manually to the package. Not a huge deal.
I'll check that out real quick.
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:45
thanks! Nathan has been helping me too with some pairing and I don't want to mess up what he started with my node isntallation. Looks like node runs globally from the command line and express was intalled in one subdirectory he set up. I want to set up a new project and see if I can follow along and do some of my own stuff. Getting antsy to code outside of code school!
Jordan Wood
@jordanw
Jan 27 2015 22:45
I know i installed the express-generator globally.
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:46
how can I check that?
Jordan Wood
@jordanw
Jan 27 2015 22:46
i'd just run it in an empty folder and see what happens :D
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:46
OK, live dangerously, right?
YOLO
always
express myappname
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:47
ah. Hmm...that sounds dangerous!! lol.
lets see what happens
Jordan Wood
@jordanw
Jan 27 2015 22:48
move fast, break things, start over(if you must) :fire:
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:50
@JordanW good advice.
Jordan Wood
@jordanw
Jan 27 2015 22:55
@AdventureBear Ha, thanks. Might not be recommended in production with millions of users.
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:55
:) Seriously one of the best pieces of advice I got from another triathlon coach regarding building products (training courses) and emailing my list..."If you make a mistake fix it, and keep going"
Jordan Wood
@jordanw
Jan 27 2015 22:56
I find the faster you can put it into practice the faster it sticks. Going through challenge after challenge just gives you an ideas of whats possible. Without a context of where to use it...
Suzanne Atkinson
@AdventureBear
Jan 27 2015 22:57
exactly, that's why I want to start practicing.
Suzanne Atkinson
@AdventureBear
Jan 27 2015 23:08
OMG it worked!
I just wrote hello world!!
so stoked.
:)
Jordan Wood
@jordanw
Jan 27 2015 23:09
@AdventureBear Nice work.
It's alive!!!!
Suzanne Atkinson
@AdventureBear
Jan 27 2015 23:09
stand back, it's going to get mighty dangerous in here now!!
this seems so much more straightforward than 'rails s'
which bums me out b/c I spent 9 months trying to learn rails well!
Jordan Wood
@jordanw
Jan 27 2015 23:11
Never got into rails. I'm a php/drupal and java (for android) guy.
Node rocks though
Suzanne Atkinson
@AdventureBear
Jan 27 2015 23:11
I used to do some php, but never could "figure out" drupal.
Jordan Wood
@jordanw
Jan 27 2015 23:12
It's a beast
Nested arrays forever and ever
Suzanne Atkinson
@AdventureBear
Jan 27 2015 23:17
so I just tried using response.write, instead of response.send.
.send is supposed to be express API and .write node API from what he's saying
.send worked fine
.write gives me an error that "response is not defined". Do I need to install node locally even though it's sinstalled globally? or initialize a project with npm or something? I just did npm install express and started coding.
haha...nevermind
this stackoverflow actually answered my question perfectly!
Suzanne Atkinson
@AdventureBear
Jan 27 2015 23:36
i can't believe it's working.