text:
Q: Inherited an AWS Lambda project. What does lambdazip.sh file do & where in AWS do I need to upload it? EDIT:
So lambda function projects can be uploaded as zip files.
I think this lambdazip.sh is a shell script used to zip the project. I have been manually zipping the project through the Finder on my MacOS.
After I cd to my /bin, I run
sh lambdazip.zip

But I get the following error:
stephenstilwell@Stephens-MacBook-Air bin % sh lambdazip.sh
lambdazip.sh: line 6: cd: /lib/python2.7/site-packages/: No such file or directory
    zip warning: name not matched: pypdftk*

zip error: Nothing to do! (/Users/stephenstilwell/Downloads/cl_boost-pdfgen-1.3.3-master/bin/dist/cl-boost.zip)
    zip warning: name not matched: bin

zip error: Nothing to do! (try: zip -r /Users/stephenstilwell/Downloads/cl_boost-pdfgen-1.3.3-master/bin/dist/cl-boost.zip . -i bin)
    zip warning: name not matched: boost*
    zip warning: name not matched: pdf_surveys

zip error: Nothing to do! (/Users/stephenstilwell/Downloads/cl_boost-pdfgen-1.3.3-master/bin/dist/cl-boost.zip)

So I've been given a zipped file with no real instructions or documentation on what to do with the codebase.
My task is to get this project all set up on AWS.
The AWS Services in use will be Lambda, S3, Api Gateway, Simple Email Service.
To my current knowledge, I think this .sh file may have been used to test the lambda function locally before deployment to AWS Lambda, but I'm not sure.
Does this file need to be uploaded to the lambda function?
Does it belong in a Lambda Layer?
What is its purpose and why did the past developer use it?

lambdazip.sh
#!/bin/bash
PYTHON_PATH=$VIRTUAL_ENV/..
BASE_PATH=$PWD

cd $VIRTUAL_ENV/lib/python2.7/site-packages/
zip -x "*pyc" -r9 $BASE_PATH/dist/cl-boost.zip pypdftk*

cd $BASE_PATH
zip -r $BASE_PATH/dist/cl-boost.zip bin

cd $BASE_PATH
zip -x "*pyc" -r9 $BASE_PATH/dist/cl-boost.zip boost* pdf_surveys

A: From what I see lambdazip.sh is used to package dependencies from the project's virtual environment and from the project's base path.
What you probably have to do is enable VIRTUALENV for the project by doing something like python2.7 -m virtualenv or following this: enable VIRTUALENV. Afterwards you may want to install the dependencies in your virtual environment using pip. You should be able to run lambdazip.sh afterwards successfully.

A: It looks like a helper for AWS Lambda function creation.
In case Lambda uses only core Python libraries, it's possible to just copy/paste its code to code editor in AWS Lambda Web UI.
But if you need some extra dependencies, you have two options:

*

