Apache Virtual host document root AND proxy file access forbidden

Question: I am setting up my personal domain and I have this config:
ServerAdmin firstname.lastname@example.com

Listen 80
<VirtualHost *:80>
    DocumentRoot "/www/brentc.in"
    ServerName brentc.in
    ServerAlias www.brentc.in
</VirtualHost>

Listen 443 https

SSLPassPhraseDialog builtin

SSLSessionCache         shmcb:/opt/rh/httpd24/root/var/run/httpd/sslcache(512000)
SSLSessionCacheTimeout  300

SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin

SSLCryptoDevice builtin

<VirtualHost *:443>
    ServerName brentc.in
    ServerAlias www.brentc.in
    DocumentRoot /www/brentc.in/
    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/brentc.in/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/brentc.in/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/brentc.in/fullchain.pem
</VirtualHost>

<VirtualHost *:443>
    ServerName atlassian.brentc.in
    ServerAlias www.atlassian.brentc.in
    DocumentRoot /www/atlassian.brentc.in/

    Options Indexes FollowSymLinks Includes ExecCGI

    SSLProtocol all -SSLv2

    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>

    ProxyRequests Off
    ProxyPreserveHost On

    ProxyPass       /jira/secure/admin/IntegrityChecker.jspa    http://localhost:8081/jira/secure/admin/IntegrityChecker.jspa timeout=3600
    ProxyPassReverse    /jira/secure/admin/IntegrityChecker.jspa        http://localhost:8081/jira/secure/admin/IntegrityChecker.jspa

    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/brentc.in/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/brentc.in/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/brentc.in/fullchain.pem

    BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    <Location /jira>
        Header set Access-Control-Allow-Origin "*"
        Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
        ProxyPass               http://localhost:8081/jira retry=0
        ProxyPassReverse        http://localhost:8081/jira
        SetOutputFilter DEFLATE
    </Location>
</VirtualHost>

For the first domain (brentc.in) I can access index.html just fine.
For the second domain (atlassian.brentc.in) it shows the apache sample (test 123) page and when I explicitly go to index.html it says I'm not allowed to access the file.
My file permissions are exactly the same as the working index.html. Am I missing something here?
The atlassian.brentc.in is also a proxy to a behind the scenes tomcat server. My intention is, when you go to atlassian.brentc.in it shows you a landing page. Then from there you can go to atlassian.brentc.in/jira.
The error_log contains this:
[Wed Jun 14 10:43:47.714099 2017] [authz_core:error] [pid 4399] [client <ip>:58299] AH01630: client denied by server configuration: /www/atlassian.brentc.in/index.html
[Wed Jun 14 10:43:47.952670 2017] [authz_core:error] [pid 4399] [client <ip>:58299] AH01630: client denied by server configuration: /www/atlassian.brentc.in/favicon.ico, referer: https://atlassian.brentc.in/index.html

Comment: I'm looking at https://stackoverflow.com/questions/18392741/apache2-ah01630-client-denied-by-server-configuration now.
Answer: i think you need to add something like this
<Directory "your/sample/directory">
    # AllowOverride All      # Deprecated
    # Order Allow,Deny       # Deprecated
    # Allow from all         # Deprecated

    # --New way of doing it this is the important part
    Require all granted
</Directory>

Comment: Yes, thanks! I didn't think of googling the error code of the logs, and that gave me the same anwer as yours!


MS SQL SERVER 2005 express - Can't find import/export wizard

Question: I have installed ms sql 2005 express i have installed the management studio, i tried(all components already installed) to install the ms sql 2005 express toolkit.
I've searched for the .exe and for the option inside the management studio, and i simply can't find it!
Someone could help me please?
Maybe with an alternative way to export my db(i have to import it on another pc)?
Comment: Create a backup and then restore on the other machine.
Comment: i have no idea how (got some random errors) but i managed to get my db on the other pc. thx
Answer: When you expand the list of databases, right-click on the database you need exported, and under tasks near the bottom are the import data and export data options (At least, this is the case in SSMS 2012):

However, as per my comment, if all you need to do is migrate a database, simply create a backup of the database, and restore it on the other machine.


Using query arguments with operators for collections

Question: In GraphQL how does one best design an "API query language" to filter collections of items with operators?
For example in REST you can have parameters such as
/family/people?height="192"&weight[]=">=65"&weight[]="<=100"
In GraphQL it seems to go against best practice to implment query logic outside of the GraphQL layer as such:
{
    family {
        people(height: 192, weight: ['>=65','<=100']) {
            givenName
            surName
            age
        }
    }
}

Although it seems overly verbose and not very DRY to do the following:
{
    family {
        people(height: 192, weightGte: '65', weightLte: '100') {
            givenName
            surName
            age
        }
    }
}

Is there a convention for query arguments that have operators such as >  <  >=  <=  == != * ?
Answer: I wouldn't say it's a graphQL issue per se, but rather - the approach you'll choose to utilize onto your solution.
Assuming we're talking JS (considering your tags), I'd go with wrapping your query with a function, similar to:
function getPeople(height, weight) {
  let [0: weightGte, 1: weightLte ] = weight;
  return {
    family {
        people(height, weightGte, weightLte) {
            givenName
            surName
            age
        }
    }
  }
}

Depending on your flavour of js and the way you create your query document, you can simply call it with different arguments.
If you're reusing the same arguments, then you can cache the document and use the cached version instead:
const commonUseCase = getPeople(192, [65, 100]);

//elsewhere in your code

query(commonCase).then(...


In general, what ways are there to show if 2 groups are isomorphic?

Question: I take it that if the number of elements of a given order n is not the same between 2 groups, then they are definitely not isomorphic. So for example if I need to show that $C_{25}$ is not isomorphic to $C_5$ x $C_5$, I need to find some $n \le 25$ for which the number of elements of order n is not the same between the 2 groups. Right?
But if I have 2 groups with the exact same number of elements of every possible order n, it's still not sufficient to establish they really are isomorphic, right? Because I need to show the mapping between them is bijective(?) So if I want to show 2 groups are isomorphic I would need to explicitly find a bijective mapping for each element that preserves the multiplication rules??
Comment: You're correct.  Clearly the number of elements of each order can be calculated in polynomial time in the size of the group, and so the comparison between two groups by this criteria can be carried out in polynomial time, too.  But GROUP-ISOMORPHISM is not known to have a polynomial-time solution; see, e.g., this column: https://rjlipton.wordpress.com/2011/10/08/an-annoying-open-problem/.
Answer: Yes, that's pretty much it.  It's easy to show that two groups are not isomorphic by showing that something invariant under isomorphism is different in the two groups.  Like the number of elements, or the number of elements of a specific order, or the number of subgroups of a certain order, etc.
But in general, the only (sure-fire) way to show two groups are isomorphic is to exhibit an isomorphism between them.


How to get the probability of bigrams in a text of sentences?

Question: I have a text which has many sentences. How can I use nltk.ngrams to process it?
This is my code:
   sequence = nltk.tokenize.word_tokenize(raw)
   bigram = ngrams(sequence,2)
   freq_dist = nltk.FreqDist(bigram)
   prob_dist = nltk.MLEProbDist(freq_dist)
   number_of_bigrams = freq_dist.N()

However, the above code supposes that all sentences are one sequence. But, sentences are separated, and I guess the last word of one sentence is unrelated to the start word of another sentence. How can I create a bigram for such a text? I need also prob_dist and number_of_bigrams which are based on the `freq_dist.
There are similar questions like this What are ngram counts and how to implement using nltk? but they are mostly about a sequence of words.
Answer: You can use the new nltk.lm module. Here's an example, first get some data and tokenize it:
import os
import requests
import io #codecs

from nltk import word_tokenize, sent_tokenize

# Text version of https://kilgarriff.co.uk/Publications/2005-K-lineer.pdf
if os.path.isfile('language-never-random.txt'):
    with io.open('language-never-random.txt', encoding='utf8') as fin:
        text = fin.read()
else:
    url = "https://gist.githubusercontent.com/alvations/53b01e4076573fea47c6057120bb017a/raw/b01ff96a5f76848450e648f35da6497ca9454e4a/language-never-random.txt"
    text = requests.get(url).content.decode('utf8')
    with io.open('language-never-random.txt', 'w', encoding='utf8') as fout:
        fout.write(text)

# Tokenize the text.
tokenized_text = [list(map(str.lower, word_tokenize(sent)))
              for sent in sent_tokenize(text)]

Then the language modelling:
# Preprocess the tokenized text for 3-grams language modelling
from nltk.lm.preprocessing import padded_everygram_pipeline
from nltk.lm import MLE

n = 3
train_data, padded_sents = padded_everygram_pipeline(n, tokenized_text)

model = MLE(n) # Lets train a 3-grams maximum likelihood estimation model.
model.fit(train_data, padded_sents)

To get the counts:
model.counts['language'] # i.e. Count('language')
model.counts[['language']]['is'] # i.e. Count('is'|'language')
model.counts[['language', 'is']]['never'] # i.e. Count('never'|'language is')

To get the probabilities:
model.score('is', 'language'.split())  # P('is'|'language')
model.score('never', 'language is'.split())  # P('never'|'language is')

There's some kinks on the Kaggle platform when loading the notebook but at some point this notebook should give a good overview of the nltk.lm module https://www.kaggle.com/alvations/n-gram-language-model-with-nltk
Comment: Why NLTK does not provide the function `model.score(sentence)`? It is not super-trivial to compute the score of a sentence if we use backoff for example.
Comment: Thanks, how can I install `nltk.lm` via `pip`. It seems there is no such module when I install `nltk`
Comment: `pip install -U nltk>=3.4`
Comment: Could you please take a look at this related quesiton: https://stackoverflow.com/questions/54999684/why-perplexity-for-padded-vocabulary-is-infinitive-for-nltk-lm-bigram


mithril avoiding to reload image

Question: I am using mithril 0.2.2-rc.1. I saw in the routing documentation:
Routing is a system that allows creating Single-Page-Applications (SPA), i.e. applications that can go from one page to another without causing a full browser refresh.
Indeed when I am routing to the same page with different parameter only the part that I want to change is refresh expect this :
m("img[src='assets/images/logo.png'][alt=''][width='100']")

I can see in the network communication that the image is reloaded (another GET request).
Is there a way to avoid that?
route.js
m.route.mode = "pathname";

m.route(document.getElementById('app'), '/', {
    '/': main,

    '/modelling/:level': main

})

Answer: It's difficult to see how the two pieces of code fit together, but two things suggest themselves:

Every change of route (even if that change results in the same route entry, eg /modelling/x to /modelling/y) will result in the entire DOM being regenerated. You can prevent this behaviour by calling m.redraw.strategy( 'diff' ) in each route component's controller.
Repeatedly requesting the same resource does not lead to extra calls to the server: a multi page site with every page requesting the same JS and CSS will only load those resources once, and will hit browser cache on subsequent requests. Thus repeatedly asking for the same image resource will not generate any new calls to the server.
Answer: If you check the documentation of the m method you will see that the config attribute lets you retain elements across redraws. So this should work for you:
m('img', {config: function persist(el, isInit, context)}) {
    context.retain = true;
}

mithril avoiding to reload image


How do I make my website display properly and get my navbar to display under the logo on smaller screens? Currently shows fine on desktops

Question: So I'm still new to web developing and currently working on a restaurant site but when I view the page on smaller screens it's not displaying properly (not show full width) and the navbar is completely gone. How can I get this to properly show on smaller screens and the navbar to either become a togglebar or display under the logo? I think my current CSS setting might be to blame. Thanks
I have tried optimising with CSS and see if it can show the full page on smaller screens and have been able to achieve that for iPad Air and bigger screens but still no luck on smaller ones.
Happy to share my code if needed
HTML

*Catering services available for hire

 Menu

Order

Location

Contact

              "Authentic
    Caribbean
  Cuisine"

 jus lik momma use tah mek it

 Like, Follow `n Share
    FOOD_BY_SOPHIE

    Order Now

    Collection Only

        <form action="https://formsubmit.co/a5f5a32519da94e6ed9ceef9fd5cf8af" class="form-alert" method="POST">
         <!-  Honeypot -->
           <input type="text" name="_honey" style="display: none;">

    <!- Disaple Captcha -->

    <input type="hidden" name="_captcha" value="false">

    <input type="hidden" name="_next" value="https://sprightly-meerkat-b47b9e.netlify.app/">

    Your name

                    <input type="text" name="name" placeholder="Enter your name">

    Your number

                    <input type="number" name="number" placeholder="Enter your number">

    Your order

                    <input type="text" name="order" placeholder="Enter your order">

    Additional orders

                    <input type="text" name="extras" placeholder="Extras">

    How much

                    <input type="number" name="amount" placeholder="How many orders">

    Collection date & time

                    <input type="datetime-local" name="time">

    Your message

                    <textarea name="message" placeholder="Enter your message" id="" cols="30" rows="10"></textarea>

            <input type="submit" value="Order now" class="btn btn-dark">
        </form>

CSS
@import url('https://fonts.googleapis.com/css2?family=Libre+Bodoni:ital@1&family=Nunito:wght@200;300;400;600;700&display=swap');

:root{
    --green:#27ae60;
    --black:#192a56;
    --light-color:#666;
    --box-shadow:0 .5rem 1.5rem rgba(0,0,0,.1);
}

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-decoration: none;
    outline: none;
    border: none;
    text-transform: capitalize;
    transition: all .2s linear;
}

