Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 25 17:12
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • 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:13
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:58
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:15
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:23
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
  • Jun 27 2018 04:48
    @bjorno43 banned @eddiecervello
  • Jun 26 2018 20:45
    @bjorno43 banned @DesmondJameso2_twitter
  • May 23 2018 21:45
    @bjorno43 banned @CherryPlaysRoblox1
  • May 22 2018 01:28
    @bjorno43 banned @grimroot23
Victor Popescu
@VicPopescu
I would appreciate some feedback on this project, thank you
https://codepen.io/VicPopescu/full/GPrvRY
Subrata Sarker
@picklu
Nice work, @VicPopescu. I like the mobile version.
Victor Popescu
@VicPopescu
@picklu thank you!
abraham anak agung
@padunk
@VicPopescu awesome as always. One think i want to ask what is this? let lastCopied: HTMLElement = null; I never see variable like this one.
Victor Popescu
@VicPopescu
@padunk thank you! that is a typescript declaration and initialization, its the equivalent of var lastCopied = null but with the type of the variable declared as HTMLElement
abraham anak agung
@padunk
@VicPopescu ah, cool. idk that we can do TS with codepen like that. Thanks.
Victor Popescu
@VicPopescu
@padunk yes, you have typescript and babel preprocessors integrated in codepen
ArMan
@hasarmu
need help . couldn't passed the last one.. please help meh how can i improve this code
abraham anak agung
@padunk
@hasarmu there is sieve of erasthothenes to help you sum all prime numbers
Massab Dubey
@massabd
Hi! Everybody.
Brad
@bradtaniguchi
hellow
Ramesh
@rnallu
Hello
Abdulhamid
@Abdulha81005454_twitter
Hae campers
Brad
@bradtaniguchi
hello
Kate Shim
@bomshim
Hi, guys!
Nelson Mfinda
@nelsonmfinda
Hi, everyone!
Brad
@bradtaniguchi
hullo
Ramesh
@rnallu
Hi guys, I have done few challenges from freeco
freeCodeCamp. Please review and suggest any improvements .
blessedsangpi
@blessedsangpi
hi everyone, how to attach viber button from dialogflow
Aditya Dehal
@aditya2000
@rnallu you're doing good.... keep going
:)
Ramesh
@rnallu
@aditya2000 Thank you
Justin Rhodes
@justinrhodes1
Hi guys! I
Brad
@bradtaniguchi
hello
Justin Rhodes
@justinrhodes1
I published a react tooltip library on npmjs: npmjs.com/package/react-power-tooltip Would be great if you guys could have a look at it and give feedback. That would be awesome!!
Christopher McCormack
@cmccormack
@justinrhodes1 wow a lot of effort was put into those docs, nice job!
Justin Rhodes
@justinrhodes1
@cmccormack thanks a lot! :)
PTI Academy
@ptiacademy_twitter
Thanks for sharing such a great article or post on it. It is very useful for everyone. Publish some more article on it in future. Our institute PTI Academy also offer various IT courses and training for all IT students. For more info visit: https://www.ptiacademy.in/
Samuel Ludwig
@samuelludwig
Hey all, this is not technically a code review, but I wrote some notes with the objective of giving a high-level overview of the core concepts of the Phoenix framework for Elixir. I'm doing this as sort of a Feynman thing as I'm going through the Programming Phoenix >= 1.4 book, and I wanted to know if there are any concepts that I've misunderstood, misrepresent, or don't communicate well. Link: https://github.com/samuelludwig/elixir-practice/blob/master/prog_phx_gte1.4_programs/notes/chapter02.md
Victor
@abeledovictor
Hi guys! I want to ask if is there a better way to handle async code with a rest api using express+mongodb(without mongoose). I have the logic split in services/model/routes.
I'll add an example of the code for a rest endpoint just for clarity:
// service
export const getUserByUsername = username => new Promise(async function(resolve, reject) {
  const userData = await dbgetUserByUsername(username);
  const user = userModelFactory(userData);
  if(validateUser(user)) {
    resolve(user);
  } else {
    reject();
  }
});
//model
export const dbgetUserByUsername = username => getdb().collection('users').find({ username }).toArray((err, result) => (err || result));
//route
router.get('/user/:username', handleasyncreq(req => getUserByUsername(req.params.username)
  .then(result => ({ body: result }))
  .catch(result => ({ body: result, status: 400 }))
));
//handleasyncreq code
export function handleasyncreq(f) {
  async function asynchandler(req, res) {
    const { status = 200, headers = {}, body = {} } = await f(req);
    res.status(status).set(headers).json(body);
  }
  return asynchandler;
}
I don't know if I'm doing promises/async right. I feel like I have to handle the async nature of MONGODB in two different places for just one operation - get a user by username -.
Brad
@bradtaniguchi

@abeledovictor I personally feel like the code you posted it too complex for its own good. Your mixing async/await with normal promises, your own async handler function, and new Promise, even tho you have async/await code.

For such a simple case, you should be fine with just the route, service and maybe the model. I also don't believe in using .then and .catch if your using async/await. It's more important to stay consistent than to do "one-liners" for the same of one-liners.

Great code is dirt easy to read and understand. Don't be clever/shorter just for the sake of it.

Victor
@abeledovictor
great, thanks for the feedback. I get what you mean but could you please provide an example using the code i've just shared? @bradtaniguchi
Brad
@bradtaniguchi

without getting to verbose (I'm to lazy to write out all your code hehe)
I would have this:

// route
router.get('/user/:username', (req, res) => {
  try {
    const {username} = req.params;
    const user = await getUserByUsername(username);
    res.send({status: 200, body: user});
  } catch (err) {
    res.send({body: err, status: 400});
  }  
});
// getUserByUsername service
// NOTE: if your using async await, you automatically return promises from this function
export const getUserByUsername =(username) => {
  const user = userModelFactory(dbGetUserByUsername(username)); // this function is the same
  if (validateUser(user) {
    return user;
  }
  throw Error();
}

The dbGetUserByUsernamefunction is the same

@abeledovictor
I mainly threw out the async-handler, and the new Promise code. I feel like using them saves you a few lines, but were like 1 or 2 lines here or there haha
Victor
@abeledovictor
great thanks @bradtaniguchi :)
Brad
@bradtaniguchi
Just noticed my getUserByUsername needs the async in front of the (username) code, otherwise the code wont work hehe
and you will need the await next to the dbGetUserByUsername call aswell hehe
Victor
@abeledovictor
:thumbsup:
Ankit Phondani
@phondani0
https://github.com/phondani0 can anyone review my code
Abiodun Akorede
@abbey5567
I need help with the managing packages with npm,after following instructions and pasting url in to box,it does not verify,only show signs of loading
Dhairya Sharma
@dhairya0907
Implement Heap Sort with a Min Heap getting erroe
linkin-park
@linkin-park
@dhairya0907 gist please
Randy
@RandyGoldsmith
let me know what you think of my personal portfolio.. still need to add form submission .. mostly interested in everyones opinion on the design and colors of the site.. i suck at design and am working on it.
https://gracious-torvalds-39f1c5.netlify.com
dinesh
@1532j0004kg
@RandyGoldsmith Good one but Smooth scroll will be an advantage!