text:
Q: convert generic type to base class public class Base {...}

public class Complex: Base {...}

public class MyOtherClass<T> {...}

and a list of the two type
List<MyOtherClass<Complex>> listOfComplex
List<MyOtherClass<Base>> listOfBase

I want have a list
listOfComplex.Union(listOfBase)

but i cant convert generic of a type to a generic of another type even if Complex derive fro Base
It's possibble to have a list of a base class?

A: Although Complex derives from Base, there is no such relationship between MyOtherClass<Complex> and MyOtherClass<Base>. That is the reason why you cannot create an Union of the two lists. For the framework both generic types are completely different.
The solution now really depends on what exactly your class does. Check out the topic of covariance and contravariance here in Docs - these are two special cases in which you will be permitted to create conversions between the two generic types if the types either are input or output only.
You could also add custom cast or manually cast the items to the "base" type before doing the "union" operation.

A: Because that's how Covariance and Contravariance in Generics works, specifically invariance, it means that you can use only the type originally specified; so an invariant generic type parameter is neither covariant nor contravariant.
You can't assign an instance of List<Base> to a variable of type List<Complex> or in the opposite direction. Same applies to custom generic classes. There is no implicit conversion that compiler could use in order to convert types.
Even if you add generic type constraint. A<B> and A<C> are two different types with no conversion between them even if C is inherited from B (because AC is not inherited from AB)

A: @MartinZikmund has explained why it does not work. The resolution to this kind of problem is to either derive the generic classes from a non-generic base class or to let them implement a common interface.
    public class MyOtherClassBase { }
    public class MyOtherClass<T> : MyOtherClassBase { }

Then you can specify MyOtherClassBase as generic parameter to Union explicitly. Now, Union will expect inputs of type IEnumerable<MyOtherClassBase>. Lists of type List<MyOtherClass<T>> are assignment compatible to IEnumerable<MyOtherClassBase>.
var result = listOfComplex.Union<MyOtherClassBase>(listOfBase);

Note the out keyword in the declaration
public interface IEnumerable<out T> : System.Collections.IEnumerable

It makes the interface covariant. See also SO question <out T> vs <T> in Generics and especially Reed Copsey's answer.

A: You should specify in your generic that T is a class base on Type :
public class MyOtherClass<T> where T : Base {...}

T will be accepted only if derive from Base And Union will should work
Here some documentation about Generics, thanks to @Marie:
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters


text:
Q: The difference between declaring a name, introducing a name, and declaring an entity From the C++11 standard, §7.3.3[namespace.udecl]/1:

A using-declaration introduces a name into the declarative region in which the using-declaration appears.

using-declaration:

using typenameopt nested-name-specifier unqualified-id ;
using :: unqualified-id ;

The member name specified in a using-declaration is declared in the declarative region in which the using-declaration appears.

What do they mean by the name being declared in the declarative region where the using-declaration occurs?
Does this mean the same as introducing that name into the declarative region where the using-declaration occurs?
Also is there a difference between declaring a name and declaring the entity that the name denotes?
Example:
namespace N { static int i = 1; } /* Declares an entity denoted by
    the name i in the declarative region of the namespace N.
    Introduces the name into the declarative region of the namespace N.
    Declares the name i in the declarative region of the namespace N? */
using N::i; /* Declares the name i in the declarative region of the
    global namespace. Also introduces that name into the declarative
    region of the global namespace? Also declares the entity that the
    name i denotes? */

A: From first principles, an entity is, from [basic]

a value, object, reference, function, enumerator, type, class member, bit-field, template, template
  specialization, namespace, parameter pack, or this. [...] Every name that denotes an entity is introduced by a declaration.

Declarations declare things. To be declared means that it was introduced by a declaration, from [basic.scope.declarative]

Every name is introduced in some portion of program text called a declarative region, which is the largest part
  of the program in which that name is valid, that is, in which that name may be used as an unqualified name
  to refer to the same entity.
The names declared by a declaration are introduced into the scope in which the declaration occurs, except
  that the presence of a friend specifier (11.3), certain uses of the elaborated-type-specifier (7.1.6.3), and
  using-directives (7.3.4) alter this general behavior.

None of those exceptions are relevant here, since we're talking about using-declarations and not using-directives. Let me alter your example somewhat so as to avoid the global namespace:
namespace N {        //  + declarative region #1
                     //  |
    static int i;    //  | introduces a name into this region
                     //  | this declaration introduces an entity
}                    //  +

So to start with, N::i is an entity that is declared in namespace N and introduced into the scope of N. Now, let's add a using-declaration:
namespace B {        //  + declarative region #2
                     //  |
    using N::i;      //  | declaration introduces a name i
                     //  | but this is not an entity
}                    //  +

From [namespace.udecl], we have:

If a using-declaration names a constructor (3.4.3.1), it implicitly declares a set of constructors in the
  class in which the using-declaration appears (12.9); otherwise the name specified in a using-declaration is a
  synonym for a set of declarations in another namespace or class.

The using-declaration using N::i does not name a constructor, so rather than having the name i be a new entity, it is instead a synonym for N::i.
So basically, both is are names introduced in and declared in their respective namespaces. In N, i declares an entity with static linkage, but in B, i declares a synonym to that entity - not a new entity.

A:
What do they mean by the name being declared in the declarative region
  where the using-declaration occurs?

I'll try and answer this with an example of my understanding of it (Refer to my comments in the depicted code):
// "namespace X {}" introduces a declarative region of the namespace X
namespace X {
  //The name SomeObject is now introduced into the declarative region X
  // It is only visible in that declarative region
  using Y::SomeObject;
}//Declarative region X ENDS here
// SomeObject NOT visible here

Below is an example where the (compiler) error makes it clear where the name is not visible:
#include <iostream>

namespace A
{
  struct X{};
}

namespace B
{
  struct X{};
}

namespace C
{
  using A::X;

  void foo(X){}
}

namespace D
{
  using B::X;

  void foo(X){}
}

void foo(X){} //FAILS TO COMPILE - DELIBERATE!!!