*Put the dependencies into so-called AWS Lamda Layer (and then you can copy/paste the function code via UI, plus in Lambda settings you'll have to connect the Layer to the function)

*Put everything (both the function and its dependencies) into a ZIP archive and upload it as a Lambda function

If you choose the second option, you'll not be able to tweak code in visual editor (which may be useful during debugging).
I suggest that the lambdazip.sh creates the ZIP file with the function and dependencies.


text:
Q: when working in Ubuntu it crashes into TTY I am using Ubuntu 11.04 with the default Unity.  I have had it crash into the TTY command prompt (black screen) from just about any program I am using (not program specific).  When it goes into the TTY, I can login in and get to a command prompt, but am unable to return to the GUI.  I am left with no alternative but to use the "sudo reboot" command to reboot the HP Laptop Pavilion dv9000.  Any one having this problem?  I've used 10.04 & 10.10 without any such problem.

A: You can use sudo service gdm restart to get the login screen back. If you use "ps ax grep gnome-session", then you will see if you're still logged in, or if the session has ended. You might want to pay attention and see if you get two gnome-sessions when you log back in. If that's the case, then you can use killall -u username gnome-session to end the old one. (You don't need sudo for that, and replace "username" with your actual username).
But if this happens frequently, then you might want to switch to the Ubuntu Classic session from the login screen, or install Unity 2D from the archives.

redpajama_set_name: RedPajamaStackExchange


text:
Q: split string at every character I want to split every character in a string and output it as comma or tab separated characters:
I need to use file_in and file_out since I have very many lines.
input
TTTGGC
TTTG
TGCAATGG
....
....

output
T,T,T,G,G,C
T,T,T,G
T,G,C,A,A,T,G,G

I have used this, but it prints every character vertically:
  /usr/bin/perl
   use strict;
   use warnings;

    my $data = 'Becky Alcorn';

   my @values = split(undef,$data);

  foreach my $val (@values) {
   print "$val\n";
  }

  exit 0;

A: In R, you can use strsplit and paste:
Strings <- c("TTTGGC","TTTG","TGCAATGG")
vapply(strsplit(Strings, ""), function(x) paste(x, collapse=","), character(1L))
# [1] "T,T,T,G,G,C"     "T,T,T,G"         "T,G,C,A,A,T,G,G"

You can write the output using writeLines, specifying sep = "\n" if required.

A: Your code uses a loop to print the values of @values one per line, so the computer does what you told it to. Try:
print join ",", @values;

or even condense your code all the way down to:
print join ",", split //, $data;

A: Using perl one-liner,
perl -F -lane 'print join ",", @F' file

output
T,T,T,G,G,C
T,T,T,G
T,G,C,A,A,T,G,G

A: awk one-liner:
awk -v FS='' -v OFS="," '$1=$1' file

A: open my $in, '<','in.txt';
open my $out, '>', 'out.txt';

while(<$in>){
    chomp;
    my @split = split(//);
    print $out join ",", @split;
    print $out "\n";
}

A: Here's a quick and easy method that uses base R functions. The documentation for paste actually notes  that paste can be used as the "the opposite" of strsplit
paste0 with collapse = "," is nice here
> txt <- c("TTTGGC", "TTTG", "TGCAATGG")  ## your data
> sapply(strsplit(txt, ""), paste0, collapse = ",")
# [1] "T,T,T,G,G,C"     "T,T,T,G"         "T,G,C,A,A,T,G,G"

A: Or with the stringr package:
txt <- c("TTTGGC", "TTTG", "TGCAATGG")
unlist(str_split(string=txt, pattern= ""))
 [1] ""  "T" "T" "T" "G" "G" "C" ""  "T" "T" "T" "G" ""  "T" "G" "C" "A" "A" "T" "G" "G"


text:
Q: Symmetric Expressions in Roots of Polynomial with Coefficients in Integral Domain Recently I learned about Pisot-Vijayaraghavan numbers, and proofs around them led me to the fact that the sums of $n$th powers of roots of a monic irreducible integer polynomial are integers. I saw a proof, but it used power series, and I thought it must be provable with Galois Theory, so I came up with this shorter proof:
Let $p=\sum_{i=0}^np_ix^i$, $p_n\neq0$ be a monic irreducible integer polynomial with roots $\alpha_1$ to $\alpha_n$, and let $f\in\mathbb{Z}[\alpha_1,...\alpha_n]$ be a symmetric expression in the roots. Then $f$ evaluates to an integers.
By Guass's Lemma we know that $p$ is irreducible in $\mathbb{Q}$ and thus separable. So its splitting field $\mathbb{Q}_f$ is Galois. $f$ is fixed by all automorphisms of $\mathbb{Q}_f$ since they all must fix the set of roots of $p$. Hence, $f\in\mathbb{Q}$. But since algebraic integers form a ring $f$ is an algebraic integer, say a root of integer polynomial $q$. Now $q$ factors in $\mathbb{Q}$ and by Gauss's Lemma, in $\mathbb{Z}$. One of these factors must have root $f$, so we  apply again, until we obtain that $x-f$ is an integer polynomial, so $f\in\mathbb{Z}$.
I was wondering how far this could be generalised. I know it works if we replace $\mathbb{Z}$ with an integral domain of characteristic $0$, and $\mathbb{Q}$ with its field of fractions. However, I was wondering if we could drop the characteristic $0$ condition. My proof does not generalise since it relies on irreducible polynomials being separable.


text:
Q: In Corda transaction, getting command associated with specific state I have a Corda transaction with multiple states and multiple commands. How can I associate each state to its corresponding command?

A: This is what I do for my use-case.
class Reject(val linearIds: List<UniqueIdentifier>) : TypeOnlyCommandData(), Commands

val correspondingStatesToEnforce = tx.inputsOfType<Obligation>()
.filter { it.linearId in command.linearIds }

require(...)

A: There is no mapping of states to commands in a transaction. Each transaction has one or more commands and one or more states, but they are not required to be related in any way.
However, the pattern you will generally see is:

*

*A state's contract checks for a specific command type

*Based on the command's type, the contract checks constraints about the states

For example:
class MyContract : Contract {
    override fun verify(tx: LedgerTransaction) {
        val command = tx.commands.requireSingleCommand<Commands>()

        when (command.value) {
            is Commands.MyCommand1 -> {
                if (tx.inputStates.size != 1)
                    throw IllegalArgumentException("When its a MyCommand1 transaction, there must be one input.")
                TODO("More checking.")
            }

            is Commands.MyCommand2 -> {
                if (tx.inputStates.size != 2)
                    throw IllegalArgumentException("When its a MyCommand1 transaction, there must be two inputs.")
                TODO("More checking.")
            }
        }

    }

    interface Commands : CommandData {
        class MyCommand1 : Commands
        class MyCommand2 : Commands
    }
}


text:
Q: For what real numbers $x > y > 0$ does the series converge Trying to find real numbers $x > y > 0 $ such that
$$\sum _{n=1}^\infty \frac{1}{x^n - y^n} $$
converges.
Been solving for radius of convergence for power series based on one variable, $x$, but this is the first I've seen with two. Tips are appreciated, thank you


text:
Q: import python dependencies in databricks (unable to import module) I am having a sample project mypackg structured as below:
- mypackg
    * appcode
        * __init__.py
        * file1.py
        * file2.py
    * dbutils
        * __init__.py
        * file3.py
    * start_point.py
    * __init__.py

The code packed into mypackg.zip
Working fine on local system testing

*

*added to pyspark via sparkContext.addPyFile('path_to_zip') and ran my job

*ran like an application via spark-submit --py-files 'path_to_zip' myjob.py
But, when I try to do the same on Databricks - I am unable to import the module
import urllib

urllib.request.urlretrieve("https://github.com/nikhilsarma/spark_utilities/blob/master/mydata.zip", "/databricks/driver/mydata.zip")

sc = spark.sparkContext.getOrCreate() and
sc.addPyFile('/databricks/driver/mydata.zip')
sys.path.insert(0, r'/databricks/diver/mydata.zip')
sc = spark.sparkContext.getOrCreate()
sc.addPyFile(r'/databricks/driver/mydata.zip')

from mypackg import start_point

Error:

ModuleNotFoundError: No module named 'mypackg'

A: It was a mistake in my uri. Instead downloading from raw/master, I was downloading from blob/master which was giving me a file I cannot use..


text:
Q: Calling .py file within function I want to run a py file within function.
I have a .py file that name is "style.py" and that file has some arguments such as "image", "gpu", "output" etc.
I run this .py file in terminal like:
!python style.py -gpu 0 -image xyz.png -output abc.png
I want to run this file within function like:
def run_image_py():
   !python style.py -gpu 0 -image xyz.png -output abc.png

Thank you.

A: You can use os module to run commands like you would in terminal.
So for your problem you could do this:
import os

def run_image_py():
   os.system("!python style.py - gpu 0 -image xyz.png -output abc.png")

And the function should return the process return value!

A: you can do it with os module
import os

def run_image_py():
    os.system('!python style.py -gpu 0 -image xyz.png -output abc.png')


text:
Q: High privileges needed: warn or kill when not given? After I find out whether the program is running as root or normal user, and knowing that this program must run with high privileges, I'm wondering if I should keep running although the program will surely fail or exit directly?
Which option and why you think is better?
Thanks and have a nice day.
Are you still confuse?
Summing up: you've got a program that needs high privileges to run. You check through a system call if it is running as root or non-root. Then you find out it does not have the privileges that it needs to run correctly; what would you do? You would exit (returning 1 e.g) or keep going on and warn the user?

A: If you know you'll fail, it's better to write a clear message to the user and exit normally before your app crashes.

A: If it can't do what is meant probably exit.
If it does damage running by not completing because of this certainly exit.
If if does most stuff without root consider a config option to control this.
If it exits as I try to start it I will know and if there is a meaningful error message fix it (you do write a log file, right? :))


text:
Q: HAProxy to use DNS from operating system? I'm using dns names for my backend servers in my hsproxy.cfg like
backend s0
    server server0 server0.x.y.local:8080

backend s1
    server server1 server1.x.y.local:8080

The name resolution works fine after startup. But as soon as the ipadress of a backendserver changes, requests to haproxy take a long time (like 25 seconds) and then respond with 503 (reason: SC). It doesn't update or reresolve the dns names. But a curl on that machine works fine so the operating system updates the ip adress for those dns entries correctly. So it looks like haproxy is caching the ip adress on startup and never changes them.
I'm using haproxy as a pod inside of a kubernetes cluster (not sure if that matters).
From what I read in the offical docs, the libc option should use the operating systems resolve? I have tried putting init-addr libc but it didn't help, haproxy still responds with long running 503 forever while on the machine, dns resolves perfectly.
I have also seen that there are some fine tunings possible when using a resolver entry, where you can configure refresh times etc. Is this possible without hardcode nameservers in haproxy.cfg and just use the ones from the operating system?

A: Seems to be correct that HAProxy does cache the resolved IP unless you tell it otherwise.
As you already found the configuration using a resolver and a custom check interval should do the trick (resolvers dns check inter 1000 and hold valid), but you are also right that this requires a resolvers section as well. Since HAProxy 1.9 you can use parse-resolv-conf to use the local resolver:
resolvers mydns
  parse-resolv-conf
  hold valid 10s

backend site-backend
  balance leastconn
  server site server.example.com:80 resolvers mydns check inter 1000

The HAProxy documentation can help you with further configuration: https://cbonte.github.io/haproxy-dconv/1.9/configuration.html#5.3.2-parse-resolv-conf


text:
Q: jsp access spring mvc resources I have spent the last hours trying to figure out how to access static ressources from a jsp in Spring mvc web application.
Here is a part from my beans config file:
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/css/**" location="/css/" />

now in the first jsp page my css file located at /css/style.css works fine like this:
<link rel="stylesheet" href="css/style.css" type="text/css" />

but in the second jsp page i can't access this image located at /images/logo.gif:

can someone explain how the <mvc:ressources /> works with jsp ?
EDIT:
here is my context
<?xml version="1.0" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <bean name="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
        <property name="exposeContextBeansAsAttributes" value="true" />
    </bean>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName"    value="com.mysql.jdbc.Driver" />
        <property name="url"                value="jdbc:mysql://localhost/test" />
        <property name="username"           value="root" />
        <property name="password"           value="" />
    </bean>

    <bean id="sessionFactory"   class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="mmapp.domain" />
        <property name="hibernateProperties">
            <value>
                hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
            </value>
        </property>
    </bean>

    <bean id="transactionManager"     class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <bean id="jdbcTemplate"     class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
        <constructor-arg ref="dataSource" />
    </bean>

    <bean id="simpledata" class="mmapp.util.SimpleDataProvider" />

    <tx:annotation-driven transaction-manager="transactionManager" />
    <context:annotation-config />
    <context:component-scan base-package="mmapp" />

    <mvc:default-servlet-handler/>
    <mvc:resources mapping="/images/**" location="/images/" />
</beans>

AND my web.xml
<?xml version="1.0" ?>

<web-app version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:shemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <servlet>
        <servlet-name>mmapp</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>mmapp</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

A: The safest way to access resources is to use the jstl core library. At the very least, you can be sure that the correct url is generated in any context. Add the following line of code to your jsp file:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

and change the img tag to use the c:url tag:
<img src="<c:url val="/images/logo.gif" />" alt="anotherimage" />

Make sure your src attribute looks good after you make this change. You'll also have to add the jstl library to your project (probably a good idea since it's pretty standard). Your mvc:resources mapping looks good as far as I can tell.

A: after this
<mvc:default-servlet-handler/>
<mvc:resources mapping="/images/**" location="/images/" />
<mvc:resources mapping="/css/**" location="/css/" />

to get your css/image :
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" />

A: I don't know if that make sense, but here is how I have resolved this:
first my controller looks like:
@Controller
@RequestMapping(value="/reports")
public class ReportsController {

    @RequestMapping(value = "/reporting", method = RequestMethod.GET)
    public String onSubmit() {
        return "home" ;
    }
}

With all configuration listeb above, I just had to change my img tag in my home.jsp from  to , and things worked well, if i remove the value = "/reporting" from my second @RequestMapping it's the  which work!


text:
Q: Date types management mismatch (2-digits year) - on copy/paste user action I find a strange inconsistency when copying-pasting dates on MS Excel, when they have a 2 digits year.
I work on a machine Windows 7 Enterprise 64 bit and my Excel is a 2010 version.
PROBLEM DESCRIPTION: if I write a short-date into any application (let's say the Notepad), and I copy this to Excel, the year will be wrongly interpreted after 2029. Examples:

*

*I write "12/01/29" on Notepad and copy-paste this value on MS Excel: the date will be interpreted as "12/01/2029".

*I write "12/01/31" on Notepad and copy-paste this value on MS Excel: the date will be interpreted as "12/01/1931" (instead of "12/01/1931").

RESEARCH 1 - control panel: After first research, I found an option on the Control Panel / Dates configuration, saying that "if a year is inserted with 2 digits, it will be included between 1997 and 2096". Picture below (it's in French, my system language, but the content is the one I described):

However, even if this setting would lead me to expect a proper conversion of the test-case above, it's not like this.
FURTHER RESEARCH - VBA: VBA is usually inheriting the settings of the hosting application (MS Excel in my case), which is inheriting the setting of the system. For example, if the system language is French, it means that the month of "December" is written as "Décembre". So, if I write this it will work: myDate = DateValue("11-déc-12"), while if I write this it won't work: myDate = DateValue("11-dec-12"). This is clearly because VBA inherits the system language, so it recognizes "décembre" (French) and not "december" (English).
However, if I write this:
myDate = DateValue("12/01/31")

the value will be properly interpreted as 12/01/2031.
FURTHER FINDING: typing manually "12/01/31" on an Excel cell will be properly converted into 2031. So it seems the problem arises on copy-paste only.
MY QUESTION: It seems there's an inconsistency between settings. Could anyone lead me to the proper place to fix this issue once forever, and make sure that the setting "if a year is inserted with 2 digits, it will be between XXXX and YYYY" please? Thank you in advance, don't hesitate to ask more details if needed.


text:
Q: How do I get certain text to appear when a condition is met using XSLT? I'm trying to get Incorrect and Correct to appear at the front of a paragraph when a condition is met.
In the HTML below, in
 when typeof="ktp:Answer is present I need the output for the explanation to start with 'Incorrect' and when typeof="ktp:AnswerCorrect is present the output for the explanation needs to start with 'Correct'.

"I cough in the morning, but it stops."

Captopril is an angiotensin-converting enzyme inhibitor (ACE-I) that has a dry, hacking, persistent cough as an adverse effect. The client reports a morning cough that may or may not be associated with the medication.

"I am waiting to learn the results of my pregnancy test."

ACE-Is are contraindicated in pregnancy. There is a black box warning that states ACE-I can cause injury and even death to a developing fetus. Since the client reports waiting for the results of a pregnancy test, this should be reported immediately to the health care provider.

Here's the part of my XSLT script that transforms this portion of the text. The Incorrect and Correct portion is not working correctly.

                <xsl:for-each select="//xhtml:section[@data-title='Feedback']">

                        <xsl:value-of select="position()"></xsl:value-of>
                        <xsl:text>)</xsl:text>
                        <xsl:choose>
                            <xsl:when test="//xhtml:li[@typeof='ktp:Answer']">

                                <xsl:text> INCORRECT</xsl:text> – <xsl:value-of select="."/>
                </xsl:when>
                         <xsl:otherwise>
                             <xsl:text> CORRECT</xsl:text> – <xsl:value-of select="."/>
                         </xsl:otherwise>
            </xsl:choose>

                </xsl:for-each>

A: I would suggest to write template with match patterns that define the check you have given in your verbal description but in your example it seems instead of test="//xhtml:li[@typeof='ktp:Answer']" you want to check test="ancestor::xhtml:li[@typeof='ktp:Answer']".


text:
Q: QGIS 3.6: variable functions, confusing explanation The documentation (https://docs.qgis.org/3.4/en/docs/user_manual/working_with_vector/expression.html#id31) says:

To use these functions in an expression, they should be preceded by @ character (e.g, @row_number).

map_scale is one of these variables. But if you see the example map_get( item_variables('Map 0'), 'map_scale')it is used without an @
Why is it in this case used without an @?


text:
Q: Angular 2 error Map is not defined I edited my question because it was not clear enough (I think)
I have a simple app in angular2 and I try to run it on Xbox (yes it's possible with the development kit and Visual Studio). I know it works with an angular 1.5 app because I already succeed. So, this is my stack trace when the code run (sorry my VS is partially in french) :

This is my index.html :

And this is my systemjs.config.js :

Because I need to push my app on Xbox I had all js files I need in my visual jsproject BUT I think I forgot one but I don't know which one so... If you have an idea. Thank you !! :)

A: My best guess is that you need to load the ES6 shim in your index.html file(as explained here).
<script src="../node_modules/core-js/client/shim.min.js"></script>

Place it before the zone.js script line(or even base.js).


text:
Q: Spacing between custom command and subsequent text I have defined a custom command for the name of my project; e.g. \newcommand{\projectname}{Gizmo}.
When I used the command in my document, I've found that I need to place a ~ after the command in order to provide a space between the command and the text that follows.
For example in my tex document,
The \projectname is on track.

Produces the following pdf output:
The Gizmois on track.

So I have to use a tilda as follows:
The \projectname~is on track.

Which now produces the correct pdf output:
The Gizmo is on track.

Would someone please clarify what is going on and what is the correct (best practice) for dealing with this situation.


text:
Q: AWS Lambda - .Net Core runtime upgrade 2.0 to 2.1 deployment Issue AWS Lambda function upgrade requires me to upgrade to 2.1 to deploy my lambda function changes.
I have done the solution upgrade to dotnet runtime to 2.1 and
serverless runtime with dotnetcore2.1
Still, I am getting the issue on serverless deployment

An error occurred: LambdaFunction - The runtime parameter
  of dotnetcore2.0 is no longer supported for creating or updating AWS
  Lambda functions. We recommend you use the new runtime (dotnetcore2.1)
  while creating or updating functions. (Service: AWSLambdaInternal;
  Status Code: 400; Error Code: InvalidParameterValueException

It works if we deploy newer serverless service. It causes issue with existing function upgrade.

A: *

*Open browser, go into AWS Console/Lambda/Functions/YourFunction .

*On the "Function Code Section" the "Runtime" dropdown must be blank.

*Set it to NetCore 2.1 C# Powershell and Save.

*All done. Upload function as usual.
Why the Visual Studio Tool does not set this by itself when you select the runtime at upload its a mistery.

A: I worked around this issue by changing logical ids of lambdas that I was updating. This way, CloudFormation deletes old lambdas and creates brand new lambdas with new runtime. Unfortunately, this seems to be the only way for now as updates to any lambda pointing to 2.0 runtime is deprecated (event if the update is upgrading the runtime).
Not an ideal way to do it, but does the job.


text:
Q: Flash.now each issue I'm trying to use flash.now with a Rails 4 Application.
Here's my code:
<% flash.now.each do |name, msg| %>
  <div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
     <%= msg %>

<% end %>

But I get an error because of the each method: undefined method each for #<ActionDispatch::Flash::FlashNow:0x00000103726c90>
How else can I write my code without triggering the each error?

A: Remove now from flash:
<% flash.each do |name, msg| %>
  <div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
     <%= msg %>

<% end %>

A: I had the same problem and I managed to find working solution( for me ;)
Using bootstrap 3 and HAML:
 - flash.each do |name, msg|
   %div{class: "alert alert-#{name.to_s == 'notice' ? 'success' : 'danger'}"}
     %span.close{"data-dismiss" => "alert"} ×
     = msg

I think in ERB it will be:
<% flash.each do |name, msg| %>
  <div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
    ×
    <%= msg %>

<% end %>


text:
Q: Way to decrease column length in DB2 Is there a way to decrease the column length in DB2?
Say I have a table temp with column col1 defined as VARCHAR(80). I want to reduce it to VARCHAR(60).

A: In DB2 9.7 for Linux/UNIX/Windows, you can use the ALTER TABLE statement to reduce the length of a column, assuming that no values in the column exceed the new column size:
ALTER TABLE temp
    ALTER COLUMN col1 SET DATA TYPE VARCHAR(60);

If any values in the column exceed the desired size you must handle that first.
In previous versions of DB2 for Linux/UNIX/Windows, you could not utilize this method to reduce the size of the column.  You either had to drop/recreate the table, or go through a process of adding a column, copying data, and removing the old column.

A: As an addition to Ian's answer and Clockwork-Muse's remark:
While it is possible, as Ian pointed out, to use ALTER statements to reduce column length in DB for LUW, this is not the case in DB2 for z/OS as of version 10.
According to this table, only data type changes from VARCHAR(n) to VARCHAR(n+x) are supported, which is a bummer.

A: You cannot reduce the length of a column. To achieve this affect you should

*

*create a new table with your data and with the attribute that you want.

*Delete old table

*Rename the new table

If you want to increase the length, it is possible with ALTER command
 ALTER TABLE temp
      ALTER COLUMN col1
      SET DATA TYPE VARCHAR(60)


text:
Q: How to use a json response from an ajax request in a JavaScript function as a Javascript array I have created a autocomplete form using javascript which takes data in the form of an array like
var city_list = ["Allahabad","Baramulla","Bellary"]
But my controller returns the requested data in json format like
[{"city_id": 9,"city_name": "Allahabad"},{"city_id": 47,"city_name": "Baramulla"},{"city_id": 60,"city_name": "Bellary"}]

I have searched a lot of StackOverflow and internet posts but nothing worked for me and since I am not good at javascript so I am unable to find a solution on my own.
Ajax Request
$('#heroCitySearch').keyup(function () {
     var q = 'q='+$(this).val();
     if(q != '') {
        $.ajax({
           type:'GET',
           url:"/fetch/city",
           data:q,
           success:function (data) {
              if(data){
                 $.each(data,function(value){
                    autocomplete(document.getElementById("heroCitySearch"), data[value].city_name);

                    // "data[value].city_name" <- This parameter must be an array

              }
           }
        })
     }
  });

Javascript Function (autocomplete)
function autocomplete(inp, arr) {
/*the autocomplete function takes two arguments,
the text field element and an array of possible autocompleted values:*/
var currentFocus;
/*execute a function when someone writes in the text field:*/
inp.addEventListener("input", function(e) {
   var a, b, i, val = this.value;
   /*close any already open lists of autocompleted values*/
   closeAllLists();
   if (!val) { return false;}
   currentFocus = -1;
   /*create a DIV element that will contain the items (values):*/
   a = document.createElement("DIV");
   a.setAttribute("id", this.id + "autocomplete-list");
   a.setAttribute("class", "autocomplete-items");
   /*append the DIV element as a child of the autocomplete container:*/
   this.parentNode.appendChild(a);

   /*==== Below is the code block which uses array elements====*/

   /*for each item in the array...*/
   for (i = 0; i < arr.length; i++) {
     /*check if the item starts with the same letters as the text field value:*/
     if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
       /*create a DIV element for each matching element:*/
       b = document.createElement("DIV");
       /*make the matching letters bold:*/
       b.innerHTML = "" + arr[i].substr(0, val.length) + "";
       b.innerHTML += arr[i].substr(val.length);
       /*insert a input field that will hold the current array item's value:*/
       b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
       /*execute a function when someone clicks on the item value (DIV element):*/
           b.addEventListener("click", function(e) {
           /*insert the value for the autocomplete text field:*/
           inp.value = this.getElementsByTagName("input")[0].value;
           /*close the list of autocompleted values,
           (or any other open lists of autocompleted values:*/
           closeAllLists();
       });
       a.appendChild(b);
     }
   }
});
/*execute a function presses a key on the keyboard:*/
inp.addEventListener("keydown", function(e) {
   var x = document.getElementById(this.id + "autocomplete-list");
   if (x) x = x.getElementsByTagName("div");
   if (e.keyCode == 40) {
     /*If the arrow DOWN key is pressed,
     increase the currentFocus variable:*/
     currentFocus++;
     /*and and make the current item more visible:*/
     addActive(x);
   } else if (e.keyCode == 38) { //up
     /*If the arrow UP key is pressed,
     decrease the currentFocus variable:*/
     currentFocus--;
     /*and and make the current item more visible:*/
     addActive(x);
   } else if (e.keyCode == 13) {
     /*If the ENTER key is pressed, prevent the form from being submitted,*/
     e.preventDefault();
     if (currentFocus > -1) {
       /*and simulate a click on the "active" item:*/
       if (x) x[currentFocus].click();
     }
   }
});
function addActive(x) {
/*a function to classify an item as "active":*/
if (!x) return false;
/*start by removing the "active" class on all items:*/
removeActive(x);
if (currentFocus >= x.length) currentFocus = 0;
if (currentFocus < 0) currentFocus = (x.length - 1);
/*add class "autocomplete-active":*/
x[currentFocus].classList.add("autocomplete-active");
}
function removeActive(x) {
/*a function to remove the "active" class from all autocomplete items:*/
for (var i = 0; i < x.length; i++) {
   x[i].classList.remove("autocomplete-active");
}
}
function closeAllLists(elmnt) {
/*close all autocomplete lists in the document,
except the one passed as an argument:*/
var x = document.getElementsByClassName("autocomplete-items");
for (var i = 0; i < x.length; i++) {
   if (elmnt != x[i] && elmnt != inp) {
   x[i].parentNode.removeChild(x[i]);
}
}
}
/*execute a function when someone clicks in the document:*/
document.addEventListener("click", function (e) {
closeAllLists(e.target);
});
}

