Get client's IP address using .NET Standard 1.4

Uncategorized
Question: I am writing a .NET Standard library to log users' IP address whenever they are trying to login to the system. I checked with .NET API Browser and I couldn't find System.Web API in .NET Standard 1.X so I can't use HttpContext to get IP. Is there anything that I can use in .NET Standard 1.X to get client's IP address? Thanks. Answer: Try this private string GetUserIP() { string ipList = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (!string.IsNullOrEmpty(ipList)) { return ipList.Split(',')[0]; } return Request.ServerVariables["REMOTE_ADDR"]; } Read more
Read More

Adding animation to CALayer when switching to fullscreen causes app to freeze for a while

swift
Question: I am having trouble with my macOS app freezing for 2-3 seconds when I switch to fullscreen. To be precise, the app's window remains the way it is until those few seconds are over and then it begins the animation to fullscreen without any further issues. The same problem occurs when leaving full screen. Now I implemented my own layoutSublayers() for a layer inside the window like so:override func layoutSublayers() { guard self.image != nil else { return } if var currentPosition = self.imageLayer.presentation()?.position { let relativeCurrentPosition = CGPoint(x: currentPosition.x / self.oldBounds.width, y: currentPosition.y / self.oldBounds.height) currentPosition = CGPoint(x: self.bounds.width * relativeCurrentPosition.x, y: self.bounds.height * relativeCurrentPosition.y) var targetPosition = (self.direction == .AtoB) ? self.positionB : self.positionB let relativeTargetPosition = CGPoint(x: targetPosition.x / self.oldBounds.width, y: targetPosition.y / self.oldBounds.height) targetPosition =…
Read More

how do I create age validation form based on MDN tutorial

javascript
Question: I am learning form validation with MDN link https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation enter image description here I am looking to make a form with the same look as on MDN. For example, given a calendar, the user would select his date of birth. Then, if the person is under 18 years old, just like MDN, a Tooltip would appear saying "You are under 18". I am requesting the same styling used on MDN, in a way that is easy for me to understand. Answer: Read more
Read More

Get DOM element which is a component in Angular

angular
Question: I read some answers already here, such as this, but my problem is slightly different. I want to get component as a DOM element so that I can add/remove some CSS classes on it. My HTML template contains component: And my class contains a reference to it: @ViewChild('sidenav') sidenav: ElementRef; But when I log this.sidenav in one of my functions, I see that it is a representation of a class of Sidenav component, not its DOM representation. Why is that happening? Answer: You can specify what you want using the read parameter:@ViewChild('sidenav', {read: ElementRef}) sidenav: ElementRef; This way you get the ElementRef and can use this.sidenav.nativeElement like mentioned by @joshrathke or (for other use cases) @ViewChild('sidenav', {read: ViewContainerRef}) sidenav: ElementRef; My answer to the question you liked to also…
Read More

How do I add my timer formula back into Google spreadsheet for column of cells?

Uncategorized
Question: We had originally gotten help from a Google developer a year or so back on how to add a timer to field when a certain cell is changed, etc. Somehow, it was deleted or defaulted, but I was lucky enough to find the equation on one of our saved discussion boards. Can someone possibly help integrate code if (sheetName == "Driver Status" && [4, 9, 14, 19, 24].indexOf(column) > -1 && row > 3) into our spread sheet again? Answer: Read more
Read More