int main()
{
    return 0;
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do I convert datestrings with '-' in it to integers when there are also years before 0 I have a dataframe in Python with one column that depicts different formats of time.
The different formats are

*

*NaN

*only the Year

*the year, the month

*the year, the month and the date

I cannot convert it to datetime because it has dates before 0. It's about museum objects so some pieces are from -800.
But the strings also sometime show the year, month and day separated by a '-', (for example '1880-04-23'). I can not just convert the '-' to empty strings because then the years before 0 also will be wrong.
Can somebody please help me with this. There are too many different forms to just pick one and delete all the other rows, that would mean the dataset will be very empty in the end.
If only the year is available in the end that would perfect as well, i just want to be able to work with it in integers.
What I tried to do now is iterating over every row in the column and then iterating over the elements of the string within that row starting from the second element, searching for a '-'. This way I can do something like delete everything after the first occurrence of the '-' (and because i start at the second element, if the year is before 0 that '-' will not be seen) or replace those with a '#' so I can split it afterwards.
for i in range(len(df)):
    for element in df.loc[i,'columnname_with_dates_as_strings'][1:]:
        element.replace('-','#')

But this doesn't work because I get the keyerror: 0
I think my second line is faulty but I don't know why

A:
def split_date(date_str):
    if date_str[0] == '-':
        sign = 1
    else:
        sign = 0
    date_array = date_str[sign:].split('-')
    return (sign, date_array)

>>>
>>> split_date("1880-04-23")
(0, ['1880', '04', '23'])
>>> split_date("-800")
(1, ['800'])
>>> split_date("-123-5-6")
(1, ['123', '5', '6'])


text:
Q: Scrapy: no item output | Debug: crawled (200)... (referer:none) I am attempting to extract bid information from this site. I am a Scrapy newbie, and bit stuck as to why I don't getting any output, instead, I get Crawled (200)...(referer: None) and no output. I am unable to figure out what I am missing or need to change. I really don't know where the problem is. Can anyone please help figure this out?
Thank you!!
Here is my spider code:
from ..items import GovernmentItem
import scrapy, urllib.parse

class GeorgiaSpider(scrapy.Spider):
    name = 'georgia'
    allowed_domains = ['ssl.doas.state.ga.us']

    def start_requests(self):
        url = 'https://ssl.doas.state.ga.us/gpr/'

        yield scrapy.Request(url=url, callback=self.parse)

    def parse(self, response):
        for row in response.xpath('//*[@class="table table-striped table-bordered"]//tbody//tr'):
            item = GovernmentItem()

            item['description'] = row.xpath('./td[@class=" all"][2]').extract_first()
            item['begin_date'] = row.xpath('./td[@class=" desktop"]').extract_first()
            item['end_date'] = row.xpath('./td[@class="desktop tablet mobile sorting_1"]').extract_first()
            item['file_urls'] = row.xpath('./td[@class=" all]/a//@href').extract_first()

            yield item

Here is my my crawl log file:
2021-07-23 05:49:13 [scrapy.utils.log] INFO: Scrapy 2.5.0 started (bot: government)
    2021-07-23 05:49:13 [scrapy.utils.log] INFO: Versions: lxml 4.6.3.0, libxml2 2.9.10, cssselect 1.1.0, parsel 1.6.0, w3lib 1.22.0, Twisted 21.2.0, Python 3.8.10 (default, Jun  2 2021, 10:49:15) - [GCC 9.4.0], pyOpenSSL 20.0.1 (OpenSSL 1.1.1k  25 Mar 2021), cryptography 3.4.7, Platform Linux-5.8.0-63-generic-x86_64-with-glibc2.29
    2021-07-23 05:49:13 [scrapy.utils.log] DEBUG: Using reactor: twisted.internet.epollreactor.EPollReactor
    2021-07-23 05:49:13 [scrapy.crawler] INFO: Overridden settings:
    {'BOT_NAME': 'government',
     'DOWNLOAD_DELAY': 1,
     'NEWSPIDER_MODULE': 'government.spiders',
     'SPIDER_MODULES': ['government.spiders']}
    2021-07-23 05:49:13 [scrapy.extensions.telnet] INFO: Telnet Password: 1196e88aa45a90c1
    2021-07-23 05:49:13 [scrapy.middleware] INFO: Enabled extensions:
    ['scrapy.extensions.corestats.CoreStats',
     'scrapy.extensions.telnet.TelnetConsole',
     'scrapy.extensions.memusage.MemoryUsage',
     'scrapy.extensions.feedexport.FeedExporter',
     'scrapy.extensions.logstats.LogStats']
    2021-07-23 05:49:13 [scrapy.middleware] INFO: Enabled downloader middlewares:
    ['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
     'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
     'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
     'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
     'scrapy.downloadermiddlewares.retry.RetryMiddleware',
     'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
     'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
     'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
     'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
     'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
     'scrapy.downloadermiddlewares.stats.DownloaderStats']
    2021-07-23 05:49:13 [scrapy.middleware] INFO: Enabled spider middlewares:
    ['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
     'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
     'scrapy.spidermiddlewares.referer.RefererMiddleware',
     'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
     'scrapy.spidermiddlewares.depth.DepthMiddleware']
    2021-07-23 05:49:13 [scrapy.middleware] INFO: Enabled item pipelines:
    ['government.pipelines.GovernmentPipeline',
     'scrapy.pipelines.files.FilesPipeline']
    2021-07-23 05:49:13 [scrapy.core.engine] INFO: Spider opened
    2021-07-23 05:49:13 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
    2021-07-23 05:49:13 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
    2021-07-23 05:49:14 [scrapy.downloadermiddlewares.redirect] DEBUG: Redirecting (302) to <GET https://ssl.doas.state.ga.us/gpr/unsupported?browser=> from <GET https://ssl.doas.state.ga.us/gpr/>
    2021-07-23 05:49:15 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://ssl.doas.state.ga.us/gpr/unsupported?browser=> (referer: None)
    2021-07-23 05:49:15 [scrapy.core.engine] INFO: Closing spider (finished)
    2021-07-23 05:49:15 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
    {'downloader/request_bytes': 468,
     'downloader/request_count': 2,
     'downloader/request_method_count/GET': 2,
     'downloader/response_bytes': 6169,
     'downloader/response_count': 2,
     'downloader/response_status_count/200': 1,
     'downloader/response_status_count/302': 1,
     'elapsed_time_seconds': 1.564505,
     'finish_reason': 'finished',
     'finish_time': datetime.datetime(2021, 7, 23, 10, 49, 15, 561300),
     'log_count/DEBUG': 2,
     'log_count/INFO': 10,
     'memusage/max': 55824384,
     'memusage/startup': 55824384,
     'response_received_count': 1,
     'scheduler/dequeued': 2,
     'scheduler/dequeued/memory': 2,
     'scheduler/enqueued': 2,
     'scheduler/enqueued/memory': 2,
     'start_time': datetime.datetime(2021, 7, 23, 10, 49, 13, 996795)}
    2021-07-23 05:49:15 [scrapy.core.engine] INFO: Spider closed (finished)

A: This is the full working solution:
 import scrapy
 import json
    # base_url = https://ssl.doas.state.ga.us/gpr/

    class GeorgiaSpider(scrapy.Spider):

        name = 'georgia'
        body = 'draw=1&columns%5B0%5D%5Bdata%5D=function&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=false&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=function&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=title&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=agencyName&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=true&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=postingDateStr&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=true&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=closingDateStr&columns%5B5%5D%5Bname%5D=&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=true&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B6%5D%5Bdata%5D=function&columns%5B6%5D%5Bname%5D=&columns%5B6%5D%5Bsearchable%5D=true&columns%5B6%5D%5Borderable%5D=false&columns%5B6%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B6%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B7%5D%5Bdata%5D=status&columns%5B7%5D%5Bname%5D=&columns%5B7%5D%5Bsearchable%5D=true&columns%5B7%5D%5Borderable%5D=false&columns%5B7%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B7%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=5&order%5B0%5D%5Bdir%5D=asc&start=0&length=50&search%5Bvalue%5D=&search%5Bregex%5D=false&responseType=ALL&eventStatus=OPEN&eventIdTitle=&govType=ALL&govEntity=&eventProcessType=ALL&dateRangeType=&rangeStartDate=&rangeEndDate=&isReset=false&persisted=&refreshSearchData=false'

        def start_requests(self):
            yield scrapy.Request(
                url='https://ssl.doas.state.ga.us/gpr/eventSearch',
                callback=self.parse,
                body=self.body,
                method="POST",
                headers={
                    'authority': 'ssl.doas.state.ga.us',
                    'path': '/gpr/eventSearch',
                    'scheme': 'https',
                    'accept': 'application/json, text/javascript, */*; q=0.01',
                    'accept-encoding': 'gzip, deflate, br',
                    'accept-language': 'en-US,en;q=0.9,bn;q=0.8,es;q=0.7,ar;q=0.6',
                    'content-length': '2030',
                    'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
                    'origin': 'https://ssl.doas.state.ga.us',
                    'referer': 'https://ssl.doas.state.ga.us/gpr/',
                    'sec-ch-ua': '"Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"',
                    'sec-ch-ua-mobile': '?0',
                    'sec-fetch-dest': 'empty',
                    'sec-fetch-mode': 'cors',
                    'pragma': 'no-cache',
                    'cache-control': 'no-cache',
                    'sec-fetch-site': 'same-origin',
                    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36',
                    'x-requested-with': 'XMLHttpRequest'
                    }
                )

        def parse(self, response):
            response = json.loads(response.body)
            for resp in response['data']:
                yield {
                    'title': resp['title'],
                    'begin_date':resp['postingDateStr'],
                    'end_date':resp['closingDateStr']
                    }

                 OUTPUT:

2021-07-25 10:48:01 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2021-07-25 10:48:04 [scrapy.core.engine] DEBUG: Crawled (200) <POST https://ssl.doas.state.ga.us/gpr/eventSearch> (referer: https://ssl.doas.state.ga.us/gpr/)
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Ford Transit Connect Cargo Van', 'begin_date': 'Jul 12, 2021 @ 05:19 PM', 'end_date': 'Jul 26, 2021 @ 09:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': '2020 CDBG Water System Improvement', 'begin_date': 'Jun 14, 2021 @ 11:58 AM', 'end_date': 'Jul 26, 2021 @ 10:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Fire Station 20 Renovations', 'begin_date': 'Jun 30, 2021 @ 08:54 AM', 'end_date': 'Jul 26, 2021 @ 10:00
AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Food Service Produce', 'begin_date': 'Jun 28, 2021 @ 07:24 AM', 'end_date': 'Jul 26, 2021 @ 10:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'LMIG 2021 ROAD RESURFACING PORJECT', 'begin_date': 'Jul 01, 2021 @ 02:36 PM', 'end_date': 'Jul 26, 2021 @ 10:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'MGA Robinson R44 Helicopter Cadet Overhaul', 'begin_date': 'Jul 07, 2021 @ 12:00 PM', 'end_date': 'Jul 26, 2021 @ 10:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Renovations to Old Hickory Flat Gymnasium', 'begin_date': 'Jun 24, 2021 @ 04:51 PM', 'end_date': 'Jul 26, 2021 @ 10:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'eCard Services', 'begin_date': 'Jul 09, 2021 @ 12:00 PM', 'end_date': 'Jul 26, 2021 @ 12:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Ford Police Interceptor', 'begin_date': 'Jul 01, 2021 @ 12:17 PM', 'end_date': 'Jul 26, 2021 @ 02:00 PM'}2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'North End Roadway Safety Analysis', 'begin_date': 'Jun 23, 2021 @ 10:18 AM', 'end_date': 'Jul 26, 2021 @
02:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Offset Printing & Finishing Services for Bulldog Print + Design', 'begin_date': 'Jun 30, 2021 @ 03:15 PM', 'end_date': 'Jul 26, 2021 @ 02:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'RECREATION, PARKS, HISTORIC AND CULTURAL AFFAIRS 5', 'begin_date': 'Jun 25, 2021 @ 10:37 AM', 'end_date': 'Jul 26, 2021 @ 02:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Surgical Sterilization of Adoptable Pets', 'begin_date': 'Jun 24, 2021 @ 03:12 PM', 'end_date': 'Jul 26,
2021 @ 03:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Remount Ambulance', 'begin_date': 'Jun 23, 2021 @ 10:43 AM', 'end_date': 'Jul 26, 2021 @ 04:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'DOCO CDBG Rehab/Elevation/Reconstruction', 'begin_date': 'Jun 23, 2021 @ 11:12 AM', 'end_date': 'Jul 26,
2021 @ 05:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'T32-D1-Veg Rem-SR 211 Barrow-121766', 'begin_date': 'Jul 08, 2021 @ 04:58 PM', 'end_date': 'Jul 26, 2021
@ 05:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Carrollton City Hall Renovation & Addition', 'begin_date': 'Jun 25, 2021 @ 09:14 AM', 'end_date': 'Jul 27, 2021 @ 10:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'HUB Transformation Project', 'begin_date': 'Jun 17, 2021 @ 05:01 PM', 'end_date': 'Jul 27, 2021 @ 10:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Extrication Equipment', 'begin_date': 'Jun 22, 2021 @ 12:08 AM', 'end_date': 'Jul 27, 2021 @ 11:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Goodyear Pressure Improvement Natural Gas Main Ext', 'begin_date': 'Jul 01, 2021 @ 02:46 PM', 'end_date': 'Jul 27, 2021 @ 11:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Septic Tank and Grease Trap Pumping', 'begin_date': 'Jun 29, 2021 @ 05:53 PM', 'end_date': 'Jul 27, 2021
@ 11:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'T-Hangar Area-Sitework', 'begin_date': 'Jun 29, 2021 @ 08:27 AM', 'end_date': 'Jul 27, 2021 @ 11:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Toccoa Airport - Apron / Ramp Seal Coat', 'begin_date': 'Jun 30, 2021 @ 04:03 PM', 'end_date': 'Jul 27, 2021 @ 11:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'UWG Nursing Building Parking Lot Expansion', 'begin_date': 'Jun 25, 2021 @ 09:08 AM', 'end_date': 'Jul 27, 2021 @ 11:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'WYCKOFF RAW WATER PIPELINE REPLACEMENT', 'begin_date': 'Jun 25, 2021 @ 09:11 AM', 'end_date': 'Jul 27, 2021 @ 11:00 AM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Purchase 1 One Ton 4x2 Extended Cab Truck', 'begin_date': 'Jul 09, 2021 @ 09:22 AM', 'end_date': 'Jul 27, 2021 @ 12:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Purchase One 4x2 Two Ton Crew Cab Truck', 'begin_date': 'Jul 09, 2021 @ 09:33 AM', 'end_date': 'Jul 27, 2021 @ 12:00 PM'}
2021-07-25 10:48:04 [scrapy.core.scraper] DEBUG: Scraped from <200 https://ssl.doas.state.ga.us/gpr/eventSearch>
{'title': 'Purchase One 4x4 Crew Cab Two Ton Truck', 'begin_date': 'Jul 09, 2021 @ 09:28 AM', 'end_date': 'Jul 27, 2021 @ 12:00 PM'}

