These are chat archives for FreeCodeCamp/Help

2nd
Mar 2015
Ashley Drake
@aldraco
Mar 02 2015 00:20
Well, I am having trouble figuring out how to get it to work when there are multiple duplicates or three of a kind but I think I can figure out the math part... Just haven't found an easy way to program it without a billion for loops and conditionals.
I think I need a mental break and then tackle tomorrow
I just want to start on the non profits :) patience grasshopper ...
Danny Fritz
@dannyfritz
Mar 02 2015 00:22
mine has no loops. ;)
Ashley Drake
@aldraco
Mar 02 2015 00:23
Hmmmmmmmmm
Danny Fritz
@dannyfritz
Mar 02 2015 00:26
i've boiled it down to 11 easy to read lines of code
Ashley Drake
@aldraco
Mar 02 2015 00:30
Nice
Danny Fritz
@dannyfritz
Mar 02 2015 00:40
9 lines of code. :P
i think it is as fast as it will get
Nathan
@terakilobyte
Mar 02 2015 00:41
so good to see people putting effort into bonfires
next bonfire on the docket… solve for magic cubes!
Harshal
@McQuinTrix
Mar 02 2015 00:51
@terakilobyte Hey do you know how to do that Confirm the Ending in Bonfire challenges ?
Dominic Jones
@towwiow
Mar 02 2015 00:51
Nathan knows how to do them all ;)
Harshal
@McQuinTrix
Mar 02 2015 00:51
@towwiow you know how to do it ? :)
(:
Nathan
@terakilobyte
Mar 02 2015 00:52
I’ve solved every bonfire multiple times in multiple ways now :)
Harshal
@McQuinTrix
Mar 02 2015 00:52

function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
return str.charAt(str.length-1)== target;
//return str;
}

end('Bastian', 'n');

i did this but one test fails
Nathan
@terakilobyte
Mar 02 2015 00:52
add three ` above and below your code
Harshal
@McQuinTrix
Mar 02 2015 00:52

function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
return str.charAt(str.length-1)== target;
//return str;
}

end('Bastian', 'n');

```
function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
return str.charAt(str.length-1)== target;
//return str;
}

end('Bastian', 'n');

Nathan
@terakilobyte
Mar 02 2015 00:52
close :)
Harshal
@McQuinTrix
Mar 02 2015 00:52
:D
Nathan
@terakilobyte
Mar 02 2015 00:53
you can edit a previous message rather than new messages
Harshal
@McQuinTrix
Mar 02 2015 00:53
function end(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  return str.charAt(str.length-1)== target;
  //return str;
}

