Git Product home page Git Product logo

learnyounode's Introduction

Workshopper

Join the chat at https://gitter.im/nodeschool/workshoppers

Workshopper is no longer maintained

In mid-term workshopper will be replaced with workshopper-adventure. Please try to build new workshoppers against workshopper-adventure. Thanks. (your maintainer)

Readme until now:

A terminal workshop runner framework

NPM NPM

Learn You The Node.js For Much Win!

Workshopper is used by learnyounode, and other Node.js command-line workshop applications.

*Documentation is being written for the v1 rewrite right now! Ping @rvagg if you need anything. learnyounode is now using this new version, for now you can use it to see how this works.

For now, @linclark has written a good introduction on creating your own workshop, available here.

High-level overview

Workshopper is essentially a test-runner with a fancy terminal UI. The Workshopper package itself is largely concerned with the menu system and some of the basic command-line parsing. Much of the work for executing the exercise validation is handled by workshopper-exercise.

Contributors

workshopper is proudly brought to you by the following hackers:

Maintainers

License

Workshopper is Copyright (c) 2013-2015 Rod Vagg @rvagg and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

Workshopper builds on the excellent work by @substack and @maxogden who created stream-adventure which serves as the original foundation for Workshopper and learnyounode. Portions of Workshopper may also be Copyright (c) 2013 @substack and @maxogden given that it builds on their original code.

learnyounode's People

Contributors

a0viedo avatar atuyl avatar billy3321 avatar ccarruitero avatar cfsghost avatar denysdovhan avatar dominhhai avatar feross avatar flet avatar greenkeeper[bot] avatar greenkeeperio-bot avatar haradats avatar isruslan avatar julianduque avatar lisposter avatar lucasfcosta avatar marocchino avatar martinheidegger avatar martiuslim avatar max-mapper avatar milesibastos avatar minatu2d avatar molcay avatar pirfalt avatar ralphtheninja avatar rvagg avatar tdd avatar tgfjt avatar thehack avatar timoxley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learnyounode's Issues

Correct result for MAKE IT MODULAR fails

Completing the MAKE IT MODULAR exercise with a correct output still results in a failure. The failure is caused both by this code as well as the answer code in the Git repo.

The following is the output log from the verify command.

Verifying "MAKE IT MODULAR"...

ACTUAL                             EXPECTED
------                             --------
"CHANGELOG.md"                     "CHANGELOG.md"                 
"LICENCE.md"                       "LICENCE.md"                   
"README.md"                        "README.md"                    
""                                 ""                             

Your additional module file:
    /Users/jwhite/Node/learnyounode/filter_module.js
did not return an Array with the correct number of elements as the second argument of the callback

# FAIL

Your solution to MAKE IT MODULAR didn't pass. Try again!

HTTP UPPERCASERER won't pass.

Even using the http_uc.js solution, it won't pass. Running learnyounode verify http_uc.js I get the following:

ACTUAL                             EXPECTED
------                             --------
"COATHANGER"                    != "She'll be right swag to built like a ya. As cunning as a skite where as cunning as a quid. Get a dog up ya barbie my she'll be right bail out."
"HIT THE TURPS"                 != null                           
"CRANKY"                        != null                           
"RATBAG"                        != null                           
"YABBER"                        != null                           
"GOOD ONYA"                     != null                           
"WAGGIN' SCHOOL"                != null                           
"BACK OF BOURKE"                != null                           
"SUNNIES"                       != null                           
"CHUCK A SICKIE"                != null                           
""                              != null   

I'm running Node v0.10.9 and Learnyounode 0.2.15.

http-collect solution cannot be verified

When running the solution provided here I get the following output

Verifying "HTTP COLLECT"...

ACTUAL:   ""
EXPECTED: "123"

ACTUAL:   null
EXPECTED: "Flat out like a swag no worries as dry as a big smoke. 
Lets throw a fruit loop how as stands out like not my
bowl of rice. "

ACTUAL:   null
EXPECTED: ""

# FAIL