html {
    font-size: 62%;
    scroll-padding-top: 5.5rem;
    scroll-behavior: smooth;
}

.loader-container {
    position:fixed;
    top: 0; left: 0;
    height: 100%;
    width: 100%;
    z-index: 10000;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    }

    .loader-container img{
        width: 35rem;
    }

      .loader-container.fade-out{
        top: 110%;
        opacity: 0;
      }

      header {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #a8b98a;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .hover-underline-animation {
        display: inline-block;
        position: relative;
        color: white;
      }

      .hover-underline-animation::after {
        content: '';
        position: absolute;
        width: 100%;
        transform: scaleX(0);
        height: 2px;
        bottom: 0;
        left: 0;
        background-color: white;
        transform-origin: bottom right;
        transition: transform 0.25s ease-out;
      }

      .hover-underline-animation:hover::after {
        transform: scaleX(1);
        transform-origin: bottom left;
      }

    header .navbar a{
        font-size: 40px;
        border-radius: .5rem;
        padding: .5rem 1.5rem;
        color: white;
        text-decoration: none;
        font-family: 'Hi Melody', cursive;
        }

        .navbar a:hover {
            font-size:88px;
    font-size-adjust: 20px;
        }

        img.shop-logo {
            width: 650px;
            border-radius: 50%;
            margin-bottom: -0px;
            border: 10px;
            margin-top: 0;
        }

        body {
            background: #a8b98a;
          }

.about .row{
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
}

.about {
    background: #fbe7d7;
    padding-right: 10px;
    padding: 20rem 9% 40rem 0rem;
}

.about .row .image {
    flex: 1 1 45rem;
    position: absolute;
    display: block;
}

.about .row .image img{
    max-width: 1250px;
    max-height: inherit;
    height: inherit;
    width: inherit;
padding-top: 100px;
}

.about .row .content {
    flex: 1 1 45rem;
}

.about h3{
    text-align: end;
}
.about .row .content p{
    color: #aa401b;
    font-size: 45px;
    text-align: center;
    font-family: 'Hi Melody', cursive;
    font-weight: bolder;
}

.line-1 {
    margin-right: 80px;
    padding-left: 0px;
    font-family: 'Hi Melody', cursive;
    font-weight:bolder;
    color: #d45a28;
    font-size: 100px;
    line-height: 0;
}
.line-2 {
margin-left: 5px;
  padding-left: 150px;
  font-family: 'Hi Melody', cursive;
  font-weight:bolder;
  color: #d45a28;font-family: 'Hi Melody', cursive;
  font-size: 100px;
line-height: 1;
}

.line-3 {
    margin-left: 5px;
      padding-left: 100px;
      font-family: 'Hi Melody', cursive;
      font-weight:bolder;
      color: #d45a28;
      font-size: 100px;
      line-height: 1;
    }

    .line-4{
        margin-left: 5px;
        padding-left: 100px;
        font-family: 'Hi Melody', cursive;
        font-weight:bolder;
        color: #d45a28;
        font-size: 40px;
        line-height: 1;
    }

    .share {
    color: #d45a28;
    font-weight: bolder;
    font-size: 20px;
    float:right;
    padding-top: 80px;
    text-decoration: none;
    font-family: 'Hi Melody', cursive;
    padding-top: 250px;
}

.share a {
    color: #d45a28;
    text-decoration: none;
    font-weight: bolder;
}

    .sub-heading {
        color: black;
        text-align: center;
        margin-top: 30px;
        padding-top: 20px;
    }

    .heading {
        color: black;
        text-align: center;
    }
    .order form {
        max-width: 90rem;
        border-radius: .5rem;
        box-shadow: var(--box-shadow);
        border: .1rem solid rgba(0,0,0,.2);
        background: #fff;
        padding: 1.5rem;
        margin: 0 auto;
    }

    .order form .inputBox {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;

    }

    .order form .inputBox .input {
        width: 49%;
    }

    .order form .inputBox .input span{
       display: block;
       padding: .5rem 0;
       font-size: 1.5rem;
       color: var(--light-color);
    }

    .order form .inputBox .input input,
    .order form .inputBox .input textarea{
    background: #eee;
    border-radius: .5rem;
    padding: 1rem;
    font-size: 1.6rem;
    color: var(--black);
    text-transform: none;
    margin-bottom: 1rem;
    width: 100%;
    }

    .order form .inputBox .input input:focus,
    .order form .inputBox .input textarea:focus{
    border: 1rem solid var(--green);
    }

    .order form .inputBox .input textarea{
        height: 20rem;
        resize: none;
    }

    .order form .btn {
    margin-top: 0;
    }

    .order {
        padding-bottom: 20px;
    }

.footer .box-container{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));
    gap: 1.5rem;
    text-align: center;
}

.footer .box-container .box{
    padding: 5rem 0;
    font-size: 2.5rem;
    color: var(--black);
}

.footer .box-container a{
    display: block;
    padding: 5rem 0;
    font-size: 1.5rem;
    color: var(--light-color);
    text-decoration: none;
}

.footer .box-container a:hover{
color: black;
text-decoration: none;
}

.footer .credit {
    text-align: center;
    border-top: .1rem solid rgba(0,0,0,.1);
    font-size: 2rem;
    color: var(--black);
    padding: .5rem;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

.footer .credit span {
    color: black;
}

.footer {
    background: #fbe7d7;
}

\\\\ Order CSS \\\\\

.order .sub-heading {
    color: white;
}

.order .heading {
    color: white;
}

.catering {
    color: #d45a28;
    text-align: right;
    font-size: 20px;
    padding-top: 40px;
    padding-right: 10px;
    font-weight: bold;
    font-family: 'Times New Roman';

}

@media (max-width:991px){
    html {
        font-size: 55%;
    }

    header{
        padding: 1rem 2rem;
    }
    section{
        padding: 2rem;
    }
}

@media (max-width:850px){
    .about {
        display: block;
        text-align: center;
        padding-bottom: 900px;
    }
    .content {
        text-align: end;
    }
    .catering {
        text-align: center;
    }
    p .share {
        text-align: center;
    }
    .about .row .image img {
        display: block;
        position:absolute;
        padding-top: 150px;
        justify-content: center;
        height: auto;
        margin-right: 10px;
}
.share{
    padding-left: 5000px;
}
}

@media (max-width:800px){
    header .icon #menu-bars{
        display: inline-block;
    }

    header .navbar {
      position: absolute;
      top: 100%; left: 0; right: 0;
      background: #a8b98a;
      border-top: .1rem solid rgba(0,0,0,.2);
      border-bottom: .1rem solid rgba(0,0,0,.2);
      padding: 1rem;
      clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
    }

    header .navbar.active{
clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
    }

    header .navbar a{
        display: block;
        padding: 1.5rem;
        margin: 1rem;
        font-size: 2rem;
        background: #eee;
    }

    .image {
        display: block;
        text-align: center;
    }
    .about .row .image img{
        height: auto;
        width: 40%;
        margin-left: 200px;
    }

    .home .home-slider .slide .content h3{
        font-size: 5rem;
    }
    .about h3{
        text-align:center;
        font-size: 2rem;
    }
}

