Group By 2 columns specifically

Question: This is my query:
SELECT
    SUM(TranAmount * -1) [RecVal],
    ISNULL(SC.CountryName,
        (SELECT tblSysCountry.CountryName
         FROM tblIdcBranchMaster
         INNER JOIN tblSysCountry ON tblIDCBranchMaster.countryID = tblSysCountry.CountryId
         WHERE tblIDCBranchMaster.idcBranchID = TM.idcBranchID)
    ) [Country]
FROM
    tblDebtorTransactionMaster TM
LEFT JOIN
    tblIDCEmployeeMaster EM ON EM.employeeID = TM.employeeWorkedBy
LEFT JOIN
    tblIDCBranchMaster BM ON EM.homeBranch = BM.idcBranchCode
LEFT JOIN
    tblSysCountry SC ON SC.CountryId = BM.countryID
WHERE
    TM.tranTypeID IN (2, 6, 7, 18, 9, 11, 51)
    AND TM.documentDate BETWEEN dbo.default_date_format('**INPUT DATE**')
    AND dbo.default_date_format('**INPUT DATE**')
GROUP BY
    SC.CountryName,TM.idcBranchID

Dates removed for security purposes
The problem is I want to be able to group completely by the second column not just by country name.
Currently I link the country to a branch which is linked to an employee who processed the transaction, but if the transaction was process automatically then I need to check to what branch the account links to (each transaction links to a branch).
The branch that the employee links to CAN DIFFER from the branch that the transaction links to if an employee from a different branch captures that transaction.
When I run the query above my results are as follows: I need to ultimately see how much money was collected for each country (Not the branch)
RecVal      +   Country
80090.42    +   SOUTHAFRICA
181248.10   +   SOUTHAFRICA
140989.16   +   SOUTHAFRICA
21854.01    +   SOUTHAFRICA
53037.25    +   SOUTHAFRICA
84241.62    +   SOUTHAFRICA
49598.07    +   SOUTHAFRICA
200.00      +   SOUTHAFRICA
75559.36    +   SOUTHAFRICA
12.91       +   SOUTHAFRICA
35784.91    +   SOUTHAFRICA
28627.04    +   SOUTHAFRICA
500.00      +   SOUTHAFRICA
22688.04    +   SOUTHAFRICA
38443.02    +   SOUTHAFRICA
34313.16    +   SOUTHAFRICA
62419.27    +   SOUTHAFRICA
50.00       +   SOUTHAFRICA
73598.95    +   SOUTHAFRICA
86741.78    +   SOUTHAFRICA
21553.98    +   SOUTHAFRICA
12.40       +   SOUTHAFRICA
86673.27    +   SOUTHAFRICA
48021.07    +   SOUTHAFRICA
22586.55    +   SOUTHAFRICA
11027.50    +   SOUTHAFRICA
14897.55    +   SOUTHAFRICA
49672.86    +   SOUTHAFRICA
14910.98    +   SOUTHAFRICA
6152.10     +   SOUTHAFRICA
91878.14    +   SOUTHAFRICA
47132.15    +   SOUTHAFRICA
24957.49    +   SOUTHAFRICA
93.25       +   SOUTHAFRICA
54657.67    +   SOUTHAFRICA
71687.30    +   SWAZILAND
740.00      +   SOUTHAFRICA
607419.67   +   NAMIBIA
150.00      +   SOUTHAFRICA
160.49      +   SOUTHAFRICA
522544.70   +   SOUTHAFRICA
300.00      +   SOUTHAFRICA
13207.29    +   SOUTHAFRICA
47090.91    +   SOUTHAFRICA
51591.77    +   SOUTHAFRICA
600.00      +   SOUTHAFRICA
45605.71    +   SOUTHAFRICA
5642.54     +   SOUTHAFRICA
1470.00     +   NAMIBIA
--------------------------------

Answer: You can wrap the code in a CTE (Common Table Expression). You need to start the with with a preceding ; if you have sql codethat exists beforehand. I see you have a lot of South African transactions. Fellow Saffa here.
;WITH Base AS (SELECT SUM(TranAmount * -1) [RecVal],
    ISNULL(SC.CountryName,
    (
        SELECT tblSysCountry.CountryName
        FROM tblIdcBranchMaster
            INNER JOIN tblSysCountry ON tblIDCBranchMaster.countryID =  tblSysCountry.CountryId
        WHERE tblIDCBranchMaster.idcBranchID = TM.idcBranchID
    )
) [Country]
FROM tblDebtorTransactionMaster TM
LEFT JOIN tblIDCEmployeeMaster EM ON EM.employeeID = TM.employeeWorkedBy
LEFT JOIN tblIDCBranchMaster BM ON EM.homeBranch = BM.idcBranchCode
LEFT JOIN tblSysCountry SC ON SC.CountryId = BM.countryID
WHERE TM.tranTypeID IN (2, 6, 7, 18, 9, 11, 51)
AND TM.documentDate BETWEEN dbo.default_date_format('**INPUT DATE**')
AND dbo.default_date_format('**INPUT DATE**')
GROUP BY SC.CountryName,TM.idcBranchID
)

SELECT Sum(RecVal) as SumRecVal,Country FROM Base GROUP BY Country

Comment: Perfect! It worked thanks I just had to sum the value in the Actual select but Thanks. Lol Im glad to see Im not the only Saffa here ...
Comment: Thanks dude for pointing the sum out. I think there are a few of us out here, just not many active on StackOverflow. Trying to get some points, would be cool to build rep. Keep well.

Group By 2 columns specifically


Can I be in character as the Silver Shroud and still complete the optional objective?

Question: I am on the quest "The Silver Shroud".
There is an optional objective

 Save Kent

If I progress in character as The Silver Shroud, make all of the choices as the Silver Shroud would, I am unable to complete the optional objective.
Is it possible to complete the optional objective as the Silver Shroud (in character)?
Answer: The problem that I faced in this quest was:

 Sinjin had a gun to Kent's head and my approach to the scene was from the front. I tried everything I could think of to take down Sinjin with quick strikes with melee weapon, a really powerful sniper rifle but nothing was working. My dialog had already caused Sinjin's henchmen to flee. So all I had to do was take down one guy.

So I needed time to get more shots with a very high damage. And for me Jet did the trick. The 10 second slowdown of time helped there. Secondly I needed to boost my damage, because none of my rifles or pistols were working. Psycho provides a 25% boost to damage.
So with that in mind this is how I finally completed the optional objective.

Have a really good high damage, low firing rate like pistol or rifle.
Have some Jet, Psycho or any time slowing/damage modifying chem.
After the third intimidation prompt as the Silver Shroud jump into your inventory and pop the Jet + Psycho. I popped one Jet and 3 Psychos. Got really close and went into VATS and lined up shots to the head.

Make sure you get close to the platform, so that you get a high VATS rate for the head. VATS modifying/AP boosting/critical hit gear is a bonus for this.
Comment: -1 Please don't do that. Just use a spoiler tag if you must. This answer is less helpful when intentionally obfuscated.
Comment: Guess in my haste to get back to the game, I half-assed the answer. Sorry. Hope the clarification helps.
Answer: Use the Syringer Rifle you find somewhere in the hospital and use the Stun Ammo on him.
Just Hipfire after your third Silver Shroud Intimidation. He'll lie on the floor and is fair game.
Answer: You can also just use the other speech option and tell Sinjin to kill you in front of Kent. Then proceed to kill all of them instead.
Comment: OP wants to know if he can save Kent while staying _in character_.


What's the approppriate term for the window under the mouse cursor?

Question: In an app I'm writing, the user has the choice to apply a given action to either the "focused window", the "topmost window" or the "window that's being pointed by the mouse".
Is there a way to refer to the latter case in adjetive form?
e.g. "pointed window" or "hovered window".
None of these sound right, though.

More info:
The target audience is people who are at least familiar with the concept of "focused/active window". So that they may want to perform an action on a window that's not focused by pointing it with their mouse.
In summary, we have 3 different concepts:

focused/active/foreground window
topmost window
pointed by mouse window

These 3 concepts may correspond to 3 completely different windows at a given time. That's why it's important that my users may choose which one they want.
Comment: Care to share some more context? The phrasing you choose should depend on your audience.
Comment: I think you could just say "another window". The mechanism by which that other window will be selected (pointing, hovering, whatever) isn't relevant at that point.
Answer: Edit: You should give these windows names as early as possible, and always use those names to refer to those windows. Whether the names are "Input Window", "Alert Window", or simply "Window A" and "Window B".
Also consider changing your phrasing to refer to what is inside of the windows, rather than the windows themselves. Without knowing what the workflow is, it's hard to give more advice.
Comment: I think the point is to be able to point to background windows
Comment: @DmitryKudriavtsev, that's exactly the point. You hover your mouse over a window to indicate that's the window you want to operate with, even if that window is not the `focused/active/foreground` window.
Comment: @GetFree That is a hovered element/ window. Are you sure it is the best idea to use focused and hover for two different categories? On mobile, this will be tricky.
Comment: @MadalinaTaina, The concept of `window under mouse` makes sense only on devices with a pointing arrow cursor. On other devices, that concept will not be used at all.


PGN viewer menu is hidden behind the navigation bar

Question: When you click the arrow pointing down on the top right of the PGN viewer, the menu appears in the top left of the screen. However, only a part of it appears:

This is very confusing. What everyone would understand (without a close look) is that "Copy Position" and "Copy Start Position" are the only available options. Now, I have removed the navigation bar (using Chrome dev tools):

A new option appears!
Solution:
For the menu (div.modal.context-menu), change top:10px to any value greater than 50px (top:75px looks good). Here is a screenshot with top:75px applied:
Answer: I tweaked the styling and the positioning of the menu (and the copy/paste modals), so they should show up in a more reasonable location now.
I was aiming for showing both right by the arrow, but for some reason that's not quite happening in production the same way I had it locally. I'll try to carve out some more time to get it in shape, but in the meantime... it should at least be more visible and usable.
Please let me know if you run into any other issues with the controls.
Comment: Thanks a lot for your efforts!


Passing value to modal scope in angular ui-bootstrap