Your solution to HTTP COLLECT didn't match the expected output.
Try again!

I'm in TIME SERVER and I get an unexpected null at the end of the verify and my script fails.

var net = require("net");
var date = new Date();
server = net.createServer(function(socket){
  socket.end(""+date.getFullYear()+"-"+parseInt(date.getMonth() + 1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes());
});
server.listen(8000);

I get:

ACTUAL                             EXPECTED
------                             --------
"2013-10-28 14:37"                 "2013-10-28 14:37"
null                            != ""
# FAIL

Why it fails?
Thank you.
(Sorry for my english).

Your project is too much fun.

I had entirely too much fun working through these exercises and solidifying my node knowledge. Thank everyone who worked on this.

Official solutions not displaying on Windows 7 x64.

Instead of an official solution I get a 'This socket is closed' error. This is with all the lessons I have tried, I include the output from the HELLO WORLD one.

ACTUAL EXPECTED


"HELLO WORLD" "HELLO WORLD"
"" ""

PASS

Your solution to HELLO WORLD passed!

Here's what the official solution is if you want to compare notes:

Error: This socket is closed.
at Socket._write (net.js:635:19)
at doWrite (_stream_writable.js:221:10)
at writeOrBuffer (_stream_writable.js:211:5)
at Socket.Writable.write (_stream_writable.js:180:11)
at Socket.write (net.js:613:40)
at fromString (C:\Users\Dev\AppData\Roaming\npm\node_modules\learnyounode\no
de_modules\workshopper\node_modules\pygmentize-bundled\index.js:44:18)
at pygmentize (C:\Users\Dev\AppData\Roaming\npm\node_modules\learnyounode\no
de_modules\workshopper\node_modules\pygmentize-bundled\index.js:104:11)
at map.updateData.xs (C:\Users\Dev\AppData\Roaming\npm\node_modules\learnyou
node\node_modules\workshopper\workshopper.js:219:9)
at invokeIterator (C:\Users\Dev\AppData\Roaming\npm\node_modules\learnyounod
e\node_modules\workshopper\node_modules\map-async\index.js:50:18)
at map (C:\Users\Dev\AppData\Roaming\npm\node_modules\learnyounode\node_modu
les\workshopper\node_modules\map-async\index.js:21:9)

I have some trouble in JUGGLYNC ASYNC

This is my code:

http = require('http');

urls = [process.argv[2], process.argv[3], process.argv[4]];
out = [];



function getter (url, iterator){
  var temp = "";
  http.get(url[iterator], function(response){
    response.setEncoding('utf-8');
    response.on('data', function(data){
      temp += data;
    });

    response.on('end', function(){
      out[iterator] = temp;
      if(iterator == 2){
        for(var i = 0;i<3;i++){
          console.log(out[i]);
        }
      }
    });
  });
}

for(var i = 0;i<3;i++){
  getter(urls, i);
}

When I test by myself:

C:\Users\Oscar\Documents\GitHub\learn>node httpget http://google.com http://amaz
on.com http://ask.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.amazon.com/">here</a>.</p>
</body></html>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.ask.com">here</a>.</p>
</body></html>

I think it works! :)

But when I try to verify in learnyoucode I get this:

Verifying "JUGGLING ASYNC"...

ACTUAL:   "undefined"
EXPECTED: "Gutful of clucky heaps trent from punchy butcher. She'll be right bra
ss razoo piece of piss you little ripper dunny. Grab us a galah to she'll be rig
ht reckon. Gutful of sheila how she'll be right throw-down. "

ACTUAL:   "It'll be pint heaps lets throw a bikkie. You little ripper yakka to t
rent from punchy booze bus. She'll be right stubby when grab us a pot. It'll be
jumbuck to as cross as a boozer. She'll be right schooner bloody he's got a mass
ive bingle. "
EXPECTED: "It'll be pint heaps lets throw a bikkie. You little ripper yakka to t
rent from punchy booze bus. She'll be right stubby when grab us a pot. It'll be
jumbuck to as cross as a boozer. She'll be right schooner bloody he's got a mass
ive bingle. "

