Exterior product respects base change of modules

Question: This is a homework assignment so I am only looking for a hint. Suppose that $f: R \rightarrow S$ is a homomorphism of commutative rings, and $M$ is an $R$-module. I am tasked with establishing an isomorphism of $S$-modules
$$\bigwedge^k\, (M\otimes_R S) \cong \bigl(\bigwedge^k M\bigr)\otimes_R S$$
I would like to use the most "concrete" approach possible, so I am trying to define two $S$-linear maps that are inverses of each. In one direction I defined $\psi$ to be the $R$-linear extension of the assignment on basic wedges,
$$\wedge_i (m_i \otimes s_i) \mapsto \wedge_i m_i \otimes \left(\prod s_i\right)$$
I would need to show that this gives a well-defined map, for which I'd like to show that elements $\wedge_i (m_i \otimes s_i)$ with $(m_j \otimes s_j) = (m_l \otimes s_l)$ for some $j\neq l$ are mapped to zero. In particular I'd like to show that $\psi$ takes such an element to an element $\wedge_i m_i \otimes s'$ with $m_j = m_l$. I don't know how to show this, so now I'm questioning if I picked the right definition for $\psi$.
Note: there's a related unanswered question on this site, which is looking for a hint given an approach using exact sequences/category theory, and this question is looking for a "concrete" treatment of this question.
Answer: Suppose that $\omega = \wedge_i(m_i \otimes s_i)$ is a simple tensor which is 0. We can rewrite $\omega$ as $\omega=(\prod_i s_i)(\wedge_i m_i \otimes 1_S)$. This is zero in $\wedge (M \otimes_R S)$ if and only if either $(\prod_i s_i) =0$ in $S$ or $\exists j\neq l$ with $m_j \otimes 1_S = m_l \otimes 1_S$ (i.e. $m_j = m_l$).
In both cases the map from above $\psi: \wedge^k (M \otimes_R S) \rightarrow (\wedge^k M) \otimes_R S$ clearly contains $\omega$ in its kernel. Thus $\psi$ is well-defined.
Conversely, suppose that $u = \wedge_i m_i \otimes \prod s_i = 0$ in $(\wedge^k M) \otimes_R S$. Then either $\prod_is_i = 0$ or $\exists j\neq l$ with $m_j = m_l$. As before it is easy to see that the inverse map $\phi: (\wedge^k M) \otimes_R S \rightarrow \wedge^k (M \otimes_R S)$  contains $u$ in its kernel in both cases. Thus the isomorphism of $(M \otimes_R S)^{\otimes k} \simeq (M^{\otimes k})\otimes_R S$ "descends" to give the required isomorphism with the exterior power in place of the tensor power.


antd components are hidden later than the parent div

Question: I have a box which makes itself visible when a button is clicked. The box has a text field and a button. When that button is clicked, the box must hide again. But my problem is the box hides first and for a split second, i still can see the antd components.
box = () => {

    <Input type= 'text' />
    <Button onClick={() => {this.hideBox()}}>Send</Button>

}
showBox = () => {
  this.setState({visibility: 'visible'});
}
hideBox = () => {
  this.setState({visibility: 'hidden'});
}
render(){
  return(

      <Button onClick={() => {this.showBox()}}>Show</Button>
      {this.box()}

  )
}

I don't know how to make them hide at the same time.
Thank you for the help.
Answer: because antd components has it's default style: transition:"all 0.3s".
styles in devtool
if you hide it with style, I suggest using dispaly:block/none,instead of visibility.
Answer: style={{display: `${this.state.visibility ? 'block' : 'none'}`}}


Android ViewFlipper with translation animation - not working properly

Question: I want to display banner(images moving in x direction) in my application. For that i am using ViewFlipper with Translation animation. Please find my below code..
my layout: banner.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
        <ViewFlipper
                android:id="@+id/banner_image"
                android:layout_width="match_parent"
                android:layout_height="258dp" />
</RelativeLayout>

In animation: in_from_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

  <translate
    android:duration="3000"
    android:fromXDelta="100%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="0%" />

</set>

Out Animation: out_to_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
  <translate android:fromXDelta="0%" android:toXDelta="-100%"
    android:fromYDelta="0%" android:toYDelta="0%"
    android:duration="3000"/>
</set>

My Java Code
public class BannerView extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.banner);

    ViewFlipper myViewFlipper = (ViewFlipper) findViewById(R.id.banner_image);

    //Setting first image in viewFlipper
    ImageView imageView1 = new ImageView(HomeView.this);
    imageView1.setImageDrawable(getResources().getDrawable(R.drawable.img1));
    myViewFlipper.addView(imageView1);

    //Setting second image in viewFlipper
    ImageView imageView2 = new ImageView(HomeView.this);
    imageView2.setImageDrawable(getResources().getDrawable(R.drawable.img2));
    myViewFlipper.addView(imageView2);
    myViewFlipper.setAutoStart(true);

    //Setting in and out animation
    myViewFlipper.setInAnimation(HomeView.this,R.anim.in_from_right);
    myViewFlipper.setOutAnimation(HomeView.this,R.anim.out_to_left);

    //Starting the view filpper to rotate
    myViewFlipper.startFlipping();
}
}

Here my problem is,
When i set the duration for in and out animation as "5000", ViewFilpper's behavior is changing like the below,
Image start to move slowly and ending quickly.
I dont know where i am missing. I want to slow down the speed. Please help me resolve the issue.
Answer: Update: I whipped up some sample code and there is a big stutter halfway through as if the 2nd view is forcibly moved to catch up to the 1st view. After much trial and error I found that setting android:flipInterval="5000" in the viewflipper xml properties fixed it. I can only assume that the default flipInterval is shorter than 5000 and hence the issue.
 <ViewFlipper
        android:id="@+id/viewflipper"
        android:layout_width="match_parent"
        android:layout_height="258dp"
        android:flipInterval="5000" >

If you still find the animation not smooth enough:
Put this in your xml for the translate animation:
android:interpolator="@android:anim/linear_interpolator"

And then
android:startOffset="1000"

to slide_out_to_left so it waits a bit before continuing.
Comment: Hi, Thanks for your response. But This is also not working for me.
Comment: Try myViewFlipper.setAutoStart(true); instead of myViewFlipper.startFlipping(); that way it will wait until the flipper is attached to the view.
Comment: I am still facing the same problem.. Can you please explain more.
Answer: Thanks for your reply. I found the solution for my problem. Please find my answer below.
I have changed my interpolator in xml as below:
 android:interpolator="@android:anim/decelerate_interpolator"

And then i used android:flipInterval="5000" in my viewflipper solved my problem.


Using The Riemann Zeta Functional Equation