Question: I have a form setup in angular and am using ui-bootstrap for a modal dialog that appears before submission is complete. My site is setup in Sharepoint and uses a context to determine if they are on English or Spanish version of the site and display the proper language content. I want to pass the bool value IsInEnglish to the modal to display the correct
 but I am not finding a solution to pass this value to the scope of the modal.
        $scope.continue = function () { //this is off an ng-click on a button

        var modalInstance = $modal.open({
            templateUrl: '_layouts/Applications/VolunteerApp/modal/myModal.html',
            controller: 'vAppController'
        });

        modalInstance.opened.then(function () {
            $scope.modalIsInEnglish = IsInEnglish;

        });
    };

Answer: Add a resolve to $modal's instantiation object:
    var modalInstance = $modal.open({
        templateUrl: '_layouts/Applications/VolunteerApp/modal/myModal.html',
        controller: 'vAppController',
        resolve: {
          myVar: function() {
            return someVal;
          }
        }
    });

and then pass someVal as an argument of the function that invokes the modal:
 $scope.continue = function (someVal)

To access someVal in the modal controller, pass it in as an argument for the modal controller:
function myModalController($scope, someVal) { // do stuff }

Comment: @Spacemancraig Well, i was in the process of updating your plnkr when something broke and all i get now (even if i create a new plnkr) is an error message about the payload needing to be a string... You had a couple problems 1) `IsInEnglish` was defined in plain ol' Javascript. As such, it is outside of angular's namespace, so the value was undefined, and 2) you weren't passing the `engVar` resolve variable in the modal controllers argument list. Check out my changes and see if they solve your issue.
Comment: I'm off site today working with a dev firm on another project and their wifi went out, fortunately I did see and save the edits you made. I applied that to my solution and that solve my problem!
Comment: So, if I was setting that value to an `ng-show` on my modal how would that look? `ng-show="someVal"`?
Comment: Assign `someVal` to a variable that is accessible from the view. If you are using `$scope`, do something like `$scope.showMyElement = someVal`. Then `someVal` will be accessible to the ngShow directive in the view.

Also note the change in my original response. You'll need to pass any value(s) in the resolves into the modal controller as argument(s).
Comment: If my reply helped, any chance you could accept it as the answer?
Comment: Sorry, I'm having some frustrations with Plnkr as I am not able to save my plunk. I have a stream and hopefully you can take a look. I am having an issue passing the `someVal` to the modal controller, get an error stating there is no provider for that value. http://plnkr.co/edit/?p=streamer&s=dTJODpQQqFC5dzql


Having terrible lag on a certain server

Question: As of today, on a certain server I play on, I lag when I get onto the server. I'm able to break blocks and move, but not able to interact with the world. By this I mean that I won't receive blocks I have broken, I cannot use redstone devices, etc. Nor can I chat (so to speak, anyways). Through dynamap, I was able to figure out that others were able to see my chat, however I was not able to see mine or theirs in-game. Sometimes, minutes later, all the actions I performed (chat, block breaking/placing, world interaction), will all come through at once. This will just happen over and over again until I usually get a  "Read time out" error which is odd, since these errors only last for about 2-3 minutes for me, when they occur. (And this has been happening continuously, all day)
NOTE: This only happens for this specific server. All other servers have been acting generally normal, no issues like this. Even the ones that I have ridiculously high ping with (like 2400ms...) are acting normal.
Later, I checked the ping for the server, and it was generally normal, being at its average 240ms or so. I restarted my computer as well, and it still happened. I ran speedtest.net, as well, and received normal results (4.5MPBS upload, 19ishMBPS download).
Is this a problem with my .minecraft? Should I delete it and start fresh? Or is the just a computer/network problem? All help is appreciated.
Comment: To find your actual ping, open a console window (cmd.exe on Windows) and use the `ping ` command, using the MC server's IP or name. Then tell us the min/avg/max.
Comment: i also usffer that a lot
Comment: I think the server is hosted far away and because of that you have high ping and game can't synchronise with the servers logic... There is nothing you can do about it. This is my opinion.
Comment: @Roberts The ping isn't that high, well for me anyways. A lot of my servers are around the 250ms range, and function perfectly fine, this turned out to be a weird occurrence all the sudden. Plus, with my high ping servers, I usually have different lag problems associated with them, nothing is like this. Anyways, the problem has seemed to fix itself. I got on today and it worked perfectly fine. Perhaps my computer just needed a rest...
Comment: Ping-with-just-one-number is just as average. A real ping number has three parts, with min/avg/max. If 250ms is average and min/max are close to 250ms, you'll get smooth connectivity. If 250ms is average but min is very low and max is very high, you'll get severe lag and disconnects, even though your "ping" seems the same.
Comment: This has only happened once, and I really have no ways to see if any of these tips explained why it happened, considering it fixed itself. Should I close this question, or just leave it with no accepted answer?
Comment: Definitely sounds like server lag.
Answer: There are several things that could be causing this:

Proxys, if you're using a proxy it could delay some information and not others.
Magic Launcher, I have found that having Magic Launcher's console open will stop all incoming connections when it receives a Coloured message. this can be fixed by launching it without the console.
Distance, if the server you play on is physically further away, then it could severly delay information going between you and the server, especially if you have a slow internet connection, to find where the server is located go to http://geoip.flagfox.net/, type the server IP or domain name in the field that looks like this:
Server lag, if the server's TPS(Ticks Per Second) is reduced, then it will start giving up on those with a slower connection. this can be fixed by getting a better internet provider.
Answer: As you have mentioned in the comments, this problem 'fixed itself'. this show you just had a temporarily poor inbound connection, the factors that can cause this are usually out of your control, such as peak traffic in your local area or local transfer point or excessive.
the problem with not being able to see blocks dropping and stuff like that is when the you (the client) breaks the block so they dissapear, then the server has to verify that you broke them and send you (client) the information about what items should be around that area now that you broke the block

Having terrible lag on a certain server


Exception starting filter struts2 - tried adding JAR's, but same result

Question: Here is the error I am getting:
SEVERE: Exception starting filter struts2
java.lang.NoClassDefFoundError: com/opensymphony/xwork2/config/FileManagerProvider
    at org.apache.struts2.dispatcher.Dispatcher.init_FileManager(Dispatcher.java:336)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:465)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:424)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.opensymphony.xwork2.config.FileManagerProvider
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    ... 30 more

List of JARs:
antlr-2.7.6.jar
commons-beanutils-1.8.3.jar
commons-collections-3.2.1.jar
commons-digester-2.1.jar
commons-fileupload-1.3.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
ejb3-persistence-1.0.2.GA.jar
freemarker-2.3.16.jar
hibernate-annotations-3.2.1.ga.jar
hibernate-commons-annotations-3.3.0.ga.jar
hibernate-core-4.2.1.Final.jar
hsqldb-2.0.0.jar
javassist-3.12.1.GA.jar
jta-1.1.jar
log4j-1.2.15.jar
mysql-connector-java-5.1.21.jar
ognl-2.7.3.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.7.5.jar
struts2-core-184.108.40.206.jar
xwork-2.1.3.jar

And my web.xml is like this:
<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

I have tried lot of things after reading on this forum:

Tried different versions of JAR.
Manually deployed WAR into Tomcat.
Placed the servlet-api JAR into the lib folder as well ( although it being present in the server lib).
Read the Tomcat logs, found nothing different. ( Please let me know, I can paste those as well)

But none of them have helped. So, last resort, I am posting it here.
Comment: Use the same version of `xwork-core` jar as the `struts2-core` jar.
Comment: Yep. You can't arbitrarily mix-and-match library versions--that's why we use tools like Maven. I don't understand why you'd randomly add a servlet-api jar to your web app: besides that you *must* not provide your own, what in the error message would lead you to believe anything other than either (a) the referenced class is missing, or (b) one of its dependencies is missing?
Comment: Thank you  Aleksandr M. I matched the struts and xwork and it is working now.
Comment: Dave Newton - I know arbitrarily mixing-match is not the way. But after trying a lot, nothing was working, so I tried it that way too. As far as servlet-api, I did that after reading in one of the posts. Thank you
Answer:
Since you are using Struts 2.3,
FilterDispatcher is deprecated. You MUST use StrutsPrepareAndExecuteFilter (or its little brothers).
From the official documentation

Deprecated. Since Struts 2.1.3, use StrutsPrepareAndExecuteFilter instead or StrutsPrepareFilter and StrutsExecuteFilter if needing using the ActionContextCleanUp filter in addition to this one

change then this

<filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>

to this:

<filter-class>
     org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>

Note that, from 2.5, it would be instead:

<filter-class>
     org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>

Comment: Thanks Andrea. :D I did following changes: 1. Changed the filter-class to StrutsPrepareAndExecuteFilter. 2. Matched the versions of xwork (2.1.6) and struts (126.96.36.199) . stackoverflow is awesome!
Comment: This has now (as of 2.5) changed to org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.  I've just used this tonight on struts2-core-2.5.8.jar.  If it looks the same, the .ng. bit is missing.
Comment: @PaulUszak I knew, but have not updated all the answers yet. I've edited this now, thanks for the comment


Converting PDF doc to image as preserving the PDF quality at image?

Question: I have looked to the site and find convert like programs and used them however I cannot preserve the quality of the PDF file. I have changes the options for better resolutions but this time the size was increased so much. I cannot find the optimal setting for the conversion. Is there any other tool or method to preserve the pdf quality? Or any program to see the specs of the PDF files to define them as argument of the conversion software?
Thanks
Answer: 1) You should be able to adjust the image quality by adding density option to the convert command as in this Nautilus Script which converts the selected PDF file to 300dpi JPG file(s)
convert -density 300 "$1" "${1%\.pdf}.jpg"
2) You can also open a PDF file with GIMP Image Editor (treating each page as a Layer or Image) which seems to use the PDF file settings as default as well as allowing the user to adjust the image quality setting at the beginning. Then you can Export it to any other image format.


How to provide ventilation on NEMA 12 Arcshield enclosure with help of fans?

