Giter VIP home page Giter VIP logo

bytewiser's Introduction

Bytewiser

A nodeschool.io workshop that teaches you the fundamentals of working with binary data in node.js and HTML5 browsers

NPM

Bytewiser!

  1. Run sudo npm install bytewiser@latest -g
  2. Run bytewiser
  3. .. there is no step 3!

bytewiser will run through a series of Node.js + JS challenges. Starting with the basic operations of Buffers and Typed Arrays and moving on to more advanced exercises.

bytewiser builds on the workshopper framework which is also used by nodeschool.

contributors

bytewiser is only possible due to the excellent work of the following contributors:

Max OgdenGitHub/maxogdenTwitter/@maxogden
Joshua K. FarrarGitHub/sent1nel
Christophe PorteneuveGitHub/tddTwitter/@porteneuve

bytewiser's People

Contributors

ajcrites avatar artisonian avatar davearel avatar jarofghosts avatar jedireza avatar max-mapper avatar sequoia avatar tdd 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

bytewiser's Issues

Half of the challenges error on open

When attempting to open it, FileReader throws this error:

/usr/local/share/npm/lib/node_modules/bytewiser/node_modules/workshopper/print-text.js:13
      throw err
            ^
Error: ENOENT, open '/usr/local/share/npm/lib/node_modules/bytewiser/problems/filereader/problem.txt'

This may be an issue with workshopper or my install. Just want to document that I'm getting this error, just in case it's not only me.

I'm on Mac OS 10.9 with node 0.10.22 installed via homebrew. Is this error me?

A number conversion exercise

One of the notes on the upgrade list was that we should be using ascii characters or their decimal representations where possible instead of their hex counterparts. I think this could lead to problems because a user could pass a course on byte-level manipulation without actually using a more typical representation of data.

I propose we create an additional exercise, that goes before modifying buffers, that attempts to teach the user hexadecimal representation of binary data as it is likely more common that data will be in hex than decimal form.

I also have some ideas for more advanced exercises where the user will be dealing with only binary data, not just data that could have an ascii representation, such as plain text. I've been looking at node-torrent, for instance, which might require the user juggle multiple get requests and work with binary data directly to position it properly within a binary file.

line-splitter validation doesn't say I passed

While trying to solve line-splitter, I came up the following solution and have it saved in lineSplitter.js:

var fs = require('fs'),
     file = process.argv[2];

fs.readFile(file, 'utf-8', function(err, data) {
    if (err) console.error(err);

    var lines = data.split("\n");
    for (var i = 0; i < lines.length; i++) {
        console.log(Buffer.from(lines[i]));
    }
});

When I run "bytewiser verify lineSplitter.js", I can see Actual vs Expected matches both cases, but I don't get the "You passed" and the list of challenges still shows Line Splitter as incomplete.

Is this due to the way I am return (or rather, not returning) the result?

official solution to exercise 2 does not pass

Hello,

When I use the official solution which looks like this :


var bytes = [0, 15, 24, 3, 250, 83]
var buff = new Buffer(bytes)
console.log(buff.toString('hex'))

I see this output:


Your submission results compared to the expected:                                                        

                 ACTUAL                                  EXPECTED                                        
────────────────────────────────────────────────────────────────────────────────                         

   "000f1803fa53"                      !=    "7c11bcb6d2"                                                
   ""                                  ==    ""                                                          

────────────────────────────────────────────────────────────────────────────────                         

✗ Submission results match expected                                                                      

# FAIL                                                                                                   

Your solution to Hexadecimal Encoding didn't pass. Try again!  

nodejs version : v0.10.32
workshop version : [email protected]

Roelof

Piping to stdout rather than using console.log causes test failures

e.g. typed-array example:

[diamonds@localhost bytewiser]$ bytewiser verify typed-array.js                              
Verifying "Typed Arrays"...                                                                  

ACTUAL:   "{\"0\":115,\"1\":101,\"2\":99,\"3\":114,\"4\":101,\"5\":116,\"6\":32,\"7\":109,\"8
\":101,\"9\":115,\"10\":115,\"11\":97,\"12\":103,\"13\":101,\"BYTES_PER_ELEMENT\":1,\"buffer\
":{\"0\":115,\"1\":101,\"2\":99,\"3\":114,\"4\":101,\"5\":116,\"6\":32,\"7\":109,\"8\":101,\"
9\":115,\"10\":115,\"11\":97,\"12\":103,\"13\":101,\"byteLength\":14},\"length\":14,\"byteOff
set\":0,\"byteLength\":14}"                                                                  
EXPECTED: "{\"0\":115,\"1\":101,\"2\":99,\"3\":114,\"4\":101,\"5\":116,\"6\":32,\"7\":109,\"8
\":101,\"9\":115,\"10\":115,\"11\":97,\"12\":103,\"13\":101,\"BYTES_PER_ELEMENT\":1,\"buffer\
":{\"0\":115,\"1\":101,\"2\":99,\"3\":114,\"4\":101,\"5\":116,\"6\":32,\"7\":109,\"8\":101,\"
9\":115,\"10\":115,\"11\":97,\"12\":103,\"13\":101,\"byteLength\":14},\"length\":14,\"byteOff
set\":0,\"byteLength\":14}"                                                                  

ACTUAL:   null                                                                               
EXPECTED: ""                                                                                 

# FAIL                                                                                       

Your solution to Typed Arrays didn't match the expected output.                              
Try again!                                                                                   

I'm failing because of the trailing "" vs. 'null'. My code:

var through = require('through');
process.stdin.pipe(through(function write(chunk){
  var typarray = new Uint8Array(chunk);
  this.queue(JSON.stringify(typarray));
})).pipe(process.stdout);

Given solution:

process.stdin.once('data', function(buff) {             
  var ui8 = new Uint8Array(buff.length)                 
  for (var i = 0; i < buff.length; i++) ui8[i] = buff[i]
  console.log(JSON.stringify(ui8))                      
})

I thought doing stuff with streams rather than sync console.logging was more proper & nodey so I've been trying to do that. If the exercise specifically requires a trailing newline, this should be stated clearly or "use console.log" or "process.stdout.write" given as hints or just explicitly "The output should end with a newline char, so if you're not using console.log or process.stdout.write, you'll need to add it explicitly."

Desired explanation for bonus challenge in final problem?

I'd love to see some definitive explanation for the bonus challenge presented in the final problem.

We know that a Uint16Array typed array represents an array of unsigned 16-bit integers and that the representation changes (viz., in the "offsets", I think) after 4294967295.

4294967294 '{"0":65534,"1":65535,"BYTES_PER_ELEMENT":2,"buffer":{"0":254,"1":255,"2":255,"3":255,"byteLength":4},"length":2,"byteOffset":0,"byteLength":4}'
4294967295 '{"0":65535,"1":65535,"BYTES_PER_ELEMENT":2,"buffer":{"0":255,"1":255,"2":255,"3":255,"byteLength":4},"length":2,"byteOffset":0,"byteLength":4}'
4294967296 '{"0":0,"1":0,"BYTES_PER_ELEMENT":2,"buffer":{"0":0,"1":0,"2":0,"3":0,"byteLength":4},"length":2,"byteOffset":0,"byteLength":4}'

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.