A: As you can see you get the response of https://ssl.doas.state.ga.us/gpr/unsupported?browser=, so set your user_agent accordingly (for example a windows machine with chrome browser).
Change (and uncomment) USER_AGENT in settings.py to:
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"

A: As mentioned by SuperUser, your original URL is getting redirected because website expects the request from real browser. To mimic the same behaviour like browser through scrapy you should pass user-agent either by setting.py or as a header in your spider.py file which would return you page source html.
Your XPath still won't work because the data you are looking for is generated dynamically. So, you should reproduce the request using browser dev tools to get the API and then utilise that to get the desired results.
You will get the JSON response from below code. For the demonstration, I have extracted only one field. Similarly, you can get other fields.
Code
import scrapy
import json
from ..items import GovernmentItem

class Test(scrapy.Spider):
    name = 'test'

    headers = {
        "authority": "ssl.doas.state.ga.us",
        "pragma": "no-cache",
        "cache-control": "no-cache",
        "sec-ch-ua": "\"Chromium\";v=\"92\", \" Not A;Brand\";v=\"99\", \"Google Chrome\";v=\"92\"",
        "accept": "application/json, text/javascript, */*; q=0.01",
        "x-requested-with": "XMLHttpRequest",
        "sec-ch-ua-mobile": "?0",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36",
        "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
        "origin": "https://ssl.doas.state.ga.us",
        "sec-fetch-site": "same-origin",
        "sec-fetch-mode": "cors",
        "sec-fetch-dest": "empty",
        "referer": "https://ssl.doas.state.ga.us/gpr/",
        "accept-language": "en-US,en;q=0.9"
    }

    body = 'draw=1&columns%5B0%5D%5Bdata%5D=function&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=false&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=function&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=title&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=agencyName&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=true&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=postingDateStr&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=true&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=closingDateStr&columns%5B5%5D%5Bname%5D=&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=true&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B6%5D%5Bdata%5D=function&columns%5B6%5D%5Bname%5D=&columns%5B6%5D%5Bsearchable%5D=true&columns%5B6%5D%5Borderable%5D=false&columns%5B6%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B6%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B7%5D%5Bdata%5D=status&columns%5B7%5D%5Bname%5D=&columns%5B7%5D%5Bsearchable%5D=true&columns%5B7%5D%5Borderable%5D=false&columns%5B7%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B7%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=5&order%5B0%5D%5Bdir%5D=asc&start=0&length=50&search%5Bvalue%5D=&search%5Bregex%5D=false&responseType=ALL&eventStatus=OPEN&eventIdTitle=&govType=ALL&govEntity=&eventProcessType=ALL&dateRangeType=&rangeStartDate=&rangeEndDate=&isReset=false&persisted=&refreshSearchData=false'

    def start_requests(self):
       url = 'https://ssl.doas.state.ga.us/gpr/eventSearch'
       yield scrapy.Request(url=url,method='POST', headers=self.headers,body=self.body, callback=self.parse)

    def parse(self,response):
        item = GovernmentItem()
        response = json.loads(response.body)
        for i in response.get('data'):
            item['title'] = i.get('title')
            yield item


text:
Q: InputMap/ActionMap does not work after opened SubDialog I have tried to make a Dialog Close when I press ESC and accept when I press ENTER.
So I have build a superclass "CloseableDialog" using Input/ActionMap like this:
    getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "accept");
    getRootPane().getActionMap().put("accept", acceptAction);

    getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel");
    getRootPane().getActionMap().put("cancel", cancelAction);

Now I built several Dialogs extending CloseableDialog. It works as aspected at first time (closing when pressing ESC, accepting when press ENTER), but when I opened a SubDialog (Dialog in Dialog) only the Subdialog was closeable by pressing ESC (ESC -> SubDialog closes, other Dialog Visible -> ESC-> nothin happens).
Any ideas?
I think, the diposed SubDialog gets still the inputs of the other Dialog, but I am not sure.

A: The shorcuts work when the components are focused.I think focus is not there in your previously opened window.Try to get the focus back to the window where you need the shortcut to be worked fine.Try cliking on that window and apply the shortcut.Perhaps it will work.Otherwise you have to deal with get focus to the window

A: I've got it!
Reading http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html told me, that there are three InputMaps:

*

*JComponent.WHEN_FOCUSED

*JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT

*JComponent.WHEN_IN_FOCUSED_WINDOW

By calling getRootPane.getInputMap() I got the "default" WHEN_FOCUSED Inputmap,
but by calling a Subdialog the rootPane seems to lost the focus and nothing helped to
get the Focus back.
Now I am using getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(...)
and it works.
I am a little bit amazed, that it has worked before until opening a Subdialog.


text:
Q: A couple of issues with JSHint: 'is defined but never used' and 'is not defined' I have this application pretty modular and as such, JSHint is giving me the 'x' is defined but never used error.
My setup goes like this:
app/assets/scripts/bootstrap.js: var x = 5;
app/assets/scripts/kickstart.js: console.log(x);
And here's the output I get from JSHint:
app/assets/scripts/bootstrap.js
  line 1  col 6   'x' is defined but never used.

app/assets/scripts/kickstart.js
  line 1  col 13  'x' is not defined.

2 problems

I know I could us something like /* exported x */ but would be really cumbersome if I have lots of variables like this.
Is there anyway to solve these 2 issues without disabling their specific options? Because they could come in handy in other, more important, situations.

A: You can add this at the top of the file.
/*jshint unused: false, undef:false */

Notice that options can be applied to specific scopes. This works for unused, but apparently not for undef.
(function () {
  /*jshint unused: false */

  // Stuff
}());


text:
Q: How to insert multiple rows into a SQLite 3 table? In MySQL I'd use
INSERT INTO `mytable` (`col1`, `col2`) VALUES
  (1, 'aaa'),
  (2, 'bbb');

but this causes an error in SQLite. What is the correct syntax for SQLite?

A: Use a UNION:
INSERT INTO `mytable`
 (`col1`, `col2`)
SELECT 1, 'aaa'
UNION ALL
SELECT 2, 'bbb'

UNION ALL is quicker than UNION, because UNION removes duplicates -- UNION ALL does not.

A: Start from version 2012-03-20 (3.7.11), sqlite support the following INSERT syntax:
INSERT INTO 'tablename' ('column1', 'column2') VALUES
  ('data1', 'data2'),
  ('data3', 'data4'),
  ('data5', 'data6'),
  ('data7', 'data8');

Read documentation: http://www.sqlite.org/lang_insert.html

A: This has already been answered before here: Is it possible to insert multiple rows at a time in an SQLite database?
To answer your comment to OMG Ponies answer:
As of version 3.7.11 SQLite does support multi-row-insert. Richard Hipp comments:
"The new multi-valued insert is merely syntactic suger (sic) for the compound insert.
There is no performance advantage one way or the other."


text:
Q: Nullpointer exception soapui file upload call I have to upload a file using soap ui.Below is my service code.It executes fine if call using jersey.But when i try to call using soapui null pointer exception occurs.
I call the fileupload service in soap ui like below
Create Rest Project:
Add the Url:
http://localhost:8080/FileService/Services/HomeService/testupload
file file:c:\\1.wav

 @POST
            @Path("testupload")
            @Consumes(MediaType.MULTIPART_FORM_DATA)
            @Produces(MediaType.TEXT_PLAIN)
            public String uploadFile(@FormDataParam("file") InputStream fis,
                            @FormDataParam("file") FormDataContentDisposition fdcd) {

                OutputStream outpuStream = null;
                String fileName = fdcd.getFileName();

                String filePath = FOLDER_PATH + fileName;

                try {
                    int read = 0;
                    byte[] bytes = new byte[1024];
                    outpuStream = new FileOutputStream(new File(filePath));
                    while ((read = fis.read(bytes)) != -1) {
                        outpuStream.write(bytes, 0, read);
                    }
                    outpuStream.flush();
                    outpuStream.close();
                } catch(IOException iox){
                    iox.printStackTrace();
                } finally {
                    if(outpuStream != null){
                        try{outpuStream.close();} catch(Exception ex){}
                    }
                }
                return "File Upload Successfully !!";
            }

How to fix this issue? Any help will be greatly appreciated!!!


text:
Q: Angular : Property 'data' does not exist on type 'Object' on ng build --prod Property 'data' does not exist on type 'Object' on ng build --prod.
My service.ts
getSlogan() {
 return this.http.get(this._slogan)
}

