text:
Q: push notification on iphones i unable to get push notification on apple devices with below mentioned code
function sendNotificationToiPhone($iUSERId, $strMessage, $pushType, $userWhoIsFllowing, $type, $typId)
{
    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', $_SERVER['DOCUMENT_ROOT'] . '/qa/api/ck.pem');
    // assume the private key passphase was removed.

    stream_context_set_option($ctx, 'ssl', 'demoname', 'anypsw');
    // ssl://gateway.push.apple.com:2195 //if sending it to app store build

    $fp = stream_socket_client("ssl://gateway.push.apple.com:2195", $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
    if (! empty($fp))

    {
        $arrBody['aps'] = array(
            'alert' => 'hello',
            'sound' => 'default'
        );

        // genrating payload
        $payload = json_encode($arrBody);
        echo $payload . "<br>";
        $deviceToken = "cc256a032af46d156a403ebc4a693b537b83bf14131bbb993028d1649b5128b8";
        $msg = chr(0) . pack("n", 32) . pack('H*', $deviceToken) . pack("n", strlen($payload)) . $payload;

        echo fwrite($fp, $msg);
    } else {
        echo "connection failed in iphone";
    }
    fclose($fp); // closing notification connection
}

that code gives a response-
{"aps":{"alert":"hello","sound":"default"}}
80
thanks in advance

A: Try This :
<?php

$deviceToken = '556666..................';

$passphrase = '';

$message = 'Recieved Notification';

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns.pem');

stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

// Open a connection to the APNS server
$fp = stream_socket_client(
    'ssl://gateway.push.apple.com:2195', $err,
    $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

if (!$fp)
    exit("Failed to connect: $err $errstr" . PHP_EOL);

echo 'Connected to APNS' . PHP_EOL;

// Create the payload body
$body['aps'] = array(
        'alert' => $message,
    'sound' => 'default',
    'content-available' => '1'
    );

// Encode the payload as JSON
$payload = json_encode($body);

// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
print_r($result);
if (!$result)
    echo 'Message not delivered' . PHP_EOL;
else
    echo 'Message successfully delivered' . PHP_EOL;

fclose($fp);


text:
Q: How to further filter on a query's .Include(.Where()) and have it reflected outside of the Include() I understand that my question is kind of confusing because I haven't found a better way to ask it, but I'm sure it isn't a hard problem to solve.
Here's what's happening:
I'm supposed to return a List<Place> inside a method called GetAllPlaces in the entity's repository.
Place entity:
public Guid PlaceId { get; set; }
public string Name { get; set; }
public Point Location { get; set; }
public bool IsOpen { get; set; }
public List<Event> Events { get; set; }
public List<Hour> Hours { get; set; }

Hour entity:
public Guid HourId { get; set; }
public Guid DayOfTheWeekId { get; set; }
public DayOfTheWeek DayOfTheWeek { get; set; }
public DateTime OpenHour { get; set; }
public DateTime CloseHour { get; set; }
public Guid PlaceId { get; set; }
public Place Place { get; set; }

Each Place have a List<Hour> property. I'm trying to filter on this list of hours to not return places that are closed to the caller of this method.
What I have so far is that I'm filtering to only include the Place's today's Hour in the Place's timezone:
public async Task<IReadOnlyList<Place>>
            GetAllPlacesAsync(
            double lat,
            double lon
            string userCity,
            double visibleRadius)
        {
            var geometryFactory =
            NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326);
        var userLocation = geometryFactory
            .CreatePoint(new Coordinate(lon, lat));

            var places = await context.Places
                .AsNoTracking()

                .Include(s => s.Hours
                    // here I'm filtering to get just today's Hour like explained previously
                    .Where(d => d.DayOfTheWeek.DayName
                        == TimeZoneInfo
                        .ConvertTime(DateTime.Now,
                            TimeZoneInfo
                            .FindSystemTimeZoneById(d.Place.Timezone.Name))
                            .DayOfWeek
                            .ToString()).FirstOrDefault())
                // a second .Where() would filter on the .Include()
                // or on the "places" List but not on its Hours.
                // How to further filter to do something like this:
                // if Place.Hour.Open <= timeNowInPlaceTimezone
                // && Place.Hour.Close >= timeNowInPlaceTimezone ? passToList : dontPassToList

                .Where(
            x => x.Address.City == userCity
            && x.Location.IsWithinDistance(userLocation, visibleRadius))
                .Distinct()
                .ToListAsync();

            return places;
        }

Do you know how I could filter it to only get the places where the Hour of the place is between the open and close hour of today in its timezone ?
EDIT 1
So, thanks to @TN's answers, here's the SQL I wrote:
CREATE PROCEDURE spUpdateIsOpenAndSelectForMap
@UserLat DOUBLE PRECISION,
@UserLon DOUBLE PRECISION,
@PlaceLat DOUBLE PRECISION,
@PlaceLon DOUBLE PRECISION,
@UserCity NVARCHAR(100),
@VisibleRadius DOUBLE PRECISION,
@PlaceToUserDistance DOUBLE PRECISION,
@UserLocation GEOGRAPHY,
@PlaceLocation GEOGRAPHY
AS
BEGIN

SET NOCOUNT ON;

DECLARE @SRID INT;
SET @SRID = 4326; -- in meters

-- Create geolocation for the user's location and the Place's location
-- as well as the distance between the user and the Place in order
-- to then return the places where the distance between the two
-- is smaller than the visible radius.
SET @UserLocation = geography::Point(@UserLat, @UserLon, @SRID);
SET @PlaceLocation = geography::Point(@PlaceLat, @PlaceLon, @SRID);
SET @PlaceToUserDistance = @UserLocation.STDistance(@PlaceLocation)

-- TO DO
-- create the new table PlacePinOnMap

-- Update the IsOpen property
UPDATE [P]
SET [IsOpen] = [OpenTimeCalc].[IsOpen]

-- when the user runs this stored procedure and updates the IsOpen
-- property, it returns a "new table" with the updated data
-- to be put into a DTO in the code.
OUTPUT [P].[PlaceId],
       [P].[Location],
       [P].[Latitude],
       [P].[Longitude],
       INSERTED.[P].[IsOpen],
       [M].[Name],
       [E].[EC]

FROM [Places] [P]
JOIN [Timezones] [TZ] ON [TZ].[TimezoneId] = [P].[TimezoneId]
CROSS APPLY (
    -- Get the Place's timezone's local datetime
    SELECT
        GETUTCDATE() AT TIME ZONE 'UTC' AT TIME ZONE [TZ].[Name] AS [LocalDateTime]
) [LT]
CROSS APPLY (
    -- Get the Place's timezone's local week-day name and local time
    SELECT
        DATENAME(WEEKDAY, [LT].[LocalDateTime]) AS [LocalWeekdayName],
        CAST([LT].[LocalDateTime] AS [TIME]) AS [LocalTime]
) [DT]
CROSS APPLY (
    -- Get the event count of event that are in the future
    SELECT
        COUNT(*)
        FROM [E]
        WHERE [E].[Date] >= [LT].[LocalDateTime]
) [EC]
JOIN [DaysOfTheWeek] [DOW] ON [DOW].[DayName] = [DT].[LocalWeekdayName]
JOIN [Moods] AS [M] ON [P].[MoodId] = [M].[MoodId]
-- Also wanted to get the events related to the place
JOIN [Events] AS [E] ON [P].[PlaceId] = [E].[PlaceId]
CROSS APPLY (
    -- select place where its open and closed hours are within
    -- the ones of the local time, for the day returned from the local datetime
    SELECT CASE WHEN EXISTS (
        SELECT *
        FROM [StoreHours] [SH]
        WHERE [SH].[PlaceId] = [P].[PlaceId]
        AND [SH].[DayOfTheWeekId] = [DOW].[DayOfTheWeekId]
        AND [SH].[OpenHour] <= [DT].[LocalTime]
        -- special case where closing time of '24:00' is stored as '00:00',
        -- since time does not support '24:00'
        AND [SH].[CloseHour] > [DT].[LocalTime] OR [SH].[CloseHour] = '00:00'
    ) THEN 1 ELSE 0 END AS [IsOpen]
) [OpenTimeCalc]
WHERE ([P].[IsOpen] <> [OpenTimeCalc].[IsOpen])
AND ([P].[Address].[City] = @UserCity)
AND (@PlaceToUserDistance <= @VisibleRadius);

END

A: For efficiency, it may be better to perform all of the filtering on the database  side using native SQL to convert the date/times and apply the open/close criteria. This would avoid loading the entire Place table and likely the entire StoreHours table into the C# environment with every execution.
The stored procedure would look something like:
CREATE PROCEDURE GetOpenPlaces
AS
    SELECT P.*
    FROM Place P
    JOIN Timezone TZ ON TZ.TimezoneId = P.TimezoneId
    CROSS APPLY (
        -- Intermediate local time calculations
        SELECT
            GETUTCDATE() AT TIME ZONE 'UTC' AT TIME ZONE TZ.Name AS LocalDateTime
    ) LT
    CROSS APPLY (
        -- More intermediate local time calculations
        SELECT
            DATENAME(weekday, LT.LocalDateTime) AS LocalWeekdayName,
            CAST(LT.LocalDateTime AS TIME) AS LocalTime
    ) DT
    JOIN DayOfTheWeek DOW ON DOW.DayName = DT.LocalWeekdayName
    WHERE EXISTS (
        SELECT *
        FROM StoreHour H
        WHERE H.PlaceId = P.PlaceId
        AND H.DayOfTheWeekId = DOW.DayOfTheWeekId
        AND H.OpenHour <= DT.LocalTime
        AND (H.CloseHour > DT.LocalTime OR H.CloseHour = '00:00')
    )

The above supports a special case where a closing time of '24:00' is stored as '00:00', since time does not support '24:00'
See this db<>fiddle for a demo that includes a variety of generated test data and a slightly modified version of the query above for illustration purposes.
This all assumes that your time zone names match those known to SQL Server. I believe that SQL server time zone information and .Net TimeZoneInfo are both based off if operating system registry data, this should be a valid assumption as long as updates are regularly applied.
Also, I recommend that you define an index on StoreHour(PlaceId) as a minimum, or (better) StoreHour(PlaceId, DayOfTheWeekId, OpenHour, CloseHour).

A: First just to clarify my understanding or your data: Each place has a List<Hour> collection where each Hour object has properties DayOfTheWeek, Open, and Close - similar to a line item on a store hours sign. Also, each place has an associated timezone to which the current (UTC) date/time needs to be converted before checking against the place.Hours collection.
I do not believe .Include() is what you want here, since that function is for selecting extra data to be eagerly loaded with the result rather than to filter the result.
My expectation is that you want something like .Where(place => place.Hours.Any(hour => hours-matches-local-time).
However, the hours-matches-local-time part may include complex calculations that may be unnecessarily evaluated inside the .Any() multiple times for the same place. To avoid redundant calculations, the condition in the outer .Where() can be made into a code block where the local day-of-week and local-time are calculated once per place, assigned to variables, and then referenced repeatedly inside the inner .Any().
Try something like:
var places = await context.Places
    .AsNoTracking()
    .Where(place => {
        var localDateTime = ...;
        var dayOfWeekInPlaceTimezone = ...;
        var timeNowInPlaceTimezone  = ...;
        bool isOpen = place.Hours
            .Any(hour =>
                hour.DayOfTheWeek == dayOfWeekInPlaceTimezone
                && hour.Open <= timeNowInPlaceTimezone
                && hour.Close > timeNowInPlaceTimezone
            );
        return isOpen;
    })
    //(not needed) .Distinct()
    .ToListAsync();

The above uses LINQ Method syntax. An alternative is to use the LINQ Query syntax which can also calculate local variables using the let clause. This post has answers that demonstrate some of those techniques. (Perhaps someone with more experience than I in LINQ query syntax can post a translation.)
There may be other opportunities for improvement, such as grouping places by timezone and calculating local day/time once per group. A .SelectMany() would eventually be used to process each group and flatten out the results. The result might be something like:
var places = await context.Places
    .AsNoTracking()
    .GroupBy(place => place.Timezone)
    .SelectMany(tzGroup => {
        var timezone = tzGroup.Key;
        var localDateTime = ...;
        var dayOfWeekInPlaceTimezone = ...;
        var timeNowInPlaceTimezone = ...;
        return tzGroup.Where(place =>
            place.Hours.Any(hour =>
                hour.DayOfTheWeek == dayOfWeekInPlaceTimezone
                && hour.Open <= timeNowInPlaceTimezone
                && hour.Close > timeNowInPlaceTimezone
            )
        );
    })
    //(not needed) .Distinct()
    .ToListAsync();

A: Not sure about your condition about Open/Close hours, but query should look like this:
public async Task<IReadOnlyList<Place>>  GetAllPlacesAsync()
{
    var dayOfWeek = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo .FindSystemTimeZoneById(d.Place.Timezone.Name))
        .DayOfWeek
        .ToString();

    var places = await context.Places
        .AsNoTracking()
        .Where(p => p.Hours.Any(h =>
                h.DayOfTheWeek.DayName == dayOfWeek
                && h.Open <= timeNowInPlaceTimezone
                && h.Close >= timeNowInPlaceTimezone
            )
        )
        .ToListAsync();

    return places;
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: TypeError: Cannot read properties of undefined (reading 'vin') For some reason I have variables outside of my function and I'm updating that variable in my function but when I call that variable in another function I get a undefined typeError
let bikeShare = []
let stations = []

function startRide(vin) {
  bikeShare = bikeShare.map((bike) => {
    bike.vin === vin ? { ...bike, checkOut: true } : bike
  })
  return {}
}

function endRide(vin) {
  console.log(bikeShare)
  bikeShare = bikeShare.map((bike) => {
    bike.vin === vin && bike.checkOut
      ? { ...bike, checkOut: false, totalRides: bike.totalRides + 1  }
      : bike
  })
  return {}
}

function createBike(color = 'red') {
  const vin = bikeShare.length + Date.now();
  const payload = { vin, color, checkOut: false, totalRides: 0 }

  bikeShare.push(payload);

  return payload
}

const bike_1 = createBike('red')
const bike_2 = createBike('blue')
const bike_7 = createBike('green')

startRide(bike_1.vin) // in the startRide function I get an array [undefined, undefined, undefined]
endRide(bike_1.vin)

A: You are in the startRide() function not returning the result of each assignment in the .map method, so it returns undefined which why you see the array of undefined values.
This should fix it:

let bikeShare = []
let stations = []

function startRide(vin) {
  bikeShare = bikeShare.map((bike) => {
    return bike.vin === vin ? { ...bike, checkOut: true } : bike
  })
  return {}
}

function endRide(vin) {
  console.log(bikeShare)
  bikeShare = bikeShare.map((bike) => {
    bike.vin === vin && bike.checkOut
      ? { ...bike, checkOut: false, totalRides: bike.totalRides + 1  }
      : bike
  })
  return {}
}

function createBike(color = 'red') {
  const vin = bikeShare.length + Date.now();
  const payload = { vin, color, checkOut: false, totalRides: 0 }

  bikeShare.push(payload);

  return payload
}

const bike_1 = createBike('red')
const bike_2 = createBike('blue');
const bike_7 = createBike('green');

startRide(bike_1.vin) // in the startRide function I get an array [undefined, undefined, undefined]
endRide(bike_1.vin)

A: To lift this out of comment, the body of the map argument function in startRide is enclosed in curly braces. You could remove the braces or put return bike inside the braces to stop it returning undefined.
However, setting bike.vin to a bike "payload" object with checkout set to true, leaving bike.checkout set to false, is a bug. One solution might be to use  find instead of map:

let bikeShare = []
let stations = []

function startRide(vin, start = true) {
  const bike = bikeShare.find(bike=>bike.vin === vin);
  if( bike) {
    bike.checkOut = start;
  }
  return bike; // for debugging
}

function endRide(vin) {
  return startRide( vin, false);
}

function createBike(color = 'red') {
  const vin = bikeShare.length + Date.now();
  const payload = { vin, color, checkOut: false, totalRides: 0 }
  bikeShare.push(payload);
  return payload
}

const bike_1 = createBike('red')
const bike_2 = createBike('blue')
const bike_7 = createBike('green')

console.log( startRide(bike_1.vin));
console.log( endRide(bike_1.vin));


text:
Q: working with the collection of objects in laravel Trying to work with the collection of objects.
the collection is NOT an Eloquent one but hand made Illuminate\Support\Collection
if i understood it right in the case of collection of objects i'm not able to use most of methods but only those which can use callback.
so, i have collection of objects:

and here is the code ($country = 'Russia'):
        dump($this->countries);
        $filtered = $this->countries->filter(function ($countryObj) use($country) {
            dump($countryObj->name == $country);
            return $countryObj->name == $country;
        });
        dd($filtered);

i expect the $filtered contains only one element, the one which return true (in our case Russia)
but instead of it i have the same collection of 3 elements.
here is the rest of classes to be sure they are collection related
use App\Services\Taxes\DataSourceInterface;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;

abstract class JsonModel extends Collection implements DataSourceInterface
{
    public function __construct()
    {
        parent::__construct($this->readDataFile(env('JSON_DATA_PATH')));
    }

    protected function readDataFile(string $path): array
    {
        $disk = Storage::disk('local');

        try {
            $dataObj = json_decode($disk->get($path), false, 10, JSON_THROW_ON_ERROR);
            return $this->loadData($dataObj);
        } catch (FileNotFoundException $e) {
            Log::error('Storage ' . $e->getMessage() . ' was not found');
        } catch (\JsonException $e) {
            Log::error('Json DataFile: ' . $e->getMessage());
        }

        return [];
    }

    abstract protected function loadData(object $dataObject): array;
}

class JsonCountries extends JsonModel
{
    public function loadData(object $dataObject): array
    {
        $data = array_filter($dataObject->countries, function ($item){
            unset($item->states);
            return true;
        });

        return $data;
    }
}

A: problem was in new static which used inside laravel methods which return instance of collection and in fact that i dont expect array entry in my constructor.
choice between empty array and file reading fixes the problem
abstract class JsonModel extends Collection implements DataSourceInterface
{
    public function __construct($dataArr = [])
    {
        if(!is_array($dataArr))
           $dataArr = $this->readDataFile(env('JSON_DATA_PATH'));

        parent::__construct($dataArr);
    }


text:
Q: How do I read strings from a file that already contain double quotes? I have a list of names in a .txt file which are in the format:

"Tim", "Dave", "Simon"

The input will always be single value names in quotes, comma separated and on a single line.
I want to read these into String[] names.
I have the following code, but the output puts each of them in double quotes, meaning it looks like:
""Tim"", ""Dave"", ""Simon""
I'm also not able to use any third party libs.
How do I get it so that each element in the String array only has one set of double quotes?
String[] names = {};

// arraylist to store strings
List<String> listOfStrings = new ArrayList<String>();

// load content of file based on specific delimiter
Scanner sc = new Scanner(new FileReader("names.txt")).useDelimiter(",");
String str;

while (sc.hasNext()) {
    str = sc.next();
    listOfStrings.add(str);
}

A:
I have a list of names in a .txt file which are already in a String format:

They actually aren't; that is not 'string format'; there is in fact no such thing as 'string format'.
Given that the input file contains quotes and you know those quotes aren't literally part of the input, merely delimiting the input, we can reduce the reasonable guesses as to what format this actually is. Down to just two commonly used formats, in fact:
Standard CSV format
"CSV" ("Character Separated Values") is an extremely common data interchange format. Unfortunately, there is no spec. But by far the most common 'take' on this format involves the following escaping rules:

*

*Newline separates record.

*Some specified character separates 2 items in a single record; usually a comma, a tab, or a semicolon - clearly comma in your input.

*So.. what to do if one of the items contains, literally, a comma or newline? The usual answer is to enclose the input in quotes in this case, and sometimes, a CSV output tool quote-delimits everything, even if it wasn't needed (Such as, presumably, your example). However, this then raises yet another question: What if the input contains quotes. Then, the answer is to double them up. So, the literal string: Jane said: "Well, hello there!" becomes, in example.csv:

"Jane said: ""Well, hello there!"""

There's even a standard for this: RFC 4180. It's a one-pager. Feel free to have a quick look at it.
backslash-escape CSV
An alternative, that has become more popular given that about 90% of all programming languages have string constants that work like this, is to treat the backslash symbol as an escape symbol: A backslash is always followed by a character and the pair together tell you what's actually intended based on a lookup table. The common escapes are:

*

*\n -> That's a newline

*\t -> a tab

*\" -> a literal quote

*\, -> a literal comma

and a few more (\r, \f, \b, \123, \u1234 are all somewhat common).
There's simply no way to know unless the source of this text file tells you which format it is, or by getting more complicated inputs that contain such strings. If you can control the actual literal text that is outputted, make a complicated string with newlines and commas and double quotes in the literal text, export it to this text file and see what it looks like.
So how do I parse this?
It's very complicated - code that properly parses it all is many pages long. You're in luck, though! Plenty of libraries exist.
The usual way to go is to use OpenCSV - that's a tutorial that takes you through how to use it.
I just want one string with literally Tim, Dave, Simon
Well, that's just not what your input file says; clearly then your input file is in some unknown format, and you're going to have to explain how in the blazes you get from the notion that the text file contains "Tim", "Dave", "Simon" to desiring Tim, Dave, Simon in a single string variable. Perhaps the input is indeed in CSV and you simply want each item concatenated together, separated out by a comma. In which case, use OpenCSV to read it, and then write the very simple code required to concatenate the items. OpenCSV can give you a List<String> to represent a 'line' of input - to turn that into a single comma separated string, that's easy:
String[] csvLine = opencsv.readNext();
String output = String.join(", ", csvLine);
assert output.equals("Tim, Dave, Simon");

A: Sorry. Actually this is better
add(s.replace("\"", ""));


text:
Q: Flutter: Как задать разные действие при нажатии на BottomNavigationBarItem Я создал BottomNavigationBar и мне надо чтобы при нажатии на боковые кнопки менялись страницы, а при нажатии на среднюю - появлялся диалог.
Вот код main.dart
class _MyHomePageState extends State<MyHomePage> {
  int _selectedIndex = 0;

  List<Widget> _widgetOptions = <Widget>[
    Home(),
    Add(),
    Calendar()
  ];

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _widgetOptions.elementAt(_selectedIndex),
      bottomNavigationBar: Container(
        height: 60,
        margin: EdgeInsets.only(left: 20, right: 20, bottom: 20),
        decoration: BoxDecoration(
          color: navbarColor,
          borderRadius: BorderRadius.circular(20),
          boxShadow: [
            BoxShadow(
              color: Colors.black38,
              blurRadius: 10,
              spreadRadius: 5
            )
          ]
        ),
        child:
        ClipRRect(
          borderRadius: BorderRadius.circular(20),
          child: BottomNavigationBar(
            items: [
              BottomNavigationBarItem(
                icon: ImageIcon(
                  AssetImage('assets/icons/Home.png')),
                title: Text('Home')),
              BottomNavigationBarItem(
                icon: ImageIcon(
                  AssetImage('assets/icons/Add.png')),
                title: Text('Add')),
              BottomNavigationBarItem(
                icon: ImageIcon(
                  AssetImage('assets/icons/Calendar.png')),
                title: Text('Calendar')),
            ],
            currentIndex: _selectedIndex,
            selectedItemColor: mainColor,
            unselectedItemColor: iconColor,
            onTap: _onItemTapped,
            iconSize: 27,
            showSelectedLabels: false,
            showUnselectedLabels: false,
          )
        ),
      )
    );
  }
}

В home.dart у меня находится class Home() и void _add
Вместо Add() в main.dart надо поставить _add из home.dart


text:
Q: How to make a nav-item reach the end of the page I am new to Bootstrap and web development but I am trying to reorganize the default navbar that is generated with the execution of a blank asp.net core 2.2 web application.  When this web app is generated there are nav-items that are floated to the left, but in this navbar I want to add another nav-item for log in and place it all the way to the right of the page similar to how many websites place their login links.
I have tried playing around with margins and padding in the container as well as in the navbar.  When I would change the margins for the left and right side of the container it would just shift the entire navbar in one direction either left or right.  I have also opened up and looked at the bootstrap.css in order to see how it works and trying to see if I could find useful information.  I have also tried playing around with the different nav-bar classes.
//I tried playing around with margins in my css as such
.container{
    padding-left: 0px;
    padding-right: 0px;
}

//part of my layout page

  `

            RazorPagesDemo
            <button class="navbar-toggler" type="button" data-
   toggle="collapse" data-target=".navbar-collapse" aria-
   controls="navbarSupportedContent"
                    aria-expanded="false" aria-label="Toggle navigation">

            </button>

                        Home

                        Privacy

                        Login

Here I would like to make it so that my login nav-item reaches all the way to the right corner.

A: As long as your navigation is inside .container it will be max-width: 1140px wide and centered because of margin-left: auto and margin-right: auto.
Try to use .container-fluid or remove container div so it will be full width "from left to right".

A: You could set style as position:absolute;right:0 to place it at the right of page:

            RazorPagesDemo
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                    aria-expanded="false" aria-label="Toggle navigation">

            </button>

                        Home1

                        Privacy1

                        Login


text:
Q: Sending multiple responses(res.json) with the same response object in Express.js res.json(Object.assign({}, cart.generateArray()));
res.json(JSON.stringify(cart.totalPrice));

how can i send Sending multiple responses because my code doesn't work
thank you

A: You cannot send multiple responses. You send an object that contains your array and total price:
res.json({
    items: cart.generateArray(),
    totalPrice: cart.totalPrice
});

Another option would be to make two different requests if you need two responses.


text:
Q: multidimensional irregular array to CSV in PHP First of all I know there are many threads dedicated to this topic but I didn't found/figured out the right solution for my problem, sorry if I missed something.
So I got an array that looks like this:
Array
(
[0] => id1
[1] => Array
    (
        [0] => Url1
    )

[2] => id2
[3] => no url found
[4] => id3
[5] => Array
    (
        [0] => url3.1
        [1] => url3.2
        [2] => url3.3
     )
)

and i want to build a csv looking like:
id1,url1
id2,no url found
id3,url3.1,url3.2,url3.3

tried with
foreach($array as $row){
   fputcsv($csv, $row, ',');
}

but it grabs only the elements of the subarrays if they exist. How should I approach that? Thanks in advance!

A: I would suggest creating an intermediate array from the original one, which would have the desired structure, and then create the CSV output from that:
// Preprocess the array to get the format needed for the CSV output
for ($i = 0; $i < count($array); $i += 2) {
    $result[] = is_array($array[$i+1])
        ? array_merge([$array[$i]], $array[$i+1])
        : [$array[$i], $array[$i+1]];
}

foreach($result as $row){
   fputcsv($csv, $row, ',');
}

See it run on eval.in.


text:
Q: RichTextBox KeyPressArgs not working I have a RichTextBox that I want to track key presses and do something for each of the key press, e.g.Ctrl + S for save and so on. But my RichTextBox won't log key strokes. The messageBox does not pop  up at all.
  private void rtfContent_KeyPress(Object sender, KeyPressEventArgs e)
    {
        if (e.KeyChar == 'C')
        {
            MessageBox.Show("C");
            e.Handled = true;
        }
    }

This is the code I am currently trying. The MessageBox is just there to actually see if the KeyPress was working and 'C' was just the first thing that came to mind.
Nonetheless my function does not do what it is supposed to. I have an eventhandler in my Designer
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.rtfContent_KeyPress);

A: You've subscribed the form's KeyPress event (not the RichTextBox) to rtfContent_KeyPress.
Replace this:
this.KeyPress +=
    new System.Windows.Forms.KeyPressEventHandler(this.rtfContent_KeyPress)

With this:
rtfContent.KeyPress +=
    new System.Windows.Forms.KeyPressEventHandler(this.rtfContent_KeyPress)

A: Try changing the KeyPreview = True i think, the keypresses is disable


text:
Q: Using Generics in TypeScript with LocalStorage Service - Angular 6 Trying to comeup with the service to use local storage. Little new to typescript so need help with generics part here. Don't want to use a third-party package since my requirement is very simple. I can put any data like string, number, date, boolean or my object in local storage and retrieve it as well. I want this service to handle every thing for me.
import { Injectable } from "@angular/core";

@Injectable({
  providedIn: 'root'
})

export class LocalStorageService {
  constructor() { }

  clear() {
    localStorage.clear();
  }

  removeItem(key: string) {
    localStorage.removeItem(key);
  }

  setItem<T>(key: string, data: T): boolean {
    try {
      if (typeof data === "string") {
        localStorage.setItem(key, data)
      }
      else if (typeof data === "number" || typeof data === "boolean" || typeof data === "date") {
        localStorage.setItem(key, data.toString())
      }
      else {
        //its my custom object
        localStorage.setItem(key, JSON.stringify(data));
      }
      return true;
    }
    catch (e) {
      return false;
    }
  }

  getItem<T>(key: string) : T {
    try {
      let data: object = null;
      if (typeof T === "string" || typeof T === "number" || typeof T === "boolean" || typeof T === "date") {
        data = <T>localStorage.getItem(key);
      }
      else {
        data = <T>JSON.parse(localStorage.getItem(key));
      }

      if (data && data is T) {
        return <T>data;
      }

      return null;

    } catch (e) {
      console.log('Error getting data from localStorage', e);
      return null;
    }
  }
}

In the set method, typeof data === "date" is resulting in === cannot be applied to strings, boolean, number etc. It is only on date part.
in the get method, how to check the typeof T and then return the proper T back.

A: In the get method, the type parameter T is not known at runtime, so you can't use it to decide how to decode the item.  You'll need to either (1) pass an extra parameter to getItem to control the decoding or (2) use a storage format that can be decoded in the same way for all T.  For example, you can use JSON.stringify and JSON.parse regardless of the type, but this will not preserve dates.  Or you can use a third-party library that is like JSON.stringify and JSON.parse but preserves dates.  The library I have experience with is Meteor's EJSON library; this appears to be a standalone package of the EJSON library that you can use in a non-Meteor project.


text:
Q: Open editor for XML file depending on its content in Visual Studio In my Visual Studio project I have an XML file containing an Excel workbook in Excel Spreadsheet 2003 XML format. Unfortunately the file extension is .xml.
Now I want to open this file by double-clicking it (from within Visual Studio) with Excel. But XML files are opened in the VS XML editor of course. If I change the association for XML files then XML files are also opened (or at least tried to open) by Excel, which is obviously not a good idea.
I also tried to Open with... the Automatic editor selector (XML) and the Office XML Handler but still no senseful results.
So my question is: How can I open an XML file containing the Excel Spreadsheet 2003 XML format with Excel, and any other XML file with the internal Visual Studio XML editor?


text:
Q: Python Compare datatype of a data file with metadata file I am trying to compare datatype of all the columns in a CSV file vs a metadata json file.
Metadata json file contains datatype of all the columns of the csv file.
example: if customer_name in the json file = CHAR, I want to check the datatype of customer_name flied in csv is CHAR.
I tried using pandas to identify datatype of each CSV columns and compare against json file. but sometime pandas identifies datatype differently. Example: Customer_phone field is CHAR in json file, but panda identifies it as INTEGE. So, is there any better way to do this comparision in python?
Metadata json contains information like below :
{
   "DataType": {
    "customer_name": "CHAR",
    "customer_id": "INTEGER",
    "customer_address": "CHAR",
    "customer_phone": "CHAR"
    }
}

CSV file data contains:
customer_name|customer_id|customer_address|customer_phone
abc|12345|abc street|0001234567

Here is the function I have written:
def check_datatype(df, meta_dict):
try:

    datatype_issue = False

    file_datatype = df.dtypes.to_dict()

    # create compare keys from metadata file

    compare_keys = [k for k, v in meta_dict['DataType'].items()]

        for key in compare_keys:

            if file_datatype[key] == 'int64':

                file_datatype[key] = 'integer'.upper()

            if file_datatype[key] == 'object':

                file_datatype[key] = 'char'.upper()

            if file_datatype[key] == 'float64':

                file_datatype[key] = 'decimal'.upper()

        # check if the metadata data type matches with file column datatypes

            if file_datatype[key] == meta_dict['DataType'][key].lower():

            else:

                datatype_issue = True

            if not datatype_issue:

                print(f"No datatype issue found")

        return datatype_issue

except Exception as e:

    print(e)


text:
Q: Robotframework-rabbitmq not working with newest robotframework library my requirements.txt file looks like this:
robotframework==4.0.3
robotframework-selenium2library==3.0.0
selenium==3.141.0
robotframework-excellib==2.0.1
robotframework-csvlib==1.0.2
robotframework-extendedrequestslibrary==0.5.5
robotframework-jsonlibrary==0.3.1
robotframework-jsonvalidator==2.0.0
robotframework-requests==0.9.1
robotframework-openpyxllib==0.7
robotframework-difflibrary==0.1.0
robotframework-xvfb==1.2.2
robotframework-archivelibrary==0.4.1
robotframework-databaselibrary==1.2.4
robotframework-rabbitmq==3.0.0
pymysql
urllib3==1.26.5
RESTinstance
requests==2.25.1
robotframework-pabot

When I was running pip install -r requirements.txt I get an outcome as follows:
ERROR: Cannot install -r requirements.txt (line 12), -r requirements.txt (line 13), -r requirements.txt (line 15), -r requirements.txt (line 4), -r requirements.txt (line 6), -r requirements.txt (line 7), -r requirements.txt (line 8), -r requirements.txt (line 9) and robotframework==4.0.3 because these package versions have conflicting dependencies.
The conflict is caused by:
    The user requested robotframework==4.0.3
    robotframework-excellib 2.0.1 depends on robotframework>=3.0.3
    robotframework-extendedrequestslibrary 0.5.5 depends on robotframework
    robotframework-jsonlibrary 0.3.1 depends on robotframework>=3.0
    robotframework-jsonvalidator 2.0.0 depends on robotframework>=3.0.1
    robotframework-requests 0.9.1 depends on robotframework
    robotframework-xvfb 1.2.2 depends on robotframework
    robotframework-archivelibrary 0.4.1 depends on robotframework
    robotframework-rabbitmq 3.0.0 depends on robotframework==3.0.4

I take it as a problem with last row - rabbitmq 3.0.0 is not really working with the newest version robotframework==4.0.3.
Loosing it by setting robotframework-rabbitmq without version causes neverending downloading dependencies, stucked for hours like:
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
  Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
  Downloading six-1.13.0-py2.py3-none-any.whl (10 kB)
  Downloading six-1.12.0-py2.py3-none-any.whl (10 kB)
  Downloading six-1.11.0-py2.py3-none-any.whl (10 kB)
INFO: pip is looking at multiple versions of robotframework-pythonlibcore to determine which version is compatible with other requirements. This could take a while.
Collecting robotframework-pythonlibcore>=2.1.0
  Downloading robotframework_pythonlibcore-2.2.1-py2.py3-none-any.whl (10 kB)
INFO: pip is looking at multiple versions of six to determine which version is compatible with other requirements. This could take a while.
  Downloading robotframework_pythonlibcore-2.2.0-py2.py3-none-any.whl (10 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
  Downloading robotframework_pythonlibcore-2.1.0-py2.py3-none-any.whl (10 kB)
INFO: pip is looking at multiple versions of robotframework-seleniumlibrary to determine which version is compatible with other requirements. This could take a while.
Collecting robotframework-seleniumlibrary>=3.0.0
  Downloading robotframework_seleniumlibrary-5.1.2-py2.py3-none-any.whl (94 kB)
INFO: pip is looking at multiple versions of robotframework-pythonlibcore to determine which version is compatible with other requirements. This could take a while.
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /packages/1b/a3/f712ffbad35b177af1c91e8ba58ec56a34a6dd61ce6348d779b4951482df/robotframework_seleniumlibrary-5.1.1-py2.py3-none-any.whl
  Downloading robotframework_seleniumlibrary-5.1.1-py2.py3-none-any.whl (94 kB)
...

(it's not the issue with my internet, as I checked)
Why is it not working with newest robotframework? How can I fix this issue?

A: According to this, looks like Rabbitmq library can be installed only with 3.0.4 version.
In this topic it was suggested to install rabbit first and then after it run pip install --upgrade robotframework, which worked pretty well.
So, install RF==3.0.4, install RMQ library and then upgrade FR to newest version.


text:
Q: How to host or run a legacy ASP.NET app on a Windows 2019 Server? I've been tasked with getting a 10 year old ASP.NET app running after the server it was running on failed. I'm unsure of the original environment it was on other than that is was an older version of windows server, and I would prefer to use the latest.
So far, I'm able to build the solution file from source using MsBuild.exe (output included), which creates a directory, PrecompiledWeb, which is similar to the main project directory, but with different files in bin directory.
However I'm not sure how to get a webserver to serve this. I'm familiar with modern dotnet-core apps that can be run using "dotnet run" or by publishing the app and running "dotnet Project.dll", but neither of these methods work.
If there are multiple ways of hosting this site I'd prefer the most time efficent option, this is a small site running behind a reverse proxy and doesn't need to be very feature rich.
Output of MsBuild.exe:
PS C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode> C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
Microsoft (R) Build Engine version 4.8.3761.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 8/24/2020 2:29:07 PM.
Project "C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
Project "C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.sln" (1) is building "C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj" (2) on node 1 (default targets).
C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj : warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or re
target your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be
correctly targeted for the framework you intend.
  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -v /DarkSkiesMusic -p DarkSkiesMusic\ -u -f -d PrecompiledWeb\DarkSkiesMusic\
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(59): warning CS0618: 'DevExpress.XtraCharts.DateTimeMeasurementUnit' is obsolete: 'This enum is obsolete now. Use the DateTimeMeasureUnit enum instead.' [C:\U
sers\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(59): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeGridAlignment' is obsolete: 'This property is obsolete now. Use DateTimeScaleOptions.GridAlignmen
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(60): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeMeasureUnit' is obsolete: 'This property is obsolete now. Use DateTimeScaleOptions.MeasureUnit in
stead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(63): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeOptions' is obsolete: 'This property is obsolete now. Use AxisX.Label.DateTimeOptions or AxisY.La
bel.DateTimeOptions instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(64): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeOptions' is obsolete: 'This property is obsolete now. Use AxisX.Label.DateTimeOptions or AxisY.La
bel.DateTimeOptions instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(66): warning CS0618: 'DevExpress.XtraCharts.AxisLabel.Antialiasing' is obsolete: 'This property is now obsolete. Use the EnableAntialiasing property instead.'
 [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(89): warning CS0618: 'DevExpress.XtraCharts.DateTimeMeasurementUnit' is obsolete: 'This enum is obsolete now. Use the DateTimeMeasureUnit enum instead.' [C:\U
sers\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(89): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeGridAlignment' is obsolete: 'This property is obsolete now. Use DateTimeScaleOptions.GridAlignmen
t instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(90): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeMeasureUnit' is obsolete: 'This property is obsolete now. Use DateTimeScaleOptions.MeasureUnit in
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(93): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeOptions' is obsolete: 'This property is obsolete now. Use AxisX.Label.DateTimeOptions or AxisY.La
bel.DateTimeOptions instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(94): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeOptions' is obsolete: 'This property is obsolete now. Use AxisX.Label.DateTimeOptions or AxisY.La
bel.DateTimeOptions instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(96): warning CS0618: 'DevExpress.XtraCharts.AxisLabel.Antialiasing' is obsolete: 'This property is now obsolete. Use the EnableAntialiasing property instead.'
 [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\Main.aspx.cs(17): warning CS0219: The variable 'TabX' is assigned but its value is never used [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\Main.aspx.cs(18): warning CS0219: The variable 'ShowTab' is assigned but its value is never used [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
Done Building Project "C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj" (default targets).

Build succeeded.

"C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.sln" (default target) (1) ->
"C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj" (default target) (2) ->
(Build target) ->
  C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj : warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or
retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not b
e correctly targeted for the framework you intend.
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(59): warning CS0618: 'DevExpress.XtraCharts.DateTimeMeasurementUnit' is obsolete: 'This enum is obsolete now. Use the DateTimeMeasureUnit enum instead.' [C:
\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(59): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeGridAlignment' is obsolete: 'This property is obsolete now. Use DateTimeScaleOptions.GridAlignm
ent instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(60): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeMeasureUnit' is obsolete: 'This property is obsolete now. Use DateTimeScaleOptions.MeasureUnit
instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(63): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeOptions' is obsolete: 'This property is obsolete now. Use AxisX.Label.DateTimeOptions or AxisY.
Label.DateTimeOptions instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(64): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeOptions' is obsolete: 'This property is obsolete now. Use AxisX.Label.DateTimeOptions or AxisY.
Label.DateTimeOptions instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucTrafficReport.ascx.cs(66): warning CS0618: 'DevExpress.XtraCharts.AxisLabel.Antialiasing' is obsolete: 'This property is now obsolete. Use the EnableAntialiasing property instead
.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(89): warning CS0618: 'DevExpress.XtraCharts.DateTimeMeasurementUnit' is obsolete: 'This enum is obsolete now. Use the DateTimeMeasureUnit enum instead.' [C:
\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(89): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeGridAlignment' is obsolete: 'This property is obsolete now. Use DateTimeScaleOptions.GridAlignm
ent instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(90): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeMeasureUnit' is obsolete: 'This property is obsolete now. Use DateTimeScaleOptions.MeasureUnit
instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(93): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeOptions' is obsolete: 'This property is obsolete now. Use AxisX.Label.DateTimeOptions or AxisY.
Label.DateTimeOptions instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(94): warning CS0618: 'DevExpress.XtraCharts.AxisBase.DateTimeOptions' is obsolete: 'This property is obsolete now. Use AxisX.Label.DateTimeOptions or AxisY.
Label.DateTimeOptions instead.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\UserControls\ucLoginTracking.ascx.cs(96): warning CS0618: 'DevExpress.XtraCharts.AxisLabel.Antialiasing' is obsolete: 'This property is now obsolete. Use the EnableAntialiasing property instead
.' [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\Main.aspx.cs(17): warning CS0219: The variable 'TabX' is assigned but its value is never used [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]
  c:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\darkskiesmusic\Main.aspx.cs(18): warning CS0219: The variable 'ShowTab' is assigned but its value is never used [C:\Users\Administrator\DSSMusicSourceCode\DSSMusicSourceCode\DarkSkiesMusic.metaproj]

    15 Warning(s)
    0 Error(s)

Time Elapsed 00:00:22.26

And here are the files associated with this project:
C:.
│   DarkSkiesMusic.sln
│
├───.vs
│   ├───config
│   │       applicationhost.config
│   │
│   └───DarkSkiesMusic
│       └───v15
│           │   .suo
│           │
│           └───Server
│               └───sqlite3
│                       db.lock
│                       storage.ide
│                       storage.ide-shm
│                       storage.ide-wal
│
├───darkskiesmusic
│   │   .DS_Store
│   │   AddToPlaylist.aspx
│   │   AddToPlaylist.aspx.cs
│   │   Captcha.aspx
│   │   Captcha.aspx.cs
│   │   FileParser.aspx
│   │   FileParser.aspx.cs
│   │   licenses.licx
│   │   Main.aspx
│   │   Main.aspx.cs
│   │   Main.htm
│   │   PBrowse.aspx
│   │   PBrowse.aspx.cs
│   │   Player.aspx
│   │   Player.aspx.cs
│   │   PlaylistPage.aspx
│   │   PlaylistPage.aspx.cs
│   │   PMain.aspx
│   │   PMain.aspx.cs
│   │   PressPlay.aspx
│   │   PressPlay.aspx.cs
│   │   web.config
│   │   website.publishproj
│   │
│   ├───App_Code
│   │       DataFacade.cs
│   │       DSSMusicSession.cs
│   │       EncryptionMD5.cs
│   │       Enumerations.cs
│   │       linq.dbml
│   │       linq.dbml.layout
│   │       linq.designer.cs
│   │       PrettyUI.cs
│   │       Utilities.cs
│   │       ViewClasses.cs
│   │
│   ├───Bin
│   │       App_Licenses.dll
│   │       DevExpress.Charts.v13.2.Core.dll
│   │       DevExpress.Data.v13.2.dll
│   │       DevExpress.Printing.v13.2.Core.dll
│   │       DevExpress.RichEdit.v13.2.Core.dll
│   │       DevExpress.Utils.v13.2.dll
│   │       DevExpress.Web.ASPxThemes.v13.2.dll
│   │       DevExpress.Web.v13.2.dll
│   │       DevExpress.XtraCharts.v13.2.dll
│   │       DevExpress.XtraCharts.v13.2.Web.dll
│   │       DevExpress.XtraEditors.v13.2.dll
│   │       taglib-sharp.dll
│   │
│   ├───Images
│   │   │   50transparent.png
│   │   │   Background.png
│   │   │   backgroundImage.jpg
│   │   │   backgroundImage.png
│   │   │   BorderStars.jpg
│   │   │   DarkMoonlessNightCD.jpg
│   │   │   DarkMoonlessNightCD.png
│   │   │   DarkSkiesCD.jpg
│   │   │   DarkSkiesCD.png
│   │   │   dssbluesmall.gif
│   │   │   dssNoColor.png
│   │   │   dssNoColorLarge.gif
│   │   │   edit.png
│   │   │   favicon.png
│   │   │   HeaderStars.png
│   │   │   logo.png
│   │   │   MenuSpace.png
│   │   │   music.png
│   │   │   save.png
│   │   │   SmallTab.png
│   │   │   stars.jpg
│   │   │   Tab.png
│   │   │   TowardTheInfiniteCD.png
│   │   │   uploading.gif
│   │   │   UsernameBackground.png
│   │   │   UsernameBackgroundMobile.png
│   │   │   video.png
│   │   │
│   │   ├───Layout
│   │   │       dss_logo.png
│   │   │       header.png
│   │   │       header1.png
│   │   │       header2.png
│   │   │       header3.png
│   │   │       header3alt.png
│   │   │       header4.png
│   │   │       page.jpeg
│   │   │       page.jpg
│   │   │       visitationcd.png
│   │   │
│   │   └───PrettyUI
│   │           Error.png
│   │           Information.png
│   │           Success.png
│   │           Warning.png
│   │
│   ├───JavaScript
│   │       AC_QuickTime.js
│   │       cycle.js
│   │       responsiveslides.min.js
│   │       swfobject.js
│   │
│   ├───Mediaplayer
│   │       dewplayer.swf
│   │       player.swf
│   │
│   ├───Styles
│   │       Main.css
│   │       Mobile.css
│   │       style.css
│   │
│   ├───Tools
│   │       switch.exe
│   │
│   └───UserControls
│           ucAccount.ascx
│           ucAccount.ascx.cs
│           ucAdmin.ascx
│           ucAdmin.ascx.cs
│           ucAlbums.ascx
│           ucAlbums.ascx.cs
│           ucBrowse.ascx
│           ucBrowse.ascx.cs
│           ucCompletePasswordRecovery.ascx
│           ucCompletePasswordRecovery.ascx.cs
│           ucCompleteRegistration.ascx
│           ucCompleteRegistration.ascx.cs
│           ucContactUs.ascx
│           ucContactUs.ascx.cs
│           ucEditTrack.ascx
│           ucEditTrack.ascx.cs
│           ucEditUser.ascx
│           ucEditUser.ascx.cs
│           ucListUsers.ascx
│           ucListUsers.ascx.cs
│           ucLoadPlaylist.ascx
│           ucLoadPlaylist.ascx.cs
│           ucLogin.ascx
│           ucLogin.ascx.cs
│           ucLoginTracking.ascx
│           ucLoginTracking.ascx.cs
│           ucLogout.ascx
│           ucLogout.ascx.cs
│           ucMailUs.ascx
│           ucMailUs.ascx.cs
│           ucMain.ascx
│           ucMain.ascx.cs
│           ucMyTracks.ascx
│           ucMyTracks.ascx.cs
│           ucOrder.ascx
│           ucOrder.ascx.cs
│           ucPlayer.ascx
│           ucPlayer.ascx.cs
│           ucPlaylistBrowser.ascx
│           ucPlaylistBrowser.ascx.cs
│           ucRecoverPassword.ascx
│           ucRecoverPassword.ascx.cs
│           ucRegister.ascx
│           ucRegister.ascx.cs
│           ucSearch.ascx
│           ucSearch.ascx.cs
│           ucTrafficReport.ascx
│           ucTrafficReport.ascx.cs
│           ucUpload.ascx
│           ucUpload.ascx.cs
│           ucUserRecoveries.ascx
│           ucUserRecoveries.ascx.cs
│
└───PrecompiledWeb
    └───DarkSkiesMusic
        │   .DS_Store
        │   AddToPlaylist.aspx
        │   Captcha.aspx
        │   FileParser.aspx
        │   Main.aspx
        │   Main.htm
        │   PBrowse.aspx
        │   Player.aspx
        │   PlaylistPage.aspx
        │   PMain.aspx
        │   PrecompiledApp.config
        │   PressPlay.aspx
        │   web.config
        │   website.publishproj
        │
        ├───bin
        │       App_Code.compiled
        │       App_Code.dll
        │       App_Code.pdb
        │       App_Licenses.dll
        │       App_Web_14srrqoc.dll
        │       App_Web_14srrqoc.pdb
        │       App_Web_ht5b3zjj.dll
        │       App_Web_ht5b3zjj.pdb
        │       App_Web_kpb545cd.dll
        │       App_Web_kpb545cd.pdb
        │       App_Web_pi5yimsm.dll
        │       App_Web_pi5yimsm.pdb
        │       DevExpress.Charts.v13.2.Core.dll
        │       DevExpress.Data.v13.2.dll
        │       DevExpress.Printing.v13.2.Core.dll
        │       DevExpress.RichEdit.v13.2.Core.dll
        │       DevExpress.Utils.v13.2.dll
        │       DevExpress.Web.ASPxThemes.v13.2.dll
        │       DevExpress.Web.v13.2.dll
        │       DevExpress.XtraCharts.v13.2.dll
        │       DevExpress.XtraCharts.v13.2.Web.dll
        │       DevExpress.XtraEditors.v13.2.dll
        │       taglib-sharp.dll
        │
        ├───Images
        │   │   50transparent.png
        │   │   Background.png
        │   │   backgroundImage.jpg
        │   │   backgroundImage.png
        │   │   BorderStars.jpg
        │   │   DarkMoonlessNightCD.jpg
        │   │   DarkMoonlessNightCD.png
        │   │   DarkSkiesCD.jpg
        │   │   DarkSkiesCD.png
        │   │   dssbluesmall.gif
        │   │   dssNoColor.png
        │   │   dssNoColorLarge.gif
        │   │   edit.png
        │   │   favicon.png
        │   │   HeaderStars.png
        │   │   logo.png
        │   │   MenuSpace.png
        │   │   music.png
        │   │   save.png
        │   │   SmallTab.png
        │   │   stars.jpg
        │   │   Tab.png
        │   │   TowardTheInfiniteCD.png
        │   │   uploading.gif
        │   │   UsernameBackground.png
        │   │   UsernameBackgroundMobile.png
        │   │   video.png
        │   │
        │   ├───Layout
        │   │       dss_logo.png
        │   │       header.png
        │   │       header1.png
        │   │       header2.png
        │   │       header3.png
        │   │       header3alt.png
        │   │       header4.png
        │   │       page.jpeg
        │   │       page.jpg
        │   │       visitationcd.png
        │   │
        │   └───PrettyUI
        │           Error.png
        │           Information.png
        │           Success.png
        │           Warning.png
        │
        ├───JavaScript
        │       AC_QuickTime.js
        │       cycle.js
        │       responsiveslides.min.js
        │       swfobject.js
        │
        ├───Mediaplayer
        │       dewplayer.swf
        │       player.swf
        │
        ├───Styles
        │       Main.css
        │       Mobile.css
        │       style.css
        │
        ├───Tools
        │       switch.exe
        │
        └───UserControls
                ucAccount.ascx
                ucAdmin.ascx
                ucAlbums.ascx
                ucBrowse.ascx
                ucCompletePasswordRecovery.ascx
                ucCompleteRegistration.ascx
                ucContactUs.ascx
                ucEditTrack.ascx
                ucEditUser.ascx
                ucListUsers.ascx
                ucLoadPlaylist.ascx
                ucLogin.ascx
                ucLoginTracking.ascx
                ucLogout.ascx
                ucMailUs.ascx
                ucMain.ascx
                ucMyTracks.ascx
                ucOrder.ascx
                ucPlayer.ascx
                ucPlaylistBrowser.ascx
                ucRecoverPassword.ascx
                ucRegister.ascx
                ucSearch.ascx
                ucTrafficReport.ascx
                ucUpload.ascx
                ucUserRecoveries.ascx


text:
Q: Posting a string on my wall from iOS App? I'm new to Facebook development. Can someone guide me
on how can I post on my wall from an iOS app?

A: You can do this by integrating the Facebook SDK in your app.
Get started here:
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/
Here's a specific example:
http://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/


text:
Q: tooltip shows out of td element for anchor tag I got a requirement to show click percentage for each link available in HTML
template which is got from DB dynamically. I had tried to display click
percentage for each anchor link adding them to data-title using jQuery but
the issue is when I hover the link tooltip was displaying at out range. Can
someone helpme out to show tooltip only when I hover nearthe anchor
link? or please give me a better solution..
I have attached all sample code in below fiddler link  Please find the sample fiddle and code.
JSFiddle

$(document).ready(function() {
   var anchors = [];
   $(this).find("a").each(function() {
     anchors.push($(this));
   });

   for (i = 0; i < anchors.length; i++) {
     var _ele = '100%'
     $(anchors[i]).attr('data-title', _ele);
   }
});
a {
  color: #900;
  text-decoration: none;
}
a:hover {
  color: red;
  position: relative;
}
a[data-title]:hover:before {
  width: 55px;
  content: attr(data-title);
  padding: 4px 8px;
  color: #333;
  position: absolute;
  left: 0;
  top: 100%;
  white-space: nowrap;
  z-index: 20px;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0px 0px 4px #222;
  -webkit-box-shadow: 0px 0px 4px #222;
  box-shadow: 0px 0px 4px #222;
  background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -webkit-gradient(linear, left top, left bottom, color- stop(0, #eeeeee), color-stop(1, #cccccc));
  background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
  background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
}

                                    Car A

                                    Car B

                                   Car B

                                    7 Series

A: Set it to :after to make sure it's z-index is always greater than it's parent.
use absolute positioning inside a relative parent to control position
https://jsfiddle.net/Panomosh/6ywncLh3/3/


text:
Q: how to make a square wave 1kHz circuit i want to make a 5V oscillator that has a frequency of 1khz. it will basically go to 5V (HIGH) and then 0 V (low) in a frequency of 1khz with 50% duty cycle.

A: If you check out this tutorial on 555 timers, the circuit showing in the "basic Astable 555 Oscillator Circuit" section will likely do what you need.  The resistors R1 and R2 and the capacitor C1 control your frequency and duty cycle.  It can be made a bit more versatile with a few diodes but for a 50% duty cycle, just make sure the resistance of R1 is vastly smaller than R2.  If you buy a newer/low power 555 chip you can use smaller capacitors, larger resistors, and waste less power.  I like TS555IN personally although I've only tried 4 or 5 ranging from old RadioShack ones to those.  That said if you need a lot of current you may wish to use a different 555 or have the 555  timer drive a transistor or mosfet.  To choose the resistor and capacitor values for the circuit, they give you formulas:
Time on = 0.693(R1+R2)*C
and
Time off = 0.693*R2*C
So if you make R1 tiny compared to R2, say 1/1000th or 1/10000th, you can just neglect R1 in the equations, giving you a 50% duty cycle and a period(T) of
T = Time on + Time off = 2*0.693*R2*C = 1.386*R2*C
Your frequency is 1000Hz, so
F = 1/T means T = 1/F
1.386*R2*C = 1/1000 = 0.001
R2*C = 7.215 e-4
So if you pick a capacitor, you can calculate the resistance you need to get 1000hz or vice versa.
For a ts555IN, I'd use a 100pF(1e-10) ceramic capacitor and 7 megOhms resistance.  With a variable capacitor and or trimmer resistor you'll be able to tune the frequency.  If you need your frequency to be stable it would be wise to make sure the 5V into the 555 timer is stable.

A: I agree with @KH with all the math, but for practical values use a CMOS TLC555 if possible, but with these low resistor values an NE555 should work the same.
I used my LabVIEW program for the TLC555 and it came up with 826.947 ohms for R1 and 6.800 K for R2, and a 100 nF capacitor, to give you 1000.000230 KHZ with a 1.1% duty cycle error. The program can take it to absurd accuracy but temperature and Vcc drift make that not worth it. It can be set as accurate as a xtal oscillator, but it will drift much more than a xtal.
Fixed resistor values should be 0.1% if possible as a tiny change affects both frequency and duty cycle. Use NPO or (worst-case) X7R capacitors and 50 ppm resistors to minimize drift with temperature.
As it is R1 was 680 ohm with 146.947 ohms added to fine-trim the frequency. If you need it accurate then just add a 500 ohm trim pot in series with R1. Bourns 3299W series 25 turn trim pots are great for fine trim.
If the duty cycle MUST be 50% then use 610 ohm for R1 and 3.3 K 0.1% for R2 which will double the frequency, then use a 74HC74 or 74HCT74 flip-flop to divide by 2 and you will get a perfect 50% duty cycle.

A: for those that want a crystal circuit
you could perhaps use a CD4060 to run a 32.000 KHz crystal, and divide it down to down to 1Khz
A 4.096MHz crystal is cheaper, and the CD4060 has enough divider stages, but I'm not sure that the oscillator in a CD4060 is up-to the task of running such a fast crystal.


text:
Q: Alternative to Dictionary Getting an error: on line  CurrentFilters.Add($"Colors", Colors[i].ToString());
An unhandled exception occurred while processing the request.
ArgumentException: An item with the same key has already been added. Key: Colors

Issue: If Dictionary can't have same key than what are my alternatives? I found few on Google like putting into a List but they don't work with asp-all-route-data.
Also since, it is auto Bind; this mean I can't do something like CurrentFilters.Add($"Colors[i]", Colors[i].ToString()); this will work but it wont bind bc name "Colors[1]" is not same as "Colors".
If you click on  tag than it will send URL format: localhost234/Index?SearchString=text%Colors=red&Colors=blue&SortOrder=Colors_asc
back-end code
[BindProperty(SupportsGet = true)]
public Dictionary<string, string> CurrentFilters { get; set; }

[BindProperty(SupportsGet = true)]
public List<string>? Colors { get; set; } //list of colors user selects
public SelectList? Colors_SELECT { get; set; } //fill dropdownlist with colors values

 public async Task OnGetAsync()
 {
     Colors_SELECT = getColors(); //fill dropdown with all colors

     //this fill get back into asp-all-route-data
     CurrentFilters.Clear();
     CurrentFilters.Add("SearchString", SearchString);
     for (int i = 0; i < Colors.Count; i++)
     {
          // ISSUE is here
          CurrentFilters.Add($"Colors", Colors[i]);
     }
  }

Front-End - form has many different filters for my grid-table
<form asp-page="./index" method="get">
     <input type="text" asp-for="SearchString" class="form-control" placeholder="Search..." />
     <select asp-for="Colors" asp-items="@Model.Colors_SELECT" class="MultiSelect" multiple>...</select>
      ...
</form>

grid-table - display data from database. Header links are for filtering and sorting. asp-all-route-data has different filters inside that get pass to URL

  ...  // header hyper link

              @Html.DisplayNameFor(model => model.MyList[0].Colors)

...

Update: I tried using list inside Dictionary but it gives an error.
[BindProperty(SupportsGet = true)]
public Dictionary<string, List<string>> CurrentFilters { get; set; }

Error:
Error: 'System.Collections.Generic.Dictionary<string,
 System.Collections.Generic.List<string>>' to
'System.Collections.Generic.IDictionary<string, string>'.
 An explicit conversion exists (are you missing a cast?)

A: Try using
[BindProperty(SupportsGet = true)]
public Dictionary<string, List<string>> CurrentFilters { get; set; }

instead of  public Dictionary<string, string> CurrentFilters { get; set; }
To handle this in your OnGetAsync handler do something like this:
public async Task OnGetAsync()
{
    CurrentFilters.Clear();
    CurrentFilters.Add("SearchString", new List<string>());
    CurrentFilters["SearchString"].Add(SearchString);

    CurrentFilters.Add($"Colors", new List<string>());
    for (int i = 0; i < Colors.Count; i++)
    {
        CurrentFilters[$"Colors"].Add(Colors[i].ToString());
    }
}


text:
Q: how to get output in terminal when debugging a c++ file? I am learning debugging C++ file from Udemy .I want to debug a code but I was getting output in external console , so I set external terminal to false . Now I am not getting any output while debugging neither in terminal nor in output option . Please help me I am new to debugging
C++ Code
#include<iostream>
using namespace std;
int main(){
    int num{100};
    cout<<"Hello from Project 2 "<<endl;
    cout<<"Enter a Number : ";
    cin>>num;
    cout<<"The number you entered : "<<num;
    return 0;

}

Launch.json
{
// Use IntelliSense to learn
    // about possible attributes.
    // Hover to view descriptions
    // of existing attributes.
    // For more information, visit:
    // https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "C:\\Users\\mahir\\OneDrive\\Documents\\C++ debugging Udemy\\project2\\main2.exe",
              // There I have got error Property keys must be doublequotedjsonc
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname} ",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}


text:
Q: SQL Server : LAG multiple Nulls I am trying to "fill in the blanks" with my table below.
I have created a PDF reader that spits out a JSON file that I have manipulated into the below format.
There is very little scope in changing source data, or using a secondary table as a helper, due to the fact that this is meant to handle new data not "seen" before.
What I need help with is getting the Class and Group columns filled in. By this I mean that the Class Column will always have a value in the last row, and I need this repeated (upwards) until it comes across a non-blank value in the column. It then needs to repeat this value, until it comes across the next non-blank and so on.
Similarly the Group Column needs the same solution but starting from the first row down.
I have tried LAG() LEAD() etc with default values, but it doesn't handle the multiple nulls.
I also need the Group column to show the class value when not blank.
I have had a look at cte's but not overly familiar with them and have gotten myself tied in knots today!
Any help is appreciated.
Current Data
ID, Class, Group, Total, Account
1, null, INCOME, null, Fencing
2, null, null, null, Crop
3, Net Income, null, null, Net Income
4, null, Farm Expenditure, null, Irrigation
5, null, null, null, electricity
6, Surplus, null, null, Surplus
7, null, GST, null, GST
8, Closing Balance, null, null, Closing Balance

What I want
ID, Class, Group, Total, Account
1, Net Income, INCOME, null, Fencing
2, Net Income, INCOME, null, Crop
3, Net Income, INCOME, null, Net Income
4, Surplus, Farm Expenditure, null, Irrigation
5, Surplus, Farm Expenditure, null, electricity
6, Surplus, Farm Expenditure, null, Surplus
7, Closing Balance, GST, null, GST
8, Closing Balance, GST, null, Closing Balance

A: This gives you the output you want with the data you give. In your sample data there is only one "group" in each "class", but it looks like there could maybe be multiple groups per class? If that is the case, it will be a bit more complicated, but the principal will be the same.
CREATE TABLE #data (ID INT, Class VARCHAR(50), [Group] VARCHAR(50), Total INT, Account VARCHAR(50));
INSERT INTO #data(ID, Class, [Group], Total, Account) VALUES
(1, null, 'INCOME', null, 'Fencing'),
(2, null, null, null, 'Crop'),
(3, 'Net Income', null, null, 'Net Income'),
(4, null, 'Farm Expenditure', null, 'Irrigation'),
(5, null, null, null, 'electricity'),
(6, 'Surplus', null, null, 'Surplus'),
(7, null, 'GST', null, 'GST'),
(8, 'Closing Balance', null, null, 'Closing Balance');

-- Find the break points that signify the end of a Class
WITH breaks as(
    SELECT IIF(Class IS NOT NULL, 1, 0) AS breakpoint, ID, Class, [Group], Total, Account
    FROM #data
),
-- count the breakpoints passed so each group will have a number we can group by
grp AS (
SELECT ISNULL(SUM(breakpoint) OVER (ORDER BY ID ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING),0) AS grp,
    ID,Class,[Group],Total,Account
FROM breaks
)
SELECT MAX(grp.Class) OVER (PARTITION BY grp.grp) AS Class,
    MAX(grp.[Group]) OVER (PARTITION BY grp.grp) AS [Group],
    grp.Total,
    grp.Account
FROM grp

A: Thanks To James, I have now tweaked his code to give the correct Group, as the class and group needed different logic.
-- Find the break points that signify the end of a Class
WITH classbreaks as(
    SELECT IIF(Class IS NOT NULL, 1, 0) AS breakpoint, ID, Class, [Group], Total, Account
    FROM [PedGroup_db].[dbo].[Cashflow]
),

-- Find the break points that signify the end of a Group
grpbreaks as(
    SELECT IIF([Group] IS NOT NULL, 1, 0) AS breakpoint, ID, Class, [Group], Total, Account
    FROM [PedGroup_db].[dbo].[Cashflow]
),

-- count the breakpoints passed so each class will have a number we can group by
clss AS (
SELECT ISNULL(SUM(breakpoint) OVER (ORDER BY ID ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING),0) AS grp,
    ID,Class,[Group],Total,Account
FROM classbreaks

),

-- count the breakpoints passed so each group will have a number we can group by
grp AS (
SELECT ISNULL(SUM(breakpoint) OVER (ORDER BY ID),0) AS grp,
    ID,Class,[Group],Total,Account
FROM grpbreaks

)

--join the two sub queries together on ID
SELECT MAX(clss.Class) OVER (PARTITION BY clss.grp) AS Class,
    case when clss.Class = grp.Account Then grp.Account else MAX(grp.[Group]) OVER (PARTITION BY grp.grp) end AS [Group],
    grp.Total,
    grp.Account
FROM clss left join grp on grp.ID = clss.ID


text:
Q: How to make a rule when a date is higher than a specific date in Google Data Studio? I'm searching for a formula to have a value of a variable xxxxx only when the date is higher than '2020-07-17'.
I have tried many options, but none work so far.
case when Date>20200717 then xxxxx
end

case when Date>'2020-07-17' then xxxxx
end

I also tried formulas with REGEXP_MATCH
case when REGEXP_MATCH(Date, '2017-07-1[0-9]') then xxxxx
end

My Date is a "Date (YYYYMMDD)"

A: 0) Summary

*

*Use EITHER #1: New Recommended approach as per the 17 Sep 2020 Date and Time Update;

*OR #2: The original suggestion, prior to the 17 Sep 2020 Date and Time Update.

1) Recommended Suggestion (Using the 17 Sep 2020 Date and Time Update fields)
The single Calculated Field below creates a Text Date field using FORMAT_DATETIME function, then the CAST function to ensure that the Type is set to Number, after which values matching 20200717 (17 Jul 2020) display values of the ifr_ds_PV field while other values (not matching 20200717) are treated as NULL:
CASE
  WHEN CAST(FORMAT_DATETIME("%Y%m%d", Date) AS NUMBER ) > 20200717 THEN ifr_ds_PV
  ELSE NULL
END

Added a New Page to the Editable Google Data Studio Report and a GIF to demonstrate:

2) Original Suggestion (Using the pre 17 Sep 2020 Date and Time Update fields)
2.1) dateNumber
It can be achieved by first creating a Date Number field at the Data Source; create the Calculated Field below and ensure that the Type is set to Numeric > Number:
CAST(Date AS NUMBER)

GIF to visualise the process:

2.2) Calculated Field(s)
The Calculated Fields can then be adapted by using the newly created Date# field (which follows the YYYYMMDD format), for example:
CASE
  WHEN dateNumber > 20200717 THEN ifr_ds_PV
  ELSE NULL
END

Google Data Studio Report and a GIF to elaborate:

A: Create a calculated field _Date as:

CAST(FORMAT_DATETIME("%Y%m%d", Date) AS NUMBER )

and make sure it can be used as a metric.
Then use that to build the CASE statement, lie this:
CASE
  WHEN LAST(_Date) > 20200717 THEN xxx
  ELSE yyyy
END


text:
Q: Bitmap threshold quicker I am trying to write a method that will take a Bitmap and force it to a strict black and white image (no shades of grey).
I first pass the bitmap to a method that makes it greyscale using colormatrix:
public Bitmap toGrayscale(Bitmap bmpOriginal)
{
    int width, height;
    height = bmpOriginal.getHeight();
    width = bmpOriginal.getWidth();

    Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
    Canvas c = new Canvas(bmpGrayscale);
    Paint paint = new Paint();
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0);

    ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
    paint.setColorFilter(f);

    c.drawBitmap(bmpOriginal, 0, 0, paint);
    return bmpGrayscale;
}

that works nice and fast..
then i pass it to another method to force the greyscaled image to a 2 color image (black and white)  this method works but obviously it is going through each pixel and that takes a long time:
public Bitmap toStrictBlackWhite(Bitmap bmp){
        Bitmap imageOut = bmp;
        int tempColorRed;
        for(int y=0; y<bmp.getHeight(); y++){
            for(int x=0; x<bmp.getWidth(); x++){
                tempColorRed = Color.red(imageOut.getPixel(x,y));
                Log.v(TAG, "COLOR: "+tempColorRed);

                if(imageOut.getPixel(x,y) < 127){
                    imageOut.setPixel(x, y, 0xffffff);
                }
                else{
                    imageOut.setPixel(x, y, 0x000000);
                }
            }
        }
        return imageOut;
    }

anyone know a faster more efficient way to do this?

A: Don't use getPixel() and setPixel().
Use getPixels() which will return a multidimensional array of all pixels. Do your operations locally on this array, then use setPixels() to set back the modified array. This will be significantly faster.

A: Have you tried something like converting it into a byte array (see the answer here)?
And, as I look into this, the Android reference for developers about Bitmap processing might help you as well.


text:
Q: ActionScript Read Sprite's Graphics? how can i retrieve the set graphics properties of a sprite?  for example, in the code below, i'd like to get the color of the sprite, also it's rounded corners setting and other graphics attributes.
var sp:Sprite = new Sprite();
sp.graphics.beginFill(0xFF0000, 0.75);
sp.graphics.drawRoundRect(0, 0, 300, 50, 10, 10);
sp.graphics.endFill();

addChild(sp);
trace(sp.graphics.color);  //pseudo trace - this doesn't work

A: I am almost certain this is not possible.  However, there are certainly other ways to do this.  What about having a valueObject for each property that stores the values used.  Then you could have a GraphicalDisplayObject that you either inherit from or use via composition.  For instance:
package {
    class FillVO extends Object {
        public var fill_color:Number = 0xFF0000;
        public var fill_opacity:Number = 0.75;
    }
}

package {
    import FillVO;
    class GraphicalDisplayObject extends Sprite {
        public var fill_vo:FillVO;
        public function beginFill($vo:FillVO) {
            graphics.beginFill($vo.fill_color, $vo.fill_opacity);
        }
        ...
    }
}

package {
    import GraphicalDisplayObject;
    class ObjectWithGraphicalProperties extends Sprite {
        public var gfx:GraphicalDisplayObject;
        public function ObjectWithGraphicalProperties() {
            gfx = new GraphicalDisplayObject();
            addChild(gfx);
        }
        public function beginFill($color:Number, $opactity:Number) {
            var fill_vo:FillVO = new FillVO();
            fill_vo.fill_color = $color;
            fill_vo.fill_opacity = $opacity;
            gfx.beginFill(fill_vo);
        }
        ...
    }
}

Then to use it...
var obj:ObjectWithGraphicalProperties = new ObjectWithGraphicalProperties();
addChild(obj);
obj.beginFill(0xffff00, .2);
...
...
trace(obj.gfx.fill_vo.fill_color);

This is obviously via composition, and you would need to write the additional proxied methods and corresponding valueObjects... but it should work.


text:
Q: MySQL Display Multiple Rows I have somewhat of a problem, using the following code:
$getTS = mysql_query("SELECT * FROM book WHERE chapter='$url' && verse='$verse'");

When I use
mysql_num_rows($getTS)

it returns 2, 3, etc (which is perfect), however, when I am printing it out I only one get row using the following code:
$rowTS = mysql_fetch_array($getTS);
$summary = $rowTS['text'];
echo $summary;

Any help would be greatly appreciated.

A: You have to do this in a loop
while($rowTS = mysql_fetch_array($getTS)) {
   $summary = $rowTS['text'];
   echo $summary;
}

A: You need iterate loop when you are using mysql_fetch_array()
From documentation

Returns an array that corresponds to the fetched row and moves the
  internal data pointer ahead.

$getTS = mysql_query("SELECT * FROM book WHERE chapter='$url' && verse='$verse'");

while ($row = mysql_fetch_array($getTS , MYSQL_NUM)) {
       $summary = $row['text'];
       echo $summary;
}

A: You can do that by using a so called iterator. The old mysql_* functions do not provide it, but it can be easily written (or re-used, see this earlier answer: PHP file cannot enter some part of code):
$getTS = mysql_query("SELECT * FROM book WHERE chapter='$url' && verse='$verse'");
$rows  = new MySqlResult($getTS);
foreach ($rows as $row)
{
    $summary = $row['text'];
    echo $summary;
}

You can further improve it by using a database object directly, e.g. for the query:
$db    = new MySql();
...
$rows  = $db->query("SELECT * FROM book WHERE chapter='$url' && verse='$verse'");
foreach ($rows as $row)
{
    $summary = $row['text'];
    echo $summary;
}

The next step then would be probably that you use PDO because mysql_* is deprecated and PDO comes with such kind of a functionality out of the box.


text:
Q: How do I get the absolute difference between two datetime.time Pandas columns? Say I have this dataframe:
import pandas as pd
import datetime

x = [datetime.time(23,0),datetime.time(6,0),datetime.time(18,0),datetime.time(17,0)]
y = [datetime.time(22,0),datetime.time(9,0),datetime.time(9,0),datetime.time(23,0)]

df = pd.DataFrame({'time1':x,'time2':y})

which looks like this:

How would I compute the absolute difference between the two columns? Subtraction doesn't work. The result should look like this:
df['abs_diff'] = [1,3,9,6]

Thanks so much!

A: Pandas doesn't like datetime objects so very much; it labels the series as object dtype, so you can't really do any arithmetics on those. You can convert the data to Pandas' timedelta:
df['abs_diff'] = (pd.to_timedelta(df['time1'].astype(str))   # convert to timedelta
   .sub(pd.to_timedelta(df['time2'].astype(str)))            # then you can subtract
   .abs().div(pd.Timedelta('1H'))                            # and absolute value, and divide
)

Output:
      time1     time2  abs_diff
0  23:00:00  22:00:00       1.0
1  06:00:00  09:00:00       3.0
2  18:00:00  09:00:00       9.0
3  17:00:00  23:00:00       6.0


text:
Q: Flex: Where is the default skin class located/specified (for components like ComboBox) For example the spark ComboBox.

*

*Where is the default skin?

*Is it generated (at compile or runtime)?

*If it was in fact written by someone how does the compiler/Virtual Machine know where to find the skin class?  I didn't see a location specified in the ComboBox source.

Thanks!
Edit: Sorry originally meant to say skin by typed style instead

A: Spark components use mostly skins. The default skin is defined in the defaults.css file which gets compiled into the spark.swc. The CSS for ComboBox looks like this:
ComboBox
{
/*  dropShadowVisible: true; in spark.css */
    paddingBottom: 3;
    paddingLeft: 3;
    paddingRight: 3;
    paddingTop: 5;
    skinClass: ClassReference("spark.skins.spark.ComboBoxSkin");
}

So, the class spark.skins.spark.ComboBoxSkin is defined as default skin for ComboBox. You can find the complete file in your Flex SDK (frameworks/projects/spark/defaults.css).
If you want to find out more about this take a look at the following topics on Adobe Flex Help:

*

*About Spark
skins

*Applying styles from a defaults.css file


text:
Q: Excel Filter(Filter()) Function. Filtering an array by columns and by rows based on dropdown selection I have a table consisting of multiple rows and 7 columns. Many of the cells are empty.
I would like to create a summary table from that table, in which I filter for 2 columns using the Filter() function. Then the third column is filtered from a dropdown menu. I manage to get that using:
FILTER(Table1;((Table1[#Headers]="Checklist Item 1")+(Table1[#Headers]="Responsible")+(Table1[#Headers]=Q6)))

where Q6 is my column dropdown.
Now the summary table is a dynamic array, all nice and good, but it contains all the blanks.
Now I would like to remove all the blanks. I manage to do that, if I nest the Filter function in another Filter function, that filters for rows, like this:
=FILTER(
(FILTER(Table1;((Table1[#Headers]="Checklist Item 1")+(Table1[#Headers]="Responsible")+(Table1[#Headers]=Q6))));
Table1[S]<>"")

But I hard-coded the last filter part here where I filter for Table1[S]<>"". Instead of hard coding that one, I would like pick the column to filter from from a drop down in cell Q6. Something like Table1["column chosen in Q6"]<>"" but I cant get the syntax right.
Any ideas? I've been hard stuck for quite a while. Thank you.
Example image in below link
(note, my Excel uses semicolon instead of comma for argument separation)
See Example Image


text:
Q: How to choose specific versions of packages to download using conda? I am trying to install a specific package version and not quite sure how to access a specific version. When I type conda install SomePackage it just downloads the latest default. How can I choose specific versions?
Currently I want this package GDAL 2.2.4 I see it listed here:
https://anaconda.org/conda-forge/gdal/files
But how do I use the conda prompt to download that specific version?
Thanks

A: According to Anaconda documentation you should do:
conda install package=version ,like:
conda install scipy=0.15.0

Check the documentation case you have mode doubt: https://conda.io/docs/user-guide/tasks/manage-pkgs.html
Or maybe the problem is the version of the package.

A: It's the same if you are building using using an environment.yml file. This environment.yml downloads the java 1.8 conda package, and the pip pyspark package.
  name: my-conda-env
  channels:
      - defaults
  dependencies:
      - python=3.6
      - pip
      - ipython
      - jupyter
      - openjdk=8.0.152
    - pip:
      - pyspark

Please note this configuration (conda java + pip pyspark) is useful if you're building and deploying a pypi packages (instead of conda environments) to prebuilt docker containers set up for spark already.


text:
Q: When trying to add a Custom app to a SharePoint 2013 on-premise I get the error "You need Office Development tools to create a site" I am trying to get a SharePoint 2013 application WebPart working compiled with Visual Studio 2019. First, I have added the custom app to the SharePoint catalog but under the header "Valid App Package" column the value is No. Second when I create a Farm Collection and try to Build an app I get the error message "You need Office Development tools to create a site". I have looked for the download but can't find one. Has anyone experienced this same issue?

A: Make sure you installed the tool for SharePoint development.


text:
Q: How to use search filter in Angular for nested JSON object? I am bringing data from my mongoose to display on my HTML table. I am able to filter a JSON object normally but unable to filter nested JSON object?
I have used "npm i ng2-search-filter --save " to import filter pipe, but this only works for the first level. Doesn't do filter for the nested JSON object.
My JSON object is:
{
    packageName:test,
    packagePrice:200,
    userid:{
        userName:John,
        userAge: 27
    }
}

     <input type="text" class="form-control" [(ngModel)]="searchtext"
     placeholder="Search">

          Package Name
          Package Price
          Customer Name
          Customer Age

           {{use.packageName}}
          {{use.packagePrice}}
          {{use.userid.userName}}
          {{use.userid.userAge}}

When I enter packageName and packagPrice in a textbox for search filter it filters out and shows me correct result, but on userName and userAge its not working.
Please help.
Thank you.

A: I solved this with by just installing the latest version ng2 search filter.
Run below command:

npm i ng2-search-filter@0.5.1

A: You can use custom search pipe for this
I have create demo on Stackblitz
searchPipe.ts
transform(value: any, searchText?: any): any {
    if(!value) return [];
    if(!searchText) return value;
    searchText = searchText.toLowerCase();
    return value.filter( it => {
      return it.packageName.toLowerCase().includes(searchText) || it.packagePrice.toString().includes(searchText) || (it.userid &&  it.userid.userAge.toString().includes(searchText) || it.userid.userName.toLowerCase().includes(searchText));
    });
}

component.html

     {{use.packageName}}
    {{use.packagePrice}}
    {{use.userid.userName}}
    {{use.userid.userAge}}

A: Try the below:-
function getResult(filterBy, objList) {
return objList.hightlights.filter(function(obj) {
return obj.queries.some(function(item){
 return item.indexOf(filterBy) >= 0;
});
});
}


text:
Q: number of views for each list item I have a list for announcement, I need to count the number of views for each item!
How can show the total number for each item view in the display form? is it possible without coding!!

A: As far as I know you cannot do that out of the box. What you could do is to create a javascript solution to handle it.
The way I would do it is to create a list - lets call it viewcount - to keep the data about views with two fields: IdOfViewedItem and ViewCount
Write a script and place it on the display form of the item you want to track views on. The script should check if an item exists in the list viewcount, if not create it and set view count to 1. If the item exsits get the current viewcount and add one to the count.
Now this isn't by any account a bullitproof solution, especially if you have several hundred users accessing the item at the same time (The script would fire massively and updating the item will not be able to keep up most likely).


text:
Q: What is a good algorithm or library for cropping images to avoid whitespace or empty areas? I have a whole bunch of images of illustrations that I would like to crop to a smaller preview size.
The problem is that I want to crop them to show an "interesting" part of the illustration (ie avoid areas of whitespace).
The images typically have a flat color or a subtle gradient for the background. They are mostly vector style artwork with fairly distinct shapes.
Here are some examples: link ;-)
I've been thinking about using some sort of image feature detection algorithm with a sliding window to find the area with the greatest number of features.
I'm implementing this in PHP, but I don't mind implementing it myself if there isn't a library or extension available.
Ideas?

A: ImageMagick has a trim operation. It's available as a library but I don't know how hard it is to use from PHP. There are some PHP interfaces.

A: OK, so here's what I would've done, after looking at the examples:
Sum all rows and all columns of each image. You'll get two arrays, both looking like this:
      /-----\  /--\
    _/       --    |
___-                \_________

By looking at these arrays for a few images, find a suitable threshold (probably something just above zero). Then the leftmost and the rightmost crossing of this threshold is where you have to crop. I hope I've managed to make it clear enough, if not -- ask!

A: Here's a fairly simple approach using an edge-detection filter, and then cropping around the center-of-edginess of the image to generate a thumbnail. It works pretty well on most images, but not if there are more than one subject. I'm open to suggestions on other ways of identifying the "interesting" points in a source image.

A: Well, you might want to consider just using an edge detection algorithm.  Pick the area with the largest number of edges.  Give higher weight to edges that are not blurry (as they may be from the background).

A: ImageMagick for PHP has automated generation of thumbnails.  This SO question has a link to an ImageMagick auto-crop operator, and I'm not sure, but I think this is the PHP interface to it.
From the link:

bool Imagick::trimImage  ( float
  $fuzz  )
  Remove edges that are
  the background color from the image.

For more general "interestingness", maybe try an inverse of seam carving (to find the highest energy, rather than lowest energy areas).

A: A CLI program using http://pecl.php.net/package/imagick:
<?php
   dl('imagick.so');

   $img = new Imagick();
   $img->readImage($argv[1]);

   # (* 0.0: exact match; * 1.0: crop entire image)
   $fuzz = current($img->getQuantumRange()) * 0.25;

   $img->trimImage($fuzz);

   $img->writeImage($argv[2]);
?>

It should work good enough, as long as the image doesn't have a frame around its border.

A: Drupal has a project called smartcrop, which has PHP code to find highest entropy and "interesting" areas in images. See the output examples.
You should be able to use the functions in the module and the library in none-Drupal projects too.


text:
Q: Is my proof that $ \lim\limits_{x \to 2} \left(x^2 - 3x\right) = -2 $ correct? My proof: take $x$ such that $|{x - 2}| < 1$. Since $|{x}| -|{2}| < |{x - 2}|$, then $|{x}| < 3$.
Now we want to find a number $n$ such that $|{x - 2}| <1 \leq \frac{\epsilon}{n} $ or $|{x - 2}| < \frac{\epsilon}{n} \leq 1 $ and also so that $|{x - 1}| < n$, and since $|{x}| - |{1}| < |{x - 1}|$ we have that $|{x}| < n + 1$ so we can choose $n = 2$ and by definition of limit, for all $\epsilon$ we have at least one $\delta$ equal to the smaller between 1 and $\frac{\epsilon}{2}$ such that $|{x - 2}| < \delta$ implies $|{x - 1}||{x - 2}| = |{x^2 - 3x - (-2)}| < \frac{\delta}{2} = \epsilon$.

A: No, it is not correct. In the first place, you start talking about a number $n$ without saying what that number is. And then you state that, by definition of limit, a certain $\delta$ must exist.  But the goal is to prove that such a $\delta$ exists. And how do you know that $1\leqslant\frac\varepsilon n$?
You can do it as follows: start assuming that $\lvert x-2\rvert<1$. It follows from this that $\lvert x-1\rvert<2$. Now, given $\varepsilon>0$, take $\delta=\min\left\{\frac\varepsilon2,1\right\}$. Then, since $x^2-3x-(-2)=(x-1)(x-2)$, assuming that $\lvert x-2\rvert<\delta$, you have\begin{align}\lvert x^2-3x-(-2)\rvert&=\bigl\lvert(x-1)(x-2)\bigr\rvert\\&=\lvert x-1\rvert.\lvert x-2\rvert\\&<2\times\frac\varepsilon2\\&=\varepsilon.\end{align}