text:
Q: Unable to use Jakarta EE 8 Security in WildFly 20 I'm trying to use Jakarta EE 8 Security in my application by defining a BasicAuthenticationMechanismDefinition in a CDI Bean:
@BasicAuthenticationMechanismDefinition(
        realmName = "RealmUsersRoles")
@ApplicationScoped
public class ApplicationConfig{}

The Realm I'm using is a FileSystemRealm defined in Elytron. Next, I've specified the allowed Roles in the endpoint:
@WebServlet("/secured")
@DeclareRoles({"Administrator"})
@ServletSecurity(@HttpConstraint(rolesAllowed = { "Administrator" }))
public class SecuredServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       // Do something
    }

}

I have added the following dependency to build and deploy the application on WildFly 20:
<dependency>
    <groupId>jakarta.security.enterprise</groupId>
    <artifactId>jakarta.security.enterprise-api</artifactId>
</dependency>

<dependency>
  <groupId>org.glassfish.soteria</groupId>
  <artifactId>javax.security.enterprise</artifactId>
  <version>1.0</version>
</dependency>

Upon requesting the secured resource, the following error is returned:
java.lang.IllegalStateException: Could not find beans for Type=interface javax.security.enterprise.identitystore.IdentityStore
    at org.glassfish.soteria@1.0.1-jbossorg-1//org.glassfish.soteria.cdi.CdiUtils.getBeanDefinitions(CdiUtils.java:194)
    at org.glassfish.soteria@1.0.1-jbossorg-1//org.glassfish.soteria.cdi.CdiUtils.getBeanReferencesByType(CdiUtils.java:158)
    at org.glassfish.soteria@1.0.1-jbossorg-1//org.glassfish.soteria.cdi.DefaultIdentityStoreHandler.init(DefaultIdentityStoreHandler.java:51)
    at org.glassfish.soteria@1.0.1-jbossorg-1//org.glassfish.soteria.cdi.CdiExtension.lambda$afterBean$12(CdiExtension.java:215)
    at org.glassfish.soteria@1.0.1-jbossorg-1//org.glassfish.soteria.cdi.CdiProducer.create(CdiProducer.java:80)
    at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
    at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
    at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
    at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:102)
    at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
    at deployment.http-basic.war//org.jboss.weldx.security.enterprise.identitystore.IdentityStoreHandler$1763020431$Proxy$_$$_WeldClientProxy.validate(Unknown Source)
    at org.glassfish.soteria@1.0.1-jbossorg-1//org.glassfish.soteria.mechanisms.BasicAuthenticationMechanism.validateRequest(BasicAuthenticationMechanism.java:60)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)

Did I miss any dependency in my application? or maybe wrong version for the glassfish.soteria dependency?
Any help is much appreciated
Thanks

A: You need to provide an implementation of javax.security.enterprise.identitystore.IdentityStore
You can use LdapIdentityStoreDefinition or DatabaseIdentityStoreDefinition or provide your own bean (ApplicationScoped) which implements IdentityStore.


text:
Q: Embedding a Video on an ASP.NET MVC Website I have created a SWF file using Flash that loads an FLV file on my local development machine.  When publishing the SWF file and generating the appropriate HTML, I can successfully load the video by opening the generated HTML page that Flash creates.  However, when placing the generated HTML code in my View, the Flash is loading, but the video is not playing.  I think it's a reference error to the location of the FLV file, but I've tried every combination I can think of.  I placed the SWF and FLV in the corresponding View folder where I want the video to load, but to no avail.  Does anyone have a working example that I can look at, or any suggestions?  Thanks.

A:
I think it's a reference error to the location of the FLV file, but I've tried every combination I can think of.

Yes, I think so as well. Have you tried using Url helpers to reference static resources on your site, like
@Url.Content("~/Content/Videos/MySupervideo.flv")

A: The actual solution to this for me was this...
In your Flash file, the Component Inspector should point to the location on the web server where the FLV file is located...
Publish the SWF, copy the appropriate HTML to the View you would like the video to play in...
And just as Darin has pointed out, use the Helpers to write the path to the SWF file on your web server where it is located.  The only difference is this (which I discovered using Google's 'Inspect Element' feature and then clicking on the 'Network' item, then clicking the path loaded on the left for the 'SWF'... on the right it stated 404 Status Not Found... why?
@Url.Content("~/Content/video/name-of-swf.swf") actually produced
src='http://localhost/content/video/name-of-swf.swf.swf'

This obviously incorrect... so here is the correct way to use the Helpers...
@Url.Content("~/Content/video/name-of-swf")

Hope this helps someone... I am giving Darin credit because he pushed me in the right direction...

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to connect with linux server using SSH connection? I am new to SSH connection & trying to connect using SSH connection but getting exception:
Inheritance security rules violated while overriding member: 'Renci.SshNet.Common.SshException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'

Security accessibility of the overriding method must match the security accessibility of the method being overriden.
Please somebody help me to resolve this issue

A: Mark GetObjectData with SecurityCriticalAttribute, because it's applied to Exception.GetObjectData. An overridden member should have the same security accessibility (Critical, Safe Critical or Transparent).
More info


text:
Q: PyQt5 UI is inconsistent across different platforms I'm trying to make a desktop application using pyqt5 because I need it to be cross platform but the UI is very inconsistent from a platform to another (the position of the widgets on the screen is different and sometimes they're on top of other widgets).
I'm new to pyqt5 and python in general so can you tell me why this is happening and how to fix it if possible?
PS: i'm using Qt designer to generate the UI and you can find all the code here
here are some examples:
on windows 10

on linux mint (ignore the missing images)


text:
Q: Titanium/Appcelerator for Android: Multiple density images not found I followed the guide here: http://developer.appcelerator.com/guides/en/app_structure.html
to use high & medium density images for android.
My file structure is:
/Resources
/Resources/android
/Resources/android/images
/Resources/android/images/high/ic_menu_add.png
/Resources/android/images/medium/ic_menu_add.png
/Resources/android/images/default.png
/Resources/user
/Resources/user/super.js
/Resources/app.js

the default.png loads as expected.
I added 6 buttons to my menu in super.js (to try and debug this):
var activity = Ti.Android.currentActivity;
activity.onCreateOptionsMenu = function(e) {
  var menu = e.menu;
  var menuItem1 = menu.add({ title: "1" });
  menuItem1.setIcon("/images/ic_menu_add.png");
  menuItem1.addEventListener("click", function(e) {
  });
  var menuItem2 = menu.add({ title: "2" });
  menuItem2.setIcon("../images/ic_menu_add.png");
  menuItem2.addEventListener("click", function(e) {
  });
  var menuItem3 = menu.add({ title: "3" });
  menuItem3.setIcon("../ic_menu_add.png");
  menuItem3.addEventListener("click", function(e) {
  });
  var menuItem4 = menu.add({ title: "4" });
  menuItem4.setIcon("/images/ic_menu_add.png");
  menuItem4.addEventListener("click", function(e) {
  });
  var menuItem5 = menu.add({ title: "5" });
  menuItem5.setIcon("/ic_menu_add.png");
  menuItem5.addEventListener("click", function(e) {
  });
  var menuItem6 = menu.add({ title: "6" });
  menuItem6.setIcon("ic_menu_add.png");
  menuItem6.addEventListener("click", function(e) {
  });
}

When I press the menu button:
12-15 14:23:59.091: INFO/TiFileHlpr(537): (main) [4617,7631] /images/ic_menu_add.png not found.
12-15 14:23:59.101: INFO/TiFileHlpr(537): (main) [4,7635] ../images/ic_menu_add.png not found.
12-15 14:23:59.121: INFO/TiFileHlpr(537): (main) [25,7660] ../ic_menu_add.png not found.
12-15 14:23:59.121: INFO/TiFileHlpr(537): (main) [3,7663] /images/ic_menu_add.png not found.
12-15 14:23:59.131: INFO/TiFileHlpr(537): (main) [5,7668] /ic_menu_add.png not found.
12-15 14:23:59.140: INFO/TiFileHlpr(537): (main) [5,7673] ic_menu_add.png not found.

The official guide says to use just 'ic_menu_add.png' which is case 6 and doesn't work.
The build directory looks like this:
/build/android/res/drawable-hdpi/ic_menu_add_ad7ef1aa68.png
/build/android/res/drawable-mdpi/ic_menu_add_ad7ef1aa68.png

My custom AndroidManifest.xml has this section in it:
<supports-screens
   android:largeScreens="true"
   android:anyDensity="true"
   android:normalScreens="true"  android:smallScreens="true"/>