I have copied the above script from w3school.
And in above code b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
 instead of city name if I want to use city Id, what changes should I make.
Thanks for your help.

A: Below example snippet would help you get only the city name:

<!DOCTYPE html>

<meta name="viewport" content="width=device-width, initial-scale=1.0">

Autocomplete

Start typing:

<form autocomplete="off" action="/action_page.php">

    <input id="myInput" type="text" name="myCountry" placeholder="Country">

  <input type="submit">
</form>

const cityArry = [{"city_id": 9,"city_name": "Allahabad"},{"city_id": 47,"city_name": "Baramulla"},{"city_id": 60,"city_name": "Bellary"}]

console.log(cityArry.map(city => city.city_name))

A: You can pluck out what you want from that JSON response. Something like this:

// You example
var cities = [{
  "city_id": 9,
  "city_name": "Allahabad"
}, {
  "city_id": 47,
  "city_name": "Baramulla"
}, {
  "city_id": 60,
  "city_name": "Bellary"
}];

const myFormat = cities.map((city) => {
  return city.city_name;
})

console.log(myFormat);
// Output
// [
//   "Allahabad",
//   "Baramulla",
//   "Bellary"
// ]

A: instead of this:
if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {

}

use this:
if (arr[i].city_id == +val ||
    arr[i].city_name.substr(0, val.length).toUpperCase() == val.toUpperCase()) {
}

+val will convert value to the number.
and you can also improve the search by adding regex matching, so it will found text anywhere in the name
var re = new RegExp(val, 'i');

if (arr[i].city_id == +val || re.test(arr[i].city_name)) {

}

if you want to be able to use special characters like * or + in input, you will need to escape the regex special characters.


text:
Q: Transform 2d numpy array into 2d one hot encoding How would I transform
a=[[0,6],
   [3,7],
   [5,5]]

into
b=[[1,0,0,0,0,0,1,0],
   [0,0,0,1,0,0,0,1],
   [0,0,0,0,0,1,0,0]]

I want to bring notice to how the final array in b only has one value set to 1 due to the repeat in the final array in a.

A: Using indexing:
a = np.array([[0,6],
              [3,7],
              [5,5]])

