Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 25 2019 17:12
    @mstellaluna banned @cmal
  • Jan 08 2019 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
Ramesh
@rnallu
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! :)
Ghost
@ghost~5cada734d73408ce4fbd52db
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!
Nazar
@IsaakNazar
@RandyGoldsmith hey man, the background image is way too heavy, pls compress it, to load the page faster
menu texts are dancing while hovering over
EMILO
@EMILO9
Paradox Framework - Please review and suggest any improvements. - https://emilo9.github.io/Paradox-CSS-Framework-Alpha/Paradox_Example.html
bbbootstrap
@bbbootstrap
It worked fine for me on my website https://bbbootstrap.com
abyshukla
@abyshukla
// running tests
JSON.parse: unexpected character at line 1 column 1 of the JSON data
// tests completed
Managing Packages with Npm
Someone help me please
dinesh
@1532j0004kg
Send the code if U can
Adhetya Narayan
@Adhetya
Can someone review my project?https://codepen.io/AdiBoy/pen/ZEYyLEP
dinesh
@1532j0004kg
Test case 1 failure @Adhetya check bro
And always send the full page view 🤹
Nancy Brown
@NancyBr04661262_twitter
Take Advices From Experts Regarding Cash App Using Cash App Help
Sometimes, it becomes necessary to take advice from the professionals who will help you out by resolving the whole host of your problems. What you need to do is to visit the official website of cash app and then move to Cash App Help section at anytime from anywhere.
https://www.gonetech.net/cash-app-customer-service/
Avoiding Breaking Security With The Cash App Number?
Do you really want to add up extra security over your cash app account? Are you also looking for the help to avoid breaking security? For the reason itself, you should get the complete information along with the proper supervision from customer care experts by using Cash App Number at anytime.
https://www.gonetech.net/square-cash-app-hacked/
PTI Academy
@ptiacademy_twitter
Hello All, I want to remove my account from Gitter, because I got irrelevant traffic from this site. My website is totally based on Jaipur, Rajasthan. I have 4k plus unwanted url from this site on my website. Please tell me how can I remove that links from my website.
dinesh
@1532j0004kg
Are you using API like!? @ptiacademy_twitter
Mayurs
@Marvin9
Hey folks! Check out Bitwise Calculator, which is built in React :) If you have time, please review and feedback code.
dinesh
@1532j0004kg
But code?
Mayurs
@Marvin9
Sorry. Forgot to add the link in markdown format.
dinesh
@1532j0004kg
Unable to delete when "NaN" in input box