My component.ts
import ...
.
.
export interface Iheader {
  facebook_link: string
  id: number
  instagram_link: string
  line_link: string
  pinterest_link: string
  site_slogan: string
  tel: string
  youtube_link: string
 }
 export class HeaderComponent implements OnInit {

 socials : any
 data : Iheader

 ngOnInit() {
 // get site data
  this.apiservice.getSlogan()
   .subscribe(data => {
    this.socials = data
  });

My html

It's error "Property 'data' does not exist on type 'Object'" on ng build --prod.
My api data look like
 [
   status: 200,
   data: {
     data: {
       pinterest_link: "url"
     }
   }
 ]

A: it looks like you stored the whole server response in socials variable.
so you need to access the data like this:

Or
the better solution is to store it first like this
ngOnInit() {
   // get site data
   this.apiservice.getSlogan()
   .subscribe(response => {
      this.socials = response.data
   });
}

and you need to set the socials variable to something by default like empty array.
socials : any = []

A: socials?.data.pinterest_link should be the error. "socials?" just checks, if its undefined/null or defined. But if it's defined, it does not guarantee, that the property "data" exist on the object. You need something like "socials?.data?", but the href will have errors.
Furthermore, you have a double nested "data". Maybe this is also an error.
Do it like


text:
Q: How to push into a certain folder from master I have to push to master branch a local folder into a specific folder from master.

*

*git init

*git add masterURL -> contains proiect folder

*git add.

*git push -u origin master

!! how can I push my changes into proiect folder from master.
Please help!
PS: so all my changes would be in proiect folder not at the same level as proiect

A: Git isn't designed that way. A Git repository tracks full snapshots of a complete project tree. You cannot push a single subdirectory and you cannot push (unrelated) commits and expect them to show up in antoher branch.
Here's what you can do:

*

*Clone the repository

*Optional: create and checkout a feature branch

*Copy your files/directories and git add them

*Remove any files you no longer need (git rm)

*Commit the new state with git commit

*Push the new commit

*Optional: create a pull request or merge request to integrate your branch into the master branch

Read an extensive overview in the Contributing to a Project chapter of the Git book.


text:
Q: Appcelerator Titanium App reading JSON from a wordpress website So iv'e been searching everywhere to get an Titanium app to read JSON from a wordpress website,
Im getting an error:
"Uncaught SyntaxError: Unexpected token )"
not sure how to fix
but here is the code i have
app.js:
// Creates a tab group with Titanium.UI API.
var tabGroup = Titanium.UI.createTabGroup();

// Create the window "mainWin"
var mainWin = Titanium.UI.createWindow ({
    title: "Most Recent Blog Posts", // Set the title
    backgroundColor: "#fff", // Set the background color to white
    url: "wordpress.js" // Link to file which will handle the code for the window
});

// Create the tab "mainTab"
var mainTab = Titanium.UI.createTab ({
    title: "Posts", // Title of the tab: "SUYS"
    window: mainWin // We will create the window "mainWin"
});

// Add the tab to our tab group
tabGroup.addTab(mainTab);
tabGroup.open();

wordpress.js
// Create variable "win" to refer to current window
var win = Titanium.UI.currentWindow;

// Function loadTweets()
function loadMessage()
{
    // Empty array "rowData" for our tableview
    var rowData = [];

    // Create our HTTP Client and name it "loader"
    var loader = Titanium.Network.createHTTPClient();

    // Sets the HTTP request method, and the URL to get data from
    loader.open("GET","http://http://localhost/wordpress/?json=get_posts");

    // Runs the function when the data is ready for us to process
    loader.onload = function()
    {
        var message = eval('('+this.responseText+')');

        alert('loaded');

        for (var i = 0; i < message.posts.length; i++)
        {
            console.log(message.posts[i].post_title);
            var tweet = message.posts[i].post_content; // The tweet message
            var user = message.posts[i].author.name; // The screen name of the user
            var avatar = message.posts[i].user_avatar; // The profile image
            // Create a row and set its height to auto
            var row = Titanium.UI.createTableViewRow({height:'auto'});

            // Create the view that will contain the text and avatar
            var post_view = Titanium.UI.createView({
                height:'auto',
                layout:'vertical',
                top:5,
                right:5,
                bottom:5,
                left:5
            });
            // Create image view to hold profile pic
            var av_image = Titanium.UI.createImageView({
                url:avatar, // the image for the image view
                top:0,
                left:0,
                height:48,
                width:48
            });
            post_view.add(av_image);
            // Create the label to hold the screen name
            var user_lbl = Titanium.UI.createLabel({
                text:user,
                left:54,
                width:120,
                top:-48,
                bottom:2,
                height:16,
                textAlign:'left',
                color:'#444444',
                font:{fontFamily:'Trebuchet MS',fontSize:14,fontWeight:'bold'}
            });
            post_view.add(user_lbl);
            // Create the label to hold the tweet message
            var tweet_lbl = Titanium.UI.createLabel({
                text:tweet,
                left:54,
                top:0,
                bottom:2,
                height:'auto',
                width: 'auto',
                textAlign:'left',
                font:{fontSize:14}
            });
            post_view.add(tweet_lbl);
            // Add the post view to the row
            row.add(post_view);
            // Give each row a class name
            row.className = "item"+i;
            // Add row to the rowData array
            rowData[i] = row;
        }
        // Create the table view and set its data source to "rowData" array
        var tableView = Titanium.UI.createTableView({data:rowData});
        //Add the table view to the window
        win.add(tableView);
    };
    // Send the HTTP request
    loader.send();
}
loadMessage();

Any help would be much appreciated!!!


text:
Q: Spread operator to merge object on import - AOT I'm trying to provide an object which contains my translations keys and it's values.
example:
{
  "try_again_key": "Try Again",
  "cancel_key": "Cancel",
  "other_key": "Other"
  ...
}

I have to import this object in my features module and provide it to a lib so that I can use translate from Angular but in my case, I need to merge 2 objects(both containing different translations keys) like this:
import { myFallback } from "../../locale/fallback-ts";
import { otherFallback} from "@company/platform-components";

 @NgModule({
  imports: [
        TranslationsModule.forChild([
        {
            domain: "domain",
            service: "service",
            fallback: { ...otherFallback, ...myFallback },
        },
    ]),

when I log the fallback on JIT = contains my 2 merged objects
when I log the fallback on AOT = empty object
import { myFallback } from "../../locale/fallback-ts";
import { otherFallback} from "@company/platform-components";
 @NgModule({
  imports: [
        TranslationsModule.forChild([
        {
            domain: "domain",
            service: "service",
            fallback: myFallback,
        },
    ]),

when I log the fallback on JIT/AOT = contains my object
but if I do like this, it works but than it doesn't help me because I won't be merging the objects, it seems spread operators is not supported by Angular AOT
some links I found about AOT: https://angular.io/guide/aot-compiler
in this link it doesn't specify I can't use with spread operator
this GitHub issue looks like what I need but it was ignored by angular team https://github.com/angular/angular-cli/issues/9511
my question is, am I doing something wrong? if it's a limitation from angular AOT, can I merge 2 objects another way?
Things I've tried:
using Object.assign() instead of spread operator.
declaring a const that receives this 2 objects and than importing it on my .forChild() method
export const fallback = { ...tsValues, ...jsonValues};

A: As discussed on this issue, ngc, which is the compiler used on AOT, does not evaluate the spread operator in object literals while processing metadata by design, even though it evaluates spread in literal arrays (as stated on the link you provided about the AOT compiler).
The good thing is that, apparently, this issue has already been fixed on ivy (the new Angular compilation and rendering pipeline), as mentioned at the end of the issue above.


text:
Q: Asp.Net MVC WebGrid helper custom attributes for table rows Is there a way to assign custom data attributes for table rows generated by the WebGrid helper in Asp.Net MVC?
What I would like to end up with is something like this:

A: No, AFAIK that's not possible. The best you could do on a tr is to apply a style and an alternating row style. I'd recommend MvcContrib Grid or Telerik Mvc Grid as more advanced alternatives to Microsoft's WebGrid helper.


text:
Q: Select Records which have distance of 5km or greater between them I am working on a location app and i need to get all locations from my Mysql Location table which have a 5km distance between them.
For Ex location table have below entries:
  id     Latitude       Longitude
  1     22.7499180     75.8950577
  2     22.7498474     75.8950653
  3     22.7498035     75.8950424
  4     22.7497787     75.8950729
  5     22.7498245     75.8950806
  6     22.7497902     75.8950272
  7     22.7497864     75.8950424
  8     22.7497768     75.8950500
  9     22.7497864     75.8950577
  10    22.7497921     75.8950653
  11    22.7497597     75.8950653
  12    22.7498283     75.8950653
  13    22.7497978     75.8950577

So from above table how i need to fetch results something like this
  id     Latitude       Longitude   Distance (>=5Km)
  1     22.7499180     75.8950577     --
  4     22.7497787     75.8950729    6km (From lat long of id 1)
  8     22.7497768     75.8950500    8km (From lat long of id 4)
  11    22.7497597     75.8950653    6km (From lat long of id 8)
  13    22.7497978     75.8950577    10km (From lat long of id 11)

I searched a lot to get such results but i got query only to get result on basis of some fixed lat/long or a fixed radius. Please help with Mysql query if possible.
Edit  (from OP's comment)
I need is to calculate distance from last selected value... For Ex. Start from Record 1. distance of 1 is compared with record 2 it is < 5km, compared with record 3 also < 5km ,when compared with 4 its distance is > 5km so we keep it in list THAN NEXT RECORD WILL BE COMPARED WITH RECORD 4. so distance of 4 will be compared with 5 and if record 5 have distance > 5km from 4 next comparison is done with record 5 as reference.

A: No stored procedure, just pure unbridled sql glory:
SET @prevLong=-1.0000;
SET @prevLat=-1.0000;
SET @currDist=1.0000;
select id, diff from (
select id,
@prevLat prev_lat,
@currDist:= 6371 * 2 * (atan2(sqrt(sin(radians(@prevLat - lat)/2)
                       * sin(radians(@prevLat - lat)/2)
                       + cos(radians(lat))
                       * cos(radians(@prevLat))
                       * sin(radians(@prevLong - longi)/2)
                       * sin(radians(@prevLong - longi)/2))
                  ,sqrt(1-(sin(radians(@prevLat - lat)/2)
                           * sin(radians(@prevLat - lat)/2)
                           + cos(radians(lat))
                           * cos(radians(@prevLat))
                           * sin(radians(@prevLong
                                         - longi)/2)
                           * sin(radians(@prevLong - longi)/2))))) diff,
@prevLong prevLong,
case when @currdist > 5 then @prevLat:=lat  else null end  curr_lat,
case when @currDist > 5 then @prevLong:= longi  else null end  curr_long

  from latLong
order by id asc
) a where diff > 5

SQLFiddle to prove that magic is real:
http://sqlfiddle.com/#!9/7e4fe/19
Edit
In Codeigniter you can use variables like the following:
$this->db->query("SET @prevLong=-1.0000");
$this->db->query("SET @prevLat=-1.0000");
$this->db->query("SET @prevDist=-1.0000");

Then issue your query as normal
$query= $this->db->query("SELECT ...");

A: So you need to calculate the distance from Lat Lon and then check if the result is greater than 5km. Problem with your sample data is, that the calculated distances are within meters, so you won't get any result from that. I guess you have a few more locations to check in your table.
try
SELECT
    a.id, a.Latitude, a.Longitude, CONCAT(a.ID,"-",b.ID) as 'FromTo',
    6371 * acos(
                  cos(radians( b.Latitude ))
                * cos(radians( a.Latitude ))
                * cos(radians( b.Longitude ) - radians( a.Longitude ))
                + sin(radians( b.Latitude ))
                * sin(radians( a.Latitude ))) as distance
FROM new_table a INNER JOIN new_table b ON a.id <> b.id
HAVING distance >= 0.001
ORDER BY id, distance;

I set the having clause to greater than a meter HAVING distance >= 0.001. if you want to check for km adjust accordingly!
EDIT
it is not the fastes solution you might have to tweak it a little bit but the procedure would look like
DELIMITER $$
CREATE PROCEDURE `calcDistWithin`(IN dist double)
BEGIN

declare maxTempID int;
declare maxTblID int;
declare breakLoop boolean;
SET breakLoop = FALSE;

DROP TEMPORARY TABLE IF EXISTS tmp;
CREATE TEMPORARY TABLE tmp (ID int, Latitude double, Longitude double, distance double, toID varchar(10));
DROP TEMPORARY TABLE IF EXISTS tmpOUT;
CREATE TEMPORARY TABLE tmpOUT (ID int, Latitude double, Longitude double, distance double, toID varchar(10));

INSERT INTO tmp select ID, Latitude, Longitude, 0, "---"  from new_table limit 1;
INSERT INTO tmpOUT select ID, Latitude, Longitude, 0, "---"  from new_table limit 1;

SELECT ID INTO maxTblID FROM new_table ORDER BY ID DESC LIMIT 1;
SELECT ID into maxTempID FROM tmp ORDER BY ID DESC LIMIT 1;

WHILE breakLoop = FALSE DO

    IF EXISTS (SELECT
                6371 * acos(
                  cos(radians( b.Latitude ))
                * cos(radians( a.Latitude ))
                * cos(radians( b.Longitude ) - radians( a.Longitude ))
                + sin(radians( b.Latitude ))
                * sin(radians( a.Latitude ))) as distance
               FROM tmp a INNER JOIN new_table b
               WHERE a.ID < b.ID AND a.ID = maxTempID
               HAVING distance >= dist
               LIMIT 1) THEN

        INSERT INTO tmpOUT SELECT
            b.ID, b.Latitude, b.Longitude,
            6371 * acos(
                  cos(radians( b.Latitude ))
                * cos(radians( a.Latitude ))
                * cos(radians( b.Longitude ) - radians( a.Longitude ))
                + sin(radians( b.Latitude ))
                * sin(radians( a.Latitude ))) as distance,
            a.ID
        FROM tmp a INNER JOIN new_table b
        WHERE a.ID < b.ID AND a.ID = maxTempID
        HAVING distance >= dist
        ORDER BY a.ID, b.ID, distance
        LIMIT 1;

        INSERT INTO tmp SELECT ID, Latitude, Longitude, distance, toID FROM tmpOUT ORDER BY ID DESC LIMIT 1;
        SELECT ID into maxTempID FROM tmpOUT order by ID DESC LIMIT 1;

    ELSE

        SET breakLoop = TRUE;

    END IF;

END WHILE;

SELECT * FROM tmpOUT;

END$$
DELIMITER ;

to call it just use
CALL calcDistWithin(5.00)

A: I am not sure you want a pure sql solution or not.
I can only give a solution with other language.
I am assume to use id to determine the nearest node.
 List locat= new List();
  last = getTheLastRecord();
  locat.add(last);
  count = getTheCountOfRecord();
  for(int i=1;i<count;i++){//i = 1 because last record already read.
   Record r = getRecord(i);
   if(compareDistance(r,last)>5000){
     locat.add(r);
     last = r;
   }
 }

// finally the list of locat will contain every location you want.


text:
Q: Do physical results for spinors depend on the Clifford algebra representation? As I understand it, the Dirac equation and its solutions depend on the representation of the $\gamma$ matrices one uses. So if I were to use the Dirac representation I would get different mathematical solutions that if I used the Majorana representation.
In particular, Majorana fermions are their own antiparticles (because the solutions are real), so I am pretty sure that solutions in the Majorana representation are not physically equivalent to the ones in Dirac representation, which are not their own antiparticles.
If the only difference between $\gamma_{dirac}$ and $\gamma_{majorana}$ is a change in representation (meaning a different way to express the same $\gamma$ object), why are the solutions physically not equivalent? Why is the physics of the Dirac equation dependant on the representation of the $\gamma$ matrices?

A: The physics is exactly the same in both basis. The solution appears different to you only because you are using a different basis for the spinors, thus the numbers "in the upper square" and in the "lower square" of the spinors are different (base dependant).
Of course you can write Majorana spinors in chiral/Dirac basis (or whatever spinor basis you want). The only difference is that the Majorana condition is not going to be as simple as
$$\psi^* = \psi$$
The general Majorana condition (in a basis indepent form) is:
$$C\psi = \psi ^*$$
where $C$ is the charge conjugation operator. The point is that $C$ has different coordinate (read: entries) in different basis.
In particular, it's the $2\times 2$ identity in Majorana basis, hence the utility of this basis.
You can also find how a Majorana spinor looks in Dirac basis by using the fact that $C=-i\gamma^2$ in chiral basis.
If you want a reference I found useful, you can look at David Tong QFT lectures on his page.


text:
Q: Rekey special Keys on Ubuntu 18.04 I found here in askubuntu some tutorials how to rekey keyboard keys. That seems to be good for most keys. However in my Lenovo Ideapad 330 I have a side keyboard with keys such as back track and next track.
Also, I have the Home and End button fabric coded with the Fn key.
If I want to go to the end of the line I have to click Fn + Right arrow.
I want to re-key the back and next track keys so that they will have the function of the Home and End buttons.
The problem is that with those specific buttons in xev I don't see any ID for those keys. Here is what I get if I press back track:
FocusIn event, serial 37, synthetic NO, window 0x3800001,
    mode NotifyGrab, detail NotifyPointer

KeymapNotify event, serial 37, synthetic NO, window 0x0,
    keys:  1   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
           0   0   0   0   0   32  0   0   0   0   0   0   0   0   0   0

FocusOut event, serial 37, synthetic NO, window 0x3800001,
    mode NotifyUngrab, detail NotifyPointer

Can anyone suggest how to re-code such two keys?
Here is a photo of the keyboard.

Thanks

A: some media keys like this below pic, may produce the keycode or may not.. and they may function while you press it under xev command..

so the easy way to get the keycode of these keys is to logon to tty and run showkey -k and press the required key..
Here based on the chat.. the keycodes when showkey -k command is used in tty are 163 for Previous Track and 165 for Next Track

also the next/previous track give keycode 165 and 163

Sorry there is no Documentation for below:
keycode with showkey -k = xmodmap keycode - 8
keycode with xmodmap = showkey -k + 8

this means the keycodes we got with showkey -k 163 and 165 are equivalent to 171 and 173 with xmodmap
thus.. run xmodmap -pke and look for the keysymbols for keycodes 171 and 173..
later you can change whatever keysym you want to map.
for example:
xmodmap -e "keycode 171 = Home"
xmodmap -e "keycode 173 = End"

Further Reading:
https://askubuntu.com/a/1177739/739431
https://unix.stackexchange.com/a/52949

keycode 171 = XF86AudioNext NoSymbol XF86AudioNext
  keycode 173 = XF86AudioPrev NoSymbol XF86AudioPrev

Based on above unmodified keysym for the keycodes, you can run these below commands at every boot or simply add those to startup applications preferences
xmodmap -e "keycode 171 = Home XF86AudioPrev"
xmodmap -e "keycode 173 = End XF86AudioNext"

this means pressing the key alone gives Home/ End and pressing the key along with Shift modifier give track previous/ track next


text:
Q: Check outgoing network traffic In Ubuntu, how can I check what information is being sent through the network connection, what programs are doing it, and what sites is my computer connecting to?
I am not paranoid about security, but who knows?

A: You could save the outgoing data using tcpdump, but that is so much (and much of it is encrypted) that it won't be of any real use.
Better than finding out how you were burglarized after the fact is to make burglary harder... check what is installed, make sure it is up to date, delete unneeded stuff, get rid of non-official software (and repositories), configure the local firewall, do not disable SELinux or similar security, use good passwords, be careful with the websites you visit, all the normal hygiene.

A: I would recommend iptraf or
iftop if you don't need that much
functionality. From the iptraf homepage:

IPTraf is a console-based network statistics utility for Linux. It gathers a variety of figures such as TCP connection packet and byte counts, interface statistics and activity indicators, TCP/UDP traffic breakdowns, and LAN station packet and byte counts.
  Features

*

*An IP traffic monitor that shows information on the IP traffic passing over your network. Includes TCP flag information, packet and byte counts, ICMP details, OSPF packet types.

*General and detailed interface statistics showing IP, TCP, UDP, ICMP, non-IP and other IP packet counts, IP checksum errors, interface activity, packet size counts.

*A TCP and UDP service monitor showing counts of incoming and outgoing packets for common TCP and UDP application ports

*A LAN statistics module that discovers active hosts and shows statistics showing the data activity on them

*TCP, UDP, and other protocol display filters, allowing you to view only traffic you're interested in.

*Logging

*Supports Ethernet, FDDI, ISDN, SLIP, PPP, and loopback interface types.

*Utilizes the built-in raw socket interface of the Linux kernel, allowing it to be used over a wide range of supported network cards.

*Full-screen, menu-driven operation.

Screenshot of the iptraf main menu:

This is a screenshot if iftop:

A: Things like the bro IDS would analyse the traffic that goes through a network interface and log all sorts of things like connections and their traffic amount, protocols found and per-protocol information (like HTTP requests, mails sent, DNS requests, SSL certificate common names...). It wouldn't tell you what application did it though (except by logging user agents like for HTTP browsers). Because it sniffs the packet, it may miss some data if it can't keep up with the amount of data being exchanged (though it would report if it does).
conntrackd can be used to log every connection tracked by the stateful firewall and as much data was exchanged. It would work whatever the amount of data going through the system, but would not report data not going through the firewall like bridged traffic if excluded from netfilter or raw socket traffic.
You can also use firewall rules to log traffic using the LOG target or the ULOG one in combination with ulogd.
To log what pid does the connection, you'd need to use the audit system (auditd/auditctl), but that would be very verbose and not easily analysed.


text:
Q: Colspan in First Row of jsPDF AutoTable I am using the jsPDF AutoTable plugin (v3.1.1) and my table needs 4 columns but the first row of my form has only 2 columns so I need to use colspans in the first row. AutoTable doesn't seem to do colspans right if the first row doesn't have all the columns there will be. If my first row contains 4 blank cells, everything works fine but I get an unnecessary row on the top of my table. Here's some code that demonstrates the issue:
var doc = new jsPDF();
var desiredDefinition = [
  [{"content":"Field 1","colSpan":2}, {"content":"201901300654","colSpan":2}],
  [{"content":"Field 2"},{"content":"Field 3"},{"content":"Field 4"},{"content":"Field 5"}],
];
doc.autoTable({ body: desiredDefinition });

var workaroundDefinition = [
  [{"content":""},{"content":""},{"content":""},{"content":""}],
  [{"content":"Field 1","colSpan":2}, {"content":"201901300654","colSpan":2}],
  [{"content":"Field 2"},{"content":"Field 3"},{"content":"Field 4"},{"content":"Field 5"}],
];
doc.autoTable({ body: workaroundDefinition });
doc.save("table.pdf");

Here's a codepen with the issue: https://codepen.io/sirhcybe/pen/rgpKEJ
I played around with the columns property but couldn't find any way to tell AutoTable how many columns I need without creating an extra row. Is there a work around for this issue?

A: This has been marked as a bug in the jsPDF AutoTable repo:
https://github.com/simonbengtsson/jsPDF-AutoTable/issues/500
I did not find a decent workaround but since I am using my own fork of jsPDF AutoTable I was able to make the code fix described in the GitHub issue.
EDIT:
This was fixed as a bug in jsPDF-AutoTable v3.2.


text:
Q: Create Ansible inventory using Terraform I am trying to create Ansible inventory file using local_file function in Terraform (I am open for suggestions to do it in a different way)
module "vm" config:
resource "azurerm_linux_virtual_machine" "vm" {
  for_each                        = { for edit in local.vm : edit.name => edit }
  name                            = each.value.name
  resource_group_name             = var.vm_rg
  location                        = var.vm_location
  size                            = each.value.size
  admin_username                  = var.vm_username
  admin_password                  = var.vm_password
  disable_password_authentication = false
  network_interface_ids           = [azurerm_network_interface.edit_seat_nic[each.key].id]
  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

output "vm_ips" {
  value = toset([
    for vm_ips in azurerm_linux_virtual_machine.vm : vm_ips.private_ip_address
  ])
}

When I run terraform plan with the above configuration I get:
Changes to Outputs:
  + test = [
      + "10.1.0.4",
    ]

Now, in my main TF I have the configuration for local_file as follows:
resource "local_file" "ansible_inventory" {
  filename = "./ansible_inventory/ansible_inventory.ini"
  content = <<EOF
  [vm]
  ${module.vm.vm_ips}
EOF
}

This returns the error below:
Error: Invalid template interpolation value
on main.tf line 92, in resource "local_file" "ansible_inventory":
90:   content = <<EOF
91:   [vm]
92:   ${module.vm.vm_ips}
93: EOF
module.vm.vm_ips is set of string with 1 element
Cannot include the given value in a string template: string required.

Any suggestion how to inject the list of IPs from the output into the local file while also being able to format the rest of the text in the file?

A: If you want the Ansible inventory to be statically sourced from a file in INI format, then you basically need to render a template in Terraform to produce the desired output.
module/templates/inventory.tmpl:
[vm]
%{ for ip in ips ~}
${ip}
%{ endfor ~}

alternative suggestion from @mdaniel:
[vm]
${join("\n", ips)}

module/config.tf:
resource "local_file" "ansible_inventory" {
  content = templatefile("${path.module}/templates/inventory.tmpl",
    { ips = module.vm.vm_ips }
  )

  filename        = "${path.module}/ansible_inventory/ansible_inventory.ini"
  file_permission = "0644"
}

A couple of additional notes though:
You can modify your output to be the entire map of objects of exported attributes like:
output "vms" {
  value = azurerm_linux_virtual_machine.vm
}

and then you can access more information about the instances to populate in your inventory. Your templatefile argument would still be the module output, but the for expression(s) in the template would look considerably different depending upon what you want to add.
You can also utilize the YAML or JSON inventory formats for Ansible static inventory. With those, you can then leverage the yamldecode or jsondecode Terraform functions to make the HCL2 data structure transformation much easier. The template file would become a good bit cleaner in that situation for more complex inventories.


text:
Q: How do you count specific rows with PDO within a function? I see other tutorials on counting rows, but  none on counting specific rows $row[scope] for specific results.  How can this be done?
function counting(){
$query = "SELECT    *
          FROM      table";

$result->fetchAll($sql, $params);
$num_rows = count($result);

$counter = 0;

    //while($row = mysql_fetch_array($result)){ //old code
    foreach($result as $row){
        if($row[scope] == "all"){
            $counter++;
        }
    }
    $return = ($counter > 0)?TRUE:FALSE;
}

protected function fetchAll($sql, $params)
{
    $stmt = $this->dbh->prepare($sql);
    $stmt->execute($params);
    return $stmt->fetchALL(DatabaseAdapter::FETCH_ASSOC);
}

A: You need two functions for that.
Instead of fetchAll() you need just a general purpose function to run a query that returns PDOStatement which is essential.
protected function sql($sql, $params)
{
    $stmt = $this->dbh->prepare($sql);
    $stmt->execute($params);
    return $stmt;
}

in most cases it will work exactly the same way as your fetchAll() function without any changes in the code, but in case you explicitly need to get an array from it, you can always attach a fetchAll() to its call:
$result = $this->sql($sql, $params)->fetchAll();

And the second function you need is for the actual count:
function counting($value)
{
    $query = "SELECT count(*) FROM table WHERE scope = ?";
    return $this->sql($sql, [$value])->fetchColumn();
}

using such a function you can count (or detect the existence) for any scope.
Note that thanks to returned PDOStatement we are able to get another type of result - a scalar value instead of array.

upgrading While loops can be a pain sometimes....

You see, when SQL and PDO are properly used, you scarcely need a while loop at all


text:
Q: get_current_language_bidi not working as expected I have added django.template.context_processors.i18n to context_processors,
I have added django.middleware.locale.LocaleMiddleware to middleware_classes, and I'm nearly certain this is unrelated, but just in case I also added url(r'^i18n/', include('django.conf.urls.i18n')) to urlpatterns.
I created a .po file successfully, compiled a .mo file, and the translations (where there are strings to be translated) are loading fine.
However, when I run the following code:
{% extends "page.html" %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% get_current_language_bidi as LANGUAGE_BIDI %}
{% block title %}{% trans "translation test" %}{% endblock %}
{% block page_main_content %}

The current language is {{ LANGUAGE_CODE }}

      {% if LANGUAGE_BIDI %}

The current language is bidirectional

      {% else %}

The current language is not bidirectional

      {% endif %}

{% endblock %}

What I get is:

*

*The current language is he_IL

*The current language is not    bidirectional

I would assume I'm importing something incorrectly or have misconfigured settings, but get_current_language is (clearly) working fine. So why is django incorrectly returning False for get_current_language_bidi?

A: I think there is something wrong with the source of your language preference. According to the documentation, the expected separator is a dash. So Django may think that he_IL is a unknown language, and as such flags it not bidirectional by default.
You should find out where this locale comes from, and make sure it gives he-il or he instead of he_IL.


text:
Q: Multi-pass variable expansion, is it possible? If you have a bash variable that contains other variables, is it possible to "double" expand it as part of a command?
For example:
# Example #1
# ----------
# We define our first variable
TOP_LEVEL=/usr;

# Then use it (trivially) to set the values of other variables when executing a command
INC_DIRS="-I$TOP_LEVEL/include -I$TOP_LEVEL/local/include" \
LIB_DIRS="-L$TOP_LEVEL/lib -L$TOP_LEVEL/local/lib" \
./my_command

This is fairly self-explanatory. Now let's expand this example to the problem scenario:
# Example #2
# ----------
# We define our first variable
TOP_LEVEL=/usr;

# Notice the use of single quotes below, to defer expansion of `TOP_LEVEL` to some point
# later - the time when DEFERRED_EVAL_INC_DIRS will actually be used
DEFERRED_EVAL_INC_DIRS='-I$TOP_LEVEL/include -I$TOP_LEVEL/local/include'
... # Other stuff happens here that may change the value of TOP_LEVEL, e.g.:
TOP_LEVEL=/usr/confused
# Since we used single quotes to define DEFERRED_EVAL_INC_DIRS, it is not affected

# Now we want to execute a command like before, and pass it three variables,
# INC_DIRS, LIB_DIRS, and FOO_LIB_INC_DIRS, in their fully expanded form:
INC_DIRS="-I$TOP_LEVEL/include -I$TOP_LEVEL/local/include" \
LIB_DIRS="-L$TOP_LEVEL/lib -L$TOP_LEVEL/local/lib" \
FOO_LIB_INC_DIRS="$DEFERRED_EVAL_INC_DIRS" ./my_command

The expansion of INC_DIRS and LIB_DIRS is trivial, they become:
INC_DIRS='-I/usr/confused/include -I/usr/confused/local/include'
LIB_DIRS='-L/usr/confused/lib -I/usr/confused/local/lib'

The problematic expansion is with FOO_LIB_INC_DIRS. The desired (fully expanded value should be):
FOO_LIB_INC_DIRS='-I/usr/confused/include -I/usr/confused/local/include'

..., finally expanding the embedded $TOP_LEVEL variables used in the value of DEFERRED_EVAL_INC_DIRS to their present value of /usr/confused. So, there is a second evaluation pass needed for that variable and it has spaces in its value that need to be preserved as well, just to make life even more difficult.
Had DEFERRED_EVAL_INC_DIRS referred to a single variable by name (and contained no other characters), the ${!DEFERRED_EVAL_INC_DIRS} indirect variable reference construct could have been used. But, this is a more complicated scenario with surrounding text and multiple uses of the variable that needs to be expanded.
I tried playing with bash's eval, but could not get this expansion to happen in one command line and without introducing additional variables, basically as an expansion of the code segment above. The full desired expanded result is:
INC_DIRS='-I/usr/confused/include -I/usr/confused/local/include' \
LIB_DIRS='-L/usr/confused/lib -I/usr/confused/local/lib' \
FOO_LIB_INC_DIRS='-I/usr/confused/include -I/usr/confused/local/include' \
./my_command

Is there a simple change or set of changes that can be made to the command invocation in Example #2 in order for the full expansion to occur?
Update: This is neither a duplicate (at least in any obvious way) of similar questions, due to the more complex deferred expansion involved, while preserving word boundaries across spaces. If the solution seems obvious to you, please post it as an answer and a change to:
INC_DIRS="-I$TOP_LEVEL/include -I$TOP_LEVEL/local/include" \
LIB_DIRS="-L$TOP_LEVEL/lib -L$TOP_LEVEL/local/lib" \
FOO_LIB_INC_DIRS="$DEFERRED_EVAL_INC_DIRS" ./my_command

..., to expand the variable DEFERRED_EVAL_INC_DIRS fully, respecting word boundaries properly, and producing:
INC_DIRS='-I/usr/confused/include -I/usr/confused/local/include' \
LIB_DIRS='-L/usr/confused/lib -I/usr/confused/local/lib' \
FOO_LIB_INC_DIRS='-I/usr/confused/include -I/usr/confused/local/include' \
./my_command

..., preferably without creating a subshell if possible (and without breaking up this command into multiple commands or adding temporary variables, which would make this a much simpler case).

A: You can use eval here but you need to call it when you set the "lower level" vars, e.g. try this:
TOP_LEVEL="/usr"
eval "INC_DIRS='-I$TOP_LEVEL/include -I$TOP_LEVEL/local/include'"
echo TOP_LEVEL: $TOP_LEVEL
echo INC_DIRS: $INC_DIRS

And of course be aware of the dangers of using eval e.g. here.
Also, as mentioned in the followup comments, you could also treat the "template" as a file that is to be evaled, e.g. try this:
$ TOP_LEVEL="/usr"
$ cat template.sh
INC_DIRS='-I$TOP_LEVEL/include -I$TOP_LEVEL/local/include'
$ eval $(<template.sh)
$ echo $INC_DIRS
-I$TOP_LEVEL/include -I$TOP_LEVEL/local/include


text:
Q: warning: compound assignment with 'volatile'-qualified left operand is deprecated I have some c++ project in my hands, before this problem arrive i have c++17 flag in my makefile after i tried c++20 this warnings shows up.
After a short look i dont understand what is the problem, after a C++20 flag this what i get from compiler ;
main.cpp: In function 'void heartbeat(LPHEART, int)':
main.cpp:185:20: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile]

This is the code cause of the warning ;
volatile int    num_events_called = 0;

void heartbeat (LPHEART ht, int pulse)
{
    DWORD t;

    t = get_dword_time();
    num_events_called += event_process (pulse);   // LINE 185 IS HERE <<<<<
    s_dwProfiler[PROF_EVENT] += (get_dword_time() - t);

    t = get_dword_time();

    if (!(pulse % ht->passes_per_sec))
    {

        if (!g_bAuthServer)
        {
            TPlayerCountPacket pack;
            pack.dwCount = DESC_MANAGER::instance().GetLocalUserCount();
            db_clientdesc->DBPacket(HEADER_GD_PLAYER_COUNT, 0, &pack, sizeof(TPlayerCountPacket));
        }
        else
        {
            DESC_MANAGER::instance().ProcessExpiredLoginKey();
        }

        {
            int count = 0;

            if (save_idx < g_vec_save.size())
            {
                count = MIN(100, g_vec_save.size() - save_idx);

                for (int i = 0; i < count; ++i, ++save_idx)
                    db_clientdesc->DBPacket(HEADER_GD_PLAYER_SAVE, 0, &g_vec_save[save_idx], sizeof(TPlayerTable));

                sys_log(0, "SAVE_FLUSH %d", count);
            }
        }
    }

    if (!(pulse % (passes_per_sec + 4)))
        CHARACTER_MANAGER::instance().ProcessDelayedSave();

    if (!(pulse % (passes_per_sec * 5 + 2)))
    {
        ITEM_MANAGER::instance().Update();
        DESC_MANAGER::instance().UpdateLocalUserCount();
    }

    s_dwProfiler[PROF_HEARTBEAT] += (get_dword_time() - t);

    DBManager::instance().Process();
    AccountDB::instance().Process();
    CPVPManager::instance().Process();

    if (g_bShutdown)
    {
        if (thecore_pulse() > g_shutdown_disconnect_pulse)
        {
            const DESC_MANAGER::DESC_SET & c_set_desc = DESC_MANAGER::instance().GetClientSet();
            std::for_each(c_set_desc.begin(), c_set_desc.end(), ::SendDisconnectFunc());
            g_shutdown_disconnect_pulse = INT_MAX;
        }
        else if (thecore_pulse() > g_shutdown_disconnect_force_pulse)
        {
            const DESC_MANAGER::DESC_SET & c_set_desc = DESC_MANAGER::instance().GetClientSet();
            std::for_each(c_set_desc.begin(), c_set_desc.end(), ::DisconnectFunc());
        }
        else if (thecore_pulse() > g_shutdown_disconnect_force_pulse + PASSES_PER_SEC(5))
        {
            thecore_shutdown();
        }
    }
}

What should i do for beat this warning ? Best regards.


text:
Q: udisksctl mount a different subvolume of an already mounted btrfs partition I have a btrfs partition with several subvolumes, one of which is /. I have another subvolume with some other stuff that I also want to mount, but trying to mount it with udisksctl:
udisksctl mount -b /dev/mapper/container -o subvol=other

gives me this error:
Error mounting /dev/dm-0: GDBus.Error:org.freedesktop.UDisks2.Error.AlreadyMounted: Device /dev/dm-0 is already mounted at `/'.

It mounts fine with mount /dev/mapper/container -o subvol=other /mnt. Is there anything I can do to get this to work with udisksctl?

A: First read the man page (man udisksctl)! It says you should use --options.
If this is not working, then subvol is considered an unsafe option (IMHO, it should). If so, you can use the mount command or you can set the options directly in /etc/fstab for a given mount point.


text:
Q: Ошибка ': not a valid identifiere при выполнении простого bash-скрипта Код скрипта:
#!/bin/bash
read -rp "Ab number:   " Number
printf "Number: %s\\n" "$Number"
read -rp "Ab name   " Name
printf "Name:: %s\\n" "$Name"

Запуск:
$ bash an.sh
Ab number:   78544
': not a valid identifierber
Number:
Ab name   Test
': not a valid identifiere
Name::

Лишних управляющих символов нет, проверила в vi.
С чем связана эта ошибка и как исправить?
И как читать пользовательский ввод, но обойтись без printf, если значение переменной потом не нужно выводить на экран?
Спасибо.

A: Все-таки проблема была в символах перевода строк CRLF
Заменила все на LF, заработало


text:
Q: Cv-qualifications of prvalues in C++14 It appears that C++11 and C++14 treat cv-qualifications of prvalues differently.
C++11 sticks to the "classic" approach that has been around since C++98: according to 3.10/4 "non-class prvalues always have cv-unqualified types".
C++14 contains a similar wording in 3.10/4, but it is presented as a note: "[Note: class and array prvalues can have cv-qualified types; other prvalues always have cv-unqualified types. See Clause 5. —end note ]"
And in Clause 5 it says:

6 If a prvalue initially has the type "cv T," where T is a cv-unqualified non-class, non-array type, the type of the expression is adjusted to T prior to any further analysis.1

This 5/6 entry is new in C++14. It now treats cv-qualifications of prvalues using the same approach that has always been used with results of reference type (see 5/5).
What could be the reason for this change? C++11 and before denied non-class prvalues the right to have any cv-qualifications. C++14 says that non-class, non-array prvalues can have cv-qualifications, but these cv-qualifications are discarded prior to any further analysis.
My guess would be that there are some new (for C++14) language features that can somehow "see" cv-qualifications of prvalues under the right circumstances (before the aforementioned adjustment takes place). Do they exist? And if so, what are these features?2

The question originated from following context: imagine a compiler that internally implements hidden parameter this of class X as a variable of type X *const. Since the compiler is required to expose this as a prvalue, that const should not lead to any problems in C++11 (or before), where scalar prvalues are never cv-qualified. But what about C++14? If the very same compiler exposes that this as a prvalue of type X *const, could it possibly lead to problems?

1 There appears to be a contradiction between 5/6 and the note in 3.10/4 in C++14, but notes are not normative anyway. And I'm using a draft version of the text.
2 My initial guess was decltype. And I even thought that I found the answer when I tried
std::cout << std::is_same<decltype((const int) 0), const int>::value << std::endl;

in GCC, which outputs 1. However, seeing that Clang and VC++ output 0 (and that the spec of decltype does not seem to support this behavior) I'm inclined to believe that this is just a bug in GCC (starting from 6.1)

A: According to the commit on github, this was done to resolve CWG1261: Explicit handling of cv-qualification with non-class prvalues
Based on comments to the question it seems there was room for surprising variations in type category of this (formally a prvalue) and that gcc formerly and MSVC currently instead used a const lvalue.
The wording tightens up the hole to be explicit that, e.g., even if this is by some compiler-internal magic a prvalue of type X* const, prior to any further analysis it is adjusted to X*.
Similarly, your given example does look like a gcc bug. Possibly decltype isn't looking at the value type before applying the c-style cast.
The reason it's now a note in [basic.lval]/4 is that it's now a consequence of the new text in [expr]/6, rather than specifying the rule in [basic.lval]/4.
Full credit to T.C. for having basically answered this in the comments on the question, including the reference to the gcc bug-fix, and various other examples of previously under-specified behaviours for cv-qualified non-class non-array prvalues.


text:
Q: Dogtag CA after installation After Dogtag 10 installation(step by step by https://www.youtube.com/watch?v=C3eElJAz7lU) when I open Admin (https://localhost.localdomain:8443/ca/agent/ca/) I get following error

Problem Processing Your Request
The Certificate Manager encountered an unexpected error while
  processing your request. The following is a detailed message of the
  error that occurred.
You did not provide a valid certificate for this operation

Please consult your local administrator for further assistance. The
  Certificate System logs may provide further information.

In tutorials for older versions of dogtag I found that after configuration with pkicreate command it shows link to /ca/agent with some param "?pin=1asdkajsjk1421" but i newer version of dogtag I don't have that command and all configuration is done by pkispawn
pkispawn create 3 files:
ca_admin.cert ,
ca_admin.cert.der ,
ca_admin_cert.p12
but when I add them to firefox and to /etc/pki/ca-trust/sources/anchors and run update-ca-trust I still get the same error

A: I have add p12 private key to firefox.
that help me a lot: http://docs.oracle.com/cd/E28385_01/en/E28378/html/STA102_Config_Iden_Mgmt_RACF.09.08.htm


text:
Q: Awesome CV template: how to add two phone numbers I've been use this template for almost 2 years and it is just really beautiful and versatile.
Can somebody tell me how to add two phone numbers? I tried:
\mobile{US +1 (111) 111-1111}
\mobile{IT +39 (111) 1111111}

but this, as expected, gives me just the second phone number. How can I have both with the same icon displayed (i.e. they're both mobile)?
Thanks,
Eleonora

A: I had the same issue a few months ago, tried a few things but did not manage to get it. I settled for a workaround. Instead of having two mobile phone icons I added both numbers in the \mobile{} field and added a small flag in front of them (.svg flags of all states can be found on WikimediaCommons). A few spaces and raiseboxes were needed to get the desired output.
Code:
\mobile{\ \raisebox{-0.5pt}{\includesvg[height=6pt]{Flag_of_the_United_States}}\ (+1) 234-5678 %
\ \raisebox{-0.5pt}{\includesvg[height=6pt]{Flag_of_Italy}} \ (+39) 23456789}

Output:

The same thing can be applied to the email address if necessary.


text:
Q: Bootstrap datepicker - return inside a foreach function I am using bootstrap datepicker and I am using beforeShowDay to select a few days to be enabled while disabling every date that is not the ones I selected.
    beforeShowDay : function(date) {
      var date1 = new Date([2017, 02, 23]);
      var date2 = new Date([2017, 04, 14]);
      var date3 = new Date([2017, 06, 12]);
      var dateArray = [date1, date2, date3];

      if (date.getTime() != date1.getTime() && date.getTime() != date2.getTime() && date.getTime() != date3.getTime()) {
        return {
          enabled: false
        };
      }
    }

I have this code that works, but I would like to convert into a foreach function as such :
    beforeShowDay : function(date) {
      var date1 = new Date([2017, 02, 23]);
      var date2 = new Date([2017, 04, 14]);
      var date3 = new Date([2017, 06, 12]);
      var dateArray = [date1, date2, date3];

      dateArray.forEach(doBleh());
      function doBleh(element) {
        if (datate.getTime() != element.getTime()) {
          return {
            enabled: false
          };
        }
      }
      return doBleh;
    }

This last piece of code does not work, I can't seem to figure out.
Any help would be appreciated

A: I can suggest you to use Array.prototype.indexOf():
beforeShowDay : function(date) {
    var date1 = new Date([2017, 02, 23]);
    var date2 = new Date([2017, 04, 14]);
    var date3 = new Date([2017, 06, 12]);
    var dateArray = [date1.getTime(), date2.getTime(), date3.getTime()];

    if (dateArray.indexOf(date.getTime()) == -1) {
        return {
            enabled: false
        };
    }
}

From MDN: The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.

In your code, this line:
dateArray.forEach(doBleh());

is wrong.
Instead to pass a callback function you are passing the result of a function execution.
Change it to:
dateArray.forEach(doBleh);

In any case a return inside the forEach is not the return of your beforeShowDay  function.


text:
Q: What the difference between google.protobuf.Any and google.protobuf.Value? I want th serialize int/int64/double/float/uint32/uint64 into protobuf, which one should I use ? which one is more effective ?
For example :
message Test {
    google.protobuf.Any   any   = 1;   // solution 1
    google.protobuf.Value value = 2;   // solution 2
};

message Test {                         // solution 3
   oneof Data {
        uint32   int_value    = 1;
        double   double_value = 2;
        bytes    string_value = 3;
        ...
   };
};

A: In your case, you'd better use oneof.
You can not pack from or unpack to a built-in type, e.g. double, int32, int64, to google.protobuf.Any. Instead, you can only pack from or unpack to a message, i.e. a class derived from google::protobuf::Message.
google.protobuf.Value, in fact, is a wrapper on oneof:
message Value {
  // The kind of value.
  oneof kind {
    // Represents a null value.
    NullValue null_value = 1;
    // Represents a double value.
    double number_value = 2;
    // Represents a string value.
    string string_value = 3;
    // Represents a boolean value.
    bool bool_value = 4;
    // Represents a structured value.
    Struct struct_value = 5;
    // Represents a repeated `Value`.
    ListValue list_value = 6;
  }
}

Also from the definition of google.protobuf.Value, you can see, that there's no int32, int64, or unint64 fields, but only a double field. IMHO (correct me, if I'm wrong), you might lose precision if the the integer is very large. Normally, google.protobuf.Value is used with google.protobuf.Struct. Check google/protobuf/struct.proto for detail.


text:
Q: How can I remove the gaps and make it a single stack while visualizing in Plotly? I am visualizing some data and I need to remove the gaps between the cells (It can be seen clearly in the picture).  The white gaps between red and blue cells/elements.

The red represents 'no', while the blue, 'yes'. The code snippet is:
fig = px.bar(
        data,
        x = policy_type,
        y = 'State',
        color = policy_type,
        title = title
)

A: This is mentioned in the plotly documentation. You can use histogram to avoid the striped look. It has a similar call signature to bar:
fig = px.histogram(
        data,
        x = policy_type,
        y = 'State',
        color = policy_type,
        barmode = 'group',
        title = title
)


text:
Q: Invoking bash commands in makefile Inside of a makefile, I'm trying to check if fileA was modified more recently than fileB. Using a few prior posts (this and this) as references, I've come up with this as an attempt to store the time since last file modification as a variable:
(I'd rather this be in a function outside of a make recipe, but one step at a time.)
    .PHONY: all clean

    all      : (stuff happens here)

    radio    :
              BASE_MOD_TIME="$( expr $(date +%s) - $(date +%s -r src/radio_interface/profile_init.c) )"
              @echo "$(BASE_MOD_TIME)"

I thought that I would be assigning the output of the expr command to a variable, BASE_MOD_TIME, but the output is:
    bash-4.1$
    BASE_MOD_TIME=""
    echo ""

What am I doing wrong here? Simple attempts to save the output of ls -l also didn't work like this.

A: Make variables are normally global, and you don't normally set make variables in a recipe.  A recipe is simply a list of commands to be executed by a shell, and so what looks like a variable assignment in a recipe is a shell variable assignment.
However, each line in a make recipe is run in its own shell subprocess. So a variable set in one line won't be visible in another line; they are not persistent. That makes setting shell variables in recipes less useful. [Note 1]
But you can combine multiple lines of a recipe into a single shell command using the backslash escape at the end of the line, and remembering to terminate the individual commands with semicolons (or, better, link them with &&), because the backslash-escaped newline will not be passed to the shell. Also, don't forget to escape the $ characters so they will be passed to the shell, rather than being interpreted by make.
So you could do the following:
radio:
    @BASE_MOD_TIME="$$( expr $$(date +%s) - $$(date +%s -r src/radio_interface/profile_init.c) )"; \
    echo "$$BASE_MOD_TIME"; \
    # More commands in the same subprocess

But that gets quite awkward if there are more than a couple of commands, and a better solution is usually to write a shell script and invoke it from the recipe (although that means that the Makefile is no longer self-contained.)
Gnu make provides two ways to set make variables in a recipe:
1. Target-specific variables.
You can create a target-specific variable (which is not exactly local to the target) by adding a line like:
target: var := value

To set the variable from a shell command, use the shell function:
target: var := $(shell ....)

This variable will be available in the target recipe and all dependencies triggered by the target. Note that a dependency is only evaluated once, so if it could be triggered by a different target, the target-specific variable might or might not be available in the dependency, depending on the order in which make resolves dependencies.
2. Using the eval function
Since the expansion of recipes is always deferred, you can use the eval function inside a recipe to defer the assignment of a make variable. The eval function can be placed pretty well anywhere in a recipe because its value is the empty string. However, evaling a variable assignment makes the variable assignment global; it will be visible throughout the makefile, but its value in other recipes will depend, again, on the order in which make evaluates recipes, which is not necessarily predictable.
For example:
radio:
    $(eval var = $(shell ...))

Notes:

*

*You can change this behaviour using the .ONESHELL: pseudo-target, but that will apply to the entire Makefile; there is no way to mark a single recipe as being executed in a single subprocess. Since changing the behaviour can break recipes in unexpected ways, I don't usually recommend this feature.

A: What's wrong with this?
fileB: fileA
    @echo $< was modified more recently than $@

A: Instead of forcing the makefile to do all of the heavy lifting via some bash commands, I just called a separate bash script. This provided a lot more clarity for a newbie to bash scripting like myself since I didn't have to worry about escaping the current shell being used by make.
Final solution:
    .PHONY: all clean

    all      : (stuff happens here)

    radio    :
            ./radio_init_check.sh
            $(MKDIR_P) $(OBJDIR)
            make $(radio_10)

with radio_init_check.sh being my sew script.


text:
Q: Can't Wireshark the USB bus: permissions I am trying to monitor my USB traffic using Wireshark.
The docs say "just do sudo modprobe usbmon". Well, that doesn't work:
vorac@laptop:~$ sudo modprobe usbmon
[sudo] password for vorac:
vorac@laptop:~$ dumpcap -D
1. wlan0
2. nflog
3. nfqueue
4. eth1
5. any
6. lo (Loopback)

If I start Wireshark as root, the interfaces are there:
vorac@laptop:~$ sudo dumpcap -D
1. wlan0
2. nflog
3. nfqueue
4. eth1
5. usbmon1
6. usbmon2
7. any
8. lo (Loopback)

Wireshark Version 1.10.6 (v1.10.6 from master-1.10)
Ubuntu 14.04.3 LTS
How do I run Wireshark as regular user, being able to capture USB traffic?


text:
Q: Webapp2 Create an index page for a subset of Handlers I am in the process of writing some js unit tests (using qunit) for my python webapp2 application, and I wish to create an index page of all of my unit test suites.  Each unit test suite is mapped to a single url and to a single handler object.  Each of these handler objects inherits from a common base class TestHandler.  Here is the handler to url mapping.
app = webapp2.WSGIApplication([
    webapp2.Route(r'/test',
        handler=TestHandler,
        name='testindex'),
    webapp2.Route(r'/test/datastream',
        handler=TestStreamHandler,
        name='datastream'),
    webapp2.Route(r'/test/timecontrol',
        handler=TestTimeControlHandler,
        name='timecontrol'),
], config=webapp2_config)

Is there a way to automatically read what test urls are available, and then generate an index html page containing links to all of the unit test suite pages?