Question: I have a NEMA 12 enclosure with VFD (Powerflex 753) mounted in it. Also the enclosure should be ArcShielded. But the norms are that if the NEMA 12 enclosure is arc proof, then no fans should be mounted on the door ( to avoid the arc fallout on the operating personnel through fans). So how should I provide the ventilation ? The space factor is 6 S.F. ( = 78 inches ). (Please note:- There are fans made especially for ArcShield, but those cannot be mounted on NEMA 12 enclosure.)
Comment: I'm voting to close this question because it is not about home improvement.
Comment: We have a car parking facility at our commercial outlet and it involves panels ( motor control centres). If this irrelevant forum then please direct my question to relevant one
Comment: Maybe the rules are different where you are but most of my enclosures have vfds and 1 or 2 fans, we did have a large one blow a year or so back melted the plastic lovers and filter media. These are what the mfg installed on our enclosures.
Answer: There are no NEMA 12 fan options for PowerFlex VFDs in the "100ms" version of ArcShield MCCs, but there are in the "Device Limited" version. Device Limited ArcShield MCCs mean the MCC can have a maximum of 1200A bus and the main must be part of the MCC.
If you have an MCC at 1600A or larger, then you are limited as to which VFD options are available to you and there are no options for NEMA 12 vented VFDs, so that limits you to I think 40A (25HP @ 480V) or 34A (20HP) if there is a reactor, which is the largest non-vented VFD in a NEMA 12 package.
What I do if the project needs larger VFDs in NEMA 12 and needs to be Arc Resistant is to split up the MCCs into 1200A or smaller segments so that I can use Device Limited, which allows for vented VFDs in NEMA 12.
But to answer your specific question, you cannot add anything to the front doors of an ArcShield MCC in the field without violating the Arc Resistant certification of it.
Side note: You mentioned "NEMA" so I am assuming you are discussing the 2100 Series NEMA MCCs, not the IEC version 2500 series. Those options may be different for IEC.
Comment: Ofcourse splitting up the MCC into 1200 Device Limited version is possible. But due to space constraints I can't split up the MCC. There is a slot for bottom entry cable which is dugged previously. Any other solution to how sufficiently ventilate the VFD. Yes, my MCC is 2100 Centerline
Comment: If it is over 1200A, you cannot have vented VFDs in it. Period. There is no option.


How can I fix a Groaning/bubbling toilet?

Question: Our toilet "groans" when flushed- it makes a loud noise that does not appear to be correlated with anything I can see. Also, it randomly bubbles and leaves black pulpy residue inside the bowl. Is there an easy fix to this that I am missing?
Answer: Check your upstream vents. Drain cleaner or a drain snake usually does the trick!
If the vents are okay, you may need to call a plumber.
Answer: If you're on a septic system it might need to be cleaned.


Training warhammer skill in dwarf fortress

Question: I saw in DF that the carpenter may craft training weapons for the dwarf sparring. Still, I cant find any training warhammer... Should they train with regular weapons? Are there any training warhammers?
Answer: As of 31.X, training weapons are not needed for training your military -- regular hammers will be fine (and non-deadly!)
The reason the training weapons exist at all is because in 28d, "sparring" consisted of the dwarves in question actually fighting with each other -- and if they used regular weapons, their sparring partners would develop regular injuries. The training weapons were a less-deadly alternative, though even then there were too many instances of dwarves crippling their squadmates.
However, sparring in .31 is decidedly different -- the dwarves "tap" the target instead of actually attacking. It's completely non-lethal training, even with adamantine edged weapons. So there is no training warhammer, nor is their a real need for them anymore.
On the other hand, if you just want a training warhammer for flavor or its own sake, crossbows raise the "hammer" skill and can be made of wood, so they're the next best thing.


Odd failed request in Google Chrome console in AngularJS SPA

Question: I have an AngularJS single page application that sends and retrieves data from a C# Web API service. Both applications are hosted on Amazon Elastic Beanstalk. Periodically I get a failed request in the Google Chrome developer console. The request is to http://singlepageapp.elasticbeanstalk.com/null. It bugs me because I can't work out where it originated from. All Ajax requests in my application come from the same place, and always have the base URI (http://mywebapi.elasticbeanstalk.com/) with 'api/' and the name of the Web API controller appended.The developer console shows the following:
Request URL:http://singlepageapp.elasticbeanstalk.com/null
Request Method:GET
Status Code:404 Not Found

The raw request that causes the error is as follows:
GET /null HTTP/1.1
Host: singlepageapp.elasticbeanstalk.com
Connection: keep-alive
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Accept: */*
Referer: http://singlepageapp.elasticbeanstalk.com/
Accept-Language: en
Range: bytes=0-1244

Chrome list the type as 'media' and the initiator as 'other'. Any ideas would be gratefully received. Huge thanks in advance.
EDIT: I just got the error again and noted that the request was not to my web api, but to the elastic beanstalk single page application. My logic makes no (direct) requests to this URI, all these are initiated by the browser in response to the user clicking a link. In this case the 'Save' button on one 'page' after a successful save runs the following:
$location.path('/next-page');

It is this that triggers the errant request. This doesn't occur though when going to this URI directly via clicking a link in the menu.
Comment: Can you list any of the Angular code that supposedly always hits `host + 'api/' + endpoint` for AJAX requests? Clearly one of those `'api/' + endpoint` calculations returned `null`, which got stringified as `"null"`.
Comment: @AustinMullins Huge thanks for your reply. I just noticed that the request in question is not to my web API, but to the single page application URI. That is, it is being initiated by the browser. I have edited my question to reflect this.
Answer: Ok, found the issue. The page in question allows the user to take a photo using their web cam. When they click the 'Save' button they are taken to another page. However before this occurs the logic does the following:
video.src = null;

where 'video' is the following element in the page:
<video class="cssimageclass" autoplay></video>

Setting the src to null initiated the browser request. Removing this fixed the problem.


Abstract classes and interfaces in C#

Question:
Possible Duplicates:
Interface vs Base class
Interface or abstract class?

Hi All,
I am just thinking about the abstract classes and interfaces, I know how they work technically but i don't understand the real use of abstract classes and interfaces.
I mean why should we use abstract classes when we know that we can't create it's object, we have to anyway extend this class to use it so why don't we put everything in the derived class.
Same is with interfaces, we have to implement the interface so why don't we put all the methods which are defined in the interface in the class in which we implement the interface.
Can someone please clear my doubts with some examples ?
Comment: check out this google video:
http://www.youtube.com/watch?v=4F72VULWFvc
Answer: Links at Stackoverflow

Exact use of Abstract class
Interface or abstract class?
Abstract classes vs Interfaces
Why do both the abstract class and
interface exist in .Net?
differences between an abstract class
and an interface in C#
What's the difference between an
interface and an abstract class?
When to use an interface instead of
an abstract class and vice versa?
Help me understand in a practical
example the usage abstract classes vs
interfaces?

Others

Abstract Class versus Interface
Should I use an abstract class or an
interface?
Abstract base class over interface
Learn This: When to use an Abstract
Class and an Interface
Recommendations for Abstract Classes
vs. Interfaces - MSDN
Working with Abstract classes, Sealed
Classes, and Interfaces in C#
Difference between Abstract class and
Interface in C# (.Net)
Comment: Identification of duplicates belongs in the comments to the questions, along with a close vote as you have the rep for it.
Comment: @Asad: that is the point. *You* identified a duplicate, so *you* should have posted a *comment* (rather than an answer) *and* voted to close. With the power comes the responsibility.
Comment: It got closed probably after several hours. The links were not identified before my post!
Comment: hmm, you are right. will take care next time
Comment: But if someone can glean all the duplicates and organize it so well, than the effort is worth an answer imo.
Answer: Also of note, in C# you can only inherit one class but multiple interfaces. An abstract class is a partial implementation of a class with reusable code for multiple subclasses. An interface is just that, an interface to the object for a specific purpose.
A good example would be objects in a game. If the object is Drawable and Collideable you may have common routines to handle that but no common base class, so you have the class implement IDrawable and ICollidable.
Answer: What do you do when there's more than one derived class sharing the same abstract behavior?
For a good example, consider the Stream class in .NET.
Answer: I've always used abstract classes as a road-map for derived classes. A lot of times I'll have a series of classes that will all be similar and will be able to share functionality but they'll all be dissimilar enough that they need their own class. So the base class is not fully functional and it has a few methods that are designed for that particular class. So by declaring it abstract, you put the functionality in the namespace for general usage, but you are still able to confine its usage to that set of classes.
Interfaces (to me) are nothing more than a blueprint. I've never NEEDED an interface, but when publishing an extendable API or making a framework within an organization, interfaces are good blueprints for how extendable classes should behave. It helps define a standard within the namespace for the functionality that is expected of a particular set of objects.
I would say neither is specifically necessary, but they are tremendously helpful in segregating your code and defining how it should be used and/or extended.
Answer: In my work, I use interfaces when I want to create plugins for specific types of components that need to be treated identically by the application, but their behavior is component-specific.  In other cases, I've wanted some common behavior amongst derived classes, so I use an abstract class to define the methods that the derived classes need to implement, but then I only need to implement component-specific behaviors when necessary.
Answer: Interface's mean that you can define methods which a class should implement without actually implementing them. An example of why this would be useful is to allow developers to write plugins for your application.
It must be clear which methods can be called on this plugin (such as load, unload execute for example) but how these methods are implemented depends on the plugin itself. At the time of designing the interface, you may have no idea what the code for those methods will actually be.
As far as abstract classes go, whilst similiar, are normally used as basis for similar classes. In the case of the Stream base class, it has a method for reading a block of bytes which it may do by repeatedly calling a method to call a single byte. If you have several classes which derive from this base class, you won't have to repeat this code in each of them; so abstract classes are often used to reduce code duplication
Answer: In simple, you use abstract class to model inheritance like Car inherit from Vehicle. Typically you will inherit some of the implementation or class definition too.
Interface is used to model types that may have similar subset of behaviour but not neccessary is-a relationship. Example will be I can have an interface IValidate which has a method Validate and this can be implemented by Car, Student, Account or etc to validate for the data they hold. These types cant/shouldnt really be modeled as is-a relationship
Interface is also used extensively too in language that dont support multiple inheritance as a workaround. Other uses include dependency separation, and exposing services in COM and WCF.

Abstract classes and interfaces in C#


return value calculated from javascript FileReader onload event

Question: I have this function:
function doStuff(range, file) {
    var fr = new FileReader();
    var hash = '';
    fr.onload = function (e) {
        var out = "stuff happens here";
        hash = asmCrypto.SHA256.hex(out);
        return hash;
    };
    fr.readAsArrayBuffer(file);
    return hash;
}

Right now, the function completes before the onload event is finished, so doStuff always returns "".  I think a callback is what I need, but I'm new to javascript, and I can't wrap my mind around how to implement it in this case.
Answer: File reading using File Reader is asynchronous operation. Place your logic inside the onload function of file reader.
function doStuff(range, file) {
    var fr = new FileReader();
    fr.onload = function (e) {
        var out = "stuff happens here";
        hash = asmCrypto.SHA256.hex(out);
        /* Place your logic here */
    };
    fr.readAsArrayBuffer(file);
}

