Image files not loading through jquery ajax from server cpanel

Question: I don't know if this is a duplicate question but i have searched and couldn't found solution for this
I am newbie in cpanel and i recently uploaded my project in it. Now there is a part in my website where i am loading a folder of images through jquery ajax. Now this was working perfectly in the local server xampp but not in the server it keeps giving 404 error that means that the files not being discovered by the ajax script. For security reasons i am not going to share the links right now but i will explain the full procedure
These are the location of those folders. These scripts are in js folder. But obviously it is included in index page. anyway lets move
var svgFolder = "img/svg/";
var productImagesFolder = "img/ImagesForProducts/";

Following are the ajax scripts that i am using to load the images of these folders
$.ajax({
    url: svgFolder,
    success: function (data) {
        $(data).find("a").attr("href", function (i, val) {
            if (val.match(/\.(jpe?g|svg)$/)) {
                $(".svg-shapesDiv").append("");
            }
        });
    }
});
$.ajax({
    url: productImagesFolder,

    success: function (data) {
        $(data).find("a").attr("href", function (i, val) {
            if (val.match(/\.(jpe?g|jpg)$/)) {
                $("#avatarlist").append("");
            }
        });
    }
});

All of this is working fine in localhost server but for some reason when i uploaded them in the cpanel it stopped working.
I tried hard coding the img tag like this

Things i tried
And this works fine so i think that the ajax is not figuring out the address. I also tried to search the image through link in the browser like this domainname.com/img/svg/file.svg and it works fine as well. i also tried to give ajax the path like this domainname.com/img/svg/file.svg but it doesn't work. I checked the file capitalization etc but everything is correct
If this was a stupid question then i am sorry but i don't know that what i am doing wrong and i am also new to cpanel and live hosting stuff.
Comment: Is there some index.php file under img/svg/ that gathers the list of files to return to the ajax call? If there is no script on the server side that builds up the html you receive back then are you relying on indexes? If so then indexes might be disabled by default, you'd want a htaccess to enable them but better yet have a server side script to gather the file names and return them in a better format like json rather than html to be processed client side.
Comment: Thank you for commenting. I don't have any index.php file under img/svg/ and the thing is i don't have much knowledge of htaccess, i don't know why an index.php file is needed inside img/svg folder, i don't know about indexes. Could you send me a link from where i can learn this stuff or just the term. I am sorry for being this dumb the thing is i code and all but never tried to upload etc and never took any tutorial for this stuff because it wasn't needed so could you tell me this so i can learn it :)
Answer: Based on the response to my comment it sounds as though your xampp has "indexes" enabled by default. Please see here: https://httpd.apache.org/docs/2.4/mod/mod_autoindex.html
It may be that on your shared webhosting they are disabled by default and you would need to enable them for those 2 directories. As you are using cpanel please see here: https://docs.cpanel.net/cpanel/advanced/indexes/82/ but this can also be achieve by adding a .htaccess file to the 2 folders containing Options +Indexes.
The trouble with relying on indexes this way is that different servers could potentially return slightly different html so you could find that your xampp server returns html links (your JavaScript searches for anchor tags and gets the href from there) but the shared server may not return links it may just return the file names. Also with this html being returned your JavaScript has to parse that html, search all links and extract the href. I would therefore recommend writing a php script that gathers the relevant files and returns only those in JSON format. Much easier then for the JavaScript to parse and use and you now have full control of what is returned whether it is on your xampp server or other hosting. You can call this script whatever you want and you can place it wherever you want. You could even have one script that accepts query parameters from your AJAX call and from those it know which folder to look into and what types of files it must gather from the folder. This also has the advantage of keeping all other files in those folders hidden from prying eyes.


How to make Python read from local dist-packages or site-packages instead of global dist-packages? ModuleNotFoundError: No module named 'azure.cosmos'

Question: First of all, this answer explains three python package locations nicely, I am giving a brief summary of them first, in my case for the azure-cosmos python package these are:
First, Global dist-packages, controlled with sudo apt-get (before installing a newer version with pip3 it shows ver 3.1.1):
$ sudo apt-get install python3-azure-cosmos
...
$ pip3 list -v | grep azure-cos
azure-cosmos 3.1.1 /usr/lib/python3/dist-packages

Second, Local dist-packages, installing with sudo pip3
$ sudo pip3 install -U azure-cosmos
...
$ pip3 list -v | grep azure-cos
azure-cosmos 4.2.0 /usr/local/lib/python3.8/dist-packages pip

Third, Local site-packages, (removed with sudo pip and then) installed with pip3 (without sudo)
$ sudo pip3 install -U azure-cosmos
...
$ pip3 list -v | grep azure-cos
azure-cosmos 4.2.0 /home/me/.local/lib/python3.8/site-packages pip

However, in all three cases my Python is looking ONLY in the (first) global dist-packages (that contains an older package version):
$ python3 -c "from azure.cosmos import CosmosClient"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'CosmosClient' from 'azure.cosmos' (/usr/lib/python3/dist-packages/azure/cosmos/__init__.py)