ACTUAL:   "She'll be right daks heaps as dry as a avos. Stands out like a stride
s no dramas lets get some maccas. Grab us a trackies with we're going sanger. "
EXPECTED: "She'll be right daks heaps as dry as a avos. Stands out like a stride
s no dramas lets get some maccas. Grab us a trackies with we're going sanger. "

ACTUAL:   ""
EXPECTED: ""

# FAIL

Your solution to JUGGLING ASYNC didn't match the expected output.
Try again!

What is my error?

Thank you ๐Ÿ˜„

MY FIRST I/O has wrong matching

here's my code (it does not pass the test, even though its right):

#!/usr/bin/env node
var args = process.argv;

if( args.length < 3 ) {
    console.error('ERROR: expected is a filename');
    return 1;
}

var content = [],
    lines = 0,
    fs = require('fs');

content = fs.readFileSync(args[2]).toString().split('\n');

lines = content.length - 1;

if( lines && (!content[lines - 1]) ) {
    --lines;
}

console.log(lines);

Error on install

/usr/local/bin/learnyounode -> /usr/local/lib/node_modules/learnyounode/learnyounode.js
npm WARN unmet dependency /usr/local/lib/node_modules/jitsu/node_modules/request/node_modules/form-data requires mime@'1.2.2' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/jitsu/node_modules/request/node_modules/mime,
npm WARN unmet dependency which is version 1.2.7
npm ERR! peerinvalid The package flatiron does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants flatiron@~0.1.9
npm ERR! peerinvalid Peer [email protected] wants flatiron@~0.1.9

npm ERR! System Darwin 12.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "learnyounode"
npm ERR! cwd /Users/kyle
npm ERR! node -v v0.10.12
npm ERR! npm -v 1.3.1
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/kyle/npm-debug.log
npm ERR! not ok code 0

verification problem

I submitted a code for verification for the "MAKE IT MODULAE" stage, the "actual" and "expected" were identical, but I still didn't pass the stage, and I got no error, just the results comparison was outputted
here's my code
for the file a.js

 module.exports=function(folder,ext){
         fs=require('fs');
         fs.readdir(folder,function(err,data){
                 if(!err){
                         rex=new RegExp('\\.'+ext+'$');
                         data.forEach(function(f){
                                 if(rex.test(f)){
                                         console.log(f);
                                 }
                         });

                 } else {
                         return err
                 }
         });
 }

and for b.js

 a=require("./a.js");
 a(process.argv[2],process.argv[3]);

and to verify I executed
learnyounode verify b.js

HTTP UPPERCASERER doesn't require POST request

I've just completed the lesson HTTP UPPERCASERER where it asks for the HTTP server to only receive POST requests. However the solution doesn't require the server to filter out non POST requests. I believe the solution should send a GET request to see if the server is filtering out non POST requests

Need help-something wrong when run time server

var net = require("net");
function pad(n) {return n < 10 ? '0'+ n : n }
var server = net.createServer(function(socket){
  var d = new Date();
  var s = d.getFullYear() + "-"
    + pad(d.getMonth()+1) + "-"
    + pad(d.getDate()) + "-"
    + pad(d.getHours()) + ":"
    + pad(d.getMinutes());
  socket.end(s);
})
server.listen(8000);

The output is "Error connecting to localhost:3911: connect ECONNREFUSED" != "2014-02-12 20:11"
null != ""
Is there anyone can help me? Thanks a lot.

Can't launch verify on Time Server

For the Time Server, the verify command fail to launch, I get connection refused.

No other TCP server is running on 8000 or 8001.
The run command is running correctly and I get the date.

If I run my solution directly, I can get the date with a telnet.

Here the full output when I launch verify:

ACTUAL                             EXPECTED
------                             --------

events.js:77
        throw er; // Unhandled 'error' event
              ^
Error: connect ECONNREFUSED
    at exports._errnoException (util.js:671:11)
    at Object.afterConnect [as oncomplete] (net.js:938:19)