You can even pass a callback function that will be executed once the file is read.
function doStuff(range, file, callback) {
    var fr = new FileReader();
    fr.onload = function (e) {
        var out = "stuff happens here";
        hash = asmCrypto.SHA256.hex(out);
        /* Assuming callback is function */
        callback(hash);
    };
    fr.readAsArrayBuffer(file);
}

Comment: No idea. There seems to be nothing wrong with this answer.
Comment: @Phylogenesis Even same here. I don't know why ppl do down voting simply :(
Comment: It can also be noted that there is a [synchronous `FileReader` API](https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync#readAsArrayBuffer()) available in Firefox only (and even then only in a web worker context).


Is Store Unit Also a Load Unit on an Intel processor?

Question: Most Intel Processors have 2 load units and 1 store unit.
Is store unit also a load unit? Are the instructions / micro-ops to modify existing memory data like inc [memory] just utilize 1 store unit and the remaining 2 load units are available for other micro-ops/instructions that can be executed in the same cycles, or instructions like inc take 1 load unit (to load existing value) plus 1 store unit (to store new value) so we have just one load unit left available? So, to keep 2 load units available, we can just purely store instructions like mov, push, etc?
Comment: The `inc` instruction is decoded, on Skylake, as four uops: one must go in either port 0,1,5 or 6 (this is the addition operation), one must go in port 4 (this is the store operation) and two in either port 2,3 or 7 (this are the AGU and load operations). (Source Fog's tables). So I believe RMW instructions use both load and store units as the intuition suggested.
Comment: I think this might depend on the micro-architecture. Though, I am not sure.
Answer: A memory read-modify-write instruction is at least 4 unfused-domain uops on an Intel P6-family or Sandybridge-family.  (It could be more if it needs more than 1 ALU uop)
There's no requirement that any of them execute in the same cycle, which the wording of your question seems to be assuming.  Allowing out-of-order execution to do other work during the load-use latency is one of the major benefits of decoding x86 instructions into internal RISC-like uops.
You can see more details in Agner Fog's instruction tables.  Consult his microarchitecture pdf to learn more about what that means.  For anything I don't explain in this answer, you can find details in there.
For inc dword [rdi] on Intel Haswell, these are the uops (and ports they can run on):

load dword [rdi] (p2/p3), depends on rdi
ALU inc (p0/p1/p5/p6), dependent on data from the load
store-address [rdi]  (p2/p3/p7), depends on rdi (but not the loaded data, I think)
store-data (p4) copies the ALU result into the store buffer, depends on the ALU and store-address uops, I think.

Note that only simple addressing modes ([reg] or [reg + constant]) can use the AGU on port7, but they can still be sent to p2 or p3 and steal load throughput.  Other store addressing modes can only use p2/3.  Load uops go to p2 or p3, and use AGU but also the load-data part of the execution unit.
This imperfect scheduling can and does impact sustained L1D bandwidth:  Intel's optimization manual suggests that although the peak L1D bandwidth in Skylake-S is 64B read and 32B written in a single cycle, the sustained bandwidth is at best ~81B per cycle.  (Table 2-4. Cache Parameters of the Skylake Microarchitecture on page 36)
inc [mem] definitely has to run a load uop.  See Can num++ be atomic for 'int num'? for more details of how read-modify-write operations work (with/without a lock prefix).  The CPU can't just send an "increment" command to DRAM or cache and have the operation happen "in memory".

Counting uops vs. ports makes more sense for throughput in a loop, or a long sequence of code.  You can't know which uops will execute in the same cycle as each other, unless they were both waiting for the same input to become ready.  Then you can predict that the oldest uop will go first if there aren't enough execution ports for the uops to run in parallel (this is called a resource conflict).  So it may be better to put instructions on the critical path first, to reduce latency from resource conflicts.
Execution-port bottlenecks on a specific port are only one of the three common uop-throughput.  The other two are:

Latency / dependency chains that limit available ILP
The front-end limit of 4 fused-domain uops per clock, rather than unfused-domain pressure on any specific port.  (Or 5 on Ryzen, 6 when running multi-uop instructions).

So, other than cache misses and branch mispredicts, the impact of a sequence of instructions on surrounding independent work can be roughly characterized by its latency, fused-domain uop count, and uops for each port.

To save front-end decode and issue bandwidth, some of these uops can micro-fuse together.  (Or AMD CPUs never did split them up in the first place, until they get to the execution units).  See also Micro fusion and addressing modes for more about micro-fusion.  (I have an unfinished update for that answer which adds a stand-alone description of micro-fusion to put everything in one place, since Agner Fog's guide omits un-lamination and Intel's optimization manual doesn't mention that HSW and later don't always un-laminate in cases where SnB did.)
inc dword [rsi] can only fuse the store-address + store-data uops together on Sandybridge-family, so it decodes to 3 fused-domain uops.
add dword [rsi], 1 can fuse the load with an ALU add uop, so it's only 2 total fused-domain uops for the issue stage to read from the IDQ and add to the ROB.  It still expands to 4 unfused-domain uops to be assigned to ports and added to the scheduler (aka Reservation Station).  (Yes, uops are assigned to ports at issue time in Intel CPUs).
Note that add sets flags different from inc, so they can't decode to exactly the same kind of internal uop.  Presumably Intel decided it was worth it to let add uops fuse loads, because instructions like add eax, [rsi] are common.  But inc + load fusion could only happen as part of inc [mem].


Closing a question as a duplicate of another - when you've answered the duplicate question

Question: I just closed https://drupal.stackexchange.com/questions/51053/global-redirect-and-www-example-com-node as a dupe of Disable node summary page on /node path, and then realised afterwards I'd answered the duplicate question myself.
It strikes me that this might be seen as a conflict of interests.
In the spirit of community involvement, what would the community like mods to do in this situation? Proceed to close as normal, or just flag the question for investigation by another mod?
Comment: Hey masters what is CW ? :)
Comment: You can always mark your answer as CW, and therefore don't get any rep.
Comment: Totally forgot about CW, good point
Comment: @MPD Making an answer CW just because closing a duplicate question doesn't make sense. Closing a duplicate question is better than answering it with a CW answer.
Comment: @kiamlaluno I'm pretty sure he meant to mark the existing answer as CW so it doesn't get any _more_ rep, not to answer the duplicate question with a CW post
Comment: I understood that, but it doesn't make sense. Voting to close a question as duplicate, and gaining reputation from the answer given to the original question are two distinct things.
Comment: @nicksmac CW stands for [Community Wiki](http://meta.stackexchange.com/questions/11740/what-are-community-wiki-posts)
Answer: I don't see a conflict of interest, in this case.
As you already answered the other question, you could have answered the new question, and gained reputation from up-votes. Closing the question as duplicate, and redirecting the users to the question you answered would not probably give you more up-votes than answering the new question. It is quite the opposite: With two answers you have more chances to get up-votes.
Deleting an answer given for a question you answered could be seen more probably as conflict of interest, as it could be interpreted as a way to remove an answer that could get up-votes instead of yours.
Comment: That makes a lot of sense :) I'll let the question sit for a while before I accept this in case anyone else wants to have some input and might be put off by the answer being accepted
Answer: For the part of the question of how this might be seen by an average user, as a fairly average user myself, I'd simply think "Clive knew that this question had already been asked because he remembered answering a question like it". It would seem perfectly normal.
Just my point of view naturally, but it seems perfectly natural that people will remember most clearly those questions that they themselves have answered, and therefore that they will be the people most likely to flag up dupes of those questions.
In fact, if the people who had invested time and effort in old questions refrained from flagging up dupes, we'd be reliant on a) people with exceptional memories for questions they'd seen but not interacted with, b) on StackExchange's not-so-reliable search, or c) on google which (hopefully) the asker had already tried. All these are less reliable than people thinking, "That sounds like that question I answered a while ago".


Layout Preview is Blank, App Runs Fine

