Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 21 2018 17:11
    @MadLittleMods banned @OmarAlmaqtri
  • Jun 05 2018 23:13
    @MadLittleMods banned @LWSS
  • May 25 2018 16:50
    @MadLittleMods banned @TheRedstoneTaco
Julian Gonggrijp
@jgonggrijp
@justoverclockl Now you're passing the items.add expression as the second argument to the final then, which is almost certainly not what you want. You can try this instead:
extend(CommentPost.prototype, 'headerItems', function (items) {
  const giveMeInfo = fetch("https://ipinfo.io/json?token=mykey")
    .then((response) => response.json())
    .then((data) => {
      this.ipInfo = data;
      console.log(this.ipInfo.country)
      const flagImage = 'http://purecatamphetamine.github.io/country-flag-icons/3x2/' + data.country.toUpperCase() + '.svg';
      items.add(
        "ipinfo",
        <div className="ipinfo" id="countryCode">{this.ipInfo.country}</div>
      );
    });
});
Anurag Vohra
@anuragvohraec
Stephen James
@sjames1958gm
Interesting proposal. Running a spell check on it would be a good idea. Thinking maybe () rather than [] might be an option
Mayank Aggarwal
@Mayank0255_twitter
https://twitter.com/Mayank0255
Soon will start sharing some dev related stuff🎉
Metheny80
@Metheny80
Is there any way to manipulate dates/times (add, subtract days to dates etc.) without having to deal with timezones? I know about UTC, but it seems wrong as what I really need is the local time only without the timezone. Is that possible?
Julian Gonggrijp
@jgonggrijp
@Metheny80 Sure. If you mean you're looking for a library that can do it, consider Moment.js or one of the alternatives mentioned on its status page.
Pedro Ávila
@aviladev
@Metheny80 personally I like date-fns beacause of their functional approach.
Metheny80
@Metheny80
@jgonggrijp I know about moment.js, but the date always contains the timezone. For example, let's say I want to get the current local date without the timezone. How do I do it?
Julian Gonggrijp
@jgonggrijp
@Metheny80 what exactly do you mean by a date without a time zone? What problem are you trying to solve?
Metheny80
@Metheny80
@jgonggrijp the front end needs to load the date and display it the same, wherever in the world the page is loaded. If a person in the US chooses July 7th at 1 AM and saves it (in the DB), and another person views the page in Europe, I still want it to be displayed as July 7th at 1 AM (the location doesn't matter)
I think when loading a Date object, it always tries to figure out the local time according to the device's timezone, but I don't want that
Christopher Suchanek
@wsuchy
Can someone explain me this voodoo:
RegExp("<").test(() => "\x3c") // false
RegExp("<").test(() => "<") // true
RegExp("<").test("\x3c") // true
Julian Gonggrijp
@jgonggrijp
@Metheny80 Would just saving the datetime as an ISO string work for you? That's yyyy-mm-ddTHH:MM:SS with optional fractional seconds (and an optional time zone)
@wsuchy I can't explain the voodoo, but I don't think passing a function to RegExp.prototype.test is standard.
Metheny80
@Metheny80
@jgonggrijp it's possible. the question is what will happen when I load it into a Date object and use moment.js to do date math (e.g. subtract/add days)? Will it try to convert it to local time using the system's timezone?
Julian Gonggrijp
@jgonggrijp
@Metheny80 I think a library like Moment will give you control over that. If necessary, you can also explicitly pass the local time zone to the parser.
Metheny80
@Metheny80
@jgonggrijp that's the thing, I don't know the timezone and I don't want to deal with it. I just want an absolute time without having to deal with timezones.
1 reply
Julian Gonggrijp
@jgonggrijp
@Metheny80 You don't need to know it. Moment can tell you. https://momentjs.com/docs/#/manipulating/utc-offset/
Also, there is no such thing as "absolute time".
Metheny80
@Metheny80
@jgonggrijp when you say "i'm going to sleep at 12:00 and wake up at 15:00", do you think about what timezone you are in? See my point?
Julian Gonggrijp
@jgonggrijp
@Metheny80 I see your point. Do you understand that I have given you a technical solution?
Liam
@LiamK021
Hi
Mahedi Hassan
@mahadihassan-dev
Hi Is there anyone?
I need to discuss about something
Eric Eastwood
@MadLittleMods
@mahadihassan-dev Best to ask your question right away, don't ask to ask
Mahedi Hassan
@mahadihassan-dev
Oh I Don't have any idea about it
Is that Question Ask Forum?
mortalkombat99
@mortalkombat991_twitter
Hello, trying to automate calendar , it worked before , maybe someone know another way to pick up current date?
var today = newDate();
var date = today.getMonth()+ '/' +(today.getUTCDate() + 1) + '/' + today.getFullYear();
6 replies
Julian Gonggrijp
@jgonggrijp
I proposed Underscore utility functions for prototype-centric (as opposed to constructor-centric) programming. Would be interested in comments.
jashkenas/underscore#2947
Tunde Oretade
@tundeiness

Hello guys. I need help with a HTML structure. I have a header tag which is styled as a flexbox. It has two contents: a picture to the left and navigation links to the right. Now I want to introduce a line in the middle of the picture and the navigation link and the way I am going about it is to use flexbox order. For example:

.nav{ position: relative;
order: 0;
//other styles}
.nav::after{
   content: '';
   display: block;
    height: 1px;
    flex: 1 1 auto;
    width: 100%;
    background: #fff;
    order: -1;
}

the result should produce a line between the picture icon on the left hand side and the navigation container on the right hand side, but the line ends up in the navigation container(i.e the .nav class) instead of outside it. It's confusing how this is happening so I'd like a second pair of eyes to help solve it. Thanks.

Julian Gonggrijp
@jgonggrijp

@tundeiness Do you mean a line between the image and the links? A vertical line?

If so, why not just set a left border on the .nav?

1 reply
Oh I see, I think you mean a horizontal line.
I think ::after and ::before always go inside the matching element rather than outside it. You can attach the pseudoelement to the header element instead.
2 replies
Tunde Oretade
@tundeiness
hi guys. I need help. I have this Api that I am trying to consume: https://torre.bio/api/bios/ and I usually get this error Access to XMLHttpRequest at 'https://torre.bio/api/bios/john' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. on close investigation at the network tab I found out that any time I hit the above url I am being redirected to https://bio.torre.co/api/bios. Which seems to show that I may need a proxy server backend to handle access to this url. I have searched and nothing comes close to a solution. A stackoverflow respose "https://stackoverflow.com/questions/70114502/access-to-xmlhttprequest-at-from-origin-http-localhost4200-has-been-bloc " is a close answer but it was implemented with .Net. My app codebase is in react and I need help on setting up a proxy server to consume the API above. Thanks.
3 replies
yoshibomball1234
@yoshibomball1234
hey could I get some help with a javascript code pls?
Julian Gonggrijp
@jgonggrijp
@yoshibomball1234 https://dontasktoask.com
2 replies
Lauro
@Lauro235

Hi guys, I'm reaching to ask for a little help. I'm working through the codecademy js course and I've just done this task.

function monitorCount(rows, columns) {
  return rows * columns;
}

function costOfMonitors(rows, columns) {
  return monitorCount(rows, columns) * 200;
}

const totalCost = costOfMonitors(5, 4);

console.log(totalCost);

I want to check my understanding of how js handles the data and what the call stack status is during the evaluation. I think I have a good idea, but I'd like your feedback in case I've missed something or I'm totally wrong..

22 replies
Stephen James
@sjames1958gm
When you call sayHelloTo(‘John’), the value of coreText is ‘John’
This is the equivalent of
function sayHelloTo(coreText) { return “Hello “ + coreText }
This is essentially what prefix returns when called with “Hello “