end('Bastian', 'n');
Nathan
@terakilobyte
Mar 02 2015 00:53
if you need to fix your formatting
Harshal
@McQuinTrix
Mar 02 2015 00:53
did it finally :P
Nathan
@terakilobyte
Mar 02 2015 00:53
what happens if the second argument (target) has a length > 1?
what if I said end(‘hello’, ‘llo’)
it should still return true
John Ellis
@johnmellis
Mar 02 2015 00:53
Anyone online familiar with angular directive?
directives*
Nathan
@terakilobyte
Mar 02 2015 00:54
yes @johnmellis
Harshal
@McQuinTrix
Mar 02 2015 00:54
yeah .. so is there any small approach ?
or I need to use for loop or something
?
(:
Nathan
@terakilobyte
Mar 02 2015 00:54
no loop needed
Danny Fritz
@dannyfritz
Mar 02 2015 00:54
i've seen people solve it with loops.
Nathan
@terakilobyte
Mar 02 2015 00:54
I’d look in the MDN at string methods
Harshal
@McQuinTrix
Mar 02 2015 00:55
yeah i don't want it with loop
John Ellis
@johnmellis
Mar 02 2015 00:55
@terakilobyte I've created a blog.js directive; it's path is public > js > blog.js
Harshal
@McQuinTrix
Mar 02 2015 00:55
alright let me see
Nathan
@terakilobyte
Mar 02 2015 00:55
post your code
John Ellis
@johnmellis
Mar 02 2015 00:55
I've stored the html file that directive calls in public > blog-post.html
Nathan
@terakilobyte
Mar 02 2015 00:55
from your directive as well as the app declaration
John Ellis
@johnmellis
Mar 02 2015 00:55
I'm wondering about structure here, not necessarily code
Nathan
@terakilobyte
Mar 02 2015 00:56
ah
John Ellis
@johnmellis
Mar 02 2015 00:56
does the blog-post.html file have to live below blog.js
or do I have to do absolute path to the blog-post.html
Nathan
@terakilobyte
Mar 02 2015 00:56
no it can live wherever you want it to as long as your pathing is correct
John Ellis
@johnmellis
Mar 02 2015 00:56
dumb question
Nathan
@terakilobyte
Mar 02 2015 00:56
you can use relative urls
you just may have to jump up then down
John Ellis
@johnmellis
Mar 02 2015 00:56
how do I do that
I've always forced dependencies to be children
is it just a matter of calling /public/blog-post.html
from /public/js/blog.js
nvm I think I go it
got it
can someone remind me how to post code via shortcut
John Ellis
@johnmellis
Mar 02 2015 01:00
perfect thanks
@terakilobyte there's still something wrong
Here's my app.js code
<!-- blog post content -->
<div class="col-md-9">
  <div ng-repeat="post in blog.posts">
    <h1> <a href="{{post.link}}" target="_blank">{{ post.title }}</a></h1>
    <p><img ng-src="{{post.image}}" style="width:20%; height:20%"/> {{ post.headline }}</p>
  </div>
</div>
sorry - that was blog-post.html
here's blog.js
(function(){
  var app = angular.module('mysite-blog',[]);

  app.directive('blogPosts',function(){
    return {
      restrict:'E',
      templateUrl: '../blog-posts.html',
      controller : function(){
                    this.posts = blog_posts;
                  },
      controllerAs:'blog'
    };
  });

})();
app.js code
(function(){
  var app = angular.module('mysite',['mysite-blog']);

  //blogs - these will eventually be pulled from a database somwhere (Mongo?)
  var blog_posts = [
    {
      name: 1,
      link: "http://www.google.com",
      title: "Serenity Teaches Us Great Things",
      headline: "This is the headline for the blog post.  It shouldn't be very many characters.",
      body: "content will show up here when it's pulled from the db.",
      image: "http://blog.jimdo.com/wp-content/uploads/2014/01/tree-247122.jpg"
    },

    {
      name: 2,
      link: "http://www.google.com",
      title: "This is my second blog post",
      headline: "This is the headline for the blog post. It shouldn't be very long.",
      body: "content is starting to get easier to create",
      image: "http://images.visitcanberra.com.au/images/canberra_hero_image.jpg"
    },

    {
      name: 3,
      title: "This is my third blog post",
      body: "This is all repeating",
      image: "https://cdn.photographylife.com/wp-content/uploads/2014/06/Nikon-D810-Image-Sample-6.jpg"
    }
  ];


})();
Any idea why it's not pulling into <blog-posts></blog-posts> in index.html
Danny Fritz
@dannyfritz
Mar 02 2015 01:03
looks like var blog_posts isn't being used.
John Ellis
@johnmellis
Mar 02 2015 01:04
It's used in the blog directive
in the controller
Danny Fritz
@dannyfritz
Mar 02 2015 01:04
i'm willing to bet it is undefined in blog.js
John Ellis
@johnmellis
Mar 02 2015 01:04
let me log it and see what happens
yep, you're right
so
how do the blog entries get passed to the directive then
do they need to be called from within that directive?
Danny Fritz
@dannyfritz
Mar 02 2015 01:06
i think the angular way is to create a service that provides them
John Ellis
@johnmellis
Mar 02 2015 01:06
If my goal is to have Nodejs provide an API to get the object - should I still use an angular service?
Danny Fritz
@dannyfritz
Mar 02 2015 01:07
if you want a really quick fix, move var blog_posts into blog.js instead of encapsulating it in app.js's IIFE
another way is to just move var blog_posts after the })(); in app.js
John Ellis
@johnmellis
Mar 02 2015 01:08
@dannyfritz thanks man - moving it down worked
now the question is
do I use app.js to pull the data from an express route when pulling blogs from a daabase
or should I have the directive do it?
Danny Fritz
@dannyfritz
Mar 02 2015 01:09
i'm not sure about that. i'm not familiar with the angular way of doing things.
Hannan Ali
@abdulhannanali
Mar 02 2015 01:10
@dannyfritz TypeScript or CoffeScript?
Danny Fritz
@dannyfritz
Mar 02 2015 01:10
it looks like maybe you want a provider
@abdulhannanali JavasScript. :P http://spiderlang.org/ is neat though
John Ellis
@johnmellis
Mar 02 2015 01:11
Yea, hmm. I'll just leave it as is right now until I get everything the way I want it
then I'll optimize
Hannan Ali
@abdulhannanali
Mar 02 2015 01:12
@dannyfritz hehe
@dannyfritz Spider has no parens in for loops
strange
Danny Fritz
@dannyfritz
Mar 02 2015 01:13
there are a few languages like that
they treat things more as statements rather than expressions
Hannan Ali
@abdulhannanali
Mar 02 2015 01:14
Seems really interesting.
Danny Fritz
@dannyfritz
Mar 02 2015 01:17
literally the only thing i want from spider script is and and or
i really don't like && and ||
Harshal
@McQuinTrix
Mar 02 2015 01:18
@terakilobyte .. Done .. with .match(target+'$');
Danny Fritz
@dannyfritz
Mar 02 2015 01:18
@McQuinTrix nice
Harshal
@McQuinTrix
Mar 02 2015 01:18
(:
Danny Fritz
@dannyfritz
Mar 02 2015 01:18
solved with a generated regexp
Hannan Ali
@abdulhannanali
Mar 02 2015 01:19
@dannyfritz It has got all the good features of the languages like C#, Python, CoffeScript and more. Does that not interest you?
Danny Fritz
@dannyfritz
Mar 02 2015 01:20
yeah, it hits most of my syntax sweet spots
JavaScript's C-like syntax is really ugly in my opinion though.
Darryl Dixon - Piece Digital
@piecedigital
Mar 02 2015 01:22
Javascript is sexy
Danny Fritz
@dannyfritz
Mar 02 2015 01:22
i love the features of javascript, i could just do with a cleaner syntax
maybe i'll mess around with sweet.js to get a syntax i like, but then nobody will want to review my code. :P
Darryl Dixon - Piece Digital
@piecedigital
Mar 02 2015 01:24
Just took a look at it.. Mooooore power to ya :thumbsup: LoL
Christopher Hutchinson
@cshutchinson
Mar 02 2015 01:37
hi guys
John Ellis
@johnmellis
Mar 02 2015 01:44
OKay, another question @dannyfritz @terakilobyte - I've got a blog post object that I'm calling and I need formatted text for the blog post body - should I store html in the blog post, or create a dynamic object for each paragraph and loop through the psot looking for keys (elements to place)
Nathan
@terakilobyte
Mar 02 2015 01:56
You aren’t storing the data in a database?
I might be misunderstanding
Cristián Berríos
@crisberrios
Mar 02 2015 02:11
@johnmellis I think you're looking for "templates"
don't store <h2>title</h2> but rather <h2>{{title}}</h2> or even better <header></header>
depending on the engine.
I'm not sure about angular
John Ellis
@johnmellis
Mar 02 2015 02:39
@crisberrios That's what I'm doing, but the body of the post is usually a lot longer than the title tag. I'm wondering how I should handle new blogposts
Cristián Berríos
@crisberrios
Mar 02 2015 02:40
well, they should be split into paragraphs
and if the posts are too long
there should be a way add a breakpoint
and then retrieve the rest of the content using a "read more" link
the engine I'm using in my WIP page/blog (wintersmith) does this automatically, but it would be a good exercise to implement it from scratch
John Ellis
@johnmellis
Mar 02 2015 02:42
hmm, I have a feeling it's going to be some sort of post-janitor script
that combs the HTML and moves it to a predictable format - but how do you store that format if not in just plain HTML
John Ellis
@johnmellis
Mar 02 2015 02:52
They need auser skill search on this
Cristián Berríos
@crisberrios
Mar 02 2015 02:55
handlebars or ejs are pretty much just html
and .md is pretty predictable too
and more plain than html
John Ellis
@johnmellis
Mar 02 2015 03:00
So, if I have a menu in angular
should I treat it as a tab?
(like in the codeschool walkthrough?)
Cristián Berríos
@crisberrios
Mar 02 2015 03:07
hmm I don't know
I'm really weak at angular :(
John Ellis
@johnmellis
Mar 02 2015 03:08
I just don't know where to start on it... I understand page elements and directives to change data
but I'm struggling when it comes to changing pages - do I just use express?
Cristián Berríos
@crisberrios
Mar 02 2015 03:08
but take a look at angular-ui
in special, ui-router
or look for ng-router
John Ellis
@johnmellis
Mar 02 2015 03:11
I think I will - I really want to reserve Express for the API calls
API calls only*
maybe, I should take a break from angular for tonight and start dynamically building the API to get blog posts
Cristián Berríos
@crisberrios
Mar 02 2015 03:19
well, one of the ideas of using angular is moving view logic into the client
so it's a good idea in that case to use express only for api calls
John Ellis
@johnmellis
Mar 02 2015 03:25
That's what I was thinking; it seems like using express to serve pages defeats the purpose of using angular
Cristián Berríos
@crisberrios
Mar 02 2015 03:30
in a sense, it does
Elliescode
@EllieAdam
Mar 02 2015 17:13
Good morning! I need some help on git graph I tried so many attemps but no progress. thanks
Ashley Drake
@aldraco
Mar 02 2015 22:46
thank you @terakilobyte and @Dadsaster for your help with the no repeats!!
Nathan
@terakilobyte
Mar 02 2015 22:54
@aldraco glad you got it, was it rewarding in the end?
Ashley Drake
@aldraco
Mar 02 2015 22:55
Very much.
Lesson - things that work on paper don't always translate to computer easily
And pairing is extremely helpful
Evan Davis
@davisec52
Mar 02 2015 23:31
Good evening, everybody. I'm just starting the bonfire challenge, "sum all numbers in a range" but am not sure I understand what the desired output is. That is, if the input is [1, 4], is the output 1+2+3+4, or something else such as, 1+2, 1+3, 1+4, 2+3, 2+4?
Christopher Hutchinson
@cshutchinson
Mar 02 2015 23:31
@davisec521+2+3+4
Evan Davis
@davisec52
Mar 02 2015 23:32
@cshutchinson Great--thank you!
Christopher Hutchinson
@cshutchinson
Mar 02 2015 23:32
@davisec52 Hi Dave, glad to help
Cristián Berríos
@crisberrios
Mar 02 2015 23:48
With Ramda it should be something like R.reduce(R.sum,R.range(1,4));
This message was deleted