Question: Layout Preview is Blank, App Runs Fine.
I see my buttons when I run my app on a device, but the preview layout in Android Studio is blank.
I tried:
-changing the API level.
-restarting Android Studio.
-changing the theme.
-force refreshing layout.
-closing and re-opening activity_main.xml
-switching from design to text and back again
-cleaning the project, then building again
I get can get a loading circle in the corner of layout, but my buttons and textviews do not appear in the layout preview.
Any suggestions?
Is this just an issue of computer performance?
Here is my screen
Comment: Possible duplicate of [this](https://stackoverflow.com/questions/51566732/ui-editer-not-showing-anything-when-i-drag-on-dop-items-on-it-but-the-code-gets) and [this](https://stackoverflow.com/questions/51471760/drag-drop-components-are-not-visible-in-preview-in-android-studio/). This seems to be a recent bug...
Answer: Chenge build.gradle dependencies from
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'

into
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
replace all the dependencies contains 28.0.0-alpha3 into 28.0.0-alpha1.
And then do a gradle sync.
The latest support dependency is not view friendly yet!
Comment: You can post the `build.gradle` if the problem exists.
Comment: This fixed the problem. Thank you very much!

Layout Preview is Blank, App Runs Fine


The difference between Free Software and Open Source Software

Question: For quite a while, I thought that Free Software was Open Source Software.  I've found out that this view is incorrect, and that Open Source Software is not necessarily Free Software.  I honestly can't see any differences.
What am I missing here?  What are the distinguishing traits of both parties?
Comment: This article should help: [http://www.gnu.org/philosophy/free-software-for-freedom.html][1] [1]:http://www.gnu.org/philosophy/free-software-for-freedom.html
Comment: counter-example to their equality: recall to seen code distributed openly but under such a license that *disallowed* any and all modifications. you could read all the code so it was 'open' in a way but you couldn't legally do *anything* with it unless you subcontracted. arguably it was far from what most people look for with 'open' stuff. (lost the example unfortunately, well I think it's out there somewhere.)
Comment: I recommend to visit [Why Open Source misses the point of Free Software](https://www.gnu.org/philosophy/open-source-misses-the-point.html) and [Why "Free Software" is better than "Open Source"](https://www.gnu.org/philosophy/free-software-for-freedom.html)
Comment: I asked a question similar to this that might help as well:
http://stackoverflow.com/questions/276629/difference-between-free-as-in-beer-vs-free-as-in-speech-with-regards-to-software
Answer: Both are basically the same, except the free software movement puts more emphasis on the freedom to modify and redistribute the code. For example, GNU GPL would be more "free" than MIT licence, because MIT license does not enforce copyleft and thus someone can develop closed-source software based on the code.
See also Wikipedia chapter about this, which mentions Microsoft shared source inititive, that can provide you with very unfree source code of their applications.
Answer:
Open source is a development methodology; free software is a social
  movement.

- Richard Stallman
Answer: The GNU project answers this question directly:
http://www.gnu.org/philosophy/free-software-for-freedom.html
The essential difference, slightly oversimplified, is that Free Software generally requires that, if you modify and/or incorporate it into another body of work, the entire result must also be distributed as Free Software, and you are forbidden to further restrict the ability of any "downstream" users from modifying, using, or redistributing the software with the same rights that were given to you.

Disclaimer:  Dammit, Jim, I'm a developer, not a lawyer.  Don't construe any terms or comments as "legal advice."
Comment: *Copyleft* licenses require that, but they are only a subset of free software licenses.  The only copyleft licenses I know of are also open-source.
Comment: I guess this was downvoted because someone already had the same answer?
Answer: Open source definition:
http://opensource.org/docs/osd
Free software defintion:
http://www.gnu.org/philosophy/free-sw.html
Both are talking about free-as-in-speech. FSF is "more free" in that for software to meet the FSF standards, it must afford more freedoms to its users. The OSI standards are looser, "free" software is "open" but the reverse isn't necessarily true - It turns out even this isn't always true.
They are functionally the same in the vast majority of cases. It's a philosophical difference - FSF wants intellectual freedom, OSI wants practical freedom to (re)use and adapt software.
Answer: It is pretty simple to understand.
Free source in the sense: Which is free with free laws applicable once you modify it also should also be shared to world with same laws! And its code if any can also be all of us!
Open source in the sense: We can see the actual application for our daily usage, but cannot use it as it is ours means that we cannot modify its code since it is copyrighted to the distributor!
For more info: "Difference between free and open source"
Answer: Freeware software is just small software which are free but their codes are not accessible.It can be downloaded ,used ,copied without restrictions.
Shareware software are just a demo version of the full software developed by small software company and the modification and other usability lies with the development group.Here end user dependencies is more.
Open source  software are just software developed often by large vendors which are re distribuable ,used and modifiable with out any restrictions.Here codes of the software are fully accessed by the user for future modification and making of large software.
Comment: OP was asking about difference between Free Software and Open Source Software not Freeware, Shareware, and Open source.
Answer: Free means the user has freedom to run,copy, study,distribute,change and improve the software. And the open source is different to that.


Grav CMS possibilities

Question: I just started fiddling with grav and reading their documentation, but I have some questions about what it allows you to do.
In each post, in my markdown file, can I set some yaml or twig variables that link e.g. folder with images, and in template I check if this variable was set and output the Images, and if not I do nothing?
In Wordpress it's quite easy, but I wanted to experiment with something a bit smaller, faster and nicer to write in.
Answer: As it turns out, after some time reading grav documentation, I found the answer to my question about creating custom fields, and default variables. It's all described in forms section of grav documentation. (The naming is a bit misleading)
And you can read about twig variables and twig in general, in sections twig filters & functions, and theme variables.
Twig documentation is really useful as well.
Comment: You should accept your own answer so this doesn't show up as unresolved. :)

Grav CMS possibilities


Splitting an Access database into a front and back-end

Question: Okay so I split my access database, and now I have a backend:

If I started a brand new table, a brand new query, and a brand form for a different purpose within the db_be.mdb would it appear in the connect "front end" db as I saved it in the backend, or do I have to import it up?

If I do have to import the above, the how do I make the table to stay in the back and just linked to the front end...with "link table"?
at this point if I create an MDE, will there still be a total of three (back end, what is now the front end, and eventually an MDE)??
thanks guys
Answer: Normally, the whole point of a FE/BE database is to have only tables in the BE and everything else in the FE.  You would create the table in the BE, then open your FE and link the table.  You can use the Link manager (Tools/Database Utilities/Linked Table Manager) or directly (File/Get External Data/Link Tables) Then you would build your forms/queries in the FE.
When you create an MDE it will be a third, separate file, as you mention.
Comment: @David: good point - you can only use the Linked Table Manager to update existing links - my bad!
Comment: @dsteele: please explain how you create a link to a new table with the Linked Table Manager.
Answer: To put it succinctly:

Add any new tables to the back-end database
Link the tables to the front-end
database using "Link table" command
(preferrably with a UNC not a mapped
table)
If you make an MDE file, it replaces
the front end database. You need to
keep the old front end database in
case you want to make changes (which
requires recreating the MDE).
Think of the Front-end database as the source code and the MDE as the "Compiled" version.
Comment: ahhh that is my kind of list! thanks! good for rookies such as me! also i did not realize that about the MDE. thanks man!
Answer: You should only be putting tables in your backend database. Your queries and forms you already created should be in the frontend. You can go to your frontend and import them in so you don't have to recreate them, but then you should go back and delete them from your backend.
When you split your database, did you link go to the frontend and link the tables from the backend? If you didn't, you need to do that. If you used the built-in Database Splitter from the Tools menu, this is already done. Otherwise, you need to go to your frontend and link to the tables in the backend. You can do this by opening your frontend and right clicking in the tables area and choosing Link Tables. This is only for tables though, you can't link to your queries/forms/etc.
Hmph...slow typing and answering while distracted at work...dsteele's answer is right on as well.
Comment: I put a small startup form in the BE MDB telling uses to go away and don't touch anything.
Comment: yeah i used the database splitter. guess these answer were just common sense about linking the tables and all. just wanted to make sure that i did not miss something since this is the first time i have done this. thanks very much for the help!
Comment: Setting the startup options of the back end to hide the database window is usually sufficient, I think.


How should the [Big Buy Now Button] in the right gutter be linked?

Question: I'm redisigning my website and would like to know how the "Big Buy Now Button" in the right gutter should be linked. This button will be available on every page of the site.
I sell two software products and each product has two purchase options:
Product A (Download Only) [sales=85%]
Product A (Download & CDROM) [sales=14%]
Product B (1 User Download) [sales=1%]
Product B (10 User Download) [sales=0%]
I do not have an add to cart situation, it's a single purchase type process.
My current site does not have a big "Buy Now" button on the home page but my new site will have this button in the top right gutter of every page.
I intend to have a buynow page on my new website that that lists out my products and prices with separate buy now links for each product. These links goto the my 3rd party payment processor page. (This is how my current site works). I plan on having the buy now section of the top navigation link to this page, as well as any links from content copy elsewhere in my site.
Here is the basic layout:

+-------------------------------------------------------------------------------------+
| LOGO                                                                                |
|                                                                                |
+-------------------------------------------------------------------------------------+
| Navigation                                                                          |
+----------------------------------------------------------+--------------------------+
|                                                          | [  BIG BUY NOW BUTTON  ] |
| Main Content Section                                     |                          |
|         |                                                |   Right Gutter Content   |
|         |                                                |            |             |
|         |                                                |            |             |
|         |                                                |            |             |
|         |                                                |            |             |
|         V                                                |            V             |

So, I'd like to know your thoughts on linking the "Big Buy Now Button" directly to the payment process page for Product A (Download Only). This product generates approximately 85% of my sales.
The alternative is to link the "Big Buy Now Button" to the buy now page on my site and have the visitor make another "decision" and "another click".
Comment: How much control do you have over the payment page? Can you customize the layout or add links? Can you customize the payment form so the product is selected at the top via radio buttons?
Comment: No, not to that extent. The payment page expects a unique ProductId.
Answer: Are you suggesting to link the Buy Now button to the payment page for the download-only version of Product A, regardless of the product/version being described by the rest of the content on the page?  Because that doesn't feel right to me.  If I'm looking at the single-license version of Product B, I'd expect the Buy Now button to allow me to purchase that product.
As far as having your button and your nav item link to different pages, I think that's acceptable.  The standalone button is part of the page content and relates to that content; items in the nav bar, assuming they're present and identical across all site pages, generally are not and do not.
Comment: You make a good point in paragraph one, thank you.
Answer: Our company is re-designing our site right now and has encountered a scenario similar to yours. We have two main products, and one of them generates a good majority of our revenue, like with you. In our case, and maybe yours too, both our products do essentially the same thing but deliver different value to the customers and are accessed/utilized differently.
When funneling traffic into a conversion (a sale, for example), you'll want to provide them with enough information to be comfortable but not enough to be distracted. To answer our scenario, our new site will focus on the one area of expertise we specialize in, but the big "Buy Now" action buttons take them to a page to start a free trial of our more popular product right away.
In your case, I think as long as customers know what they're doing, that button should directly take them to a checkout/download page or a page to start a trial of your most popular product.
So fundamentally, the purpose of your site is probably to market and sell your products. Period. On the front face, it probably has little-to-no functionality or behavior, and so its purpose is focused on selling the user to that product. Once your site has accomplished that task and the visitor is interested enough, that button is there and ready to step in and finish the conversion. If the site is well-designed, the user will clearly know sooner than later what that button ultimately does for them.
Answer: A frictionless process to purchase your product is always better (take as an example the '1-click buy' option from Amazon).
So I'd advice to give the user the option to purchase right-on with a pretty simple and apparent purchase form when clicking on the "Big Buy Now Button".
Then also keep a less noticeable option for the other products in the same page, in case the user is unsure and still wants to see other options before purchasing, in which case he will make the effort of fishing (looking around) a bit on the same page and will notice the other options.


Swagger Error - description: "Not a valid parameter definition"

Question: I am trying to define a simple swagger definition for a rest api. I am getting error on all my parameter section.
I am getting following swagger definition error in the swagger editor, I am not getting any clue what i wrong. please advise.
Swagger definition:
paths:
'/customer/{customerId}/accountlist':
get:
  responses:
    '200':
      description: ''
  parameters:
    - name: customerId
      in: path
      allowMultiple: false
      required: true
      type: string
  x-auth-type: None
  x-throttling-tier: Unlimited
  produces:
    - application/json
  x-scope: InternalUse
  swagger: '2.0'
  info:
  title: Sample
  description: API for Sample

Swagger Error:
Swagger Error
Not a valid parameter definition
Jump to line 7
Details
Object
code:  "ONE_OF_MISSING"
params: Array [0]
message:  "Not a valid parameter definition"
path: Array [5]
0:  "paths"
1:  "/customer/{customerId}/accountlist"
2:  "get"
3:  "parameters"
4:  "0"
schemaId:  "http://swagger.io/v2/schema.json#"
inner: Array [2]
0: Object
code:  "ONE_OF_MISSING"
params: Array [0]
message:  "Data does not match any schemas from 'oneOf'"
path: Array [5]
0:  "paths"
1:  "/customer/{customerId}/accountlist"
2:  "get"
3:  "parameters"
4:  "0"
inner: Array [2]
0: Object
code:  "OBJECT_MISSING_REQUIRED_PROPERTY"
params: Array [1]
0:  "schema"
message:  "Missing required property: schema"
path: Array [0]
1: Object
code:  "ONE_OF_MISSING"
params: Array [0]
message:  "Data does not match any schemas from 'oneOf'"
path: Array [0]
inner: Array [4]
1: Object
code:  "OBJECT_MISSING_REQUIRED_PROPERTY"
params: Array [1]
0:  "$ref"
message:  "Missing required property: $ref"
path: Array [5]
0:  "paths"
1:  "/customer/{customerId}/accountlist"
2:  "get"
3:  "parameters"
4:  "0"
level: 900
type:  "Swagger Error"
description:  "Not a valid parameter definition"
lineNumber: 7

Comment: Please include the Swagger / OpenAPI definition in your question preferably in YAML format.
Comment: Added sample swagger definition as part of question.
Answer: I rewrote your OpenAPI spec.  This version is valid:
swagger: '2.0'

info:
  title: Sample
  version: 1.0.0
  description: API for Sample

paths:
  '/customer/{customerId}/accountlist':
    get:
      responses:
        '200':
          description: ''
      parameters:
        - name: customerId
          in: path
          required: true
          type: string
      x-auth-type: None
      x-throttling-tier: Unlimited
      produces:
        - application/json
      x-scope: InternalUse

Some comments about your original version:

The indenting was bad.  For example the get: line needs to be indented from     the preceding line.  But perhaps that was just a copy & paste issue.
The info object requires a version property.
The customerId parameter included an allowMultiple property.  I was seeing an error until I removed that.


Let S = {${a_1, a_2, a_3, ... a_n}$} be a finite nonempty set of real numbers a. prove bounded b. show lub and glb are elements of S

Question: Question:
Let S = {${a_1, a_2, a_3, ... a_n}$} be a finite nonempty set of real numbers.
(a) show that S is bounded
(b) Show that lub S and glb S are elements of S

for (a) I see an attempt to answer it was made here: Prove that a finite non empty set of real numbers in bounded .
But the logic is escaping me. Why is M necessarily larger than $a_i$ in the posted example?
(b) I don't know where to begin for this one... I know that if S is bounded then there must be a lub and glb. But why would they necessarily be elements of S? I didn't think a lub or glb had to be an element in a set? Am I misunderstanding?
Answer: Let $$M=max \{|a_1|,|a_2|,...,|a_n|\}$$
We have $$-M\le a_i\le M, i =1,2,...,n$$
That is $S$ is bounded.
The minimum element of $S$ is a lower bound of $S$ and it is the greatest lower bound because if $x$ is greater than the minimum then $x$ is not a lower bound due to the fact that an element of the set namely the minimum is less than that.
Similar argument works for the maximum being the least upper bound.
Answer: For part (a), note that for each $i$, $a_i\leq|a_i|$. Also, adding more positive numbers to $|a_i|$ simply makes the number greater. So we get that for each $i$, $a_i\leq|a_i|\leq|a_1|+\cdots+|a_i|+\cdots+|a_n|$. Hence, the set is bounded.
For part (b), note that if a set contains its maximum, then the least upper bound of that set is its maximum. To prove this, let $S$ be a set bounded above that contains its maximum. Then we know it has a supremum $\sup S$, which satisfies the properties that $\sup S$ is an upper bound for $S$, and that any upper bound of $S$ is greater than or equal to $\sup S$. Now note that the maximum of the set $S$ is an upper bound for $S$, since any element of $S$ is less than or equal to the maximum of the set $S$. What can you conclude?


Replace FS5/FS2 starter with S10?

Question: for a jukebox restoration project (changing T12 lamps to T8 by replacing lamp + ballast, the juke uses one ballast and starter per lamp), I am looking for the correct starter of the TL lamp.
The juke states that it uses FS5 and FS2 starters, the lamps are currently F20T12 and F4T5.
Would I be correct in assuming that these both can be replaced with the newer S10 starter by philips ?
https://www.amazon.de/dp/B00BFT1RC0/ref=zg_bs_10388864031_1?_encoding=UTF8&psc=1&refRID=CZDKH5B6TX3JA17JQYEM
Comment: In the U.S. old mag ballasts were outlawed in 2002 or 2004 I don't remember as it was delayed several times. Since then all ballasts are electronic and no longer need a starter. Since you are updating you might consider a frosted T8 led instead of the fluorescent. But it would be obvious a change as most led tubes  only have 120 deg beam angle.
Answer: The starter is part of the ballast
So it goes with the ballast.
Changing from T12 to T8 is a good thing to do.  You have to change the ballast.
T8 ballasts are almost universally electronic ballasts, do not use starters, and use one of two wiring schemes.
Old-style ballasts that use starters use quite a different wiring scheme.
Your new ballast includes a wiring diagram, either on the label or its instructions/data sheet.  You will need to convert to this new wiring scheme.  It will not involve starters.  So there is no reason to be shopping for starters, unless (amazingly) your T8 ballast requires one, in which case you'll need to use the starter it proscribes.
Choices of ballast type
Since a starter based lamp does use preheats, that means your lampholders will be 2-wire (non-shorting).  That means you can use any modern T8 ballast (which matches your bulbs): instant-start, rapid-start or programmed-start.

Instant-start ballasts don't use the preheaters, and strike the arc with sheer brute force: a big voltage spike. This is hard on the tube, and will necessitate more frequent tube changes. (that's relevant if the tube is difficult to change).
Rapid-start ballasts do the same thing starters do; they use the pre-heater filaments before striking the arc, to ease wear and tear on the tubes.
Programmed-start ballasts preheat intelligently, actively monitoring tube conditions until the ideal arc strike. These are far easiest on the tube; the tubes can even outlast LEDs! However, this patient preheating can annoy; for instance at -20C they can take 4-5 seconds to start.

Keep in mind T8 ballasts won't feel traditional; they won't flicker at 100Hz, won't flash on and off at times, and won't perform horribly in the cold.  Also, the T8 tubes will have good clean >80 CRI light.
Comment: I have installed these from robertson already, in combination with the current old starters and older tl bulbs. I've been trying to find a mini T5 bulb in led to go full led but they simply don't exist (yet). The diagram states they're electro magnetic starters. https://docs.google.com/viewerng/viewer?url=https://s3.amazonaws.com/rww-w2m/CC1420.pdf
Comment: @user3263070 if you found this answer helpful, please click the check mark so others know that it's been resolved. That helps make the system work better for everyone.

Replace FS5/FS2 starter with S10?


Maintaining a fork with patches in master

Question: I want to maintain a fork with custom functionality added on top of the original code. It is not a contribution to the project itself and won't be merged upstream.
What I want to achieve:

The GitHub page of the fork should point to the patched version of the project instead of the original one.
I should be able to easily merge new upstream code while preserving a separate history for my own commits.

My current plan is to have the upstream/master branch in the fork repository as vendor, from which my own master will be branched. Whenever there is a stable release upstream I can pull & push it into the vendor branch and than rebase my master.
Questions:

Is there an easier or cleaner way to achieve the same results?
Should I fork via GitHub web-interface and then move master, or should I create the repository locally as described in this answer?
Comment: This seems like a perfectly reasonable workflow. Forking via the GitHub web interface is nice because it provides a pointer to the original project.
Answer: A fork is just a more formal way to link those two GitHub repo.
You don't even need to name upstream/master as "vendor": you can directly rebase your own master branch on top of that remote branch.
git fetch upstream
git checkout master
git rebase upstream/master

Comment: That's an interesting approach. I guess I should've paid more attention to the git-rebase manpages. Thanks!
Comment: Is there any approach that allows keeping refs to older versions as tags/branches? (eg: changes applied on an older upstream, for rolling back)
Comment: @Edi you can make a tag first, before the rebase: that will keep the previous state referenced.


Ambiguous call of method

Question: I have the following code
class Program
{
    static void Main()
    {
        A a = new A();
        a.M(null);
    }
}

class A
{
    public void M(int? i)
    { }

    public void M(string s)
    { }
}

And I have an error, because the call is ambiguous. I need to change the call of M method without adding any lines to Main method and accessing class A so that it became correct. Could someone please tell me how to do this?
Comment: Define correct ? which method should be called ?
Comment: which method you want to invoke
Answer: You can use explicit cast:
A a = new A();
a.M((string)null);

or
a.M((int?)null);

to help the compiler of picking the right overload. Note that C# compiler can't determine what method overload to call based on null literal.
For advanced topic consider Eric's article What is the type of the null literal?
edit:
since your argument names are different, you can use named arguments, which are avaliable since C# 4.0:
a.M(i : null);

or
a.M(s : null);

Answer: You can use a cast, or the default keyword, or for int?, new int?() (which, due to how Nullable types work, is also the same as null). You could also use named parameters to disambiguate. Or, of course, if you were ok with adding another line, you could declare your value in a variable and pass that in.
// these call the int? overload
a.M(default(int?));
a.M((int?)null);
a.M(new int?());
a.M(i: null);
int? i = null;
a.M(i);

// these call the string overload
a.M(default(string));
a.M((string)null);
a.M(s: null);
string s = null;
a.M(s);

Comment: And rounding out the list you could also use `new int?()`.
Comment: @EricLippert for complete list: `a.M(i : null)` since argument names are different
Comment: @IlyaIvanov: Good one!
Comment: I like it. :) I've added both of these. Are there any other ways that come to mind, besides variations on the "pass a variable in" approach?
Comment: I can't think of any. Maybe `a.M(null as string)`, but it's just a variation of cast in this case.
Answer: The answer is that you cannot overload the member M this way if you cannot alter existing call sites.
Presumably you are adding one of the two methods and can alter the call sites for calls to the new method. Change the name of the method for those new call sites to use.
Comment: The question says that he can't add new lines of code to the call sites, not that he can't change them, so the other answers are still technically correct.
Comment: @Servy I read "can't add new lines" to mean "can't modify any lines" because it doesn't make sense to be able to modify but not add lines. Is there some kind of line count limit that must be avoided?
Comment: `I need to change the call of M method without adding any lines to Main method and accessing class A so that it became correct` this is as vague as I can imagine. Where in my answer I have added lines?
Comment: @IlyaIvanov Read "the call of M" as "the signature of M" and "without adding any lines" as "without modifying any lines" (as per the argument above). I agree that my interpretation of the poorly worded question is subject to debate, but my money is on that interpretation.