And my solution:

var net = require('net')

function zeroFill(number) {
    return (number < 10 ? '0'+number : number)
}

var server = net.createServer(function (socket) {
    var date=new Date()
    var strDate=date.getFullYear()+'-'+
                zeroPad(date.getMonth())+'-'+
                zeroPad(date.getDay())+' '+
                zeroPad(date.getHours())+':'+
                zeroPad(date.getMinutes())+'\n'
    socket.write(strDate)
    socket.end()
})
server.listen(8000)

potential issues with files without extensions

hey there

1st of all - great work - playing around and it's great fun and a learning experience combined ๐Ÿ‘


however, i've got an issue with filtering the extensions and such

what about files without an extension?

if i'd like to filter for files without the extension, the solution like

path.extension(file) === '.' + ext

seems wrong to me

my solution was a comparison like

path.extension(file).replace(/^\./, '') === ext

or am i missing something here? :)

'MAKE IT MODULAR' not getting marked '[COMPLETED]'

My code seems to be passing:

$ learnyounode verify modular.js
Verifying "MAKE IT MODULAR"...

ACTUAL                             EXPECTED
------                             --------
"CHANGELOG.md"                     "CHANGELOG.md"                 
"LICENCE.md"                       "LICENCE.md"                   
"README.md"                        "README.md"                    
""                                 ""                             
[Error: testing]

but 'MAKE IT MODULAR' is not getting marked '[COMPLETED]' in the main menu.

Here is my code:

//filterModule.js
var fs = require('fs');

module.exports = function(path, filter) {
    var regex = new RegExp("\\." + process.argv[3] +"$");
    fs.readdir(path, function(err, data) {
        if (err) {
            return console.log(err)
        }
        // print a list of files path, with the extention given
        for (var i = 0; i < data.length; i++) {
            if (regex.test(data[i])) {
                console.log(data[i])
            }
        };
    })
}
//modular.js
var filter = require('./filterModule.js');

filter(process.argv[2], process.argv[3]);

Other languages?

Hi,

i really enjoyed nodeschool.io - great work!

Have you planed to offer it in other languages? I can help you translate to german if you want.

Especially the hints are not so easy to understand if english is not your native language

http_file_server Never Passes

I've tried to complete the "http_file_server" course. Verify always tells me my test failed. However, when I copy the solution it fails as well.

Here is the output using the recommended solution:

Verifying "HTTP FILE SERVER"...

ACTUAL:   "Grab us a ugg mate he hasn't got a dropkick. Stands out like a boogie board mate as stands out like bradman. Grab us a ironman no worries trent from punchy grog. Get a dog up ya bogged piece of piss lets throw a larrikin."
EXPECTED: "As cunning as a mozzie bloody trent from punchy pokies. She'll be right fly wire flamin as cross as a jumbuck. Gutful of cockie with lets get some knock. Flat out like a cook heaps as busy as a rollie."

# FAIL

Your solution to HTTP FILE SERVER didn't pass. Try again!

moment is frameworky

On the time server example, it'd probably be better to recommend strftime instead of moment since strftime is far more unixy since it just implements the string formatting from the unix date command. The time format is just strftime('%F %H:%M', date).

The last verify solution is incorrect

I have confirmed this issue by grabbing the solution from the repo.

Here is the output from the verify:

ACTUAL: "{"hour":18,"minute":1,"second":47}"
EXPECTED: "send me a POST"

ACTUAL: "{"unixtime":1377208907000}"
EXPECTED: ""

ACTUAL: ""
EXPECTED: "send me a POST"

ACTUAL: null
EXPECTED: ""

FAIL

Your solution to HTTP JSON API SERVER didn't match the expected output.
Try again!

My first I/O - wrong line count

My first I/O validates line count with an extra line.
the output of :

fs = require('fs');
//console.log(fs.readFileSync(process.argv[2]).toString().split('\n') );
console.log(fs.readFileSync(process.argv[2]).toString().split('\n').length );