Anyone know the proper way to get multiple density images to work? [I'm using mobile sdk 1.5.x]

A: This is a known and logged issue.  It is scheduled to be fixed in the 1.6
You can check out the log from their bug tracking system:
Medium Density Images Bug Logged - Appcelerator
So, no immediate relief for you but it's coming.  This happens to be on occasion, I'm currently waiting for the UIscreen for iOS so I can support external displays / VGA dongle.


text:
Q: Prevent activity from opening inside another app I am developing an app which receives share intents from other apps.
I specified android:launchMode="singleTask" in the AndroidManifest.xml which works fine when it receives share intents from most apps.
However, "Microsoft 365" (previously known as "Microsoft Lens") opens the app inside its app. So the user sees 2 same apps but one app is actually inside another app.
How can I prevent this?
https://github.com/localsend/localsend/issues/176
Current XML:
<application
        android:label="LocalSend"
        android:name="${applicationName}"
        android:usesCleartextTraffic="true"
        android:banner="@drawable/banner"
        android:icon="@mipmap/ic_launcher"
        android:requestLegacyExternalStorage="true"> <!-- localsend: image_gallery_saver requires requestLegacyExternalStorage -->

        <!-- localsend: prevent multiple instances by android:launchMode="singleTask" -->
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>

                <!-- enable Android TV -->
                <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
            </intent-filter>

            <!-- localsend: Receive share intent (share_handler) -->
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>

        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

A: If you specified android:launchMode="singleTask" within your app and you still experience this behaviour, it implies that the app which is launching your app(activity) is most likely doing so using startActivityForResult(). With this, android:launchMode="singleTask" is ignored and your app is launched within the task of the caller app(In this case Microsoft 365).
To prevent this, the caller app has to launch your app using startActivity().
Follow this link for more clarification: Android "singleTask" activity creates new instance of the Activity


text:
Q: kafka_2.10 source is not available I have the below dependency in pom.xml.
   I need to check the source of some classes for debugging purpose.
    <dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.10</artifactId>
    <version>0.8.1.1</version>
    </dependency>

But unable to find any source in eclipse, where as sources to other jars are available.

A: go to inside the project and go to jar file and Right-click on it, then  go to property optopn, in the property you can find 'Java Source Attachment' click 'Workspace' Select the 'src' folder .


text:
Q: Directly go to Product Detail page on click of a category in the nav bar In my store, one of the category has only one product. Is it possible to take the user directly to the product detail page of this one product whenever they click this category in the nav bar?

A: Yes this can be done by using the URL Rewrite Management option in Magento Admin.
In Magento Admin:

*

*Select from menu bar Catalog > URL Rewrite Management.

*Click on the Add URLRewrite button.

*Select the category you want to redirect from.

*Make a note of the ID Path (e.g.: category/10) and the Request Path (e.g.: flowerpots.html)

*Repeat steps 1 & 2, but this time select Custom from the Create Urlrewrite dropdown box.

*Enter the values in each field:

*

*ID Path (from step 4)

*Request Path (from step 4)

*Target Path - enter path of your product (or the page you want to redirect to).

*

*example 1: for product url www.myswebsite.co.uk/flowers.html enter flowers.html.

*example 2: for product url www.myswebsite.co.uk/sale/garden/flowers.html enter sale/garden/flowers.html.

*Select Redirect Permanent (301) from the Redirect dropdown.

*Save.

Now when the category is clicked on on your website it will re-direct to the product.

A: This can be done programmatically by adding code to the page template in your theme folder which is called for showing the categories. Check full solution here - http://www.codeboss.in/web-funda/2015/01/30/magento-auto-redirect-to-product-details-page-if-category-have-only-one-product/

A: Follow the Steps:

*

*Open the page template which is assigned to the category pages. You will find it under "template/page/" folder in your theme directory. For example let us assume the page is 1column.phtml (for the One column layout).

*Just after the lines

/**
 * Template for Mage_Page_Block_Html
 */

*Add the following code :

<?php
$product = Mage::registry('current_product');
if($product == ''){
$category = Mage::registry('current_category');
if(is_object($category)){
$catLoaded = Mage::getModel('catalog/category')->load($category->getEntityId());
 $collection = $catLoaded->getProductCollection();
$collection->addAttributeToSelect('*');
if(count($collection) == 1){
foreach($collection as $product){
 $productUrl = $product->getProductUrl();
 header("location:$productUrl");
 exit;
  }
 }
 }
}
?>


text:
Q: Word for someone seeming deep and intelligent, but not really being that What is the word for someone trying to seem/be deep and intelligent, but really they are shallow, and not at all being insightful.
Pedant is about rules, so that is disqualified, the closest I could find is pseudointellectual, but that feels like cheating and clumsy as it is a simple compound word.

A: The word sophistication is from the Greek word sophis, which implies false or pompous wisdom. Appearing to be wise. Which is different from the Greek words sophee, sophia which mean wise, wisdom.
Therefore we have in English the words sophist, sophistry and sophism.
We also have the words

*

*Smarty pants

*Smart Aleck (more prevalent in Brit English)

smar·ty-pants, smart′ al`eck
n. Informal.
an obnoxiously conceited and impertinent person.
[1860–65, Amer.; generic use of Aleck, nickname for Alexander]
smart′-aleck•y, smart′-aleck, adj.
Random House Kernerman Webster's College Dictionary, © 2010 K Dictionaries Ltd. Copyright 2005, 1997, 1991 by Random House, Inc. All rights reserved.
sophistry

n, pl -ries

*

*(Philosophy)
a. a method of argument that is seemingly plausible though actually invalid and misleading
b. the art of using such arguments

*subtle but unsound or fallacious reasoning

*an instance of this; sophism

sophism

n

*

*(Philosophy) an instance of sophistry. Compare paralogism

[from Latin sophisma, from Greek: ingenious trick, from sophizesthai to use clever deceit, from sophos wise, clever]
Collins English Dictionary – Complete and Unabridged © HarperCollins Publishers 1991, 1994, 1998, 2000, 2003
soph·ist

n.

*

*
a. One skilled in elaborate and devious argumentation.
b. A scholar or thinker.

*Sophist Any of a group of professional fifth-century b.c. Greek philosophers and teachers who speculated on theology, metaphysics, and the sciences, and who were later characterized by Plato as superficial manipulators of rhetoric and dialectic.

[Middle English sophiste, from Latin sophista, from Greek sophists, from sophizesthai, to become wise, from sophos, clever.]
The American Heritage® Dictionary of the English Language, Fourth Edition copyright ©2000 by Houghton Mifflin Company. Updated in 2009. Published by Houghton Mifflin Company. All rights reserved.

A: I'd call someone like that an intellectual fraud, poseur, pseud, phoney intellectual or — notwithstanding your reservations, which I think are feeble — pseudointellectual.

A: It's not common, but sciolist seems to have the required definition.

One who exhibits only superficial knowledge; a self-proclaimed expert with little real understanding.

I prefer this to sophist, which I think has a suggestion of deceit rather than just ignorance or error.

A: While it is not limited to intellectual chicanery, charlatan means

one making usually showy pretenses to knowledge or ability : fraud, faker

Merriam-Webster
Or perhaps know-it-all

one who claims to know everything; also: one who disdains advice

Merriam-Webster

A: Sophomoric suggests both limited experience and pretensions of knowledge:

suggestive of or resembling the traditional sophomore; intellectually pretentious, overconfident, conceited, etc., but immature

Wiseacre may fit, but is not widely used:

A person with an affectation of wisdom or knowledge, regarded with scorn or irritation by others; a know-it-all.

A: Pseudo-intellectual---A person who pretends an interest in intellectual matters (theFree Dictionary.com.Eg., 'The guy is a pseudo-intellectual. He's so deep he's shallow.'


text:
Q: $T \vdash Prov_T(\sigma)$ but $T \nvdash \sigma$ If we have a consistent and axiomatizable extension of PA, which we'll call $T$, I'm wondering if it's possible to have a sentence $\phi$ such that $T \vdash Prov_T(\phi)$ but $T \nvdash \phi$ where $Prov_T(x)$ expresses "$x$ is provable in $T$".
Note very importantly that we assume $T$ contains "sufficient induction" such that it satisfies the following derivability conditions:
(1) "reflection" which is if $T \vdash \sigma$ then $T \vdash Prov_T(\sigma)$ and (2) a "formal" version of modus ponens such that $T \vdash Prov_T(a) \land Prov_T(a \rightarrow b) \rightarrow Prov_T(b)$ for any sentences $a$ and $b$.
My intuition is that there is such a sentence $\phi$ since @Noah Schweber points out in this post that soundness might not hold.
On the other hand, I also think Lob's theorem is relevant and some adaptation of it might actually prove that $T \vdash Prov_T(\phi)$ then $T \vdash \phi$ if we use the derivability to adapt Lob's theorem. Any hints?

A: Take $T$ to be Peano arithmetic (PA) + the sentence "PA is inconsistent" (for instance $Prov_{PA}(0=1)$)
Then $T$ is recursively axiomatizable; and by Gödel's incompleteness theorem, $T$ is consistent (otherwise $PA \vdash Con(PA)$, and thus PA is inconsistent, which is absurd; unless PA is inconsistent, but then the whole discussion is rendered useless because there is no consistent extension of PA - anyway if we're working in ZF, PA is clearly consistent so we are content with that)
Since $T$ is consistent, and $PA \vdash \neg (0=1)$, then $T\nvdash 0=1$.
However, by very definition of $T$, $T\vdash Prov_{PA}(0=1)$ and so $T\vdash Prov_T(0=1)$ because for any recursively axiomatisable extension of PA $S$ and every $\phi$, we have $PA\vdash (Prov_{PA}(\phi) \implies Prov_S(\phi))$.
Hence we have found such a $T$.
This first part (before edit) answered the "is it possible ?" question; now if you were wondering about an arbitrary $T$ (can we find a $\phi$ for all $T$ ?), the answer is no, the best example being PA. Indeed, if $PA\vdash Prov_{PA}(\sigma)$, then $\mathbb{N}\models Prov_{PA}(\sigma)$ and so there is an actual proof in PA of $\sigma$: $PA\vdash \sigma$. In fact this argument shows that any recursively axiomatizable extension of PA that is contained in true arithmetic (the theory of $\mathbb{N}$) will have the property that there is no such $\phi$: indeed we have a soundness condition: if $\mathbb{N}\models Prov_T(\sigma)$, then $T\vdash \sigma$

A: Building off of Max's excellent answer, what we're dealing with here is that there are many different "niceness" properties a theory might have, and they yield different conclusions.

*

*Being consistent. 'Nuff said.

*Being recursively axiomatizable. This is necessary in order to even talk about provability from a theory in the language of arithmetic. (OK that's not quite true, in general all we need is that the theory be definable, but working with arithmetically defined theories can lead to weird results so it's reasonable to restrict attention to recursive axiomatizations here.)

*Being sufficiently strong. A theory extending PA (indeed, even much less) has the nice property that it is $\Sigma_1$ complete: every true $\Sigma_1$ sentence is provable in the theory. This in particular implies that if $T$ is sufficiently strong (and recursively axiomatizable) then $T\vdash\phi$ implies $T\vdash Prov_T(\phi)$ for each $\phi$.

*Being sufficiently correct. Consistent sufficiently strong recursively axiomatizable theories can still be quite weird - e.g. PA+$\neg$Con(PA). We have a separate interest in not-too-stupid theories - that is, theories which don't prove "blatantly false" sentences. Such theories are called "sound" - more specifically, if $T$ is a theory which proves only (not necessarily every!) true sentence of type $\Gamma$, then we say $T$ is $\Gamma$-sound. E.g. PA+$\neg$Con(PA) is not $\Sigma_1$ sound, since it proves the false $\Sigma_1$ sentence "$Prov_{PA}(\underline{\ulcorner 0=1\urcorner})$." Correctness is particularly relevant here, and somewhat subtle, so let me give three further comments on it:

*

*First, note that correctness is in tension with completeness. To make a theory "more complete" we would strengthen it, while to make a theory "more correct" we would weaken it (by removing offending axioms).

*Second, $\Gamma$-soundess principles aren't the only kinds of correctness which are of interest. For example, consider the following property: $$\mbox{If $T$ proves $\neg \phi(\underline{n})$ for each $n\in\mathbb{N}$, then $T$ doesn't prove $\exists x\phi(x)$.}$$ (Note that the conclusion is not "then $T$ proves $\forall x\neg\phi(x)$"!) This property is called $\omega$-consistency. Historically this was an assumption Godel needed in his proof, which was later removed by Rosser. The term "consistency," rather than "soundness," in the name of the principle reflects the fact that it really is a consistency property *with respect to a stronger-than-usual proof system. Indeed, soundness principles in general can be viewed as "higher consistency principles."

*Finally, it's worth noting that on the face of it soundness principles can require some kind of "Platonic commitment" - to make sense of the phrase "$\Sigma_{17}$-sound," we need to (on the face of it) commit to the notion that $\Sigma_{17}$ statements have definite truth values. If we believe that $\mathbb{N}$ "exists" (???), then this is unproblematic, but the more "mathematical skepticism" we adopt can rapidly make us suspicious of even the notion of soundness (whereas consistency, being $\Pi_1$, is somewhat more palatable). This takes us well into foundational issues, and is really orthogonal to your question here, so I don't want to go into it in more detail - in particular, in my opinion it's best when learning the basics of this subject to at least temporarily adopt the position that $\mathbb{N}$ "really exists" and all arithmetic statements (at least) have definite truth values - but it's nonetheless worth mentioning.

The connection with your question is the following:

Suppose $T$ is a consistent, recursively axiomatizable, sufficiently strong theory. Then it is possible that there is some $\phi$ such that $T\vdash Prov_T(\phi)$ but $T\not\vdash\phi$; for example, take $T$ to be PA+$\neg$Con(PA) and $\phi$ to be "$0=1$." However, this is ruled out if $T$ is additionally assumed to be $\omega$-consistent$^1$ or even $\Sigma_1$-sound$^2$.

$^1$This was how Godel used $\omega$-consistency in his original argument, although he could have made due with the weaker$^3$ assumption of $\Sigma_1$-soundness without changing the argument at all; I don't know when this was first observed.
$^2$Note that $\Sigma_1$-soundness and $\Sigma_1$-completeness - the latter of which follows from the assumed strength of $T$ - together imply that the $\Sigma_1$ theorems of $T$ are exactly the true $\Sigma_1$ statements, but do not imply that $T$ proves every true $\Pi_1$ statement, and indeed since the set of true $\Sigma_1$ statements isn't recursive we know this can't happen since $T$ is recursively axiomatizable.
$^3$Yes, $\omega$-consistency is strictly stronger than $\Sigma_1$ soundness! The point is that $\omega$-consistency applies to all $\phi$, not just to $\phi$ of a certain complexity.


text:
Q: How do you read this, "to staff a 100 bed"?
The health provider will get $20 million from the Abbott Government to staff a 100 bed hospital in Sierra Leone. (here is the audio) (from Aussie ABC)

I don't hear clearly how the presenter is saying this number, 100. 'a-hundred' or 'hundred'. I hear the latter. But the presenter might be saying 'to staffa a-hundred,' not 'to staff a hundred.' How do you read the number, 100? 'A-hundred' or 'hundred'? If it was 200, would you read 'to staff a two-hundred'?

A: ... to staff a 100-bed hospital ...
This could be said either as "a one-hundred-bed hospital" or more simply, "a hundred-bed hospital". The second was what the announcer in your clip said.
We can have a 200-bed hospital, "a two-hundred-bed hospital". Indeed, we can use any number there. The 'a' is necessary, The 'one' before numbers beginning with one hundred/thousand (100, 110, 175, 1,000, etc) is optional.

A: To use and articulate a one-hundred-bed hospital is to emphasize, while saying a hundred is very passive.
Apparently this hundred-bed hospital is not to big of a deal.  It nearly sounds like the presenter is indicating some kind of experiment; an experiment funded by Abbott.
EMPHASIS EXAMPLE

Abbott gave ONE Hundred Million Dollars to charity!  That is quite a lot of money!

PASSIVE EXAMPLE

Abbott gave a hundred million dollars to charity.  He couldn't think of anything else to spend it on.

A: You can use either "a one-hundred" or "a hundred". I am not aware of any prescribed grammar in this circumstance. Maybe because it has become an all too familiar usage.
But, just to be analytical: "a—used as a function word before singular nouns when the referent is unspecified  and before number collectives and some numbers "
Technically, 'a' in this circumstance is an indefinite article (singular). Which means it can be any 'hundred', not a specific 'hundred.'
Where these examples refer to a specific hundred:
1.) This hundred bed hospital.
2.) That hundred bed hospital.
3.) Your hundred bed hospital.
'One-hundred bed hospital' itself does not refer to a specific or non-specific one-hundred bed hospital. It only really creates an lexicon image.
One is not required before hundred because in this case (and most all cases) hundred is a noun. Just the same as any other noun, it is understood already as '1' singular. (Cat or One Cat, bed or one bed)


text:
Q: How can I filter my data in Crystal Reports in C#? I have text fields where I can enter all my data, and when I click a button print it will directly go into the Crystal Report which is already filtered containing my data. How do I do this?

A: Pass the data as parameters to the Report. Bind the button click event to Generate the Report.


text:
Q: Show that if $ |f( \frac{1}{n}) | \leq \frac{1}{n!}$ then $0$ is an essential singularity Given holomorphic non-constant  function $f:D(0,1) \smallsetminus \{0\} \rightarrow \mathbb{C}$ so $\forall n=2,3,...:\ |f(\frac{1}{n})| \leq \frac{1}{n!}$ I need do show that $0$ is an essential singularity.
I tried expanding $f$ to it's Laurent series near $z_0 = 0$ and compute coefficients by:
$$a_{-k} = \frac{1}{2 \pi i} \int_{|z|=r} z^{n-1}f(z)dz$$
and take $r= \frac{1}{n}$ so
$$a_{-k} = \frac{1}{2 \pi i} \int_{|z|=\frac{1}{n}} z^{n-1}f(z)dz $$
But I don't know how to if it's a fertile direction nor how to proceed if it is.

A: Suppose the singularity is removable. Then $f(0) = \lim_{n\to\infty} f(1/n) = 0$, so we may write $f(z) = z^k g(z)$ for some $k\in \mathbb{N}$ and $g$ holomorphic with $g(0) \neq 0$. In a small enough neighborhood around $0$, we may assume $|g| > C > 0$. Thus, in this neighborhood, we have $|f(z)| > C |z|^k$. For large enough $n$, it follows that $Cn^{-k} < 1/n!$, contradiction.
Similarly: suppose the singularity is a pole. Write $f(z) = g(z)/z^k$ where $g(0)\neq 0$. Then in a small enough neighborhood of $0$, we have $|f(z)| > C|z|^{-k}$ so for large enough $n$, it must be true that $1/n! > Cn^k$, contradiction.

A: Hint:

Does $$\lim_{z\to0}f(z)=L$$ exist? (For finite or infinite $L$)

Suppose it does, and because $1/n\to0$ then $|L|\leq0\to L=0$. Now, you must check that this value is possible.


text:
Q: Use part of an URL under other domain I have a webshop as part of a website on an Apache server that can be reached on an URL like this:
http://www.example.com/webshop

There are a bunch of URLs that are derived from this URL, for e.g.:
http://www.example.com/webshop/tops/
http://www.example.com/webshop/tops/sweatshirts
http://www.example.com/webshop/tops/t-shirts
http://www.example.com/webshop/bottoms/
http://www.example.com/webshop/bottoms/shorts
http://www.example.com/webshop/bottoms/jeans
...

I would like to register a domain (for e.g.: examplewebshop.com) and configure it for the webshop part of the website URL, so it is able to show the contents of http://www.example.com/webshop/ without redirecting. So for e.g. these:
http://www.example.com/webshop/tops/sweatshirts
http://www.example.com/webshop/bottoms/shorts

could be reached under the URL of
http://www.examplewebshop.com/tops/sweatshirts
http://www.examplewebshop.com/bottoms/shorts

as well.
Can this be achieved?
If yes, is it only .htaccess + RewriteRules, or something else?


text:
Q: Parts of Flot Chart Not Displayed I am developing a flot chart to include in an existing web site. When I create the chart in an otherwise empty web page, for development purposes, everything renders correctly.
But when I add it to the web site, parts of the chart to not display (this applies regardless of the chart type: line, bar or stacked). Here's what does not show:
(1) The chart title, which I have done as a top xaxis
(2) The xaxis ticks (except for part of the first one)
(3) The xaxis (bottom) label
(4) The yaxis label, although the yaxis ticks DO appear
Also, the yaxis ticks, while they appear, they are off by a half. So instead of 0 being at the lower corner, it is below the x axis, and the next y tick is positioned between 0 and its grid line, etc. So when a bar chart is rendered that has a value of 500, it shows at the 600 level.
Also, the the very top of the first xaxis tick also renders.  Sometimes I can get an inner vertical scroll to appear and scroll down to see the xaxis ticks, but the first one is higher vertically than the others. I can't see any of the rest of the missing features.
I have tried everything that I can think of:
(1) Adding padding around the container div
(2) setting overflow:auto on that div
(3) removing rendering the labels as canvas
(4) removing autorotate ticks (which appear only on the x axis)
Any help would be appreciated.


text:
Q: Why can't you pass strings from contract to contract? When calling trying to pass a string from contract to contract, I get an error. in getName with error. I'm aware you cannot pass strings but what is the reason?

Return argument type inaccessible dynamic type is not implicitly
  convertible to expected type (type of first return variable) string
  memory. return toBeCalled.getName();

pragma solidity ^0.1.0;

contract ToContract{
    FromContract fromContract = new FromContract();

    function getName() constant returns (string) {
        return fromContract.getName();
    }

}

contract FromContract{
    string name = 'dapp';

    function getName() constant return(string){
        return name;
    }

}

A: In solidity a string "Hey" is internally stored as ["H","e","y"] which is a dynamic array. As of now it has no support to pass dynamic arrays. you can try to work around this by passing the string as a part of an object.


text:
Q: How can I rewrite lines in a txt file using grep [sed]? I have a text file where each line has the format like this...
25126 Akers, David
And I'm needing to put it in a format like this to insert into a database...
25126;Akers, David;

Only problem is there might be some with names having spaces like...
25257 Ah You, C.J.

I was told I should use grep but I'm not sure how to go about doing it.

A: grep is not suitable for such a task, because it is a search tool, but if I understand correctly the problem, you can use sed, as in the following example:
sed 's/^\([0-9]\+\) \(.*\)$/\1;\2;/' input-file >output-file

To preventively check that all lines conform to the above pattern, run the following command
sed -n '/^\([0-9]\+\) \(.*\)$/!p' input-file

that should return nothing.


text:
Q: What's an efficient way to filter this array? My data structure is
companies = [
  {name: 'A', ramps: [1, 2]},
  {name: 'B', ramps: [3, 4, 5]}
  ...
]

ramps = [
  {id: 1, division: 'accounting', amount: 500},
  {id: 2, division: 'sale', amount: 200},
  ...
]

My goal is to end up with the following data:
groupedByDivision = [
  {division: accounting, total: 12000},
  {division: sales, total: 6500},
  ..
]

My first brute-force approach is something like this (note: I've extended Ember.Array with this flatten method:
var ramps = this.get('controller.companies') // this is the array of companies
  .get('model')
  .mapProperty('ramps')
  .flatten();

var temp = {}, data = [];
$.each(ramps, function(index, ramp) {
  if ( !(ramp.billingDiv in tempCompanies) ) {
    temp[ramp.billingDiv] = ramp.feeChange;
  } else {
    temp[ramp.billingDiv] += ramp.feeChange;
  }
});

$.each(temp, function(division, amount) {
  data.push({
    'category': division,
    'count': amount
  });
});

return data;

Any other suggestions? I'm not too familiar with the Ember.Array methods yet, so I'm not aware of all their use cases.


text:
Q: jQuery Cycle plugin - how to re-start from beginning of the slide each time i click on navigation link? each time I click on navigation link "Services", it displays the previous Section I've visited. Instead I'd like to re-start displaying always the 1st section. How can I make this works, please?
This is the html markup:

Home

Services

Contact

This is 1st Section

This is 2nd Section

This is 3rd Section

And this is the jQuery:
function cycle() {

   // Services Cycle.
   var $cycleServices = $(".cycle-services");

   // The paging.
   $cycleServices
      .before('
');

   // Let's put in the next button.
   $cycleServices
      .after("
Next
");

   $cycleServices.cycle({
      fx:     "scrollHorz",
      speed:  800,
      easing: "easeOutExpo",
      timeout: 0,
      pager:   ".cycle-services-pager",
      next:   ".cycleServicesNext",
      prev:   ".cycleServicesPrevious",
      pagerAnchorBuilder: function(idx, slide) {
         return '
' + idx + '
';
      }
   });

   // Resize Panel according to slide cycle selected.
   var $panelServices = $("#panel-services");

   $("#cycle-services-pager-0")
      .on("click", function() {
         $panelServices
            .animate({ "width" : "430px" }, 800, "easeOutExpo");
      });

   $("#cycle-services-pager-1")
      .on("click", function() {
         $panelServices
            .animate({ "width" : "555px" }, 800, "easeOutExpo");
      });

   $("#cycle-services-pager-2")
      .on("click", function() {
         $panelServices
            .animate({ "width" : "555px" }, 800, "easeOutExpo");
      });

   $("#cycle-services-pager-3")
      .on("click", function() {
         $panelServices
            .animate({ "width" : "555px" }, 800, "easeOutExpo");
      });

   $("#cycle-services-pager-4")
      .on("click", function() {
         $panelServices
            .animate({ "width" : "555px" }, 800, "easeOutExpo");
      });

   $(".cycleServicesNext")
      .on("click", function() {

         var thePanelID = $(".cycle-services-pager").find("li.activeSlide").text();

         if ( thePanelID == 0 ) {

            $panelServices
               .animate({ "width" : "430px" }, 800, "easeOutExpo");

         } else {

            $panelServices
               .animate({ "width" : "555px" }, 800, "easeOutExpo");

         }

      });

}

A: You can trigger first page button in cycle pagination. In this case you can try:
$("#nav-services").first().click(function(){
 $(".cycle-services-pager li").first().click();
});


text:
Q: Is it safe to delete static casted pointer? Consider abstract class AbstractMap and it's child classMyMap. Is it safe to perform the following delete operation? Or, should I delete the ptr only after re-casting to MyMap? And why? I guess it is unsafe, because in this case destructor of MyMap is not called.
AbstractMap* ptr;
ptr = static_cast<AbstractMap*>(new MyMap());
delete ptr;

The past question talked about casting to void* case, but I'm not sure for my case.

A: Provided that AbstractMap's (or it's base if any) destructor is marked as virtual, delete ptr would be well-defined.
Compiler will invoke the most derived destructor virtually (as with any virtual function), which will, in turn, call destructor(s) of base(s) non-virtually.
A destructor will have all necessary code to call destructors of all member objects,  and in the end of this process the memory will be reclaimed back to heap manager (based on size of allocated block).

A:
Consider abstract class AbstractMap and it's child classMyMap.
Is it safe to perform the following delete operation?
ptr = static_cast<AbstractMap*>(new MyMap());
delete ptr;

Deleting through a pointer to base sub object can be safe only if the destructor of the base (AbstractMap in this case) is virtual. If that precondition isn't satisfied, then the behaviour of the program is undefined.

Suppoes AbstractMap has a virtual destructor, how can it call the child class's destructor?

Note that if you created the instance using allocating new expression, then you aren't supposed to call the destructor directly. delete will do that for you.
But in the special cases where you may need to call the destructor directly, you do it by calling the destructor of AbstractMap using dynamic dispatch (which is the default form of dispatch for virtual functions).

how can it know that the "original" one is MyMap?

You don't need to know the dynamic type. That's what makes virtual functions so great.

P.S. Avoid owning bare pointers. There's hardly ever a need to write new and delete.


text:
Q: Add user with card numer to ZKTime Device I'm using Python 2.7, and I use PyZk to communicate with ZKTime (Time Attendence software) on Linux OS, And I can't set user with 'Card Number'. Below the method that allows to add a user in the device, how can I add the card number for user?
set_user(uid=1, name='Fanani M. Ihsan', privilege=const.USER_ADMIN, password='12345678', group_id='', user_id='123')

Thanks.

A: The new version can do that
https://github.com/fananimi/pyzk
set_user(uid=345, name='', privilege=0, password='', group_id='', user_id='123', card=0)

This response for everyone search for the solution


text:
Q: Run a query with an if condition on the same query IF the the number of ROWS in the QUERY A is greater than 5, THEN show the ROWS of Query A. If it is less than 5, then try 10 more times to pass the condition. IF it doesn't meet the condition after 10 tries, then LEAVE.
Set try=0
   While try <10:
   IF (select count(*) of QUERY A) > 5
      EXECUTE QUERY A
       Leave while
   ELSE
   try=try+1

Is this possible in a MySQL statement?


text:
Q: How can I make a table column width somewhat similar automatically? I wrote a PHP code to generate a table dynamically. The head of the table can be any text value in a database and the column of the table can be any text in the database.
If the value of the columns are the same or similar, then the width should be somewhat the same.
the following is my HTML code that is generated by PHP

            Title

            Answer Options
            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11+

            Response Count
            2
            0
            0
            0
            1
            0
            0
            0
            0
            0
            1

this is my common2 css code
.common2
    {
        width: 100%;
        border: solid #E6E6E6 1px;
        margin: 0 auto;
        padding: 0;
        border-spacing: 0px;
        /* border-collapse: collapse; */
    }

    .common2 td
    {
        padding: 6px;
        border: solid #E6E6E6 1px;
    }

    .common2 th
    {
        color: #fff;
        font-weight: bold;
        text-align: center;
        border: solid #E6E6E6 1px;
        background-color: #1A1A1C;
        padding: 8px;
        font-size: 14.5px;
    }

    .common2 th.highlighed
    {
        color: #fff;
        font-weight: bold;
        text-align: center;
        border: 0px solid #DBDBDB;
        background-color: #666666;
        padding: 6px 10px;
    }

.common2 tr:last-child td:last-child {
    -moz-border-radius: 0 0 6px 0;
    -webkit-border-radius: 0 0 6px 0;
    border-radius: 0 0 6px 0;

}

.common tr:last-child td:last-child {
    -moz-border-radius: 0 0 10px 10px;
    -webkit-border-radius: 0 0 10px 10px;
    border-radius: 0 0 10px 10px;
}

    .common2 tr:nth-child(even)
    {
        background-color: #E8E8E8; /*#E7E9E8; /*#D6D8D7;*/
        position: relative;
    }

    .common2 td.stickOut
    {
        background-color: #DDEAFA; /*#DBAFAF;*/
        position: relative;
        font-weight: bold;
        border: solid #DBDBDB 1px;

    }

    .common2 td.head
    {
       background-color: #25328C; /* #4F4F4F; */
        text-align: center;
        border: 1px solid #25328C;
        padding: 3px;
        font-weight: bold;
        color: #fff;
        padding: 4px 10px;
        height: 35px;

        /* IE10 Consumer Preview */
        background-image: -ms-linear-gradient(bottom, #2C3C92 0%, #25328C 100%);

        /* Mozilla Firefox */
        background-image: -moz-linear-gradient(bottom, #2C3C92 0%, #25328C 100%);

        /* Opera */
        background-image: -o-linear-gradient(bottom, #2C3C92 0%, #25328C 100%);

        /* Webkit (Safari/Chrome 10) */
        background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #2C3C92), color-stop(1, #25328C));

        /* Webkit (Chrome 11+) */
        background-image: -webkit-linear-gradient(bottom, #2C3C92 0%, #25328C 100%);

        /* W3C Markup, IE10 Release Preview */
        background-image: linear-gradient(to top, #2C3C92 0%, #25328C 100%);

    }

    .common2 td.subfoot
    {
       background-color: #FFFF99; /* #4F4F4F; */
        text-align: center;
        border: 1px solid #DBDBDB;
        padding: 3px;
        color: #000;
        font-weight: 600;
        font-style:italic;
        padding: 4px 10px;
    }

    .common2 td.foot1
    {
       background-color: #999999; /* #4F4F4F; */
        text-align: center;
        border: 1px solid #DBDBDB;
        padding: 3px;
        font-weight: bold;
        color: #fff;
        padding: 4px 10px;
    }

    .common2 td.foot2
    {
       background-color: #555555; /* #4F4F4F; */
        text-align: center;
        border: 1px solid #DBDBDB;
        padding: 3px;
        font-weight: bold;
        color: #fff;
        padding: 4px 10px;
    }

Here is a screenshot of my current output.
How can I make those columns with a similar width, excluding the very first column, as I specified how wide that will be?

A: remove width property  from .common2
http://jsfiddle.net/raam86/knj9E/


text:
Q: Giving title to my different dataframes on excel sheet using python I have few dataframes in an excel sheet with 2 rows of spaces between them and now I want to give title or description to those dfs. How is it possible?
Used this function for multiple dfs
# funtion
def multiple_dfs(df_list, sheets, file_name, spaces):
    writer = pd.ExcelWriter(file_name,engine='xlsxwriter')
    row = 2
    for dataframe in df_list:
        dataframe.to_excel(writer,sheet_name=sheets,startrow=row , startcol=0)
        row = row + len(dataframe.index) + spaces + 1
    writer.save()

# list of dataframes
dfs = [df,df1,df2]

# run function
multiple_dfs(dfs, 'Validation', 'test1.xlsx', 1)

A: You can wrap your description in a Series and write it the same way as the dataframe:
import pandas as pd
import numpy as np

def multiple_dfs(df_list, sheets, file_name, spaces, comments):
    writer = pd.ExcelWriter(file_name,engine='xlsxwriter')
    row = 2
    for dataframe, comment in zip(df_list, comments):
        pd.Series(comment).to_excel(writer,sheet_name=sheets, startrow=row,
                                    startcol=1, index=False, header=False)
        dataframe.to_excel(writer,sheet_name=sheets,startrow=row + 1, startcol=0)
        row = row + len(dataframe.index) + spaces + 2
    writer.save()

# list of dataframes
df = pd.DataFrame(np.arange(9).reshape(3,3))
df1 = pd.DataFrame(np.arange(10, 19).reshape(3,3))
df2 = pd.DataFrame(np.arange(20, 29).reshape(3,3))
dfs = [df,df1,df2]
comments = ['first', 'second', 'third']

# run function
multiple_dfs(dfs, 'Validation', 'test1.xlsx', 1, comments)

Update as per comment:
def multiple_dfs(df_list, sheets, spaces, comments):
    row = 2
    for dataframe, comment in zip(df_list, comments):
        pd.Series(comment).to_excel(writer,sheet_name=sheets, startrow=row,
                                    startcol=1, index=False, header=False)
        dataframe.to_excel(writer,sheet_name=sheets,startrow=row + 1, startcol=0)
        row = row + len(dataframe.index) + spaces + 2

# list of dataframes and comments
# ...

# run function
writer = pd.ExcelWriter('test1.xlsx',engine='xlsxwriter')
multiple_dfs(dfs123, 'Validation1', 1, comments123)
multiple_dfs(dfs456, 'Validation2', 1, comments456)
writer.save()


text:
Q: Why is there a syntax error in my map iterator? I wrote a template function for flipping my std::map keys and values.
#include <map>
#include <iterator>

template <typename A, typename B>
std::map<B, A> flip_map(std::map<A, B> &src)
{
    std::map<B, A> dst;
    for (std::map<A, B>::iterator it = src.begin(); it != src.end(); ++it)
    {
        dst.insert(std::pair<B, A>(it->second, it->first));
    }
    return dst;
}

VS gives me a syntax error:

unexpected token 'identifier', expected ';'

I don't know what I'm doing wrong.

A: GCC tells you more clearly what's wrong: you need typename there, for arcane C++ reasons.
Like this:
for (typename std::map<A, B>::iterator it = src.begin(); it != src.end(); ++it)
//   ^^^^^^^^

Further reading:

*

*Where and why do I have to put the "template" and "typename" keywords?

I'd instead write it like this:
#include <map>

template <typename A, typename B>
std::map<B, A> flip_map(const std::map<A, B>& src)
{
    std::map<B, A> dst;

    for (const auto& p : src)
        dst.insert(std::make_pair(p.second, p.first));

    return dst;
}

In fact, as it happens, I did; two weeks ago. :)
(You could also consider some .emplace and std::move etc, depending on what A and B are likely to be, though since you cannot move from a map key this is only ever going to be "sort of useful".)

A: The reason is that std::map<A,B>::iterator is a dependent name (in rough terms, it is in a templated function, and depends on A and B which are parameters of that template).   So it needs to be preceded with the typename keyword.
template <typename A, typename B>
std::map<B, A> flip_map(std::map<A, B> &src)
{
    std::map<B, A> dst;
    for (typename std::map<A, B>::iterator it = src.begin(); it != src.end(); ++it)
    {
        dst.insert(std::pair<B, A>(it->second, it->first));
    }
    return dst;
}

Additionally you would probably be better specifying src as const, and using const_iterator rather than iterator, viz
template <typename A, typename B>
std::map<B, A> flip_map(const std::map<A, B> &src)
{
    std::map<B, A> dst;
    for (typename std::map<A, B>::const_iterator it = src.begin(); it != src.end(); ++it)
    {
        dst.insert(std::pair<B, A>(it->second, it->first));
    }
    return dst;
}

or (C++11 and later), let the compiler do the type deduction for you by using auto and std::make_pair.  This avoids need for the programmer to worry about dependent names.
template <typename A, typename B>
std::map<B, A> flip_map(const std::map<A, B> &src)
{
    std::map<B, A> dst;
    for (const auto &e : src)
    {
        dst.insert(std::make_pair(e.second, e.first));
    }
    return dst;
}


text:
Q: Time a while loop python I'm trying to time a while loop within a while loop, total time it takes to execute, and record the time it takes to do so, every time it loops. I need a way to achieve this using my code if possible, or open to different concepts I may not know of yet.
import random
import time
import sys

def main():

    looperCPU = 500
    start = time.time()
    while (looperCPU != 0):
        #start = time.time()

        #this is the computation for 3 secs
        time.sleep(3)
        random_number = random.randint(0,1000)

        #Send to printer for processing
        #.75 secs to 4.75 secs to generate a pause before printing
        secondsPause = random.uniform(.75,4.75)

        #This is the printer function
        printerLooper = True
        while printerLooper == True :
            print("Sleeping for ", secondsPause, " seconds")
            print(random_number)
            printerLooper = False

        #
        print("total time taken this loop: ", time.time() - start)
        looperCPU -= 1

main()

The loop will print a time, but I'm very certain it is not taking into account the nested while loop sleep time. How can I allow python to time both while loops, every loop that it will need to do (in this case 500)?

A: In python you may look into this doc https://docs.python.org/2/library/timeit.html
Stackoverflow example: How to use timeit module
import timeit
timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)

In Jupyter notebook,
%%timeit -n 100
import pandas as pd
s = pd.Series([101.00, 121.00])
summary = 0
for item in s:
    summary+=item

A: When you set start outside your initial loop you are guaranteeing that you are getting the incorrect time it takes for the while loop to execute. It would be like saying:
program_starts = time.time()
while(True):
    now = time.time()
    print("It has been {0} seconds since the loop started".format(now - program_starts))

This is because start stays static for the entire execution time while your end time is steadily increasing with the passing of time.
By placing start time within the loop you ensure that your start time is also increasing as the program runs.
while (looperCPU != 0):
    start_time = time.time()
    # Do some stuff
    while printerLooper == True :
        print("Sleeping for ", secondsPause, " seconds")
        print(random_number)
        printerLooper = False
    end_time = time.time()

    print("total time taken this loop: ", end_time - start_time)

A: Right idea, but your placement of the timing functions is a wee bit off, I've corrected it here:
import random
import time import sys

def main():

    looperCPU = 500
    start = time.time()
    while (looperCPU != 0):
       #this is the computation for 3 secs
       time.sleep(3)
       random_number = random.randint(0,1000)

       #Send to printer for processing
       #.75 secs to 4.75 secs to generate a pause before printing
       secondsPause = random.uniform(.75,4.75)

       #This is the printer function
       printerLooper = True
       myStart = time.time()
       while printerLooper == True :
          print("Sleeping for ", secondsPause, " seconds")
          print(random_number)
          printerLooper = False
          print("total time taken this loop: ", time.time() - myStart)

       looperCPU -= 1
main()

A: You can use this pytictoc. install using pip or conda. read documentation on pytictoc. It works like matlabs tic toc. basically just start timer with tic and end with toc. and u can print it directly or store it in a new variable.
from pytictoc import TicToc
def main()
    t = TicToc()  # create instance of class
    start_time= t.tic() #start timer
    while ():

    #end of while loop

    end_time = t.toc()
    print("end_time", end_time)


text:
Q: How to configure SSIS merge Join transformation
The Excel Source has a column (ExcelColumn1) of type Unicode text stream[DT_NTEXT] and  the OLE DB Source has a column(SQLColumn1) of type Unicode string[DT_WSTR]
I want to match and merge join results from the above two sources where

ExcelColumn1 = SQLColumn1

I have right clicked both sources, went to thier Advanced Editor dialogues, then to their input and output properties, then output columns, then the columns i want to sort by and set their sortkeyPosition from 0 to 1.
The isSorted property for both sources has also been set to True, but when i double click the Merge Join so i can configure the columns on which to join on, i am getting the error in the screenshot below. I can't seem to figure out what is wrong with my sources.

A: Drag a Sort component for both the inputs : the sortid should be the same on the columns where you make a join,then configure merge join component.
see these links
1.http://www.bimonkey.com/2010/10/the-merge-join-transformation/
2.http://www.mssqltips.com/sqlservertip/1322/merge-multiple-data-sources-with-sql-server-integration-services/
If the error is with mismatch data type drag a Type conversion component and try joining with copy of column with other input !


text:
Q: Connect to DB (Derby) I try to connect to the database with this code:
      try
    {
        Class.forName("org.apache.derby.jdbc.ClientDriver");
        String url = "jdbc:derby://localhost:1527/sample";
        Connection con = DriverManager.getConnection(url);
        PreparedStatement pstmt=con.prepareStatement("insert into app.discount_code values('A',22)");
        pstmt.executeUpdate();
        con.close();
    }

    catch(Exception e)

    {
         System.out.println(e.getMessage());

    }

..but not result.  What do I need to do to connect to the DB?

A: Sir, You are connecting to derby network server. So you need to firstly config the environment and start the network server. Please also check the jdbc driver jars are correct.
About how to config and start derby network server.Look at here.
http://db.apache.org/derby/papers/DerbyTut/ns_intro.html#ns_config_env
Also you'd better put the close method in your finally block.
You'd better paste your error message, it wil be helpful to find your problem.


text:
Q: SQLAlchemy: operator LIKE and custom types I use sqlalchemy ORM. I have following custom column type and table-mapped class:
class JSONEncodedDict(TypeDecorator):
    impl = VARCHAR

    def process_bind_param(self, value, dialect):
        if value is not None:
            value = json.dumps(value)

        return value

    def process_result_value(self, value, dialect):
        if value is not None:
            value = json.loads(value)
        return value

Base = declarative_base()
class Task(Base):
    __tablename__ = 'tasks'

    id = Column(INT, primary_key=True)
    description = Column(JSONEncodedDict)
    created = Column(TIMESTAMP)
    updated = Column(TIMESTAMP)

I want to query objcts using operator 'like':
tasks = session.query(Task).filter(Task.description.like("%some pattern%")).all()

But as far as I can see, method process_bind_param also converts parameter of like operator. so in sql trace I see
...WHERE description LIKE '"%some pattern%"'
instead of
...WHERE description LIKE '%some pattern%'
so no rows are matched.
How can I execute a query with LIKE operator the way I want?

A: It's possible to get around automatic type processing (or force your own with type_ argument) using literal():
Task.description.like(literal("%some pattern%"))

A: Another way is to coerce the column to a textual form using cast() or type_coerce() before attempting to use operator like like, contains or something else:
from sqlalchemy import type_coerce, String

stmt = select([my_table]).where(
    type_coerce(my_table.c.json_data, String).like('%foo%'))

or you can do this in your custom type class defination:
from sqlalchemy.sql import operators
from sqlalchemy import String

class JSONEncodedDict(TypeDecorator):

    impl = VARCHAR

    def coerce_compared_value(self, op, value):
        if op in (operators.like_op, operators.notlike_op):
            return String()
        else:
            return self

    def process_bind_param(self, value, dialect):
        if value is not None:
            value = json.dumps(value)

        return value

    def process_result_value(self, value, dialect):
        if value is not None:
            value = json.loads(value)
        return value

ref: doc


text:
Q: SQL: Retrieve Values if different from prior date I have the following Table:
Date_            Value_
2013-07-13       100055
2013-07-14       100055
2013-07-15       120060
2013-07-16       115040
2013-07-17       115040
2013-07-18       130005

I would like to return the first value in my results and every change.
Desired output:
Date_            Value_
2013-07-13       100055
2013-07-15       120060
2013-07-16       115040
2013-07-18       130005

Thanks for the help!

A: You are looking for group by clause and min function
select min(Date_) as Date_, Value_
from tab
group by Value_


text:
Q: How to convert nvarchar m/d/yy to mm/dd/yyyy in SQL Server? Input is nvarchar that varies in format from m/d/yy to mm/dd/yyyy. How can this be converted to mm/dd/yyyy in SQL? So far the CONVERT() function works for the format m/d/yyyy but errors for m/d/yy.

A: Cast it as a date like so:
cast(@m + '/' + @d + '/' + @y as datetime)

or similarly
cast('m/d/yy' as datetime)

cast(Fieldnamehere as datetime)

A: update table_name set column_name = convert(varchar,cast(column_name as date),101)  or if a select statment select convert(varchar,cast(column_name as date),101)

A: There's usually some additional nuances in the data, but here's a starter template I've been able to come up with... Just replace the debug text with convert(datetime2, [DateNVarChar], 101).
CASE
    -- x/y/zzzz to xx/yy/zzzz
    WHEN SUBSTRING([DateNVarChar], 2, 1) = '/' AND SUBSTRING([DateNVarChar], 4, 1) = '/' THEN
        'x/y/zzzz: ' + '0' + SUBSTRING([DateNVarChar], 1, 2) + '0' + SUBSTRING([DateNVarChar], 3, 20)

    -- xx/y/zzzz to xx/yy/zzzz
    WHEN SUBSTRING([DateNVarChar], 3, 1) = '/' AND SUBSTRING([DateNVarChar], 5, 1) = '/' THEN
        'xx/y/zzzz: ' + SUBSTRING([DateNVarChar], 1, 3) + '0' + SUBSTRING([DateNVarChar], 4, 20)

    -- x/yy/zzzz to xx/yy/zzzz
    WHEN SUBSTRING([DateNVarChar], 2, 1) = '/' AND SUBSTRING([DateNVarChar], 5, 1) = '/' THEN
        'x/yy/zzzz: ' + '0' + [DateNVarChar]

    ELSE
        'Normal: ' + [DateNVarChar]
END as [FormattedDate]


text:
Q: IE throws an exception on "self = this" in JavaScript? I have some objected oriented JS that works fine in firefox but not in IE 8 (though it will be IE 9 that we will need to support).
When I do:
 "self = this;"
  IE flags that as an error.
  I am trying to set this to self to then use it in a jquery callback to call some other
 method in my JS object.
this.upd_params = function () {
   $("#add-parameter-modal").modal('hide');

   var param_form = $('#add_param_form');
   self = this;
   this.added_params = [];
   this.removed_params = [];

   $('.unused_parameter').each(function (index, obj) {
     if (obj.checked) {
       id = self.get_idnum(obj.id);
       self.add_param2list(id);
     }
   });

   $('.used_parameter').each(function (index, obj) {
     if (!obj.checked) {
       id = self.get_idnum(obj.id);
       self.remove_param(id);
     }
   });

   this.upd_html();

   cfg_form_changed = true;

};

A: Okay, i'm posting this because i believe its related and can be useful to others,
if you do inline variable assigning, as the code below:
var var1 = value1,
    var2 = value2,
    self= this;

it will throw an Exception on IE saying Not Implemented.
You can fix it by changing to something like this:
var var1 = value1,
    var2 = value2;

var self= this;

A: Make sure self is a locally-scoped (not global) variable.
var self = this;

Otherwise, self refers to window.self and assigning to it is not allowed.


text:
Q: Dozer Mapping Ignore Hibernate Lazy Loading - Spring I am using Apache CXF with Spring and Dozer Mapper to convert DTOs (Database Objects) in to models. For Hibernate side I have enabled lazy="extra" and lazy="true" for mapping and which works fine hibernate loads child whenever respective getter methods are called. But when I convert DTO using dozer mapper it calls getter methods of all the child object in some case it was not necessary but in some it is not necessary. Is there any way by using which I can reduce overheads.

A:
Fetch(load) child's always in every call results to heavy process and
  unnecessary data to persist. So instead of doing this always fetch
  data as lazy and initialize child's model whenever there is
  need. This is the best way to fetch data.

A: If you convert entities to DTOs, you have two options:

*

*do not use lazy collections

*ignore the collections when serializing, if you don't want them in the output


text:
Q: Is using a back door product key piracy? There are several programs that have a universal serial key to register. Now lets say I downloaded a trial for one of these (in this case Visual Studio 2012) from the developer (microsoft) and registered it with a backdoor product key. Is that illegal or not (and can I please have a response from someone who knows what there talking about....)

A: By "backdoor key" I assume you mean one of the following:

*

*A key generated by the software owners for use by its development team for testing, that has been leaked (or you sneaked).

*A key intended to be hidden within the install process of an "unlocked" copy of the software, such as copies issued to site licensees.

It's illegal. What you have done is no different legally than "borrowing" your company's MSDN/TechNet copy of VS2012, or finding a cracked key on a Warez resource.


text:
Q: difference between int( (n+1)/2 ) and (n+1)//2? In python for a problem https://www.spoj.com/problems/APM i used
t = int(input())
while t > 0:
    n= int(input())

    if n%2 == 0:
        print(-1)
    else:
        n = int((n+1)/2)
        print(n,n-1)
    t -= 1

this code and rejected,
but for this :
t = int(input())

while t > 0:
    n= int(input())

    if n%2 == 0:
        print(-1)
    else:
        n = (n+1)//2
        print(n,n-1)
    t -= 1

accepted, my question is why int((n+1)/2) gives different ans then (n+1)//2 at large number n< 10^18?

A: Even though for small n, it is true that int(n*(n-1)/2) == n*(n-1)//2, that can fail for large n. The reason why is that / is floating point division, which can result in loss of information, information that int() can't recover:
>>> n = 10**18 - 1
>>> n*(n-1)
999999999999999997000000000000000002
>>> n*(n-1)//2
499999999999999998500000000000000001
>>> n*(n-1)/2
5e+35
>>> int(n*(n-1)/2)
500000000000000021210318687008980992

The loss of information can be seen in 5e+35 vs. 499999999999999998500000000000000001

A: Consider:
import sys

print(sys.float_info)

i=(10**17+2)/2
j=(10**16+2)/2

print(i,j)
print(type(i), type(j))

i,j=int(i),int(j)

print(i,j)
print(type(i), type(j))

Although you're far from reaching float limits - you reached limit of digits that float can store - so everything after this limit will just get truncated in the exponential notation - so it will be the same magnitude of values, yet all the excessive numbers from the back will be 0.
Conclusion:
Converting types requires great care to detail - just use \\ instead.

A: The double slash in Python performs integer division, whereas the single slash performs regular old division which may yield a float.
I don't see anywhere in the question you linked to that requires you to have an integer answer, but I imagine the author wanted it to be this way to prevent any floating point precision errors preventing the automated test cases from being successful.


text:
Q: jQuery Syntax error, unrecognized expression I have a script that updates a fixed menu with the user's position as they scroll down the page. Working on the front-end was error free, however now that I have started working on the WordPress integration I am getting a bizarre error message which I am having trouble understanding.
One loading the page it is fine, however as soon as I scroll down the error appears.
Here is the jsfiddle. http://jsfiddle.net/2k4Eq/
It seems to be related to the full URL, as it works with just #whatWeDo.
Syntax error, unrecognized expression: http://localhost:8888/sitename/#whatWeDo

From jQuery
 Sizzle.error = function( msg ) {
    throw new Error( "Syntax error, unrecognized expression: " + msg );
 };

Thank you!
// Update menu position on scroll
    $(function() {
        function updateMenu() {

            var lastId,
                mainMenu = $("#main-menu ul"),
                mainMenuInnerHeight = mainMenu.outerHeight(),
                mainMenuItems = $("#main-menu.navigation ul").find(".section-item a"),
                sliderButtons = $("#call-to-actions "),
                sliderLinks = sliderButtons.find("a.button.white"),

                // Anchors relating to links
                scrollItems = mainMenuItems.map(function(){
                  var item = $(this).attr("href");
                  if (item.length) { return item; }
                });
                console.log(scrollItems);

            mainMenuItems.bind("click",scrollDown);
            sliderLinks.bind("click",scrollDown);

            function scrollDown(e){
                e.preventDefault();

                var href = $(this).attr("href"),
                    offsetTop = href === "#" ? 0 : $(href).offset().top;

                $("html, body").stop().animate({
                    scrollTop: offsetTop
                }, 600);

                $("#main-mobile-menu").hide();

            }

            $(window).scroll(function(){
                var fromTop = $(this).scrollTop()+mainMenuInnerHeight;

                var cur = scrollItems.map(function(){
                    if ($(this).offset().top < fromTop)
                        return this;
                });

                cur = cur[cur.length-1];

                var id = cur && cur.length ? cur[0].id : "";

                if (lastId !== id) {
                    lastId = id;

                    mainMenuItems
                        .parent().removeClass("active")
                        .end().filter("[href=#"+id+"]").parent().addClass("active");
                }
            });

        }

        updateMenu();
        $(window).resize(function(){
            updateMenu();
        });
    });

A: The issue was caused by trying to use full URL other than just the hash and ID. By splitting the results and only using the anchor ensured the script still ran, but also meant navigating to the correction homepage section from another page still worked. Thanks to those who helped as it got me thinking and eventually lead me down the right path.
$(function() {
function updateMenu() {

    var lastId,
        mainMenu = $("#main-menu ul"),
        mainMenuInnerHeight = mainMenu.outerHeight(),
        mainMenuItems = $(".home .navigation ul").find("li.section-item a"),

        scrollItems = $(".navigation li.section-item a").map(function() {
            itemsSplit = $(this).attr("href").split("#");
            itemHref = $("#" + itemsSplit[1]);

            return itemHref;
        });

    mainMenuItems.bind("click",scrollDown);

    function scrollDown(e){
        e.preventDefault();

        var href = $(this).attr("href").split("#"),
            hrefSplit = href[1],

            offsetTop = $("#" + hrefSplit).offset().top;

        $("html, body").stop().animate({
            scrollTop: offsetTop
        }, 600);
    }

    $(window).scroll(function(){

        var fromTop = $(this).scrollTop()+mainMenuInnerHeight;

        var cur = scrollItems.map(function(){
            if ($(this).offset().top < fromTop)
                return this;
        });

        cur = cur[cur.length-1];

        var id = cur && cur.length ? cur[0].id : "";

        if (lastId !== id) {
            lastId = id;

            mainMenuItems
                .parent().removeClass("active")
                .end().filter("[href$="+id+"]").parent().addClass("active");
        }
    });
}

updateMenu();
$(window).resize(function(){
    updateMenu();
});
});

A: From what I can see the problem is in the fllowing .filter(), where id is the value http://localhost:8888/sitename/#whatWeDo. The cause of the error is the special characters within the attribute value
mainMenuItems.parent().removeClass("active").end().filter("[href=#" + id + "]").parent().addClass("active");

'
so wrap the attribute value like a string literal to escape it.
mainMenuItems.parent().removeClass("active").end().filter('[href="#' + id + '"]').parent().addClass("active");

Since @Curt deleted the answer I'm just coping that too for the OP to see(will delete this if Curt undelete's it)
The above said issue can also come in the following line
$(href).offset().top

href is a string value. Change this to:
$(this).offset().top

A: jQuery.map()
Description: Translate all items in an array or object to new array of items.
var cur = scrollItems.map(function(){
    if ($(this).offset().top < fromTop)
        return this;
});

change it to:
var cur = $.map(scrollItems, function () {
    if ($(this).offset() != null) {
        if ($(this).offset().top < fromTop) return this;
    }
});


text:
Q: Inheritance in camel routes I have a set of microservices and I want to have a common camel route end point to serve the request
Same my microservices are
1. Student
2. Teacher
3. HouseKeeping
All these microservices have common CRUD methods and their own custom methods.
Is it possible to design something like
class MasterRoute extends RouteBuilder{
  //Route for All CRUD methods
}

class Student extends RouteBuilder{
  //Inherited common routes
  from ( "overridden get route from the Master Route").log( "does it make sense?? ");

  from("a custom route specific to student").log( "does it make sense?? ")
}


text:
Q: How do I connect to mongodb on MacOS after adding configurations for replica set? I want to tail mongo collection's documents and in order to do so, I need to activate the oplog. Oplog requires some extra configuration in the mongod.conf file and these configurations are not letting mongo connected.
I tried to look into questions pertaining to tailing mongodb, setting conf file but none could address my need of connecting to mongodb after setting replciaset configs.
My conf file, location of which is /usr/local/etc/mongod.conf is:
systemLog:
  destination: file
  path: /usr/local/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath: /usr/local/var/mongodb
net:
  bindIp: 127.0.0.1
replSet=rs0
oplogSize=1024

I am not getting anything in logs, brew services list command also shows the following:
mongodb   started aviralsrivastava /Users/aviralsrivastava/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

Although, when rs0 is set, the started signal is yellow in color, with the last two lines commented, its green.
I expect mongodb to get connected, mongo shell to start but all I get is connection refused. If I comment the last two lines, mongo gets connected. And yes, I did restart mongodb via brew services restart mongodb each time I changed the config file.
Following is the error when I try to connect via command mongodb:
➜  etc mongo
MongoDB shell version v4.0.3
connecting to: mongodb://127.0.0.1:27017
2019-04-27T08:53:31.350+0530 E QUERY    [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed

A: mongod --config path/to/config-file-portx --replSet rsName
connect:
mongo --port xxx
config:
config:
rs.initialize();
rs.add(host:port-y);
rs.status()

connect with replica:
mongo "mongodb://host1,host2,host3/myDB?replicaSet=rsName"


text:
Q: Typescript: Override property type from library - got error Subsequent property declarations must have the same type I want to override property type from library declaration, i try to override using interface but i got error Subsequent property declarations must have the same type. How should i do to solve this issue?
// this is library declaration
declare class Auth {
    user: Record<string, string | number> | null
    // i want to remove null type in user property, because i dont want to use `non-null assertion` in line 21
    // i cant change this file because it is 3rd party library
}

// ------------------------------

// our file

// my override interface, but fail
interface Auth {
    user: Record<string, string | number>
}

const a: Auth = {
    user: {
        name: 'joko',
        age: 30
    }
}

const userName = a.user!.name
// const userName = a.user.name // <-- i want use like this, because i'm sure that this property is always available

I've tried to override library decalaration using interface but it fail. My expected result is the type can be overriden without touching or change the library, only by using our code.

A: Hi @Bagaskara,
why are you not doing like that.
Interface to extend the Auth class and override the type of the user property.
interface MyAuth extends Auth {
    user: Record<string, string | number>
}

In your file:-
const a: MyAuth = {
    user: {
        name: 'joko',
        age: 30
    }
}

If you want to override a variable that has been declared in a library, you can do so by declaring a new variable with the same name in your code.

note that this is not library file. its your code file.

In your code file.
const userName = a.user.name;

So, that const userName = a.user.name; declared in your code will be used instead of the one from the library which is that const userName = a.user!.name;.

A: I have solved by my self. In my case, i want to override Auth interface on nuxt-auth module. Here is the solution:

*

*Duplicate modules types from node_modules, to our type file. Then change the appropriate interface (change Auth to IAuth). IAuth is our modified interface.

import { IAuth } from '~/interface/auth/model';

export * from '@nuxtjs/auth-next/dist';

declare module 'vue/types/vue' {
  interface Vue {
    $auth: IAuth;
  }
}

// rest of the file

*Add file above as paths in tsconfig.json, so typescript will use that file instead of original module types.

"compilerOptions": {
// ...
"paths": {
    "@nuxtjs/auth-next": [
        "types/nuxt-auth.d.ts"
      ],
    // ...
   }
// ...
}

Voila, the type is run as expected using our modified interface


text:
Q: Is it bad practice to duplicate data in JSON? I'd like to store some data in a JSON object and am wondering if it's bad practice to store it in more than one place. Take for example a review site, in a relational database I might have a table for reviews and a table for users. I could connect the two using a join. My goal is to have a Movie page that holds all reviews for that movie and also have users who know about all of their reviews they've written.
{
  "reviews": {
    "movie1": [{
      "author": "user1",
      "review": "Some review..."
    }]
  },
  "users": [{
    "userName": "user1",
    "userReviews": [{
      "movie1": "Some review..."
    }]
  }]
}

Would keeping a reviews object with all reviews for that specific movie (and within each review, an author property) and also a users object with all of their reviews be a bad idea? Data would be duplicated, so wondering what the best way to approach this situation.
Thank you.

A: I'd probably keep the data normalized and refer to the shared content by some sort of key, similar to how Java serialization works.


text:
Q: two images and text overlaping I want to get the same output you can see, for example on genius.com.
There is:

(1) big image
(2) small squares over that image
(3) text (links) plus some small images over (1) and (2)

The difference in what I want to do is that the (1) images are uploaded by users, not posted as static content (e.g. posted as background image, like on genius.com).

Text...

css (an attempt)
.bg-img{width:300px; height:250px;}
.text-plus-links{display:table; margin-top:-250px;...}

/* small image that adds the squares */
opacity: 0.2;
background: asset-url("http://genius.com/images/tooth_bg.png") repeat scroll 0% 0% transparent;

A: First things first if the pictures are going to be uploaded by the users that means you will need a server-side script and potentially somewhere to store the images. You can not store data on the client side since the code is renewed on everypage load (exceptions browser cookies).
Solution1
Here is a static solution to what you are looking.
https://jsfiddle.net/jd6c7fdj/2/
Just change the background-color to background image and set the transparency
However since the the images will be loaded by the user, you have to detect image properties and set everything accordingly
Solution 2
A more elegant solution would be keeping the divs of a static width and height and setting images as their background images
The downside of this is the size of the image will be highly restricted but it will save you a lot of code
Again this is much more elegant
https://jsfiddle.net/e1pktges/1/

 Hello

 yess

 .cover{
   background-color: rgba(0,0,0,0.7);
    z-index: 500;
   position: absolute;
   width: 700px;
   height: 500px;
 }

p{
  color: white;
}

.whatever{
  background-image: url("http://www.lucamartincigh.com/wp-      content/uploads/2010/11/fullscreen-website-template.png");
  width: 700px;
  height: 500px;
}
}


text:
Q: IllegalStateException: impossible to get artifacts when data has not been loaded for Guava 12.0? In a Java Play 2.1.1 app I get the following error:
[myproject] $ update
[info] Updating {file:/C:/path/myproject/}myproject...
[info] Resolving ...
[error] impossible to get artifacts when data has not been loaded. IvyNode = com.google.guava#guava;12.0
[error] (*:update) java.lang.IllegalStateException: impossible to get artifacts when data has not been loaded. IvyNode = com.google.guava#guava;12.0
[error] Total time: 230 s, completed 17.05.2013 19:16:41

Build.scala
"com.google.guava" % "guava" % "14.0.1",
"org.mydependency" % "mydependency" % "1.0-SNAPSHOT" changing() exclude("org.jboss.netty","netty") exclude("com.google.guava", "guava") exclude("log4j", "log4j"),

The thing that causes this error (it all worked fine before) is a dependency change within mydependency:
old:
<dependency>
    <groupId>com.thinkaurelius.titan</groupId>
    <artifactId>titan-berkeleyje</artifactId>
    <version>0.3.1</version>
</dependency>

new:
<dependency>
    <groupId>com.thinkaurelius.titan</groupId>
    <artifactId>titan-cassandra</artifactId>
    <version>0.3.1</version>
</dependency>

I don't want guava 12.0 anyway and it is and was excluded.
Can I tell Play 2.1.1 to use a newer Ivy?
In plugins.sbt I have:
addSbtPlugin("play" % "sbt-plugin" % "2.1.1")

Temporary fix
As someone mentioned here Apache IVY error message? : impossible to get artifacts when data has not been loaded manually adding the dependency solves it: I've added
"com.google.guava" % "guava" % "12.0"

and the problem is gone.

A: Instead of using a lower version, you could try adding this line to .sbt file:
dependencyOverrides += "com.google.guava" % "guava" % "14.0.1"

A: Play 2.1.x uses sbt 0.12, which uses Ivy 2.3.0-rc1, but looks like this is still an issue.
If you can come up with a reproduction steps using publicly available libraries, please open a Github issue with a link to this comment.

A: Apparently more people had and have this issue, so I'm putting my solution as an answer:
Temporary fix
As someone mentioned here Apache IVY error message? : impossible to get artifacts when data has not been loaded manually adding the dependency solves it: I've added
"com.google.guava" % "guava" % "12.0"

and the problem is gone.


text:
Q: How to Horizontally Center View in Landscape orientation? I have an app that was originally written for iPhone 4s landscape mode (480x320) but when I run this in iPhone 5 simulator I see that my app is aligned to the left and there's alot of blank space to the right of it. (vertically, it looks/stretches properly)
I was hoping my app would atleast be centered in landscape mode in iPhone5, any ideas?
Also, I have another app that is in portrait mode (320x480) and in iPhone 5 is does vertically center my app properly. So is this just a problem with landscape?

A: Found it in Size Inspector -> "AutoResizing".
Just had to align the red box correctly


text:
Q: VBA + Adobe Acrobat SDK - Unable to save an empty page? I am using VBA as a platform to do some PDF manipulation. The issue I am having is that I cannot seem to get the PDF object to save if the PDF object have not been opened. Below is a snippet of the code that inserts pages to the PDF object, and then saves the pdf object. In terms of the code, I have determined that it works since I have tested the save method with the same input with another pdf object and it worked just fine. Can someone help by explaining why it doesn't allow me to save the object?
Thanks!
Dim NewPDF As New Acrobat.AcroPDDoc
Set NewPDF = CreateObject("AcroExch.PDDoc")
If NewPDF.InsertPages(j, OriPDF, j, 1, 0) Then MsgBox "Success"
If NewPDF.Save(PDSaveLinearized, WritePath & "\" & sh.Cells(StartRow + j - 1, i).Value & ".pdf") Then MsgBox "Success"
NewPDF.Close
Set NewPDF = Nothing

When the above code was ran, neither of the success lines worked as expected.

A: Change line 3 to this...
If NewPDF.InsertPages(-1, OriPDF, j, 1, 0) Then MsgBox "Success"

The first parameter is the location after which the new pages get inserted but you have no pages because the document is empty so there is no page zero.


text:
Q: Java physics triangles okay, i cannot post images yet :/
Basically, i have an application with three edittext fields, three check boxes, a calculation button and a text field to output the answer. i want the program to scan to see which value is missing, so that from this it know which calculation it should do. Another method would be for the user to check one of the checkbox's and then the program would only run the calculation for the corresponding checkbox.
for instance, if the user inputs Q = 10, T = 2, and checks the checkbox for I, the program would then do the math and display I = 20 ?
this make much sense yet
i spose in psuedo code it would look like
" if checkbox one is checked and values for Q and T have been entered, then calculate value for I and display in answers field" however i will be adding some error checks and validation methods in there.
if you need the xml file and java file then please ask, im just looking for a method at the moment as to how i could do it, i wouldnt expect you all to waste your free time writing a whole program for me.
cheers guys and girls
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background1"
android:gravity="fill"
android:orientation="vertical"
android:textColor="#ffffff"
tools:context=".CurrentPage" >

<!--
     The primary full-screen view. This can be replaced with whatever view
     is needed to present your content, e.g. VideoView, SurfaceView,
     TextureView, etc.
-->

<!--
     This FrameLayout insets its children based on system windows using
     android:fitsSystemWindows.

-->

    <TextView
        android:id="@+id/Current_hint"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:layout_marginTop="33dp"
        android:text="Welcome to the Current Calculation page."Hint - Use the check boxes to find the values that are missing "
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#ffffff"
        tools:ignore="HardcodedText" />

    <TextView
        android:id="@+id/Equation_letter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/current_calculate"
        android:layout_marginTop="37dp"
        android:layout_toLeftOf="@+id/current_calculate"
        android:text="     HELLO  "
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#ffffff"
        tools:ignore="HardcodedText" />

    <TextView
        android:id="@+id/Distances_answer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/Equation_letter"
        android:layout_alignBottom="@+id/Equation_letter"
        android:layout_alignLeft="@+id/current_calculate"
        android:layout_alignParentRight="true"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#ffffff" />

    <TextView
        android:id="@+id/t"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Q"
        android:layout_alignRight="@+id/Q"
        android:layout_below="@+id/Q"
         android:layout_marginTop="36dp"
        android:gravity="right|top"
        android:text="t ="
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#ffffff"
        tools:ignore="HardcodedText" />

    <CheckBox
        android:id="@+id/custom3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/t"
        android:layout_alignLeft="@+id/custom2"
        android:background="@drawable/check_box_new"
        android:button="@drawable/check_box_new" />

    <CheckBox
        android:id="@+id/custom1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/number_input_3"
        android:layout_alignLeft="@+id/custom3"
        android:background="@drawable/check_box_new"
        android:button="@drawable/check_box_new" />

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Current_hint"
        android:layout_alignRight="@+id/Current_hint"
        android:layout_below="@+id/Equation_letter"
        android:layout_marginTop="25dp" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/CurrentmainHelp"
                android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1.31"
                android:text="HELP! This equation can be used to calculate the current of an object in amps. The correct equation to discover amps is I=Q/t. Where I = current, Q = charge flowing past a point in the circuit, and t = time taken for the charge to flow. Please note, Q is measure in coulombs and t is measured in seconds, with I being measured in amperes.

    Still need more help? "
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="18sp"
                tools:ignore="HardcodedText" />

            <Button
                android:id="@+id/Yes_Please"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="36dp"
                android:layout_weight="1.31"
                android:onClick="CurrentHelp"
                android:text="Yes Please"
                android:textColor="#ffffff" />

        </LinearLayout>

    </ScrollView>

    <Button
        android:id="@+id/current_calculate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/Calculate_Current"
        android:textColor="#ffffff"

        />

    <EditText
        android:id="@+id/number_input_2"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_above="@+id/t"
        android:layout_alignLeft="@+id/number_input_1"
        android:layout_alignRight="@+id/number_input_1"
        android:ems="10"
        android:focusable="true"
        android:inputType="numberDecimal"
        android:textColor="#ffffff" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/number_input_3"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/t"
        android:layout_alignLeft="@+id/number_input_2"
        android:layout_alignRight="@+id/number_input_2"
        android:ems="10"
        android:focusable="true"
        android:inputType="numberDecimal"
        android:textColor="#ffffff" />

    <CheckBox
        android:id="@+id/custom2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/number_input_1"
        android:layout_marginLeft="45dp"
        android:layout_toRightOf="@+id/number_input_1"
        android:background="@drawable/check_box_new"
        android:button="@drawable/check_box_new" />

    <EditText
        android:id="@+id/number_input_1"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_above="@+id/Q"
        android:layout_alignRight="@+id/current_calculate"
        android:ems="10"
        android:focusable="false"
        android:inputType="numberDecimal"
        android:singleLine="true"
        android:textColor="#ffffff" />

    <TextView
        android:id="@+id/Q"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Equation_letter"
        android:layout_below="@+id/I"
        android:layout_marginTop="36dp"
        android:gravity="right|top"
        android:text="Q ="
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#ffffff"
        tools:ignore="HardcodedText" />

    <TextView
        android:id="@+id/I"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Q"
        android:layout_alignRight="@+id/Q"
        android:layout_below="@+id/Current_hint"
        android:layout_marginTop="65dp"
        android:gravity="right|top"
        android:text="I ="
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#ffffff"
        tools:ignore="HardcodedText" />

okay, that was the xml, and this is the java so far
    package com.kieran.whetherfieldphysicscalculator;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import android.support.v4.app.NavUtils;
// i=q/t this will be the first calculation on the list

public class Current extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_current);
            // Show the Up button in the action bar.
            setupActionBar();

          Button calc1 = (Button)findViewById(R.id.current_calculate);

            calc1.setOnClickListener(new View.OnClickListener() {

                 public void onClick(View v) {

                    EditText Charge1 = (EditText)findViewById(R.id.number_input_2);
                    EditText Time1 = (EditText)findViewById(R.id.number_input_3);
                    TextView Distances_answer = (TextView)findViewById(R.id.Distances_answer);
                    double charge = Double.parseDouble(Charge1.getText().toString());
                    double time = Double.parseDouble(Time1.getText().toString());
        //Time is a class in Java
                    Distances_answer.setText("" +charge*time);

                }
            });
        }

    public void CurrentHelp(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, CurrentHelp.class);
        startActivity(intent);
    }
    /**
     * Set up the {@link android.app.ActionBar}.
     */
    private void setupActionBar() {

        getActionBar().setDisplayHomeAsUpEnabled(true);

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            // This ID represents the Home or Up button. In the case of this
            // activity, the Up button is shown. Use NavUtils to allow users
            // to navigate up one level in the application structure. For
            // more details, see the Navigation pattern on Android Design:
            //
            // http://developer.android.com/design/patterns/navigation.html#up-vs-back
            //
            NavUtils.navigateUpFromSameTask(this);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}

I am asking if there is an easier way to formate the program to find the values, rather than have to code each individual segment?
cheers

A: In your case I guess that you want the user to check only one checkbox and only answer corresponding to that checkbox should be displayed to the user.
so for that you would need to set OnClickListener on checkbox so that the corresponding operation is selected.
Read here on how to set listener on checkbox and use it. Paticularly look for the addListenerOnChkIos() method as it has the code you want.
 Also set another OnClickListener on the calculate button and in that check which checkbox is checked depending on which you will perform the operation and update the textview.