Question: Riemann was able to establish the following link between the Riemann zeta function and the weighted prime counting function $J(x)$.
$$\ln(\zeta(s))=s\int_1^\infty J(x)x^{-s-1}dx$$
Using the Mellin inverse transform, he then obtained the following:
$$J(x)=\frac{1}{2\pi i}\int_{c-i\infty}^{c+i\infty}\frac{\ln(\zeta(s))}{s} x^{-s}ds$$
The problem with the above equation is that it evaluates $\zeta(s)$ at complex values. However, he was able to surmount that problem by using the Zeta functional equation, which states
$$\pi^{-s / 2} \Gamma \left({\frac s 2}\right) \zeta \left({s}\right) = - \frac 1 {s \left({1 - s}\right)} + \int_1^\infty \left({x^{s / 2 - 1} + x^{- \left({s + 1}\right) / 2} }\right) \omega \left({x}\right)dx$$
I understand how this formula is obtained, but cannot grasp this next step. From combining the functional equation and the result from the inverse Mellin transform, he obtains
$$J(x)=Li(x)-\sum_\rho Li(x^\rho)-\ln(2)+\int_x^\infty\frac{dt}{t(t^2-1)\ln(t)}$$
How did the functional equation result in this simplification? How did Riemann simplify the complex integral? a step by step explanation from the Mellin integral to the final result above would be very helpful!
NOTE: I am not very familiar with integration over the complex plane, but very willing to learn.
Comment: start with $\frac{\zeta'(s)}{s \zeta(s)}$ you'll get with the residue theorem (and the functionnal equation to allow applying residue theorem on the contour $\Re(s)$ going to $-\infty$) a sum of $x^\rho$ for $\varphi(x)$, then remark that $\zeta'(s)/\zeta(s)$ is the derivative of $\ln\zeta(s)$ so that $J(x) = \int \varphi'(x)/\ln x$ and you'll get the $Li(x^\rho)$ terms... the integral in the right of the $Li(x^\rho)$ is a sum of $Li(x^{-2k})$ for the "trivial" zeros of zeta. my advice : read wikipedia, the Tichmarsh's book "the theory of the riemann zeta function" and forums and pdfs.
Comment: What is the exact question? Is this a historical question about Riemann or a question about proofs of the Prime Number Theorem? Anyway, the question seems somewhat based on a false premise. (What is your source for the claims you make.) Most any book on analytic number theory should be able to clear this up.
Comment: @quid thanks for pointing that out - just edited the question
Answer: pleas look this page 4  may you get what you want (P. Bourgade and J.P. Keating Seminaire Poincare)


Update nuget package referenced by package

Question: I have a nuget-package A in my project that uses nuget-package B.
When I update package B I alway have to update the nuget-package-rerefence to B in nuget-package A and then update the nuget-package-reference to A in my project.
Is there any way to directly update the implicitly referenced nuget-package B in my top-level-project?
Comment: Confirm, is package A and package B separate packages? And nuget package B is dependence of nuget package A?
Comment: A and B are separate packages built from separate solutions. Package a uses package B. And the top-level-project uses package A (and hence package B implicitly).
Answer:
Is there any way to directly update the implicitly referenced nuget-package B in my top-level-project?

Sure, just add a direct dependency from your project to package B - then you can specify the version you want.
When package A is updated so that it now refers to the same version of B as you want, you can remove the direct dependency again.
Comment: Is there no other way? I don't want to add all the tier-2 and tier-3 packages to the solution (there are about 100 in total).
Comment: @user2033412: I don't know what you mean by "tier-2 and tier-3 packages" - but the only packages you need to add directly are the ones you want to change the version of. If there are 100 packages that you want to change the version of, that sounds like a bigger problem...
Comment: I'm talking about packages that are referenced by packages.
Comment: @user2033412: But you don't need to add those, and I never said you did. You only need to add the packages where you want to explicitly specify the version numbers. So in the example you gave in the question, you add a dependency on B. You don't need to add a dependency on anything that B refers to.
Comment: My Problem is: There are a dozend projects depending on A. And they all want B1 to B4 to be in the current version. I can of course add all these packages. But it would be nicer if package A could define: "Give me the latest Version of package B" and the nuget-updates would show this update (without explicitly adding it).
Comment: @user2033412: You could always create a dependencies-only package A2 that depended on B1-B4 and was easier to update than A. Then you just need to update *that* each time B1-B4 change. Alternatively, you can add dependencies on B1-B4 (to each of the packages - yes, there are dozens, but that's a one-time hit) that don't specify a version, and then they'll always be updated, as I understand it. (It doesn't help that we don't know whether you're using packages.config or the newer SDK projects.)


OpenCV 184.108.40.206 + windows 8.1 + Visual Studio 2013 == Error

Question: I've installed new Windows 8.1 system with the following:
OpenCV 220.127.116.11
   Visual Studio 2013 Ultimate.
I'm tying to work with my OpenCV projects but get's the following error:
<code>'OPENCV_PROJECT.exe' (Win32): Loaded 'E:\Users\yirmio\Documents\Visual Studio 2013\Projects\OPENCV_PROJECT\x64\Debug\OPENCV_PROJECT.exe'. Symbols loaded.
'OPENCV_PROJECT.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
'OPENCV_PROJECT.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.
'OPENCV_PROJECT.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file.
'OPENCV_PROJECT.exe' (Win32): Loaded 'E:\Dev\opencv\build\x64\vc11\bin\opencv_core247d.dll'. Cannot find or open the PDB file.
'OPENCV_PROJECT.exe' (Win32): Loaded 'E:\Dev\opencv\build\x64\vc11\bin\opencv_features2d247d.dll'. Cannot find or open the PDB file.
'OPENCV_PROJECT.exe' (Win32): Loaded 'E:\Dev\opencv\build\x64\vc11\bin\opencv_highgui247d.dll'. Cannot find or open the PDB file.
'OPENCV_PROJECT.exe' (Win32): Loaded 'E:\Dev\opencv\build\x64\vc11\bin\opencv_nonfree247d.dll'. Cannot find or open the PDB file.
'OPENCV_PROJECT.exe' (Win32): Loaded 'C:\Windows\System32\msvcp120d.dll'. Cannot find or open the PDB file.
'OPENCV_PROJECT.exe' (Win32): Loaded 'C:\Windows\System32\msvcr120d.dll'. Cannot find or open the PDB file.
The program '[4752] OPENCV_PROJECT.exe' has exited with code -1073741515 (0xc0000135) 'A dependent dll was not found'.
</code>
I've searched Google for houres with no solution to this problem...
Allready changed the libraries and all project settings...
Hope for some help...
Thanks!
Yirmi.
Comment: if you got an older project, that was built with 245, you'll probably need to change all the library names to 247
Comment: Please try to work with VS 2010 or 2012.. 2013 has some issues with OpenCV..
Comment: Thank you both, i've updated the topic...  @scap3y i'm realy going to unistall 2013 because of this, i'm just giving it last chance...
Comment: Please read [this](http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx)..
Answer: Did you ever tried this?

setting PATH
add compiler 'vc11' and linker to visual studio

OpenCV 2.4.7.2 + windows 8.1 + Visual Studio 2013 == Error


Is there any script like Greasemonkey that enables to read/write files?

Question: Greasemonkey is a great addon but its main drawback is that its not possible to read/write files from hard disk. So, is there any other addon that can read/write files from hard disk??
Comment: Not sure what you mean here; all addons can read/write files, but Greasemonkey doesn't expose that ability to its scripts, only [GM_setValue][1] etc.

  [1]: http://wiki.greasespot.net/GM_setValue
Answer: Chickenfoot might well work for you, and it does do file IO.

Or if you feel particularly frisky, you could fork off of the Greasemonkey code and make a version that bypasses the file restrictions.
Comment: If someone is still interested on 2019. The linked pafe has only Chickenfoot 1.0.7. However, there is a later v1.0.9 (never accepted by Mozilla/AMO) which can work in quite recent  Firefox (XUL/preQuantum), Waterfox or Basilisk browser.


How can I load all nodes (and their children) in a TreePanel in one request?

Question: I am trying to create a TreePanel that loads all its items (and their children) in a single request at creation.  From everything I read if items have a "children" property they shouldn't attempt to load children again when expanded, however mine do.
<code>Ext.define('ec.view.MarketGroupTree', {
extend: 'Ext.tree.Panel',
requires:[
    'Ext.tree.*',
    'Ext.data.*'
],

xtype: 'market-group-tree',

store: Ext.create('Ext.data.TreeStore', {
    autoLoad: true,
    root: {
        expanded: true
    },
    fields: ['marketGroupName', 'children', 'marketGroupID'],
    proxy: {
        type: 'ajax',
        url: 'backend/market.php?a=marketGroupTree',
        reader: {
            type: 'json',
            root: 'records'
        }
    }
}),

rootVisible: false,
rowLines: true,
sealedColumns: true,
singleExpand: true,
useArrows: true,
headerPosition: 'left',
lines: false,

columns: {
    items: [
        {
            xtype: 'treecolumn',
                dataIndex: 'marketGroupName',
                flex: 1
            },
            {
                xtype: 'treecolumn',
                dataIndex: 'marketGroupID',
                flex: 0.3
            }
        ]
    }
});
</code>
A sample bit of JSON as received from backend/market.php?a=marketGroupTree is:
<code>{
   "success":true,
   "records":[
      {
         "marketGroupID":"2",
         "marketGroupName":"Blueprints",
     "iconID":"2703",
     "hasTypes":"1",
     "leaf":false,
     "children":[
        {
           "marketGroupID":"204",
           "marketGroupName":"Ships",
           "iconID":"2703",
           "hasTypes":"1",
           "leaf":false,
           "children":[
              {
                 "marketGroupID":"205",
                 "marketGroupName":"Frigates",
                 "iconID":"2703",
                 "hasTypes":"1",
                 "leaf":false,
                 "children":[
                    {
                       "marketGroupID":"261",
                       "marketGroupName":"Caldari",
                       "iconID":"0",
                       "hasTypes":"1",
                       "leaf":true
                    },
                    {
                       "marketGroupID":"264",
                       "marketGroupName":"Minmatar",
                       "iconID":"0",
                       "hasTypes":"1",
                       "leaf":true
                    }
                 ]
              },
              {
                 "marketGroupID":"206",
                 "marketGroupName":"Cruisers",
                 "iconID":"2703",
                 "hasTypes":"1",
                 "leaf":false,
                 "children":[
                    {
                       "marketGroupID":"273",
                       "marketGroupName":"Minmatar",
                       "iconID":"0",
                       "hasTypes":"1",
                       "leaf":true
                    },
                    {
                       "marketGroupID":"274",
                       "marketGroupName":"Amarr",
                       "iconID":"0",
                       "hasTypes":"1",
                       "leaf":true
                    }
                 ]
              }
           ]
        },
        {
           "marketGroupID":"209",
           "marketGroupName":"Ship Equipment",
           "iconID":"2703",
           "hasTypes":"1",
           "leaf":false,
           "children":[
              {
                 "marketGroupID":"210",
                 "marketGroupName":"Turrets & Bays",
                 "iconID":"2703",
                 "hasTypes":"1",
                 "leaf":false,
                 "children":[
                    {
                       "marketGroupID":"286",
                       "marketGroupName":"Hybrid Turrets",
                       "iconID":"2703",
                       "hasTypes":"1",
                       "leaf":false,
                       "children":[
                          {
                             "marketGroupID":"289",
                             "marketGroupName":"Large",
                             "iconID":"0",
                             "hasTypes":"1",
                             "leaf":true
                          },
                          {
                             "marketGroupID":"290",
                             "marketGroupName":"Medium",
                             "iconID":"0",
                             "hasTypes":"1",
                             "leaf":true
                          }
                       ]
                    },
                    {
                       "marketGroupID":"287",
                       "marketGroupName":"Projectile Turrets",
                       "iconID":"2703",
                       "hasTypes":"1",
                       "leaf":false,
                       "children":[
                          {
                             "marketGroupID":"296",
                             "marketGroupName":"Small",
                             "iconID":"0",
                             "hasTypes":"1",
                             "leaf":true
                          },
                          {
                             "marketGroupID":"297",
                             "marketGroupName":"Medium",
                             "iconID":"0",
                             "hasTypes":"1",
                             "leaf":true
                          }
                       ]
                    }
                 ]
              },
              {
                 "marketGroupID":"214",
                 "marketGroupName":"Hull & Armor ",
                 "iconID":"2703",
                 "hasTypes":"1",
                 "leaf":false,
                 "children":[
                    {
                       "marketGroupID":"335",
                       "marketGroupName":"Hull Upgrades",
                       "iconID":"0",
                       "hasTypes":"1",
                       "leaf":true
                    },
                    {
                       "marketGroupID":"1536",
                       "marketGroupName":"Armor Repairers",
                       "iconID":"0",
                       "hasTypes":"1",
                       "leaf":true
                    }
                 ]
              }
           ]
        }
     ]
  },
  {
     "marketGroupID":"4",
     "marketGroupName":"Ships",
     "iconID":"1443",
     "hasTypes":"1",
     "leaf":false,
     "children":[
        {
           "marketGroupID":"391",
           "marketGroupName":"Shuttles",
           "iconID":"1443",
           "hasTypes":"1",
           "leaf":false,
           "children":[
              {
                 "marketGroupID":"393",
                 "marketGroupName":"Amarr",
                 "iconID":"0",
                 "hasTypes":"1",
                 "leaf":true
              },
              {
                 "marketGroupID":"394",
                 "marketGroupName":"Minmatar",
                 "iconID":"0",
                 "hasTypes":"1",
                 "leaf":true
              }
           ]
        },
        {
           "marketGroupID":"1361",
           "marketGroupName":"Frigates",
           "iconID":"1443",
           "hasTypes":"1",
           "leaf":false,
           "children":[
              {
                 "marketGroupID":"5",
                 "marketGroupName":"Standard Frigates",
                 "iconID":"1443",
                 "hasTypes":"1",
                 "leaf":false,
                 "children":[
                    {
                       "marketGroupID":"61",
                       "marketGroupName":"Caldari",
                       "iconID":"0",
                       "hasTypes":"1",
                       "leaf":true
                    },
                    {
                       "marketGroupID":"64",
                       "marketGroupName":"Minmatar",
                       "iconID":"0",
                       "hasTypes":"1",
                       "leaf":true
                    }
                 ]
              },
              {
                 "marketGroupID":"1362",
                 "marketGroupName":"Faction Frigates",
                 "iconID":"1443",
                 "hasTypes":"1",
                 "leaf":false,
                 "children":[
                    {
                       "marketGroupID":"1365",
                       "marketGroupName":"Pirate Faction",
                       "iconID":"0",
                           "hasTypes":"1",
                           "leaf":true
                        },
                        {
                           "marketGroupID":"1366",
                           "marketGroupName":"Navy Faction",
                           "iconID":"0",
                           "hasTypes":"1",
                           "leaf":true
                        }
                     ]
                  }
               ]
            }
         ]
      }
   ],
   "metaData":{
      "rootProperty":"records"
   },
   "num_sent":2
}
</code>
Answer: The problem turned out to be the fact that I used "records" as the root.  It appears that if you change the name of the root that also changes where children are looked for so each item should have a "records" property with its children, not a "children" one.
Comment: Yes, it is written in [the docs](http://docs-origin.sencha.com/extjs/4.2.2/#!/api/Ext.data.TreeStore). Look at the "Reading Nested Data" section. Thanks for taking the time to leave an answer for others :)


Chamar lista em função no python 3

Question: Estou criando um script para meu curso de python.
O script recebe como entrada uma sequência de números inteiros terminada por zero e me devolve os números em ordem crescente, removendo os repetidos.
O script funcionou de primeira compilação, mas agora que o dividi em uma função ele está dando algum erro com a 'lista' que não entendo:

TypeError: remove_repetidos() missing 1 required positional argument: 'lista'

Segue meu script:
def remove_repetidos (lista):
    lista2 = set(lista)
    lista = list(lista2)
    lista.sort()
    return lista

x = 1
lista = []
while x > 0:
    x  = int(input("Digite um número inteiro: "))
    lista.append(x)
del lista[-1]

remove_repetidos()

Comment: Faltou passar a lista como parâmetro em remove_repetidos()
Comment: acho q estou com dificuldades nessa questão mesmo, como faço isso?
Comment: basta fazer `remove_repetidos(lista)` ali na ultima linha
Comment: fiz isso e deu outro erro agora, remove_repetidos() take 0 positional argumentos, but 1 was given
Comment: Qual erro? Aqui quando eu copiei e colei deu erro também. No meu caso era só por conta do acento em "número". Depois disso, funcionou normalmente como esperado. Veja se de repente é isso aí também.
Comment: Eu resolvi colocando lista entre os parênteses da função lá no começo do código, e no final também quando chama a função, seria isto mesmo? Existe alguma maneira de colocar o parâmetro apenas na chamada da função? Exemplo, se eu estivesse trabalhando com duas listas e quiser usar a mesma função para organizá-las
Answer: Primeira, Python é uma liguagem Interpretada não compilada, se quiser saber mais click aqui!
Como sua declaração da função remove_repetidos (lista) pede um parâmetro você deve passa-lo.
no caso de listas o python não cria uma cópia da lista e sim passa um ponteiro da mesma.
Tente isso.
def remove_repetidos (lista):
    lista2 = set(lista)
    lista = list(lista2)
    lista.sort()
    return lista

def main():
   x = 1
   lista = []
   while x > 0:
       x  = int(input("Digite um número inteiro: "))
       lista.append(x)
   del lista[-1]

   remove_repetidos(lista)

main()

Comment: Neste caso, a cópia da lista está sendo feita na conversão para `set` e para `list` novamente, então `lista` que é retornado será diferente da `lista` de entrada, o que exige você utilizar o retorno da função.
Answer: O erro diz que você chamou a função remove_repetidos, que espera um argumento, sem argumentos. Para arrumar isso, basta informá-lo devidamente. Porém, a nova lista será retornada pela função, então você precisa capturar este retorno.
Ficaria assim:
def remove_repetidos (lista):
    lista2 = set(lista)
    lista = list(lista2)
    lista.sort()
    return lista

x = 1
lista = []
while x > 0:
    x  = int(input("Digite um número inteiro: "))
    lista.append(x)
del lista[-1]

lista = remove_repetidos(lista)
#  ^                       ^
#  |                       +--- Passa o parâmetro para a função
#  +--- Captura o retorno da função

print(lista)  # Exibe a lista final

Outra forma de ler a lista seria:
lista = []

while True:
    x = int(input('Numero: '))
    if x == 0:
        break
    lista.append(x)

O que evita você de ter que inicializar o x igual a 1, elimina a condição errada x > 0 do laço (pois a entrada pode ser negativa) e evita ter que excluir o último elemento, 0, da lista, adicionado indevidamente.
Faça o teste com a entrada -5 -6 -2 -2 -3 0 com as duas soluções e compare os resultados.
Comment: Obrigado, realmente ficou melhor dessa forma, mas infelizmente tirei nota zero no meu teste, não o que está havendo pois meu programa está dando resultado como esperado. Segue o enunciado :Exercício 1 - Removendo elementos repetidos

Escreva a função remove_repetidos que recebe como parâmetro uma lista com números inteiros, verifica se tal lista possui elementos repetidos e os remove. A função deve devolver uma lista correspondente à primeira lista, sem elementos repetidos. A lista devolvida deve estar ordenada.

Dica: Você pode usar lista.sort() ou sorted(lista). Qual a diferença?

Chamar lista em função no python 3


How S3 storage cost works on daily basis?

Question: I' having hard time to calculate S3 storage cost. The case is that I need to store daily backups to it.
The scenario: Let's say that I lease S3 service on 1st of January and send to it 10 files (zip) 10GB each. Then, every single day the 2 oldest files will be deleted and replaced by 2 new ones (10 GB each). So, every day will always stored 100GB of files.
How do I calculate the storage cost in this case? What will i pay at the end of January?
Comment: There is a tool that help to calculate your cost right here http://www.bucketexplorer.com/documentation/amazon-s3--cost-calculator.html
Comment: @Tolsadus I used it but it didn't help me.
Comment: The storage cost for s3 storage is 3 cents per GB up to my knowledge. Apart from that network cost will be added based on the upload and download request based on the plan
Answer: You're storing 100 GBs. Each day you upload 20 GB (two files, 10GB each), ie. your monthly uploads total 620 GB (20 GB x 31 days).
Request count is quite low (two DELETE requests daily + some requests for uploading etc.) ... Requests are cheap, so let's estimate that you make 2x 100k.
You probably should use standard storage. Then, enter these values to the calculator linked above (https://calculator.s3.amazonaws.com/index.html).
With estimated values above: If you are just uploading, costs are ~4 dollars per month. If you download something, that increases costs. (100GB downloads => ~$11/month). Your mileage may vary.
Screenshot of AWS S3 price calculator with example values


Does a Mono based application consume more battery (Android)

Question: Does a Mono application consume more battery (having to execute more instructions for the same task) compared to a java application developed in eclipse/adt?
Answer: Based on this article from Xamarin they prove the opposite in which mono touch app consumes less resources than regular java app
http://blog.xamarin.com/2012/05/01/android-in-c-sharp/
Comment: That article is when android itself is running in Mono (if I'm not mistaken)
Comment: Yes but when you have a MonoForAndroid app, it is running on the same VM as when the whole Android is running in Mono.


Differentiable function satisfying $f(x+a) = bf(x)$ for all $x$

Question: This is an exercise from Apostol Calculus, (Exercise 10 on page 269).

What can you conclude about a function which has derivative everywhere and satisfies an equation of the form
  $$ f(x+a) = bf(x) $$
  for all $x$, where $a$ and $b$ are positive constants?

The answer in the back of the book suggests that we should conclude $f(x) = b^{x/a} g(x)$ where $g(x)$ is a periodic function with period $a$.  I'm not sure how to arrive at this.
One initial step is to say, by induction,
$$ f(x+a) = bf(x) \implies f(x+na) = b^n f(x)$$
for all $x$.  I'm not sure what to do with this though.  I'm also not clear how to use the differentiability of $f$.  (If I write down the limit definition of the derivative then I end up with a term $f(x+h)$, but I cannot use the functional equation on that since the functional equation is for a fixed constant $a$.)
Answer: One trivial solution that doesn't use the differentiability of $ f(x) $:
From $ f(x+na)=b^nf(x) $, letting $ y=x+na $, and requiring that $ x \in [0,a) $ and $ n = \left\lfloor \frac{y}{a} \right\rfloor $ we get the following equivalent definition of $ f $:
$$ f(y)=b^{\frac{y-\left(y-\left\lfloor \frac{y}{a} \right\rfloor a\right)}{a}}f\left (y- \left\lfloor \frac{y}{a} \right\rfloor a \right) $$
By letting $ g(y)=b^{-\frac{\left( y-\left\lfloor \frac{y}{a} \right\rfloor a\right)}{a}}f\left(y-\left\lfloor \frac{y}{a} \right\rfloor a \right) $ noting that $ g $ is periodic with a period of $ a $:
$$ f(y)=b^{\frac{y}{a}}g(y) $$
Answer: $$f(x+a)=bf(x)$$
$$f'(x+a)=bf'(x)$$
Then
$$\frac{f'(x+a)}{f(x+a)}=\frac{f'(x)}{f(x)}$$
Let
$$\frac{f'(x)}{f(x)}=h(x)$$
$$f(x)=\exp\left(\int{h(x)}{dx}\right)$$
And we require :
$$h(x+a):=h(x)$$
Now from $f(x+a)=bf(x)$ :
$$\exp\left(\int^{x+a}{h(x)}{dx}\right)=b \,\, \exp\left(\int^x{h(x)}{dx}\right)$$
$$\exp\left(\int^{x+a}_x{h(x)}{dx}\right)=b$$
Now your book suggests $f(x)=b^\frac{x}{a}g(x)=e^{\frac{x \ln b}{a}}g(x)$
This gets :
$$f'(x)=\frac{\ln b}{a}e^{\frac{x \ln b}{a}}g(x)+e^{\frac{x \ln b}{a}}g'(x)$$
$$h(x)=\frac{f'(x)}{f(x)}=\frac{\ln b}{a}+\frac{g'(x)}{g(x)}$$
As $g(x)$ and $g'(x)$ are both periodic we can see that this makes $h(x)$ periodic as well.  So the form we derived earlier is simply related to the form the book describes.
And equating $\frac{f'(x+a)}{f(x+a)}=\frac{f'(x)}{f(x)}$ we get
$$\frac{g'(x+a)}{g(x+a)}=\frac{g'(x)}{g(x)}$$
Which is correct if $g(x)$ has a period $a$.
Comment: Ok, so the $x$ you are integrating against is a different $x$ than the the one on the bounds of integration?  Which is fine, I just want to be clear.  What I mean is that you've just rearranged some terms.  I don't see where we have derived an expression for $f(x)$ until the end where we assume that it is of the form given in the back of the book.  The expression $$\exp \left( \int_x^{x+a} h(x) \, dx \right) = b$$ is just a different way of writing $f(x+a) = bf(x)$.  We haven't gotten an expression for $f(x)$ in terms of a periodic function $g(x)$.
Comment: I don't understand what you've done in the equations following "Now from $f(x+a) = bf(x)$.  Should those bounds of integration be in a different variable from the variable we are integrating over?  Also, this just seems circular since if I take the $\log$ of both sides and then integrate we end up write where we started: $f(x+a) = bf(x)$.
Comment: It makes no difference what variable we use for the integration, as in this case it is simply a label.  We could use $t$ or $\theta$ on one side instead of $x$ but we get the same "shape" of function as a result of integration, and evaluate that at either $x$ or $x+a$.  I am afraid I do not know what you mean by "taking the log of both sides and integrate".  What equation ?  The art in mathematics is often knowing which path or operation to do to avoid ending up where you came from.
Comment: I think you may be writing the MathJax in comments using double dollar signs, because it doesn't show up until I edit.  I think comments only use single dollar ( inline ) forms of MathJax.  In fact both the book and my answer cannot do more than derive a "shape" for the function $f(x)$ and the shape in the book is just a "transformation" of the one I gave.  The form in the back of the book, as I tried to show you, is just a different arrangement of the one I derived.  Regarding the use of variables, think of them as *symbols*, and not variables and it may help.
Comment: I can see display math in comments without issue (on this post and others).  My point on the variable $x$ is that you have written $\int_x^{x+a} h(x) \, dx$ but the $x$ in the limits of integration is representing something different than the $x$ in $h(x) \, dx$.  Maybe $\int_x^{x+a} h(t) \, dt$ would be more clear if that is what you mean?
Comment: Yes, if you find the $t$ form clearer then fine.  The integral means the same thing in both cases.
Comment: I do not thing $\int_{a(x)}^{b(x)} h(x) \,dx$ is in general the same thing as $\int_{a(x)}^{b(x)} h(t) \, dt$.  For instance, try differentiating these two.  You'd need to use the Leibniz rule on the first and would get something involving $a'(x)$ and $b'(x)$.  (Maybe in this case it turns out not to matter since $a(x) = x$ and $b(x) = x+a$ implies $a'(x) = 1$ and $b'(x) = 1$.)
Comment: No they are the same.  You need to think of the integral without the limits first.  So the integral is $s(t):=\int{f(t)}{dt}$.  Now the *definite* integral is simply $\int_x^{x+a}{f(t)}{dt}=s(x+a)-s(x)$.  It makes no difference what symbol we use inside the definite integral, as we will be replacing that with the limits when we are finished.  The $x$ inside the definite integral is gone and replaced by the limits.
Comment: @StephenG-HelpUkraine While the beginning seemed promising, it is not even clear what the point in the answer is. One obvious mistake is that, ∫h(x)dx=log|f(x)|+C, because nobody said f(x) is non-negative, as exp(x) is, so it is incorrect that f(x)=exp(∫h(x)). Furthermore, we do not know that g(x) is continuous, because it is said that f′(x) exists, but not that it is also continuous. Can you please make the point in your answer, such that it does not start with a solution and prove that the solution is correct, because that is already known?
Answer: The function $g$ defined by $g(x9=b^{-x/a}f(x)$ clearly satisfies $g(x+a)=g(x)$, hence the periodicity. The given differentiality is not used, except that you may use it to conclude that $g$ is differentiable.
Comment: This just verifies that the given answer is correct, but doesn't indicate how one might arrive at that answer, other than looking in the back of the book.
Comment: @user2718281828 The $g$ is a deus ex macjina here, but from a pattern one should recognize even while asleep ... The way $g$ is introduced in the accepted answer doesn't seem a lot more motiveted to me.


How to change Stars in Webform-star module?

Question: I have just implemented the Fivestar option in one of the evaluation form created by webform, I used the Fivestar module and Webform-fivestar module. But now I want to change the stars with different layout or design. In some of the article i read that we can change in manage display tab of the contentype but that option is not applicable for webform components. So that changing option is not available in the webform configurations. So please help me how to achieve this.
Comment: Currently it is not configurable with webform fivestar. See https://www.drupal.org/project/webform_fivestar/issues/2377729 It shouldn't be that hard to add though, I'll have a quick look into it.
Comment: Also this issue: https://www.drupal.org/project/webform_fivestar/issues/2071161
Answer: The webform-fivestar module currently doesn't have the option to select which star widget to use, however there is a patch you can apply at https://www.drupal.org/project/webform_fivestar/issues/2071161
There is information regarding how to apply patches at https://www.drupal.org/patch/apply
You can then select the widget per component, when editing the component, in the display settings (see screenshot).
Comment: Thanks rooby. I applied this patch but where will i get the option of selecting different widgets?
Comment: @Suraj I have added more information to the answer.
Comment: Now it works fine, thanks for that. Is there any way to increase the size of the stars?
Comment: You could override the CSS to change the size, however you would have to also override the images that the CSS refers to and create larger images to go with it. OR you could create your own widget style. There are some instructions for that at https://www.drupal.org/node/234391
Comment: Although that doco hasn't been updated for a while so it might not be up to date.


How to extract data from an array of objects to render a list in an html email template? Using React/Formik/Sendgrid

Question: So, basically I have a form data that I am having trouble parsing correctly. I keep getting [object Object]'s in the response for the listPets variable. Every other variable is mapping correctly. Anyone have any ideas on how I could go about this? :)
<Formik
  initialValues={{
    email: '',
    password: '',
    jobType: '',
    comments: '',
    cookies: [],
    terms: '',
    newsletter: '',
    firstName: '',
    pets: [{ type: '', name: '', id: '1' }]
  }}
  validationSchema={ LoginSchema }
  onSubmit={
    async data => {
      await sleep(1000);
      setStatus(prevStatus => ({ ...prevStatus }));
      const res = await fetch('/api/send', { method: 'POST',
                      headers: {
                      'Content-Type': 'application/json'
                    },
                    body: JSON.stringify(data)
                  });

      const text = await res.text();
      handleResponse(res.status, text);
    }
  }
>

const sgMail = require('@sendgrid/mail');

export default async function(req, res){
  sgMail.setApiKey(process.env.SENDGRID_API_KEY);

  const { email, comments, firstName, cookies, jobType, pets } = req.body;

  const content = {
    to: '',
    from: email,
    subject: `New Message From - ${email}`,
    text: comments,
    html: `

Hi, ${firstName}.

${comments}

${cookies}

${jobType}

${listPets}

    `
  };

  try {
    console.log('Content', content);
    res.status(200).send('Message sent successfully.');
  } catch (error) {
    console.log('ERROR', error);
    res.status(400).send('Message not sent.');
  }
}

Answer: Why not use JSON.stringify(pets) to debug whats happening? I would have commented but i dont have enough reputation.
Comment: yeah, no worries any response is helpful! I'm still relatively new to the whole programming world and still trying to wrap my head around alot of this stuff. But so, when I console.log(JSON.stringify(pets)) everything  seemed to come back okay. For, example:

 Pets [{"type":"dog","name":"Timmy","id":"1"},{"type":"cat","name":"Billy","id":"6GKXXqGG"}]

Now, i'm just wondering how I can get that data into the html within the content variable.
Comment: This part seems a bit weird :

const listPets = pets.map(pet => {pet.name}); ...You are aware its making an array of , right? Instead of  ${listPets} maybe try  ${listPets}.join("")
Comment: const listPets = JSON.stringify(pets);

 const joinPets = listPets.join("");

  ${joinPets}

This is giving me listPets.join is not a function error. I dont know if I did that right exactly though. Ideally, I would like to try to get the email to create a list item for each pets object something like:

Name: ""
Type: ""

Name:""
Type:""


Better way to build JSON array and retrieve its elements

Question: Here's how I'm initializing and building an array:
var newCountyInfo = new Object();

newCountyInfo.name = newCountyName;
newCountyInfo.state = newCountyState;
newCountyInfo.zips = newCountyZips;
newCountyInfo.branchID = newCountyBranchID;

So I have my four elements in the array. I'm then passing newCountyInfo to another function to pull out the elements for display in some HTML elements.
The only way I know how to get to the individual elements in the function that uses them is this:
JSON.parse(JSON.stringify(newCountyValidation)).name
JSON.parse(JSON.stringify(newCountyValidation)).state
... etc...

There's got to be a better/shorter/more elegant way of doing this!
What is it?
Comment: That's not a "JSON array", that's a normal JavaScript object. You really should read about what JSON is (a data exchange format) and what `JSON.parse` and `JSON.stringify` are doing. Then you would notice that calling them like this is just unnecessary.
Comment: you would only need to use json if you were passing your object to say PHP or using it to create a cross domain api (jsonP). since you're not doing either of those, using a regular object literal `{}` would be the way to do it.
Answer: Why are you serializing at all? I don't understand what JSON has to do with this, unless you're using web workers, ajax, or something else which demands serialization. Start with object literal syntax:
var newCountyInfo = {
    name: newCountyName,
    state: newCountyState,
    zips: newCountyZips,
    branchID: newCountyBranchID
};

And just pass the whole object to the other function:
someOtherFunction(newCountyInfo);

Which can access the fields using plain old property accesses:
function someOtherFunction(foo) {
    console.log(foo.name); // whatever was in newCountyname
}

No JSON whatsoever.
Comment: @eventide unlike in PHP, a JS array is distinctly different from a JS object. I suggest you get a handle on that ASAP. https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Predefined_Core_Objects#Array_Object and https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Working_with_Objects
Comment: I have to know, why were you shoveling the object through JSON like that? What made you think that was the right approach?
Comment: As it is apparently quite clear, I haven't messed with arrays too much, with the exception of getting an array of data from a PHP/MySQL return to an $.ajax call. In which case I use a JSON array. I assumed that this was just one way to handle arrays in Javascript in general. Now I know differently...
Comment: @Mathletics I am guessing the OP is (ab)using the term as PHP does, blurring the line between an object and an array.
Answer: Something like this should work just fine:
var newCountyInfo = {
    name: newCountyName,
    state: newCountyState,
    zips: newCountyZips,
    branchID: newCountyBranchID
}

function test(newCountyValidation)
{
    alert(newCountyValidation.name);
}

test(newCountyInfo);


Cannot change column names after converting dict to Pandas dataframe.

Question: I am new to Python and Pandas. I am trying to convert a dictionary to a data frame. My original dictionary is a key followed by uneven length of list.
The dict looks as below:
      {'PlaceA': [(1992, 2015)], 'PlaceB': [(1980, 1984), (1988, 1991)], 'PlaceC': [(1985, 1987)]}

To convert this to a df, I use
d = pd.DataFrame.from_dict(city_dict, orient='index')

It works fine and produce the resultant df as below:
                                     0                1
    PlaceA                     (1992, 2015)          None
    PlaceB                     (1980, 1984)    (1988, 1991)
    PlaceC                     (1985, 1987)          None

While I can rename column easily using
d.rename(columns={0:'new column name'})

I cannot rename the name of the first column (place name). I tried using
d.rename(columns={'':'place'}, inplace=True)

but it does not work.
Strangely, when I tried to print out the header, I get the following output
print(list(d.columns.values))

[0, 1]

Is there anything I am missing out?
Your comments are greatly appreciated!
Thanks
Answer: That first 'column' isn't a column; it is the index.  You can name it using:
df.index.name = 'Place Name'

                       0             1
Place Name
PlaceC      (1985, 1987)          None
PlaceB      (1980, 1984)  (1988, 1991)
PlaceA      (1992, 2015)          None

Or you can convert that index into a column using:
d = d.reset_index()
d.rename(columns={'index':'Place Name'}

  Place Name             0             1
0     PlaceC  (1985, 1987)          None
1     PlaceB  (1980, 1984)  (1988, 1991)
2     PlaceA  (1992, 2015)          None

Comment: Thanks so much Scott! It works now. I guess I still have a lot to learn about Python and Pandas.
Comment: @macintosh81 You are welcome.  Thank you for accepting.


Python function to solve Ax = b by back substitution

Question: Okay, for my numerical methods class I have the following question:
Write a Python function to solve Ax = b by back substitution, where A is an upper triangular nonsingular matrix. MATLAB code for this is on page 190 which you can use as a pseudocode guide if you wish. The function should take as input A and b and return x. Your function need not check that A is nonsingular. That is, assume that only nonsingular A will be passed to your function.
The MATLAB code that it refers to is:
x(n) = c(u)/U(n,n)
for i = n-1 : -1 : 1
  x(i) = c(i);
  for j = i+1 : n
    x(i) = x(i) - U(i,j)*x(j);
    end
  x(i) = x(i)/U(i,i);
end

My Python code, which I wrote using the MATLAB code snippet, is with an upper triangular test matrix(not sure if its nonsingular! How do I test for singularity?):
from scipy import mat
c=[3,2,1]
U=([[6,5,1],[0,1,7],[0,0,2]])
a=0
x=[]
while a<3:
    x.append(1)
    a=a+1

n=3
i=n-1
x[n-1]=c[n-1]/U[n-1][n-1]
while i>1:
    x[i]=c[i]
    j=i+1
    while j<n-1:
        x[i]=x[i]-U[i][j]*x[j];
    x[i]=x[i]/U[i][i]
    i=i-1
print mat(x)

The answer I am getting is [[1 1 0]] for x. I not sure if I am doing this correctly. I assume it is wrong and can't figure out what to do next. Any clues?
Comment: I do not know what the output should be but matrix U multiplied by the output matrix should give me matrix c.
Comment: changing the i>=0: seems to give me an infinite loop.
Comment: http://www.scipy.org/NumPy_for_Matlab_Users
Answer: j=i+1
while j<n-1:
    x[i]=x[i]-U[i][j]*x[j];

is infinite ... and never gets executed
your indexing is fubared:
for i in range(n-2,-1,-1):
....
    for j in range(i+1,n):

notice, range is half open unlike matlab
Comment: neither `j` nor `n` change, so the truthiness of the statement never changes.
Comment: @aaa: yeah....noticed that after i wrote it. couldn't think of the word...truthfulness? isn't there a word for 'boolean value'?
Comment: How is it infinite when n is finite making the while condition legitimate?
Comment: @Mark heh, i am russian, dont know
Comment: Yup I should have not missed that. Then how could I properly translate the MATLAB code to python for my while statements?
Comment: @user use range instead, while sux imo
Comment: I am new to Python. Can you give me an example?
Comment: I was able to get it, forgot to update. Office hours really help sometimes. But still thanks for your help guys!
Answer: One problem I see is that your input consists of integers, which means that Python is going to do integer division on them, which will turn 3/4 into 0 when what you want is floating point division. You can tell python to do floating point division by default by adding
from __future__ import division

To the top of your code. From the use of scipy, I'm assuming you're using Python 2.x here.
Answer: You ask how to test for singularity of an upper triangular matrix?
Please don't compute the determinant!
Simply look at the diagonal elements. Which ones are zero? Are any zero?
How about effective numerical singularity? Compare the smallest absolute value to the largest in absolute value. If that ratio is smaller than something on the order of eps, it is effectively singular.


Bayesian and frequentist connections regarding the central limit theorem

Question: I have been wondering how the central limit theorem may be useful in Bayesian statistics with potentially misspecified model distribution. Suppose $x$ is a random variable that follows an unknown (and possibly non-normal) population distribution $P_x$. $P_x$ depends on two parameters, the mean $\mu$ and variance $\sigma^2$. We have observed i.i.d. samples $x_{1:n}=(x_1,...,x_i,...,x_n)$ from $P_x$. I am interested in the unknown parameter $\mu$.
Now consider the case that $\sigma^2$ is known. (1) A common frequentists' point estimate would be the sample mean $\hat{\mu}=\bar{x}=\frac{1}{n}\sum_{i=1}^{n}x_i$. According to the central limit theorem (CLT), $\bar{x}\sim N(\mu,\sigma^2/n)$ as $n\to\infty$. (2) But from an objective Bayesian perspective (using a flat prior on $\mu$), how can we obtain the posterior distribution $\mu\mid(x_{1:n},\sigma^2)$ when $n\to\infty$ without making any distributional assumptions? May be applying the Bernstein-von Mises theorem?
Answer: The Bernstein-von Mises theorem says something about the asymptotic behavior of the posterior; it does not inform your choice of likelihood.
There are approaches to unknown likelihoods in Bayesian statistics, most of which, however, are more complicate than your problem requires.
Because if all you want to model is a mean $\mu$ and a variance $\sigma^2$, you're effectively estimating a second-order approximation to a unimodal symmetric distribution about its mode. The distribution that is its own 2nd-order approximation is the Gaussian.
Bottomline: just model $P_x$ as a Gaussian, reminiscent of QMLE.
Comment: Thanks. One thing remains unclear for me: Will the Gaussian approximation be better when $N\to\infty$? I mean, $\frac{1}{n}\log p(x_i;\mu,\sigma^2)$ may be more accurately approximated asymptotically?
Comment: The convergence of the likelihood function is more than just a Bayesian question. You'll probably [find the answer here](https://stats.stackexchange.com/q/616332).
Answer: Thanks for the help of @Durden. Here is my answer.
First, some relevant questions on this site: question 1 and question 2 are very relevant. @Sextus Empiricus 's answer seems to utilize the idea of Bayesian synthetic likelihood:

So we could use the likelihood function: $\mathcal{L}(\mu \vert \bar{X}) \approx \frac{1}{\sqrt{2 \pi \sigma^2/n}} \exp \left(\frac{(\bar X - \mu)^2}{2 \sigma^2/n} \right)$

The summary statistic $\bar{x}$ is observed and we can reasonably assume it follows a normal distribution per CLT. Then the posterior $\mu\mid x_{1:n}$ (here $\sigma^2$ is omitted because it's known and fixed) becomes $\mu\mid\bar{x}$. However, I have come up with a different explanation than replacing $x_{1:n}$ with $\bar{x}$.
Then, I provide an approach using Taylor expansion of log-likelihood. We konw in objective Bayes, the posterior distribution depends on the sum likelihood $p(x_{1:n}\mid\mu)$. For notation conveniency, let
$l(\mu)=\log p(x\mid\mu)$, the population log-likelihood.
$l_i(\mu)=\log p(x_i\mid\mu)$, the individual log-likelihood.
$\bar{l}(\mu)=\frac{1}{n}\log p(x_{1:n}\mid\mu)=\frac{1}{n}\sum_{i=1}^{n}l_i(\mu)$, the average log-likelihood. This corresponds to our target sum of log-likelihood.
$E[l(\mu)]=\mathrm{plim}_{n\to\infty}\bar{l}(\mu)$, the expected log-likelihood. The asymptotics can be used in this way.
Following this answer, the expected log-likelihood can be expanded in the parameter space (differing from the sample space) as a second-order Taylor series:
$\bar{l}(\mu)=\bar{l}(\mu_0)+\bar{l}'(\mu_0)(\mu-\mu_0)+\frac{1}{2}\bar{l}''(\mu_0)(\mu-\mu_0)^2+o^2.$
Let $\mu_0$ be the maximum likelihood estimator (MLE) point, i.e. $E[l'(\mu_0)]=0$. Also, this answer said:

Then one goes to show that the remainder converges uniformly in probability to zero...

So asymptotically ($n\to\infty$) we have
$E[l(\mu)]\approx E[l(\mu_0)]+\frac{1}{2}E[l''(\mu_0)](\mu-\mu_0)^2,$
which is essentially a quadratic approximation. This shows that asymptotically, the true average (also the expected) log-likelihood can be quadratically approximated. How do we do this quadratic approximation? A practical way is to model the individual log-likelihood $l_i(\mu)$ as Gaussian, whose highest order of Taylor expansion is 2. Then their sum and average will be just quadratic.
So my conclusion: In a large-sample setting, the problems of modelling the unkonwn population distribution as Gaussian will be alleviated, which is a different perspective compared to frequentists' CLT.
However, I found that the Gaussian approximation error may not converge to zero at the second-order level even asymptotically, and the remaining error comes from the Fisher information differences of two models! The true asymptotic posterior and the Gaussian-approximted asymptotic postetior are both normal, but with different variances depending on their respective Fisher information matrices, as the Bernstein-von Mises theorem shows. This is a problem not specific to Bayesians. Frequentists too suffer from so, as the QMLE estimator does not reach the Cramer-Rao lower bound. So relying on asymptotic inference may be problematic!
The case of unknown $\sigma^2$ would be a bit more tricky and I leave this unfinished.


Calculating the integral $\int_0^\infty \frac{\cos x}{1+x^2}\, \mathrm{d}x$ without using complex analysis

Question: Suppose that we do not know anything about the complex analysis (numbers). In this case, how to calculate the following integral in closed form?
$$\int_0^\infty\frac{\cos x}{1+x^2}\,\mathrm{d}x$$
Comment: Complex analysis methods: http://math.stackexchange.com/questions/100616/how-to-evaluate-this-integral
Answer: This can be done by the useful technique of differentiating under the integral sign.
In fact, this is exercise 10.23 in the second edition of "Mathematical Analysis" by Tom Apostol.
Here is the brief sketch (as laid out in the exercise itself).
Let $$ F(y) = \int\limits_{0}^{\infty} \frac{\sin xy}{x(1+x^2)} \ dx \ \ \text{for} \quad\quad y > 0$$
Show that
$\displaystyle F''(y) - F(y) + \pi/2 = 0$ and hence deduce  that $\displaystyle F(y) = \frac{\pi(1-e^{-y})}{2}$.
Use this to deduce that for $y > 0$ and $a > 0$
$$\displaystyle  \int_{0}^{\infty} \frac{\sin xy}{x(x^2 + a^2)} \ dx = \frac{\pi(1-e^{-ay})}{2a^2}$$
and
$$\int_{0}^{\infty} \frac{\cos xy}{x^2 + a^2}  dx = \frac{\pi e^{-ay}}{2a}$$
Comment: @AmadeusDrZaius: Differentiate $F(y)$ (differentiate with respect to $y$ inside the integral).
Comment: How does the $\cos$ integral follow from the $\sin$ integral?
Answer: Since
$$\frac{x}{1+x^2}=\int_0^\infty e^{-y}\sin (xy) \, dy,$$
we have that
$$I=\int_0^\infty \frac{\cos bx}{1+x^2} \, dx=\int_0^\infty \frac{\cos bx}{x} \, dx \int_0^\infty e^{-y}\sin (xy)\, dy.$$
Changing the order of integration (which can be justified by the standard method) yields
$$I=\int_{0}^{\infty}e^{-y} \, dy \int_0^\infty \frac{\sin xy}{x} \cos bx \, dx.$$
The calculation of the integral (a.k.a. the discontinuous Dirichlet factor)
$$\int_0^\infty \frac{\sin xy}{x} \cos bx \, dx = \begin{cases}0, & 0 < y < b
\\\ \ \\\ \pi/2, & 0 < b < y, \end{cases}$$
can be easily reduced to the calculation of the standard Dirichlet integral.
Therefore,
$$I=\frac{\pi}{2}\int_{b}^{\infty}e^{-y} \, dy = \frac{\pi}{2}e^{-b}.$$
Comment: Very inspiring solution! I learned a lot. Thanks!
Comment: . . . "which can be justified by the standard method" - it can be justified here, but not as routinely as you seem to suggest: the double integral does not quite converge absolutely, so Fubini is not automatic.
Comment: And how does one evaluate the Dirichlet integral without complex analysis?  Feynman's Trick is one way forward.  But why not simply use Feynman's Trick to begin and save yourself the unnecessary work herein?
Answer: These are the methods I use to evaluate
$$
\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx
$$
and post it on Brilliant.org as a solution of similar problem. You can use the similar technique to evaluate
$$
\int_0^{\infty}\frac{\cos x}{x^2+1}\,dx.
$$

Method 1:
Consider the function $f(t)=e^{-a|t|}$, then the Fourier transform of $f(t)$ is given by
$$
\begin{align}
F(\omega)=\mathcal{F}[f(t)]&=\int_{-\infty}^{\infty}f(t)e^{-i\omega t}\,dt\\
&=\int_{-\infty}^{\infty}e^{-a|t|}e^{-i\omega t}\,dt\\
&=\int_{-\infty}^{0}e^{at}e^{-i\omega t}\,dt+\int_{0}^{\infty}e^{-at}e^{-i\omega t}\,dt\\
 &=\lim_{u\to-\infty}\left. \frac{e^{(a-i\omega)t}}{a-i\omega} \right|_{t=u}^0-\lim_{v\to\infty}\left. \frac{e^{-(a+i\omega)t}}{a+i\omega} \right|_{0}^{t=v}\\
&=\frac{1}{a-i\omega}+\frac{1}{a+i\omega}\\
&=\frac{2a}{\omega^2+a^2}.
\end{align}
$$
Next, the inverse Fourier transform of $F(\omega)$ is
$$
\begin{align}
f(t)=\mathcal{F}^{-1}[F(\omega)]&=\frac{1}{2\pi}\int_{-\infty}^{\infty}F(\omega)e^{i\omega t}\,d\omega\\
e^{-a|t|}&=\frac{1}{2\pi}\int_{-\infty}^{\infty}\frac{2a}{\omega^2+a^2}e^{i\omega t}\,d\omega\\
\frac{\pi e^{-a|t|}}{a}&=\int_{-\infty}^{\infty}\frac{e^{i\omega t}}{\omega^2+a^2}\,d\omega.\tag1
\end{align}
$$
Now, rewrite
$$
\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx=\frac{1}{2}\int_{-\infty}^{\infty}\frac{\mathbb{Re}\left(e^{2ix}\right)}{x^2+2^2}\,dx.\tag2
$$
Comparing $(2)$ to $(1)$ yield $t=2$ and $a=2$. Thus,
$$
\begin{align}
\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx &=\frac{1}{2}\frac{\pi e^{-2\cdot|2|}}{2}\\
&=\frac{\pi}{4e^4}\\
\end{align}
$$
and
$$
\Large\color{blue}{\int_0^{\infty}\frac{\cos x}{x^2+1}\,dx=\frac{\pi}{2e}}.
$$

Method 2:
Note that:
$$
\int_{y=0}^\infty e^{-(x^2+4)y}\,dy=\frac{1}{x^2+4},
$$
therefore
$$
\int_{x=0}^\infty\int_{y=0}^\infty e^{-(x^2+4)y}\cos2x\,dy\,dx=\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx
$$
Rewrite $\cos2x=\Re\left(e^{-2ix}\right)$, then
$$
\begin{align}
\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx&=\int_{x=0}^\infty\int_{y=0}^\infty e^{-(x^2+4)y}\cos2x\,dy\,dx\\
&=\int_{y=0}^\infty\int_{x=0}^\infty e^{-(yx^2+2ix+4y)}\,dx\,dy\\
&=\int_{y=0}^\infty e^{-4y} \int_{x=0}^\infty e^{-(yx^2+2ix)}\,dx\,dy.
\end{align}
$$
In general
$$
\begin{align}
\int_{x=0}^\infty e^{-(ax^2+bx)}\,dx&=\int_{x=0}^\infty \exp\left(-a\left(\left(x+\frac{b}{2a}\right)^2-\frac{b^2}{4a^2}\right)\right)\,dx\\
&=\exp\left(\frac{b^2}{4a}\right)\int_{x=0}^\infty \exp\left(-a\left(x+\frac{b}{2a}\right)^2\right)\,dx\\
\end{align}
$$
Let $u=x+\frac{b}{2a}\;\rightarrow\;du=dx$, then
$$
\begin{align}
\int_{x=0}^\infty e^{-(ax^2+bx)}\,dx&=\exp\left(\frac{b^2}{4a}\right)\int_{x=0}^\infty \exp\left(-a\left(x+\frac{b}{2a}\right)^2\right)\,dx\\
&=\exp\left(\frac{b^2}{4a}\right)\int_{u=0}^\infty e^{-au^2}\,du.\\
\end{align}
$$
The last form integral is Gaussian integral that equals to $\dfrac{1}{2}\sqrt{\dfrac{\pi}{a}}$. Hence
$$
\int_{x=0}^\infty e^{-(ax^2+bx)}\,dx=\frac{1}{2}\sqrt{\frac{\pi}{a}}\exp\left(\frac{b^2}{4a}\right).
$$
Thus
$$
\int_{x=0}^\infty e^{-(yx^2+2ix)}\,dx=\frac{1}{2}\sqrt{\frac{\pi}{y}}\exp\left(\frac{(2i)^2}{4y}\right)=\frac{1}{2}\sqrt{\frac{\pi}{y}}\exp\left(-\frac{1}{y}\right).
$$
Next
$$
\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx=\frac{\sqrt{\pi}}{2}\int_{y=0}^\infty \frac{\exp\left(-4y-\frac{1}{y}\right)}{\sqrt{y}}\,dy.
$$
In general
$$
\begin{align}
\int_{y=0}^\infty \frac{\exp\left(-ay-\frac{b}{y}\right)}{\sqrt{y}}\,dy&=2\int_{v=0}^\infty \exp\left(-av^2-\frac{b}{v^2}\right)\,dv\\
&=2\int_{v=0}^\infty \exp\left(-a\left(v^2+\frac{b}{av^2}\right)\right)\,dv\\
&=2\int_{v=0}^\infty \exp\left(-a\left(v^2-2\sqrt{\frac{b}{a}}+\frac{b}{av^2}+2\sqrt{\frac{b}{a}}\right)\right)\,dv\\
&=2\int_{v=0}^\infty \exp\left(-a\left(v-\frac{1}{v}\sqrt{\frac{b}{a}}\right)^2-2\sqrt{ab}\right)\,dv\\
&=2\exp(-2\sqrt{ab})\int_{v=0}^\infty \exp\left(-a\left(v-\frac{1}{v}\sqrt{\frac{b}{a}}\right)^2\right)\,dv\\
\end{align}
$$
The trick to solve the last integral is by setting
$$
I=\int_{v=0}^\infty \exp\left(-a\left(v-\frac{1}{v}\sqrt{\frac{b}{a}}\right)^2\right)\,dv.
$$
Let $t=-\frac{1}{v}\sqrt{\frac{b}{a}}\;\rightarrow\;v=-\frac{1}{t}\sqrt{\frac{b}{a}}\;\rightarrow\;dv=\frac{1}{t^2}\sqrt{\frac{b}{a}}\,dt$, then
$$
I_t=\sqrt{\frac{b}{a}}\int_{t=0}^\infty \frac{\exp\left(-a\left(-\frac{1}{t}\sqrt{\frac{b}{a}}+t\right)^2\right)}{t^2}\,dt.
$$
Let $t=v\;\rightarrow\;dt=dv$, then
$$
I_t=\int_{t=0}^\infty \exp\left(-a\left(t-\frac{1}{t}\sqrt{\frac{b}{a}}\right)^2\right)\,dt.
$$
Adding the two $I_t$s yields
$$
2I=I_t+I_t=\int_{t=0}^\infty\left(1+\frac{1}{t^2}\sqrt{\frac{b}{a}}\right)\exp\left(-a\left(t-\frac{1}{t}\sqrt{\frac{b}{a}}\right)^2\right)\,dt.
$$
Let $s=t-\frac{1}{t}\sqrt{\frac{b}{a}}\;\rightarrow\;ds=\left(1+\frac{1}{t^2}\sqrt{\frac{b}{a}}\right)dt$ and for $0<t<\infty$ is corresponding to $-\infty<s<\infty$, then
$$
I=\frac{1}{2}\int_{s=-\infty}^\infty e^{-as^2}\,ds=\frac{1}{2}\sqrt{\frac{\pi}{a}}.
$$
Thus
$$
\begin{align}
\int_{y=0}^\infty \frac{\exp\left(-ay-\frac{b}{y}\right)}{\sqrt{y}}\,dy&=2\exp(-2\sqrt{ab})\int_{v=0}^\infty \exp\left(-a\left(v-\frac{1}{v}\sqrt{\frac{b}{a}}\right)^2\right)\,dv\\
&=\sqrt{\frac{\pi}{a}}e^{-2\sqrt{ab}}\\
\end{align}
$$
and
$$
\begin{align}
\int_0^{\infty}\frac{\cos2x}{x^2+4}\,dx&=\frac{\sqrt{\pi}}{2}\int_{y=0}^\infty \frac{\exp\left(-4y-\frac{1}{y}\right)}{\sqrt{y}}\,dy\\
&=\frac{\sqrt{\pi}}{2}\cdot\sqrt{\frac{\pi}{4}}e^{-2\sqrt{4\cdot1}}\\
&=\frac{\pi}{4e^4}.
\end{align}
$$
Hence
$$
\Large\color{blue}{\int_0^{\infty}\frac{\cos x}{x^2+1}\,dx=\frac{\pi}{2e}}.
$$
Answer: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
$\ds{\int_{0}^{\infty}{\cos\pars{x} \over 1 + x^{2}}\dd x:\ {\large ?}}$
\begin{align}
\mbox{Lets}\quad\fermi\pars{\mu} & \equiv
\half\int_{-\infty}^{\infty}{\cos\pars{\mu x} \over
1 + x^{2}}\,\dd x
\\[5mm] \quad\mbox{such that}\quad &
\left\lbrace\begin{array}{rcl}
\ds{\int_{0}^{\infty}{\cos\pars{x} \over 1 + x^{2}}\dd x} & \ds{=} & \ds{\fermi\pars{1}}
\\[2mm]
\ds{\fermi\pars{0}} & = & \ds{\pi \over 2}
\end{array}\right.
\end{align}

\begin{align}
\fermi''\pars{\mu} & =
\half\int_{-\infty}^{\infty}
{-x^{2}\cos\pars{\mu x} \over 1 + x^{2}}\,\dd x
\\[5mm] & =
-\pi\,\Re\int_{-\infty}^{\infty}\expo{\ic\mu x}
\,{\dd x \over 2\pi} +\fermi\pars{\mu}
\\[5mm]& \implies\quad\fermi''\pars{\mu} - \fermi\pars{\mu} = -\pi\,\delta\pars{\mu}
\end{align}
The differential equation is equivalent to:
$$\left\lbrace
\begin{array}{rcl}
\fermi''\pars{\mu} - \fermi\pars{\mu} = 0 & \mbox{if} & \mu \not= 0
\\[2mm]
\fermi'\pars{0^{+}} - \fermi'\pars{0^{-}} & = & -\pi
\end{array}\right.
$$
When $\ds{\mu \not= 0}$, the solutions are linear combinations of $\ds{\expo{\pm\mu}}$. Since $\ds{\fermi\pars{0} = {\pi \over 2}}$and the solution is continuos at $\ds{\mu = 0}$ and finite, we'll get:
$$
\fermi\pars{\mu} = {\pi \over 2}\,\expo{-\verts{\mu}}
$$
It satisfies
$\ds{\fermi'\pars{0^{+}} - \fermi'\pars{0^{-}} = \pars{-\,{\pi \over 2}} - \pars{{\pi \over 2}} = -\pi}$
$$\color{#44f}{\large
\int_{0}^{\infty}{\cos\pars{x} \over 1 + x^{2}}\dd x}
=\fermi\pars{1} = {\pi \over 2}\,\expo{-\verts{1}}=
\color{#44f}{\large{\pi \over 2\expo{}}}
$$
Answer: The method of brackets, which is an extension of Ramanujan's master theorem, can be used to evaluate this classic integral.
The term bracket refers to the assignment of the symbol $\langle a \rangle$ to the divergent integral $\int_{0}^{\infty} x^{a -1} \, \mathrm{d}x$.
You can read about the method in the following papers:
Definite integrals by the method of brackets. Part 1
The method of brackets. Part 2: Examples and applications
Evaluation of entries in Gradshteyn and Ryzhik employing the
method of brackets
On the Method of Brackets: Rules, Examples, Interpretations and Modifications

The hypergeometric representation of the cosine function is $$ \, _0F_{1} \left(; \frac{1}{2}; - \frac{x^{2}}{4} \right) = \sum_{n=0}^{\infty} \frac{(-1)^{n}}{n!} \,  \frac{\Gamma \left( \frac{1}{2} \right)}{\Gamma \left(n+\frac{1}{2} \right)} \left(\frac{x^{2}}{4} \right)^{n} = \sum_{n=0}^{\infty} \phi_{n} \,  \frac{\Gamma \left( \frac{1}{2} \right)}{\Gamma \left(n+\frac{1}{2} \right)} \left(\frac{x^{2}}{4} \right)^{n}. $$
(This representation can be derived from the Maclaurin series of $\cos (x)$ by using the duplication formula for the gamma function).
And according to Rule 3.1 on page 8 of the first paper, the function $   \frac{1}{1+x^{2}}$ is assigned the bracket series $$\sum_{k=0}^{\infty} \sum_{m=0}^{\infty} \phi_{k,m} \, x^{2m}  \langle k+m+1 \rangle. $$
Therefore, the integral $  \int_{0}^{\infty} \frac{\cos x}{1+x^{2}} \, \mathrm{d}x$ corresponds with the bracket series $$ \sum_{k=0}^{\infty} \sum_{m=0}^{\infty} \sum_{n=0}^{\infty} \phi_{k,m,n} \, \frac{\Gamma \left(\frac{1}{2} \right)}{\Gamma \left(n+\frac{1}{2}\right)} \frac{1}{4^{n}} \langle k+m+1\rangle \langle 2m+2n+1 \rangle. \tag{1}$$
To evaluate $(1)$, first let $k$ be a free parameter.
The brackets then vanish if $m=-k-1$ and $n= k + \frac{1}{2}$.
So according to Rule 3.3 in the first paper, the contribution to the integral is
$$\begin{align}\frac{1}{2} \sum_{k=0}^{\infty} \frac{(-1)^{k}}{k!} \frac{\Gamma \left(\frac{1}{2} \right)}{\Gamma (k+1 )} \, \frac{\Gamma (k+1) \Gamma \left(-k-\frac{1}{2} \right)}{4^{k+ 1/2}}  &= \frac{\sqrt{\pi}}{4} \sum_{k=0}^{\infty} \frac{(-1)^{k}}{k!} \frac{1}{4^{k}} \frac{\pi (-1)^{k-1} }{\Gamma \left(k + \frac{3}{2} \right)}  \\ &= - \frac{\pi  \sqrt{\pi} }{4}  \sum_{k=0}^{\infty} \frac{1}{k!} \frac{1}{4^{k}}  \frac{2^{2(k+1)-1} \Gamma(k+1)}{ \sqrt{\pi} \,  \Gamma(2k+2)}  \\ &= -\frac{\pi}{2} \sum_{k=0}^{\infty} \frac{1}{(2k+1)!} \\ &= -\frac{\pi}{2} \, \sinh (1). \end{align}$$
(I used the reflection formula for the gamma function on the first line, and then I used the duplication formula for the gamma function on the second line.)
Now let $m$ be a free parameter.
The brackets then vanish if $k = -m-1$ and $n=-m -\frac{1}{2}$.
So according to Rule 3.3, the contribution to the integral is $$ \frac{1}{2} \sum_{m=0}^{\infty} \frac{(-1)^{m}}{m!} \frac{\Gamma \left(\frac{1}{2} \right)}{{\color{red}{\Gamma (-m)}}} \frac{\Gamma(m+1) \Gamma \left(m+ \frac{1}{2} \right)}{4^{-m-1/2}} =0.$$
Finally let $n$ be a free parameter.
The brackets then vanish if $k = - n - \frac{1}{2}$and $m=  n - \frac{1}{2}$.
So according to Rule 3.3, the contribution to the integral is
$$\begin{align}\frac{1}{2} \sum_{n=0}^{\infty} \frac{(-1)^{n}}{n!} \frac{\Gamma \left(\frac{1}{2} \right)}{\Gamma (n + \frac{1}{2} )} \, \frac{\Gamma \left(n + \frac{1}{2} \right) \Gamma \left(\frac{1}{2}-n \right) }{4^{n}}  &= \frac{\sqrt{\pi}}{2} \sum_{n=0}^{\infty} \frac{(-1)^{n}}{n!} \frac{1}{4^{n}} \frac{\pi (-1)^{n}}{\Gamma \left(n+ \frac{1}{2} \right)} \\ &= \frac{\pi \sqrt{\pi}}{2}  \sum_{n=0}^{\infty} \frac{1}{n!} \frac{1}{4^{n}}  \frac{2^{2(n+1/2)-1} \Gamma(n+1)}{\sqrt{\pi} \,  \Gamma(2n+1)} \\ &= \frac{\pi}{2} \sum_{n=0}^{\infty} \frac{1}{(2n)!} \\ &= \frac{\pi}{2} \, \cosh (1). \end{align}$$
Rule 3.4 in the first paper says that we should add these three contributions to get the value of the integral.
Therefore, $$\int_{0}^{\infty} \frac{\cos(x)}{1+x^{2}} \, \mathrm{d}x = - \frac{\pi}{2} \sinh(1) + 0 + \frac{\pi}{2} \cosh(1) = \frac{\pi}{2e}.$$
Comment: A nicely written solution.  +1
Answer: The previous answer is not correct. If you use the Taylor expansion of cosine and integrate termwise you consider integrals of the following form:
\begin{eqnarray}
\int_{0}^{\infty} \frac{x^{a} \ dx}{1 + x^{2}} = \tfrac{\pi}{2} \sec (\tfrac{\pi a}{2})
\end{eqnarray}
which is only well-defined if $-1 < a < 1$.
Answer: Another way forward is to use Feynman's Trick.  To that end, let $I(a)$ be the integral
$$I(a,b)=\int_0^\infty e^{-ax}\frac{\cos(bx)}{1+x^2}\,dx \tag 1$$
for $a\ge 0$.  Then, for $a>0$ we have
$$\begin{align}
\frac{\partial^2 I(a,b)}{\partial b^2}&=-\int_0^\infty e^{-ax}\frac{x^2\cos(bx)}{1+x^2}\,dx\\\\
&=I(a,b)-\frac{a}{a^2+b^2}
\end{align}$$
Therefore, using $\lim_{b\to \infty}I(a,b)=0$ (apply the Riemann-Lebesgue Lemma), we find that for $a>0$
$$I(a,b)=C(a)e^{-|b|}+\frac12\int_0^\infty e^{-|b-x|}\frac{a}{a^2+x^2}\,dx \tag 2$$
for some function $C(a)$.
When $b=0$ and $a\to 0^+$, $I(a,b)$ as given by $(2)$ is $I(0^+,0)=C(0^+)+\frac{\pi }{4}$, where $I(0^+,0)$ as given by $(1)$ is $I(0^+,0)=\frac{\pi}{2}$. Therefore, we find that $C(0^+)=\frac{\pi}{4}$.
Finally, when $b=1$ we have from $(1)$,
$$\lim_{a\to 0^+}I(a,1)=I(0,1) \tag 3$$
whereas we have from $(2)$, we have
$$\lim_{a\to 0^+}I(a,1)=\frac{\pi}{2e}\tag 4$$
Comparing $(3)$ and $(4)$ yields
$$I(0,1)=\frac{\pi}{2e}$$
as expected!
Answer: Let $\lambda\in\mathbb{R}$, set
$$I(\lambda)=\int_{-\infty}^{\infty}{\cos(\lambda x)\over x^2+1}dx$$
we use integrate by parts, writing
$$u=\frac{1}{{{x}^{2}}+1}\quad,\quad dv=\cos (\lambda x)$$
we have
$$I(\lambda )=\frac{\sin (\lambda x)}{\lambda ({{x}^{2}}+1)}\left| \begin{matrix}
   \infty   \\
   -\infty   \\
\end{matrix} \right.+\frac{2}{\lambda }\int_{-\infty }^{+\infty }{\frac{\sin (\lambda x)}{{{({{x}^{2}}+1)}^{2}}}}\,dx
$$
as a result
$$\lambda I(\lambda )=2\int_{-\infty }^{\infty }{\frac{x\sin \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx \,.\quad(1)$$
By differentiate with respect $\lambda$ to get
$$\lambda \frac{dI}{d\lambda }+I(\lambda )=2\int_{-\infty }^{\infty }{\frac{{{x}^{2}}\cos \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx=\underbrace{2\int_{-\infty }^{\infty }{\frac{\cos \lambda x}{{{x}^{2}}+1}\,}dx}_{2I(\lambda )}-2\int_{-\infty }^{\infty }{\frac{\cos \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx$$
therefore
$$\lambda \frac{dI}{d\lambda }-I(\lambda )=-2\int_{-\infty }^{\infty }{\frac{\cos \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx$$
and
$$\lambda \frac{{{d}^{2}}I}{d{{\lambda }^{2}}}=2\int_{-\infty }^{\infty }{\frac{x\sin \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,}dx.\quad(2)$$
$(1)$ and $(2)$
$$\frac{{{d}^{2}}I(\lambda)}{d{{\lambda }^{2}}}- I(\lambda )=0$$
thus
$$I(\lambda)=c_1e^{\lambda}+c_2e^{-\lambda}$$
on the other hand
\begin{align}
  & I(0)={{c}_{1}}+{{c}_{2}}=\int_{-\infty }^{+\infty }{\frac{1}{{{x}^{2}}+1}}\,dx=\pi \,\,\,\,\Rightarrow \,\,{{c}_{1}}+{{c}_{2}}=\pi \, \\
 & I(\lambda )=\frac{2}{\lambda }\int_{-\infty }^{+\infty }{\frac{x\sin \lambda x}{{{({{x}^{2}}+1)}^{2}}}\,\,}dx\,\,\,\Rightarrow \,\,\underset{\lambda \to \infty }{\mathop{\lim }}\,I(\lambda )=0\,\,\,\Rightarrow \,{{c}_{1}}=0 \\
\end{align}
then
$$I(\lambda )=\pi {{e}^{-\lambda }}$$
set $\lambda=1$, we have
$$I(1)=\int_{-\infty}^{\infty}{\cos( x)\over x^2+1}dx=\frac{\pi}{e}$$
so
$$\int_{0}^{\infty}{\cos( x)\over x^2+1}dx=\frac{\pi}{2e}$$
Comment: Nice solution.  +1
Comment: So thanks Mark ;)
Comment: Very nice! I've been trying to do that for a couple of hours, but it didn't occur to me to use 2nd order equations instead of 1st order.
Answer: Glaisher's theorem, which is a special case of Ramanujan's master theorem, can also be used to compute this integral. If a function has a series expansion of the form:
$$f(x) = \sum_{k=0}^{\infty}(-1)^k c_{k}x^{2k}$$
then:
$$\int_0^{\infty}f(x) dx = \frac{\pi}{2}c_{-\frac{1}{2}}$$
Here $c_{-\frac{1}{2}}$ is obtained by analytically continuing $c_k$, e.g.  by  writing $c_k$ in terms of gamma functions (the rigorous way to do this is to apply the rigorous version of Ramanujan's master theorem). The above expression is only valid if the integral converges. For $f(x)=\frac{\cos(x)}{1+x^2}$, we have:
$$c_k = \sum_{j=0}^{k}\frac{1}{(2j)!}$$
We can obtain the analytic continuation of $c_k$ by considering the limiting value at infinity:
$$\lim_{k\to\infty}c_{k} = \cosh(1)$$
and by imposing the recursion relation
$$c_{k+1} = c_{k} + \frac{1}{(2k+2)!}$$
for general $k$. This means that for general $k$ we have:
$$c_k + \sum_{j=k+1}^{\infty}\frac{1}{(2j)!} = \cosh(1)$$
To compute $c_{-\frac{1}{2}}$, we thus need to evaluate the summation:
$$\sum_{j=\frac{1}{2}}^{\infty}\frac{1}{(2j)!} = \sum_{j=0}^{\infty}\frac{1}{(2(j+\frac{1}{2}))!} = \sum_{j=0}^{\infty}\frac{1}{(2j+1)!} = \sinh(1)$$
Therefore:
$$c_{-\frac{1}{2}} = \exp(-1)$$
and the integral is given by $\frac{\pi}{2} \exp(-1)$.
Answer:
Recall that, if we consider the Fourier transform
  $$\mathcal Ff (a) =\int_\Bbb R e^{-ia x}f(x)dx$$
  then its Fourier inverse  is defined as
  $$\mathcal F^{-1}f (x) =\frac{1}{2\pi}\int_\Bbb R e^{it x}f(t)dt.$$

But we have,
\begin{split}
\mathcal F(e^{-|t|})(x) = \int_{-\infty}^{\infty}e^{-|t|}e^{-ix t}\,dt
&=&\int_{-\infty}^{0}e^{t}e^{-ix t}\,dt+\int_{0}^{\infty}e^{-t}e^{-ix t}\,dt\\
 &=&\left[ \frac{e^{(1-ix)t}}{1-ix} \right]_{-\infty}^0-\left[\frac{e^{-(1+ix)t}}{1+ix} \right]_{0}^{\infty}\\
&=&\frac{1}{1-ix}+\frac{1}{1+ix}\\
&=&\frac{2}{x^2+1}.
\end{split}
Then,
$$
\begin{align}
e^{-|a|}=\mathcal F^{-1}\left( \frac{2}{x^2+1}\right)(a) &=\frac{1}{2\pi}\int_\Bbb R \frac{2}{x^2+1}e^{ix a}\,dx =
\frac{1}{\pi}\int_\Bbb R\frac{e^{ix a}}{x^2+1}\,dx \\&=\frac{1}{\pi}\int_\Bbb R\frac{\cos a x}{x^2+1}\,dx = \frac{2}{\pi}\int_0^\infty\frac{\cos ax}{x^2+1}\,dx
\end{align}
$$
 Given that, as $x\mapsto\sin ax $ is an old function we have,
 $$\int_\Bbb R \frac{\sin{a x}}{x^2+1}dx= 0.$$
Thus we have,
$$
\int_0^\infty\frac{\cos ax}{x^2+1}\,dx =\frac{\pi}{2}e^{-|a|}
$$
Answer: I am surprised nobody has written about Schwinger's method, which can be used to evaluate loop integrals in quantum field theory, and which nicely computes this integral in combination with Glasser's master theorem. First notice that the integral can be re-written as
$$\int_0^\infty \cos(x)\int_0^\infty e^{-u(1+x^2)}\,du\,dx.$$
Now, switch the order of integration and extend the range of one of the integral to the entire real line, gaining  a factor of $1/2$:
$$\frac{1}{2}\int_0^\infty e^{-u}\int_{-\infty}^\infty e^{-x^2+ix}\,dx\,du.$$
Complete the square in the exponential, and evaluate the now Gaussian integral (use the analyticity of $e^{-z^2}$ to bring the line of integration back to the real line) to obtain
$$\sqrt{\pi}\int_0^\infty \frac{du}{2\sqrt{u}}\,\exp-\left(u-\frac{1}{4u}\right).$$
The time is ripe for a substitution $x=\sqrt{u}$, bringing us to
$$\frac{\sqrt{\pi}}{2}e^{-1}\int_{-\infty}^\infty dx\, \exp-\left(x-\frac{1}{2x}\right)^2.$$
Glasser's master theorem  now tells us how to compute this last integral, reducing it to a Gaussian, and the original integral is just
$$\frac{\pi}{2}e^{-1}.$$
Answer: I'm using the Feynman trick.
Let $f(t)=\int_{0}^{\infty}\frac{\cos x}{1+x^2}e^{-t(1+x^2)}\, dx$. Then $f'(t)=-\int_{0}^{\infty}\cos x \cdot e^{-t}e^{-tx^2}\, dx$.
Then $-f'(t)=e^{-t}\int_{0}^{\infty}\cos x \cdot e^{-tx^2}\, dx$.
So, as $\cos x=\sum_{n\ge 0}(-1)^n\frac{x^{2n}}{(2n)!}$, and $\int_{0}^{\infty}x^{2n}e^{-tx^2}\, dx=\frac{\sqrt{\pi}}{2}\frac{(2n)!}{2^{2n}n!}(\frac{1}{\sqrt{t}})^{2n+1}$, so $-f'(t)=e^{-t}\sum_{n\ge 0}(-1)^{n}\frac{\sqrt{\pi}}{2}\frac{(2n)!}{2^{2n}n!n!}(\frac{1}{\sqrt{t}})^{2n+1}$. So $f'(t)=-e^{-t}\frac{\sqrt{\pi}}{2}\sum_{n\ge 0}(-1)^n\binom{2n}{n}\frac{1}{2^{2n}}(\frac{1}{\sqrt{t}})^{2n+1}$.
Look at the series for $(1+u^2)^{-\frac{1}{2}}$.
So $f'(t)=-e^{-t}\cdot \frac{1}{\sqrt{t}}\frac{\sqrt{\pi}}{2}\times\frac{1}{\sqrt{1+\frac{1}{t}}}$.
Hence $f'(t)=-e^{-t}\cdot\frac{\sqrt{\pi}}{2}\cdot \frac{1}{\sqrt{t+1}}$
So by integrating, $f(t)=c+\frac{\sqrt{\pi}}{2}e\Gamma(\frac{1}{2},t+1)$, with $\Gamma$ being the incomplete gamma function. I can't complete the argument further, but I feel it may be possible to find the value of $f(0)$ (and hence $\int_{0}^{\infty}\frac{\cos x}{1+x^2}\, dx$ from this idea.
Answer: Considering
$$\int_{0}^{\infty}e^{-t}\sin (xt)dt=\frac{1}{1+x^2},$$
And $$\int_{0}^{\infty}\frac{\cos{mx}}{1+x^2}dx=\int_{0}^{\infty}dx\int_{0}^{\infty}dt\text{ }\big(e^{-t}\cos{(mx)}\cos{(xt)}\big),$$
$$=\int_{0}^{\infty}dx\int_{0}^{\infty}dt\text{ }\big(e^{-t}\frac{\cos{(m+t)x}+\cos(m-t)x}{2} \big)$$
where $\int_{0}^{\infty}\cos{Qa da=\pi\delta(Q)}$, and $\delta$ is Dirac-Delta function.
$$=\int_{0}^{\infty}dt\text{ }\frac{e^{-t}}{2}\big(\pi\delta(m+t)+\pi\delta(m-t) \big)$$
hence: $$\int_{0}^{\infty}\frac{\cos{mx}}{1+x^2}dx=0+\frac{\pi}{2}e^{-|m|},$$
plug in $m=1$:
$$\int_{0}^{\infty}\frac{\cos{x}}{1+x^2}dx=\frac{\pi}{2}e^{-1}$$

Reference: Feynman's Lectures on Mathematical Methods (lecture notes) Lec 3,4 and 5.


Select não carrega os options corrretamente

Question: Bom dia Galera Dev, desde ontém me deparei como uma situação um tanto bizarra (se posso falar assim).
Eu estou utilizando php poo para carregar um select e trazendo a resposta em um while:
while($dados = $sql->fetch_assoc()){
    $cd_cobr = $dados["cd_tipo_cobr"];
    $ds_cobr = $dados["ds_tipo_cobr"];

    echo("<option value='$cd_cobr' selected='yes'> $ds_cobr </option>");
    echo("$cd_cobr $ds_cobr");
}

Já fiz dessa forma 1 milhão de vezes, mas desde ontem ele está carregando o html assim:

Percebam que eu mandei printar propositalmente as variáveis para ver se o valor estava correto, e está. Se eu inverto as variáveis de ordem só aparece o 'PAG'. Alguém tem alguma ideia do que pode ser?
Answer: Tente dessa forma:
echo "<option value='", $cd_cobr , "' selected='yes'>", $ds_cobr, "</option>";

Answer: Consegui achar o problema, havia duas requisições em java/jquery que lia o select e isso estava fazendo o 'value' ficar NULL, removi uma das requisições e funcionou.


Dialog in Custom Adapter in android

Question: I have one custom adapter that have one checkbox and one textview.I want when user clicked on one row one alert dialog pop up and user enter data.I use following code in activity and worked fine:
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View layout = inflater.inflate(R.layout.floordialog,
            (ViewGroup) findViewById(R.id.floordialog));

    floornum = (EditText) layout.findViewById(R.id.floordialog_floornumber);
    unitnum = (EditText) layout.findViewById(R.id.floordialog_unitnumber);
    Button next = (Button) layout.findViewById(R.id.floordialog_next);
    Button cancel = (Button) layout.findViewById(R.id.floordialog_cancel);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("floors");
    builder.setView(layout);
    builder.setCancelable(false);
    builder.create();

    flooralert = builder.create();
    flooralert.show();

    next.setOnClickListener(this);
    cancel.setOnClickListener(this);

but i cant use in MyCustomAdapter because i Dont extend activity, how can solve my problem?
and this is my CustomAdapter
        public MyadapterForListFloor(Activity a, int textViewResourceId,
        ArrayList<Integer> Floornum) {
    super();
    unitdialog = new UnitDialog();
    this.entries = Floornum;
    this.activity = a;
}

@Override
public int getCount() {

    return entries.size();
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    View v = convertView;

    if (v == null) {
        LayoutInflater vi = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.unitview, null);
        holder = new ViewHolder();
        holder.text = (TextView) v.findViewById(R.id.UnitTextview);
        holder.checked = (CheckBox) v.findViewById(R.id.unitCheckbox);

        v.setTag(holder);

        holder.checked.setTag(entries.get(position));
        holder.text.setTag(entries.get(position));

        holder.checked.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                ViewHolder obj = new ViewHolder();
                obj.checked = (CheckBox) v.findViewById(R.id.unitCheckbox);

                getid = (Integer) v.getTag();

                if (isChecked(getid))
                {
                    obj.checked.setChecked(true);
                    unitdialog.DialogForFloor();
                    Urban.selectedRow.add(getid);
                }
                else
                    Log.d("in else onclick", "**");
            }

            private boolean isChecked(int getid) {

                for (int i = 0 ; i< Urban.selectedRow.size() ; i++)
                {
                    if (Urban.selectedRow.get(i)== getid)
                        return false;
                }
                return true;
            }

        });
        holder.text.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                holder.checked.performClick();
            }
        });
    }
    else
    {
        ((ViewHolder) v.getTag()).checked.setTag(entries.get(position));
        holder = (ViewHolder) v.getTag();

        getid = (Integer) holder.checked.getTag();

        Log.d("geti is", String.valueOf(getid));

        if (checkBoxRefresh(getid))
            holder.checked.setChecked(true);

        else
            holder.checked.setChecked(false);

    }

    final String str = String.valueOf(entries.get(position));
    if (str != null) {

        holder.text.setText(str);

    }

    return v;
}

private boolean checkBoxRefresh(int FloorNum) {
    Log.d("urban.selectedrow.size is", String.valueOf(Urban.selectedRow.size()));
    for (int i = 0 ; i < Urban.selectedRow.size() ; i++)
    {
        if (Urban.selectedRow.get(i) == FloorNum)
            return true;
    }
    return false;

}

static class ViewHolder {
    TextView text;
    CheckBox checked;

}

}
Comment: Pass your context to MyCustomAdapter. Show your code for MyCustomAdapter..
Comment: So what's the problem? What do you want to do that you can't do?
Comment: I have CustomAlertDialog Too, that i need findviewById that dont recognize
Comment: how can define LayoutInflater and how can refer to my edittext in alertdialog?
Comment: You can create a separate method for your custom alertdialog in your class and you can invoke that method whenever you click onItem of your ListView or whichever you have used by implementing `setOnItemClickListener`.
Answer: In Class CustomAdapter you need to declare a class level variable mContext
Context mContext;

Create a constructor:
public AdapterAudio(Context mContext) {
    super();
    this.mContext = mContext;
}

When you call CustomAdapter from Activity, "Activity_Main.this" is Context you need
CustomAdapter adapter = new CustomAdapter(Activity_Main.this);

Don't pass getApplicationContext(), we need to pass MainActivity.this to the constructor as AlertDialog class need this to show alert.
If you pass getApplicationContext() or getContext() then you will get the following error:
W/System.err: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Now, pass the mContext to show alert:
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setTitle("floors");
    builder.setView(layout);
    builder.setCancelable(false);
    builder.create();

    flooralert = builder.create();
    flooralert.show();

Answer: Try this:
 LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

You are already passing your Context to MyCustomAdapter.
Comment: its worked , but how can define my View? i use final View layout = inflater.inflate(R.layout.floordialog,
    (ViewGroup) findViewById(R.id.floordialog));
Comment: Same thing. activity.findViewById.
Comment: but activity layout and alertDialog layout is separated, i dont Think So Its Work !!!
Answer: Simply pass necessary Context to your adapter from activity and use that context in your dailog.
Here@
AlertDialog.Builder builder = new AlertDialog.Builder(here will be your context which is from activity);

As you mention in your comment that you  have to custom dialog and you have to do findviewById.
you can do like this@ (It just an example)
Updated
AlertDialog.Builder builder = new AlertDialog.Builder(your_activity_context);
View view = your_activity_context.getLayoutInflater().inflate(R.layout.dialog_layout, null);
builder.setView(view);

 Button button = (Button) view.findViewById(R.id.dialog_ok);

Comment: i need LayoutInflater to refer to my edittext in alertdialog, can you explain to me how can create LayoutInflater and View because findviewbyid dont recognize.
Comment: I try to put first part of my code that is for my alert dialog in the second part that is my CustomAdapter, if you think that is better way to do that please suggest me.tnx

Dialog in Custom Adapter in android


Carousel next previous buttons moving up and down how to fix it?

Question: When the slide changes the next previous buttons move up and down I am trying to figure out how to make sure that it remains in one position. I think it is somehow aligning itself according to the text (vertically at the center) so if the text is not equal in all the slides then it appears to move up and down.
https://jsfiddle.net/39amxqjd/4/

    <link rel="stylesheet" type="text/css" id="skin"  href="assets/css/themes/default.css">

dsfdsf

                                             fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd

sfdsdfds

                                            fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd

sdfsfsd

                                            fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd fsdfdsfsd

                                Previous

                                Next

Js Code
jQuery(document).ready(function() {

     // ------------------------------------------------------------------------------ //
    // owl Detail property
    // ------------------------------------------------------------------------------ //
    var changeSlide = 4; // mobile -1, desktop + 1
    // Resize and refresh page. slider-two slideBy bug remove
    var slide = changeSlide;
    if ($(window).width() < 600) {
        var slide = changeSlide;
        slide--;
    } else if ($(window).width() > 999) {
        var slide = changeSlide;
        slide++;
    } else {
        var slide = changeSlide;
    }
    $(document).ready(function() {
        $('.one').owlCarousel({
            nav: true,
            items: 1,
        })
        $('.wrap-features-bestproperties').owlCarousel({
            loop: true,
            items: 1,
            autoplay: true,
            autoplayTimeout: 4000,
            smartSpeed: 1200,
        })
        $('.two').owlCarousel({
            nav: true,
            margin: 15,
            mouseDrag: false,
            touchDrag: false,
            responsive: {
                0: {
                    items: changeSlide - 1,
                    slideBy: changeSlide - 1
                },
                600: {
                    items: changeSlide,
                    slideBy: changeSlide
                },
                1000: {
                    items: changeSlide + 1,
                    slideBy: changeSlide + 1
                }
            }
        })
        var owl = $('.one');
        owl.owlCarousel();
        owl.on('translated.owl.carousel', function(event) {
            $(".right").removeClass("nonr");
            $(".left").removeClass("nonl");
            if ($('.one .owl-next').is(".disabled")) {
                $(".slider .right").addClass("nonr");
            }
            if ($('.one .owl-prev').is(".disabled")) {
                $(".slider .left").addClass("nonl");
            }
            $('.slider-two .item').removeClass("active");
            var c = $(".slider .owl-item.active").index();
            $('.slider-two .item').eq(c).addClass("active");
            var d = Math.ceil((c + 1) / (slide)) - 1;
            $(".slider-two .owl-dots .owl-dot").eq(d).trigger('click');
        })
        $('.right').click(function() {
            $(".slider .owl-next").trigger('click');
        });
        $('.left').click(function() {
            $(".slider .owl-prev").trigger('click');
        });
        $('.slider-two .item').click(function() {
            var b = $(".item").index(this);
            $(".slider .owl-dots .owl-dot").eq(b).trigger('click');
            $(".slider-two .item").removeClass("active");
            $(this).addClass("active");
        });
        var owl2 = $('.two');
        owl2.owlCarousel();
        owl2.on('translated.owl.carousel', function(event) {
            $(".right-t").removeClass("nonr-t");
            $(".left-t").removeClass("nonl-t");
            if ($('.two .owl-next').is(".disabled")) {
                $(".slider-two .right-t").addClass("nonr-t");
            }
            if ($('.two .owl-prev').is(".disabled")) {
                $(".slider-two .left-t").addClass("nonl-t");
            }
        })
        $('.right-t').click(function() {
            $(".slider-two .owl-next").trigger('click');
        });
        $('.left-t').click(function() {
            $(".slider-two .owl-prev").trigger('click');
        });
    });
    // CLIENTS SLIDER LOGOS
    $(".clients-slider").owlCarousel({
        nav: true,
        margin: 15,
        rewind: true,
        smartSpeed: 1200,
        autoplay: true,
        navText: ["", ""],
        responsive: {
            0: {
                items: 1
            },
            480:{
                items:1
            },
            600: {
                items: 2
            },
            1000: {
                items: 5
            }
        }
    });

});

Answer: You can force the height of your .carousel-inner so the arrows will always be centered regarding of the same sized box.
You can see the result on your updated fiddle.
This solution is really basic and do not care of the content the client can put on. You will probably have to limit client characters entry, or do an ellips for example.
Answer: Your problem is that your parent element doesn't have static height, it set height depended of it's items height, try to set height to your parent and to children height: 100%

...

...

...

Your parent should be relative and have some static height e.g. 500px or 100% of his parent etc. and his children should have 100% of height,
.parent {
    position: relative;
    height: 500px;
}
.children {
    height: 100%;
}

Try to implement this idea in your project in js fiddle it worked


Will JWT authorizer in aws HTTP API gateway cache Public key to avoid repeated call to Authorisation server

Question: Will JWT authorizer in  aws HTTP API gateway cache Public key to avoid repeated call to Authorisation server ?
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: Yes it does. It is documented in the part explaining how cognito keys are cached by API Gateway:
https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-caching-tokens.html


jQuery blocks style

Question: Here comes a noob question: saw a jQuery code that was written like this:
    var PRINCIPAL = {};

PRINCIPAL.Function = function($element) {
    var self = this;
    /*more vars*/

    this.init = function() {
        self.initialFunction();
    };
    this.initialFunction = function() {
        /*code here*/
    };
    this.secondOne = function() {
        /*code here*/
    };
    this.init();
};
    /*associative array below??*/
PRINCIPAL.array = {
    CONFIGURATION: 10,
    CONFIGURATION2: 200,
    init: function($element) {
        /*code here*/
    },
    firstFunction: function() {
        /*code here*/
    },
    secondOne: function() {
        /*code here*/
    },
    thirdOne: function() {
        /*code here*/
    }
};
/*and at the end it stars all functions inside the blocks*/
$(function() {
    PRINCIPAL.array.init($('#element'));
});

Ok, now: there was a lot of arrays(?) like the one above, and some other functions too, all the code was all divided in blocks. I don't get it much, is this a kind of programming style or what?
Comment: in javascript, `{}` denotes an object not an array. all the `function() {}` are anonymous functions, which are used here to store functions in variables to be executed later.
Comment: Re your question "associative array below?" Yes, sort of. Some people (mostly from PHP) call objects "associative arrays," but in JavaScript, the normal term is just "object" or "map" or (rarely) "dictionary".
Answer: This is object notation.  It is not particularly well-written code, though, so you might not want to use it as a learning example.
The general principle, though, is that {} denotes an object, so PRINCIPAL becomes an object by assignment.  The dot notation allows you to access the object's parameters and methods easily, so the first block defines a method (or function) and the second block a parameter, which in this case is another object.  In this example, the method and parameter have further methods/parameters defined within them, using object literal notation.
Here's a basic introduction to object-oriented javascript if you're interested.
Answer: In JavaScript, {} denotes an object not an array. (But you can think of an object as essentially an associative array or hash.)
All the function() {} are anonymous functions, which are used here to store functions in variables to be executed later (functions are just objects and can be stored). PRINCIPAL.array here is essentially a pseudo-class, as closures can be used to emulate a class in JavaScript (JS does not have classes built-in).
Answer: That is a common (and good) question.
Take a look here: http://ejohn.org/apps/learn/
Start with 'Named Functions' and work your way down.
The code in your example uses the techniques in this tutorial.
The example, is poorly written, though.

jQuery blocks style


Create a keyboard shortcut in excel to insert specific symbol - Mac Excel 2011

Question: Trying to figure out how to create a keyboard shortcut to insert the delta symbol (δ).
Cannot find any documentation to create a shortcut for a symbol based on a google search.
Comment: There are step by step instructions for this here: https://www.techrepublic.com/blog/microsoft-office/assign-a-keystroke-shortcut-to-insert-a-symbol-or-special-character/  I can't say if they will work on the Mac in precisely the same way.
Answer: Apparently the most viable way to do that is creating a VBA macro that inserts the character and assigning it a shortcut.
I'm on Excel 2019 and need to redefine my keyboard shortcut for the basic Excel functions (such as Find, Replace, etc.): looks like the shortcut customization has disappeared in the most recent Office versions...