Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
studentzero
@studentzero
A yes
now i get this
function (path, options) {
  options = getOptions(options, { flag: 'r' });
  var isUserFd = isFd(path); // file descriptor ownership
  var fd = isUserFd ? path : fs.openSync(path, options.flag || 'r', 0o666);

  tryStatSync(fd, isUserFd);
  // Use stats array directly to avoid creating an fs.Stats instance just for
  // our internal use.
  var size;
  if ((statValues[1/*mode*/] & S_IFMT) === S_IFREG)
    size = statValues[8/*size*/];
  else
    size = 0;
  var pos = 0;
  var buffer; // single buffer with file data
  var buffers; // list for when size is unknown

  if (size === 0) {
    buffers = [];
  } else {
    buffer = tryCreateBuffer(size, fd, isUserFd);
  }

  var bytesRead;

  if (size !== 0) {
    do {
      bytesRead = tryReadSync(fd, isUserFd, buffer, pos, size - pos);
      pos += bytesRead;
    } while (bytesRead !== 0 && pos < size);
  } else {
    do {
      // the kernel lies about many files.
      // Go ahead and try to read some bytes.
      buffer = Buffer.allocUnsafe(8192);
      bytesRead = tryReadSync(fd, isUserFd, buffer, 0, 8192);
      if (bytesRead !== 0) {
        buffers.push(buffer.slice(0, bytesRead));
      }
      pos += bytesRead;
    } while (bytesRead !== 0);
  }

  if (!isUserFd)
    fs.closeSync(fd);

  if (size === 0) {
    // data was collected into the buffers list.
    buffer = Buffer.concat(buffers, pos);
  } else if (pos < size) {
    buffer = buffer.slice(0, pos);
  }

  if (options.encoding) buffer = buffer.toString(options.encoding);
  return buffer;
}
studentzero
@studentzero
I don't get what this is. The text file only has 2 lines of tekst.
Christopher McCormack
@cmccormack
That's your output when you log buf.toString()?
if you're still using your code above, you should notice that you aren't actually reading the file at all
fs.readFileSync('/home/futurebug/nodeschool/learnyounode/io.txt')
buf = fs.readFileSync;
What do you expect buf to be here?
:point_up: April 7, 2018 9:38 AM @sjames1958gm was giving you a partial solution but the implementation was incorrect
studentzero
@studentzero
The file is
io test operations
foobar mathafuckah
I have this code
var fs = require('fs');
fs.readFileSync('/home/futurebug/nodeschool/learnyounode/io.txt');
var buf = fs.readFileSync;
console.log(buf.toString());
Moisés Man
@moigithub
so.... readFileSync method returns the content of whatever it readed
studentzero
@studentzero
I think so.
Reads into the buffer?
Christopher McCormack
@cmccormack
@studentzero hint - fs.readFileSync('/home/futurebug/nodeschool/learnyounode/io.txt'); this line does nothing
well, nothing you can use
studentzero
@studentzero
I would think it reads the file io.txt?
This is in the turorial (nodeschool)
  All synchronous (or blocking) filesystem methods in the fs module end with  
  'Sync'. To read a file, you'll need to use  
  fs.readFileSync('/path/to/file'). This method will return a Buffer object  
  containing the complete contents of the file.
Moisés Man
@moigithub
should be more like...
var buf =fs.readFileSync('/home etc etc.........')
studentzero
@studentzero
Yeah that works
Christopher McCormack
@cmccormack
@studentzero it returns a buffer object but you have to store it :)
studentzero
@studentzero
Yeah
And buf isn't really anything.
Just a variable.
Stephen James
@sjames1958gm
@studentzero Sorry that I mislead with my post
studentzero
@studentzero
No worries dude!
Christopher McCormack
@cmccormack
@studentzero in your previous (not working) code buf was a reference to the function fs.readFileSync. You could actually invoke buf by doing something like
console.log(buf('/home/futurebug/nodeschool/learnyounode/io.txt').toString())
John
@tertiaryidentifier
Hey folks. Wondering why my for loop correctly updates each element's class but does not correctly place the [users][i] associated with the currently loop/GET call
Christopher McCormack
@cmccormack
@tertiaryidentifier try replacing the var with let or instead using a clojure
Aditya
@ezioda004
@tertiaryidentifier Thats because of closure and async nature of $.getJSON() when you use for loop i is not encapsulated and thats why you get only the last element request and appened to your html
As @cmccormack said use let and also assign user = users[i]; inside $.getJSON() callback function.
John
@tertiaryidentifier
where should I replace var with let?
Christopher McCormack
@cmccormack
in your for loop initialization and anywhere you're using i in the loop basically
Aditya
@ezioda004
In for loop let i = 0 well you didnt have var in the first place
John
@tertiaryidentifier
it worked, thanks all!
Christopher McCormack
@cmccormack
glad it's working!
Ken Haduch
@khaduch
@NJM8 - I like the tic-tac-toe - smoooth operation and it looks good. They removed the requirement for the "unbeatable" option? I haven't tried it yet,other than experiment with the styling a little. I'd put the unbeatable option on the "todo" list for a later time... :)
zootechdrum
@zootechdrum
hey guys into css question here i want my image to have the button on the bottom
I would like the button to be centered on the bottom in relation to the image above
I kinda made it word but when the window resizes it goes all sort of crazt
I does not stay in place
here is the link
kerafyrm02
@kerafyrm02
hi zoo you still there?
zootechdrum
@zootechdrum
yes i am
https://codepen.io/zootechdrum/pen/PRxbMN here is where i am at now
kerafyrm02
@kerafyrm02
I just walked into room., but you're in luck. I'm a css guru.
zootechdrum
@zootechdrum
@kerafyrm02 Then . you are my best friend right now lol
kerafyrm02
@kerafyrm02
Which button are you referring to?
zootechdrum
@zootechdrum
well both really what i would like is for the image to be float left to create the nice style
But I would also like the button stay centered in relation to the image