@media (max-width:400px){
    html {
        font-size: 50%;
    }
    .dishes .box-container .box img {
        height: auto;
        width: 100%;
    }
    .order form .inputBox .input {
        width: 100%;
    }
    .about {
        display: block;
        text-align: center;
    }
    .content {
        text-align: end;
    }
    .catering {
        text-align: center;
    }
    p .share {
        text-align: center;
    }
    .about .row .image img {
        display: block;
        position:absolute;
        padding: 200px 0 200px 0;
        justify-content: center;
        height: auto;
        margin-right: 1000px;
}

}

Answer: Please check this https://www.w3schools.com/css/css3_mediaqueries.asp for learning CSS responsiveness and media queries.
Also check this one please: https://www.w3schools.com/css/css_rwd_mediaqueries.asp


Routing a .GIF one way, the rest of the MVC 4 site another

Question: I've been trawling through 1000s of questions and blogs and still don't fully understand dam routing!
Along the lines of Scott Hanselman's blog I am trying to route a certain call to a .GIF to a custom HttpHandler while the rest of the MVC4 site behaves normally. I'm 90% of the way there.
So in the my RouteConfig I have
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.Add("AnalyticsRoute", new Route("analytics/a.gif", new AnalyticsRouteHandler()));
    routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
    routes.RouteExistingFiles = true;
}

and in my web.config I have
<handlers>
  ...
  <add name="analytics" verb="*" path="analytics/a.gif" type="Lms.Analytics.AnalyticsHandler, Lms.Analytics" preCondition="managedHandler" />
</handlers>

Now this way, http://mysite.com/analytics/a.gif routes correctly and all is happy, however all my ActionLinks are resolving as http://mysite.com/analytics/a.gif?action=Index&controller=Category
If I reverse the order in the RouteConfig i.e.
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
    routes.Add("AnalyticsRoute", new Route("analytics/a.gif", new AnalyticsRouteHandler()));
    routes.RouteExistingFiles = true;
}

All the links resolve just fine, but a call to http://mysite.com/analytics/a.gif results in a 404 error?
I must be doing something stupid and just can't see it?!
Thanks in advance
Answer: After finally coming across a similar post, I cracked it. The post was why is the httphandler not running
You need to ignore the path to the file you want the HttpHandler to handle
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("analytics/a.gif");
        routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
        routes.RouteExistingFiles = true;
    }

The problem was when I added the web.config and removed the Route.Add I got a 404. I guess the Routing engine was over ruling the Handler.
Answer: What you need to do is to create your own custom Route class.
In this class you must override the GetVirtualPath method (on MSDN), which will examine the route data, and generate the right Url. Implement it so that it returns null if your special Url it's not in the provided RequestContext.
What is going on now in your app is that you're using the standard Route class which treat the controller and action in the RouteValue dictionary as overflow paramters, so they're added to the created url.
When you add the route to the route collection use your custom class instead of the default Route class.
More explanation: when you use any method like Url.Action to create a Url, RouteCollection.GetVirtualPath is called. And this method calls the GetVirtualPath of every registered Route, until one of them returns a value different from null (the Url string).
As you're not providing your own Route class, the "standard" Route class is being used, and returning the undesired Url. If you create your custom Route class with you own GetVirtualPath implementation you'll return the desired Url.
Comment: Hmm, this may have worked too, but wasn't a path I wanted to pursue. I was sure it could be handled in the HttpHandlers. Sorry I didn't try it and solved it another way.
Comment: how did you solve it? You should share your solution so does we all can see it, and mark it as correct (what you can do after 2 days, I think).
Answer: According to Hanselman's article, you don't want to add a route for your image, you just want to set up the handler in your web.config. Have you tried removing your AnalyticsRoute and see if it works? You may also need to add an ignore route to keep MVC from trying to handle the request.
I haven't used it, but I've heard RouteMagic, written by Phil Haack, is great at troubleshooting route issues.
Comment: That's not what I got from Hasselmans article, I got that you could get around using runAllManagedModulesForAllRequests="false". Quote: "Remember that HttpHandlers are targeted to a specific path, file or wildcard and HttpModules are always watching. Why not use an HttpHandler directly and plug it in at the web.config level and set runAllManagedModulesForAllRequests="false"?" He didn't mention anywhere what to do with the Route.Add. I did try and remove it but only got 404's. THanks anyhow.


Find all kids born on Friday

Question: How I can find all dates in one table - which are Fridays - so that I can show the information in another table?
I am taking the information from Ads.Date.
Comment: SELECT DAYOFWEEK('2007-02-03');
Answer: Look at the mysql function dayofweek()
select * from ads where DayOfWeek(ads.Date)=6

dayofweek() returns weekdaynumber from 1-7 where 1 is Sunday. If you want to get everyone born on Friday you have to filter on dayofweek() = 6
Answer: SELECT *
FROM users
WHERE DAYOFWEEK(birthday)=6

Comment: Although this code may be help to solve the problem,
providing additional context regarding _why_ and/or _how_ it
answers the question would significantly improve its
long-term value.  Please [edit] your answer to add some
explanation.
Answer: You can use it :
DATE_FORMAT( yourdate, '%w') will return the day of the week, 0 for Sunday and 6 for Saturday. If you want all the fridays ou can try something like that :
SLECT DATE_FORMAT( yourdate, '%w') AS dateofbirth FROM yourtable WHERE dateofbirth = 5

Find all kids born on Friday


Crafting Glitch?

Question: So I went to try and craft myself a weapon called a Jagged Blade. I had all the proper materials, and I got Cedric to craft it for me. Or I thought I did. After getting the "crafting completed" heads up I go in my inventory to equip it. What's this? Where is it? It didn't even pop up in my inventory. I figured maybe I'm not looking in the right place, so I look at the tutorial to see maybe I have to pick it up from somewhere. Nope. Should pop up right in my inventory. So here I am, very confused, wanting to have my new weapon. So I decide maybe it was a glitch with Cedric that I didn't know about, and maybe you're not supposed to craft items with him even though it says you can. I gather the components to craft another Jagged Blade. I go to a different craftsmen, this time one around the outside of Flotsam. Get him to craft it. Look in my inventory aaaand not there. What's going on? Why am I not recieving my painfully crafted items?
Answer: Turns out I wasn't "selecting" what I wanted to craft and was crafting something else instead. A pretty stupid mistake, and I feel stupid for it, but it happens.

Crafting Glitch?


Why does the Google logo sometimes take you back to search and sometimes take you back to the product?

Question: The title is a little lengthy -- I know -- but please bear with me on this one.
I observed today that some Google sub-sites (namely Google Images, Google Books, Google Shopping) redirect to Google's main search page when the Google logo in the upper-left hand side of the site is clicked.
Why does this behavior only occur on some portions of the site and not others?
Answer: I believe its because its these subsites specifically use the Google search engine to retrieve results (from the world wide web) and are also subsets of the google search itself, and hence the logo on the top left serves serves as a medium to return to the primary home page i.e. the google search page.
However if you take something like Gmail,though Gmail is a part of Google its an independent entity and the search is restricted to the contents of Gmail unless explicitly specified.
I'll try to update this answer with some references if I can get some


Automatically inject version tag into HTML file after git pull

Question: I would like to put a placeholder into e.g. the footer.html and have it automatically replaced by the version tag set by git tag xy right after a git pull.
... something like a post pull procedure. Is there any quick way you can do this with git?
Answer: You can use git hooks to achieve this. There is no pull hook, but pull actually does fetch and merge, so you can set up a post-merge hook to automatically generate your footer.html file.
Read the relevant chapters on the Pro Git and Community books for more information.
Comment: Or `post-receive` (i.e. post fetch).
Comment: AFAICS, `post-receive` runs on the *remote* end (i.e. the server) when you run `git push`. I may be wrong, but that's how I read its description.


prove/show algebraic equivalence of 2 3x3 systems.

Question: Consider the following two continuous-time state-space representations of the form
$\frac{d}{dt}x(t) = Ax(t)+Bu(t), \quad y(t)=Cx(t), \quad t \in \mathbb{R}^+$
With their matrices given by
$1)  \quad \left[ \begin{array}{l|l}
A&B\\
\hline
C
\end{array} \right] = \left[ \begin{array}{lll|l}
3&0&0&0\\
0&1&-1&0\\
0&0&2&1\\
\hline
0&1&2
\end{array} \right] \quad 2)\quad \left[ \begin{array}{l|l}
A&B\\
\hline
C
\end{array} \right] = \left[ \begin{array}{lll|l}
1&0&0&1\\
0&2&-1&1\\
0&0&3&0\\
\hline
1&1&1
\end{array} \right]$
Note that for these systems $1$ and $2$ there exist invertible matrices $T_1$ and $T_2$, respectively, such that $AT_i=T_i\Lambda, \ \bar{B}\ \text{and} \ \bar{C}T_i, \ i=1,2$ with
$\Lambda = \begin{bmatrix}1&0&0\\0&2&0\\0&0&3\end{bmatrix}, \quad \bar{B}=\begin{bmatrix}1\\1\\0\end{bmatrix} \quad \text{and} \quad \bar{C}=\begin{bmatrix}1&1&0\end{bmatrix}$
Systems $1$ and $2$ are algebraically equivalent according to the answers. But i dont know how to check/prove this.
Normally I would prove algebraic equivalence by showing that:
$A_2=TA_1T^{-1}$ in which $T = \mathcal{C_1}\mathcal{C_2}^{-1}$ with $\mathcal{C_i}$ being the corresponding controllability matrix. This has always worked but now $\mathcal{C_2}$ is singular. So I don't know how to check/prove it.
Answer: Two state space realizations are always algebraically equivalent as long as the matrices have the same state dimensions and there exist invertible matrices $T_1$ and $T_2$, respectively for which the following holds: $AT_i=T_i \Lambda$