Ambiguous call of method


How should I build an obtuse corner into my horizontal board fence?

Question: We live near the bay area in California and currently planning our front yard fence. I have already touched base with city about property line and possible height restrictions, so nothing needed there (unless there are common unknowns you'd like to share).  Style = horizontal fence, like this:

pictures of my design and others
Odd fence angles - In the main plan picture you can see near the top left a fence that would be an obtuse angle. What's the best way to build this correctly? We are planning a horizontal plank fence and so I thought we may need an additional post screwed onto the main post cut at the proper angle to give a face to screw the face of planks into it. Does that make sense, or is there another better approach? Pictures included to show what I mean here
Comment: This question is broad and opinion-based. It's simple carpentry to handle angles, and what's "best" is in the eye of the beholder and the funds-holder.
Comment: Horizontal boards is a bad idea. Consider the shrinking and expanding factors, the overlapping boards is the best solution
Answer: You can have one post and mount both fence sections to it, one of them at an angle. But I think it might be easier to use a separate post for each section, and extend the fence boards a few inches past the post. Trim the boards so that they just barely touch.

Depending on the thickness of the fence boards, equipment on hand and attention detail/perfection, you can miter the ends of the boards to butt against each other properly.
Comment: Saves wasting the effort to rip a post and gives a better result, using two. My thought exactly. Though if you really want to *wow* the neighborhood, dovetail those boards together at the odd angle rather than butting them ;^) *I jest, ...or do I?*
Comment: This is really so simple that I'm baffled why I didn't think of it. Basically using the same amount of wood and just one more hole. Thank you! I'll keep the corners simple if I can get myself a miter saw.
Comment: The idea of using two posts for this strikes me as absurd. This is a custom-built fence (as opposed to a kit). There's absolutely no reason for the extra expense and odd appearance of dual posts. Since this question is mostly just a popularity vote, I have to vote against this option.
Comment: @Ecnerwal The main thing is to make it look nice...wouldn't want to be o-fence-ive
Comment: @isherwood Expense isn't much. Odd appearance? Maybe. But **thank you for explaining your downvote**.
Comment: Fence posts move with seasonal moisture and differential drying on the different faces. As those corner posts move independently the corner boards are going to smash into each other or open gaps. You'll end up putting a corner 2x4 in there to keep everything tied together.
Answer: Your detail requires that the corner posts get located exactly where you want them. When setting posts it's nice to allow for some inaccuracy. You can reduce the complexity of locating that corner post perfectly by holding it back by 6" to 12" along the face of the non-45° fence line.
Offsetting the corner post along the non-45° fence line, cantilever your horizontal boards beyond the corner post by 6" to 12". Join these cantilever tips with the 45° fence line's boards by using a floating, vertically oriented 2x4. Use a table saw to bevel the long face of this 2x4 twice at 22.5°.
Comment: Don't tell me down here. _Improve your answer._
Comment: Can you elaborate more on the 2x4 portion? Is this vertical all the way to the ground but not put in as a post?
Comment: @Dave O, with the double post detail, the tips of the boards coming from either side move independently as the posts independently move due to environmental factors. You would then install the 2x4 from the bottom board to the top board to fix all of the board tips to move in parallel. At this point, the extra post increases the stress where the boards come together, and you regret installing the extra post when the 2x4 better provides the same functionality.


