text:
Q: Can't connect to wireless routers and settings page - connection refused 1st router.
I can't connect to my wireless router setting page at 192.168.1.1. in chrome it says "ERR_CONNECTION_REFUSED". I didn't have this problem before. this happens to another router too. I'm using a wireless network adapter for wireless connection. I changed my MAC address, used this command: NETSH WINSOCK RESET , restarted PC, refreshed everything using IE settings.
2nd router
There is another router for my friend that gave me it's password and I used to connect to it successfully but now i can't. I tried everything i could but none of them worked. I'm using Windows 8.1 and the error i get when trying to connect to that router is this: "Can't connect to this network". on this network my friend set up a QOS and set a static Internal IP for my MAC address. I don't know what's wrong with my computer. I also haven't Installed any Windows updates recently.
IP config Output
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32>ipconfig/all

Windows IP Configuration

Host Name . . . . . . . . . . . . :
Primary Dns Suffix  . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : domain.name

Wireless LAN adapter Wi-Fi 2:

Connection-specific DNS Suffix  . : domain.name
Description . . . . . . . . . . . : TP-link Wireless adapter 802.11b/g   54Mbps
USB 2.0 Network Adapter
Physical Address. . . . . . . . . : 00-C0-BA-3A-4C-5E
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::1961:9d21:bd7c:fcf3%29(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.1.3(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Wednesday, July 1, 2015 5:02:26 PM
Lease Expires . . . . . . . . . . : Thursday, July 2, 2015 5:02:25 PM
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.1
DHCPv6 IAID . . . . . . . . . . . : 302039242
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-AC-AF-BC-54-42-49-F6-CF-F9

DNS Servers . . . . . . . . . . . : 8.8.8.8
                                   8.8.4.4
NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Ethernet 2:

Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : Intel(R) Ethernet Connection I217-V
Physical Address. . . . . . . . . : 74-D0-2B-C5-2D-6F
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::9590:b3e4:e8fb:d1f6%8(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.137.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 175427627
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-AC-AF-BC-54-42-49-F6-CF-F9

DNS Servers . . . . . . . . . . . : 8.8.8.8
NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter Kerio Virtual Network:

Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : Kerio Virtual Network Adapter
Physical Address. . . . . . . . . : 44-45-53-54-4F-53
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::14d0:7d29:f86a:4124%14(Preferred)
Autoconfiguration IPv4 Address. . : 169.254.65.36(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 356795731
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-AC-AF-BC-54-42-49-F6-CF-F9

DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                   fec0:0:0:ffff::2%1
                                   fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Disabled

Ethernet adapter VMware Network Adapter VMnet1:

Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet
1
Physical Address. . . . . . . . . : 00-50-56-C0-00-01
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::7128:f9d7:a5bb:72dd%31(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.147.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 486559830
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-AC-AF-BC-54-42-49-F6-CF- F9

DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                   fec0:0:0:ffff::2%1
                                   fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter VMware Network Adapter VMnet8:

Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8
Physical Address. . . . . . . . . : 00-50-56-C0-00-08
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::c83e:7ac0:4762:fb52%32(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.1.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 838881366
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-AC-AF-BC-54-42-49-F6-CF-F9

DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                   fec0:0:0:ffff::2%1
                                   fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled

Tunnel adapter isatap.{6C49020A-98D2-48B0-984D-65C147047475}:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #2
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{3430FAAF-97F3-410C-97B4-BA1AAFCE1FC3}:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes

 Tunnel adapter isatap.{610BCE9C-8DD1-4874-8A4C-2AED8A2CC2AE}:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #4
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.domain.name:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix  . : domain.name
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #5
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes

Tunnel adapter isatap.{41B0142F-60AE-48D7-9374-8A164EA54798}:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #6
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes

C:\Windows\system32>

A: 1st.
the problem is OS related. It's only my computer that refuses to connect to the router settings, other computers can successfully connect to 192.168.1.1.
2nd.
I found what the problem was, the way router was responding to my connection request even with different devices was weird so that's how i found it. It was about Wireless MAC filtering which gives the router the ability to allow only wireless devices with specific MAC address to connect to it. my friend also confirmed it.

A: Check whether your VMware Network Adapter is Disabled or not.
It may use the dhcp ip-address having range 192.168.0.0/24.
Disable it.


text:
Q: Replication of RabbitMQ queues into different node(upgraded) I have one RabbitMQ cluster which consists of 3 nodes (each node has : Rabbitmq version :3.3.5, Erlang R14B0 ). Let's call this as Group1. Each node has n number of queues.
I have another cluster with set of 3 nodes with specifications as RabbitMQ 3.6.6, Erlang R16B03-1.Let's call this as Group2.
I need to replicate the queue structure of Group1 (node 1,node 2,node 3)  exactly for Group2(node 1,node 2,node 3).
Is there any easy way to perform this without having to add each queue explicitly. Please suggest some  measures.
Thank you.
Regards,
Shweta

redpajama_set_name: RedPajamaStackExchange


text:
Q: how to combine mahout recommendations I'd like to build a simple recommendation system. Let's say for online shop, where I have events like purchases, likes, views.
Currently, I understand how to build a recommendation for each of those types of events separately. But, I can't figure out how to combine those results to provide a user a single list of the most relevant items.
It would be great if you could point me to the docs or briefly explain so I could google it.
Thanks in advance!

A: There are different ways how to combine the recommendations.
One straight forward way is built three types of recommenders (or as many as you need), and put the recommendations from all of them into one list, and sort it by the estimated preference value. You can even have a wrapper recommender that combines your other recommenders underneath.
Another way is to combine the similarity metrics, instead of the recommendations. Again, you will have a CustomSimilarity class that implements the User/ItemSimilarity, depending on what you need, and combine the outputs of your individual similarity metrics into one as a linear combination. You should actually be careful when combining similarities. They should all be either User similarity measures or Item similarity measures. Then you will use this CustomSimilarity measure for your recommender.
You can read more about hybrid recommendation in this book.


text:
Q: Count in an Array a number of same value Items in Razor , Umbraco i am having an array of records
Model.Categories = ["apple", "banana", "apple", "orange"]

from this array i am displaying the records one by one
 @foreach (var category in Model.Categories)
            {
                @category
            }

so this currently displaying two times apple record but i wants to display single time with the count beside like this
apple -(2)
banana
orange

like this can any help me with this on Razor how to implement this ?

A: To do this, we need to create Method in Model which will return a Dictionary of category and its occurrence. Please find the below method which can be used to return the dictionary.
public Dictionary<string,int> CountArray()
    {
        Dictionary<string, int> countArr = new Dictionary<string, int>();

        foreach (var category in Categories)
        {
            if(countArr.ContainsKey(category))
            {
                countArr[category] = countArr[category] + 1;
            }
            else
            {
                countArr[category] = 1;
            }
        }
        return countArr;
    }

Now create a variable in cshtml file and assign this value returning from model.
Use this variable in foreach loop.
I guess this will help you in resolving your problem.
I really don't suggest this approach. But as you need help please find the Razor Code.
@{ Dictionary<string, int> countarry = new Dictionary<string, int>();}
@foreach (var category in Model.Categories)
{
    if (countarry.ContainsKey(category))
    {
        countarry[category] = countarry[category] + 1;
    }
    else
    {
        countarry[category] = 1;
    }
}
@foreach (var categoryName in countarry.Keys)
            {
if(countarry[categoryName] > 1)
        @categoryName - (@countarry[categoryName])
else
@categoryName
    }

I hope this is what you are expecting.

A: I have simple solution
var fruits = ["apple","coconut","apple","banana","papaya"];

var sortFruits = [];
for(fruit of fruits ){
if(sortFruits.includes(fruit)==false){
    sortFruits.push(fruit);
}

}
console.log(sortFruits);

A: Not sure if it could be "Razor code" as you call, but why don't you use Linq GroupBy?
The following code produce your expected output on browser.
@foreach (var category in categories.GroupBy(k => k))
{
    @category.Key@(category.Count() > 1 ? $" - ({category.Count()})" : "")

}

Example above works in Razor 3.0.0.0 and .Net franework 4.6.1 (C# 6.0)
The code above is a result after trying to output as expected in the question. If making it simpler, possibly it could work in earlier versions.
@foreach (var category in categories.GroupBy(k => k))
{
    @category.Key - @category.Count()

}


text:
Q: What's the difference between ngerman and german in babel? I use the following three packages to get correct German umlauts in the generated PDF:
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf

Today, I have seen this:
\usepackage[german]{babel}

What's the difference between ngerman and german? I think n could probably mean new, but which one should I use? Do you have an example where it matters?

A: Yes, the n stands for new, as it is the "neue deutsche Rechtschreibung" from (in the current form) 2006. One of the most common differences is the different use of 'ß' and 'ss'. As it is the current one, you should always use ngerman.
One example is "Schifffahrt" (new) in contrast to the old "Schiffahrt", as triple consonants at the joint of compound words used to be reduced to only two.

A: As has been said before, german is Alte Rechtschreibung (= "right-writing" = orthography = "right-writing"), ngerman is Neue Rechtschreibung. The part that's really relevant is hyphenation, because that's what babel influences. So here are some examples what has changed in hyphenation, taken from canoonet (I'm strongly assuming that babel implemented these changes, but I didn't check the code):

old         new
Braue-rei   Brau-e-rei
Bäk-ker     Bä-cker     ← This is imho the most important change, which can easily be spotted
Mei-ster    Meis-ter

While changes like old Schiffahrt to new Schifffahrt are correct, they're not really relevant from babel's point of view because babel doesn't correct your spelling, so that's really up to you, i.e. it depends on what you type. As always with such conventions, you should be consistent in your choice of orthography. Officially, Alte Rechtschreibung has been deprecated for a few years; before that, both were "allowed".

A: As said before german refers to "Alte Rechtschreibung", the orthography before 2006, and ngerman to "Neue Rechtschreibung", the orthography since 2006 (with transition period since 1996). Thus the differences are:

*

*Different hyphenation patterns are used due to changed rules in hyphenation.
In case of ngerman babel loads hyphenation pattern, that are derived from the
old patterns by Walter Schmidt.
BTW, there are newer experimental patterns, see dehyph-exptl. They can be made available using package hyphsubst.

*Some of the hyphenation rules have changed. In the old orthography ck was hyphenated
as k-k. Or triple consonants are avoided if followed by vowels, but the third consonants reappeared if hyphenated, e.g.:
Schiffahrt → Schiff-fahrt
In german this was supported by shorthands:
B"a"cker Schi"ffahrt

Because these cases are simplified in the new orthography, these special shorthands
are no longer available in ngerman:
  "c, "C, "f, "F, "l, "L, "m, "M, "n, "N, "p, "P, "r, "R, "t", "T

Also macro \ck has been dropped for the same reason.


text:
Q: Is this riemann integrable? So as far as I know to be riemann integrable there should be an value (lets say e>0 ) that $U(f,P)-L(f,P) < e$.
However my teacher showed that below function is not riemann integrable by this method.
Method
$$f(x) = \begin{cases} 1 & x\in[0,1]\cap \Bbb Q , \\ 0 & otherwise .\end{cases}$$
What she did was, $U(f,P) = 1(1-0)$ and $L(f,P) = 0(1-0)$
Since both are not equal this is not riemann integrable.
Problem
What she did was clear to me. So I tried to prove this beliw one using the same logic. But I don't know how to start it. If someone can please tell me what should I do to prove whether this is reimann integrable or not.
Let,
$$f(x) = \begin{cases} 1 & x\in[0,1]\setminus\ \frac{1}{2}\, \\ 0 & x=\frac{1}{2} .\end{cases}$$

A: It's a good idea to actually draw a few Riemann approximations, in this case.
Suppose $n$ is "large", and let's cut $[0, 1]$ into $n$ equal subintervals. Then:

*

*The upper Riemann sum will have every single rectangle of height $1$ (why?), so will guess that the area is $(1\cdot {1\over n})\cdot n=1$.

*The lower Riemann sum will have all but one rectangle of height $1$, and  one will be of height $0$ (why?). So the upper Riemann sum will be $(1\cdot{1\over n})\cdot (n-1)+ 0\cdot{1\over n}={n-1\over n}$.
Now, do these Riemann sums look like they're converging to the same value as $n$ goes to infinity? What does that suggest about whether $f$ is Riemann integrable?

The distinction between your $f$ and the function your teacher showed you (the Dirichlet function) is that your $f$ only has one "bad" point ($f$ is discontinuous at $x={1\over 2}$), whereas the Dirichlet function has lots (every point is a bad point).

A: Let $P$ be a partition and let $a$ be the length of the sub-intervals which includes $1/2$.
Note that: if $1/2$ is an end point, then there exist two such sub-intervals and if it is not, then there exists one sub-interval.
Since each sub-interval has image value $1$, we have the supremum on each interval is $1$. Therefore $$U(f,P)=1.$$ Since the length  of interval having  the $1/2$ is $a$, we have $$L(f,P)=1-a.$$
Now $$U(f)=1$$ and $$L(f)=\sup\{ 1-a \; | \; a \in (0,1]\}=1.$$ Therefore, it is Riemann integrable and the integral value is $1$.


text:
Q: In Joomla article: How to load a module while hovering on a link I'm working on a Joomla website with a slider in it. I'm using {loadposition slider1}, to get the slider (slider 1) in an article. There is a text link beneath the slider. Now I'd like the page to load another slider (slider 2), in the position of slider 1 when someone hovers over the text link. So visitors hovering the link will see slider 2 in stead of slider 1 when hovering the link.
Can I do this by using javascript? I haven't  been able to find a solution. I hope someone can help me with this problem. Thanks in advance.

A: In Joomla! the {loadposition slider1} tag in articles is processed by a content plug-in when an event is triggered. Usually onContentPrepare or similar event. The important part of this is that it's all done on the server before it reaches the users browser.
As it's processed in the article there is no way to call the server again and request just slider 2...
To swap in your slider2 would require the browser to already have it available.  To achieve this you could have {loadposition slider2} in a
 or other element in the article that is set to display:none. eg.

{loadposition slider2}

NB. this is not necessarily good html...
This means when the browser receives the article html, it contains the element it's just hidden, then you can use the your javascript to hide slider1 and show slider2 when the user hovers over the link.


text:
Q: Ångström sign not outputting correctly with libertine OT1 font I have this document:
\documentclass{article}
\usepackage[OT1]{fontenc}
\usepackage{libertine}
%\UndeclareTextCommand{\l}{OT1}
%\DeclareTextSymbolDefault{\l}{T1}

%\UndeclareTextCommand{\AA}{OT1}
%\DeclareTextSymbolDefault{\AA}{T1}

%\let\oldAA\AA
%\renewcommand{\AA}{\begingroup\fontencoding{T1}\selectfont\oldAA\endgroup}

\usepackage{amsmath}
\usepackage{siunitx}

%\DeclareSIUnit{\angstrom}{\AA}

\begin{document}

This is Quantifiably Efficiently Ligatured Text.

\AA

\si{\angstrom}

\l

\capitalring{A}

\end{document}

As you can see, the ł character is misprinted. I got that sorted out in this question, which is the first two commented lines, taking that specific symbol from the T1 encoding. I'm having similar issues with the Å symbol through the siunitx package. This checks for the default encoding and selects either \AA or \capitalring{A}:
\str_if_eq:VnT \encodingdefault { OT1 }
  {
    \__siunitx_option_unchanged:Nnn \l__siunitx_angstrom_math_tl
      { \text { \AA } }
      { \text { \capitalring { A } } }
    \__siunitx_option_unchanged:Nnn \l__siunitx_angstrom_text_tl
      { \AA }
      { \capitalring { A } }
  }

Hence, the MWE above checking these commands. Problem is, I can't get the symbol to show properly through siunitx. The second pair of commented lines follows the fix I got from the ł issue. But that just freezes the LaTeX compiler. The third pair of commented lines fix the \AA command, but I can't seem to make siunitx use it (final commented line).
Is there any way for the siunitx package to use the T1 encoded \AA (which is exacltly what I need)?
Note that I need OT1 encoding for cool ligatures (especially the Qu) displayed in the first sentence,a nd they disappear if I don't use OT1.

A: The command \AA is not encoding specific and this is the reason for the error: its definition is \r{A}. Unfortunately, the ring accent macro in OT1 encoding doesn't work well with the Libertine font, so you can adopt an ad hoc definition:
\documentclass{article}
\usepackage[T1,OT1]{fontenc}
\usepackage{libertine}

\usepackage{amsmath}
\usepackage{siunitx}

\DeclareSIUnit{\angstrom}{\mbox{\normalfont\AA}}

\UndeclareTextCommand{\l}{OT1}
\DeclareTextSymbolDefault{\l}{T1}

\makeatletter
\DeclareRobustCommand{\AA}{%
  \leavevmode
  \vbox{\ialign{##\cr
    \hidewidth\char'27 \hidewidth\cr
    \noalign{\nointerlineskip\kern-1.4ex}
    A\cr
  }}%
}
\makeatother

\begin{document}

This is Quantifiably Efficiently Ligatured Text.

\si{\angstrom}

\l

\end{document}

I'm afraid that \AA will not work in other font shapes (italic, especially). If you just use it for the angstrom unit (which you shouldn't, by the way), it's good.


text:
Q: How development remote project using Pycharm without cloning the file to local environment? I have a big project located on a remote server. Now I just want to open these files and code it (maybe debug and run the project) without cloning the file to my local pc.
The procedure that Pycharm configures a project is too slow. Meanwhile, some data files are too big(TB size), impossible to clone it to local pc. I know that I can exclude it through configuring the development tool. But it's not the experience I desire.
I just want a simple editor to do some code and run it. Just like using vim to edit and python xxx.py with ssh on iterm2, but with a good debugging experience.

A: You could potentially try mounting the folder your project lives in over SSH using SSHFS. It's unconventional but it would allow you to open up your project in pycharm.
Speed of it would depend on your internet connection, latency, etc.
Another way would be to install something like VSCode Server on the actual host. This will allow you to open up VSCode instance in your browser.

A: Another approach is to edit your remote code repository through VSCode 1.56 (Apr. 2021) VSCode "Remote Repository" feature

Remote Repositories (RemoteHub)#
As part of this release, we are previewing a new built-in extension, Remote Repositories (RemoteHub), which allows you to instantly browse, search, edit, and commit to any GitHub repository directly from within VS Code without having to clone or have the repository locally.
To get started, run the Open Remote Repository... command from the Command Palette. From there, you can paste in any GitHub URL, or choose to search for a specific repository or pull request.

Once you enter a URL or choose a repository or pull request, VS Code will open a new workspace for that repository.
The remote status indicator, on the left side of the Status bar, shows the connected remote provider name, for example GitHub, for the remote repository.

Now:

*

*it seems to be limited to GitHub repositories

*it has limited language intelligence - Many language servers don't yet understand this virtualized environment. TypeScript supports single file intelligence for remote repositories.

*and limited extension support - As with language servers, many extensions don't work with remote repositories. Extensions can opt-out and will not be activated for virtual workspaces.

It will be however publicly available in VSCode 1.57 (May 2021), with a  few new features.

You can now see your remote repositories in the Remote Explorer view, to quickly open or see and compare any uncommitted changes you may have.
Additionally, you can apply changes, from the same repository, to the current remote repository — allowing you to quickly and easily move uncommitted changes from one branch to another.

A: You can check remote interpreter using Docker:
https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html
Without docker might be harder


text:
Q: How do I create an application pool with specific user in IIS 8.5 using PowerShell? The shortened code below works, but it winds up using the ApplicationPool identity, not the specific ones that I specify in the array.
Declarations:
#App pool array positions
$Name = 0
$User = 1
$Pwdx = 2

#Application array positions
$SiteNm = 0
$PhyPath = 1
$PoolNm = 2

#App Pool Settings
$Port="80"
$HostName="*"
$Environment="local"
$Runtime="v4.0"
$Pipeline="0" #Integrated
$Identity="3" #SpecificUser

#Define the App Pools
$Pools = @(3)*2
$Pools[0] = "SomeAppPool","FooBar\SomeUser","S0meUs3rP4ssw0RD"
$Pools[1] = "AnotherAppPool","FooBar\AnotherUser","An0th3rUs3rP4ssw0RD"

Execute Code:
Import-Module WebAdministration

#navigate to the app pools root
cd IIS:\AppPools\

foreach($p in $Pools)
{
    $AppPoolName = $p[$Name]
    $AppPoolUser = $p[$User]
    $AppPoolPwd = $p[$Pwdx]

    $appPool = New-Item $AppPoolName
    $appPool | Set-ItemProperty -Name managedRuntimeVersion -Value $Runtime
    $appPool | Set-ItemProperty -Name managedPipelineMode -Value $Pipeline
    $appPool | Set-ItemProperty -Name processModel.identityType -Value $Identity
    $appPool | Set-ItemProperty -Name processModel.username -Value $AppPoolUser
    $appPool | Set-ItemProperty -Name processModel.password -Value $AppPoolPwd

    Write-Host "$AppPoolName Application Pool Created..."
}

A: Instead of using "Set-ItemProperty", access and set the AppPool property directly:
$appPool = New-Item $AppPoolName
$appPool.managedRuntimeVersion = $Runtime
$appPool.managedPipelineMode = $Pipeline
$appPool.processModel.identityType = $Identity
$appPool.processModel.username = $AppPoolUser
$appPool.processModel.password = $AppPoolPwd
$appPool | Set-Item
$appPool.Stop()
$appPool.Start()

EDIT: Did some testing and it appears that your code works just fine, except it does not set the user name. Why?
The actual parameter is "processModel.userName" (Notice the capital 'N').
So, it looks like
$appPool | Set-ItemProperty -Name processModel.userName -Value $AppPoolUser

is case sensitive, but
$appPool.processModel.username = $AppPoolUser

is not. Got to love PowerShell.


text:
Q: Error in R: unable to find an inherited method for function 'dbWriteTable' I'm trying to write a table in a db using R and I got this error:
Script:
try(
silent = TRUE, {
dbWriteTable(conn, tableName, csvData, append = app, overwrite = !app)
dbDisconnect(conn)})

PS.: app <- FALSE
Error:

"Error in (function (classes, fdef, mtable)  : \n  unable to find an inherited method for function 'dbWriteTable' for signature '\"character\", \"character\", \"data.frame\"'\n"
  attr(,"class")
  [1] "try-error"
  attr(,"condition")
  \001NULL\001, skeleton = (function (conn,     name, value, ...) stop("invalid call in method dispatch to 'dbWriteTable' (no ...

A: This happened to me because the object I was providing was not a data.frame (or tibble).
dbWriteTable(conn, tableName, csvData, append = app, overwrite = !app)

How I fixed it was to simply convert the object to a data.frame before calling dbWriteTable()
csvData <- as.data.frame(csvData)
dbWriteTable(conn, tableName, csvData, append = app, overwrite = !app)
#  It works!


text:
Q: with OutputCache random user have to pay cost I'm using OutputCache to avoid execute same code everytime, but I have the following problem:
when it expires, a random user have to pay the cost to execute this code.  Can avoid it??
I'm using asp.net MVC 4.0.
thanks!

A: If data is really immutable, you can set Duration property to max value and forget.
But if cache entry expires, you have to load fresh data anyway. By design, OutputCacheAttribute allows to load data on demand only. If you want to precache data, you should invent your own caching mechanism, or extend OutputCacheAttribute someway.


text:
Q: PostgreSQL SELECT query using same structure as a DELETE query With MySQL, I perform a delete with a join as follows:
DELETE t1
FROM t1
LEFT OUTER JOIN t2 ON t2.fk_id = t1.id
WHERE t2.id IS NULL;

Before executing the query, I would typical make sure I am okay with the outcome first by viewing the soon to be deleted records as follows:
SELECT t1.*
FROM t1
LEFT OUTER JOIN t2 ON t2.fk_id=t1.id
WHERE t2.id IS NULL;

Using PostgreSQL, I believe I should perform the same delete action as follows (EDIT below):
DELETE FROM t1
USING t2
WHERE t1.id = t2.fk_id
AND t2.id IS NULL;

Concerned that I might not be correct, I unsuccessfully tried the following:
SELECT t1.*
USING t2
WHERE t2.fk_id=t1.id
AND t2.id IS NULL;

Is there a way with PostgreSQL to perform a SELECT query using the same structure as a DELETE query?
EDIT - Not even correct since I am effectively performing an INNER JOIN and will not delete any records, and will need to change it as follows.  Still would appreciate an answer to my original question.
DELETE FROM t1
USING t1 t_1
LEFT OUTER JOIN t2 ON t2.fk_id=t_1.id
WHERE t1.id=t_1.id AND t2.id IS NULL;

A: I would use a NOT EXISTS condition:
delete from t1
where not exists (select *
                  from t2
                  where t1.id = t2.fk_id);

That's typically faster than a join and it's also standard compliant SQL.


text:
Q: UIImageView fill in UIView I have a UIImageView as a subview of UIView (frame size 300 x 300). My UIImage would be either portrait, landscape or some odd sizes. How do I fill in the UIImage within the UIView frame size without stretching the image to 300 x 300?
The purpose of this, I will be adding another UIImageView as the image border.
Please help.
Thanks.

A: Ah I just reread what you were asking, I know what your question is now.
Your UIImageView's frame changes, and when it does so does your image. You don't want your image to change, but you do want your ImageView to adjust to fill the view it is contained in.
UPDATE
I figured it out.
[self.imageView setContentMode:UIViewContentModeCenter];

No matter what orientation, the size stays the same.
You also have the option of setting it to align top, bottom, left, right, top left, top right, bottom left, bottom right, all of which only help to align your image and NOT redraw or re-size the image.
Does that help?

A: Try
[img setContentMode:UIViewContentModeScaleAspectFit];

UIViewContentModeScaleAspectFit: Scales the content to fit the size of the view by
  maintaining the aspect ratio. Any remaining area of the view's bounds is transparent.

or [img setContentMode:UIViewContentModeScaleAspectFill];

UIViewContentModeScaleAspectFill: Scales the content to fill the size of the view. Some
  portion of the content may be clipped to fill the view's bounds.

if you are clipping subviews, then you need to do
[imgView clipToBounds:YES];

A:  [image setContentMode:UIViewContentModeScaleToFill];

A: Set the contentMode property of UIImageView to either of this values depending on where you want to put it in the superview:
 UIViewContentModeCenter,
    UIViewContentModeTop,
    UIViewContentModeBottom,
    UIViewContentModeLeft,
    UIViewContentModeRight,
    UIViewContentModeTopLeft,
    UIViewContentModeTopRight,
    UIViewContentModeBottomLeft,
    UIViewContentModeBottomRight,

As this values:
UIViewContentModeScaleToFill,
    UIViewContentModeScaleAspectFit,
    UIViewContentModeScaleAspectFill,

Will indeed cause the image to be 300 x 300, which is what you don't want.

A: Use the contentMode property of UIImageView.

Edit: and set the image size to 300x300.


text:
Q: Searching though an empty jagged array in VB.NET So I have a function that looks up values in a jagged array, and it goes like this:
Private Function Lookup(ByVal Search_path As String) As Integer
    Dim i As Integer = 0
    Do Until MasterIndex(i) Is Nothing 'throws an exception here
        If Search_path = MasterIndex(i)(0) Then
            Return MasterIndex(i)(1)
        End If
        i = i + 1
    Loop
    Return -1
End Function

Problem is, when I test this with an empty array, it gives me the error of Index was outside the bounds of the array at line 3. How do I fix this?

A: You need to check to see if your indexer exceeds the number of elements in the array.
Private Function Lookup(ByVal Search_path As String) As Integer
    Dim i As Integer = 0
    Do Until i = MasterIndex.Length OrElse MasterIndex(i) Is Nothing
        If Search_path = MasterIndex(i)(0) Then
            Return MasterIndex(i)(1)
        End If
        i = i + 1
    Loop
    Return -1
End Function

A: Arguably cleaner as a FOR loop:
Private Function Lookup(ByVal Search_path As String) As Integer
  for i = 0 to MasterIndex.Length - 1
    if MasterIndex(i) is nothing then exit for
    If Search_path = MasterIndex(i)(0) Then
        Return MasterIndex(i)(1)
    End If
  next
  Return -1
End Function

Endlessly debatable.


text:
Q: Spying on instance variable and return the value when instance function get calls I am trying to mock class instance and then return the mock object when we call the instance function but in result, it makes an actual call to function.
Here is my code:
AuthenticationSessionModel authSessionCookie =
    new AuthenticationSessionManager(session)
       .getCurrentAuthenticationSession(realm, client, tabId);

and my test code is:
AuthenticationSessionManager spyAuthSessionManager =
    Mockito.spy(new AuthenticationSessionManager(session));

doReturn(authenticationSessionModel)
    .when(spyAuthSessionManager)
    .getCurrentAuthenticationSession(any(), any(), anyString());

It makes an actual call to getCurrentAuthenticationSession() and returns me Null Pointer Exception

A: In the test, you create a spy, and stub some behaviour.
But you don't use that spy in the code under test.
Instead, in the code under test you create a new AuthenticationSessionManager.
You need to restructure your code and:

*

*create AuthenticationSessionManager outside of object under test.

*pass it to object under test. Constructor is the first thing that comes to mind.

With these changes, it becomes trivial to substitute a real AuthenticationSessionManager with a spy in a test.


text:
Q: Echo number of rows per group by I have a mysql query in which I group each post by the date is was posted. I want to be able to echo the amount of posts that happened each day, know a way?
Here is what I've written so far which does post a new
 for each day it was posted.
$trendQuery = "
SELECT DATE(timestamp) AS ForDate,
    COUNT(*) AS NumPosts
 FROM   trends
 WHERE `trend` = '" . $_GET['graph'] . "'
 GROUP BY DATE(timestamp)
 ORDER BY ForDate
";

$result = mysql_query($trendQuery);
    while ($row = mysql_fetch_array($result)) {
        echo'

Here is where I want to say how many posts that happened!

    ';
}

A: You have your query pretty much set up. To echo the results, you simply need to refer the columns with the alias name, in your case ForDate and NumPosts
$trendQuery = "
SELECT timestamp AS ForDate,
    COUNT(*) AS NumPosts
 FROM   trends
 WHERE `trend` = '" . $_GET['graph'] . "'
 GROUP BY timestamp
 ORDER BY ForDate
";

$result = mysql_query($trendQuery);
    while ($row = mysql_fetch_array($result)) {
        echo'

            Date: '.$row['ForDate'].' ---- Number of Posts: '.$row['NumPosts'].'

    ';

A: Create a view of your trend query and inner join it with "Select (Id or day that you want to merge) From trend"
i hope that helps


text:
Q: Uninstall windows VM installed with curl on Mac I tried installing a Windows VM with IE11 using the curl command
curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="11″ bash

This didn't end up being recognised as a VM on Oracle Virtual box, so I headed over to windows' website and downloaded a zip folder which worked fine. I'm looking for a way to uninstall/remove the previously installed windows VM (It is verifiably taking up space) that I installed using cURL on a Mac

A: Try to find the file like this:
find / -type f -name "*.exe"

You can also search for zip because I see zip files in that .sh:
find / -type f -name "*.zip"

If you have a lot of zip files you should search for every image like:
find / -name "IE9_Win7.zip"


text:
Q: Dependency module fails to load resource when used in the IT module I'm working on a multi-module project which contains a service and an integration-tests module.
In the service module there is a service for some reset password functionality, based on Spring greenhouse which is using a template file which is expected to be loaded on initialization. While trying to solve this issue I changed slightly the initialization of the class based on the loaded file and moved it to xml configuration:
<bean id="resetPasswordMailMessageConverter" class="com.myapp.service.reset.ResetPasswordMailMessageConverter">
    <constructor-arg name="resource">
        <value>classpath*:**/spring/reset-password.st</value>
    </constructor-arg>
</bean>

The service works fine once deployed and used in tomcat but there are issues when integration tests are executed : Unable to read template resource class path resource [classpath*:**/spring/reset-password.st]
I placed that file in both places serviceModule/META-INF/spring/ and integrationTestsModule/META-INF/spring/ but still it can't be found.
I placed some code both in service and in integration tests where I export the result of ClassLoader.getSystemResources("META-INF") and noticed that in both cases the integrationModule/target/test-classes/META-INF and the .m2/repository/../serviceModule.jar!META-INF are included in the exported path and the file is contained inside both META-INF/spring/ but not found.
I tried also keeping the file in the same package with the converter and initializing converter's resource as new ClassPathResource("reset-password.st", getClass().getClassLoader()) or new ClassPathResource("reset-password.st") but didn't work.
The structure of the project is mainModule->[mainSubmoduleA->[serviceModule, integrationTestsModule, etc], mainSubmoduleB[other modules]]
Any idea?
There's a basic layout of the project structure

Parts of the pom files:
main:
...........

<groupId>com.myapp</groupId>
<artifactId>mainModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
.............
<modules>
    <module>mainSubmoduleA</module>
    <module>mainSubmoduleB</module>
</modules>

mainSubmoduleA:
..............
<parent>
    <groupId>com.myapp</groupId>
    <artifactId>mainModule</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
.........

<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.mainsuba</groupId>
<artifactId>mainSubmoduleA</artifactId>
<packaging>pom</packaging>
<name>mainSubmoduleA</name>
..........

<modules>
  <module>subModuleAA</module>
</modules>
...............

subModuleAA:
<parent>
  <groupId>com.myapp.mainsuba</groupId>
  <artifactId>mainSubmoduleA</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.mainsuba.subaa</groupId>
<artifactId>subModuleAA</artifactId>
<packaging>pom</packaging>
<name>subModuleAA</name>
..........

<modules>
  <module>service</module>
  <module>web</module>
  <module>integration</module>
</modules>

service:
<parent>
  <groupId>com.myapp.mainsuba.subaa</groupId>
  <artifactId>subModuleAA</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.mainsuba.service</groupId>
<artifactId>service</artifactId>
<packaging>jar</packaging>
<name>service</name>

web:
<parent>
  <groupId>com.myapp.mainsuba.subaa</groupId>
  <artifactId>subModuleAA</artifactId>
 <version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp.mainsuba.web</groupId>
<artifactId>web</artifactId>
<packaging>war</packaging>
<name>web</name>

integration:
<parent>
  <groupId>com.myapp.mainsuba.subaa</groupId>
  <artifactId>subModuleAA</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>integration</artifactId>
<packaging>jar</packaging>
<name>integration</name>
<description>Integration Tests</description>

A: Chris,
try setting the resource value without any ant-style wildcard matchers. I.e.:
<value>META-INF/spring/reset-password.st</value>

More info on wildcard restrictions can be found here: Other notes relating to wildcards


text:
Q: Error al exportar en PDF con Report Viewer Tengo un Report Viewer en Visual Studio 2017 con C# con su llamada al DataSet, hice todo de manera visual, no realice ningún código, cargue la conexión desde el administrador de servidores, coloque mi tabla, llene el diseño, me cargan los datos, todo bien, el problema ocurre al intentar exportalo a PDF, lo exporto a Word y Excel y me guarda, pero cuando intento exportarlo a PDF me aparece una interrupción y me sale el siguiente mensaje:
Asistente para la depuración administrada 'PInvokeStackImbalance'
Mensaje = Asistente para la depuración administrada 'PInvokeStackImbalance': "Una llamada a la función PInvoke 'Microsoft.ReportViewer.Common!Microsoft.ReportingServices.Rendering.ImageRenderer.FontPackage::CreateFontPackage' impidió la correspondencia de la pila. Es posible que la razón sea que la signatura PInvoke administrada no coincida con la signatura de destino no administrada. Compruebe que la convención y los parámetros de llamada de la signatura PInvoke coinciden con la signatura no administrada de destino."
Solo ocurre con el PDF, ¿alguna manera de solucionarlo?

A: Tuve el mismo problema, el Report Viewer generaba el documento correctamente y podía imprimirlo, pero al intentar exportarlo en PDF se interrumpía la ejecución haciendo referencia a la pila de llamadas.
Después de navegar por diversos foros encontré algunos comentarios que hablaban sobre la arquitectura.. así que probé cambiar la arquitectura de visual studio de "ANY CPU" a "X64" y se solucionó el problema. Por lo que entendí la pila de llamadas se maneja distinto en X32 y X64.

A: Para mantener las configuraciones solo se necesita:
var deviceInfo = @"<DeviceInfo>
<EmbedFonts>None</EmbedFonts>
</DeviceInfo>";

byte[] bytes = rdlc.Render("PDF", deviceInfo);

A: Me pasó lo mismo, lo solucioné pasando el parámetro de deviceInfo así:
Warning[] warnings;
string[] streamIds;
string contentType;
string encoding;
string extension;
string deviceInfo = @"<DeviceInfo>
                      <OutputFormat>EMF</OutputFormat>
                      <PageWidth>8.5in</PageWidth>
                      <PageHeight>11in</PageHeight>
                      <MarginTop>0.25in</MarginTop>
                      <MarginLeft>0.25in</MarginLeft>
                      <MarginRight>0.25in</MarginRight>
                      <MarginBottom>0.25in</MarginBottom>
                    </DeviceInfo>";

//Export the RDLC Report to Byte Array.
byte[] bytes = rdlc.Render("PDF", deviceInfo, out contentType, out encoding,
                           out extension, out streamIds, out warnings);


text:
Q: Removing files that do not exist I apologize for the possibly misleading title, but it is the best way I could think of to describe the problem, which is: I have several files that I can cat, but when I try to rm them I get a "No such file or directory" error.
$ cat "A11 D5 D5.txt"
... OUTPUT ...
$ rm -f "A11 D5 D5.txt"
rm: cannot remove `A11 D5 D5.txt': No such file or directory

I've tried overwriting the file and can execute the remove without error, but the file is still there; I can still cat the file.
$ echo "Boom" > "A11 D5 D5.txt"
$ cat "A11 D5 D5.txt"
Boom
$ rm -f "A11 D5 D5.txt"
$ cat "A11 D5 D5.txt"
Boom
$ rm -f "A11 D5 D5.txt"
rm: cannot remove `A11 D5 D5.txt': No such file or directory

I'm at a complete loss. I suspect a reboot would fix the problem, but I am really more interested in why such a thing would happen. Some sort of filesystem problem? (I don't have reboot privileges for the system; it's a university cluster.)
Edit: I get the following output
$ ls
A11 D5 D5.txt
$ ls -b
A11\ D5\ D5.txt
$ printf '<%q>\n'
<''>

I've also stated the file (just in case):
$ stat A11\ D5\ D5.txt
  File: `A11 D5 D5.txt'
  Size: 5               Blocks: 8          IO Block: 131072 regular file
Device: 1bh/27d Inode: 18446744068941111933  Links: 1
Access: (0644/-rw-r--r--)  Uid: (  596/  <username>)   Gid: ( 1015/<group>)
Access: 2012-12-09 22:48:29.000000000 -0600
Modify: 2012-12-09 22:56:44.835662498 -0600
Change: 2012-12-09 22:56:44.835662498 -0600

Edit 2: The filesystem is apparently of type "fuse" and
$ ls -lb A11\ D5\ D5.txt
-rw-r--r-- 1 <username> <group> 5 Dec  9 22:56 A11\ D5\ D5.txt

A: You can try to using tools to determine the filename for you if you think it has some special characters you can't see.
ls | xargs -i rm -i {}

or
find . -exec rm -i {} \;


text:
Q: Emacs - Skip whitespace kills I'm trying to make the kill ring essentially ignore whitespace only entries (tabs, newlines, just spaces, etC), I'm fairly new to elisp and I'm pretty sure the way to do is by doing defadvice but I have a few questions.

*

*Would it better to stop whitespace entries from ever getting into the kill ring in the first place, or to skip them on yank? I assumed the latter.

In which case, I'm completely lost on which function I should advise, its between current-kill, yank, and insert-for-yank - but am not entirely sure which I should manipulate to not yank whitespace from the kill ring.
Thanks!
EDIT: I'm pretty sure the way to do this is to manipulate `current-kill' to keep calling itself until it reaches a non whitespace entry? (or the end of the ring, whichever comes first)

A: From the comments it seems that you are having problems with whitespaces in your kill-ring since you kill whitespace lines. My solution would be to avoid killing whitespace lines and to use the function delete-blank-line (C-x C-o) instead. This reduces a group a blank lines (including whitespaces and tabs) to a single blank line.

A: I wrote a package clean-kill-ring.el that provides functionality for controlling what is allowed in the kill ring.
By default enabling clean-kill-ring-mode prevents blank strings from entering the kill ring, but further customization is possible as well.

A: The following advice does not let whitespace be added to the kill ring in the first place:
(defun night/h-kill-skip-whitespace (orig-fn string &optional rest)
  (let* (
         (string-raw (substring-no-properties string))
         (space-p (not (string-match-p "[^ \t\n\r]" string-raw))))

    (cond
     ((not space-p)
      (apply orig-fn string rest))
     (t
      (message "skipped whitespace kill")
     ))))

(advice-add 'kill-new :around #'night/h-kill-skip-whitespace)


text:
Q: The following ProviderNotFoundException was thrown building Consumer(dirty) Error: Could not find the correct Provider above this Consumer Widget
EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK
The following TestFailure object was thrown running a test:
Expected: exactly one matching node in the widget tree
Actual: _TextFinder:<zero widgets with text "0" (ignoring offstage widgets)>
Which: means none were found but one was expected

When the exception was thrown, this was the stack:

#4 main.<anonymous closure> (file:///C:/flutter/MyProject/dumpit/test/widget_test.dart:19:5)

(elided one frame from package:stack_trace)

This was caught by the test expectation on the following line:

file:///C:/flutter/MyProject/dumpit/test/widget_test.dart line 19
The test description was:
Counter increments smoke test

A: There was default test case file present in test folder which was against my app model and hence threw an error. I got rid of it to solve my test run


text:
Q: Is it possible to dynamically create an entry point for each folder in the webpack config? This is my current folder structure:
-- src
   -- js
      -- page 1
         -- index.js
         -- actions
         -- components
         -- reducers
      -- page 2
         -- index.js
         -- actions
         -- components
         -- reducers
      -- page 3
         -- index.js
         -- actions
         -- components
         -- reducers

And this is my webpack.config.js:
module.exports = {
    entry: {
        page1: './src/js/page1/index.js',
        page2: './src/js/page2/index.js',
        page3: './src/js/page3/index.js',
    },
    output: {
        path: './assets/javascripts',
        publicPath: '/assets/',
        filename: '[name].js'
    }
}

So every time I create a new page, I have to add another line in my entry object. This may get very big and very messy.
So is there a way to just have webpack loop through all the folders in the /src/js/ folder and automatically make the index.js in the corresponding folder the entry point?

A: To add to the answer above mine since I cannot comment. Using the path.basename method will give you clean, un-nested file names.

const glob = require("glob")
const path = require("path")

const entry = glob
    .sync("src/js/**/*.js")
    .reduce((acc, curr) => {
        return {...acc, [path.basename(curr, ".js")]: curr}
    })

module.exports = {
    entry,
    output: {
        path: './assets/javascripts',
        publicPath: '/assets/',
        filename: '[name].js'
    }
}

A: Use the glob package:
const glob = require("glob");

const entry = glob.sync("src/js/**/*.js")
    .reduce((x, y) => Object.assign(x, {
        [y]: y,
    }), {});

module.exports = {
    entry,
    output: {
        path: './assets/javascripts',
        publicPath: '/assets/',
        filename: '[name].js'
    }
}

This iterates over your whole folder structure and grabs each js file and adds it to the entry hash

A: This is how I did for nested directory using glob:

const path = require('path');
const glob = require('glob')

let entries = glob.sync('./CLientApp/src/js/**/**/**/*.js').reduce((entries, entry) => {
    let arr = []
    let entryName = ""

    const SplitPathIntoArry = (path) =>{
        let splitted = []
        splitted = path.split('/')
        if(splitted.length > 4){
            splitted.splice(0, 4)
        }
        return splitted
    }

    arr = SplitPathIntoArry(entry)

    let entryName2 = ""
    if(arr.length > 1){
        arr.forEach((o, i) => {
            entryName2 += `/${o}`
        });
    }

    if(entryName2.length > 1){
        entryName2 = entryName2.slice(0, -3)
        entryName2 = entryName2.substring(1)
        entryName = entryName2
    }else{
        entryName = path.parse(entry).name
    }

    entries[entryName] = entry

    return entries
}, {});

module.exports = {
    mode: 'development',
    entry: entries,
    output: {
        filename: 'js/[name].entry.js',
        path: path.resolve(__dirname, 'dist'),
        clean: true,
        publicPath: ""
    },

}


text:
Q: How to remove duplicates from a given sample string? s = "aadarsh , aravind aadarsh,"
st=s.split()
lst=[]
for i in st:
    if i not in lst:
         lst.append(i)
print(' '.join(lst))

this is my program but am not able to get my desired output
My sample string is
s = "aadarsh , aravind aadarsh,"
and my output should be -> aadarsh , aravind
and all the duplicates should be removed including commas as well how to do it.

A: The issue seems to be with the fact that split should sometimes work with a comma, and sometimes with a space. Use re.split instead:
s = "aadarsh , aravind aadarsh,"
st=re.split("[\s,]+", s)
lst=[]
for i in st:
    if i and i not in lst:
         lst.append(i)
print(' '.join(lst))
==> aadarsh aravind

An even simpler solution would be to use a set:
s = "aadarsh , aravind aadarsh,"
# (use comprehension to drop empty strings)
lst = [x for x in set(re.split("[\s,]+", s)) if x]
print(' '.join(lst))


text:
Q: Is there a way to shorting this regular expression I am not very good at regular expressions so i have hacked a solution to ignore whitespaces or new lines
here is my string which i am trying to find a match
    $str = 'name="something"> function
    (para
    m)';

The string may have line breaks or whitespaces anywhere. Please note that i do not want a implementation to  which includes string replacing on \n or \r or " ", as my real string is a PDF file containing human readable text.
My current solution is to wrap each character in (MY CHAR HERE)(\s)* as you can imagine my regex will be rather large for a big search string ie
    (n)(\s)*(a)(\s)*(m)(\s)*(e)(\s)*(=)(\s)*(")(\s)*(s)(\s)*(o)(\s)*(m)(\s)*(e)(\s)*(t)(\s)*

etc..............
Is there a simplier/cleaner solution for this?
My end goal is to do preg_replace
so hopefully something like this
    $pattern = ''; //My new pattern here

    $str = 'name="something"> function
    (para
    m)';

    $replace = 'name="something"> different function(param1, param2){} function(param)';
    echo preg_replace($pattern, $replace, $str);

A: You could dynamically construct a regex to add \s* inbetween each char.
I've seen very large regex strings, so thats not a concern. It might be
a tad slower, but not too much I don't think.
Split the string into chars, join it with '\s*' then use the regex.
Physically you could see it better (with one of those regex format programs)  -
n\s*a\s*m\s*e\s*=\s*"\s*s\s*o\s*m\s*e\s*t\s*
 n \s*
 a \s*
 m \s*
 e \s*
 = \s*
 " \s*
 s \s*
 o \s*
 m \s*
 e \s*
 t \s*

A: A slightly better way to construct a pattern:
$pattern = preg_replace('@\s+@', "\s+", preg_quote($str));

A: You could just strip all whitespace first, then run your match on the result of that. Much easier ;)


text:
Q: Изменения кода регистрации wordpress, какой файл редактировать? Я пробовал честно , искал , читал ..пробовал... но увы.. ничего не нашел путевого..
Поля для регистрации:
выбор1 - минор (ссылка1)
Выбор2 - прайм (ссылка2)

логин
мыло
пароль

В проверки правильности заполнения...

<?php

function getPage($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12');
    $data_fin = curl_exec($ch);
    curl_close($ch);
    return $data_fin;
}
$url = "Если выбрали минор то ссылка1 = Логин";  (пример ссылки http://w2.dwar.ru/user_info.php?nick=FC%20SD)
$page = getPage($url);
if(preg_match('/Ключевое слово/',$page)){
    $result = $names[] = "Если ключевое слово нашлось Регистрация разрешается";
    foreach ($names as $value) {
echo "$value
";
}
}else{
    $result = $names[] = "Если ключевого слова нет Регистрация запрещается";
    foreach ($names as $key => $value) {
echo "$value
";
}
}
      ?>

Подскажите пожалуйста в каком файле можно отредактировать так регистрацию ,может создать отдельный модуль? как это лучше сделать, и какая документация понадобится?

A: Если речь о кастомизации формы регистрации пользователей, то официальная документация должна помочь https://codex.wordpress.org/Customizing_the_Registration_Form


text:
Q: Postgresql - Sort a character field with Special characters, numbers and alphabets I have the following data in one of my Postgresql table.
name
-----------------
AdvertiserTest123
Advertiser ADV 833
:1Advertiser
02 Advertiser
MH Advertiser

When I query as: Select * from adv_names order by name;
The output I get is
AdvertiserTest123
Advertiser ADV 833
:1Advertiser
02 Advertiser
MH Advertiser

I'm expecting the order of sorting to be name with Specials Characters followed numbers and then alphabets. If I'm not wrong this is how it behaves in Sql Server.
I tried changing collation and tried ascii search. It doesn't work the way I am expecting.  Can anyone help on this?
Expected Output:
:1Advertiser
02 Advertiser
Advertiser ADV 833
AdvertiserTest123
MH Advertiser

A: The real question here is whether your expectation is reasonable. Sorting text values in SQL is determined by the collation. In PostgreSQL, you can change the collation when you run your query.
select * from adv_names order by "name" collate "POSIX";

It boils down to this: in which collations are special characters ordered before numbers? I don't think any of the collations work that way, but I could be wrong. (I don't have to think much about collations where I work.)
To see which collations are available to you, run this.
select * from pg_collation;

In a pinch, you can create your own collation.  See create collation. I'm not sure this will work for you. It depends on OS support and PostgreSQL build options.


text:
Q: Regular expression to allow dash sign I currently need to allow a "-" sign in this regular expression ^[a-zA-Z0-9]*$.

A: Simply add it as the first character after the opening bracket: ^[-a-zA-Z0-9]*$
Or, to match one or more of letters/numbers with a dash in between: ^[a-zA-Z0-9]+-[a-zA-Z0-9]+$

A: You could use a regex like this:
^[a-z\d]+[-a-z\d]+[a-z\d]+$

Working demo

The idea is to use insensitive flag to avoid having A-Za-z and use only a-z. And also use \d that's the shortcut for 0-9.
So, basically the regex is compound of three parts:
^[a-z\d]+   ---> Start with alphanumeric characters
 [-a-z\d]+  ---> can continue with alphanumeric characters or dashes
 [a-z\d]+$  ---> End with alphanumeric characters

A: Hyphen can be included immediately after the open bracket [ or before the closing bracket
] in the character class. You should not include in the middle of the character class, otherwise it will treat as range characters and some Regex engine might not work also.
In your case both are valid solutions
(^[-a-zA-Z0-9]*$) - Starting of the Char class
(^[a-zA-Z0-9-]*$) - End of the Char class

Demo:
http://regex101.com/r/yP3sH7/2


text:
Q: page width beyound 1250,headless-chromium will push content to out of left side it looks the default browser width is 1250, when my page content is greater than 1250, let's say 1682px.
then the content be pushed out to the left side(1250-1682 = -432px)
what the result is like this
this is test.js. you can run like node test.js
const puppeteer = require("puppeteer");
async function generatePDF(html) {
    const browser = await puppeteer.launch({
        headless: false,
        defaultViewport: null,
        args: [
            "--disable-dev-shm-usage",
            "--no-sandbox",
            "--disable-setuid-sandbox"
            // "--start-maximized" ///not working...
        ]
    });
    const page = await browser.newPage();
    await page.emulateMedia("print");
    await page.setContent(html, { waitUntil: "load" });
    return [page, browser];
}

generatePDF(require("fs").readFileSync("./test.html", { encoding: "utf8" }));

and this is the test.html page. i have set the body to position:absolute;top:0;left:0; in purpose. it is run fine in normal chrome browser ,but in headless-chromium, it just looks wired.

    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />

                                      Hello Kent

                                  <svg width="100%" height="100%">
                                    <g>
                                      <g
                                        transform="translate(100,90)"
                                        class="slices"
                                      >
                                        <path
                                          class="innerSlice"
                                          d="M -36.2 2.963645253936595e-15 A 36.2 24.200000000000003 0 0 1 -36.2 2.963645253936595e-15 L -36.2 20.000000000000004 A 36.2 24.200000000000003 0 0 0 -36.2 20.000000000000004 z"
                                          style="fill: rgb(40, 79, 159);"
                                        ></path>
                                        <path
                                          class="innerSlice"
                                          d="M -36.2 2.963645253936595e-15 A 36.2 24.200000000000003 0 0 1 -36.2 2.963645253936595e-15 L -36.2 20.000000000000004 A 36.2 24.200000000000003 0 0 0 -36.2 20.000000000000004 z"
                                          style="fill: rgb(171, 44, 14);"
                                        ></path>
                                        <path
                                          class="innerSlice"
                                          d="M -36.2 2.963645253936595e-15 A 36.2 24.200000000000003 0 0 1 -29.2864151963731 -14.22440310547785 L -29.2864151963731 5.775596894522151 A 36.2 24.200000000000003 0 0 0 -36.2 20.000000000000004 z"
                                          style="fill: rgb(199, 119, 0);"
                                        ></path>
                                        <path
                                          class="innerSlice"
                                          d="M -29.2864151963731 -14.22440310547785 A 36.2 24.200000000000003 0 0 1 11.18641519637309 -23.01556769434272 L 11.18641519637309 -3.015567694342721 A 36.2 24.200000000000003 0 0 0 -29.2864151963731 5.775596894522151 z"
                                          style="fill: rgb(12, 117, 19);"
                                        ></path>
                                        <path
                                          class="innerSlice"
                                          d="M 11.18641519637309 -23.01556769434272 A 36.2 24.200000000000003 0 0 1 36.2 -5.92729050787319e-15 L 36.2 19.999999999999993 A 36.2 24.200000000000003 0 0 0 11.18641519637309 -3.015567694342721 z"
                                          style="fill: rgb(119, 0, 119);"
                                        ></path>
                                        <path
                                          class="topSlice"
                                          d="M 90 0 A 90 60 0 0 1 27.81152949374527 57.06339097770921 L 11.124611797498108 22.825356391083687 A 36 24 0 0 0 36 0 z"
                                          style="fill: rgb(51, 102, 204); stroke: rgb(51, 102, 204);"
                                        ></path>
                                        <path
                                          class="topSlice"
                                          d="M 27.81152949374527 57.06339097770921 A 90 60 0 0 1 -72.81152949374525 35.267115137548394 L -29.124611797498105 14.106846055019359 A 36 24 0 0 0 11.124611797498108 22.825356391083687 z"
                                          style="fill: rgb(220, 57, 18); stroke: rgb(220, 57, 18);"
                                        ></path>
                                        <path
                                          class="topSlice"
                                          d="M -72.81152949374525 35.267115137548394 A 90 60 0 0 1 -72.81152949374527 -35.26711513754838 L -29.12461179749811 -14.106846055019354 A 36 24 0 0 0 -29.124611797498105 14.106846055019359 z"
                                          style="fill: rgb(255, 153, 0); stroke: rgb(255, 153, 0);"
                                        ></path>
                                        <path
                                          class="topSlice"
                                          d="M -72.81152949374527 -35.26711513754838 A 90 60 0 0 1 27.81152949374525 -57.06339097770922 L 11.124611797498101 -22.825356391083687 A 36 24 0 0 0 -29.12461179749811 -14.106846055019354 z"
                                          style="fill: rgb(16, 150, 24); stroke: rgb(16, 150, 24);"
                                        ></path>
                                        <path
                                          class="topSlice"
                                          d="M 27.81152949374525 -57.06339097770922 A 90 60 0 0 1 90 -1.469576158976824e-14 L 36 -5.8783046359072966e-15 A 36 24 0 0 0 11.124611797498101 -22.825356391083687 z"
                                          style="fill: rgb(153, 0, 153); stroke: rgb(153, 0, 153);"
                                        ></path>
                                        <path
                                          class="outerSlice"
                                          d="M 89.5 20 A 89.5 59.5 0 0 1 27.657020996557797 76.58786271956163 L 27.657020996557797 56.587862719561635 A 89.5 59.5 0 0 0 89.5 0 z"
                                          style="fill: rgb(40, 79, 159);"
                                        ></path>
                                        <path
                                          class="outerSlice"
                                          d="M 27.657020996557797 76.58786271956163 A 89.5 59.5 0 0 1 -72.40702099655779 54.973222511402156 L -72.40702099655779 34.973222511402156 A 89.5 59.5 0 0 0 27.657020996557797 56.587862719561635 z"
                                          style="fill: rgb(171, 44, 14);"
                                        ></path>
                                        <path
                                          class="outerSlice"
                                          d="M -72.40702099655779 54.973222511402156 A 89.5 59.5 0 0 1 -89.5 20.000000000000007 L -89.5 7.286648454926752e-15 A 89.5 59.5 0 0 0 -72.40702099655779 34.973222511402156 z"
                                          style="fill: rgb(199, 119, 0);"
                                        ></path>
                                        <path
                                          class="outerSlice"
                                          d="M -89.5 20.000000000000007 A 89.5 59.5 0 0 1 -89.5 20.000000000000007 L -89.5 7.286648454926752e-15 A 89.5 59.5 0 0 0 -89.5 7.286648454926752e-15 z"
                                          style="fill: rgb(12, 117, 19);"
                                        ></path>
                                        <path
                                          class="outerSlice"
                                          d="M -89.5 20.000000000000007 A 89.5 59.5 0 0 1 -89.5 20.000000000000007 L -89.5 7.286648454926752e-15 A 89.5 59.5 0 0 0 -89.5 7.286648454926752e-15 z"
                                          style="fill: rgb(119, 0, 119);"
                                        ></path>
                                        <text
                                          class="percent"
                                          x="43.686917696247164"
                                          y="21.160269082529034"
                                        >
                                          20%
                                        </text>
                                        <text
                                          class="percent"
                                          x="-16.686917696247157"
                                          y="34.23803458662553"
                                        >
                                          20%
                                        </text>
                                        <text
                                          class="percent"
                                          x="-54"
                                          y="4.408728476930472e-15"
                                        >
                                          20%
                                        </text>
                                        <text
                                          class="percent"
                                          x="-16.686917696247168"
                                          y="-34.238034586625524"
                                        >
                                          20%
                                        </text>
                                        <text
                                          class="percent"
                                          x="43.68691769624716"
                                          y="-21.16026908252904"
                                        >
                                          20%
                                        </text>
                                      </g>
                                    </g>
                                  </svg>

final updated
after i lunch putteteer with devtools: true,i finaly got why that happen
there is a css define that effect the page layout. i removed it,and it looks fine now.
@media print {
        .yGsvL .page {
          background: yellow !important;
          page-break-after: always;
          page-break-inside: avoid;
          width: 21.59999999969397cm;
          height: 29.599999999577385cm;
        }
      }

A: One of the args in the puppeteer configuration is the size of the window, even if it is headless...
This will do the trick to define the size
args: [`--window-size=1920,1080`]

Or even:
launchPuppeteerOptions: {
    args: [`--window-size=1920,1080`],
    defaultViewport: null
}


text:
Q: VectorPlot doesn't show PlotLegend when I change VectorColorFunction to measure vector components Using the example given in Mathematica's own reference page (https://reference.wolfram.com/language/ref/VectorColorFunction.html) we can make VectorPlot colour the arrows by, e.g., horizontal component (by inserting ...#3]&)):
VectorPlot[{-1 - x^2 + y, 1 + x - y^2}, {x, -3, 3}, {y, -3, 3}, VectorColorFunction -> (ColorData["Rainbow", #3] &)]

I can also give a default coloured VectorPlot a bar legend:
VectorPlot[{-1 - x^2 + y, 1 + x - y^2}, {x, -3, 3}, {y, -3, 3}, PlotLegends -> BarLegend[Automatic, LegendLabel -> "u"], VectorColorFunction -> ColorData["Rainbow"]]

But combining the two doesn't work! I get a VectorPlot coloured by component but with no legend:
VectorPlot[{-1 - x^2 + y, 1 + x - y^2}, {x, -3, 3}, {y, -3, 3}, PlotLegends -> BarLegend[Automatic, LegendLabel -> "u"], VectorColorFunction -> (ColorData["Rainbow", #3] &)]

I'd be grateful for any help on this; am I doing something wrong? Is this a bug? Is there a way around it?


text:
Q: How to call a function of component from view? Q1 : How to call a function of component from view?
one of my function is using most of the controllers.
public function actionDynamicdepartment()
    {

            //Department
            $data = Department::model()->findAll('p_id=0 AND company_id=:company_id', array(':company_id'=>(int) $_POST['company_id']));
            $data = CHtml::listData($data,'id','name');
            $dddepatment = "<option value=''>Please select a department</option>";
            foreach($data as $value=>$name)
                $dddepatment .= CHtml::tag('option', array('value'=>$value),CHtml::encode($name),true);

            //Section and Team
            $ddsection = "<option value=''>Please select a section</option>";
            $ddteam = "<option value=''>Please select a team</option>";

            // return data (JSON formatted)
            echo CJSON::encode(array(
              'dddepartment'=>$dddepatment,
              'ddsection'=>$ddsection,
              'ddteam'=>$ddteam
            ));
    }

I want to put it into component or some place.
And I want to call those function from my views. e.g
<div class="row">
    <?php echo $form->labelEx($model,'company_id'); ?>
    <?php
        $records = Company::model()->findAll();
        $company = CHtml::listData($records, 'id', 'name');

        echo $form->dropDownList($model,'company_id', $company, array('prompt'=>'Please select a company',
                'ajax' => array(
                    'type'=>'POST', //request type
                    'url'=>CController::createUrl('department/dynamicdepartment'), //url to call.
                    'dataType'=>'json',
                    'data'=>array('company_id'=>'js:this.value'),
                    'success'=>'function(data) {
                        $("#FaMovehistory_department_id").html(data.dddepartment);
                        $("#FaMovehistory_section_id").html(data.ddsection);
                        $("#FaMovehistory_team_id").html(data.ddteam);
                    }',
                )
            )
        );
    ?>
    </div>

Or
Q2 : put those function at one of the controller (department.php). And can I call those function from different view?
Q3 : if do as Q2, is there any traffic?

A: What I use to do is to define a CWidget (like Dmitry said) and then I create some functions (I tend to make them static, as if it was a library), so if, for instance, your Widget is called "Departments", you could do something like this:
Yii::import("application.components.Departments");
Departments::actionDynamicdepartment();

Pretty straightforward. You could, for this situation, return that CJson instead of echoing. However, you may not be interested in having a static response from this method.
For your last questions, I tend to approach the population of dropdowns in a more classic manner, having an ajax call (I use jquery) requesting a central controller and passing some variables to it. That, of course, generates traffic.
So, to sum up, if you want to recieve a list of departments and avoid changing it during the current page, you could go for a widget/component. If, on the other side, your dropdown needs to be responsive along with the rest of the items in a form, a controller's action is your best (and probably unique) option.

A: You need to create a widget instead of component.
Each widget has its own view, and you will be able to describe in its class logic of his behaviour (move the code from the controller) Then call it in the main view:
 <?php $this->widget('path.to.your.widget') ?>

Read more: http://www.yiiframework.com/doc/api/1.1/CWidget and http://www.yiiframework.com/doc/guide/1.1/en/basics.view#widget


text:
Q: How do I install the Google Wave server software? Now that the news is all around that Google will stop Wave development, and I like to keep using it, I was wondering how I can install their software. For example, is there a .deb package?

A: DJango version? http://code.google.com/p/pygowave-server/
Java: code.google.com/p/wave-protocol/wiki/Installation

A: There seems to be some progress being made by the Google Team towards "Wave in a Box". The latest seems to be : https://groups.google.com/group/wave-protocol/browse_thread/thread/99434acbce5d807d


text:
Q: The twisting sheaf The definition given of the twisting sheaf on $\textrm{Proj}S$ for some graded ring $S$ is $\mathcal O_S(n) = \widetilde{S(n)}$. I'm having trouble seeing what this sheaf is though, I'm not even totally sure what the module $S(n)$ is (I think it's the same set as $S$ but the grading is such that degree $i$ elements in $S(n)$ are degree $n+i$ elements in $S$?). I guess it's not helped by the construction of the sheaf associated to a module being not particularly easy to visualise.
For example of one of the things I'm having trouble understanding I've seen that $s \in S_d$ can be naturally associated to a global section of $\mathcal O_S(d)$ but I can't explicitly work out what this section should be.
Perhaps this question is too general/vague so if it is just let me know and I'll try and add in some more specific questions.

A: First, let's fix some notation to make our lives easier. Let $S_\bullet$ be a $\mathbb{Z}^{\geq 0}$-graded ring. We construct a scheme $\operatorname{Proj}(S_\bullet)$. It has a covering by affine open patches of the form $\operatorname{Spec}((S_{\bullet})_f)_0)$. In words, these affine open patches are the spectrum of the degree $0$ part of the localization of the graded ring at some homogeneous element $f$ of positive degree. These form a base for the topology on $\operatorname{Proj}(S_\bullet)$, and we can identify $\operatorname{Spec}((S_{\bullet})_f)_0)$ with $D(f)=\{p:f(p)\neq 0\}$. To define a sheaf, we only need to define a sheaf on the base, so we need to declare what the sections of our sheaf are on the $D(f)$ basic opens. Now let $M_\bullet$ be a $\mathbb{Z}$-graded $S$-module. In your case, we just take $M_\bullet=S_\bullet$. As you have in your post, we can define the graded module $M(n)_{\bullet}$ by $M(n)_{m}=M_{n+m}$. Now, we are ready to define our sheaf. We let $\Gamma(D(f),\widetilde{M(n)_{\bullet}})=((M_{\bullet})_f)_n$.
The important thing to understand here is that this is really the only definition that could possibly make sense! Indeed, it's precisely the definition that generalizes what the sheaf associated to a module is in the affine case, as we just take our sections over the basic affine opens to be the degree $0$ part of the localization of our given module $M(n)$.
Now, with these generalities in mind, how do we think about global sections of $\mathcal{O}_S(d)$? A global section is given by the data of local sections on an open covering that agree on overlaps. According to our definition, we can just think of these local sections as being of the form $\frac{s}{f}$ where $s\in S_{\bullet}$ is homogeneous and $f$ is some homogeneous element of positive degree, such that the difference in the degrees of $s$ and $f$ is $d$. But if these local sections have to agree on all the overlaps, then we can't have any denominators (you should work this out)! So we can precisely identify global sections with homogeneous degree $d$ elements of $S_{\bullet}$.


text:
Q: ERROR on E: EIdSocketError do begin - Delphi
I'm starting in Delphi , and creating a program to download ... In which I realize that when I try to download and type a wrong URL and it can not download ... Generates the error Error # 10060 Socket connection Time out ...
I know that this error is generated when it gets too long trying to make a connection to a URL that does not exist ....
E: EIdHTTPProtocolException

he Raises the number 0 (zero ) Error ... it does not exist in HTTP ...
I'm trying to prevent this error appears , it stops trying to access the page ... but I want the response to this error ... and cause it not to appear ....
I believe it is using: on E: EIdSocketError the begin ...
But the program generates error when I try to use : undeclared undefined EIdSocketError
How am by starting in delphi ... I do not know where I'm going wrong ... how to correct this error :
 undeclared undefined EIdSocketError

[ dcc32 Error] Unit1.pas ( 162 ) : E2003 Undeclared identifier: '
  EIdSocketError '

except
         on E: EIdSocketError do begin

         end ;
         on E: EIdHTTPProtocolException the
             Begin
             / / Handle the error generated
               code_erro : = IdHTTP.ResponseCode ;
             / / code_erro : = E.ErrorCode ;
             end
        end ;

A: EIdSocketError is defined in the IdStack unit.  You need to add that unit to your uses clause.


text:
Q: Manipulating acrofields with pdfbox changes encoding of checkboxes onValue I do some acrofield manipulation for text fields which have parent fields. This works so far, but the form also contains some checkboxes, the will not be changed. But when I store the manipulated pdf to disk and inspect the value of the checkbox, i can see that the value of cb_a.0 has been changed from ÄÖÜ?ß to ?????
My further processing fails because of this unintended change, any idea how to prevent that?

My testcase
@Test
public void changeBoxedFieldsToOne() throws IOException {

    File encodingPdfFile = new File(classLoader.getResource("./prefill/TestFormEncoding.pdf").getFile());
    byte[] encodingPdfByte = Files.readAllBytes(encodingPdfFile.toPath());

    PdfAcrofieldManipulator pdfMani = new PdfAcrofieldManipulator(encodingPdfByte);
    assertTrue(pdfMani.getTextFieldsWithMoreThan2Children().size() > 0);
    pdfMani.changeBoxedFieldsToOne();
    byte[] changedPdf = pdfMani.savePdf();
    Files.write(Paths.get("./build/changeBoxedFieldsToOne.pdf"), changedPdf);

    pdfMani = new PdfAcrofieldManipulator(changedPdf);
    assertTrue(pdfMani.getTextFieldsWithMoreThan2Children().size() == 0);

}

public void changeBoxedFieldsToOne() {
    PDDocumentCatalog docCatalog = pdDocument.getDocumentCatalog();
    PDAcroForm acroForm = docCatalog.getAcroForm();

    List<PDNonTerminalField> textFieldWithMoreThan2Childrens = getTextFieldsWithMoreThan2Children();

    for (PDField field : textFieldWithMoreThan2Childrens) {
            int amountOfChilds = ((PDNonTerminalField) field).getChildren().size();
            String currentFieldName = field.getPartialName();
            LOG.info("merging fields of fieldnam {0} to one field", currentFieldName);

            PDField firstChild = getChildWithPartialName((PDNonTerminalField) field, "0");
            if (firstChild == null ) {
                LOG.debug("found field which has a dot but starts not with 0, skipping this field");
                continue;
            }
            PDField lastChild = getChildWithPartialName((PDNonTerminalField) field, Integer.toString(amountOfChilds - 1));
            PDPage pageWhichContainsField = firstChild.getWidgets().get(0).getPage();

            try {
                removeField(pdDocument, currentFieldName);
            } catch (IOException e) {
                LOG.error("Error while removing field {0}", currentFieldName, e);
            }
            PDField newField = creatNewField(acroForm, field, firstChild, lastChild, pageWhichContainsField);
            acroForm.getFields().add(newField);
            PDAnnotationWidget newFieldWidget = createWidgetForField(newField, pageWhichContainsField, firstChild, lastChild);
            try {
                pageWhichContainsField.getAnnotations().add(newFieldWidget);
            } catch (IOException e) {
                LOG.error("error while adding new field to page");
        }
    }
}

public byte[] savePdf() throws IOException {
    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        //pdDocument.saveIncremental(out);
        pdDocument.save(out);
        pdDocument.close();
        return out.toByteArray();
    }
}

I am using PDFBox 2.0.8
Here is the source PDF:https://ufile.io/gr01f or here https://www.file-upload.net/download-12928052/TestFormEncoding.pdf.html
Here the output: https://ufile.io/k8cr3 or here https://www.file-upload.net/download-12928049/changeBoxedFieldsToOne.pdf.html

A: This indeed is a bug in PDFBox: PDFBox cannot properly handle PDF Name objects containing bytes with values outside the US_ASCII range (in particular outside the range 0..127, and your umlauts are outside).

The first error in PDF Name handling is that PDFBox internally represents them as strings after a mixed UTF-8 / CP-1252 decoding strategy. This is wrong, according to the PDF specification a name object is an atomic symbol uniquely defined by a sequence of any characters (8-bit values) except null (character code 0). [...]
Ordinarily, the bytes making up the name are never treated as text to be presented to a human user or to an application external to a PDF processor. However, occasionally the need arises to treat a name object as text, such as one that represents a font name [...], a colourant name in a Separation or DeviceN colour space, or a structure type [...]
In such situations, the sequence of bytes making up the name object should be interpreted according to UTF-8, a variable-length byte-encoded representation.
Thus, it generally does not make sense to treat a name as anything else than a byte sequence. Only names used in certain contexts should be meaningful as UTF-8 encoded strings.
Furthermore, a mixed UTF-8 / CP-1252 decoding strategy, i.e. one that first tries to decode using UTF-8 and in case of failure tries again with CP-1252, can create the same string representation for different name entities, so this can indeed falsify by making unequal names equal.
This is not the problem in your case, though, the names you used can be interpreted.

The second error is, though, that while serializing the PDF it only properly encodes the characters in the strings representing names which are from US_ASCII, all else are replaced by '?':
public void writePDF(OutputStream output) throws IOException
{
    output.write('/');
    byte[] bytes = getName().getBytes(Charsets.US_ASCII);
    for (byte b : bytes)
    {
        [...]
    }
}

(from org.apache.pdfbox.cos.COSName.writePDF(OutputStream))
This is where your checkbox values (which internally are represented by PDF Name objects) get damaged beyond repair...

A more simple example to show the problem is this:
PDDocument document = new PDDocument();
PDPage page = new PDPage();
document.addPage(page);
document.getDocumentCatalog().getCOSObject().setString(COSName.getPDFName("äöüß"), "äöüß");
document.save(new File(RESULT_FOLDER, "non-ascii-name.pdf"));
document.close();

In the result the catalog with the custom entry looks like this:
1 0 obj
<<
/Type /Catalog
/Version /1.4
/Pages 2 0 R
/#3F#3F#3F#3F <E4F6FCDF>
>>

In the name key all characters are replaced by '?' in hex encoded form (#3F) while in the string value the characters are appropriately encoded.

After a bit of searching I stumbled over an answer on this topic I gave almost two years ago. Back then the PDF Name object bytes were always interpreted as UTF-8 encoded which led to issues in that question.
As a consequence the issue PDFBOX-3347 was created. To resolve it the mixed UTF-8 / CP-1252 decoding strategy was introduced. As expressed above, though, I'm not a friend of that strategy.
In that stack overflow answer I also already discussed the problems related to the use of US_ASCII during PDF serialization but that aspect has not yet been addressed at all.
Another related issue is PDFBOX-3519 but its resolution also was reduced to trying to fix the parsing of PDF Names, ignoring the serialization of it.
Yet another related issue is PDFBOX-2836.


text:
Q: How to get both base64 imageobject and image location/name in phonegap? I am using camera.getPicture and i need the base64 image object and the file name . As per my understanding i can get only one the base 64 image object or the location of the image. How do i get the imageobject and the name of the image file ?

A: You can set Camera.destinationType to FILE_URI to get the location of the image and then use the readAsDataURL function of the FileReader API to get a base64 representation of the image.
http://docs.phonegap.com/en/edge/cordova_file_file.md.html#FileReader
Or you can set the uri to the src of an image tag, not sure what you're trying to do next with your image object.

A: You can get the image path first by setting Camera.destinationType to FILE_URI, then use this plugin to get its base64 encoding


text:
Q: Is putting external jars in the JAVA_HOME/lib/ext directory a bad thing? We have an application which runs in a JRE environment.   The application uses some external jars and we have been putting them in the JAVA_HOME/lib/ext folder.   This has worked for us for years but recently a new programmer joined our team and seems emphatic that this is some how a bad thing to do.   I can't understand why and I'm trying to do some research before I dig further with this developer.   Is there something I'm missing here?

A: Yes - it's a bad thing.  Think about it: the application depends on the JRE and some extra jars.  What if you update the JRE?  Then you have to remember to copy the files into the new JRE. What if you need to set up the application on a new system?  You have to copy the application there, and then also remember to copy the external jars into the JRE on that system.
Both those issues wouldn't be an issue at all if you just package the application properly together with the external jars it needs.  If you don't see this, then maybe it's not an issue at all.  But you should still be grateful for the new guy for sharing his opinion.

A: In addition to the answer by weiji (packaging and upgrades to new JVM versions), there are other risks.
If you are using security manager in any of your applications, the libraries in ext often have a lot more capability by default - they are treated much like the system libraries. You need to be sure that you can trust, in the sense of enforcing security rules, these classes. Did the authors think through what they were exposing correctly? If these classes do not use access control to change the security context then you don't need to worry about this but do you know if they do or do not (e.g. a method that provides access to a file and uses AccessController, does it ensure that the caller has the right file permissions?)
Can all your applications use the exact same version of the library? What happens when you need to update that library (not just the JVM)? Will you break any of your applications? You will need to retest everything. The libraries in ext are loaded by the extension class loader which, due to parent delegation, has higher precedence than the normal (i.e. CLASSPATH) loader so these are guaranteed to be used by your application and there is no way for an individual application to override the library in ext with a different version.
If you want to share the libraries across your applications, why not instead provide a separate folder of common libraries that applications can be individually configured (CLASSPATH) to reference. Then if you have problems with one application and a library, you can switch to a different version of the libraries or just for that one, put it earlier in the CLASSPATH (if that works, you must test this too as there may be other dependency issues). This will allow you to have more individual control for each application. But then, bundling all the required libraries with your application is the safest as you can retest and roll-out library upgrades to individual applications.

A: Also it looks like JEP-220 is ostensibly deprecating this behavior with some arbitrary means to "possibly replace it" with some other behavior.


text:
Q: Ubuntu 16.04 (I think?): I'm very new to Ubuntu and Unity has disappeared Unity has disappeared and every single solution I find ends in errors including or similar to

E: Sub-process usr/bin/dpkg returned an error code (1)

I can't install anything, and unless I'm doing something wrong it seems like I can't even reinstall Ubuntu. I have no idea how to fix the problem now, as I said, every solution I find comes in error.

A: If you can login and you got a empty desktop try right click on the wallpaper, open a terminal or hit ALT+F2. Then restart unity:
unity --replace

If the unity package is broken more information will be show in the terminal. If not then the desktop should load.
Ultimatley you can reinstall the whole unity desktop:
sudo apt purge ubuntu-desktop
sudo apt install ubuntu-desktop

Also you can install other desktop until you fix the unity:
sudo apt install gnome


text:
Q: Laravel Notifications - Queue ONLY on toMail method? I've set up Laravel Notifications and so far so good. My set up is that i'm sending two notifications: "mail" and "database". I plan on having the database notification so that I can display the notification somewhere and allow the user to clear it.
The problem is, when I queue the entire Noitification class, as expected, everything is queued... so this means that even database notifications are queued as well. I would like only the "mail" portion to be queued while the database portion is instantly stored to the database. Is this possible?
Here is the class so far.
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use App\Document;

class ViewedDocument extends Notification implements ShouldQueue
{
    use Queueable;

    protected $document;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Document $document)
    {
        $this->document = $document;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail','database'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->line('The introduction to the notification.')
                    ->action('Notification Action', url('/'))
                    ->line('Thank you for using our application!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            'document_id' => $this->document->id,
            'document_title' => $this->document->title
        ];
    }

}

... And im calling it in a controller somewhere ...
// notification
Notification::send(User::find($document->created_by['user_id']), new ViewedDocument($document));

Thanks


text:
Q: Review queues pulldown - numbers or circles? What now? I think since a few days that the pulldown menu for review queues is now using dots instead of number of entries (grey dot: stuff to review. red dot: much more stuff to review. no dot: nothing to review).
But I am like 99% convinced that yesterday (or so) ... the pulldown did show me numbers again.
Is that feature still under work?
And for the record: it is not documented here (yet)

A: This was mentioned in the following questions on Meta Stack Overflow:

*

*When I look at the review icon, I see red

*The new review icon isn't an improvement
It looks like it's being A/B-tested (AFAIK there's no official confirmation of that, but no denial either), and for the moment only on Stack Overflow (because that's the only site with the new topbar).


text:
Q: Rails - nested content_tag (:ul -> :li -> :div) render the div html tag I'm trying to nest content tags into a custom helper, to create something like this:

    Microposts

O

I have tried this helper:
def user_info(user)
   user_microposts = content_tag(:li,  ("Microposts" + " " + content_tag(:div, user.microposts.count.to_s)))
  content_tag(:ul, user_microposts)
end

but it renders the div html tags in the view:
Microposts

0

I would be pleased to know how to manage this!
Thank you

A: You need to mark the string as HTML-safe, like this:
... "Microposts ".html_safe + content_tag(...


text:
Q: magento migration tool migrate:data errors When I run migrate:data I get some errors, any way to fix this?
[2017-03-06 17:00:38][ERROR]: Foreign key (FK_CATALOG_COMPARE_ITEM_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID) constraint fails. Orphan records id: 0 from `catalog_compare_item`.`customer_id` has no referenced records in `customer_entity`
[2017-03-06 17:00:38][ERROR]: Foreign key (FK_CATALOG_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID) constraint fails. Orphan records id: 903 from `catalog_eav_attribute`.`attribute_id` has no referenced records in `eav_attribute`
[2017-03-06 17:00:38][ERROR]: Foreign key (FK_CAT_PRD_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID) constraint fails. Orphan records id: 903 from `catalog_product_entity_int`.`attribute_id` has no referenced records in `eav_attribute`
[2017-03-06 17:00:38][ERROR]: Foreign key (FK_EAV_ATTRIBUTE_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID) constraint fails. Orphan records id: 19,21 from `eav_attribute`.`entity_type_id` has no referenced records in `eav_entity_type`
[2017-03-06 17:00:38][ERROR]: Foreign key (FK_EAV_ATTR_SET_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID) constraint fails. Orphan records id: 19,21 from `eav_attribute_set`.`entity_type_id` has no referenced records in `eav_entity_type`
[2017-03-06 17:00:38][ERROR]: Foreign key (FK_EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID) constraint fails. Orphan records id: 202,213,706,732,903,2712 from `eav_entity_attribute`.`attribute_id` has no referenced records in `eav_attribute`

and this is another one
[2017-03-06 17:00:42][ERROR]: Source documents are not mapped: paybox_question_number,strikeiron_tax_rate

A: First problem: Foreign key (fk_...) constraint fails. Orphan records id: ...
What does it mean?

*

*You have orphan records in your database. This means that a foreign key is referencing another item which doens't exist anymore. Check some SQL-Tutorials or documentation to read more about it.

How to solve it:

*

*Delete all rows with orphan records or correct all missing data. (https://stackoverflow.com/questions/6445966/elegant-way-to-remove-orphan-rows)

Second problem: Source documents are not mapped
What does it mean?

*

*(I'm not complete sure about this, probably correction needed): You have had different tables that are no more the same, but in a way that the migration tool can't recognize it, as they are customized or extended tables. So in that case you have to check manually whether you want or need to migrate that data aswell or exclude it.

How to solve it:

*

*Check the documentation about mapping, if you want to migrate this data. (http://devdocs.magento.com/guides/v2.0/migration/migration-tool-configure.html)

*You can exclude these like shown in this case study example: (http://oyenetwork.com/articles/data-migration-to-magento2-case-study/)

A: According to the issues section of the data migration tool Github, the official solution is there : https://devdocs.magento.com/guides/v2.1/migration/migration-troubleshooting.html


text:
Q: Limit bandwidth available to VMWare VM in VMWare Fusion Is there a way to limit the bandwidth VMWare Fusion makes available to a particular VM?  I need to do some tests of behavior with limited bandwidth, and I figured limiting the VM image would be the easiest thing to do.  However, I'm not seeing any option for setting the speed in the VM's settings.

A: you may install some 'bandwidth shaping' software on the VM (e.g. NetLimiter on a Windows guest OS)

A: You can do this with Teams in VMware.
However, I think you'll need one of the more expensive products like VMware Workstation to have this functionality available.


text:
Q: Count Facebook post sharing with progress bar I would like to make a bar displaying how many times a post was shared.
I'm a complete newbie about Facebook Debug so I would like to know if it's possible to do it and if I can animate this through JQuery.
Any comment or proposal is appreciated.