Which of the original 151 Pokemon learn moves AS they are evolving?

Question:
In Pokemon Red and Blue, which Pokemon learn moves at the same level at which they evolve?

or

Which Pokemon (limited to the original 151) learn moves as they simultaneously evolve?

Originally this question was asked somewhere else: https://gaming.stackexchange.com/questions/27854 however, the original asker deleted it with in 11 seconds of me trying to post the answer.  Since I spent the time to work out the answer, I wanted to preserve the question.
Comment: If the old question gets un-deleted then I'll have to ask some nice mod to migrate the answer.
Answer: Now, I might be wrong, but my understanding is that no Pokemon learns moves during the act of evolution.  All moves are learned through: breeding, leveling, or HM/TM.
That said, there are Pokemon who evolve at levels where they also learn moves.  The two mechanisms are disjoint, but can occur at the same time.
For example: Charmander, learns Dragon Rage at level 16.  It also evolves to Charmeleon at level 16.  Thus it can learn Dragon Rage and then evolve after a single battle.
Assuming you want a list of these occurrences the answer is:
Before Evolving

Charmander to Charmeleon (level 16, learns Dragon Rage)
Squirtal to Wartortle (level 16, learns Bite)
Wartortle to Blastoise (level 36, learns Skull Bash)
Poliwag to Poliwirl (level 25, learns Bubble Beam)
Geodude to Graveler (level 25, learns Smack Down)
Magnemite to Magneton (level 30, learns Lock-On)

After Evolving

Bublbasaur to Venusaur (level 32, learns Petal Dance)
Charmeleon to Charrizard (leavel 36, learns Wing Attack)
Metapod to Butterfree (level 10, learns Confusion)
Kakuna to Beedrill (level 10, learns Furry Attack)
Rattata to Raticate (level 20, learns Scary Face)
Ekens to Arbok (level 22, learns Crunch)
Sandshrew to Sandslash (level 22, learns Crushclaw)
Oddish to Gloom (level 21, learns Mega Drain)
Venonat to Venomoth (level 31, learns Gust)
Digglet to Dugtrio (level 26, learns Mud Bomb)
Mankey to Primape (level 28, learns Rage)
Abra to Kadabra (level 16, learns Confusion)
Ponyta to Rapidash (level 40, learns Fury Attack)
Slowpoke to Slowbrow (level 37, learns Withdraw)
Seel to Dewgong (level 34, learns Sheer Cold)
Gastly to Haunter (level 25, learns Shadow Punch)
Rhyhorn to Rhydon (level 42, learns Hammer Arm)
Magikarp to Gyarados (level 20, learns Bite)
Omanyte to Omstar (level 40, learns Spike Cannon)
Kabuto to Kabutops (level 40, learns Slash)
Dragonair to Dragonite (level 55, learns Wing Attack)
Comment: Actually, some Pokemon learn a move after evolving, if the evolution learns it at that level. The classic example is **Kadabra** - it learns Confusion at level 16, *after* evolving from Abra (who does not learn Confusion at all). I haven't the patience to browse all the Pokedexes looking for more though ;)
Comment: @Disgruntled Updated
Answer: It appears the question was about Pokémon Red, Blue, and Yellow specifically. Almost every Pokémon had their movepools and the levels they learnt moves changed from Gen I to the Advanced Generation (Gen III), so here is a list of the Pokémon that learnt moves as they levelled up within the Gen I games (solely Red, Blue, and Yellow):

Charmeleon to Charizard, Level 36, Wing Attack
Caterpie to Metapod, Level 7, Harden (only Yellow, not Red or Blue)
Metapod to Butterfree, Level 10, Confusion (only Yellow, not Red or Blue)
Weedle to Kakuna, Level 7, Harden (only Yellow, not Red or Blue)
Mankey to Primape, Level 28, Rage (only Yellow, not Red or Blue)
Poliwag to Poliwhirl, Level 25, Doubleslap
Bellsprout to Weepinbell, Level 21, Stun Spore
Slowpoke to Slowbro, Level 37, Withdraw
Magikarp to Gyarados, Level 20, Bite
Dratini to Dragonair, Level 30, Slam