I do have $PATH and $PYTHONPATH set properly to include the local dist-packages and local site-packages locations, Python actually shows them in sys.path before global dist-packages:
$ python3 -c "import sys; print([p for p in sys.path])"
['', '/usr/local/lib/python3.8/dist-packages', '/home/me/.local/lib/python3.8/site-packages', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/lib/python3/dist-packages']

So why is Python taking the old version of azure-cosmos that came with the distro instead of getting a newer version that I have installed with pip? What am I missing here?
(I did try to update the python3-azure-cosmos package but 3.1.1 seems to be highest available via apt-get, and that's not the point of the question)

An easy solution is to remove the GLOBAL dist-packages version, one can simply run:
$ sudo apt-get remove python3-azure-cosmos

Then Python magically uses a version from either local dist-packages or site-packages from my home dir (package installed via sudo pip3 or pip3 respectively), because the package does not exist in global dist-packages.
But... my problem is that I cannot run sudo in this case. So I cannot remove the global package. Halp.
Answer: Try to use the below command to Uninstall/Remove the packages without using sudo privileges
rm -rf <Package_Directory>
Linux rm -rf is a powerful command deletes directory forcefully. It means a file or directory will be removed. Even though it has read-only permission.
Comment: Without sudo I don't have permissions to remove from /ust/lib/python3/dist-packages
Answer: A possible workaround (but not a solution) to this and a similar issue I had one day later is to just use a python virtual environment, e.g. using pipenv:
$ pip3 install --upgrade pipenv
$ pipenv install azure-cosmos
$ pipenv run python -c "from azure.cosmos import CosmosClient"

And we have empty output so there is no import error anymore, meaning that it works.


Is it acceptable to frame and drywall just one exterior wall in a basement?

Question: Unique question here...am going to put the epoxy pebble stone floor in eventually.  Want to use the inside wall for a flat screen and entertainment center.  Basement is dry, with cinders.
Is it common to put dry wall up on the inside (left) wall but not on the remaining walls   See picture
Comment: It is not unusual to find basements with "some" walls finished and others left unfinished.
Comment: It's funny that your question is "unique", but the actual questions starts with "is it common...."
Answer: I would suggest that you plan out the entire basement before you frame the one wall. Figure out what you would like the entire space to become (eventually) and make sure that the one wall that you are framing will fit in with those plans, or at least is flexible with future plans. It's not fun down the road having to rip down sections of a new wall to accommodate new plans, ESPECIALLY if you were the one to frame the first wall.
While you are at it, make sure to run all the cables and future proofing items that you would want in the future in this one wall, or provide an easy way to have them installed. Install conduit (if possible) for power and another for telecommunications (Cat5e/Cat6, Telephone, etc). If you don't want to run conduit, at least pre-drill the holes, and leave a pull string in the holes to help with fishing wires. I wish I thought of this before finishing portions of our basement.
Answer: You can certainly frame and finish just one wall. Obviously you won't see substantial benefits if you insulate. It would be nice for in-wall electrical and easy mounting of fixtures.
That said, You wouldn't have to go to all that trouble just to mount a tv. Concrete screws (Tapcon) and the right brackets would make quick work of setting up an entertainment center if you're ok with painted block as the wall finish. Concrete block drills easily when using appropriate bits. The challenge would be setting up wiring in an aesthetically pleasing way, but that's possible as well.


Can I set a default namespace in Kubernetes?

Question: Can I set the default namespace? That is:
$ kubectl get pods -n NAMESPACE

It saves me having to type it in each time especially when I'm on the one namespace for most of the day.
Comment: Are you looking for environment variable? [Create env. variable](https://askubuntu.com/questions/58814/how-do-i-add-environment-variables)
Comment: Kubectx and kubens both provides great flexibility together
Comment: 'default' Namespace is literally a namespace and what you are basically asking for is how to set "current" namespace to save typing efforts everytime, for my bash session or inside kubectlConfig, which has been already answered.
Answer: Yes, you can set the namespace as per the docs like so:
$ kubectl config set-context --current --namespace=NAMESPACE

Alternatively, you can use kubectx for this.
Answer: You can also use a temporary linux alias:
alias k='kubectl -n kube-system '

Then use it like
k get pods

That's it ;)
Comment: Consider using the [kubectl-aliases](https://github.com/ahmetb/kubectl-aliases) project to do things like this :)
Comment: @EduardoBaitello I feel uneasy having so many aliases on my system when I only use a handfull.
Answer: I used to use the aliases shown below and set the variable N to the namespace to use.
# Set N=-nNamespace  if N isn't set then no harm, no namespace will be used
alias k='kubectl $N'
alias kg='kubectl get $N'
alias ka='kubectl apply $N'
alias kl='kubectl logs $N'

To switch to the my-apps namespace; I'd use:
N=-nmy-apps

After this the commands:
kg pods

actually runs kubectl get -nmy-apps pods.
NOTE: If the bash variable N is not set, the command still works and runs as kubectl would by default.
To override the namespace set in N variable simply add the --namespace option like-nAnotherNamespace and the last namespace defined will be used.
Of course to more permanently (in the current shell) switch, I'd simply set the N variable as shown:
N=-nAnotherNamespace
kg pods

While the above works, I learned about kubens (bundled with kubectx, See github) which works more permanently because it updates my $HOME/.kube/config file with a line that specifies the namespace to use for the current k8s cluster I'm using (dev in the example below)
contexts:
  - context:
        cluster: dev
        namespace: AnotherNamesapce  <<< THIS LINE IS ADDED by kubens
        user: user1
    name: dev
current-context: dev

But all kubeens does is what is already built into kubectl using:
kubectl config set-context --current --namespace=AnotherNamespace

So really a simple alias that is easier to type works just as well, so I picked ksn for (kubectl set namespace).
function ksn(){
  kubectl config set-context --current --namespace=$@
}

So now to switch context, I'm just using what is built into kubectl!
To switch to the namespace AnotherNamespace, I use:
ksn AnotherNamespace

Tada!  The simplest "built in" solution.
Summary
For bash users, add the following to your $HOME/.bashrc file.
    function ksn(){
        if [ "$1" = "" ]
        then
            kubectl config view  -v6 2>&1 | grep 'Config loaded from file:' | sed -e 's/.*from file: /Config file:/'
            echo Current context: $(kubectl config current-context)
            echo Default namespace: $(kubectl config view --minify | grep namespace: | sed 's/.*namespace: *//')
        elif [ "$1" = "--unset" ]
        then
            kubectl config set-context --current --namespace=
        else
            kubectl config set-context --current --namespace=$1
        fi
    }

This lets you set a namespace, see what your namespace is or remove a default namespace (using --unset).  See three commands below:
# Set namespace
ksn AnotherNamespace

# Display the selected namespace
ksn
Config file: /home/user/.kube/config
Current context: dev
Default namespace: AnotherNamespace

# Unset/remove a default namespace
ksn --unset

See also: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ for the command to view the current namespace:


Do I always need a web server with spring integration?

Question: I'm new to spring-integration and what I want to acheive is lanching a spring-batch job from an external web application.
Batchs are run in two diffrent maners. Cron (outside of the scope of this question) and started manually by a user action like shown in the picture below

Now each batch is configured like the following :
@SpringBootApplication
@EnableBatchProcessing
public class Batch1Application {

    public static void main(String[] args) {
        new SpringApplicationBuilder(Batch1Application.class)
                .web(WebApplicationType.NONE)
                .registerShutdownHook(true)
                .run(args);
    }
}

Currently when the web app receives an action it calls the same sh script used in by cron configuration :
//...
ProcessBuilder processBuilder = new ProcessBuilder(List.of(/*path to batch-1-script.sh*/));
Process process = processBuilder.start();
//...

The script do something like : java -jar batch1.jar
It works fine and contexts of each application is not shared.
Now I want to move to spring-integration. I've found several articles/videos that talk about spring-integration and spring-batch-intergartion, But all use the same web-app to launch jobs using a simple DirectChannel (as context contains all the needed beans).

My question is how to keep each batch listening for messages to come and then start executing ?
Do I need to convert them all to web app and add spring-integration on them ?
Comment: No, you do not need a web server to use Spring Integration, and your application does not need to be a web app. You can have any kind of Java app that puts something on a Spring Integration channel to let it do what it needs to do. The putting something on a channel does not necessarily need to be done from a Spring MVC controller, for example.
Comment: if no server is needed, how my batch (jvm) listen to the incoming messages ? Currently each batch is running in a separate jvm (process) and shutdown just after it is done
Answer: Spring Integration is just a library and it fully is not tied to any container specifics. If you need to expose an interaction with your application via HTTP, only then you need to have this application on Web server.
It is not clear from your description what does that batch-1-script.sh do to start the batch application, but probably you can live this feature and just change its service implementation to emit a message to a channel instead of direct job execution call as it is right now.
On the other hand you can take any messaging broker in between and publish a message to the topic to let those apps to listener for such a message on their side.
See possible endpoints in Spring Integration for this solution: https://docs.spring.io/spring-integration/docs/current/reference/html/endpoint-summary.html#spring-integration-endpoints.
Also, since you say that you can some script at a the moment, it sounds like everything is done on the same host, so probably you can take an advantage from ZeroMQ as a protocol between Web APP and those workers: https://docs.spring.io/spring-integration/docs/current/reference/html/zeromq.html#zeromq
Comment: thank you for the answer, I can see more clearly now
Comment: It seems I have similar requirement. I have to deploy around 8 java batch job (docker container) in separate web app on one Azure app service plan(Premium V3). Java batch code need to be modify to include spring batch scheduler so that batch jobs can be schedule to run at different time through code itself and some will trigger based on new file arrival at storage location.  For trigger based do we need to convert batch code to Rest api. If yes then will rest api will be able to handle batch .csv processing million of records. IF possible could you please share your experience


Add apex SQL Server with replace

Question: I need to add an apex in a specific point of a formula in SQL Server, in a lot of rows. Can I do this with a script? I tried but SQL doesn't understand apex "like a string"
CAMPO XYZ:
X NOT IN (SELECT A FROM #ABC# WHERE APPLE = 'NO')
AND ISNULL(ISNULL(SUNNY,'),'NO') <> 'YES'
AND (VEG = 'CARROTS')

My idea:
DECLARE @a varchar(100)
DECLARE @b varchar(100)

SET @a = 'SUNNY,'';
SET @b = 'SUNNY,''';

UPDATE A
SET A.XYZ = REPLACE(A.XYZ, @a, @b)
FROM...

I need to replace the wrong one apex with double apex for that ISNULL.
Can you find the correct syntax?
Answer: Apex, i guess you mean quote?
Every quote must be quoted again, so something like this should work:
DECLARE @a  varchar(100)
DECLARE @b  varchar(100)

SET @a = 'SUNNY,''';
SET @b = 'SUNNY,''''';

UPDATE A SET A.XYZ= REPLACE(A.XYZ,@a,@b) FROM...

Add apex SQL Server with replace


Is it possible to have the menu link color change on the table hover for an asp.net menu control?

Question: I'm using an ASP.net menu and when i hover inside my menu item's table, i change the background color on the table column, but unless i hover over the link text itself, the link text color will not change.
Is it possible to have the link text color changed on the table hover?
Example below shows what happens.

Excuse the ugly CSS:
.TopStaticSelectedStyle
{
    cursor: pointer;
    font-size: 11px;
    font-family: Verdana;
}

.TopStaticMenuStyle a,
.TopStaticMenuStyle a:visited,
.TopStaticMenuStyle a:active
{
    color: #ffffff;
    text-decoration: none;
    font-weight: bold;
    font-family: Verdana;
}
.TopStaticMenuStyle a:hover
{
    color: #000000;
    text-decoration: none;
    font-size: 11px;
    font-weight: bold;
    font-family:  Verdana;
}

.TopStaticMenuItemStyle td
{
    padding: 0px 12px 0px 12px;
    text-align: center;
    background-color: #6c85b0;
    height: 18px;
    border-top: solid 1px #012754;
    border-bottom: solid 1px #012754;
    border-left: solid 1px #012754;
    border-collapse:collapse;
}

.TopStaticHoverStyle
{
    font-weight: normal;
    font-family: Verdana;
}

.TopStaticHoverStyle td
{
    padding: 0px 12px 0px 12px;
    text-align: center;
    background-color: #ffffff;
    height: 18px;
    border-top: solid 1px #012754;
    border-bottom: solid 1px #012754;
    border-left: solid 1px #012754;
        border-collapse:collapse;
        color: #000000;
}

Answer: I scrapped your css and just started from scratch but you should be able to get the idea from this.
So some basic table html:

            Test

            Test 2

And then the css:
a {
    color:#000;
}
td {
    border:solid 1px black;
    background:#234567;
    padding:5px 10px;
}
td:hover {
    background:#eee;
}
td:hover a {
    color:#ccc;
}
td a:hover {
    color:#777;
}

The key here is the td:hover a selector which is what you need to change the color on hover of the td.
Comment: Another method is to make the `a` tag `display: block;` and do all the color switching on that.  Shown here: http://jsfiddle.net/2xdwJ/3/
Comment: BOOMSHAKALAKA!! John, you nailed it. Thanks! Matthew, i tried your method but the asp.net menu was being a bit buggy about it. I see it does work in your example though


What is wrong with my PSP's thumbstick to make a character walk the opposite direction

Question: Recently i've been noticing that when i push up in the thumb stick my character actually moves down, i've mainly been noticing this in Disgaea in the overloads castle where using the thumbstick is preferred for movement there
Now at first i thought that maybe the stick was wearing out cause it's a first gen PSP and i've never swapped it (the second one i got was for the purpose to play on the TVT, not a replacement) but thinking back evidence of that would be the character automatically moving up because i used to play a lot of Dissidia Final Fantasy
So i'm wondering what could be wrong with my thumb stick that it would make a character move down when i press up, what actually happens is that Lahal moves up but then stops and starts switching his facing front front to back and start slightly move downwards, if i move the stick slightly to the right he moves strait down and because of the thumb stick i can't down exactly the position of the stick
Comment: Is this happening only in Disgaea?  Or does it happen in other games?  That will determine whether it's a game setting, or your PSP.
Comment: @fbueckert it happens in Shin Megami Tensei: Persona but i rarely use the thumb stick in it, sometimes in menus the cursor would keep moving down
Answer: The problem might be an issue with calibration. Sometimes the stick sets the center of its movement range to somewhere other than the center due to getting worn out.
Try going to the Settings area of the PSP's main menu, then down to System Settings section, then to the System Information section, and on that screen, try rotating the stick along the very edge of it's available area a few times, and see if that helps .
Comment: Then the symptoms would be walking when the stick isn't being touched. Miscalibration wouldn't reverse the axis.
Comment: True. Rereading the question, I realized that I had misunderstood what Memor-X meant with the "slightly moving downwards." However, calibrating couldn't hurt to try.
Comment: @WingManEXE your initial answer is what i originally thought, i'll try the recalibration thing when i get home from work
Comment: @WingManEXE wow, i can not believe that did something, when i started up disgaea i was almost fixed, the symptom did occur for a brief moment but i haven't came across it since, though this is probably only a band aid solution, is the system menu option also a calibration tester as well?
Comment: @Memor-X How do you mean calibration tester? Like, are you asking if it will tell you if it's calibrated? Because sadly it can't do that. However, once it's been recalibrated, the PSP usually remembers the new calibration settings for a while. I had to recalibrate mine about 5-6 months ago, and it's still good.
Comment: @WingManEXE by Calibration Tester i'm talking about something like the touch screen Calibration Tester you get at the end of the calibration settings on the Nintendo DS
Comment: Ah, I see. Sadly, it's not, since the control stick isn't compatible with the PSP's main menu for some silly reason. Most games use it however, so I've just gone to a game to see if it worked.


How do I deploy Polymer3 App to GH Pages?

Question: I have created a polymer3 app using the Polymer CLI. I cannot seem to configure the polymer.json file properly so that when I deploy to GH pages everything loads correctly.
At the moment my polymer.json looks like this:
<code>{
"entrypoint": "index.html",
  "shell": "src/site-app/site-app.js",
  "sources": [
    "src/site-app/**",
    "package.json",
    "css/**",
    "js/**"
  ],
  "extraDependencies": [
    "manifest.json",
    "node_modules/@webcomponents/**",
    "node_modules/@polymer/**",
    "node_modules/@fabricelements/**",
    "node_modules/web-animations-js/**"
  ],
  "moduleResolution": "node",
  "npm": true,
  "lint": {
    "rules": [
      "polymer-3"
    ]
  },
  "builds": [{
    "preset": "es6-unbundled"
  }]
}
</code>
And the Errors I see in my Dev Console on Chrome are the following

<code>web-animations-next-lite.min.js:1 Failed to load resource: the server responded with a status of 404 ()
web-animations.min.js:1 Failed to load resource: the server responded with a status of 404 ()
webcomponents-loader.js:1 Failed to load resource: the server responded with a status of 404 ()
8
website.github.io/:1 Uncaught TypeError: Failed to resolve module specifier "@polymer/polymer/polymer-element.js". Relative references must start with either "/", "./", or "../".
</code>
How can I fix my polymer.json so I will properly deploy to GH Pages?
Answer: polymer.json is only the configuration for polymer build. Github Pages wont download or host anything for you except whats in your repo. So you need load anything not in your repo (npm dependencies) from a cdn like https://cdnjs.com .


How to destroy previous instance of window?

Question: I have a button with a click function like this
var win = Ext.create('Ext.window.Window', {
                            title: 'We want your Feedback!',
                            cls: 'Hub-feedback-form',
                            //height: 320,
                            width: 300,
                            layout: 'fit',
                            closable: true,
                            closeAction: 'destroy',
                            items: [form]

                        });
win.show();
winVisible++ //winVisible is a global variable declared as 0.
if(winVisible % 2==0)
{
win.hide();
}

But what is happening is it is creating multiple instances of win, so everytime an insstance remains, how to modify the code so that every open instance of win gets removed. Please help!
Answer: You can call win.close(), it will remove the component and destroy it.
Comment: I want to hide the window on second click of button, but one instance of win remains no matter what I do.
Comment: Hiding does not destroy a window, only makes it invisible. If you call `destroy`, it will be destroyed as an ExtJS component, but that does not mean that the variable `win` will be `null` or `undefined`. Even destroyed components can be still available from JS code, see for example [`destroyed`](https://docs.sencha.com/extjs/6.2.1/classic/Ext.window.Window.html#property-destroyed) property of `Ext.window.Window`.
Comment: Eventually JS garbage collection will take care of unreferenced objects.
Comment: yeah, i get it, but how to hide that window component, means the window will retain the values(if any) inserted into the form
Comment: If you keep `win` variable and don't create the window if it already exists (`if (!win) {win=Ext.create...}`), and `form` variable holds the form, it should retain state if you `hide` and after `show` it.
Comment: if I dont create the window, it says win is undefined
Comment: got it, i gave the window an id and set it to hide and it got hidden. Thanks :)


Remove illegal markup from xml string (node starting with number)

Question: I am converting a JSON Array to a XML string:
JSONArray json = new JSONArray(response);
xml = XML.toString(json);

and unfortunately the result contains nodes like
<24x24>blah</24x24>
Afterwards I want to create a 'real' XML Node with SAXBuilder which produces following error:
The content beginning "<2" is not legal markup. Perhaps the "2" ( ) character should be a letter.
Does anybody know how to remove this illegal markup from the XML String?
Maybe a regex which replaces <24x24>blah</24x24> with <t24x24>blah</t24x24>?
Thank you!
Answer: You can try using String.replaceAll() method with regex. Live demo
System.out.println("<24x24>blah</24x24>".replaceAll("(<\\/?)(?=\\d)", "$1t"));

output:
<t24x24>blah</t24x24>


NativeScript Angular - Unable to navigate between sibling views located in different page-router-outlets

Question: I have this TabView component:
<TabView androidTabsPosition="bottom">
  <page-router-outlet *tabItem="{title: 'Item 1'}" name="map"></page-router-outlet>
  <page-router-outlet *tabItem="{title: 'Item 2'}" name="subscribe"></page-router-outlet>
</TabView>

Router config:
  {
    path: '',
    redirectTo: '/(map:map//subscribe:subscribe)',
    pathMatch: 'full'
  },
  {
    path: 'map',
    loadChildren: '~/app/routes/+map/map.module#MapModule',
    outlet: 'map'
  },
  {
    path: 'subscribe',
    loadChildren: '~/app/routes/+subscribe/subscribe.module#SubscribeModule',
    outlet: 'subscribe'
  }

In the feature module SubscribeModule I have a function which should navigate to the map route:
// The NativeScript router service
constructor(private router: RouterExtensions) {}

navigate(args) {

  const item = this.items[args.index];

  this.router.navigate(['map'], {
    transition: {
      name: 'slideLeft',
      duration: 300
   }
  });
}

But all I keep getting is Error: Cannot match any routes. URL Segment: 'map'.
I have also tried the following:

Navigating to the named outlet with this.router.navigate([{outlets: {map: 'map'}}]
Navigating with this.router.navigate(['../', 'map'])
Navigate using navigateByUrl

But they all yield the same result.
What could I be doing wrong?
Comment: @DanielN. I can confirm that changing the `selectedIndex` of the `TabView` after navigating works. Just use a service with a subject and trigger it when navigating then you can just subscribe to the subject observable in whatever component your `TabView` is in and change the index accordingly.
Comment: I think when you have multiple outlets you have to satisfy the URL that contains segments for all outlets. Refer [template-tab-navigation-ng](https://github.com/NativeScript/template-tab-navigation-ng) for clean examples.
Comment: Hi, were you able to solve this in any way? I'm having the exact same problem.
Comment: @DanielN. Nope.. :/ I think one solution might be to first change the selectedIndex of the TabView and then try to navigate.. but that would probably break as well..
Comment: Thanks, I will try this in the next few days and let you know if it works. I'll most likely use a Subject inside a service and tie it to the selectedIndex property so it can be changed from any component.
Comment: Great to hear, thanks for trying it out. You should post it as an answer and mark it accepted for future reference.
Answer: Please try below
this.router.navigate(["/map"], {
    transition: {
      name: 'slideLeft',
      duration: 300
   }
  });
try adding private activeRoute: ActivatedRoute in component
this.router.navigate([{ outlets: { search: ["map"] } }], { relativeTo: this.activeRoute });
Comment: I have same problem and i solved it using above both approach for details you can look into docs https://docs.nativescript.org/angular/core-concepts/angular-navigation  it might solve your problem
Comment: That gives `Error: Cannot match any routes. URL Segment: 'subscribe'`, which is odd since it's not subscribe I'm trying to navigate to...


Make queuename in JMSTemplate dynamic based on type of record

Question: I am using JSMItemWriter in a spring Batch application.
Is it possible to dynamically set the queue name or dynamically define a jmsTemplate at runtime instead of defining it as a bean in the code
Depending on the type of record passed to the JSMItemWriter, i would need to write to a different queue.
Answer: You can configure a jms writer for each queue and use a ClassifierCompositeItemWriter. This composite writer will classify items dynamically at runtime and call the delegate writer accordingly.


How do I find attribution for a chess problem I have come across and want to ask a question about?

Question: Let's say I wanted to ask a question about a chess problem I found, to learn about the strategy behind it, but I also want to give attribution to the author. However, I don't know who the author is and extensive searching hasn't brought up anything useful. What can/should I do to find the author then? Are there any known tools that could help aid me?
Answer: One way that you can find who created a chess problem is by using chess problem databases, which are more or less giant Wikipedias for chess problems. Here are a few that are easy to use and widely used, along with small guides on how to use them.

Yet Another Chess Problem Database

Note: Instead of the English notation "N" for knight, YACPBD (the site's acronym) uses "S" for the knight, as it reserves "N" for the fairy chess pieces called [nightriders](https://en.wikipedia.org/wiki/Nightrider_(chess).

Die Schwalbe Chess Database Server

Forewarning: The Die Schwalbe database is a German site that uses German chess notation.
(More coming soon)


Makita impact screwdriver was dropped, now it doesn't work. Prospects?

Question: I dropped a brand new impact screwdriver (Makita XDT 14) and now it won't work. It's like it's has no power? I know it's a good battery. The work light doesn't work, nor do settings indicators.  Any chance of fixing it?
Comment: Guessing it was too much impact.
Comment: There's not much we can do with that information. There is no reset switch or anything like that. You can try another battery to make sure that's that battery you are using now. The instructions have a troubleshooting section, I suggest looking that over
Comment: So dropped it 5 feet or 50?
Answer: If it's brand new, take it back to where you purchased it and get another one. Makita has great warranties on their products. Don't try to take it apart or otherwise fix it or you'll void the warranty. Good luck.
Comment: I agree that if under warranty and no visible damage I would take it back.

Makita impact screwdriver was dropped, now it doesn’t work. Prospects?


NodeJS find if file or folder is hidden

Question: What the title says, how do I find if a file or folder is hidden using NodeJS? Please don't just refer me to some npm package that's suppose to do that (been there, done that), only answer if you have working code and show that code. Thanks.
Comment: Share the code you wrote. Share what your expectations were and how they failed. Usually all you have to do is to see if the file or directory starts with a `.`
Answer: hidden files are already displayed when reading for exemple a dir they just have a dot in front of them
<code>//Require fs (node filesystem)
var fs = require("fs");
//Read folder syncronously with fs (node filesystem)
var folder = fs.readdirSync("/path/to/folder/")
//Print to the console a stringified version of the array returned by folder read
console.log(JSON.stringify(folder))
</code>
Exemple of what could be printed to the console:
<code>["file", ".hiddenfile"]
</code>
As you can see the hidden files are displayed with a dot (".") at the start of their name: "hiddenfile" => ".hiddenfile"
Comment: "*they just have a dot in front of them*" This is a UNIX-specific convention and in no way is a cross-platform solution. Windows does not hide files beginning with a `.`.
Comment: Then use this npm package as so:
```bash
npm i is-hidden-file
```
Then write this:
```javascript
var isHiddenFile = require("is-hidden-file").isHiddenFile;

var check = isHiddenFile("path/to/file");
console.log(check); //true or false
```

NodeJS find if file or folder is hidden


Lubricant for squeaky doors

Question: I'm looking for a long term solution to my squeaky doors.  Our home is fitted with brass hinges on all doors and lately they have all been starting to squeak.  I've tried several silicone based lubricants but none have solved this issue permanently.
Answer: Properly lubricating the hinges should stop the squeaks.  In short, you remove the hinges from the door, lubricate them, and put them back.
You'll want to use white lithium grease.  It works very well for metal on metal contact.
I'm assuming simple door hinges here, like these

You'll want to do each door one at time.
Long Process

Have someone support the door while you knock the hinge pins up and out from the bottom of each hinge.
Lean the door up against the wall and unscrew the hinges from the door and the jamb.
Lay out the hinges on newspaper and use the lithium grease to lubricate the pins and the inside of the barrel.  The barrel is the tube that the hinge pin passes through,
Usually, you let the lithium grease dry before reassembly.  Follow the directions on the grease.
Finally, re-attach the hinge wings to the door and jamb.
With someone holding the door, re-insert the pins from the top.
Enjoy the silence.

Short Process

Have someone support the door while you knock the hinge pins up and out from the bottom of each hinge.
Lay the hinge pin on newspaper and use the lithium grease to lubricate it.
Usually, you let the lithium grease dry before reassembly.  Follow the directions on the grease.
With someone holding the door, re-insert the pins from the top.
Enjoy the silence.

Do one door first, and give it few days to make sure the squeak is gone.
Comment: I like WD-40, and it has it's uses, isn't really a very good lubricant for this type of job.  It will usually stop the squeaks for a short time, and the poster was looking for a permanent solution.
Comment: Any reason you couldn't pull the pins, and then lubricate the barrels while they're still attached to the door and jamb, respectively?  Why unscrew the hinge wings from the door and jamb?
Comment: That sounds like a lot of work.  No offense but I bet you could squirt WD-40 on a whole house full of door hinges in the time it takes to do this to one door.  The WD-40 probably wouldn't last as long as the lithium grease but I think I'd rather use it every year than do this every 5 years.
Comment: @Chris: WD-40'd my doors 5 years ago, still no squeaks not sure if Eternity is what he is after ;)
Comment: @tnorthcutt: Some hinges are anti-pick, such as those to outside doors. You can remove the top and bottom pin but the middle can't be removed without taking the entire hinge off the door (which the screws are typically on the inside if this applies to this type of door - I have one in my house like this).
Comment: Spray Sillicone > WD-40
Comment: Clean the pins and hinges before lubricating. Black brass oxides and other ugly stuff builds up in hinges over the years. Get rid of it and your lubricant will at least start out its life squeaky clean, and less likely to squeak.
Answer: The underlying problem may be that the hinges are not perfectly aligned.
Comment: This is very likely especially if the squeaking is recurring soon after lubricant is applied, as the OP implies.  You can check this by removing the screws from one half of one hinge and seeing if the plate still lines up with its recess when the door is held by the other two hinges.
Answer: Motor cycle chain lubricant or a 3-in-one oil works well. Motorcycle chain lubricant is designed to penetrate and provide lasting protection, though as with any lubricant, it does need to be re-applied occasionally.
Lithium grease is a better option for sure, I just am putting this out there because it can be applied without taking the hinges apart, and works reasonably well. If the hinge is REALLY bad, you'll need to take it apart though.
Comment: +1 for 3-in-1 oil.  That stuff works well.  Can be used without removing the hinge and lasts a surprisingly long time.
Answer: Use WD-40. Works everytime.
Comment: Blasphemy!  Citation please.

I'm looking at a can right now that says "lubricates moving parts such as hinges, wheels, rollers, chains, gears."

Anyway, it makes my door hinges stop squeaking.
Comment: WD-40 does lubricate, but it doesn't last. It is good to clean off a rusty hinge, but is definitely not long-term.
Comment: These things may all be true, but none of them mean it's *not* a lubricant, which clearly it is.
Comment: WD-40 is not a lubricant.
Comment: WD-40 is good stuff, but actually the WD in WD-40 stands for "Water Displacement."  It's primarily a rust and corrosion preventative.  See paragraphs 1-3 at http://www.wd40.com/about-us/history/
Comment: @Chris: Website title says "WD-40 **Lubricates**, Cleans, Protects, Penetrates & Displaces Moisture" - so clearly it is a lubricant.
Answer: I like graphite-based lubricants (like you'll see for loosening a frozen car door lock). Lithium grease is an excellent option, though, too.
Comment: Graphite is good until it gets to your carpet.
Answer: Jigaloo is an amazing lube. If you don't go nuts with it, it dries really quickly. It smells nice, waterproofs, and generally works really well. But, it causes cancer, so don't spray the kids or their toys.
I use it on squeeky things, my leathers, my bike, and my rubik's cube.
Comment: And it smells soooo delicious!
Comment: Jigaloo is silicone-based, pretty much the same as what I was suggesting.
Answer: As others have said, WD-40 is not a "permanent" lubricant, but the spray can is damn convenient.  So, what I would use is Spray silicone.  You can find it in white and clear varieties.  You probably want clear.
(Spray silicone is what my car manufacturer reccomends for lubricating the door hinges.)
My next choice would be 3-in-1 oil.  It is a little more runny though.
No matter what you pick, don't overdo it.  Spray a tiny bit and open/shut the door to let it work in.
Comment: -1 parent clearly say's they've tried silicone.

Lubricant for squeaky doors


ModuleNotFoundError: No module named 'Qualtrics'

Question: I am trying to follow the example available in
https://github.com/dwallach1/Qualtrics_API
Once I do the following
!pip install Qualtrics

It gives me the following
ERROR: Could not find a version that satisfies the requirement Qualtrics (from versions: none)
ERROR: No matching distribution found for Qualtrics

Then I follow the webpage provided
import Qualtrics

It gives me
ModuleNotFoundError: No module named 'Qualtrics'

Have anyone tried it before?
Answer: You should be importing this file
https://github.com/dwallach1/Qualtrics_API/blob/master/src/qualtrics.py
and you should not be installing it from pip
If you want to use a pip package, do have the python package below, check it out!
pip install py-qualtrics-api
https://pypi.org/project/py-qualtrics-api/


Servlet to handle both applet communication and http requests

Question: I'm building a solution where a servlet on tomcat6 handles input from another machine by providing a jsp web page. I'd also like the same servlet to communicate with an applet on the same machine to show some results and perform a few tasks.
I'm able to connect from the applet to the servlet using a URLConnection but when receving a message from the servlet I get a "invalid stream header" exception message from the applet.
Any ideas?
edit: Error message:
java.io.StreamCorruptedException: invalid stream header: 0A0A0A3C
        at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
        at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
        at applet.viewApplet.onSendData(viewApplet.java:126)
Applet code:
 private URLConnection getServletConnection()
        throws MalformedURLException, IOException {

    // Open the servlet connection
    URL urlServlet = new URL("http://localhost:8080/Servlet");
    connection = urlServlet.openConnection();

    // Config
    connection.setDoInput(true);
    connection.setDoOutput(true);

    connection.setUseCaches (false);
    connection.setDefaultUseCaches (false);

    connection.setRequestProperty(
            "Content-Type",
            "application/x-java-serialized-object");

    return connection;
}

private void onSendData() {
    try {
        // get input data for sending
        String input = "Applet string heading for servlet";

        // send data to the servlet
        connection = getServletConnection();
        OutputStream outstream = connection.getOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(outstream);
        oos.writeObject(input);
        oos.flush();
        oos.close()

        // receive result from servlet
        InputStream instr = connection.getInputStream();
        ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
        String result = (String) inputFromServlet.readObject();
        inputFromServlet.close();
        instr.close();

        // show result
        textField.setText(result);

    } catch (java.net.MalformedURLException mue) {
        textField.setText("Invalid serlvetUrl, error: " + mue.getMessage());
    } catch (java.io.IOException ioe) {
        textField.setText("Couldn't open a URLConnection, error: " + ioe.getMessage());
    } catch (Exception e) {
        textField.setText("Exception caught, error: " + e.getMessage());
    }
}

Servlet code:
public class Servlet extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=ISO-8859-1");
    PrintWriter out = response.getWriter();
    String defect = request.getParameter("defect").toString();

    try {
        out.println("");
        out.println("");
        out.println("<title>Servlet</title>");
        out.println("");
        out.println("");
        out.println("
Servlet at " + request.getContextPath() + "
");
        out.println("
Defect: " + defect + "
");
        out.println("");
        out.println("");
    } finally {
        out.close();
    }
}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    try {
        response.setContentType("application/x-java-serialized-object");

        InputStream in = request.getInputStream();
        ObjectInputStream inputFromApplet = new ObjectInputStream(in);

        String servletText = "Text from Servlet";

        // echo it to the applet
        OutputStream outstr = response.getOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(outstr);
        oos.writeObject(servletText);
        oos.flush();
        oos.close();

    } catch (Exception e) {
        e.printStackTrace();
    }

    processRequest(request, response);
}

Comment: Seems like your servlet for handling POST(doPost) is supposed to handle a serialized object while your URLConnection will send a get (and end up in doGet) - or is that intended ?
Answer: That's because you're attempting to deserialize the textbased response body of the servlet using ObjectInputStream while it isn't serialized at all and you should be using a Reader for this.
Long story short: How to fire and handle HTTP requests using URLConnection?.


Finding the Galois group of $f(t)=t^{3}-4t+2$ over $\mathbb{Q}$

Question: I have read a few answers to similar questions on here but I can't get my head around this. This is my attempt to far:
$f(t)$ is monic and irreducible over $\mathbb{Q}$ since it is $2$-Eisenstein. Since $\mathbb{Q}$ has characteristic $0$, $f(t)$ has $3$ different roots, so $\varphi:\text{Gal}(f)\to S_{3}$ is injective. So there is a tower of extensions $\mathbb{Q}(f)\supset\mathbb{Q}(\alpha)\supset\mathbb{Q}$ where $\alpha$ is a root of $f$.
Now, $[\mathbb{Q}(f):\mathbb{Q}]$ is divisible by $[\mathbb{Q}(\alpha):\mathbb{Q}]=\deg(f)=3$, so $|\text{Gal}(f)|$ is divisible by $3$ and so $\text{Gal}(f)$ contains a $3$-cycle.
Is what I have done so far correct? How do I proceed? My gut is telling me the $\text{Gal}(f)\cong S_{3}$ but I don't know how to show it.
Answer: All of what you did is solid. To finish note that, in general, the Galois group of an irreducible cubic is $A_3$ iff the discriminant is a square (because $\Bbb Q(\sqrt{\Delta_f})$ is a subfield of your splitting field). In your case $\Delta_f=148$ is not a square, so you get that the full Galois group is $S_3$.
Comment: Ok thank you. Just to be clear, because $\text{Gal}(f)$ contains a $3$-cycle, the only options are $A_{3}$ or $S_{3}$ yes?
Comment: @PercyF2519 Yes, the irreducibility means you get a transitive subgroup and only those two fit the bill.


Orthonormal basis

Question:
Suppose $\{e_n\}_{n=1}^\infty$ is an orthonormal sequence in a Hilbert space $H$. Then $\{e_n\}_{n=1}^\infty$ is an orthonormal basis if and only if $h=0$ given $h \in H$ and $h \perp e_n$ for all $n$.

My question concerns the proof of the forward direction; that is, if $\{e_n\}_{n=1}^\infty$ is an orthonormal basis and $h \perp e_n$, then $h=0$.
The proof in my textbook suggests proof by contrapositive: Suppose $h \not=0$ and note as above that $h \perp e_n$. Then $\{e_n\}_{n=1}^\infty \cup \{\frac h{\|h\|}\}$ is an orthonormal set.
Now how does $\{e_n\}_{n=1}^\infty \cup \{\frac h{\|h\|}\}$ become an orthonormal set based on this? I do notice, though, as a result that $\{e_n\}_{n=1}^\infty \subset \{e_n\}_{n=1}^\infty \cup \{\frac h{\|h\|}\}$, which would make $\{e_n\}_{n=1}^\infty$ not an orthonormal basis by this reasoning, completing the contrapositive proof.
Answer: If $h \ne 0$ and $h \perp e_n$ for all $n$, then $\left\lVert \frac{h}{\lVert h \rVert} \right\rVert = 1$ and $\frac{h}{\lVert h \rVert} \perp e_n$ for all $n$. Thus the set $X = \{ e_n \}_{n=1}^{\infty} \cup \left\{ \frac{h}{\lVert h \rVert} \right\}$ satisfies the necessary conditions to be a normal set, namely that if $x \in X$ then $\lVert x \rVert = 1$ and if $x \ne y \in X$ then $x \perp y$. Moreover, $X$ is not a basis since it strictly contains the orthonormal set $\{ e_n \}_{n=1}^{\infty}$.
Comment: Since $\frac{1}{\lVert h \rVert}$ is a positive scalar you can pull it out to obtain $$\left\lVert \frac{h}{\lVert h \rVert} \right\rVert = \frac{1}{\lVert h \rVert} \lVert h \rVert = 1$$
Comment: How did we obtain $\left\|\frac h{\|h\|} \right\|=1$?
Comment: And is the fact that $\frac h{\|h\|} \perp e_n$ due to our hypothesis of $h \perp e_n$ (when working with proving the contrapositive)?
Comment: Yes, multiplying by a (non-zero) scalar doesn't change orthogonality.

Orthonormal basis


What's the limit of $\prod_{i=1}^{i=n}\left ( 1+\frac{i}{n^2} \right)$?

Question: What is the limit of $a_{n}$ when n approaches infinity?
pls give me insight about how to approach the problem.
$a_{n} =\prod_{i=1}^{i=n}\left ( 1+\frac{i}{n^2} \right)$
I encountered this problem reading a book about undergraduate algebra(the book language is not in English, I couldn't find a good reference.). Although the problem was answered in the book using Stirling's approximation, the answer was kind of ungly.
Comment: Taking the logarithm and using the Taylor approximation $\log(1+x)=x+\mathcal{O}(x^2)$, we find $$
\log a_n  = \sum\limits_{i = 1}^n {\log \left( {1 + \frac{i}{{n^2 }}} \right)}  = \frac{1}{n}\sum\limits_{i = 1}^n {\frac{i}{n}}  + \mathcal{O}\!\left( {\frac{1}{n}} \right)\frac{1}{n}\sum\limits_{i = 1}^n {\left( {\frac{i}{n}} \right)^2 } .
$$ Can you finish from here?
Comment: @Ritam_Dasgupta No it is not.
Comment: @Gary this is what I have come up with.
$a_n = \sum ln(1+\frac{i}{n^2}) = \sum (\frac{i}{n^2}) + O(n^2) \sim \sum (\frac{i}{n^2}) =\frac{1}{2} \rightarrow a_n = e^\frac{1}{2}$
is it correct?
Comment: Is the answer 1?
Comment: If you don't have any clue, you could try some arithmetic, simplification, or see some initial terms of the product notation. What have you tried?
Comment: @Gary a pretty hint :)
Comment: I know Taylor approximation of log(1+x) but I haven't seen this O notation in math.
Comment: @gigili $\mathcal{O}(x^2)$ denotes a function which can be bounded in absolute value by a fixed constant multiple of $x^2$ in a neighbourhood of $x=0$. In fact, $$
\left| {\log (1 + x) - x} \right| \le \frac{1}{2}x^2
$$ for $x \geq 0$.
Comment: let me think for 5 minute.
Comment: @gigili Almost. The error term is $$
\mathcal{O}\!\left( {\sum\limits_{i = 1}^n {\frac{{i^2 }}{{n^4 }}} } \right) = \mathcal{O}\!\left( {\frac{1}{{n^4 }}\sum\limits_{i = 1}^n {i^2 } } \right) = \mathcal{O}\!\left( {\frac{1}{n}} \right).
$$ This of course does not change the final answer.
Comment: @Gary thank you. God bless you.
Comment: @gigili [it is important to show](https://math.meta.stackexchange.com/questions/33508/enforcement-of-quality-standards) what have you tried!
Answer: Using the fact that $ \left(\forall x\in\left[0,1\right]\right),\ \mathrm{e}^{x-x^{2}}\leq 1+x\leq\mathrm{e}^{x}$, we have :
\begin{aligned}\exp{\left(\frac{i}{n^{2}}-\frac{i^{2}}{n^{4}}\right)}\leq 1+\frac{i}{n^{2}}\leq\exp{\left(\frac{i}{n^{2}}\right)}\ \ \ \ \ \ \ \ \ \ \ \ \\ \Longrightarrow\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \prod_{i=1}^{n}{\exp{\left(\frac{i}{n^{2}}-\frac{i^{2}}{n^{4}}\right)}}\leq\prod_{i=1}^{n}{\left(1+\frac{i}{n^{2}}\right)}\leq\prod_{i=1}^{n}{\exp{\left(\frac{i}{n^{2}}\right)}}\ \ \ \\ \iff\ \ \ \ \ \ \ \ \ \exp{\left(\frac{1}{n^{2}}\sum_{i=1}^{n}{i}-\frac{1}{n^{4}}\sum_{i=1}^{n}{i^{2}}\right)}\leq\prod_{i=1}^{n}{\left(1+\frac{i}{n^{2}}\right)}\leq\exp{\left(\frac{1}{n^{2}}\sum_{i=1}^{n}{i}\right)}\\ \iff \exp{\left(\frac{n+1}{2n}-\frac{\left(n+1\right)\left(2n+1\right)}{n^{3}}\right)}\leq\prod_{i=1}^{n}{\left(1+\frac{i}{n^{2}}\right)}\leq\exp{\left(\frac{n+1}{2n}\right)}\ \ \ \ \end{aligned}
Since $ \exp{\left(\frac{n+1}{2n}-\frac{\left(n+1\right)\left(2n+1\right)}{n^{3}}\right)} $ and $ \exp{\left(\frac{n+1}{2n}\right)} $ both approach $ \exp{\left(\frac{1}{2}\right)} $ as $ n\to +\infty $, using squeezing theorem, we have : $$ \prod_{i=1}^{n}{\left(1+\frac{i}{n^{2}}\right)}\underset{n\to +\infty}{\longrightarrow}\sqrt{\mathrm{e}} $$
Comment: [fyi](https://math.meta.stackexchange.com/questions/33508/enforcement-of-quality-standards)


jQuery select elements generated by a php script

Question: I have multiple <select id="direction_X"></select> generated by my php script. X is its ID. I am trying to select those  elements by doing so:
$('select[id*="direction_"]').live('change', function() {
     selected = $('select[id*="direction_"] option:selected');
     option_ID = $(selected).val();

     console.log(option_ID);
}

In fact, when I use  I am getting the option_ID, but if I try to use any other  I am getting the same option_ID from  all the time.
If you click  first, it gives you (an empty string) and when you click  after it gives you the correct ID from the first
Answer: You should use this keyword which refers to the current select element.
$('select[id^="direction_"]').on('change', function() {
     var selected = $(this).val(); // this.value
     console.log(selected);
})

Note that live method is deprecated, you can use on method instead, if the select elements are generated by php, there is no need to use event delegation, in case that elements are generated after page is loaded, the correct way of delegating event using on method is:
$(document).on('change', 'select[id^="direction_"]', function() {

Attribute Starts With Selector
| on
Answer: Well, if you want to get all of the selected values then you'll have to iterate over all of your select elements and build an array of all the selected options.
Given this HTML -
<select id="sel_1">
    <option value="1" selected="selected">1</option>
    ...
</select>
<select id="sel_2">
    <option value="2" selected="selected">2</option>
    ...
</select>
<select id="sel_3">
    ...
    <option value="3" selected="selected">3</option>
</select>

You would do something like this to collect all of the selected elements -
var selValues = $("select[id*='sel'] option:selected").map(function(){
  return $(this).val();
});
console.log(selValues); // ["1", "2", "3"]

Here is a quick demo (open your console)


Limit of $\frac{1}{e^3}$

Question: I am working with a 12 year old learning about limits, and am having a tough time proving
lim$_{n \rightarrow \infty}$ (1 - $\frac{3}{n-2})^n$ = $\frac{1}{e^3}$
using
lim$_{n \rightarrow \infty}$ (1 + $\frac{x}{n})^n$ = lim$_{n \rightarrow 0}$ (1 + $n$)$^{\frac{x}{n}}$ = $e^x$.
I am probably missing some small analysis trick.
one thing I tried is that the negative 3 is why its $e^{-3}$, but where does the $n-2$ come from, how can I account for that?
ALSO, need helps showing
lim$_{n \rightarrow \infty}$ ($\frac{n+2}{n-3})^n$ = $e^5$
would you rewrite $\frac{n+2}{n-3}$ = $\frac{n}{n-3}$ + $\frac{2}{n-3}$??
Comment: I can't unfocus on the idea of a 12 year old understanding this. Good for him/her.
Comment: You would rewrite $\frac{n+2}{n-3}=1+\frac{5}{n-3}$, and then hopefully you can see how similar it is to the one above (and hopefully get a suspicion as to where $-3$ and $5$ come from).
Comment: Substitute $m=n-2$, then $n = m+2$, you can get rid of $(..)^2$ since it is one.
Comment: @UmbertoP. yeah he is a student at the mathnasium learning center I work at, he is super advanced, I even explained intro set theory and chain rule product rule power rule to him!
Answer: For the first one, take logarithms and note that
$$\lim_{n \to \infty} n \log(1 - \frac{3}{n-2}) = \lim_{n \to \infty} \frac{n}{n-2} \cdot \lim_{n \to \infty} (n-2) \log(1 - \frac{3}{n-2}).$$
The second limit on the right-hand side can be computed using your provided fact.

For the other question, Arthur has already given you a hint in the comments.
Comment: thanks I got it!!!!
Answer: You could rewrite the limit:
$$\lim_{n \to \infty}\left(1-\frac{3}{n-2}\right)^n = \lim_{n \to \infty}\left(1+\frac{-3}{n-2}\right)^n = \lim_{n \to \infty}\left[\color{blue}{\left(1+\frac{-3}{n-2}\right)^{n-2}}\right]^{\color{green}{\frac{n}{n-2}}}$$
Now, just make use of the standard limit $\color{blue}{e^x = \lim_\limits{n \to \infty}\left(1+\frac{x}{n}\right)^n}$. Since $\color{green}{\frac{n}{n-2} \to 1}$ as $n \to \infty$, the limit becomes $\left(\color{blue}{e^{-3}}\right)^{\color{green}{1}} = e^{-3} = \frac{1}{e^3}$.
For your second question, I think it would be the simplest to write $\frac{n+2}{n-3}$ as $1+\frac{5}{n-3}$. The limit is therefore rewritten:
$$\lim_{n \to \infty}\left(\frac{n+2}{n-3}\right)^n = \lim_{n \to \infty}\left(1+\frac{5}{n-3}\right)^n = \lim_{n \to \infty}\left[\color{blue}{\left(1+\frac{5}{n-3}\right)^{n-3}}\right]^{\color{green}{\frac{n}{n-3}}}$$
The exact same idea applies here.
Comment: LOL I literally was just doing the second one on my now and got exactly what you got, thanks so much!!!
Answer: Just take $m=n-2$ and $x=-3$. Then you have $\lim_{m\rightarrow \infty}(1+\frac x m)^{m+2}$. You can then write that as  $\lim_{m\rightarrow \infty}(1+\frac x m)^{m}(1+\frac x m)^2$. If you can show that you can split that into separate limits, then you have ($\lim_{m\rightarrow \infty}(1+\frac x m)^{m}$) ($\lim_{m\rightarrow \infty}(1+\frac x m)^{2}$). The right parentheses clearly goes to $1$, and the left parentheses clearly goes to $e^x$. Substitute $-3$ in for $x$, and QED.

For your second limit, take $m=n-3$. Then $\frac {n+2}{n-3}=\frac {m+5} m=1+\frac5 m$. Proceed similarly.

Also, if it helps you get a more intuitive idea why $\frac {m+5} {m}$ leads to a limit of $e^5$, consider that the statement $\lim_{n\rightarrow \infty}(1+\frac 1 n )^{n}=e$ can be written as $\lim_{n\rightarrow \infty}(\frac {n+1} n)^{n}=e$. Then $\lim_{n\rightarrow \infty}(\frac {n+2}{n} )^{n}=\lim_{n\rightarrow \infty}\left(\frac {n+2}{n+1} \cdot \frac {n+1}{n}\right)^{n}$. Both $\frac{n+2}{n+1}$ and $\frac {n+1}{n}$ lead to a limit of $e$, so together they yield a limit of $e^2$. Similiary, $\frac{n+5}n$ yields a limit of $e^5$.

Limit of $\frac{1}{e^3}$


Gutter overhang past end of drip edge

Question: My gutter has a 4" overhang past the end of drip edge. Does this do anything or can I just not have it in my next gutter that I am working on?
It's a mod bit 10 degree roof that all drains into this gutter.
Comment: "Mod bit 10"? What's that?
Comment: **Mod**ified **bit**umen and speech to  text, probably. Or just shorthand and it's 10 degrees slope, in context.
Comment: @Ecnerwal that is correct
Answer: This is fairly normal, though the exact overhang is a matter of installer preference. You want some extension because there can be a fairly high flow at the corner and wind can push it outward. I'd say 1-2" is fine in most cases, though it should be a bit more for long drops.

Gutter overhang past end of drip edge


Integrating HerzultForumBundle in Symfony2

Question: I have installed the HerzultFourmBundle into my Symfony2 application, added the calls in the app kernel and auto load and extended the base classes.  The problem i am having is i have a site layout that is applied to every page in the application and i want to render the forum within this.
I am very new to Symfony and PHP, but i have tried a few ways to get this working.  I have a controller method set up that will render the forum page correctly which is set through the normal routing configuration, i can also set it up so that is routes to the index method in the Forum controller in the Herzult forum bundle.  However this renders the default styles for the forum index page and is not contained by the layout i require.
Can someone provide me with an example of how to implement the forum and integrate it into a site?  A simple example would point me in the right direction.
Answer: If you look at bundle's main layout file you'll notice that it extends '::base.html.twig' template:
{% extends '::base.html.twig' %}

This is an application level template located in apps/Resources/viewsbase.html.twig file.
You should be able to define your custom stuff as long as you're using this template.
This is a convention called "Three level template inheritance". Read more about it in the documentation: http://symfony.com/doc/2.0/book/templating.html#three-level-inheritance
Note that HerzultForumBundle is currently under intensive development. Some features might be missing.
Comment: Thanks, i still had some issues with the blocks defined in our base twig but i have got it sorted now through a combination of reading the documentation and looking at the bundle code.


Old thermostat to Hive thermostat

Question: My wife decided we needed a smart thermostat... which means I need to install said thermostat...
Currently a Bryant Evolution series is mounted. She purchased the Hive with Hub when it was on sale.
The Bryant is wired using A, B, C, and D at the thermostat. Those wires run to my Bryant Plus80v furnace. They plug into the corresponding spots on the 4 circuit communication connector. There are also at least 3 wires that are not connected on either end.
My question is this... Can I disconnect the wires from both ends and move them over to the bigger board (W2, Y1, DHUM, G, COM 24V, W/W1, Y/Y2, R)? Obviously using only the necessary ones that correspond with the Hive.
Comment: *"My wife decided ..."*, *"She purchased ..."*  You can relax, I think she has it covered.
Comment: A picture of your '4 circut communication connector' would also be helpful.
Comment: Can you post the wiring diagram for your furnace please?
Comment: @ThreePhaseEel I have added the wiring diagram.
Comment: Do you need the dehumidification functionality of your system?
Comment: I added the 4 circuit connector which is PL7 on the diagram. I also added the main board (even though I'm sure you knew what it was).
Comment: No I dont need the dehumidification function.
Answer: You can do this, but you'll lose some fancy features
The rewiring you describe (from using the ABCD commlink to using the standard 24VAC inputs) should be supported by your control board.  However, there are downsides to this, namely that your system will act as a good two-stage forced-air system, without full command modulating functionality or the ability to display feedback (such as fault codes) on the thermostat.  So, go ahead, as long as you are cool trading these communicating functions for the Hive's "smarts".
Comment: Is there another method you would suggest? Mainly what we (she) are aiming for is the ability to change the temp from our phones and program it to a lower temp when we arent home and heat when we are going to be home.

Old thermostat to Hive thermostat


What does "Inspire Loyalty" actually do?

Question: I'm playing as a Zabrak, whose social ability is "Inspire Loyalty".  When I use it the target ally is either "Feeling patriotic" if it works or "Not feeling it" if it fails.  What does this "feeling" do for them?  Does it temporarily increase stats in any way, or have some other effect?
Answer: All racial abilities are purely social, they cause no interference in combat and do not affect stats in any way.


Is it a good idea to show a warning to users who are typing tags incorrectly?

Question: On our site, we have a tag field that looks like the following:

Today, while looking at some of our users interacting with the site, I noticed that one of them had used only spaces to separate their tags, instead of using commas as the input field advises (he probably did not see the advice and applied his idea of how tags should be typed in).
This raised a concern: are we going to get many users that fail to read the advice and end up typing in tags by only separating them with spaces (which would lead to having a huge single tag) and if so, should we try to do something about it by educating the user about the problem?
I thought that we could make the field detect if the user has entered no commas in the field and check for the presence of more than one space, and if the condition is met display a warning that would say something along the lines of "You might be typing in your tags incorrectly. Are you using commas to separate them?".
If we didn't tell our user about this issue they would probably have a hard time noticing and correcting the issue after submitting their entry, because the only difference between well-formed tags and "huge chunk" tags is the amount of space that goes between them, a thing which a novice and uneducated user might miss.
Is it a good idea to try to prevent this behavior and try to educate the user a priori? Are we taking the right approach?
Comment: Are there a restricted list of tags or can users create new tags?
Comment: @mervinj currently, any user can create tags and we don't have suggestions implemented.
Answer: One way to guide the user would be to style the tags as soon as the users finish typing a tag, thus indicating that the application/system has recognized their tag.
For example, when the user types in the tags that you have entered for this question i.e. "user-behavior", "tags", "warnings", this is what people typically do.

Instead, try the following. As soon as they type a comma, change the styles of the text to indicate that the word(s) has been added/recognized as a tag.

And most importantly, provide clear instructions above the textbox on the accepted delimiter for the tags. It makes it more readable. When people see textboxes, they start typing right away. It's natural behavior since the user feels invited to respond when there's a call to attention especially with a cursor blinking at them.
And if you have watermark/placeholder text in that box that disappears as soon as the user starts typing something, then the user can't remember what the instructions were.
Finally, highlighting the instructions about the delimiter in the guidelines can play an important role too as it grabs the user's attention by providing contrast to the surrounding content.
Comment: An implementaion of the proposed solution is the tag input of ux or any stackexchange site, you can check when asking a question
Answer: 1) What Girish said would be my first port of call
2) How many people are doing the 'wrong' thing? Maybe you need to reconsider whether not allowing spaces as separators is the best option? How many people are actually using multi-word tags compared to the number of people making mistakes? Can you support the multi-word tag folk in other ways (hyphens rather than spaces for example)?


Difference between two files

Question: I have two files. I want to compare the files but the order of the rows is not same in both files.
Can you please provide the simplest method to compare the both files.
Example:
file1
My name is sumit.
My surname is vedi.
I like shell scripting.

file2
My surname is vedi.
My name is sumit.
I like shell scripting.

The difference between the files should be zero; however, the order of the rows is not same.
Note: the files are huge.
Answer: Probably the command below would do the thing.
diff <(sort file1) <(sort file2)

If the files are huge and you do not need a sort command, then may be you could use awk:
awk 'FNR==NR{a[$0];next}!($0 in a)' file1 file2

The above command will only give the lines that are present in file2 but not in file1.
Comment: @sumitvedi: There is no significance to the number of fields.  If you can't sort the files, you are snookered.  This is `bash` (4.x) `process substitution'; it is about as good as it gets.  If this won't work, then you are very rapidly going to run out of options.  (How many terabytes huge are your huge files?)
Comment: The `awk` command must be able to hold all of one file in memory; the `diff` command does not need to hold very much in memory at one time.
Comment: Suppose if any line is not present in file then it gives the error for all line that's why we can't sort the file.
Eg

Difference between two files


Swift , CoreData not inserting a record

Question: I have a function which errors where marker // ERRORS HERE
The db is empty, I try to append a Persistence record, then set its values,
tasks[0].persistencevalue = "Some Text"!
Any help would be appreciated.
Thanks
The stack shows :

2017-08-18 10:09:07.158047+0100 Ontrack[6491:1684506] [error] error:
  CoreData: error: Failed to call designated initializer on
  NSManagedObject class 'Persistence'
      CoreData: error: CoreData: error: Failed to call designated initializer on NSManagedObject class "Persistence" 2017-08-18 10:09:08.678 Ontrack[6491:1684506] -[Persistence   setPersistencevalue:]: unrecognized selector sent to instance
  0x60800026a040
      2017-08-18 10:09:08.681 Ontrack[6491:1684506] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
  '-[Persistence setPersistencevalue:]: unrecognized selector sent to
  instance 0x60800026a040'

func Update() {
    let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
    let app = (UIApplication.shared.delegate as! AppDelegate )

    var tasks: [ Persistence] = []

    let pers = Persistence()

    tasks.append(pers)
    cnt = tasks.count
    // ERRORS HERE
    tasks[0].persistencevalue = Rate.text!
    // END ERROR
}

Comment: Possible duplicate of [CoreData Swift: How to save and load data?](https://stackoverflow.com/questions/25586593/coredata-swift-how-to-save-and-load-data)
Comment: See also [this answer](https://stackoverflow.com/a/33307824/3985749) to the "Failed to Call Designated initializer" error.
Answer: Thanks for your help, I was able to fix the problem with the following code.  Hope it helps someone with the same problem.
func Update() {

    let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
    let app = (UIApplication.shared.delegate as! AppDelegate )

    var persistencies: [ Persistence]?

    var cnt = persistencies?.count

    var perRec: AnyObject! = NSEntityDescription.insertNewObject(forEntityName: "Persistence", into: context) as NSManagedObject

    perRec.setValue(DbKeys.PERSISTENCE_SPEECHRATE_KEY, forKey: "persistencekey")
    perRec.setValue(Rate.text, forKey: "persistencevalue")

    do {
     try context.save()
    } catch {
        print (" ERROR")
    }

    app.saveContext()

    do {
        persistencies = try context.fetch(Persistence.fetchRequest())
    } catch {
        print("Fetching Failed")
    }

    cnt = persistencies?.count

  }

Swift , CoreData not inserting a record


ImageResizer AzureReader2 404 Error

Question: We are trying to test the ImageResizer with our Azure Blob Storage. We have included the latest version of everything (including the AzureReader2) but we keep getting the 404 error.
Our config setting is as follows:
    <resizer>
        <plugins>
           <add name="AzureReader2" prefix="~/" connectionString="DefaultEndpointsProtocol=https;AccountName=ouraccount;AccountKey=ourAccountKey;BlobEndpoint=https://ouraccount.blob.core.windows.net/;TableEndpoint=https://ouraccount.table.core.windows.net/;QueueEndpoint=https://ouraccount.queue.core.windows.net/;FileEndpoint=https://ouraccount.file.core.windows.net/" />
    </plugins>
</resizer>

Is there anything we can do to make this work.
Many thanks
Comment: Try changing the prefix to "~/azure" or any other string
Comment: Thanks for your response. We changed it to azure as above and now we do not get any error but the image does NOT resize. Does this prefix have any significance ? How are we supposed to use it ?
Comment: @NathanaelJones Anything else you can suggest or should we assume that ImageResizer cannot be used in Azure.
Comment: Tens of thousands of people are using ImageResizer with Azure. What URLs are you trying? Can you attach a Gist of the self-diagnostics page per support guidelines?
Comment: @NathanaelJones. We found that the ImageResizer is complaining about licences - Can we not test the azure functionality when our web app is running on localhost and accessing our azure storage account?
Comment: License validation will not affect this. Please show the URLs you are trying.
Comment: @NathanaelJones - Here is the Url: https://bbzstorage.blob.core.windows.net/u0k/1/logo.jpg?width=100&height=60&mode=max
Answer: Thank you for sharing the URL you are getting the 404 with in the comments:
https://bbzstorage.blob.core.windows.net/u0k/1/logo.jpg?width=100&height=60&mode=max
This URL is served by bbzstorage.blob.core.windows.net. bbzstorage.blob.core.windows.net is not running ImageResizer, so it cannot resize your images.
For ImageResizer to resize an image for you, you must communicate with it somehow. It does not perform a magical man-in-the-middle attack on your network traffic in order to inject its functionality.
If you have an ImageResizer server at localhost, you might need to use a URL like
https://localhost/azure/bbzstorage/u0k/1/logo.jpg?width=100&height=60&mode=max
This diagram tries to explain how data flows. In your case, you don't have a CDN, so just pretend there's a straight line from the rightmost computer to the ImageResizer server.
Comment: Thanks for the diagram. But nothing works! We even uploaded everything including the website with the image resizer libraries into azure and still the images that are in blob storage do not resize while other images that are not in blob storage work as expected..
Comment: Look, given that you won't share the self-diagnostics page, I don't think I can help you further. Diagnosing a problem requires clear communication of steps, methods, and only changing on variable at a time. I don't have anything to work with here.
Comment: Is there anywhere we can email the self-diagnostics page.
Comment: We are desperate to sort this problem out. Could you PLEASE assist us. If there is a paid support where we can resolve this issue faster, please advise. Many thanks.

ImageResizer AzureReader2 404 Error


Can't connect to certain HTTPS sites

Question: I've just moved to a new apartment and with internet connection via a router and I'm finding that I can't connect to quite a few sites that use SSL.
For example trying to connect to PayPal:
curl -v https://paypal.com
* About to connect() to paypal.com port 443 (#0)
*   Trying 184.108.40.206... connected
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to paypal.com:443
* Closing connection #0
curl: (35) Unknown SSL protocol error in connection to paypal.com:443

curl -v -ssl https://paypal.com gives the same output.
For some sites it works:
curl -v https://www.google.com
* About to connect() to www.google.com port 443 (#0)
*   Trying 184.108.40.206... connected
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-RC4-SHA
* Server certificate:
*    subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=www.google.com
*    start date: 2011-10-26 00:00:00 GMT
*    expire date: 2013-09-30 23:59:59 GMT
*    common name: www.google.com (matched)
*    issuer: C=ZA; O=Thawte Consulting (Pty) Ltd.; CN=Thawte SGC CA
*    SSL certificate verify ok.
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/126.96.36.199 libidn/1.23 librtmp/2.3
> Host: www.google.com
> Accept: */*
>
< HTTP/1.1 302 Found
< Location: https://www.google.co.jp/
  .
  .
  .

I'm using Ubuntu 12.04, with Windows 7 installed as well. These sites work on Windows :(
Not sure if this information helps but I ran ifconfig and got the following:
eth0      Link encap:Ethernet  HWaddr 1c:c1:de:bc:e2:4f
          inet6 addr: 2408:c3:7fff:991:686b:8d18:81b3:8dd1/64 Scope:Global
          inet6 addr: 2408:c3:7fff:991:1ec1:deff:febc:e24f/64 Scope:Global
          inet6 addr: fe80::1ec1:deff:febc:e24f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:87075 errors:0 dropped:0 overruns:0 frame:0
          TX packets:54522 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:78167937 (78.1 MB)  TX bytes:10016891 (10.0 MB)
          Interrupt:46 Base address:0x4000

eth1      Link encap:Ethernet  HWaddr ac:81:12:0d:93:80
          inet6 addr: fe80::ae81:12ff:fe0d:9380/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:498
          TX packets:0 errors:26 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:17

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:630 errors:0 dropped:0 overruns:0 frame:0
          TX packets:630 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:39592 (39.5 KB)  TX bytes:39592 (39.5 KB)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:22.214.171.124  P-t-P:188.8.131.52  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:39631 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22391 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:43462054 (43.4 MB)  TX bytes:2834628 (2.8 MB)

I've run PING:
ping www.paypal.com
PING e6166.b.akamaiedge.net (184.108.40.206) 56(84) bytes of data.
64 bytes from a184-31-66-234.deploy.akamaitechnologies.com (184.108.40.206): icmp_req=1 ttl=54 time=15.3 ms
64 bytes from a184-31-66-234.deploy.akamaitechnologies.com (220.127.116.11): icmp_req=2 ttl=54 time=15.0 ms
64 bytes from a184-31-66-234.deploy.akamaitechnologies.com (126.96.36.199): icmp_req=3 ttl=54 time=15.2 ms
64 bytes from a184-31-66-234.deploy.akamaitechnologies.com (18.104.22.168): icmp_req=4 ttl=54 time=17.2 ms
64 bytes from a184-31-66-234.deploy.akamaitechnologies.com (22.214.171.124): icmp_req=5 ttl=54 time=16.6 ms
64 bytes from a184-31-66-234.deploy.akamaitechnologies.com (126.96.36.199): icmp_req=6 ttl=54 time=16.7 ms
64 bytes from a184-31-66-234.deploy.akamaitechnologies.com (184.108.40.206): icmp_req=7 ttl=54 time=14.8 ms
^C
--- e6166.b.akamaiedge.net ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6009ms
rtt min/avg/max/mdev = 14.878/15.890/17.214/0.901 ms

And without www:
ping paypal.com
PING paypal.com (188.8.131.52) 56(84) bytes of data.
^C
--- paypal.com ping statistics ---
303 packets transmitted, 0 received, 100% packet loss, time 302265ms

TRACEROUTE:
traceroute www.paypal.com
traceroute to www.paypal.com (220.127.116.11), 30 hops max, 60 byte packets
 1  220.127.116.11 (220.127.116.11)  8.424 ms  8.404 ms  8.540 ms
 2  184.108.40.206 (188.8.131.52)  8.212 ms  8.189 ms  8.162 ms
 3  22.214.171.124 (18.104.22.168)  9.405 ms  11.359 ms  13.469 ms
 4  18.104.22.168 (126.96.36.199)  8.049 ms  8.072 ms  8.040 ms
 5  184.108.40.206 (220.127.116.11)  8.574 ms  8.549 ms  8.558 ms
 6  184.108.40.206 (184.108.40.206)  8.667 ms  7.605 ms  7.545 ms
 7  xe-4-0-0.a21.osakjp01.jp.ra.gin.ntt.net (18.104.22.168)  18.255 ms  18.232 ms xe-3-0-0.a21.osakjp01.jp.ra.gin.ntt.net (220.127.116.11)  19.042 ms
 8  * * *
 9  * * *
   .
   .
   .
29  * * *
30  * * *

without www:
traceroute paypal.com
traceroute to paypal.com (22.214.171.124), 30 hops max, 60 byte packets
 1  126.96.36.199 (18.104.22.168)  5.607 ms  5.674 ms  5.875 ms
 2  220.127.116.11 (18.104.22.168)  5.468 ms  5.453 ms  5.576 ms
 3  220.127.116.11 (220.127.116.11)  7.595 ms  10.062 ms  11.660 ms
 4  220.127.116.11 (184.108.40.206)  5.684 ms  5.660 ms  5.635 ms
 5  22.214.171.124 (18.104.22.168)  5.960 ms  5.924 ms  5.898 ms
 6  ae-11.r20.tokyjp01.jp.bb.gin.ntt.net (18.104.22.168)  86.468 ms  30.960 ms  30.899 ms
 7  as-1.r20.sttlwa01.us.bb.gin.ntt.net (184.108.40.206)  161.185 ms  144.343 ms  132.410 ms
 8  ae-1.r05.sttlwa01.us.bb.gin.ntt.net (18.104.22.168)  139.008 ms  127.377 ms  139.050 ms
 9  xe-0.sprint.sttlwa01.us.bb.gin.ntt.net (220.127.116.11)  116.006 ms  104.306 ms  115.954 ms
10  18.104.22.168 (188.8.131.52)  141.046 ms  129.870 ms  140.991 ms
11  sl-crs2-sj-0-5-2-0.sprintlink.net (184.108.40.206)  131.271 ms  131.248 ms  142.544 ms
12  sl-st31-sj-0-15-0-0.sprintlink.net (22.214.171.124)  129.543 ms  141.575 ms  141.066 ms
13  * * *
14  * * *
    .
    .
    .
29  * * *
30  * * *

The tcpdump:
1   0.000000    188.8.131.52   220.127.116.11   TCP 76  37374 > https [SYN] Seq=0 Win=14520 Len=0 MSS=1452 SACK_PERM=1 TSval=68855 TSecr=0 WS=64
2   0.136291    126.96.36.199   184.108.40.206   TCP 80  https > 37374 [SYN, ACK] Seq=0 Ack=1 Win=4356 Len=0 MSS=1460 WS=1 TSval=3608913175 TSecr=68855 SACK_PERM=1
3   0.136322    188.8.131.52   22.214.171.124   TCP 68  37374 > https [ACK] Seq=1 Ack=1 Win=14528 Len=0 TSval=68889 TSecr=3608913175
4   0.137409    22.214.171.124   184.108.40.206   SSL 309 Client Hello
5   0.274446    184.108.40.206   188.8.131.52   SSL 95  [TCP Previous segment lost] Continuation Data
6   0.274469    184.108.40.206   220.127.116.11   TCP 80  [TCP Dup ACK 4#1] 37374 > https [ACK] Seq=242 Ack=1 Win=14528 Len=0 TSval=68923 TSecr=3608913175 SLE=2881 SRE=2908
7   7.117833    220.127.116.11    220.127.116.11   TLSv1   142 Application Data, Application Data
8   7.118823    184.108.40.206   184.108.40.206    TLSv1   216 Application Data, Application Data, Application Data, Application Data
9   7.393725    18.104.22.168    184.108.40.206   TCP 68  https > 41264 [ACK] Seq=75 Ack=149 Win=146 Len=0 TSval=875420654 TSecr=70634
10  60.301444   126.96.36.199   22.214.171.124   TCP 56  https > 37374 [RST, ACK] Seq=2908 Ack=242 Win=4597 Len=0

This is a Japanese ISP and even though I'm connecting to with a cable to the modem / router I need to add a username and password, but with Ubuntu's "Wired" connection I couldn't add these. My housemate told me to create an OCN connection but I'm not sure if that's a name of a type of network or just the Japanese company... but after looking at her computer we found it to be a PPPoE connection. After some googling I learned that to create a PPPoE connection I would need to create a DSL connection and that I could add a password & username to it. I also changed the "Wired" connection to not connect automatically.
I get the same problem if I hook up to the modem directly.
I've tried changing the DSL MTU to 500, 1500, 1492 and 1482 but it didn't make a difference.
Also for some reason Ubuntu doesn't always pick up the connection, I sometimes have to restart for it to connect.
Comment: are these sites only not opening with `curl` or are they not opening with other browsers as well?
Comment: They're not opening at all, I was just trying to find out where the problem is...
Comment: @mind.blank - What does the browser give you when you try to connect? If you don't get anything from the main window, try installing Firebug (if you use Firefox; if you use Chrome, it has the developer tools built in), open it, and activate the console and net tabs and see if there are any errors, then report them here.
Comment: Were you using the router before or is it new? Also, you haven't done anything silly and upgraded your ssl packages or anything from a default install?  I'm accessing all of those sites fine (well, through my proxy at least, China randomly blocks ssl protocol otherwise), so I'm guessing the problem lies either with the router or with an upgraded/installed package.
Comment: @Shauna I'm using Chrome and it's saying `Error 7 (net::ERR_TIMED_OUT): The operation timed out`. FireFox just keeps trying to load but never does (the page doesn't change). Console and Network don't give me anything...
Comment: @adempewolff the router is new. At least new to this computer since I just moved in to the apartment - never had this problem on this laptop before... I haven't changed SSL although after all these problems I tried to update them but it said they were up to date already...
Comment: Similar issue: [Why can I not access imgur.com and gravatar.com from Ubuntu but can do so from Windows?](http://askubuntu.com/q/239921/88802)
Answer: This is an old question, but for those getting here via Google, this will help.  The issue is fragmentation on SSL is bad, and breaks the protocol. If you are using PPPOE, the normal MTU in your router/DSL/Cable modem is 1492.  That is too high, and will cause fragmentation. 1476 is the magic number that will work with the most sites.  Some sites use different SSL implementations so 1480 may work, or even 1488.  For the MOST compatibility, the MTU on the WAN side of your network device (router, modem, etc) should be 1476.
Comment: I don't see how fragmentation will break SSL. Fragmented packets will be reassembled by routers in IPv4. SSL happens on top of TCP, on a level where you should not notice this. I do think this has to do with MTU values, but I don't think your explanation qualifies. I think it has to do with MTU settings not in sync on both ends, resulting in *wrong* reassembling of fragmented packets. The magic number may work in your case, but not for others.
Comment: holy cow! This enabled me to `sudo yum install docker-engine` after adding the yum.dockerproject.org repo on a CentOS 7 box: `sudo ip link set mtu 1476 dev enp6s0` to lower the MTU from its default of 1500 to 1476. Been scratching my head for a day trying to figure out why yum.dockerproject.org was accessible via https from other nodes on the same network.
Comment: The DF (Dont Fragment) bit is always set on SSL traffic by design - fragmentation is a security hole.  A fragmented SSL packet will get dropped 99.9% of the time. An MTU too low on PPoE traffic will cause fragmentation.
Comment: This happened to me with the PayPal website. I tried to settle with MTU 1476 and did not work, but with 1480 worked. Thank you!
Comment: I spent 6am-2pm trying to solve this until I found your response. Much appreciated!
Answer: Here are a couple of things to try:

Check your network card settings. Neither of your eth interfaces are showing IPv4 addresses. Make sure you have IPv4 turned on (you may need to re-establish your connection with your router to renew the IP). If that doesn't work, try turning off IPv6 support and see if that makes a difference. Do this by right clicking the networking icon by your clock (when on an Ethernet connection, it's a pair of arrows, one pointing up, the other down) and selecting "Edit Connections...". In the "IPv4 Settings" tab, make sure it's set to "Automatic (DHCP)". If you want to turn off IPv6, go to its tab and set it to "Ignore".
Check to see if you can connect to the sites using other methods. What does ping respond with for the sites you can't connect to? How about a traceroute (you may have to install traceroute to use it, FYI)? Their responses might help you troubleshoot the issue. If they can't get to the URL's servers, then it might be a DNS issue (however, if they can get to the URL's servers, but are then dropped, it might just mean those commands are blocked).
Bypass the router. If your router and your modem are two different machines, try hooking up your computer directly to your modem and seeing if that changes anything.
Restart your modem and router. Sometimes, they just suck.
Restart your computer. Sometimes, they just suck.
Try a different computer. If you have one, does another computer work where this one fails? If not, then it might be something with your specific computer.
Clear your computer's cache, cookies, etc. Sometimes, bad sessions cookies, cache, etc. can interfere with connecting to a site (I had this issue with Google a while back). Clear them out and start fresh and see what you get.
Disconnect any VPN connections. Point-to-Point protocol is often used for VPN (the PPP interface), and VPNs can interfere with connecting to sites. Make sure you aren't connected by right clicking your network icon by your clock, finding the "VPN Connections" entry and making sure no listing are checked (if you don't have a "VPN Connections" menu item, then you don't have one set up). If there are any checked, then you're connected to it, disconnect from it.

Remember: Not everything you do will result in a simple "work or fail," any change in the reaction of the server to your request will tell us something. So, if you do any of the above and get a new message, don't forget to update your question.
Comment: 1) Sorry not sure how to do both these things. http://www.cyberciti.biz/faq/setting-up-an-network-interfaces-file/ - not sure what IP addresses to add. 2) I've added both of those in the original question. 3) I'll see if I have that option tomorrow (modem etc. is in roomate's room). 4) Same as above although I have restarted the router at least. 5) Tried a few times. 6) I don't have another comp with ubuntu, these connections work however when I switch to Windows. 7) Tried that.
Comment: @mind.blank You don't need to do anything of the sort in the link. Simply right click the networking icon by the clock and select "Edit Connections...". Click on the connection and select "Edit" and select the "IPv4 Settings" tab and make sure it's set to "Automatic (DHCP)". Then go to the "IPv6 Settings" tab and make sure "Require IPv6 addressing for this connection to complete" is **un**checked. Save and reconnect. If/when you want to turn off IPv6, then come back to the IPv6 Settings tab and change "Automatic" to "Ignore".
Comment: In Network Connections > DSL > Edit, IPv4 settings are on "Automatic (PPPoE)" and there is no IPv6 tab...
Answer: I have seen this behaviour twice in practice for which I have found the following solutions.

Some computer in the local network was successfully attempting a man-in-the-middle attack. It was ARP-spoofing the gateway, thus redirecting all traffic to go through this machine, modifying requests and other nasty stuff. The machine was running Windows and found to be infected with some nasty malware. As soon as this machine was disconnected from the network physically, symptoms vanished.
An MTU problem on your or another gateway. In IPv4 gateways are responsible for fragmenting and re-assembling IP packets on the network if the frame size of the networks it's routing traffic for isn't the same. For DSL connections using PPPoE/PPPoA the MTU size is usually smaller than the 1500 bytes at the LAN side. Also routers in between fail and you need to enable TCP MSS Clamping on your router. I always needed to set this on the connection of my previous ISP, but it was resolving more than just SSL-related issues. Check if your modem/router has such an option. Consider this to be a workaround.
I was in a network probably running a transparent proxy to also pass SSL traffic, but failing at TLSv1 for some reason. The same request worked when using a VPN connection. scaryTry running curl with the option --sslv3. If that solves it, then it stinks.

General stuff to try:

Check if you're running the latest firmware on your modem/router. If not, try upgrading.
Capture the traffic using tcpdump or Whireshark and get it analysed (post it here for example).
  # 1. start the dump
$ sudo tcpdump -w httpstrafficdump.pcap -i eth0 -s 0 port 443
  # 2. open a new terminal window and do your HTTPS request there (curl/browser)
  # 3. end tcpdump (Ctrl+C)
  # 4. open the file in wireshark
$ wireshark httpstrafficdump.pcap

If you're getting Reassembling errors or Previous segment lost repeatedly, this is a clear sign about packet loss caused by a wrong MTU size.However, HTTPS traffic is encrypted and hard to analyse from network traffic by itself.

Edit:
From your tcpdump the root of your SSL problem is clear: TCP Previous segment lost. General networking troubleshooting should apply here, but it may be outside the scope of your local network and a problem with your ISP.
Comment: I've tried running curl with `--sslv3` and it still doesn't work. Also I tried to capture the dump but it doesn't seem to be working? `tcpdump: WARNING: eth0: no IPv4 address assigned` `0 packets captured` `6 packets received by filter` `0 packets dropped by kernel` - I'm not sure how to assign the IPv4... I will have to try the rest tomorrow as it's getting late and my brain isn't working well. Thanks for your help everyone so far!
Comment: @mind.blank For you it is ``ppp0`` interface instead of ``eth0`` which makes me think: Why do you need PPP for a connection when using a router?
Comment: The normal "Wired" connection didn't pick anything up. I've now added the tcpdump at the bottom of my question with some more details about why I'm using PPPoE. Also if you need more information from the dump please tell me.
Comment: @mind.blank The dump is very useful, but doesn't point to a solution just. See my updated answer.
Answer: Hi everybody this IS marcovaleriof from Italy, recently we had a problem similar to yours: all our Linux machine could'n Connect anymore to any https website while Android or Windows Device had no issue.
The trouble was an mtu disalignement between our DSL router which had a 1492 mtu length and the default Linux mtu which IS 1500.
As a matter of facts issuing this command as root
ifconfig wlan0 mtu 1492 up

(in English this set The mtu value of the net interface - wlan0 in My case - to 1492 length) has get rid of the problem, thank you!
Hope this could help someone.
Answer: Thanks for all your help , the problem is finally fixed!
I was trying to limit the MTU to see if it would help and ended up using pppoeconf to set up the PPPoE connection since it limits the MTU for me. I then disabled the DSL connection I previously used.
For anyone experiencing a similar problem you can try this solution out by typing sudo ppoeconf and following the instructions. Then you can connect with pon adsl-provider and disconnect with poff

Can't connect to certain HTTPS sites


Avoid mobs from spawning automatically

Question: I made a swimming pool in Minecraft and squids are spawned automatically in the water
I tried to set difficulty to Peaceful but it not working
Any solution?
Comment: Honestly, I don't think it's possible. You could reduce the chance they will spawn in your pool by making sure there's plenty of water nearby for squid to spawn in (perhaps next to a lake, ocean, or even some artificial pools built underground).
Answer: Turn off the doMobSpawning gamerule to prevent mobs spawning naturally:
/gamerule doMobSpawning false

You will need to have cheats enabled to run the above command. If you have not, you can temporarily enable them by the following:

Open the menu while on the world (ESC)
Press Open to LAN
Switch Allow Cheats to ON, then press Start LAN World
Comment: I tried this, I don't know if it works, when verify that it works, I will accept the answer

Avoid mobs from spawning automatically


Print unique lines, compare no more than N characters

Question: With uniq, you can choose to compare only first N characters

$ cat foo.txt
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy cat.
The quick brown fox jumps over the lazy mouse.

$ uniq -w 40 foo.txt
The quick brown fox jumps over the lazy dog.

Can the same effect be achieved using awk? I read
this example
awk '!a[$0]++'

but it compares the whole line.
Answer: awk has substr() function:
awk '!a[substr($0,1,40)]++'

with your example:
kent$  echo "The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy cat.
The quick brown fox jumps over the lazy mouse."|awk '!a[substr($0,1,40)]++'
The quick brown fox jumps over the lazy dog

Comment: P.S. I just found the period after "dog" (in output) is missing. It was a copy/paste mistake. The dot is there in output after executing the awk command.
Answer: Two alternatives using FIELDWIDTHS and FPAT:
awk '!a[$1]++' FIELDWIDTHS=40

awk '!a[$1]++' FPAT='.{40}'

Comment: You should probably state that both of these are gawk-only. And no, I didn't down-vote anyone.
Comment: How does a side note get more upvotes than a correct answer? 3 downvotes... these are perfectly valid alternatives to the `substr` solution.
Comment: Some people just love the down-vote button. Here, I'll give it an up-vote to take the edge off :-).