is one line longer than the output of the unix utility
wc -l , and to the real number of lines in the file.
but It passes the verify step.
detailed output:

vagrant@precise32:~/stuff$ wc -l wc.js
3 wc.js
vagrant@precise32:~/stuff$ node wc.js wc.js
4

seems that an empty string at the end of the array is counted.

$: node wc.js wc.js

[ 'fs = require(\'fs\');',
  'console.log(fs.readFileSync(process.argv[2]).toString().split(\'\\n\') );',
  '//console.log(fs.readFileSync(process.argv[2]).toString().split(\'\\n\').length );',
  '' ]

HTTP JSON API SERVER

Ok all works great ... very cool project.
Unfortunately there is just a small caveat in the last problem.

User need to write code to respond to api request. One of them is the unixtime api.
Time gap between user code execution and provided solution execution could make a false negative test result.

An example here:

ACTUAL:   "{\"hour\":10,\"minute\":27,\"second\":54}"
EXPECTED: "{\"hour\":10,\"minute\":27,\"second\":54}"

ACTUAL:   "{\"unixtime\":1376468974699}"
EXPECTED: "{\"unixtime\":1376468874180}"

ACTUAL:   ""
EXPECTED: ""

One solution is to change api request in the problem to something less picky. I think there are not available solution considering how Workshopper works
Best Regards
Francesco

process.argv

Hello, I had problems with the array process.argv, my return:
['node', 'path-file.js']

Exercises in the use of the solutions process.argv talks to use the array at position 'process.argv [2], but the two have nothing ... used in position' process.argv [1] ', but when I send command 'VERIFY' he needs me to use the 'process.argv [2] to complete the exercise.

Thank you.

A typo in learnyounode/TimeServer task

In Time Server task there's a typo in date format. Original quote:

Your server should listen to TCP connections on port 8000. For each
connection you must write the current date & time in the format:

  YYYY-MM-DD HH:MM

I think that time format should look like YYYY-MM-DD hh:mm. Especially it is important for minutes since minutes and months has similar format literals.

HTTP JSON API Server test is never true

The second test (unixtime test) will never be true. The compared expected/actual values we get from Date.now() and will never be the same.
Proposal:
the expectedValue - constant <= actualValue <= expectedValue + constant

Unhandled stream error in pipe.

On HTTP FILE SERVER, I get:

$ learnyounode verify myprogram11.js

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: connect ECONNREFUSED
    at errnoException (net.js:901:11)
    at Object.afterConnect [as oncomplete] (net.js:892:19)

Even when using the proposed solution.

Node is v0.10.15.

verify text formatting remains active for prompt

Using learnyounode v0.2.16 on node v0.10.21 on Windows7 (standard cmd-shell, no elevated permissions, although I am a local admin), upon learnyounode verify [foo.js] some formatting remains when the application exits back to the command-prompt:

learnyounode formatting 00

Unable to complete HTTP File Server

I wrote out my code for the exercise and it was failing with the following error:

var fs = require('fs');
var http = require('http');

var path = process.argv[2];

var server = http.createServer(function (request, response){
    var src = fs.createReadStream(path);
    src.pipe(response);
});

server.listen(8000);

stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: Parse Error
at Socket.socketOnData (http.js:1584:20)
at TCP.onread (net.js:525:27)

I then tried the solution code in the repository (see below) and it too is failing with the same error.

var http = require('http');
var fs = require('fs');

var server = http.createServer(function (req, res) {
  fs.createReadStream(process.argv[2]).pipe(res);
  res.end();
});
server.listen(8000);

stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: Parse Error
at Socket.socketOnData (http.js:1584:20)
at TCP.onread (net.js:525:27)

I am running the latest version of node v0.10.16

Error on attempting to run `learnyounode`

Not sure if this is an issue with learnyounode or workshopper (or mkdirp!), but after successful installation, running 'learnyounode' threw an error on a Windows machine:

D:\Data\NodeJS\nodeSchool>learnyounode