(Information compiled from Serebii.net's RBYGSC Pokédex).
Comment: Actually that was Raven's edit of the original question (which only asked about the first 151).
Comment: Ahh. Well, I was going to answer the original question using the RBY Pokédex anyways, so here is my retro-based answer.
Comment: @Tzenes - I don't see the difference. The question was tagged with the First Generation games -- Red and Blue (and Yellow). There were only 151 Pokémon in those games.
Comment: @Raven Actually the question was tagged [Pokemon] and [leveling], you're the one who changed it to [pokemon-first-gen]
Comment: @tzenes - right. Because the asker specified first-gen.
Comment: @Raven actually the asker looks harassed and angry.  When Keven asks him "Do you mean the Kanto Pokémon within Gen I games, or in a different generation? (The movepools changed from generation to generation.)"  He literally gives up and deletes the question.
Comment: Caterpie learns Harden at Level 7 on evolving to Metapod, and Metapot learns Confusion at level 10 when evolving, in Red and Blue as well. Same with Weedle to Kakuna (for Harden). I used to always catch these PokéMon as bugs first, then level them up in the Viridian Forest.
Comment: @KevinYap Charizard doesn't learn Wing Attack in RBY. Maybe you confused it with GSC?


Downloading Ubuntu 12.04

Question: I started downloading Ubuntu last night.  It has stopped downloading. I am installing it along side windows.  How do I get it to continue to download?  It is locked-up.
Comment: How are you downloading?
Answer: Download through torrent so you can pause and resume download anytime you want.

BitTorrent is a peer-to-peer download network that sometimes enables
  higher download speeds and more reliable downloads of large files. You
  will need to install a BitTorrent client on your computer in order to
  enable this download method.

http://www.ubuntu.com/download/desktop/alternative-downloads
Answer: Use a torrent client and the alternative downloads section that way you can resume progress
http://www.ubuntu.com/download/desktop/alternative-downloads
utorrent works well on windows - http://www.utorrent.com/

Downloading Ubuntu 12.04


How can I make members of a Team in Minecraft Invulnerable?

Question: I have a small Java Server on 1.16.1 and use a Vanilla Tweaks datapack ("AFK Display")to have people that stand still for 5+ minutes be considered AFK. This datapack puts them in a team to tell them apart on the Tab list.
I have so far set their nametagVisibility and collisionRule to never, so their nametag cannot be seen and they cannot be pushed around by other players.
Is there a way to prevent these players from taking damage at all? So they cannot even be hit around? Basically making them invulnerable?
Answer: I'm not sure if that is possible, but you could give them Resistance 255, so if they get attacked, they cannot be moved or damaged. Regeneration can be added if needed.
Comment: The problem with that is that they're still being able to take damage and be moved by the knockback. This movement would then make the datapack consider them not afk anymore.
Comment: @ColinShark, I have changed it so the AFK player cannot be moved.


portlet:renderUrl - how to make URL relative?

Question: I have problem with http vs https link in portlets. I work with jboss liferay 6.0 but it is not relevant in this case.
Portlets may be used in http or https mode. Portlet tag creates absolute URL. I would need this relative to work correctly with http vs https.
I know secure attribute, but I don't want it always secure.
<portlet:renderURL var="detailLink">
    <portlet:param name="id" value="${recordId}" />
    <portlet:param name="backURL" value="${backLink}" />
</portlet:renderURL>

Please no javascript for this.
Thank you
Comment: Couldn't you just manipulate *detailLink* manually?
Comment: I use this tag in many portlets. Should I create my own tag for something what must be already solved - or am I really only one with this problem? Thanks.
Comment: In a single site the same portlet should have some URLs `http` and some `https`, is this what you want?
Comment: No, when I hit web page `http://whatever.com` I want to see links on this page `http://whatever.com/nextPage`. But when I hit the web page `https://whatever.com` I want to see links on this page `https://whatever.com/nextPage`
Answer: On the server, you will know whether you are in http or http mode. So you could create it server side using something like this
PortletUrl detailLink renderResponse.createRenderUrl();
detailLink.setSecure(renderRequest.isSecure());

//set all the params on detailLink here

model.setAttribute("detailLink",detailLink);

Answer: You can use the Relative URL concept here...
If you don't want to go ahead with javascript then you can create a Java method in your jsp page, preferably in a common jsp page like init.jsp and place the following method:
<%!

private String _getRelativePath(String cURL) {
        if (Validator.isNull(cURL)) {
            return cURL;
        }

        if (cURL.startsWith(Http.HTTP)) {
            int pos = cURL.indexOf(
                StringPool.SLASH, Http.HTTPS_WITH_SLASH.length());

            cURL = cURL.substring(pos);
        }

        return cURL;
}

%>

You can call this method on your url and it would return the string having path and parameters.
For example; if you pass cURL as
http://localhost:8080/web/guest/home?p_p_id=58&p_p_lifecycle=1&p_p_state=pop_up&p_p_mode=view&_58_struts_action=%2Flogin%2Flogin

then it will return
/web/guest/home?p_p_id=58&p_p_lifecycle=1&p_p_state=pop_up&p_p_mode=view&_58_struts_action=%2Flogin%2Flogin

Also you can use themeDisplay.getURLPortal() method to split absolute url to get required relative url out of it.
<%!

private String _getRelativePath(String cURL, ThemeDisplay themeDisplay) {

        if (Validator.isNull(cURL)) {
            return cURL;
        }

        String [] urlArr = cURL.split(themeDisplay.getURLPortal());

        return urlArr[1];
}

%>

This mechanism will fulfill your requirement.


Explicit Semantic Analysis

Question: I came across this term called 'Explicit Semantic Analysis ' which uses Wikipedia as a reference and finds the similarity in documents and categorizes them into classes (correct me if i am wrong).
The link i came across is here
I wanted to learn more about it. Please help me out with it !
Answer: This explicit semantic analysis works on similar lines as semantic similarity . I got hold of this link which provides a clear example of ESA
Comment: It's a bit redundant to have two links to the exact same page.

Explicit Semantic Analysis


htaccess - redirect directory and remove matching string form end of SEF url

Question: I want to use .htaccess to redirect directory structure and remove this string "-detail" from the end of all SEF url.
for example:
https://www.example1.com/shop/items/product-catalog/category/concrete-tiles-detail

redirect to
https://www.example2.com/product-catalog/category/concrete-tiles

The "category" part of the path is dynamic. and could even be comprised of several directories like
https://www.example1.com/shop/items/product-catalog/category1-2-or-3/sub-category/concrete-tiles-detail

the first rule works, but i have not found a solution for removing the string at the end.i tried this answer but its not working for this scenario.
RewriteEngine On
RewriteBase /
RewriteRule ^shop/items/product-catalog/(.*) https://www.example2.com/product-catalog/$1 [R=301,L]
RewriteRule ^(.*?)="\{\{-detail(.*)$ /$1$2 [R=301,L]

Answer: Just adding that part after the grouped match in the pattern (and anchoring the pattern at the end), should do the trick.
RewriteRule ^shop/items/product-catalog/(.*)-detail$ https://www.example2.com/product-catalog/$1 [R=301,L]

That second rule you tried, can be removed completely then.
Comment: sorry, let me make it more clear.
the "/category/" part of the path is dynamic. it could be
https://www.example1.com/shop/items/product-catalog/shoes/concrete-tiles-detail  or https://www.example1.com/shop/items/product-catalog/tiles/concrete-tiles-detail or https://www.example1.com/shop/items/product-catalog/tiles/blue/concrete-tiles-detail
Comment: And what exactly is the problem? Accoprding to https://htaccess.madewithlove.be/, your first example here should get rewritten to `https://www.example2.com/product-catalog/shoes/concrete-tiles` now. How is that not what you want?


Finding and obtaining the difference between two columns

Question: I have two columns. Each column has tens of thousands of values. I need to find the difference between them and print the difference in some cells. I read similar questions, but they are not enough for my question, highlighting the different cells is not enogh for me because it would be very tiring to look at tens of thousands of cell by searching highlighted cells. Thus, i need to obtain the values.
Example:
Column1     Column2
John        Jennifer
Mary        Washington
Joe         John
Michael     Texas
Houston     Newyork
Texas       Mary
Values existing in col1 but not col2 : Joe, Michael, Houston
Values existing in col1 but not col2 : Jennifer, Washington, New York
Algorithmically, i need to check each row of column1 whether it exists in Column2, if the row does not exist in Column2, the value is taken.
Similarly,   i need to check each row of column2 whether it exists in Column1, if the row does not exist in Column1, the value is taken.
Thanks
Answer: Old: If this is a once-off i'd make a backup then mark the area of the two columns and "remove duplicates" which is a button on the DATA command bar.
You would be left with unique records only, which is what I understand you want.
Edit: If you want to completely remove duplicate values then: Assuming that col1 is "A" and col2 is "B" then this formula only shows the record if it is in A but not in B. You can make a similar one for B not in A. In my example I made two columns C, D for the unique values. Then filter the list on these being "not nothing", and you have a set of unique records.
Current formula is for A2 cell - in my example placed in C2.
<code>=IF(ISERROR(MATCH(A2;B:B;0));A2;"")
</code>
Comment: No, if a value has a duplicate, i want to delete both value from two columns.


listening for programmatic change of view controller in UITabBarController

Question: I need a tabbed application to switch from view controller 2 to view controller 1 (home view controller) and then immediately call a method on view controller 1, without any input from the user.  Using viewDidLoad doesn't work, since (as far as I can tell) the home view controller stays loaded the whole time; making it visible doesn't load it again.  I've been trying to use -(void)tabBarController: didSelectViewController: but it's not getting called either, I assume because it only works with user-initiated selections, not programmatic selections.
So what can I do?
Answer: You can use the method -(void) viewWillAppear to do this. Once the view is already loaded, you do whatever you want when it appear! Here it is:
- (void) viewWillAppear:(BOOL)animated {
   [super viewWillAppear:animated];
   // You code here to update the view.
}

Comment: Hmm.  I just tried this in both view controller 1 and view controller 2, but the methods I put in it aren't getting called.  I'm sure I'm misunderstanding--would you mind being more explicit about how I do this?  Sorry for not getting it.
Comment: I edited my answer above! Check it out and test it! You can also include something like `NSLog("Method being called when viewcontroller 1/2 appear")` to check if this method is being called.


How exactly do Helmets work in Apex Legend?

Question: Is it percentage damage reduction? Life points, similar to body armor?
Answer: They essentially reduce bonus headshot damage, with higher tiers having more of a reduction.
White: 30% Reduction
Blue: 40% Reduction
Purple/Gold: 50% Reduction
They also do no break like shields from armour does.
Source: Chad Armstrong, Designer at Respawn
Comment: It's worth noting that Legendary (Gold) gear has the same effects as Epic (Purple) plus a bonus effect.  The Gold helmet charges your tactical (Q) and ultimate (Z) abilities faster than normal.
Comment: @Buns Glazing Absolutely, this should be added into the answer to make it more complete.
Answer: There is a new answer recently. Reddit user "TheChessur" worked out that actually the damage reduction applies to total damage; and the reductions themselves are much smaller than expected, at 10%/20%/25%.

A headshot with a Wingman would deal 45 body shot damage, plus 45
bonus headshot damage, for a total of 90.
If you headshot an enemy with a White Helmet, the game's description would have you believe you deal 45 + (0.7*45) = 77 damage.
But in fact, the headshot deals (0.9*90) = 81 damage.

Source:

https://www.rockpapershotgun.com/2019/03/18/apex-legends-armor-and-gear-guide-helmet-backpack-knockdown-shield-body-shield/
https://www.reddit.com/r/apexlegends/comments/aqzism/skullpiercer_rifling_helmets_explained/


jqGrid custom formatter

Question: For one of the columns in my jqGrid, I'm providing a custom formatter function.  I'm providing some special cases, but if those conditions aren't met, I'd like to resort to using the built-in date formatter utility method.  It doesn't seem that I'm getting the right combination of $.extend() to create the options that method is expecting.
My colModel for this column:
{ name:'expires',
    index:'7',
    width:90,
    align:"right",
    resizable: false,
    formatter: expireFormat,
    formatoptions: {srcformat:"l, F d, Y g:i:s A",newformat:"n/j/Y"}
},

And an example of what I'm trying to do
function expireFormat(cellValue, opts, rowObject) {
    if (cellValue == null || cellValue == 1451520000) {
        // a specific date that should show as blank
        return '';
    } else {
        // here is where I'd like to just call the $.fmatter.util.DateFormat
        var dt = new Date(cellValue * 1000);
        var op = $.extend({},opts.date);
        if(!isUndefined(opts.colModel.formatoptions)) {
            op = $.extend({},op,opts.colModel.formatoptions);
        }
        return $.fmatter.util.DateFormat(op.srcformat,dt,op.newformat,op);
    }
}

(An exception is being thrown in the guts of that DateFormat method, looks like where it's trying to read into a masks property of the options that get passed in)
EDIT:
The $.extend that put everything in the place it needed was getting it from that global property where the i18n library set it, $.jgrid.formatter.date.
var op = $.extend({}, $.jgrid.formatter.date);
if(!isUndefined(opts.colModel.formatoptions)) {
    op = $.extend({}, op, opts.colModel.formatoptions);
}
return $.fmatter.util.DateFormat(op.srcformat,dt.toLocaleString(),op.newformat,op);

Answer: In the jqGrid source code, different options are passed to the formatter when it is a built-in function versus when a custom formatter is used:
    formatter = function (rowId, cellval , colpos, rwdat, _act){
        var cm = ts.p.colModel[colpos],v;
        if(typeof cm.formatter !== 'undefined') {
            var opts= {rowId: rowId, colModel:cm, gid:ts.p.id };
            if($.isFunction( cm.formatter ) ) {
                v = cm.formatter.call(ts,cellval,opts,rwdat,_act);
            } else if($.fmatter){
                v = $.fn.fmatter(cm.formatter, cellval,opts, rwdat, _act);
            } else {
                v = cellVal(cellval);
            }
        } else {
            v = cellVal(cellval);
        }
        return v;
    },

So basically what's going on is that when a built-in formatter is used, cm.formatter is passed as an argument. I need to confirm this, but based upon the error you are receiving, this appears to be a copy of the formatter options from grid.locale-en.js (or whatever version of the i18n file you are using). So when called internally the formatter would contain additional options such as masks - which is the one your code is failing on.
As a preventative measure, I would try adding masks to your op variable. If that solves your problem then great, otherwise keep adding other missing options back into your code until it works.
Does that help?
Comment: Yes, seems I had to extend from the i18n formatter options, found the right combination.  Thanks!

jqGrid custom formatter


When do smoke grenade defense bonuses apply?

Question: Smoke grenades state that they give a +20 to defense to anyone in the smoke (friend or enemy).
However, if someone has to trace a line of sight through smoke to a target on the other side who is not in smoke, does the defense bonus still apply?
Likewise, if I'm standing in smoke and shooting at someone not in smoke, does the smoke I'm in interfere with my shot and make it harder to hit?
In short, I'm trying to understand if I should be dropping smoke grenades directly on my units instead of trying to use them as a screen between me and the enemy.
Answer: It appears you need to be standing in the smoke, and yes the smoke is a defensive buff, designed to be used on allies.  There should be no problems whatsoever shooting out of it.  This is all a bit counterintuitive, but the cover system is pretty abstract so there you go.
Comment: Yeah, the in-game text for the grenades sounded pretty simple and backs up what you're saying, but it just seemed so backwards to me that I figured I'd ask anyway to see if anyone had tested it out. Thanks for the answer!
Comment: @Sterno NP.  Like I said, it's sort of an incongruity - why would you drop a smoke grenade on your own guys except in desperation/to cover a retreat?
Answer: Smoke affects everything in the radius of the smoke, INCLUDING enemies. If you are standing next to an alien when smoke is popped on you, it will increase the cover of the alien in the same way (20%). It does not affect cover for things outside of smoke, even if your line of sight on an alien is through a patch of smoke.
Smoke has saved me at least a dozen times so far; it's well worth popping if:

You have a guy exposed to potentially fatal fire under little to no cover. This can happen if, for example, an alien or missed shot blew up his cover, or if you just had to expose your guy so he could kill an alien.
You want to provide at least some cover to an area you will move through that has little or no cover of its own.


Is there a way to know if transmission-daemon currently active?

Question: I have a laptop that i use as a media station connected to my TV, occasionally i would fall a sleep and forget to shutdown the laptop and that is unwanted behavior. so i use crontabs to shutdown my laptop everyday at 7AM because i am sure that i am always either asleep or not at home then.
However sometimes i am actually downloading something using transmission-daemon and would prefer the laptop not to turn off at that time. Is there a way to check whether transmission daemon is downloading or not? like a file flag by transmission-daemon? i though about scanning the active ports used by transmission-daemon but i figured that there might be a more elegant solution.
Answer: Sure. The first one is with transmission not active, the second one is.
rinzwind@schijfwereld:~$ ps -ef | grep transmission | grep -v grep

rinzwind@schijfwereld:~$ ps -ef | grep transmission | grep -v grep
rinzwind 10490     1 11 22:04 ?        00:00:00 transmission-gtk

Is there a way to check whether transmission daemon is downloading or not?

Yes. There is an API and here is an old script from 2013 doing a shutdown for a MAC. Requires 1 change:
subprocess.call(['osascript', '-e','tell application "Finder" to shut down'])

needs to be something like this:
subprocess.call(['shutdown', '--now','turn off'])

It assumes you set up the web interface on port 9091

Pre req:
cd ~
virtualenv .transmission_env
source .transmission_env/bin/activate
pip install transmissionrpc
deactivate

and the script:
#!/Users/fots/.transmission_env/bin/python

import subprocess

import transmissionrpc
from transmissionrpc.error import TransmissionError

def main():
    all_done = True
    try:
        tc = transmissionrpc.Client('localhost', port=9091)
        for torrent in tc.get_torrents():
            if torrent.status == 'downloading':
                all_done = False
                break
        if all_done:
            subprocess.call(['osascript', '-e',
                             'tell application "Finder" to shut down'])
    except TransmissionError:
        pass

if __name__ == "__main__":
    main()

Comment: shellcheck gave me an error tonight for `ps` piped to `grep`. It would recommend `pgrep transmission` instead. As a bonus this returns the PID which benefits the kill command as you don't need to use `tr -s ' ' | cut -d ' ' -f2` to isolate PID. Still +1 for putting up with me :P


Finite groups in group theory

Question: How to prove that finite group of even order comprises an element of order two?
I thought that if a group is finite it could have a finite set of elements with order two, couldn't it?
Comment: The statement doesn't exclude the possibility of a finite set of elements with order 2. It only says that there should be *at least one* element of order 2.
Comment: @Dreamer but how to find this element?
Answer: Hint: Define a relation $g \sim h$ if $g = h$ or $g = h^{-1}$. Show that this is an equivalence relation, and that an element is of order $1$ or $2$ iff it's alone in its equivalence class. Then count.
Comment: @T.Bongres don't understand how will it help
Comment: @Phill Every non-identity element that's not of order $2$ can be paired up with its inverse - so these classes all have size exactly $2$. Then there's another class with just the identity; put it together, and we're at least $1$ element short. This element has order $2$.
Answer: This answer is meant to elaborate on T. Bongers' answer. Once you proved that the relation that he defined is an equivalence relation, you know that it covers the whole space. Then, for every element not of order $2$, the relation defines a class, namely that containing an element itself, and it's inverse (as defined by the relation). Therefore, these classes are all sets of size 2. However, one of these sets, the set containing $e$, has size $1$, since the inverse of $e$ is just $e$ itself. So, all these sets together contain an odd number of elements. The only way that $G$ can still have an even number of elements is therefore if it contains an element  order $2$. This is because for an element $a$ of order $2$ it holds that $a=a^{-1}$, which means that the equivalence relation will create a set with just $1$ element. Therefore, the total number of elements of $G$ is then again even.

Finite groups in group theory


optimizing JQuery SmoothScroll script

Question: The script below acieves the task, but I need it to run another 20 time or so. How can I optimize the script so I don`t need to call the same script over and over again?
"a1" changes to "a2", "a3" and so on. "#thing" needs to change also so it can scroll to another part of the page
$(document).ready(function() {
$(".a1").click(function() {
        $('html,body').animate({
        scrollTop: $("#thing").offset().top
    }, 500);
});

Answer: Something like that can do the job i think:
var cnt = 0;
$(".a1").click(function() {
        $('html,body').animate({
        scrollTop: $("#schoonmaak").offset().top
    }, 500, function() {
      if (cnt++ > 20) $(".a1").click();
});

EDIT - after your question edit has made, i think this will solve your problem:
var items = $('body ul li[id]');
$('.nobackground h2 a').each(function(i){

  $(this).click(function() {
     $('html,body').animate({ scrollTop: $(items[i]).offset().top}, 500);
  });

});

Comment: Thank you, but I`ve not been clear what I want. "a1" changes to "a2", "a3" and so on. "#schoonmaak" changes also to something else.

optimizing JQuery SmoothScroll script


Setting Events in a class that utilize a later mentioned Prototype?

Question: When I reach the console.log() its returning window.
How can I get the element under consideration?
let builder = function(){
    this.box = $(`<div id="box" class="box">`);
    this.inputcontainer = $(`<div id="inputcontainer" class="inputcontainer">`).appendTo(this.box);
    this.textarea = $(`<textarea id="textarea"></textarea>`).appendTo(this.inputcontainer);
    this.textarea.on("change keyup keydown input paste", this.postmsg);
    this.chat.appendTo($('body'));
}

//someothercode

builder.prototype.postmsg = (e) => {
    console.log(this); // returns window when I need it to be referencing textarea
}

let instance = new builder();

Comment: No `this` in arrow functions
Answer: builder.prototype.postmsg = function(e){
    console.log(this.textarea);
}

Comment: I think it's beacause of the arow function postmsg, declare it as a normal function
Comment: Comes back as undefined
Comment: It's been the purpose of arrow function, it let you to get the this reference of the last parent classic function, in your case it was window


Proof using Bolzano's theorem

Question: Im having relatively hard time with this particular problem. We're asked to prove this:
Show, that there exists a real number $x$, which satisfies $x^5 − x^2 + 3 = 2019$
The thing is that we should use Bolzano's theorem for this and construct a reasonably rigorous proof, but wouldn't this work also with Intermediate value theorem? How should one approach this?
Comment: Any odd degree polynomial has atleast one real root.
Answer: As mentioned correctly in the comments,every odd degree polynomial has a real root.
As another simple proof take $h(x)=x^5-x^2-2016$ and apply Bolzano's theorem to the interval $[0,10]$
Comment: Could you elaborate, how do we come up with the interval $[0, 10]$?
Comment: @Daniel you just find an interval where $h(x)<0$ in one endpoint and $h(x)>0$  in the other
Comment: Im bit stuck... how do i find the interval?
Comment: @Daniel ...there is not a explicit way...just try numbers  to achive what i said in my above comment.

Proof using Bolzano's theorem


WPF 3d LinearGardientBrush / TextureCoordinates

Question: I have the following LinearGradientBrush
var brush = new LinearGradientBrush();
brush.GradientStops.Add(new GradientStop { Color = Colors.Transparent, Offset = 0 });
brush.GradientStops.Add(new GradientStop { Color = Colors.Blue, Offset = 0.1 });
brush.GradientStops.Add(new GradientStop { Color = Colors.Cyan, Offset = 0.2 });
brush.GradientStops.Add(new GradientStop { Color = Colors.GreenYellow, Offset = 0.4 });
brush.GradientStops.Add(new GradientStop { Color = Colors.Yellow, Offset = 0.6 });
brush.GradientStops.Add(new GradientStop { Color = Colors.Red, Offset = 0.8 });
brush.GradientStops.Add(new GradientStop { Color = Colors.Magenta, Offset = 1 });

and I use the following code to set the texture coordinates
textureCoordinates.Add(new Point(z_value / 100d, 0));

The result is not bad. But as you can see in the following image the highest value is always magenta even if the z value I used for the texture coordinate is quite low:

The right example should be colored blue.
How can I set the color correctly? My z values are all between 0 and 100.
Answer: This took me hours too before I found the solution here.
The LinearGradientBrush is using the bounding box as reference by default.
To fix this, the Property MappingMode of your brush object must be set to BrushMappingMode.Absolute. So in your case try this :)
brush.MappingMode=BrushMappingMode.Absolute


In mysql workbench 'select top' is not working... how can i access top 5 in table?

Question: I want to fetch top 5 data from my table.
I try with "TOP" query (Ref by, following link), but it's not working for me.
Click here!
Can some one suggest for this? Thanks in advance.
Comment: Did you read the link you have provided? it's written there plain and clear.
Comment: you must click on that link..test your code... if you have problem ask a Clear question to get GOOD answer
Comment: yes, while using that query(SELECT TOP) in mysql its not working
Comment: and it shouldn't . Read the MySQL part in your link.....
Comment: then how will i get the top rows?
Comment: Please share more details, like the query you are currently using and a clear error message. If there is no error thrown, please explain what you mean by "not working"
Answer: From the link that you have provided:

SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;

SELECT TOP is SqlServer syntax
Answer:     SELECT TOP <Number> <column_name(s)>
    FROM <table_name>
    WHERE <condition>;

For this SQL query corresponding MYSQL query is
    SELECT <column_name(s)>
    FROM <table_name>
    WHERE <condition>
    LIMIT number;

Using TOP will give the error.


Facebook mobile login and server-side validation

Question: I am working on a mobile app that has an integrated Facebook login (using the fb android sdk). I also have a server that has some rest endpoints on it that I would like to secure. I have been looking around for days trying to find the best solution (reading articles on the dev site: https://developers.facebook.com/docs/facebook-login/security, other stackoverflow posts) but I am not quite sure what is the best solution.
At the moment I have the following setup in place:

User logs in on the app using Facebook (mobile android sdk).
When requesting a resource from a rest endpoint the token will be added as a header.
On the server side I validate the token using the fb debug_token endpoint (https://developers.facebook.com/docs/graph-api/reference/v2.5/debug_token)
If the validation is successful I allow my rest resource to be 'called'

As you can see I will have do my own request to Facebook (server side) for every request I receive. Is there a better way to solve this problem?
Thanks in advance!
Comment: Verify the token once, and then store the result in your session.
Comment: So I should keep the result from the token debug stored in a database?
Comment: Not unless you're extending the token, because it will only be valid for about two hours anyway.
Comment: "Mobile apps that use Facebook's iOS and Android SDKs get long-lived tokens by default." https://developers.facebook.com/docs/facebook-login/access-tokens.
Comment: Alright. Still, the token could have become invalid by the next time the user uses your app … so I think storing the debug result makes more sense on a per-session basis.
Answer: Facebook uses OAuth, and with this protocol you should have in the response headers or body an expiry time attribute associed with the token.
So you can store wherever you want the tuple (token, token_expiry) to bypass the request to facebook most of the time.
In fact you should have a response with those attributes:
<code>{
"access_token": <access-token>,
 "token_type":<type>,
 "expires_in":<seconds-til-expiration>
}
</code>
Comment: So are saying that I should send this information over and store it on my server?
Comment: Yes you can do that (in memory and/or long live persistency) to manage the authentication across all the user requests


Why I have this error message when I try to add a new constructor to a class that extend another class?

Question: I have the following problem:
I have a class named PdfReport that extends another class named iTextDocumentBase declared in this way:
public class PdfVulnerability : iTextDocumentBase
    {
    private DataModel.Vulnerability.Vuln currentVuln;
    ...................................
    ...................................
    }

Into this class I am trying to add a new constructor that take a specific object as paramether, this one:
    public PdfVulnerability(DataModel.Vulnerability.Vuln currentVuln){
        this.currentVuln = currentVuln;
    }

My problem is when I add this constructor to the previous PdfReport class, Visual studio give me the following error message:

'PdfReport.iTextDocumentBase' does not contain a constructor that
  takes 0 arguments

Why I obtain this error message when I try to add a new constructor to a class that extends another class?
Tnx
Comment: Could you post code about the PdfReport?
Comment: Do you mean that `PdfReport` extends `PdfVulnerability`? It's not clear where `iTextDocumentBase` really comes in here... (Also given the error message, it sounds like `PdfReport` might be the namespace, not the type name...) Posting a short but *complete* program demonstrating the problem would make it much clearer.
Answer: That's because a class's constructor always calls its base class's constructor - either explicitly or implicitly.
In your case, since you didn't specify a call to any base class's constructor, a call to a constructor with 0 parameters is inferred. Your code is equivalent to this:
public PdfVulnerability(DataModel.Vulnerability.Vuln currentVuln) : base()
{
    this.currentVuln = currentVuln;
}

And, apparently, this constructor doesn't exist in the base class iTextDocumentBase.
Check which constructors the base class provides, and call one of them explicitly.
Answer: If base class doesn't have parameter less constructor defined and Child class doesn't call the base class constructor along with child class constructor. this error will occur. You have to call specific base class constructor with child class constructor


Django custom foreign key representation

Question: If i have two models
class Parent(models.Model):
    attribute_1 = ....
    attribute_2 = ....

class Child(models.Model):
    parent = models.ForeignKey(Parent)

Django by default will do lazy fetching to parent as it will hit the database when i try to access attribute_1 or attribute_2, so how can I make it fetch them by default for this specific use case
Answer: Use select_related when fetching your child object(s) to also fetch the data for the foreign key in a single query
child = Child.objects.select_related('parent').get(id=1)
print(child.parent.attribute_1) # No additional query
print(child.parent.attribute_2) # No additional query

Comment: is there a way to access this from the child instance itself?


Java Transfer Object, what is it?

Question: Directly from this oracle article about the J2EE DAO Pattern:
Everything is very clear indeed but the Transfer Object "participant" (as they call it).
Here I quote the bit I would like more insights about (especially would be useful a real life example (an easy one)).

TransferObject
This represents a Transfer Object used as a data carrier. The
DataAccessObject may use a Transfer Object to return data to the
client. The DataAccessObject may also receive the data from the client
in a Transfer Object to update the data in the data source.

I am trying to use this pattern as an exercise (as a student for the exam OCPJP it requires to understand the DAO Pattern). So far I have my DataSource (mysql database), my business object (JavaBean called Person) and my DAO object interfacing properly between the database and the JavaBean (Person).
So again What exactly a Transfer Object is?
EDIT:
FROM THE FIRST REPLIES I UNDERSTOOD THAT ACTUALLY I KNOW WHAT A TRANFER OBJECT IS BUT I DO NOT KNOW WHAT A BUSINESS OBJECT IS... SO THE QUESTION REMAIN THE SAME BUT FOR THE BUSINESS OBJECT. NOT FOR THE TRANSFER OBJECT.
Thanks in advance and  sorry about that.
Thanks in advance.
Comment: Why not accept the best answer you got so far and post a new one about the business object?
Comment: @nakosspy you are right indeed here it is http://stackoverflow.com/questions/17008521/dao-pattern-in-java-what-is-a-business-object
Answer: Transfer object is a simple class with fields and NO logic. They are serializable POJOs (Plain Old Java Objects) and have accessors (getters, setters) to access fields. They are called transfer because they are used to pass data between layers or roughly speaking group arguments to service method calls, they need not to match business objects.
Example
UserLogin { // just fields that are needed to login, not a User business object
    String name;
    String password;
}

LoginService { // sample sarvice that check passwords
    boolean Login(UserLogin userLogin) {...}
}

Transfer Objects are distinguished from other structure-like classes by the way they are used (transferring data) not by the way they are build (fields and accessors).
Comment: Ok I thought it was the business object... so what's the business object then?
Answer: DTO
DTO does not have any behavior except for storage and retrieval of its own data (accessors and mutators). DTOs are simple objects that should not contain any business logic that would require testing.
DTO Usage

Case 1:  Use DTO's if the domain object is huge, but you just need a
  few attributes of it! For large domain objects, in which the client
  visualize, change or display only a few of its attributes. In this
  case we recommend to use the notation: prefixDTO. This is the object
  which the client uses to do its works. The service gets the Domain
  Object, creates the DTO and gives it back. If this DTO is used in a
  wizard or kind of formular in which the user may type something in
  setting values, which means that you have to store the typed
  information into database, then you should use in addtion to the DTOs
  new objects called: prefixDTOData. why that? Because otherwise we
  would force the service which writes the attributes into database to
  iterate over the whole domain object (remember that the domain object
  is huge) looking and comparing for changes before writing down in the
  database.
Case 2:  Use DTOs if the client has to show fields from different
  domain objects. In this special case you may consider putting all the
  needed attributes together already in the database creating the DTO in
  the server which is passed to the service going to the client. The
  client creates analoque to Case 1 a prefixDTOData an gives it back to
  the service. the reasons are the same as in explained in Case 1.
Comment: +1 :: When there are large domain objects having a DTO sure helps.
Comment: Ok my bad I thought it was the business object... then i don't know what a business object is... my bad again
Comment: Perfect answer . Also thanks @EdwardJBeckett for pointing out the generics thing
Answer: It will transfer the data from one layer to another layer.You can call it as DTO(DATA TRANSFER OBJECT) orVO(VALUE OBJECT)`.
For example if we fill a form contains user details to save in the databse.First values will go to the action class.Then i need to send it to the DAO through service.So in action class i will set all the details to a class and then access it in service class

Java Transfer Object, what is it?


Advice on using (or not using) singletons

Question: I'm working on a multiplayer game iOS app and I've come to a point in the design where it seems that I would benefit from creating two singletons but I don't know if there is a superior design pattern.

A live game singleton: to get/set properties and start/stop the game from anywhere in the app.
A location manager singleton: to manage user location updates/properties from anywhere in the app but especially from inside of the live game singleton because the game mechanics affect the properties of the location manager.

And if you are wondering do I really need to interact with these objects from absolutely anywhere in the app, the answer is a definite yes. This is a live multiplayer experience so everything related to gameplay needs to persist cleanly throughout the app's lifecycle.
So would this be a correct use of the singleton pattern or is there a better method, and if there is why is it better?
Comment: What are your other options?
Comment: Read http://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons
Comment: You will be very sorry down the road if you use a singleton now. Consider a future update where you need to support tracking more than one live game at a time.
Comment: "You will be very sorry down the road" - sorry I still don't see why that would be the case. Is there something more fundamental than the example you gave?
Comment: Singletons also create a memory issue, because they always reside in the memory and are not deallocated.
Comment: @user3915477 Let's say you create a `LiveGame` singleton. Throughout your app you have code such as `LiveGame.instance.whatever`. Everything works. Now you realize you need to support separate `LiveGame` instances. Now, every single reference to `LiveGame` in your app needs to change to reference a specific instance. You now have to refactor your entire app. That's painful. Plan ahead. Pass the `LiveGame` instance around properly from controller to controller now. Then you don't need to refactor your entire app later.
Comment: @BhavukJain unless he's reading and writing a massive amount of things from this singleton that's really a non-issue.
Answer: I believe that you need to take a look at dependency injection. You should someway instantiate your objects passing a Game and LocationManager instances during each other object construction time (i.e. pass them as constructor arguments to any object that will need either or both Game and LocationManager instances).
Actually, there will be only a single instance of Game and LocationManager that will be created during game initialization and the top-most object in your game will start to inject both objects like a cascade!


Terminal has network (DNS?) issues but browser works fine. ipv6 issue?

Question: EDIT: It seems it might be a cable modem issue: according to https://test-ipv6.com/ ipv6 is not working both in Ubuntu as well as windows (dual boot, same workstation), and neither on my smartphone when on wifi (i.e. same cable modem), while it does work on smartphone with wifi disabled (i.e. mobile data). So I will contact my ISP.
I have a fresh Ubuntu 22.04 install on a desktop PC with a wired internet connection. It has the default networking configuration settings (DHCP; IP address from cable modem).
Internet access works fine from a browser.
From the command line however, some programs (e.g. apt update or apt upgrade) seem to work fine, though maybe somewhat slow (?), while others fail, e.g. wget:
~$ wget https://raw.githubusercontent.com/ros2/ros2/rolling/ros2.repos
--2023-05-17 13:56:57--  https://raw.githubusercontent.com/ros2/ros2/rolling/ros2.repos
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 2606:50c0:8002::154, 2606:50c0:8001::154, 2606:50c0:8000::154, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8002::154|:443... failed: Connection timed out.
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8001::154|:443... ^C

Accessing the same link from a webbrowser instantly loads the ros2.repos file.
Adding an entry "22.214.171.124  raw.githubusercontent.com" to /etc/hosts also solves the issue:
$ wget https://raw.githubusercontent.com/ros2/ros2/rolling/ros2.repos
--2023-05-17 14:52:18--  https://raw.githubusercontent.com/ros2/ros2/rolling/ros2.repos
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 188.8.131.52
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|184.108.40.206|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12144 (12K) [text/plain]
Saving to: 'ros2.repos.1'

ros2.repos.1                                     100%[=======================================================================================================>]  11,86K  --.-KB/s    in 0s

2023-05-17 14:52:18 (124 MB/s) - 'ros2.repos.1' saved [12144/12144]

So I think it is an ipv4 vs ipv6 issue.
Though I have no idea why it works from the browser but not from the terminal.
Any suggestions on how to debug this?
Comment: Must be an IPv6 issue. I only get to see IPv4 addresses for that server.
Comment: @Jos It is not just that server, that's just an example. E.g.
`ping www.google.com
PING www.google.com(ams15s41-in-x04.1e100.net (2a00:1450:400e:802::2004)) 56 data bytes`
does not work either, whereas ipv4 ping does work:  `ping -4 www.google.com
PING  (184.108.40.206) 56(84) bytes of data.
64 bytes from ams15s41-in-f4.1e100.net (220.127.116.11): icmp_seq=1 ttl=58 time=30.7 ms`
Comment: Ignore my last comment.  You are having an IPv6 DNS issue.  I'll get back to ya about what to possibly check.  But, have you checked if your IPv6 is working in a web browser?  https://test-ipv6.com/
Answer: Apparently wget may have issues with IPv6 addresses occasionally. There is an option that can be set so that it always uses IPv4 addresses only:
Adding inet4_only = on to /etc/wgetrc should resolve this.
Credits to wget and ipv6 problem?
Comment: It is not a specific problem with `wget`, e.g. ping isn't working either for ipv6 addresses.
Comment: Okay, can you post the output of `ip a`? There is the option of disabling IPv6 altogether, if it acts erroneously. https://itsfoss.com/disable-ipv6-ubuntu-linux/


How to prevent DataTables from displaying or hiding columns on the basis of an obsolete saved state

Question: I have a table driven by DataTables 1.10. Filtering is turned on. When I talk about "doing a search" below, I'm talking about using the filtering function of this table.
Description of the Problem
Everything works fine with stateSave off. However, when stateSave is on, the following happens:

Alice logs in as admin. Because admin has all privileges, when she does a search through articles, she can see all articles. Because some articles are published and some are unpublished the table has a column that show which are published and which are not. So far so good.
Bob, a random user, accesses the site. Random users cannot ever see unpublished articles so the table hides the column that shows publication status. So far so good.
Alice logs out. She now accesses the site like a random user. So she should see exactly what Bob sees. However, when she does a search she still sees the column that indicates publication status.

(Note: The issue I'm discussing here is purely one of user interface. The server ensures that unprivileged users cannot ever get a record for an unpublished article. The problem though is that the additional column gives unpriviledged users information that they do not need. They can only see published articles in their search so they don't need to see that every article they get in a search is published.)
The code that configures the datatable hides the publication column by doing something like this:
var columnDefs = [];
if (!privileged) {
    columnDefs.push({
        targets: [1],
        orderable: false,
        visible: false
    });
}

columnDefs is passed to DataTables as the columnDefs option.
Technical Reason for the Problem
The problem is that DataTables store things like column visibility into the state it saves into localStorage. So when Alice logs out and makes a search again as an unprivileged user, even though the value of columnDefs is correct, it is overwritten by the saved state. That state was stored when Alice was an admin, and it declared the publication column to be visible, so it remains visible even when Alice is accessing the site as an unprivileged user.
What I want is for users to benefit from the saved state but avoid having this state carry over when the user's privileges change.
Caveats:

I don't want to use sessionStorage because I want the state to persist between browser closings, but sessionStorage is cleared when the browser is closed.
I cannot use the session cookie assigned by the server to detect logins and logouts because it is HTTP only. Besides, privileges could change for other reasons.
I do not want to arbitrarily set an expiration time on the saved state.
Answer: The solution I've settled on is to use an additional field in the saved data to know when the conditions I care about have changed. This is a field whose value changes depending on the privileges that the user currently has. For instance, because in the case I described here, I decide to hide or show a column on the basis of a variable named priviledged (which is initialized from data provided by the server), it could be as simple as:
var token = privileged;

Then I set stateSaveParams to record the token when the state is saved:
stateSaveParams: function (settings, data) {
    data.myapp_token = token;
}

The prefix myapp_ is just there to avoid possible collisions with DataTable's own fields.
I set stateLoadParams so that if the current value of token differs from what has been recorded before, the state is cleared:
stateLoadParams: function (settings, data) {
    if (data.myapp_token !== token) {
        this.api().state.clear(); // Clears the state.
        return false; // Tells DataTables to not use the state that was stored.
    }

    // This return is here to keep the IDE happy but does not do anything special.
    return undefined;
},

I've just set token to the single condition I've shown in my question (privileged) in this example but in production I use a combination of variables plus a local version number so I can bump the value of token as needed if I do something that requires clearing the state but cannot be detected just as a privilege change.
Comment: Great answer!!!!
It actually helped me: specially cause I'm planning on several incremental deploys and there will be times when I'm gonna need to "reset" the user saved states and times when not: which is all a question of changing  the token. THANKS!


How can I determine what the minimum working pressure is for a gas range?

Question: I have recently purchased a range top, converted it to propane and am planning to use it with a 5 gallon propane tank.
When I connected it to my tank, I got a second worth of gas flow and then it stopped.
After my plumber troubleshooted with the manufacture for a while, it turns out that new ranges seem to have a minimum working pressure in order to operate.
How is this minimum pressure feature called- so I can look for a different range that doesn't have it?
Comment: If you changed the orifices is there a possibility that debris got into the gas line and is now clogging them up?
Comment: Check the manufacturers installation instructions. It will surely be listed there.
Comment: Do you have a regulator on the tank? If so, what type (high or low pressure), and what is it set for?
Answer: You may not be able to use a 5 gallon (20 lb?) tank as the supply for a range top - effective propane delivery depends on having adequate tank to boil off the required supply of gas - depending on how much the range uses and the temperature, a 5 gallon tank may "freeze up" (really, self-cool) to the point where it does not provide the gas required - a 100-200lb tank is certainly much more standard as the supply for a propane range.
LP stands for Liquified Propane - it has the useful feature for storage and transport of becoming a liquid at relatively low pressures. when you draw gas from the tank, the liquid boils - as it boils, it cools the tank. If the tank is already cold (question is from February) and the gas use rate is high, the pressure in the tank falls to 0 at roughly -40 (F or C) A larger tank has more area to collect heat from so it cools more slowly for the same rate of gas use.
Using the correct regulator (for delivery pressure with adequate tank pressure driving it) is also required...
This previous answer may also shed more light on the subject.
If my regular propane tank for the house runs out, can I use a BBQ tank as a temporary fix?
Answer: The specs for the range will list the minimum pressure required, likely with verbiage along the lines of "Minimum Xinch water column" or "Minimum X psi".
All gas appliances have a minimum requirement, and while it will vary between units, its not something that only applies to new ranges.
Comment: I'm not sure minimum pressure is a spec that's typically listed.  It will likely be included in the installation instructions, but not likely in the specs.
Comment: I guess it depends on manufacture.  I downloaded a two page reference guide for all of my appliances with all of the measurements, electrical specs, gas specs, etc.
Answer: One thing that you may need to take care of is the conversion of the gas orifices. If the range top that you purchased was setup for natural gas usage you would have to change the orifices for propane usage.
Comment: The OP mentions that they converted the range to use propane, which I would assume includes changing the orifices.


Regular expression and Boost

Question: I have a problem with the following regex in boost:
const boost::regex eComment("^\/\*[\s\S]*?\*\/|^\/\/");

When I run program with this regex, it's aborted with message:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::regex_error> >'

what():  Invalid preceding regular expression prior to repetition operator.
The error occured while parsing the regular expression: '^/*[sS]*?*>>>HERE>>>/|^//'.

This regexp should find lines with comment in *.cpp file, but should skip if there is code in the line.
Comment: I don't know anything about boost, but I think you may have an issue.  [\s\S] translates to "a whitespace char OR not a whitespace char".  I think it should be one or the other.  And normally forward slashes don't need to be escaped in a regex (unless it is Perl and the / is your delimiter).
Comment: I think what you want is this.  ^\s*(/\*.*?\*/|//)  ... start of line plus zero of more spaces followed by the comment.  And the comment is either "/* any number of chars */" or "// anything".  If you need to escape backslashes because they are special in C, then it would be ^\\s*(/\\*.*?\\*/|//)
Comment: `[\s\S]*?` = `0 or 1 of 1 or more characters`?
Answer: I think the problem is that you forgot to escape the backslash characters. Each backslash should be doubled like \\s\\S instead of \s\S
Hope it helps

Regular expression and Boost