b = np.zeros((len(a), a.max()+1), dtype=int)

b[np.arange(len(a)), a.T] = 1

Output:
array([[1, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 1, 0, 0, 0, 1],
       [0, 0, 0, 0, 0, 1, 0, 0]])

A: This can also be done using numpy broadcasting and boolean comparision in the following way:
a = np.array([[0,6],
              [3,7],
              [5,5]])
# Convert to 3d array so that each element is present along the last axis
# Compare with max+1 to get the index of values as True.
b = (a[:,:,None] == np.arange(a.max()+1))
# Check if any element along axis 1 is true and convert the type to int
b = b.any(1).astype(int)

Output:
array([[1, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 1, 0, 0, 0, 1],
       [0, 0, 0, 0, 0, 1, 0, 0]])


text:
Q: Find the number of balanced parentheses sequences using Catalan Numbers Need to find the number of balanced parentheses sequences in the length of 200, starts with (((.
First, I defined '(' as 0 and ')' as 1.
Then I defined S to be the group of all balanced sequences, according to Catalan numbers, |S| = $\frac{1}{101}$$200\choose100$.
After that, I wanted to subtract all the sequences that does not fit.
The first type is those starts with 0,1,....
So we want all the balanced sequences in the lentgh of 198, that is $\frac{1}{100}$$198\choose99$.
Now the second type I can think of is the sequences starts with 0,0,1.....  because we want to ensure that 0,0 doesn't followed by another 0.
And there I got stuck. It is impossible to create a balanced sequence in the length of 197 so I can't use the previous method.
Maybe I'm not approching the problem the right way?
By-the-way, the correct answer is $\frac{1}{101}$$200\choose100$ - $\frac{1}{50}$$198\choose99$, which I assume to be $\frac{1}{101}$$200\choose100$ - $\frac{1}{100}$$198\choose99$ - $\frac{1}{100}$$198\choose99$.

A: After the initial $001$ you must have a balanced sequence followed by a $1$ followed by another balanced sequence. The first balanced sequence can be of any length $2k$ such that $0\le k\le 98$, and the second balanced sequence will then have length $196-2k$. There are
$$\sum_{k=0}^{98}C_kC_{98-k}$$
such pairs of balanced sequences, and you can now apply the standard Catalan recurrence to finish the problem.


text:
Q: Allocating full width for the one step in the Angular Material stepper For my project I am using Angular Material Stepper component as it is advised in docs
But when I run the stepper, the actual width of the text area (first step) is too small for my task (red rectangle). Is it possible to extend width of a step in the stepper to maximum size (green rectangle).

Markup for the first step text-area looks like that:
<mat-step [stepControl]="firstFormGroup">
  <form [formGroup]="firstFormGroup">
    <ng-template matStepLabel>Raw text</ng-template>
    <mat-form-field appearance="outline">
      <mat-label>Input raw text here</mat-label>
      <textarea
        matInput
        rows="15"
        placeholder="Raw text"
        required
        [(ngModel)]="sourceText"
      ></textarea>
    </mat-form-field>
    <div>
      <button mat-button matStepperNext>Next</button>
    </div>
  </form>
</mat-step>

I've tried using css code as it is advised here:
::ng-deep .mat-horizontal-stepper-content[aria-expanded="false"] {
  width: 0px !important;
}

But without effect.
Resume: Is there a way to extend text area in the red square (shown on the picture above) to the width of the green square?

A:  <mat-form-field appearance="outline" class='w100'>
      <mat-label>Input raw text here</mat-label>
      <textarea
        matInput
        rows="15"
        placeholder="Raw text"
        required
        [(ngModel)]="sourceText"
      ></textarea>
    </mat-form-field>

in CSS
.w100{
width : 100%;

}


text:
Q: ggplot2 - Create a stacked density plot with respect to the total sample size Suppose we have two groups, "a" and "b", of different sample size.
n = 10000
set.seed(123)
dist1 = round(rnorm(n, mean = 1, sd=0.5), digits = 1)
dist2 = round(rnorm(n/10, mean = 2, sd = 0.2), digits = 1)
df = data.frame(group=c(rep("a", n), rep("b", n/10)), value=c(dist1,dist2))

I would like to translate the following stacked barplot to a stacked density plot.
library(ggplot2)
ggplot(data=df, aes(x=value, y=(..count..)/sum(..count..), fill=group)) +
  geom_bar()

I know there is an option position="stack" for density plots. However, the result looks as follows, since the height of the density is with respect to the group sample size, not the total sample size. Hence, the small group is, in a way, overrepresented.
ggplot(data=df, aes(x=value, fill=group)) +
  geom_density(position="stack")

Is there a way to create a density plot that corresponds to the above barplot?

A: Does just doing the same thing with the density chart as you did with the bar chart not give you what you're looking for?
   ggplot(data=df, aes(x=value, fill=group)) +
     geom_density( aes(y = ..count../sum(..count..)),  position="stack", alpha=.7)

which gives

A: If you do a density plot, the y-axis is different from that you get from the first histogram, where your y-axis reflects the counts over total . To get something close to that, you can try below, where the histogram function is used to get the counts, converted and then stacked:
library(dplyr)
library(ggplot2)

RN =range(df$value)

df %>% group_by(group) %>%
do(data.frame(hist(.$value,breaks=seq(RN[1],RN[2],
length.out=40),plot=FALSE)[c("mids","counts")])) %>%
mutate(freq=counts/nrow(df)) %>%
ggplot(aes(x=mids,y=freq,col=group)) + geom_line(position="stack")


text:
Q: Custom Widget in QScrollArea Badly Redrawing Only on Scroll I'm trying to get a custom scrolling widget in QT, and I'm getting redraw errors on scroll. Alt-tab or other redrawing events redraw correctly.
I'm basing it on the example at http://doc.qt.io/qt-5/qtwidgets-widgets-charactermap-example.html
repeatingwidget.cpp (excerpt):
QSize RepeatingWidget::sizeHint() const {
    return QSize(500, itemHeight * displayItems.size() + 1);
}

void RepeatingWidget::paintEvent(QPaintEvent *event) {
    QPainter painter(this);
    painter.fillRect(event->rect(), QBrush(Qt::white));
    painter.setFont(displayFont);

    QRect itemRect = event->rect();

    int top = itemRect.top();

    QFontMetrics fontMetrics(*displayFont);
    for (auto item : displayItems) {
        painter.setPen(QPen(Qt::gray));
        painter.drawRect(itemRect.left(), top, itemRect.right(), itemHeight);
        painter.setPen(QPen(Qt::black));
        painter.drawText(8, 4 + top + fontMetrics.ascent(), item.name);

        top += itemHeight;
    }
}

mainwindow.cpp (excerpt):
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    QMenu *filemenu = menuBar()->addMenu(tr("File"));
    filemenu->addAction(tr("Quit"), this, &QWidget::close);

    auto *centralWidget = new QWidget;

    scrollArea = new QScrollArea;

    repeatingArea = new RepeatingWidget();
    scrollArea->setWidget(repeatingArea);

    auto *centralLayout = new QVBoxLayout;
    centralLayout->addWidget(scrollArea, 1);

    centralWidget->setLayout(centralLayout);

    setCentralWidget(centralWidget);
    setWindowTitle(tr("Widget Test"));
}

This seems to match the example, but I'm getting redraw errors that don't happen in charmap.
I've tried setGeometry, setWidgetResizable, and different size policies, but I'm still getting these redraw errors.

After scrolling:

I don't know what I'm doing wrong because it's largely identical in important ways to the example code from the charmap.
This is the full code: https://gist.github.com/jonasbuckner/2acc1a960e457946ce4756199de3fb57

A: QPaintEvent is a method that allows you to make an intelligent painting, that is, to paint where necessary, thus saving resources, for example it gives us the information of the rectangle that must be painted through event->rect(), with this we can calculate the items that have to be painted since others will be hidden and therefore it is not necessary to paint them:
void RepeatingWidget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.fillRect(event->rect(), QBrush(Qt::white));
    painter.setFont(displayFont);
    QFontMetrics fontMetrics(displayFont);
    int i = std::max(event->rect().top()/itemHeight, 0);
    int j = std::min(event->rect().bottom()/itemHeight+1, displayItems.size());
    QRect itemRect(0, i*itemHeight, width(), itemHeight);
    for(; i < j; i++){
        painter.setPen(QPen(Qt::gray));
        painter.drawRect(itemRect);
        painter.setPen(QPen(Qt::black));
        painter.drawText(8, 4 + itemRect.top() + fontMetrics.ascent(), displayItems[i].name);
        itemRect.translate(0, itemHeight);
    }
}

A: Your original code didn't work because you were drawing all of the items, but using the event->rect, which may only be part of the RepeatingWidget.
Sometimes it is not easy to calculate which items are in the event->rect as @eyllanesc shows.  In these cases, just use clientRect instead - Qt will clip the drawing for you.


text:
Q: Unit Testing Express app in Jenkins Ok, I'm searching a couple of hours for a solution to run my Mocha unit tests inside Jenkins, for my Express JS app.
Writing tests is quite easy, but connecting the tests with my app is a bit harder. An example of my current test:
/tests/backend/route.test.js
var should    = require('should'),
    assert    = require('assert'),
    request   = require('supertest'),
    express   = require('express');

describe('Routing', function() {

  var app = 'http://someurl.com';

  describe('Account', function() {
    it('should return error trying to save duplicate username', function(done) {
      var profile = {
        username: 'vgheri',
        password: 'test',
        firstName: 'Valerio',
        lastName: 'Gheri'
      };
    // once we have specified the info we want to send to the server via POST verb,
    // we need to actually perform the action on the resource, in this case we want to
    // POST on /api/profiles and we want to send some info
    // We do this using the request object, requiring supertest!
    request(app)
    .post('/api/profiles')
    .send(profile)
    // end handles the response
    .end(function(err, res) {
          if (err) {
            throw err;
          }
          // this is should.js syntax, very clear
          res.should.have.status(400);
          done();
        });
    });
});

In above example I connect to a running app (see ```var app = 'http://someurl.com'``). Obviously this is not working inside Jenkins, except if I can tell Jenkins to first run the app and then check for a localhost url. But how to do this?
Now if I take a look at https://www.npmjs.org/package/supertest this should be enough to test my express app:
var request = require('supertest')
  , express = require('express');

var app = express();

But it's not. I receive 404 errors on all urls which I would like to test.
Anyone who knows how to test my app inside Jenkins?

A: Is the app you referenced at http://someurl.com the app you're trying to write this test for?  If so...
Supertest should allow you to run tests without needing an external server running.  The way you accomplish this is by separating out the server routing Express code from the code you'll run that actually starts the server, and use Supertest on the server routing code.
Here is an example:
Given this directory structure:
./package.json
./server/index.js
./app.js
./test/server-test.js

Here are my files:
./package.json
All of these dependencies aren't required for this example, I just pulled this from my package.json I'm using in my project.
{
  "name": "StackOverflowExample",
  "version": "1.0.0",
  "description": "Example for stackoverflow",
  "main": "app.js",
  "scripts": {
    "test": "mocha"
  },
  "author": "Mark",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.15.2",
    "ejs": "^2.5.2",
    "express": "^4.14.0",
    "express-validator": "^2.21.0",
  },
  "devDependencies": {
    "chai": "^3.5.0",
    "mocha": "^3.1.2",
    "supertest": "^2.0.1"
  }
}

./server/index.js
var express = require('express');
var app = express();
app.get('/', function(req, res) {
    res.send('Hello World');
});
module.exports = app;

./app.js
var app = require('./server');
var server = app.listen(8000, function() {
    console.log('Listening on port 8000');
});

./tests/server-test.js
var request = require('supertest');
var app = require('../server');

var assert = require('assert'); //mocha
var chai = require('chai');
var expect = null;

chai.should();
expect = chai.expect;

describe('GET /', function() {
    it('should return a 200', function(done) {
        request(app).get('/').expect(200, done);
    });
});

I'm using Mocha and Chai here (didn't have time to refactor and make the example simpler, sorry).  The main point is that within the it statement you can run your tests.
Doing it this way does not require a separate server running.  Supertest magically starts one up for you and runs it based on the express server you exported from the server module.  I think this approach should allow you to run your tests seamlessly through Jenkins.
In ./server/index.js, an Express object is created.  That object is exported, and imported via require in both ./app.js and ./test/server-test.js.  In ./app.js it's used to start a server via listen().  In the test file, Supetest uses it to start a server for testing internally.
When you are running the server in this example, you would run it via ./app.js.  That would set the port you choose (8000 in this example) and start listening for connections on that port.
Hope this helps!  Good luck!


text:
Q: Import part of an audio file in Matlab I have a .wav audio file of X seconds and I would like to resize this sample in order to delete 5secs each from the beginning and the end.
Is it possible? I tried to figure it out by using
 [Y, FS]=audioread(FILENAME, [START END]) and  info = audioinfo(filename)

but it didn't work.

A: After you load in the audio file with audioread you have the samples Y and the Sampling frequency FS - 5 seconds refers to 5 * FS samples you want to remove from your audio samples so just do something like:
[Y, FS]=audioread(FILENAME);
discard = 5 * FS;
newY = Y(discard+1:end-discard);


text:
Q: Available parameters details for WooCommerce product image zoom options Apologies if these are very basic questions but I'm trying to understand Woocommerce hooks.
In the post below, the answer very helpfully sets out the available parameters for the hook woocommerce_single_product_zoom_options:
Adjusting product image's Zoom magnification factor in woocommerce 3
Is there a archive of all hooks and the relevant parameters? I looked on Woocommerce and could find the hook list but it didn't provide info on the parameters.
Very grateful for any help.

A: You can find all available arguments for woocommerce_single_product_zoom_options hook on jquery.zoom.js file included in the WooCommerce plugin, but they are not documented on this file. But as you can see it's a jQuery plugin, so there is some documentation:
Documentation for jQuery Zooom plugin by Jack Moore
So the detailed available option arguments are:

*

*url - (default value is false) - The url of the large photo to be displayed. If no url is provided, zoom uses the src of the first child IMG element inside the element it is assigned to.

*on (default value is 'mouseover'): The type of event that triggers zooming. Choose from mouseover, grab, click, or toggle.

*duration (default value is 120): The fadeIn/fadeOut speed of the large image.

*target (default value is false): A selector or DOM element that should be used as the parent container for the zoomed image.

*touch (default value is true): Enables interaction via touch events.

*magnify (default value is 1): This value is multiplied against the full size of the zoomed image. The default value is 1, meaning the zoomed image should be at 100% of its natural width and height.

*callback (default value is false): A function to be called when the image has loaded. Inside the function, this references the image element.

*onZoomIn (default value is false): A function to be called when the image has zoomed in. Inside the function, this references the image element.

*onZoomOut (default value is false)*: A function to be called when the image has zoomed out. Inside the function, this references the image element.


text:
Q: Is it possible to see private file/class names of framework in IOS? I have got a framework from a vendor and it crashes intermittently. I identified the class name and method which causes the crash but it is not visible when I open header folder of framework. Is it possible to check whether that class is used inside framework as private file or not?
Is there any terminal script which I run in .framework file and list all class names/files names of framework?
Appreciate your response.


text:
Q: Eigenvectors of a $2\times 2$ Matrix I wish to calculate the eigevalues and eigenvectors of the following matrix:

$$ \begin{bmatrix}
    \frac{\displaystyle \epsilon}{\displaystyle 2}       & \frac{\displaystyle \delta}{\displaystyle 2}  \\
    \frac{\displaystyle \delta}{\displaystyle 2}       & - \frac{\displaystyle \epsilon}{\displaystyle 2}
\end{bmatrix} $$

I get that the eigenvalues are,

$$ \lambda = \pm \frac{1}{2} \sqrt{\epsilon^2 + \delta^2}. $$

The eigenvectors are given by:

The eigenvectors are written in Dirac's BraKet notation.
I am not sure how the eigenvectors have been computed. Any help would be appreciated. Thanks.

A: $\def\ket#1{\mathinner{\rvert{#1}\rangle}}$For a symmetric matrix, eigenvectors that correspond to different eigenvalues are orthogonal. This makes the situation particularly simple in the $2\times2$ case. If you choose a unit eigenvector for one of the eigenvalues, it can be represented as $(\cos\theta,\sin\theta)^T$ for some angle $\theta$ relative to an orthonormal basis, or in BraKet notation, $\cos\theta\ket{0}+\sin\theta\ket{1}$. The corresponding unit eigenvector for the other eigenvalue is simply this rotated by $\pi/2$, or $-\sin\theta\ket{0}+\cos\theta\ket{1}$.
To find the angle $\theta$ we can proceed by diagonalizing the matrix: $$\begin{bmatrix}\frac\epsilon2&\frac\delta2\\\frac\delta2&-\frac\epsilon2\end{bmatrix}=R\begin{bmatrix}\lambda_1&0\\0&\lambda_2\end{bmatrix}R^T$$ where $R$ is the matrix of a rotation through an angle of $\theta$. If you multiply this out and equate corresponding matrix elements, you end up with the equations $$\begin{align}(\cos^2\theta-\sin^2\theta)\sqrt{\epsilon^2+\delta^2}&=\epsilon\\2\cos\theta\sin\theta\sqrt{\epsilon^2+\delta^2}&=\delta.\end{align}$$ Applying the double-angle formulas and dividing one equation by the other yields $$\tan{2\theta}=\frac\delta\epsilon.$$
Underneath the hood, this is essentially the same solution as Joel Cohen's, since there's an isomorphism between $\mathbb C$ and conformal $2\times2$ matrices.

A: Eigenvectors $x_i$ for a matrix $A$ with eigenvalues $\lambda_i$ are calculated by solving $Ax_i = \lambda_i x_i$ or equivalently $(A-\lambda_i I)x_i = 0$ where $I$ is the identity matrix. Is this enough help, or were you past this point already?

A: It may help here to identify $\mathbb{R}^2$ with $\mathbb{C}$ (identifying $|0\rangle$ with $1$ and $|1\rangle$ with $i$). In that setting, denoting $\omega = \frac{\epsilon+ i \delta}{2}$, your matrix is that of the linear map $u : z \mapsto \omega \overline{z}$.
Finding the eigenvectors of the matrix amounts to finding non zero complex numbers $z$ such that $\omega \frac{\overline{z}}{z}$ is a real number (this real number being the associated eigenvalue). We may assume $z$ to be of norm $1$ by scaling. Write $\omega$ in polar form as $\omega = \lambda e^{2i\theta}$ (here, we write the argument as $2\theta$ for convenience). We can see that $z = e^{i\theta}$ and $z=ie^{i\theta} = e^{i(\theta+\frac{\pi}{2})}$ are solutions (with eigenvalues $\pm\lambda$ respectively).
Geometrically, the map $u$ is the composition of a scaling of factor $\lambda$ with a reflection whose axis is generated by $e^{i\theta}$, and the eigenvectors are along the axis or perpendicular to it.


text:
Q: Wordpress E-commerce I want to add shop to a site. But, before using the tools I need to know if I'm using the right ones
The site is already built in a form of a blog with different articles. In this stage I want to add a shop and I decided to use Woocommerce as a plugin.
The point is that i don't know how to continue. Should i build a child-theme for the shop to take the same style of the website that is already build?
Many of you might suggest shopiffy but at this point I want to have an idea more about the woocommerce.


text:
Q: easySlider doesn't work in IE7 I tried using easyslider 1.7 in a site and I noticed that in IE7 does not work properly, it shows all the images and the slider does not work.
in all other higher versions of IE and other major browsers everything works perfectly.
The version IE6 does not consider it either.
the URL is:
http://www.esteticasilvia.it/php/chisiamo.php

A: It seems like a well known bug. Have you tried this?
http://clicknathan.com/2011/04/04/easy-slider-1-7-with-internet-explorer-7-bug-fix/


text:
Q: Salt Proxy Minion Concept We are testing Salt Stack open source for one of our internal project. Basically we would want to automate few things on windows machines using salt but we don't want to install salt minions (not allowed in our environment) or use salt ssh (since we don't have openssh or any other ssh server on windows in our environment).
We thought salt proxy minion would solve our purpose but its confusing how it is configured. We would like to know if salt proxy minion would solve our requirements or please suggest a solution for our situation. Our use cases are like

*

*Get Windows Machines details using WMI remotely

*Run other Remote Machine commands for reading details on the machine

A: You're using the wrong tool for the job. If you can't install configuration management software like Saltstack, then use native Windows capabilities such as Powershell's remote execution tooling and Windows remote management (WinRM).
It's fairly easy once you've configured your environment to support WinRM to do WMI queries on remote machines.
Salt Proxy Minions are intended for things like embedded devices such as networking equipment, serial-only devices, and so forth -- not for managing full Windows clients.


text:
Q: Find multiple files containing a certian string and list the files that don't containt the string In the midst of building a site checker I have ran unto a problem, the client needs to check all of their pages for certain strings if they are included in the code and then list the files that do not have the code yet.
Tried with multiple grep commands with no success. The -v supposedly exports the inverted match of the results, but that does not happen. Currently I am missing the part of the code telling grep to only search in specific files (example files names code.php) in all sub folders.
With the current code it searches all the files even unnecessary ones.
grep -vrn '.' -e "SRING" > list.txt
I'd like to export a list of files (preferably that it only checks files in all sub folders with the same name) that do not posses the sting that I am looking for.

A: grep -c STRING files will give you a count of lines with STRING for each file.
You can optomize it somewhat with -m1 to stop after the first match.
You can pipe that to sed to grab the files with zero matches:
grep -cm1 STRING files | sed -n '/:0$/s/:0//p'
That gets you one file per line.
You can pipe that to xargs to merge it into a one-line list.
If your STRING is just that and not a regex, you could use the -F flag with grep to specify it's a fixed string, and that will also speed things up.   So maybe...
grep -Fcm1 STRING files | sed -n '/:0$/s/:0//p' > list.txt
...in that case


text:
Q: SQL join 2 tables based on third I have 3 tables:
tbl_question (id,question)
tbl_answer (id,answer)
question_has_answer (id,question_id,answer_id)

It looks like many-to-many association, but in fact it is only used like 1-to-many (one question has multiple answers, but each answer belongs to only question). So I need to get fields (except id) from first and second table like this:
Question1
      answer1
      answer2
      answer3
Question2
      answer5
      answer4

and so on.

A: Would be:
SELECT question, answer
    FROM tbl_question q
    INNER JOIN question_has_answer qha
    ON q.id = qha.question_id
    INNER JOIN tbl_answer a
    ON qha.answer_id = a.id
ORDER BY question,answer

I would also recommand not using an ID for table question_has_answer, if you don't plan to use that ID.
And further more: if 1 answer is associated with only 1 question, than you shouldn't use question_has_answer and modify tbl_answer to add a questionID column.

A: Try this one.
SELECT  b.question, c.answer
FROM    question_has_answer a
        INNER JOIN tbl_question b
            ON a.question_ID = b.ID
        INNER JOIN tbl_answer c
            ON a.answer_ID = c.id
ORDER BY a.question_ID, a.answer_ID

A: select question, answer
from tbl_question q
join question_has_answer qa on qa.question_id = q.id
join tbl_answer a on a.id = qa.answer_id
order by 1,2

btw, it's irrelevant that "each answer belongs to only one question"; the table structure allows for answers to be used for multiple questions. The fact that they aren't is merely a matter of extant data.

A: To build on the other answers presented here. The two tables question_has_answer and tbl_answer should be one table something like tbl_answers with(id, question_id, answer_id). There is no need for  two tables, you already can tell if a question is answered or not. If a question has no answers presented in the table question_has_answer, then it isn't answered. But for now you can JOIN the three tables as pointed out by the other answers.

A: SELECT obj.*,mapping.*,mas.* FROM object_master obj
INNER JOIN mapping_master mapping ON mapping.FMM_Object_ID = obj.FOM_ID
INNER JOIN feedback_master mas ON mapping.FMM_FM_ID = mas.FM_ID


text:
Q: sql query is returning the same values twice I have this sql query, and it should be returning two values, which is does but it returns each returned row twice, the sql looks like this,
SELECT * FROM `mailers`
  LEFT JOIN `mailer_content` ON `mailers`.`id` = `mailer_content`.`mailer_id`
  LEFT JOIN `mailer_images` ON `mailer_content`.`id` = `mailer_images`.`content_id`
WHERE `mailers`.`id` = 26

The table structure for the tables I am query look like this,
    -- --------------------------------------------------------

--
-- Table structure for table `mailers`
--

CREATE TABLE `mailers` (
  `id` int(11) NOT NULL auto_increment,
  `mailer_title` varchar(150) NOT NULL,
  `mailer_header` varchar(60) NOT NULL,
  `mailer_type` enum('single','multi') NOT NULL,
  `introduction` varchar(80) NOT NULL,
  `status` enum('live','dead','draft') NOT NULL,
  `flag` enum('sent','unsent') NOT NULL,
  `date_mailer_created` int(11) NOT NULL,
  `date_mailer_updated` int(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=29 ;

-- --------------------------------------------------------

--
-- Table structure for table `mailer_content`
--

CREATE TABLE `mailer_content` (
  `id` int(11) NOT NULL auto_increment,
  `headline` varchar(320) NOT NULL,
  `content` text NOT NULL,
  `mailer_id` int(11) NOT NULL,
  `position` enum('left','right','centre') default NULL,
  `tab_1_name` varchar(25) default NULL,
  `tab_1_link` varchar(250) default NULL,
  `tab_2_name` varchar(25) default NULL,
  `tab_2_link` varchar(250) default NULL,
  `tab_3_name` varchar(25) default NULL,
  `tab_3_link` varchar(250) default NULL,
  `tab_4_name` varchar(25) default NULL,
  `tab_4_link` varchar(250) default NULL,
  `created_at` int(10) NOT NULL,
  `updated_at` int(10) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `mailer_id` (`mailer_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;

-- --------------------------------------------------------

--
-- Table structure for table `mailer_images`
--

CREATE TABLE `mailer_images` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(150) NOT NULL,
  `filename` varchar(150) NOT NULL,
  `mailer_id` int(11) NOT NULL,
  `content_id` int(11) default NULL,
  `date_created` int(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=49 ;

I am sure that is must be a problem with my sql I just do not know what the problem is

A: If you use SELECT DISTINCT SQL will not return dupplicated rows, if there are some.
SELECT DISTINCT * FROM `mailers` LEFT JOIN `mailer_content` ON `mailers`.`id` = `mailer_content`.`mailer_id` LEFT JOIN `mailer_images` ON `mailer_content`.`id` = `mailer_images`.`content_id` WHERE `mailers`.`id` = 26

A: U can use group by smthng. It will delete the same records.
but u can delete nonsame rows. Use smthng without same values in different rows in original table.

A: try this
SELECT * FROM mailers
  LEFT JOIN mailer_content ON mailers.id = mailer_content.mailer_id
  LEFT JOIN mailer_images ON mailer_content.id = mailer_images.content_id
WHERE mailers.id = 26 GROUP BY mailers.id

A: It doesn't look like an SQL isse to me; I suspect this is more likely down to the data in your tables.
My guess is that there are two rows in mailer_content where mailers.id = 26 and then two rows (or possibly 1 and 3) in mailer_images for each of the mailer_contents.
How many rows do each of the following queries return?
SELECT * FROM `mailers`
WHERE `mailers`.`id` = 26

SELECT * FROM `mailer_content`
WHERE `mailer_content`.`id` = 26

My guess is that the first returns 1 row (because it has a primary key on id) and that the second returns two rows.
That all may be fine but my guess is that the following query returns 4 records:
SELECT * FROM `mailer_content`
LEFT JOIN `mailer_images` ON `mailer_content`.`id` = `mailer_images`.`content_id`
WHERE `mailer_content`.`id` = 26

Because either each content has two images each OR one content has one image and the other has three.


text: Q: Rails application ignores RAILS_ENV=production We've done export RAILS_ENV=development. But still, the app uses the production values from database.yml. It is as if no matter what we do, production is always enforced. Where is this done and how do we kill it?


text:
Q: VBA loop: How to get Ticker symbols into Ticker column? How do I populate the Ticker column from each sheet for example from pic1 to pic2 using VBA?, attached is the code I am using but it creates the headers fine on each sheet but not able to populate the Ticker column. I would like to populate the ticker column and later on the yearly change, percent change columns and so on.
Option Explicit

Sub Stock_market()

'Declare and set worksheet
Dim ws As Worksheet

'Loop through all stocks for one year
For Each ws In Worksheets

'Create the column headings
ws.Range("I1").Value = "Ticker"
ws.Range("J1").Value = "Yearly Change"
ws.Range("K1").Value = "Percent Change"
ws.Range("L1").Value = "Total Stock Volume"

ws.Range("P1").Value = "Ticker"
ws.Range("Q1").Value = "Value"
ws.Range("O2").Value = "Greatest % Increase"
ws.Range("O3").Value = "Greatest % Decrease"
ws.Range("O4").Value = "Greatest Total Volume"

'Define Ticker variable
Dim Ticker As String
Ticker = " "
Dim Ticker_volume As Double
Ticker_volume = 0

'Create variable to hold stock volume
'Dim stock_volume As Double
'stock_volume = 0

'Set initial and last row for worksheet
Dim Lastrow As Long
Dim i As Long
Dim j As Integer

'Define Lastrow of worksheet
Lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row

'Set new variables for prices and percent changes
Dim open_price As Double
open_price = 0
Dim close_price As Double
close_price = 0
Dim price_change As Double
price_change = 0
Dim price_change_percent As Double
price_change_percent = 0

'Do loop of current worksheet to Lastrow
For i = 2 To Lastrow

'Ticker symbol output
If ws.Cells(i + 1, 1).Value <> ws.Cells(i, 1).Value Then
Ticker = ws.Cells(i, 1).Value

'Calculate change in Price
close_price = ws.Cells(i, 6).Value
price_change_percent = close_price - open_price

'Fixing the open price equal zero problem
ElseIf open_price <> 0 Then
price_change_percent = (price_change_percent / open_price) * 100

End If

Next i

Next ws

End Sub

A: Dim TickerRow As Long: TickerRow = 1

'Do loop of current worksheet to Lastrow
For i = 2 To Lastrow

'Ticker symbol output
If ws.Cells(i + 1, 1).Value <> ws.Cells(i, 1).Value Then
TickerRow = TickerRow + 1
Ticker = ws.Cells(i, 1).Value
ws.Cells(TickerRow, "I").Value = Ticker

'Calculate change in Price
close_price = ws.Cells(i, 6).Value
price_change_percent = close_price - open_price

'Fixing the open price equal zero problem
ElseIf open_price <> 0 Then
price_change_percent = (price_change_percent / open_price) * 100

End If

Next i


text:
Q: why is one of my rotating elements going the opposite direction? I am creating a wheel like animation where 12 elements rotate around an axis. It works fine, except one element snaps around in the wrong direction? I assume this is do to with going past 360deg but I can't figure it out.
Occasionally there is a jump on the first transition, which I am not sure what is happening. I've slowed the transition-duration down to 1s so you can view the rotation more clearly.
Any help appreciated, thanks!

function getRotationDegrees(obj) {
  var matrix = obj.css("-webkit-transform") ||
  obj.css("-moz-transform")    ||
  obj.css("-ms-transform")     ||
  obj.css("-o-transform")      ||
  obj.css("transform");
  if(matrix !== 'none') {
    var values = matrix.split('(')[1].split(')')[0].split(',');
    var a = values[0];
    var b = values[1];
    var angle = Math.round(Math.atan2(b, a) * (180/Math.PI));
  } else { var angle = 0; }
  return angle;
}

$(function(){
  $('.btn.up').on('click', function(){
    var spinR = $('.spinner-wrapper').width()/2;
    var array = [];
    $.each($('.spinner-item'), function(i){
      var rotate = getRotationDegrees($(this));
      var rotation = rotate - 30;
      array.push(rotation);
    }); // end each
    $.each($('.spinner-item'), function(j){
      $('.spinner-item').eq(j).css({
        'transform':'rotate('+array[j]+'deg) translateX('+spinR+'px)'
      });
    });
  }); // end click
}); // end ready
/* utils */
/* layout */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box; }

.site-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  background: #282D33;
  display: flex;
  flex-direction: column; }

.site-header {
  position: relative;
  height: 50px;
  background: black;
  width: 100%; }

.site-main {
  position: relative;
  flex: 1;
  height: 100%;
  width: 100%; }

.site-footer {
  position: relative;
  width: 100%;
  height: 25px;
  background: black; }

.content {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 40px; }

.btn {
  position: relative;
  margin: 10px 0 10px 300px;
  background: white;
  text-align: center;
  width: 70px;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer; }

.spinner-wrapper {
  position: relative;
  top: 37.5vh;
  -moz-transform: rotate(0deg) translate(-50%, -50%);
  -ms-transform: rotate(0deg) translate(-50%, -50%);
  -o-transform: rotate(0deg) translate(-50%, -50%);
  -webkit-transform: rotate(0deg) translate(-50%, -50%);
  transform: rotate(0deg) translate(-50%, -50%);
  left: 0;
  height: 75vh;
  width: 75vh;
  background: rgba(255, 0, 0, 0.1); }

.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  -moz-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  -o-transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  height: 100%;
  width: 100%;
  border-radius: 50%; }

.spinner-item {
  position: absolute;
  height: 20px;
  width: 20px;
  line-height: 20px;
  background: white;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transition: all 1s ease; }
  .spinner-item:nth-of-type(1) {
    -moz-transform: rotate(0deg) translateX(37.5vh);
    -ms-transform: rotate(0deg) translateX(37.5vh);
    -o-transform: rotate(0deg) translateX(37.5vh);
    -webkit-transform: rotate(0deg) translateX(37.5vh);
    transform: rotate(0deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(2) {
    -moz-transform: rotate(30deg) translateX(37.5vh);
    -ms-transform: rotate(30deg) translateX(37.5vh);
    -o-transform: rotate(30deg) translateX(37.5vh);
    -webkit-transform: rotate(30deg) translateX(37.5vh);
    transform: rotate(30deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(3) {
    -moz-transform: rotate(60deg) translateX(37.5vh);
    -ms-transform: rotate(60deg) translateX(37.5vh);
    -o-transform: rotate(60deg) translateX(37.5vh);
    -webkit-transform: rotate(60deg) translateX(37.5vh);
    transform: rotate(60deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(4) {
    -moz-transform: rotate(90deg) translateX(37.5vh);
    -ms-transform: rotate(90deg) translateX(37.5vh);
    -o-transform: rotate(90deg) translateX(37.5vh);
    -webkit-transform: rotate(90deg) translateX(37.5vh);
    transform: rotate(90deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(5) {
    -moz-transform: rotate(120deg) translateX(37.5vh);
    -ms-transform: rotate(120deg) translateX(37.5vh);
    -o-transform: rotate(120deg) translateX(37.5vh);
    -webkit-transform: rotate(120deg) translateX(37.5vh);
    transform: rotate(120deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(6) {
    -moz-transform: rotate(150deg) translateX(37.5vh);
    -ms-transform: rotate(150deg) translateX(37.5vh);
    -o-transform: rotate(150deg) translateX(37.5vh);
    -webkit-transform: rotate(150deg) translateX(37.5vh);
    transform: rotate(150deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(7) {
    -moz-transform: rotate(180deg) translateX(37.5vh);
    -ms-transform: rotate(180deg) translateX(37.5vh);
    -o-transform: rotate(180deg) translateX(37.5vh);
    -webkit-transform: rotate(180deg) translateX(37.5vh);
    transform: rotate(180deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(8) {
    -moz-transform: rotate(210deg) translateX(37.5vh);
    -ms-transform: rotate(210deg) translateX(37.5vh);
    -o-transform: rotate(210deg) translateX(37.5vh);
    -webkit-transform: rotate(210deg) translateX(37.5vh);
    transform: rotate(210deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(9) {
    -moz-transform: rotate(240deg) translateX(37.5vh);
    -ms-transform: rotate(240deg) translateX(37.5vh);
    -o-transform: rotate(240deg) translateX(37.5vh);
    -webkit-transform: rotate(240deg) translateX(37.5vh);
    transform: rotate(240deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(10) {
    -moz-transform: rotate(270deg) translateX(37.5vh);
    -ms-transform: rotate(270deg) translateX(37.5vh);
    -o-transform: rotate(270deg) translateX(37.5vh);
    -webkit-transform: rotate(270deg) translateX(37.5vh);
    transform: rotate(270deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(11) {
    -moz-transform: rotate(300deg) translateX(37.5vh);
    -ms-transform: rotate(300deg) translateX(37.5vh);
    -o-transform: rotate(300deg) translateX(37.5vh);
    -webkit-transform: rotate(300deg) translateX(37.5vh);
    transform: rotate(300deg) translateX(37.5vh); }
  .spinner-item:nth-of-type(12) {
    -moz-transform: rotate(330deg) translateX(37.5vh);
    -ms-transform: rotate(330deg) translateX(37.5vh);
    -o-transform: rotate(330deg) translateX(37.5vh);
    -webkit-transform: rotate(330deg) translateX(37.5vh);
    transform: rotate(330deg) translateX(37.5vh); }

up

1

2

3

4

5

6

7

8

9

10

11

12


text:
Q: Objects chaining interrogations I spent some time on something I thought was a bug until I found a workaround.
Still I can't understand why the previous code failed.
Any insight please?
Failing code:
getModule: ->
  Gmaps4Rails.Google

createMap : ->
  new @getModule().Map()

Working code:
constructor:
  @module = @getModule()

getModule: ->
  Gmaps4Rails.Google

createMap : ->
  new @module.Map()

A: The reason is that new anonymous function is not the same as new Gmaps4Rails.Google() in JavaScript.
// Translated JavaScript code (simplified):

var your_module = {
    getModule: function() {
        return Gmaps4Rails.Google;
    },
    createMap: function() {
        // This is where things go wrong
        return new this.getModule().Map();
    }
};

The problem is that return new this.getModule().Map(); translates to return new function() { return Gmaps4Rails.Google; } - which ignores the return value and uses this (which is a new object inheriting from the anonymous function).  Thus the line essentially translates to return {}.Map(); Since objects do not have a Map method, you get an error.
When you set @module to be a reference to Gmaps4Rails.Google then when you call new @module.Map() you are actually calling new Gmaps4Rails.Google - and it returns an object which has a Map method - thus everything works.


text:
Q: jScrollpane does not take the border-width into account The jScrollPane jquery plugin allows to style a scrollable zone. Great, except that the design i must implement uses the borders, but the plugin does not take the height into account.
To see where the problem is, scroll down the scrollable area. When the jspDrag element has reached the bottom, its border-bottom disappears. I would like that it stays in the visible part.
Demo: http://jsfiddle.net/pixeline/nsAny/
This demo uses the plugin basic CSS, and this:
$('.scroll-pane').jScrollPane({
    showArrows: false,
    scrollbarWidth: 11
});

CSS:
.scroll-pane {
        height: 440px;
        overflow: auto;
    }

.jspDrag{
    border:1px solid green;
}

Is there a way to fix this without hacking the code?

A: Hey I had the same problem and "fixed" it via a workaround.
There is a line (#286 on version 2.0.17):
verticalTrackHeight = paneHeight;
I changed it to :
verticalTrackHeight = paneHeight-2;
Now I have a red line at the bottom, I need black so modified the background colour of the jspVerticalBar class in the css.
Hope this helps, no other functionality seems affected yet...


text:
Q: Content loading with jsonp I am a beginner at sencha touch2. i am trying to create a some app which contains a blog view. the code of the blog is given below.  when i launch the app, the content fails to load, giving these errors.  i am using wamp for localhost.
XMLHttpRequest cannot load "  http://secureclick-media-maynemyltf.netdna-ssl.com/Extensions/rjs/c2.js".  Origin< http://localhost> is not allowed by Access-Control-Allow-Origin.

XMLHttpRequest cannot load  " http://api.yontoo.com/GetClientData.ashx?key=null&id=47a8564d-d089-4195-9564-72f107ea1c56&loc=http%3A//localhost/GS/&apps=bestvideodownloader,ezLooker,pagerage,buzzdock,toprelatedtopics,twittube".  Origin <http://localhost> is not allowed by Access-Control-Allow-Origin.

Ext.define('GS.view.blog',
{
        extend:'Ext.navigation.View',
    xtype: 'blogpanel',

    config:{
        title: 'Blog',
        iconCls: 'star',

        items:
        {
            xtype:'list',
            itemTpl:'{title}',
            store:
            {
                autoLoad: true,
                fields:['title','author','content'],

                proxy:
                {
                    type:'jsonp',
                    url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
                reader:
                {
                        type:'json',
                    rootProperty:'responseData.feed.entries',
                }
                }
            }
        }
    }
});

A: You're not calling a JSONP service but a JSON one. You can detect it by calling your URL from your browser and see the content isn't starting by a method call.
So you're not bypassing Cross-Domain protections.
You can't just tell the server you want it to answer in JSONP : it must be ready to make such an answer.
And your browser won't let you access from another domain a server answering in json and not having set a header specifying he accepts this cross-domain request. Read this.
EDIT :
You may call this service using JSONP : you just have to specify a callback at the end of the URL.

In addition to this response format, the protocol also supports a
  classic JSON-P style callback which is triggered by specifying a
  callback argument, which directs the API to deliver the JSON object as
  an argument to the specified callback.

Example from the documentation :
'https://ajax.googleapis.com/ajax/services/feed/find?v=1.0&q=Official%20Google%20Blogs&callback=processResults'


text:
Q: Why am I getting the "The user hasn't authorized the application to perform this action" error when I try to post a video (but not a photo) I've been successfully posting from my app to user's walls for a couple of years now using the methodology defined here:
https://developers.facebook.com/docs/reference/api/post/
and now I'm switching to posting video (instead of photos) to their walls and suddenly am getting this error:
{"error":{"message":"(#200) The user hasn't authorized the application to perform this action","type":"OAuthException","code":200}}
Presumably the permissions for posting photos and videos are the same (as far as I can tell) so this is almost certainly a red herring error (not unusual for facebook).  So, I'm curious if anyone else uses the /post/ method to publish content to the walls of users who have authorized your apps and I'm wondering what I'm doing wrong... After I pull the user's access token (which I have xxxed out below) the rest of my call looks like this:
    post/access_token=xxxxxxxxx
&from=MyCompany
&to=user_facebook_id
&title=SomeString
&link=URL_TO_FOLLOW_BACK_FROM_FB
&source=URL_OF_VIDEO_FILE
&name=SOME_STRING
&type=video
&picture=URL_OF_THUMBNAIL

My guess is that I'm missing something in the call, but I can't figure out what it might be.

A: I guess this is what is different:

Video POST requests should use graph-video.facebook.com

Source: Graph API > Video


text:
Q: Add Adobe Reader in prerequisite of my Setup project (VS 2010) Am trying to add adobe reader in my setup project as pre-requisite, i don't know how to do this. I got this link but there is no Bootstrap generator in VS 2010.
http://msdn.microsoft.com/en-us/library/ms165429.aspx
Kindly tell me is there any other way to add custom pre requisite in set up project of VS 2010?

A: You can include additional installer with your setup installer in VS2010 with the help  BMG_2008. Just Build the Manifest using BMG_2008.
the Build results dialog box as you need to locate the generated files and manifest file, normally the location of this is here "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Your Installer" As this version of Bootstrapper Manifest Generator is version 2008 so it does generate in v6.0 folder. In order that this Prerequisites will appear in Visual Studio 2010 IDE you need to do some tricks.
Just  copy the whole folder to this path "C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages", the v7.0A folder is the location for all the Prerequisites Packages for Visual Studio 2010 Projects.
After copying you can now view this Prerequisites package on Prerequisite Dialog box of VS2010.
SOURCE
Now, you can read THIS again.


text:
Q: Is there a proper way to nil-coalescing a string value or handling a nil found while unwrapping an optional error? I'm attempting to set a text label string value equal to the text field string value. However, it is crashing due to a unexpectedly found nil while unwrapping an optional value. I thought that nil-coalescing will work just fine in a macOs application. Any idea what would be the proper way to handle this error?
At the moment, I have tried to nil-coalescing to make sure that the default value is a blank string.
@IBAction func textFunctionality(_ sender: NSButton) {
    let text: String = textField.stringValue ?? ""
    switch sender.tag {
    case 0:
        print(textLabel.stringValue)
        textLabel.stringValue = text
    default:
        print("error")
    }
}

I expect to set the text label string value to the text field string value. For example, if the string value of the text field is Adam, then string value of the text label will be Adam as well.


text:
Q: How can we see objects with the help of light if we cannot see atoms? We know that the objects are made up of atoms. We also know that we cannot see atoms with the help of light as the wavelength of light is too big in comparison to atom. So, my question is then: how can we see objects with the help of light if we cannot see atoms?

A: It depends with what you mean with the word "seeing", because seems to me that you are confusing it with the word "resolve".
You cannot resolve the particulars of the atomic structure just with electromagnetic radiation, because higher wavelenght as you said are "too big" for the atoms; the human visible light has a wavelenght not too less than $1\mu$m, while the extension of a whole atom is in general around $0.1$nm. Theoretically you can go with higher frequency radiation, so less wavelenght, like X-rays or gamma radiation, but Nature is smarter and what happens with this energy scale of radiation is that it starts to actively interact with atomic structure and so, even in this case, you have a limit in your ability to resolve atomic structure.
But even if you have the most precise instrument in the world quantum mechanics states that the basic principle of Nature is indetermination, so it's very hard to say what you would actually "see", maybe like a substantially blurred picture if you just want to imagine it.
So in conclusion light interacts with atoms with absorption, reflection and diffraction, that's what allows you to perceive trough vision complex bodies; but at the same time, given the underteministic nature of the things in the World, doesn't allow you to resolve them with arbitrary precision.

A: Imagine kicking many footballs at a large pile of invisible bricks. The fact that the footballs rebound tells you that the pile is there, and the angles at which they rebound tells you something about the overall shape of the pile, but you won't be able to work out the position of individual bricks in the pile.

A: As explained in a related previous thread, the human eye cannot resolve atoms (in the sense that visible light is too coarse to distinguish one atom from its neighbours in solids and liquids), but that does not mean that we cannot perceive the light that they emit.
The light emitted by each atom is generally quite faint (probably just under the detection threshold for human vision), but if the atom is emitting (or reflecting, or scattering) photons, there's a nonzero probability that the cells in the human eye will detect it.
If you then put a bunch of atoms together, they will emit more photons, and the probability that the cells in the eye will detect it increases. Put enough atoms together, and it becomes certain that the eye will detect the signal. We cannot tell with certainty where the signal comes from to any accuracy better than the wavelength of light, but that does not mean we cannot detect the signal.

A: This can probably be answered by analogy. If you look at an individual pixel on a TV screen it doesn't tell you much about what picture is on the screen. However, if you have a screen with several million pixels, when viewed together you are able to process them into a meaningful image.
The situation is similar with atoms. Your eyes do detect individual photons coming from atoms, however just like looking at a single pixel, seeing a single photon from a single atom would not even register on your vision.

A:
how can we see objects with the help of light if we cannot see atoms?

It is easy to think of a solid material as "just a bunch of atoms", but for photons (which interact with charges), that isn't the case.
Solid materials are made up of molecules, or large numbers of bonded atoms.  When bonded, the positions of the (charged) electrons changes from a very localized position near the nucleus of the atom to a smeared-out surface surrounding the molecule or bulk material.
The visible light reaching this surface has a much higher chance of interacting.  Given a bulk material of some thickness, the chance goes way up for it to interact with at least some of the material.  For a material with homogenous properties from one region to another, all these different interactions give similar results.  So we can sum the light that is reflected in a meaningful way.
To image atoms, we need the light to interact with one specific atom.  Detecting the interaction with other nearby atoms does not help us image this one.  The low likelihood of a visible photon interacting with an unbound atom makes this task too noisy to be useful.


text:
Q: CircleProgressIndicator with round caps CircularProgressIndicator does not seem to support alternative types of stroke end caps. How can I achieve an intermediate indicator with round caps.
I know that https://pub.dev/packages/percent_indicator supports custom end caps, if all fails I can have a constantly rotating percent indicator with animated percent changes.


text:
Q: Magento2.2 error while install extension I have tried to install magento extension in magento 2.2 using magento connect. But during readiness check I am getting the following error screen.

I have enabled always_populate_raw_post_data = -1 line in php.ini file. It does not help me.
I tried with lot of searching but not get a good solution.


text:
Q: Better way of making a Full Outer Join using LINQ for two Queries? C# I would like to know if there is a much cleaner looking code to do this LINQ statements because soon as I transfer to my actual program with these queries I will be querying more variables (other properties of the child_t table).
LINQ Statements from LINQpad:
// Displaying the Child (with their dialects)
var query = (
from c in child_t

join cd in tn_child_dialect_t on c.child_id equals cd.child_id into tcdGroup
from a in tcdGroup.DefaultIfEmpty()

join d in lu_dialect_t on a.dialect_id equals d.dialect_id into dGroup
from b in dGroup.DefaultIfEmpty()

group c by new { c.child_id, c.last_name, b.name } into grp

select new
{
    child_id = grp.Key.child_id,
    last_name = grp.Key.last_name,
    dialects = grp.Key.name,
});

var query2 = (from item in query.ToList()
group item by new { item.child_id } into grp
select new
{
    child_id = grp.FirstOrDefault().child_id,
    last_name = grp.FirstOrDefault().last_name,
    dialects = string.Join(", " , grp.Select(d=>d.dialects)),
}).ToList();

// Displaying the Child (with their vaccinations)
var query3 =
from c in child_t

join cv in tn_child_vaccination_t on c.child_id equals cv.child_id into tcvGroup
from n in tcvGroup.DefaultIfEmpty()

join v in lu_vaccination_t on n.vaccination_id equals v.vaccination_id into d2Group
from m in d2Group.DefaultIfEmpty()
//where (c.child_id == 1)

group c by new { c.child_id, c.last_name, m.name } into grp

select new
{
    child_id = grp.Key.child_id,
    last_name = grp.Key.last_name,
    vaccinations = grp.Key.name,
};

var query4 = (from item in query3.ToList()
group item by new { item.child_id } into grp
select new
{
    child_id = grp.FirstOrDefault().child_id,
    last_name = grp.FirstOrDefault().last_name,
    vaccinations = string.Join(", " , grp.Select(d=>d.vaccinations)),
}).ToList();

/* Fuller Outer Join query2 and query4*/
var childIDs = query2.Select(x => x.child_id).Union(query4.Select(x => x.child_id));

var q = from id in childIDs
join d in query2 on id equals d.child_id into firstGroup from n in firstGroup.DefaultIfEmpty()
join v in query4 on id equals v.child_id into secondGroup from m in secondGroup.DefaultIfEmpty()
//where firstGroup.Any() ^ secondGroup.Any()
select new {
id = n.child_id,
dialects = n.dialects,
vaccinations = m.vaccinations
};

Console.WriteLine(q);

This is how it looks like when run:

Description of other related tables:

*

*child_t = Table with all the info of children

*tn_child_dialect_t = Transaction table that gets the child_id of 'child_t' and dialect_id of 'lu_dialect_t'

*lu_dialect_t = Table with the dialects that can be chosen

*tn_child_vaccination_t = Transaction table that gets the child_id of 'child_t' and vaccination_id of 'lu_vaccination_t'

*lu_vaccination_t = Table with the vaccinations that can be chosen

A: Try something like this:
var query =
    (from child in child_t
     join tmp_child_dialect in tn_child_dialect_t
         on child.child_id equals tmp_child_dialect.child_id into tmp_child_dialect_group
     from child_dialect in tmp_child_dialect_group.DefaultIfEmpty()
     join tmp_dialect in lu_dialect_t
         on child_dialect.dialect_id equals tmp_dialect.dialect_id into tmp_dialect_group
     from dialect in tmp_dialect_group.DefaultIfEmpty()
     join tmp_child_vaccination in tn_child_vaccination_t
         on child.child_id equals tmp_child_vaccination.child_id into tmp_child_vaccination_group
     from child_vaccination in tmp_child_vaccination_group.DefaultIfEmpty()
     join tmp_vaccination in lu_vaccination_t
         on child_vaccination.vaccination_id equals tmp_vaccination.vaccination_id into tmp_vaccination_group
     from vaccination in tmp_vaccination_group.DefaultIfEmpty()
     select new { ChildId = child.child_id,
                  DialectName = dialect.name,
                  VaccinationName = vaccination.name }
     )
     .GroupBy(x => x.ChildId, (key, group) => new
         {
             ChildId = key,
             Dialects = group.Select(x => x.DialectName)
                             .Where(x => x != null)
                             .Distinct(),
             Vaccinations = group.Select(x => x.VaccinationName)
                                 .Where(x => x != null)
                                 .Distinct()
         });


text:
Q: Unable to get started with a new Expo project | ERROR: Node.js v12.4.0 is no longer supported while I tried to creat react-native project using expo init projectName, I'm getting an error like this please help me solve this error.
//
ERROR: Node.js v12.4.0 is no longer supported.
expo-cli supports following Node.js versions:

*

*

=10.13.0 <11.0.0 (Maintenance LTS)

*

=12.13.0 <13.0.0 (Active LTS)

*

=14.0.0  <15.0.0 (Current Release)

//
I'm using Windows OS and I'm not using nvm.

A: Seems straightforward. You need to uninstall your current node version and then reinstall a supported version. For example, I'm using Node v14.15.1.
To uninstall Node, open the Control Panel, then under "Programs" click "Uninstall a program". Next, find your Node installation, select it, and click "Uninstall".
To get a new Node version, go to https://nodejs.org/en/ and download/install the latest recommended version. As of now, the latest recommended version is v14.15.1.