Pandas index isin method

Question: I'm having throuble working with the isin method when working with pandas indexes, it always returns False.
from pandas import DataFrame
df = DataFrame(data=[['a', 1], ['b', 2], ['c', 3]], index=['N01', 'N02', 'N03'])
df.index.isin(['01', '02'])

returns
array([False, False, False], dtype=bool)

Answer: Use str.contains and pass a regex pattern:
In[5]: df.index.str.contains('01|02')

Out[5]: array([ True,  True, False], dtype=bool)

isin looks for exact matches which is why you get all False array returned
Answer: df.index.isin(['01', '02']) method  in your example is checking if each of the values in the index is equal to one of the values in the range (similar to SQL).
Therefore in your case the check is:
'N01'=='01' or 'N01' == '02'
which is False
The correct usage of .isin() in your case would be:
from pandas import DataFrame
df = DataFrame(data=[['a', 1], ['b', 2], ['c', 3]], index=['N01', 'N02', 'N03'])
df.index.isin(['N01', 'N02'])

which will result in
array([True, True, False], dtype=bool)

Pandas index isin method


Can't open Pyinstaller's output file

Question: SOLUTION:
The main issue was occurring due to ImageTk , this can be skipped by loading image using tkinter instead of PIL.ImageTk by using this command and using this object as normal you would do with PIL.ImageTk.
my_image = PhotoImage(file ="Image location here")

MAIN ISSUE:
I'm trying to pack these files into a single executable file using pyinstaller, but after compilation, the executable file doesn't run, don't know where the error is, files in the given link, and installation log in pictures
Command Used:
pyinstaller --onefile ui.py

Where ui.py is my driver script
Files:
https://github.com/RoyalEagle73/NIT-JSR-Result-Leecher/tree/master/GUI%20%2B%20Source%20v2.0/Source
Build Log( Images ):

What I've already tried
tried Cx_Freeze as an alternative but no application seems to open the output file.
here is what I'm importing overall in the whole program
from tkinter import *
from PIL import ImageTk, Image
import fb
from tkinter.ttk import Progressbar
import webbrowser
from tkinter import messagebox
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import re
from bs4 import BeautifulSoup
import time

Comment: Your first link below "Files:" is wrong. Please show the output **as text in the question** formatted as a code block instead of linking screenshots.
Comment: What exactly means "the executable file doesn't run"? How exactly do you start the application? Do you get an error message? Does the program exit without any output?
Comment: https://github.com/RoyalEagle73/NIT-JSR-Result-Leecher/tree/master/GUI%20%2B%20Source%20v2.0/Source
Comment: Can't edit my question now, fresh user so forgive for ghe mistakes
Comment: I normally run the executable file with double click and "right click and run " both, it never starts
Comment: Below your question you should see gray links like `share edit close delete flag`. Click on `edit` there or on this [edit] to edit your question. Try to run your program from a shell window and tell in your question what exactly happens. If you get an error message, copy & paste the message to your question
Comment: Ok, i'll make sure to do this next time, by now updated my questions
Comment: Run your program from a shell window, show the exact command in your question. Describe what happens. If you get any text output copy&paste it to the question. Show the output of `echo $?` after running your program.
Comment: `Traceback (most recent call last):

  File "ui.py", line 1, in

ModuleNotFoundError: No module named 'Tkinter'

[4633] Failed to execute script ui`
Comment: Got this error, if not clear see the update section in question
Answer: I was not able to access the github link in your question, I think it did not get  pasted properly. So I am unable to access your source files.
Try one of these:
 pyinstaller --onefile --noupx ui.py

or
pyinstaller --debug --onefile --noupx ui.py

The pyinstaller uses UPX. The documentation for pyinstaller states the following:

PyInstaller looks for UPX on the execution path or the path specified
  with the --upx-dir option. If UPX exists, PyInstaller applies it to
  the final executable, unless the --noupx option was given. UPX has
  been used with PyInstaller output often, usually with no problems.

Hope this helps.
Comment: Post updated, with the link, I'll try this one asap, first command does not work as I've tried after watching other answer, not sure about second one, will let you know in few moments
Comment: No but it never created issue before, using class and methods in script.py and using those methods in main script i.e. ui.py

Can't open Pyinstaller's output file


How to install Ansys15 in Ubuntu 14.04 LTS?