D:\AppData\goffinf\Application Data\npm\node_modules\learnyounode\node_modules\workshopper\node_modules\mkdirp\index.js:74
                    throw err0;
                          ^
RangeError: Maximum call stack size exceeded

This was on the attendee's machine at a node school IRL event, and I have been unable to replicate.

Install error: Error: SSL Error: CERT_UNTRUSTED

I just installed npm 1.1.43. Then, I tried to install learnyounode. I'm getting this output:

$ sudo npm install learnyounode -g
Password:
npm http GET https://registry.npmjs.org/learnyounode
npm http GET https://registry.npmjs.org/learnyounode
npm http GET https://registry.npmjs.org/learnyounode
npm ERR! Error: SSL Error: CERT_UNTRUSTED
npm ERR! at ClientRequest. (/usr/local/lib/node_modules/npm/node_modules/request/main.js:440:26)
npm ERR! at ClientRequest.g (events.js:185:14)
npm ERR! at ClientRequest.EventEmitter.emit (events.js:88:17)
npm ERR! at HTTPParser.parserOnIncomingClient as onIncoming
npm ERR! at HTTPParser.parserOnHeadersComplete as onHeadersComplete
npm ERR! at CleartextStream.socketOnData as ondata
npm ERR! at CleartextStream.CryptoStream._push (tls.js:396:27)
npm ERR! at SecurePair.cycle (tls.js:750:20)
npm ERR! at EncryptedStream.CryptoStream.write (tls.js:131:13)
npm ERR! at Socket.ondata (stream.js:38:26)
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

npm ERR! System Darwin 13.0.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "learnyounode" "-g"
npm ERR! cwd /Users/alshamma
npm ERR! node -v v0.8.3
npm ERR! npm -v 1.1.43
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/alshamma/npm-debug.log
npm ERR! not ok code 0

The log says (in part):
24 http GET https://registry.npmjs.org/learnyounode
25 info retry will retry, error on last attempt: Error: SSL Error: CERT_UNTRUSTED
26 info retry registry request attempt 2 at 17:48:11
27 http GET https://registry.npmjs.org/learnyounode
28 info retry will retry, error on last attempt: Error: SSL Error: CERT_UNTRUSTED
29 info retry registry request attempt 3 at 17:49:11
30 http GET https://registry.npmjs.org/learnyounode
31 silly lockFile a353de34-learnyounode learnyounode@
32 error Error: SSL Error: CERT_UNTRUSTED
32 error at ClientRequest. (/usr/local/lib/node_modules/npm/node_modules/request/main.js:440:26)

When I look at https://registry.npmjs.org/learnyounode with Chrome is says the identity is verified.

Error in HTTP Collect answer ?

The answer for this exercise contains:

...
          if (err)
            return console.error(data)
...

Shouldn't it be

...
          if (err)
            return console.error(err)
...

?

Time Server seems to hang

I've been trying to verify my solution to time server and it seems to hang and do nothing.
It comes up with -

Verifying "TIME SERVER"...
ACTUAL EXPECTED

Then nothing for about 5 minutes.
It then says -
"Error connecting to localhost:8000: read ECONNRESET" != "2013-11-05 18:32"

FAIL

I've tried this with the official solution too and I get the same problem.

I'm running windows 7. Do you have any idea why I might be encountering this problem?

verify http file server give strange results

I haven't ruled out that this is a PEBKAC yet. This is the solution I have for HTTP file server:

var http = require('http')
var fs = require('fs')

if(process.argv.length < 3) {
  console.error('you forgot to give me a file')
  process.exit
}

var file = process.argv[2]

var server = http.createServer(function (request, response) {
  var stream = fs.createReadStream(file)
  stream.pipe(response)
})

server.listen(8000)

When I hit this in a browser (after passing in an ASCII file on the filesystem), it always returns consistent (and expected) results. When I use learnyounode verify, it always returns different (inconsistent) results that don't match expected.

Couple of examples:

$ learnyounode verify httpfileserver.js
ACTUAL:   "As cross as a cane toad no worries it'll be bizzo. Come a grouse bloody you little ripper swag. As cross as a bush bash my shazza got us some thingo."
EXPECTED: "We're going pot also mad as a struth. Lets get some slabs when he's got a massive grog. We're going sleepout how as cross as a cockie. Watch out for the ankle biter no dramas come a rotten. Watch out for the captain cook mate stands out like a piker."

Another one (expected is the same as above):

ACTUAL:   "You little ripper freo bloody as cross as a crook. As cross as a esky and as stands out like corker. Stands out like a chrissie how grab us a jillaroo. Mad as a prezzy to as cross as a slacker."

Problem with Port on Time Server question

I have a problem using port 8000 on a windows 7 machine this port is being used by the system, for some purpose or other. I am afraid that finding what is actually using this port maybe a little beyond me and is certainly beyond the time I have available. I have seen in other posts that you were going to allow users to input the port on the command line. Has this been implemented yet? If not is there a workaround?

The baby steps official solution

We could use Array.prototype.forEach instead plain for (var i = 2; i < process.argv.length; i++) { ... }, couldn't we?

So the solution might be

var total = 0;

process.argv.forEach(function(item) {
  //we need to exclude first and second items
  //so we could just filter them as NAN
  total += +item ? +item : 0;
});

console.log(total);

HTTP JSON API SERVER - Verify Error

Hey,

i get an error on verify the last chapter:

> learnyounode verify 13.js

/usr/local/lib/node_modules/learnyounode/exercises/http_json_api_server/exercise.js:66
    , 'Error connecting to http://localhost:' + port + ': ' + err.message
                                                                 ^
TypeError: Cannot read property 'message' of undefined
at Stream.error (/usr/local/lib/node_modules/learnyounode/exercises/http_json_api_server/exercise.js:66:70)
at Stream.EventEmitter.emit (events.js:117:20)
at ClientRequest.<anonymous> (/usr/local/lib/node_modules/learnyounode/node_modules/hyperquest/index.js:13:15)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:415:13)

This is my 13.js-file:

var url = require('url');
var http = require('http');

var port = parseInt(process.argv[2]);

var server = http.createServer(function (req,res) {

var urlparam = url.parse(req.url, true);

if(req.url.match(/\/api\/unixtime/)){
    var datum = new Date(urlparam.query.iso);

    var objt = {
        unixtime: datum.getTime()
    };

    res.writeHead(200, { 'Content-Type': 'application/json' });
    res.end(JSON.stringify(objt));
}else if(req.url.match(/\/api\/parsetime/)){
    var datum = new Date(urlparam.query.iso);

    var objt = {
        hour: datum.getHours(),
        minute: datum.getMinutes(),
        second: datum.getSeconds()
    };
    res.writeHead(200, { 'Content-Type': 'application/json' });
    res.end(JSON.stringify(objt));
}else{
    res.writeHead(404);
    res.end();
}

});

server.listen(port);

Invalid Port Number being used.

I found an interesting bug i wanted to fix. :/

dennis learnyounode $ learnyounode verify myprogram.js 
Verifying "TIME SERVER"...

ACTUAL                             EXPECTED
------                             --------
"Error connecting to localhost:66062: connect ECONNREFUSED" != "Error connecting to localhost:66063: connect ECONNREFUSED"
# FAIL

Your solution to TIME SERVER didn't match the expected output.
Try again!

Sorry, but i don't think port 66062 exists.

no mention of JSON.stringify() requirement in the last lesson

Thankfully after just attempting response.toString() in the final lesson (HTTP JSON API SERVER) I remembered there was a javascript way of turning objects into a json string.

However somebody else may not know about this and there was no mention of it in the hints or instruction or in any of the previous lessons.

Just thought I would point this out.

Regression test harness

I'm interested in adding a simple test harness to guard against regressions as alluded to in a recent PR.

I can't imagine it's too difficult since workshopper is essentially a test framework already.

Would this work be useful to the project in your collective minds?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.