Question: I am a novice in using Ubuntu.Can anyone guide me through the process to install Ansys 15 in Ubuntu14.04 LTS? I have the ANSYS software on the CD.
Comment: possible duplicate of [How can I install Windows software or games?](http://askubuntu.com/questions/988/how-can-i-install-windows-software-or-games)
Answer: Please take a look at is manual: http://saiwal.esy.es/tech/installing-ansys-15-in-ubuntu-14-04/


Need advice on how to wire a switch outlet combo with two hot wires

Question: So my situation is that I have a switch which controls an outlet. I want to wire in a switch outlet combo to still control that outlet with the switch, but also have constant power to the outlet on the combo receptacle. The issue is that there are only to hot wires in the box. The grounds are wire nutted together, one hot line is independent, and the other is wire nutted to two other hot lines. I have tried every possible combination that I can think of. The switch still works as before but I cannot get power to the outlet on the combo receptacle. How can I wire this so I can get the desired outcome?
Comment: Can you post photos of the inside of the box please?
Comment: Do *not* use trial and error and all combinations to solve wiring problems.  Do you still know how it was originally wired?  It appears power comes to this box and goes to the plug from there, and if that's the case, you have a line wire and a neutral present and it's possible to do what you want.    If power goes to the plug first, unfortunately your plan won't work out, so you need a bit more information.
Comment: Are you trying to put a swich/receptacle combo *here at the switch location*?  Or are you trying to have a receptacle not pictured that is controlled by this switch, have 1 socket switched 1 socket always-hot?
Comment: @user263983 Judging from the presence and wires in those splices it seems likely a neutral is present, although that should be confirmed.
Comment: Yes, I am trying to wire the switch outlet receptacle at this location. The power is fed here first, as there is no power to the outlet. Both hot wires have power, as I have tested the terminals with a voltmeter
Comment: This room, the hallway, and another bedroom are on the same circuit breaker if that helps
Comment: Since there appears to be a bundle of whites nutted together in the background, those should be the neutrals. The hots are brown, so you should have conduit in the walls which makes adding wires easy (though you shouldn't need to), _but_ it appears that one of those wires disappears into a sheath toward the back of the box... Where in the world are you? Also, **without detaching anything**, can you pull all the wires out of the box & take another pic (assuming that this setup is the original and working).
Comment: @KH my comment has been mad before the OP posted the picture. I did not try to judge anybody or anything, just giving the information or solution, based on posted information. My opinion the site is for technical information.
Comment: I've never seen such groovy cables.   Hot is a medium taupe and neutral is a deep cream?  Is that it?  I can hardly tell black from white when it's aged and dirty, how do you work with this???
Comment: Do all of:  1) Clarify (edit) your question.    You want a new combo at "this switch location", to be [switched or unswitched] and the "existing remote outlet" to [remain switched or become unswitched].   2) Post pictures of the combo switch you bought, clearly showing both sides.  3) Post pictures of the inside of the remote outlet clearly showing the wiring 4) Pull out the wires of this box, without undoing anything, and post a picture showing what's connected to what 5) Tell us how these subtle skin tones are used to identify wires in your location.  The barely darker one is hot?
Comment: @user263983  No worries.  The word "judging" in the sentence as I used it means I'm using *my* judgement of the picture to hypothesize the presence of a neutral.  Did not mean to imply you were being judgemental =).  Didn't know you hadn't seen the picture though.
Answer: Your description and comments are a little confusing, and your picture lacks detail, but I'll take a general swing at this. I think you want to swap this switch for a Leviton style switch/receptacle combo with the new switch controlling the existing receptacle(s).
Add white wire from the existing nutted white wires to the silver screw on the new device.
It looks like the wire from the top of the switch goes unspliced directly into a cable with two insulated conductors, if your existing receptacle is not a split duplex that cable normally would be a cable to the receptacle.
If you want the switch to control only the existing wall receptacle, and the half of the combo to stay hot then attach that top wire to the gold screw and the wire from the bottom of the switch to one of the black screws. There should be two black screws, it doesn't matter which one since you should be able to see they are connected together.
If you want the switch to control both the receptacle at the switch and the existing then attach the top wire to one of the black screws, and the bottom wire to the gold screw.
Add a bare wire to the ground screw.


Show Toast in a Widget from a Thread

Question: I've to develop a widget (AppWidget) that contains a button.
When the button is pressed an http request is done and, if the request is successful, the widget notify the fact through a Toast.
Since the http request can lock the UI, I run it in a thread.
All it's working fine (I can see "All right" in my logat), except for the Toast notification.
What am I doing wrong?
In the AppWidgetProvider subclass:
@Override
    public void onReceive(Context c, Intent intent){
        super.onReceive(c, intent);
        if(intent.getAction().equals(CLICK_ACTION)){
            performRequest(c);
        }
    }

(I think onUpdate method is not necessary for the question)
private void performRequest(final Context c){
    new Thread(new Runnable(){
        public void run() {
            try {
                if(Http.get(URL).contains(SUCCESS)){
                Toast.makeText(c, "All right", Toast.LENGTH_SHORT).show();
                Log.i("Widget","All right");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }}}).start();
}

I think that the problem is the Context argument of performRequest, but if I remove the final keyword, I have errors.
Thanks in advice.
[EDIT]
I "solved" the problem in this way:
-I declare Toast t as a global variable;
-Inside the onReceive method I initialize it with Toast.makeText(Context,String,int)
-When I need to show it, I simply call t.show()
I hope that there are better solutions.
Answer:
Since the http request can lock the UI, I run it in a thread. All it's working fine (I can view "All right" in my logat), except for the Toast notification. What am I doing wrong?

The problem is you cannot alter the UI from another Thread.  You must pass this message back to the main Thread in order to display your Toast.

How can I do it?

There are a lot of different ways to do this, try saving the Context in onReceive() as a field variable:
Context context;

@Override
public void onReceive(Context c, Intent intent){
    super.onReceive(c, intent);
    context = c;
    ...

Next create a simple method in your Activity:
public void httpGetSucceeded() {
    Toast.makeText(context, "All right", Toast.LENGTH_SHORT).show();
    Log.i("Widget","All right");
}

Now call this inside your Runnable:
try {
    if(Http.get(URL).contains(SUCCESS)){
         httpGetSucceeded();
    }
} //etc

Comment: Thanks for the answer. How can I do it?
Comment: My Runnable is in the AppWidgetProvider subclass, so it doesn't see an activity's method (you mean the main activity, right?)
Comment: Ok, then put `httpGetSucceeded()` in your AppWidgetProvider intead. (Sorry, I should've notice that.)
Comment: Toast.makeText needs a Context as the firs argument. If I use `this` it points to an `AppWidgetProvider` instance.
Comment: Ok, you were using `c` before what happens when you use that instead?
Comment: let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/25185/discussion-between-supergiox-and-sam)
Comment: You cant use this because this is not valid for passing a thread to the toast message. Contextually speaking you need to pay attention where you are using the keyword this.
Comment: @supergiox Sorry, I got pulled away. Have you solved this yet? Either way I updated my answer, hope it helps!
Answer: Better yet, why don't you have a handler that dispatches a message after the thread completes its task. When you receive that message in your broadcast receiver just consume the message and display the toast by using the post runnable method from the Handler object.
Because the handler will belong to your broadcast receiver, you should be running on the UI thread when you call the post for the runnable.
Ref
http://developer.android.com/reference/android/os/Handler.html
http://developer.android.com/reference/android/os/Handler.html#post(java.lang.Runnable)
Comment: Thanks, I'm going to try it.
Comment: I tried it. I create an Handler inside `onReceive()` and I send the notification Message from the thread. But anyway I had to make the Toast from the handler and to do this operation I need a Context, and this is the same problem of the question.
Comment: You need to have the context either passed in the message's obj variable OR have the context object be static in your broadcast receiver.
Comment: How can I pass a Context through a message? (Context isn't Parcelable).
Comment: technically you can its an object that you can pass between the.. two but it would probably be preferred to use a static Context object that you maintain in the receiver and after its been used free it up by setting it to Null.
Comment: The static way is the first one I've tried. I declared the Context as a static attribute of the class and I assign it a value inside onReveice() (because there I've a Context reference). I've no errors/warning (neither in logat), but the Toast is not shown.
Comment: Update your post with what you have now. Also keep in mind that the displaying of the toast must come from the handler code being invoked after the task is done.
Answer: Easiest way is to call
activity.runOnUiThread(new Runnable() {
  public void run() {
    // launch toast here
  }
});

Or, given a specific widget:
view.post(new Runnable() {
  public void run() {
    // launch toast here
  }
});

Comment: Wrong, you don't need an activity to show a toast... last I checked. It can also come from a broadcast receiver. BUT it must come from the same thread the broadcast receiver is running on.
Comment: context does not have runOnUiThread also, he doesn't necessarily has a view at any given point during this process. Since its **after** the thread has completed. -1
Comment: Old habits die hard; I generally name my Activity reference "ctx".  I've edited my response accordingly.
Comment: Hehe, hes not in an activity either, so your response about activity is invalid. Hes asking within the widget context not an activity or view :)

Show Toast in a Widget from a Thread


How to avoid recursive oracle sql query

Question: We have a PL/SQL procedure that calculates account balance. There a two tables, accounts and transactions. Procedure goes through all accounts and for every account runs this query in parallel! (sum of + and - transactions from some date):
SELECT sum(claim) - sum(debt)
FROM transactions
WHERE account_id = :b3
  AND currency_id = :b2
  AND account_type = 2
  AND date > :b1

There is more then million accounts and similar number of transactions so this pl/sql creates lot's of queries and takes lot's of cpu and time to finish (and kills the machine it is running on).
Is there a way to calculate this in one pass through transactions table (instead of million passes) by using sum with group by account_id and currency_id or by putting sum in associative array sum[account_id, currency_id] like you would do in awk? Will it be faster? Of course sums have to be inserted in balance table in the end.
Comment: what is mean by **in one pass instead of million pass** ? If possible share table structure of both tables.
Comment: one pass means with one sql, right now when this batch runs i have millions of sql queries that do the same thing - one for each account/currency combination and they kill everything on that server and on all other servers on same physical machine
Answer: If you just want all account_id/currency_id combinations:
SELECT account_id, currency_id , sum(claim) - sum(debt)
FROM transactions
WHERE account_type = 2
  AND date > :b1
GROUP BY account_id, currency_id

Comment: Great, tnx! And how would you update balances with output from this?
Let's say balance is just a column in accounts table.
Comment: For example in shell script i would pipe it to another script that would do update accounts set balance=3rd_column where account_id=1st_column and currency_id=2nd_column, but not sure how to do it in pl/sql.
Comment: See http://stackoverflow.com/questions/7030699/oracle-sql-update-with-data-from-another-table

How to avoid recursive oracle sql query