问:
How to make scrollable vertical grid of images
I need to make list of images which is scrollable along vertical axis.

Images' links are in string[] imagesLocation.

When tile is clicked, event handler should know string imageLocation.

It shoul look something like this:

I was able to make it in grid. But couldn't make it scrollable.

Found some tip to use LongListSelector, but couldn't make it to work.

Update:

MainPage.xaml.cs:

```<code>namespace PhoneApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();
            ContentPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            ContentPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength() });
            ContentPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength() });
            ContentPanel.Children.Add(new TextBlock() { });
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Image MyImage1 = new Image();
                    MyImage1.SetValue(Grid.ColumnProperty, i);
                    MyImage1.SetValue(Grid.RowProperty, j);

                    ImageSource src = new BitmapImage(new Uri(string.Format("Assets/ApplicationIcon.png"), UriKind.RelativeOrAbsolute));

                    MyImage1.Source = src;

                    ContentPanel.Children.Add(MyImage1);
                }
            }
        }
    }
}
</code>```

MailPage.xaml:

```<code><phone:PhoneApplicationPage
    x:Class="PhoneApp1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
            <TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>
        <Grid Grid.Row="1" x:Name="ContentPanel">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="160"></ColumnDefinition>
                <ColumnDefinition Width="160"></ColumnDefinition>
                <ColumnDefinition Width="160"></ColumnDefinition>
            </Grid.ColumnDefinitions>

        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
</code>```

答:
I thought of an easy solution which you could try.
Insert a Panel first and then create the grid inside the panel

The panel has a property called AutoScroll You just have to set that to True

```<code>    panel.AutoScroll = "True";
</code>```

WrapPanel is great for laying out things in a vertical or horizontal orientation until you reach the edge of the container and then move to the next column or row. But unfortunately I found WrapPanel is no longer supported by Windows Store apps (Universal Apps).

UniversalWrapPanel is an alternative for WrapPanel layout.

This is considering you're working on Visual Studio

To get the UniversalWrapPanel, go to the package manager, find and install Package UniversalWrapPanel This will add the DLL in your references.

Then Open MainPage.xaml and add the namespace to the XAML:

```<code>xmlns:UniversalWrapPanel="using:Gregstoll"
</code>```

Body:
I need to make list of images which is scrollable along vertical axis.

Images' links are in string[] imagesLocation.

When tile is clicked, event handler should know string imageLocation.

It shoul look something like this:

I was able to make it in grid. But couldn't make it scrollable.

Found some tip to use LongListSelector, but couldn't make it to work.

Update:

MainPage.xaml.cs:

namespace PhoneApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();
            ContentPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            ContentPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength() });
            ContentPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength() });
            ContentPanel.Children.Add(new TextBlock() { });
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Image MyImage1 = new Image();
                    MyImage1.SetValue(Grid.ColumnProperty, i);
                    MyImage1.SetValue(Grid.RowProperty, j);

                    ImageSource src = new BitmapImage(new Uri(string.Format("Assets/ApplicationIcon.png"), UriKind.RelativeOrAbsolute));

                    MyImage1.Source = src;

                    ContentPanel.Children.Add(MyImage1);
                }
            }
        }
    }
}

MailPage.xaml:

<phone:PhoneApplicationPage
    x:Class="PhoneApp1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
            <TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>
        <Grid Grid.Row="1" x:Name="ContentPanel">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="160"></ColumnDefinition>
                <ColumnDefinition Width="160"></ColumnDefinition>
                <ColumnDefinition Width="160"></ColumnDefinition>
            </Grid.ColumnDefinitions>

        </Grid>
    </Grid>

</phone:PhoneApplicationPage>

Body:
I thought of an easy solution which you could try.
Insert a Panel first and then create the grid inside the panel

The panel has a property called AutoScroll You just have to set that to True

    panel.AutoScroll = "True";

WrapPanel is great for laying out things in a vertical or horizontal orientation until you reach the edge of the container and then move to the next column or row. But unfortunately I found WrapPanel is no longer supported by Windows Store apps (Universal Apps).

UniversalWrapPanel is an alternative for WrapPanel layout.

This is considering you're working on Visual Studio

To get the UniversalWrapPanel, go to the package manager, find and install Package UniversalWrapPanel This will add the DLL in your references.

Then Open MainPage.xaml and add the namespace to the XAML:

xmlns:UniversalWrapPanel="using:Gregstoll"


来源: stackexchange

问:
How to convert a downloaded repo into a git repo?
Due to some server issues resulting into the error: "aborting due to possible repository corruption on the remote side.", I am not able to clone the repo. As per online research, I found that my server does not have enough RAM to process heavy memory usage. The repo size is 400mb.

Although, I have downloaded the code by clicking the latest commit > Browse code > Download as zip.

Is there a way to init this downloaded folder as git repo? So, that I can push the code?

答:
You can use these commands</p>

```<code>cd folder
git init
git remote add origin https://github.com/user/repo.git
</code>```

ContentLicense: CC BY-SA 3.0

Body:
You can use these commands

cd folder
git init
git remote add origin https://github.com/user/repo.git


问:
How to get user input in Yesod without using Yesod Form
In my page I have a search field(text area).

Yesod Form is quite complicated to use, so I figure I'll just use Javascript to get the value typed by the user. But then how my Haskell program gets that value?

答:
You need to make a HTTP request to the server and pass it data.

In case of GET request, you just declare handler parameters in config/routes and then get them as getYourHandlerR arguments. In case of POST, you can use requireJsonBody to get data as JSON or getPostParams.


问:
sqlite3_step failure: NOT NULL constraint failed
I am new to ionic 1. I have tested my app in browser and it works fine. I have used sqlite. I have a form. When I left one text input field empty the data is added to the database table. That's exactly what I want. But, it does not work in device. Whenever I left one field empty it shows the below error:

```<code>Object {message: "sqlite3_step failure: NOT NULL constraint failed: items.barcode", code: 6}
</code>```

Here's my code snippet:

```<code>if ($scope.item.itemname && $scope.item.soldby && $scope.item.price) {
                        var query = "INSERT into items (itemname,category,soldby,price,sku,barcode) VALUES(?,?,?,?,?,?)";

                        $cordovaSQLite.execute(db, query, [$scope.item.itemname, $scope.item.category, $scope.item.soldby, $scope.item.price, $scope.item.sku, $scope.item.barcode,])
                            .then(function (result) {
                                console.log($scope.item.itemname);
                                console.log($scope.item.category);
                                console.log($scope.item.soldby);
                                console.log($scope.item.price);
                                console.log($scope.item.sku);
                                console.log("Printing barcode");
                                console.log($scope.item.barcode);
                                console.log($scope.item.total);

                                //ITEM ADDED SUCCESS POPUP STARTS

                                //ITEM ADDED SUCCESS POPUP ENDS

                            }, function (error) {
                                console.log(error);

                            });

                        // $scope.item = {
                        //     itemname: $scope.item.itemname,
                        // };
                        $state.go('menu.allItems');
                    }
</code>```

And here is the code where I created the table:

```<code>$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS items (id integer primary key AUTOINCREMENT,itemname text ,category text ,soldby text ,price REAL ,quantity REAL ,sku integer ,barcode text,timestamp DATE DEFAULT (datetime('now','localtime')),cashier text,total REAL,receitnumber integer,grandtotal REAL)");
</code>```

答:
CREATE TABLE IF NOT EXISTS does not change anything if a table with the same name already exists, even if it has a different structure.

To ensure that you always get rid of the old table, use:

```<code>DROP TABLE IF EXISTS items;
CREATE TABLE items ( [...] );
</code>```

This also deletes all old data. If you want to update the table definition but keep the old data, you have to use a temporary table to do the conversion.

Body:
I am new to ionic 1. I have tested my app in browser and it works fine. I have used sqlite. I have a form. When I left one text input field empty the data is added to the database table. That's exactly what I want. But, it does not work in device. Whenever I left one field empty it shows the below error:

Object {message: "sqlite3_step failure: NOT NULL constraint failed: items.barcode", code: 6}

Here's my code snippet:

if ($scope.item.itemname && $scope.item.soldby && $scope.item.price) {
                        var query = "INSERT into items (itemname,category,soldby,price,sku,barcode) VALUES(?,?,?,?,?,?)";

                        $cordovaSQLite.execute(db, query, [$scope.item.itemname, $scope.item.category, $scope.item.soldby, $scope.item.price, $scope.item.sku, $scope.item.barcode,])
                            .then(function (result) {
                                console.log($scope.item.itemname);
                                console.log($scope.item.category);
                                console.log($scope.item.soldby);
                                console.log($scope.item.price);
                                console.log($scope.item.sku);
                                console.log("Printing barcode");
                                console.log($scope.item.barcode);
                                console.log($scope.item.total);

                                //ITEM ADDED SUCCESS POPUP STARTS

                                //ITEM ADDED SUCCESS POPUP ENDS

                            }, function (error) {
                                console.log(error);

                            });

                        // $scope.item = {
                        //     itemname: $scope.item.itemname,
                        // };
                        $state.go('menu.allItems');
                    }

And here is the code where I created the table:

$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS items (id integer primary key AUTOINCREMENT,itemname text ,category text ,soldby text ,price REAL ,quantity REAL ,sku integer ,barcode text,timestamp DATE DEFAULT (datetime('now','localtime')),cashier text,total REAL,receitnumber integer,grandtotal REAL)");

Body:
CREATE TABLE IF NOT EXISTS does not change anything if a table with the same name already exists, even if it has a different structure.

To ensure that you always get rid of the old table, use:

DROP TABLE IF EXISTS items;
CREATE TABLE items ( [...] );

This also deletes all old data. If you want to update the table definition but keep the old data, you have to use a temporary table to do the conversion.


问:
"textAllCaps=false" does not work for textview?
I am using custom list view with sections. I am using below xml for the section layout

```<code><TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Large Text"
android:textColor="#000000"
android:background="#c3c3e5"
android:id="@+id/tv_li_section"
android:padding="8dp"
android:gravity="center"
android:layout_alignParentTop="true"
android:textStyle="bold"
android:textAllCaps="false" />
</code>```

Here textAllCaps= false is not working for me. Any help would be appreciated.

答: By default textAllCaps is false for TextView there are chances that the data your are filling to List is having capital text in it.

Body:
I am using custom list view with sections. I am using below xml for the section layout

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Large Text"
android:textColor="#000000"
android:background="#c3c3e5"
android:id="@+id/tv_li_section"
android:padding="8dp"
android:gravity="center"
android:layout_alignParentTop="true"
android:textStyle="bold"
android:textAllCaps="false" />

Here textAllCaps= false is not working for me. Any help would be appreciated.


问:
customizable date time picker in ionic2
I  don't want to display date after selecting the date from date picker by using  tag is it possible following is the code
As is in the image i don't want to display the MAR 31,2017 is it possible??

```<code>    <ion-header>
      <ion-icon class="moreicon" name="more">
    <ion-datetime type="button" [(ngModel)]="myDate" (click)="get()"></ion-datetime>
  </ion-icon>
</ion-header>
</code>```

答:
On your component page where just do as shown below.

.scss

```<code> .ios,
 .md,
 .wp
     {
      .datetime-text{
         display: none;
    }
}
</code>```

Title: customizable date time picker in ionic2

Body:
I  don't want to display date after selecting the date from date picker by using  tag is it possible following is the code
As is in the image i don't want to display the MAR 31,2017 is it possible??

    <ion-header>
      <ion-icon class="moreicon" name="more">
    <ion-datetime type="button" [(ngModel)]="myDate" (click)="get()"></ion-datetime>
  </ion-icon>
</ion-header>

Body:
On your component page where just do as shown below.

.scss

 .ios,
 .md,
 .wp
     {
      .datetime-text{
         display: none;
    }
}


问:
Compiled distribution of Qt application for windows
I was successfully able to compile and run my Qt application. However, when I move the .exe file outside its original path, I found out that I have to manually copy the Qt DLLs (e.g. mingw10.dll, qtcore4.dll). Is there any dynamic way to link these libraries with my application?</p>

答:
I think you mean you want to "statically" link these libraries with your application.
Basically this means that everything will be rolled inside your exe, and you will have no need of those dlls anymore.

There are advantages to to static linking, but there are also disadvantages as well.  You should be absolutely sure that this is what you want to do before you go this way.

Check out this link which explains the difference in depth Dynamic Linking vs Static Linking

As for your specific issue, if you are sure you want to use static linking you will have to change your Qt setup to be built statically.  By default the Qt distribution is setup to use dynamic linking.  There is a handy guide for that here.

Basically when you setup the build you have to run "configure -static" to change all the project settings to use static linking instead of dynamic linking. And then build Qt over again.

You should also verify your Qt license. If you are using the Qt LGPL license and you want to to link statically you will have to include all your object files (.o and .obj) as Mihai Limbășan wisely explained in his comment.  If you have bought and paid for Qt, then you have no problem.

ContentLicense: CC BY-SA 2.5


问:
BeanFactory not initialized or already closed - call 'refresh' before
here is my error:

I am getting this error , can any one help me on this.

```<code>> SEVERE: Exception sending context initialized event to listener
> instance of class
> org.springframework.web.context.ContextLoaderListener
> java.lang.NoSuchMethodError:
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.setEnvironment(Lorg/springframework/core/env/Environment;)V
>   at
> org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:87)
>   at
> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
>   at
> org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
>   at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
>   at
> org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
>   at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
>   at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
>   at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
>   at
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
>   at
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
>   at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)    at
> java.util.concurrent.FutureTask.run(Unknown Source)   at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>   at java.lang.Thread.run(Unknown Source) Nov 21, 2013 12:54:38 PM
> org.apache.catalina.core.StandardContext startInternal SEVERE: Error
> listenerStart Nov 21, 2013 12:54:38 PM
> org.apache.catalina.core.StandardContext startInternal SEVERE: Context
> [/FLPalette] startup failed due to previous errors Nov 21, 2013
> 12:54:38 PM org.apache.catalina.core.ApplicationContext log INFO:
> Closing Spring root WebApplicationContext Nov 21, 2013 12:54:38 PM
> org.apache.catalina.core.StandardContext listenerStop SEVERE:
> Exception sending context destroyed event to listener instance of
> class org.springframework.web.context.ContextLoaderListener
> java.lang.IllegalStateException: BeanFactory not initialized or
> already closed - call 'refresh' before accessing beans via the
> ApplicationContext    at
> org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172)
>   at
> org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066)
>   at
> org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040)
>   at
> org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:988)
>   at
> org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:556)
>   at
> org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)
>   at
> org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4763)
>   at
> org.apache.catalina.core.StandardContext$4.run(StandardContext.java:5472)
>   at java.lang.Thread.run(Unknown Source)     at
> org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5481)
>   at
> org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
>   at
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
>   at
> org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>   at
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
>   at
> org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>   at
> org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>   at
> org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>   at org.apache.catalina.startup.Catalina.start(Catalina.java:620)    at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
> java.lang.reflect.Method.invoke(Unknown Source)   at
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)   at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431) Nov 21,
> 2013 12:54:38 PM org.apache.coyote.AbstractProtocol start INFO:
> Starting ProtocolHandler ["http-bio-8080"] Nov 21, 2013 12:54:38 PM
> org.apache.coyote.AbstractProtocol start INFO: Starting
> ProtocolHandler ["ajp-bio-8009"] Nov 21, 2013 12:54:38 PM
> org.apache.catalina.startup.Catalina start
</code>```

pom.xml :

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.paypal.palette</groupId>
  <artifactId>FLPalette</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
   <name>FLPalette</name>
  <url>http://maven.apache.org</url>
  <dependencies>
  <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.5</version>
</dependency>
       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

  <dependency>
    <groupId>wsdl4j</groupId>
    <artifactId>wsdl4j</artifactId>
    <version>1.6.3</version>
    <scope>test</scope>
</dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>0.1.50</version>
    </dependency>
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>3.1.0.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20090211</version>
    </dependency>
    <dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.2.1</version>
    </dependency>
     <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>1.4</version>
    </dependency>
  </dependencies>
  <properties>
        <org.springframework.version>3.0.2.RELEASE</org.springframework.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
           <artifactId>maven-war-plugin</artifactId>
       </plugin>
    </plugins>
  </build>
</project>
</code>```

答: In my case, this error was due to the Network connection error that i was noticed in log.</p>

Body:
here is my error:

I am getting this error , can any one help me on this.

> SEVERE: Exception sending context initialized event to listener
> instance of class
> org.springframework.web.context.ContextLoaderListener
> java.lang.NoSuchMethodError:
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.setEnvironment(Lorg/springframework/core/env/Environment;)V
>   at
> org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:87)
>   at
> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
>   at
> org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
>   at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
>   at
> org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
>   at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
>   at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
>   at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
>   at
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
>   at
> org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
>   at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)    at
> java.util.concurrent.FutureTask.run(Unknown Source)   at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>   at java.lang.Thread.run(Unknown Source) Nov 21, 2013 12:54:38 PM
> org.apache.catalina.core.StandardContext startInternal SEVERE: Error
> listenerStart Nov 21, 2013 12:54:38 PM
> org.apache.catalina.core.StandardContext startInternal SEVERE: Context
> [/FLPalette] startup failed due to previous errors Nov 21, 2013
> 12:54:38 PM org.apache.catalina.core.ApplicationContext log INFO:
> Closing Spring root WebApplicationContext Nov 21, 2013 12:54:38 PM
> org.apache.catalina.core.StandardContext listenerStop SEVERE:
> Exception sending context destroyed event to listener instance of
> class org.springframework.web.context.ContextLoaderListener
> java.lang.IllegalStateException: BeanFactory not initialized or
> already closed - call 'refresh' before accessing beans via the
> ApplicationContext    at
> org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:172)
>   at
> org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066)
>   at
> org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040)
>   at
> org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:988)
>   at
> org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:556)
>   at
> org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)
>   at
> org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4763)
>   at
> org.apache.catalina.core.StandardContext$4.run(StandardContext.java:5472)
>   at java.lang.Thread.run(Unknown Source)     at
> org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5481)
>   at
> org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
>   at
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
>   at
> org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>   at
> org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
>   at
> org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>   at
> org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>   at
> org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
>   at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
>   at org.apache.catalina.startup.Catalina.start(Catalina.java:620)    at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
> java.lang.reflect.Method.invoke(Unknown Source)   at
> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)   at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431) Nov 21,
> 2013 12:54:38 PM org.apache.coyote.AbstractProtocol start INFO:
> Starting ProtocolHandler ["http-bio-8080"] Nov 21, 2013 12:54:38 PM
> org.apache.coyote.AbstractProtocol start INFO: Starting
> ProtocolHandler ["ajp-bio-8009"] Nov 21, 2013 12:54:38 PM
> org.apache.catalina.startup.Catalina start

pom.xml :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.paypal.palette</groupId>
  <artifactId>FLPalette</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
   <name>FLPalette</name>
  <url>http://maven.apache.org</url>
  <dependencies>
  <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.5</version>
</dependency>
       <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

  <dependency>
    <groupId>wsdl4j</groupId>
    <artifactId>wsdl4j</artifactId>
    <version>1.6.3</version>
    <scope>test</scope>
</dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
        <version>3.1.1.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>0.1.50</version>
    </dependency>
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>3.1.0.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20090211</version>
    </dependency>
    <dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.2.1</version>
    </dependency>
     <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>1.4</version>
    </dependency>
  </dependencies>
  <properties>
        <org.springframework.version>3.0.2.RELEASE</org.springframework.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
           <artifactId>maven-war-plugin</artifactId>
       </plugin>
    </plugins>
  </build>
</project>


问:
C - Install GTK on Windows without hassle?
I'm trying to install GTK+ on Windows but every tutorial says to download 7 different programs, etc. I just want one library that I include in my folder just like SDL has. How to do this?</p>

答:
You can download boundle pack that contains all libraries you need.
There are different gtk+ boundles on the net.
Here is the one that might help you, it has both x86 and x64:
http://www.tarnyko.net/dl/gtk.htm</p>


问:
How to custom change the date format in excel from any format to dd-MM-yyyy
I need to change date from existing format to dd-MM-yyyy in excel .

EDIT : I have seen other formats , but they don't contain - dd-MM-yyyy format .

答:
Create your own Custom Number Format, entering dd-mm-yyyy:

Codes:

m = 4

mm = 04

mmm = Apr

mmmm = April


问:
Bing translator exception while integrating with java application
I am trying to integrate bing translator in my java application. I have registered to Microsoft azure cognitive service and Microsoft market place.
while executing below code </p>

```<code>import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;

public class Main {
    public static void main(String[] args) {
        try{
            Translate.setClientId(/* my Client Id */);
            Translate.setClientSecret(/* my Client Secret */);

            String translatedText = Translate.execute("Bonjour le monde", Language.FRENCH, Language.ENGLISH);

            System.out.println(translatedText);
        }
        catch(Exception e) {
            System.err.println("Exception: " + e.getMessage());
        }
    }
}
</code>```

<p>I am getting below exception: </p>

```<code>Page NoException in thread "main" java.lang.Exception: [microsoft-translator-api] Error retrieving translation : Server returned HTTP response code: 400 for URL: https://datamarket.accesscontrol.windows.net/v2/OAuth2-13
    at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:202)
    at com.memetix.mst.translate.Translate.execute(Translate.java:61)
    at test.SimpleExcelTranalator.main(SimpleExcelTranalator.java:44)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://datamarket.accesscontrol.windows.net/v2/OAuth2-13
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.memetix.mst.MicrosoftTranslatorAPI.getToken(MicrosoftTranslatorAPI.java:139)
    at com.memetix.mst.MicrosoftTranslatorAPI.retrieveResponse(MicrosoftTranslatorAPI.java:160)
    at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:199)
    ... 2 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://datamarket.accesscontrol.windows.net/v2/OAuth2-13
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
    at com.memetix.mst.MicrosoftTranslatorAPI.getToken(MicrosoftTranslatorAPI.java:138)
    ... 4 more
</code>```

答:
According to your referenced package com.memetix.mst.language.* in your code, I searched and found its source code on GitHub, repository on Maven, and an old repository on GoogleCode. I reviewed its source code, and discovered it wrappered the MS Translator Text API from Azure old datamarket web site. The library is out of date with the old REST API, the old website shows "THE MICROSOFT TRANSLATOR API IS NOW AVAILABLE ON THE AZURE PORTAL" and "IMPORTANT: An Azure account is required. Read the steps to get started on the portal here." So first you need to have an Azure subscription to create a Translator Text API service on Azure portal, then write code to call the new REST API. You can refer to my answer for the two other SO threads as below to know how to use the new REST API and call it via my sample code.

My answer for MS Translator returns empty response when used with Azure token shows the new REST API usage.

My answer for Microsoft Translator API Java, How to get client new ID with Azure which includes my sample code, it shows how to call the new REST API in Java.

Hope it helps.

Body:
I am trying to integrate bing translator in my java application. I have registered to Microsoft azure cognitive service and Microsoft market place.
while executing below code

import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;

public class Main {
    public static void main(String[] args) {
        try{
            Translate.setClientId(/* my Client Id */);
            Translate.setClientSecret(/* my Client Secret */);

            String translatedText = Translate.execute("Bonjour le monde", Language.FRENCH, Language.ENGLISH);

            System.out.println(translatedText);
        }
        catch(Exception e) {
            System.err.println("Exception: " + e.getMessage());
        }
    }
}

I am getting below exception:

Page NoException in thread "main" java.lang.Exception: [microsoft-translator-api] Error retrieving translation : Server returned HTTP response code: 400 for URL: https://datamarket.accesscontrol.windows.net/v2/OAuth2-13
    at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:202)
    at com.memetix.mst.translate.Translate.execute(Translate.java:61)
    at test.SimpleExcelTranalator.main(SimpleExcelTranalator.java:44)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://datamarket.accesscontrol.windows.net/v2/OAuth2-13
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.memetix.mst.MicrosoftTranslatorAPI.getToken(MicrosoftTranslatorAPI.java:139)
    at com.memetix.mst.MicrosoftTranslatorAPI.retrieveResponse(MicrosoftTranslatorAPI.java:160)
    at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:199)
    ... 2 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://datamarket.accesscontrol.windows.net/v2/OAuth2-13
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
    at com.memetix.mst.MicrosoftTranslatorAPI.getToken(MicrosoftTranslatorAPI.java:138)
    ... 4 more


问:
Compressed file (packed EXE) in WIX/MSI package increase MSI size by twice
I have simple WiX MSI installer script. This script generate package what deploy only one exe file. This file is Java application wrapped to exe file. Overall size of this exe is 10MB. Unfortunately when I get builded  MSI final size of MSI increased by twice - e.g. 20MB.

I tried to change
attribute Media/CompressionLevel to none/high/low/mszip - but can get acceptable MSI size.

Please help - I need get uncompressed MSI with similar  to deployed exe size +/- 3-4 MB!

Thank you !

答: Windows Installer natively only supports some pretty basic compression formats.  You might want to give InstallAware's Setup Squeezer a try.</p>


问:
ionic: content goes behind nav bar
So, I have a code pen link here: http://codepen.io/anon/pen/oXwZmr

In that, they combined all the templates in index.html (tabs.html, mainContainer.html, entry.html, ...) and all controllers of template pages in js file(MainController, TabsPageController, ...).

I wanted to keep all things separate, so i did like index.html, mainController.html mainController.js, tabs.html, tabs.js, app.js.

The codepen works perfectly. But I am getting problem. My Content is going behind tabs.

index.html

```<code><html ng-app="DroidRestClient">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

        <title>Droid Rest Client</title>

        <!--        <link href="http://code.ionicframework.com/0.9.27/css/ionic.min.css" rel="stylesheet">
                <script src="http://code.ionicframework.com/0.9.27/js/ionic.bundle.min.js"></script>-->

        <link href="lib/ionic/css/ionic.css" rel="stylesheet">
        <link href="css/style.css" rel="stylesheet">
        <link href="css/ionicons.css" rel="stylesheet" type="text/css"/>

        <!--ionic/angularjs js-->
        <script src="lib/ionic/js/ionic.bundle.js"></script>

        <script src="js/app.js" type="text/javascript"></script>
        <script src="templates/mainContainer/mainContainer.js" type="text/javascript"></script>
        <script src="templates/tabs/tabs.js" type="text/javascript"></script>
    </head>
    <body>

        <!-- ALL VIEW STATES LOADED IN HERE -->
    <ion-nav-view>

    </ion-nav-view>
</body>
</html>
</code>```

app.js

```<code>angular.module('DroidRestClient', ['ionic', 'DroidRestClient.mainController', 'DroidRestClient.tabsPageController'])

    .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {

        $stateProvider
            .state('main', {
                url : '/main',
                templateUrl : 'templates/mainContainer/mainContainer.html',
                abstract : true,
                controller : 'MainController'
            })
            .state('main.tabs', {
                 url: '/tabs',
                 views: {
                     'main': {
                         templateUrl: 'templates/tabs/tabs.html',
                         controller : 'TabsPageController'
                     }
                 }
            });

        $urlRouterProvider.otherwise('/main/tabs');
    }]);
</code>```

mainContainer.html

```<code><ion-side-menus>
    <ion-pane ion-side-menu-content>
        <ion-nav-bar type="bar-positive"
                     back-button-type="button-icon"
                     back-button-icon="ion-ios7-arrow-back"
                     animation="nav-title-slide-ios7">
        </ion-nav-bar>
        <ion-nav-view name="main">

        </ion-nav-view>
    </ion-pane>

    <ion-side-menu side="left">
        <header class="bar bar-header bar-assertive">
            <div class="title">Settings</div>
        </header>
        <ion-content has-header="true">
            <ul class="list">
                <a ui-sref="main.tabs" class="item" ng-click="toggleMenu()">Tabs</a>
            </ul>
        </ion-content>
    </ion-side-menu>
</ion-side-menus>
</code>```

mainContainer

```<code>angular.module('DroidRestClient.mainController', ['ionic'])
        .controller('MainController', ['$scope', function ($scope) {
                $scope.toggleMenu = function () {
                    $scope.sideMenuController.toggleLeft();
                };
            }]);
</code>```

tabs.html

```<code><ion-view title="{{navTitle}}"  left-buttons="leftButtons">
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
    <ion-tab title="Request" icon-off="ion-ios-cloud-upload-outline" icon-on="ion-ios-cloud-upload">
        <ion-content has-header="true" padding="true">
            <form ng-submit="doLogin()">
                <div class="list">
                    <div class="item item-divider item-button-right">
                        Url
                    </div>
                    <label class="item item-input">
                        <input type="text" placeholder="enter url">
                    </label>
                    <div class="item item-divider item-button-right">
                        Method
                    </div>
                    <label class="item item-input">
                        <div class="input-label">
                            Method
                        </div>
                        <select>
                            <option selected>GET</option>
                            <option>POST</option>
                            <option>PUT</option>
                            <option>DELETE</option>
                        </select>
                    </label>
                    <div class="item item-divider item-button-right">
                        Parameters
                        <a class="button button-icon icon ion-ios-plus-empty"></a>
                        <button class="button button-positive">
                            <i class="icon ion-ios-plus-empty"></i>
                        </button>
                    </div>
                    <div class="list list-inset">
                        <div class="item">
                            No parameters
                        </div>
                    </div>
                    <div class="item item-divider item-button-right">
                        Headers
                        <a class="button button-icon icon ion-ios-plus-empty"></a>
                        <button class="button button-positive">
                            <i class="icon ion-ios-plus-empty"></i>
                        </button>
                    </div>
                    <div class="list list-inset">
                        <div class="item">
                            No headers
                        </div>
                    </div>
                    <div class="item item-divider item-button-right">
                        Body
                    </div>
                    <label class="item item-input">
                        <textarea placeholder="enter body"></textarea>
                    </label>
                </div>
            </form>
        </ion-content>
    </ion-tab>

    <ion-tab title="Response" icon-off="ion-ios-cloud-download-outline" icon-on="ion-ios-cloud-download">
        <ion-content has-header="true" padding="true">
            <h2>Response</h2>
        </ion-content>
    </ion-tab>
</ion-tabs>
</code>```

tabs.js

```<code>angular.module('DroidRestClient.tabsPageController', ['ionic'])
    .controller('TabsPageController', ['$scope', '$state', function ($scope, $state) {
            $scope.navTitle = 'Home';

            $scope.leftButtons = [{
                    type: 'button-icon icon ion-navicon',
                    tap: function (e) {
                        $scope.toggleMenu();
                    }
                }];
        }]);
</code>```

答:
Give class="has-header" to ion-content.

```<code><ion-content class="has-header">
</ion-content>
</code>```

And you need to initialise your angular app - See javascript on my example. Note ng-controller and ng-app.

Title: ionic: content goes behind nav bar

Body:
So, I have a code pen link here: http://codepen.io/anon/pen/oXwZmr

In that, they combined all the templates in index.html (tabs.html, mainContainer.html, entry.html, ...) and all controllers of template pages in js file(MainController, TabsPageController, ...).

I wanted to keep all things separate, so i did like index.html, mainController.html mainController.js, tabs.html, tabs.js, app.js.

The codepen works perfectly. But I am getting problem. My Content is going behind tabs.

index.html

        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

        <title>Droid Rest Client</title>

        <link href="lib/ionic/css/ionic.css" rel="stylesheet">
        <link href="css/style.css" rel="stylesheet">
        <link href="css/ionicons.css" rel="stylesheet" type="text/css"/>

    <ion-nav-view>

    </ion-nav-view>

app.js

angular.module('DroidRestClient', ['ionic', 'DroidRestClient.mainController', 'DroidRestClient.tabsPageController'])

    .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {

        $stateProvider
            .state('main', {
                url : '/main',
                templateUrl : 'templates/mainContainer/mainContainer.html',
                abstract : true,
                controller : 'MainController'
            })
            .state('main.tabs', {
                 url: '/tabs',
                 views: {
                     'main': {
                         templateUrl: 'templates/tabs/tabs.html',
                         controller : 'TabsPageController'
                     }
                 }
            });

        $urlRouterProvider.otherwise('/main/tabs');
    }]);

mainContainer.html

<ion-side-menus>
    <ion-pane ion-side-menu-content>
        <ion-nav-bar type="bar-positive"
                     back-button-type="button-icon"
                     back-button-icon="ion-ios7-arrow-back"
                     animation="nav-title-slide-ios7">
        </ion-nav-bar>
        <ion-nav-view name="main">

        </ion-nav-view>
    </ion-pane>

    <ion-side-menu side="left">

Settings

        <ion-content has-header="true">

                Tabs

        </ion-content>
    </ion-side-menu>
</ion-side-menus>

mainContainer

angular.module('DroidRestClient.mainController', ['ionic'])
        .controller('MainController', ['$scope', function ($scope) {
                $scope.toggleMenu = function () {
                    $scope.sideMenuController.toggleLeft();
                };
            }]);

tabs.html

<ion-view title="{{navTitle}}"  left-buttons="leftButtons">
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
    <ion-tab title="Request" icon-off="ion-ios-cloud-upload-outline" icon-on="ion-ios-cloud-upload">
        <ion-content has-header="true" padding="true">
            <form ng-submit="doLogin()">

                        Url

                        <input type="text" placeholder="enter url">

                        Method

                            Method

                        <select>
                            <option selected>GET</option>
                            <option>POST</option>
                            <option>PUT</option>
                            <option>DELETE</option>
                        </select>

                        Parameters

                        <button class="button button-positive">

                        </button>

                            No parameters

                        Headers

                        <button class="button button-positive">

                        </button>

                            No headers

                        Body

                        <textarea placeholder="enter body"></textarea>

            </form>
        </ion-content>
    </ion-tab>

    <ion-tab title="Response" icon-off="ion-ios-cloud-download-outline" icon-on="ion-ios-cloud-download">
        <ion-content has-header="true" padding="true">

Response

        </ion-content>
    </ion-tab>
</ion-tabs>

tabs.js

angular.module('DroidRestClient.tabsPageController', ['ionic'])
    .controller('TabsPageController', ['$scope', '$state', function ($scope, $state) {
            $scope.navTitle = 'Home';

            $scope.leftButtons = [{
                    type: 'button-icon icon ion-navicon',
                    tap: function (e) {
                        $scope.toggleMenu();
                    }
                }];
        }]);

Body:
Give class="has-header" to ion-content.

<ion-content class="has-header">
</ion-content>

And you need to initialise your angular app - See javascript on my example. Note ng-controller and ng-app.


问:
How to create factory in AngularJS?
I had created a factory in angular but i am  getting the following  error

```<code>Unknown provider:
</code>```

Here is the factory:

```<code>app.factory("getFoo", function($scope){
    return {
       getCommi: function(val,id){
          var array = ["hello","world"];
          return array;
       }
     }
});
</code>```

The controller is:

```<code>app.controller('myCtrl', ['$scope','getFoo',function($scope,getFoo){
   $scope.myArr = getFoo.getCommi(4,1);
}])
</code>```

What can I have to do for  fix this? I just don't see any problem.

答:
you just need to remove $scope from factory.

working fiddle link

Title: How to create factory in AngularJS?

Body:
I had created a factory in angular but i am  getting the following  error

Unknown provider:

Here is the factory:

app.factory("getFoo", function($scope){
    return {
       getCommi: function(val,id){
          var array = ["hello","world"];
          return array;
       }
     }
});

The controller is:

app.controller('myCtrl', ['$scope','getFoo',function($scope,getFoo){
   $scope.myArr = getFoo.getCommi(4,1);
}])

What can I have to do for  fix this? I just don't see any problem.


问:
iCheck check if checkbox is checked
I am using iCheck plugin for customizing checkboxes. I need to display certain text when one or more checkbox is checked and hide the text when none are checked.

The code I have currently displays the text on first click but doesn't hide it unless I click 2 more times.
I have multiple checkboxes and would like to show text if one of 'em are checked else hide the text.
Does anybody have any idea? The plugin has:

```<code>ifChecked
ifChanged
ifClicked
ifUnchecked
ifToggled
ifDisabled
ifEnabled.......
</code>```

callbacks....Here is the plugin function

```<code>$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
</code>```

Here is what I tried..

```<code>$('input').on('ifChecked', function(event){
$(".hide").toggle();
});
</code>```

html

```<code><input type="checkbox">
<div class"hide" style="display:none">Hi there</div>
</code>```

答:
```<code>$('input').on('ifChanged', function(event) {
             if($(".checkbox").is(":checked")) {
                $value = $(this).val();
             }

             else if($(".checkbox").is(":not(:checked)")) {
                $value= $(this).val();
             }
        });
</code>```

Title: iCheck check if checkbox is checked

Body:
I am using iCheck plugin for customizing checkboxes. I need to display certain text when one or more checkbox is checked and hide the text when none are checked.

The code I have currently displays the text on first click but doesn't hide it unless I click 2 more times.
I have multiple checkboxes and would like to show text if one of 'em are checked else hide the text.
Does anybody have any idea? The plugin has:

ifChecked
ifChanged
ifClicked
ifUnchecked
ifToggled
ifDisabled
ifEnabled.......

callbacks....Here is the plugin function

$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});

Here is what I tried..

$('input').on('ifChecked', function(event){
$(".hide").toggle();
});

html

<input type="checkbox">

Hi there


问:
Do I need to release the COM object on every 'foreach' iteration?
Here's the (potential) problem:

I create a COM object, and then use a 'foreach' to iterate through each element in a collection it returns.  Do I need to release each individual element I iterate through in the collection?  (See code below.)  If so, I can't think of a way to effectively to release it from within a 'finally' statement, just in case there is an error as the item is being operated upon.

Any suggestions?

```<code>private static void doStuff()
{
    ComObjectClass manager = null;

    try
    {
        manager = new ComObjectClass();
        foreach (ComObject item in manager.GetCollectionOfItems())
        {
            Log.Debug(item.Name);
            releaseComObject(item); // <-- Do I need this line?
                                    //     It isn't in a 'finally' block...
                                    //             ...Possible memory leak?
        }
    }
    catch (Exception) { }
    finally
    {
        releaseComObject(manager);
    }
}

private static void releaseComObject(object instance)
{
    if (instance != null)
    {
        try
        {
            System.Runtime.InteropServices.Marshal.ReleaseComObject(instance);
        }
        catch
        {
            /* log potential memory leak */
            Log.Debug("Potential memory leak: Unable to release COM object.");
        }
        finally
        {
            instance = null;
        }
    }
}
</code>```

答:
You should not use a foreach statement with a COM object, as a reference is made behind the scenes to which you have no control over releasing. I would switch to a for loop and make sure you never use two dots with COM objects.

The way this would look would be:

```<code>try
{
    manager = new ComObjectClass();
    ComObject comObject = null;
    ComObject[] collectionOfComItems = manager.GetCollectionOfItems();
    try
    {
        for(int i = 0; i < collectionOfComItems.Count; i++)
        {
            comObject = collectionOfComItems[i];
            ReleaseComObject(comObject);
        }
    }
    finally
    {
        ReleaseComObject(comObject);
    }
}
finally
{
    ReleaseComObject(manager);
}
</code>```

Body:
Here's the (potential) problem:

I create a COM object, and then use a 'foreach' to iterate through each element in a collection it returns.  Do I need to release each individual element I iterate through in the collection?  (See code below.)  If so, I can't think of a way to effectively to release it from within a 'finally' statement, just in case there is an error as the item is being operated upon.

Any suggestions?

private static void doStuff()
{
    ComObjectClass manager = null;

    try
    {
        manager = new ComObjectClass();
        foreach (ComObject item in manager.GetCollectionOfItems())
        {
            Log.Debug(item.Name);
            releaseComObject(item); // <-- Do I need this line?
                                    //     It isn't in a 'finally' block...
                                    //             ...Possible memory leak?
        }
    }
    catch (Exception) { }
    finally
    {
        releaseComObject(manager);
    }
}

private static void releaseComObject(object instance)
{
    if (instance != null)
    {
        try
        {
            System.Runtime.InteropServices.Marshal.ReleaseComObject(instance);
        }
        catch
        {
            /* log potential memory leak */
            Log.Debug("Potential memory leak: Unable to release COM object.");
        }
        finally
        {
            instance = null;
        }
    }
}

Body:
You should not use a foreach statement with a COM object, as a reference is made behind the scenes to which you have no control over releasing. I would switch to a for loop and make sure you never use two dots with COM objects.

The way this would look would be:

try
{
    manager = new ComObjectClass();
    ComObject comObject = null;
    ComObject[] collectionOfComItems = manager.GetCollectionOfItems();
    try
    {
        for(int i = 0; i < collectionOfComItems.Count; i++)
        {
            comObject = collectionOfComItems[i];
            ReleaseComObject(comObject);
        }
    }
    finally
    {
        ReleaseComObject(comObject);
    }
}
finally
{
    ReleaseComObject(manager);
}


问:
HttpClient 4.0.1 - how to release connection?
I have a loop over a bunch of URLs, for each one I'm doing the following:

```<code>private String doQuery(String url) {

  HttpGet httpGet = new HttpGet(url);
  setDefaultHeaders(httpGet); // static method
  HttpResponse response = httpClient.execute(httpGet);   // httpClient instantiated in constructor

  int rc = response.getStatusLine().getStatusCode();

  if (rc != 200) {
    // some stuff...
    return;
  }

  HttpEntity entity = response.getEntity();

  if (entity == null) {
    // some stuff...
    return;
  }

  // process the entity, get input stream etc

}
</code>```

The first query is fine, the second throws this exception:

Exception in thread "main"
  java.lang.IllegalStateException:
  Invalid use of
  SingleClientConnManager: connection
  still allocated. Make sure to release
  the connection before allocating
  another one.  at
  org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:199)
    at
  org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:173)......

This is just a simple single-threaded app. How can I release this connection?

答:
I'm using HttpClient 4.5.3, using CloseableHttpResponse#close worked for me.

```<code>    CloseableHttpResponse response = client.execute(request);

    try {
        HttpEntity entity = response.getEntity();
        String body = EntityUtils.toString(entity);
        checkResult(body);
        EntityUtils.consume(entity);
    } finally {
        response.close();
    }
</code>```

With Java7 and beyond:

```<code>try (CloseableHttpResponse response = client.execute(request)) {
   ...
}
</code>```

Body:
I have a loop over a bunch of URLs, for each one I'm doing the following:

private String doQuery(String url) {

  HttpGet httpGet = new HttpGet(url);
  setDefaultHeaders(httpGet); // static method
  HttpResponse response = httpClient.execute(httpGet);   // httpClient instantiated in constructor

  int rc = response.getStatusLine().getStatusCode();

  if (rc != 200) {
    // some stuff...
    return;
  }

  HttpEntity entity = response.getEntity();

  if (entity == null) {
    // some stuff...
    return;
  }

  // process the entity, get input stream etc

}

The first query is fine, the second throws this exception:

Exception in thread "main"
  java.lang.IllegalStateException:
  Invalid use of
  SingleClientConnManager: connection
  still allocated. Make sure to release
  the connection before allocating
  another one.  at
  org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:199)
    at
  org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:173)......

This is just a simple single-threaded app. How can I release this connection?

Body:
I'm using HttpClient 4.5.3, using CloseableHttpResponse#close worked for me.

    CloseableHttpResponse response = client.execute(request);

    try {
        HttpEntity entity = response.getEntity();
        String body = EntityUtils.toString(entity);
        checkResult(body);
        EntityUtils.consume(entity);
    } finally {
        response.close();
    }

With Java7 and beyond:

try (CloseableHttpResponse response = client.execute(request)) {
   ...
}

ContentLicense: CC BY-SA 4.0


问:
Need some advice regarding a media query and CSS
I'm hoping someone is able to help with an issue I'm currently having with a website I am designing. The media query for mobile is where I'm getting hung up.

This is an image of it.

The content isn't centered. I can fix the text simply with a text-align property, and I assume that I can just make the image display as a block and use margin: 0 auto to center it, the problem is that the container itself is not centered. I'm using Bootstrap, and it's all in a Bootstrap container.

I think part of the issue is that on small screens, I am hiding some content that is to the right of the content I can't get centered using Bootstrap's "hidden-xs" and "hidden-sm" properties.

Here is the code for the relevant section in the screenshot, plus my CSS for the media query. If anyone could point me in the right direction, I'd appreciate it.

/* Content Styles*/
.gas-content {
 margin: 4.50em 0 4.50em 5%;
}

.left-content {
 margin: 2.50em 0 2.50em 5%;
}

.content-container {
 width: 75%;
 float: left;
}

.test-container {
 width: 25%;
 float: left;
 margin-top: -10px;
}

.move-up {
 margin-top: -2em;
}

.move-down {
 margin-top: 2em;
}

.img-center {
 display: block;
 margin: 0 auto;
}

.content-heading {
 color: rgb(3, 17, 85);
 font-family: 'Montserrat', sans-serif;
 font-weight: 600;
 line-height: 1.50em;
}

.services li {
 color: rgb(3, 17, 85);
 font-family: 'Montserrat', sans-serif;
 text-transform: uppercase;
 font-size: 1.25em;
 font-weight: 600;
}

.emergency-services li {
 color: rgb(3, 17, 85);
 font-family: 'Montserrat', sans-serif;
 text-transform: uppercase;
 font-size: 1.25em;
 font-weight: 600;
}

.contact-box {
 background-color: rgb(3, 17, 85);
 padding: 2em 0 6.50em 0;
}

.contact-box h3 {
 color: white;
 text-transform: uppercase;
 margin-left: 15px;
 font-family: 'Montserrat', sans-serif;
 font-weight: 600;
}

.contact-info {
 color: white;
 margin-left: 15px;
}

.eztouselogo {
 margin-left: 15px;
 margin-bottom: 15px;
}

.services-left {
 margin-right: 0.50em;
}

.content-paragraph {
 font-family: 'Open Sans', sans-serif;
 margin-bottom: 5em;
 line-height: 2.25em;
}

@media (max-width: 991px) {
 .test-container {
  display: none;
 }

 .content-container {
  display: block;
  margin: 0 auto;
  padding: 0 0 0 0;
  float: none;
  clear: both;
 }

 .container {
  display: block;
  margin: 0 auto;
  float: none;
  clear: both;
 }

 .pipes-img {
  width: 75%;
  height: 75%;
  display: block;
  margin: 0 auto;
  float: none;
 }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <!--Begin Main Content -->
   <div class="container"> <!--New Container -->

    <div class="content-container"> <!--Content on Left Side of Testimonials -->
      <div class="row gas-content"> <!--Gas, Water, & Sewer Line Row -->
        <div class="col-md-4">
          <img class="pull-left img-responsive pipes-img" src="img/pipes.jpg">
        </div>
        <div class="col-xs-8 move-up">
          <h3 class="content-heading">Gas, Water, & Sewer Line Inspection and Replacement in the Pittsburgh Area</h3>
          <p class="content-paragraph">Vivamus id ante molestie, vehicula justo nec, facilisis justo. Sed efficitur feugiat accumsan. Nunc vitae fermentum nulla. Aliquam imperdiet nunc felis, et malesuada ligula molestie eget. Proin sodales dictum semper. Proin nec sodales quam. Maecenas ac erat non mauris laoreet volutpat. Proin egestas enim ut magna sagittis vulputate. Aenean non odio lacus. Nam vehicula metus viverra quam laoreet, nec interdum orci porttitor. Etiam gravida velit sit amet commodo suscipit. Cras est erat, scelerisque quis velit non, luctus molestie ex.</p>
          <div class="row">
            <div class="col-xs-5">
              <ul class="services services-left">
                <li>Sewer Lines</li>
                <li>Gas Lines</li>
                <li>Water Lines</li>
              </ul>
            </div>
            <div class="col-xs-7">
              <ul class="services services-right">
                <li>Sewer Inspections</li>
                <li>Water Heaters</li>
                <li>Full-Service Plumbing</li>
              </ul>
            </div>
          </div>
        </div>
      </div> <!--End Gas, Water, & Sewer Line Row --></code>```

答:
I don't think we (web developer) need to customize the media query of Bootstrap Framework. Bootstrap has built-in or default media query that fits to all devices such as :

Extra small devices Phones (<768px)

Class prefix : .col-xs-

Small devices Tablets (≥768px)

Class prefix : .col-sm-

Medium devices Desktops (≥992px)

Class prefix : .col-md-

Large devices Desktops (≥1200px)

Class prefix : .col-lg-

We just need to use it "cleverly" as it is.

Body:
I'm hoping someone is able to help with an issue I'm currently having with a website I am designing. The media query for mobile is where I'm getting hung up.

This is an image of it.

The content isn't centered. I can fix the text simply with a text-align property, and I assume that I can just make the image display as a block and use margin: 0 auto to center it, the problem is that the container itself is not centered. I'm using Bootstrap, and it's all in a Bootstrap container.

I think part of the issue is that on small screens, I am hiding some content that is to the right of the content I can't get centered using Bootstrap's "hidden-xs" and "hidden-sm" properties.

Here is the code for the relevant section in the screenshot, plus my CSS for the media query. If anyone could point me in the right direction, I'd appreciate it.

/* Content Styles*/
.gas-content {
 margin: 4.50em 0 4.50em 5%;
}

.left-content {
 margin: 2.50em 0 2.50em 5%;
}

.content-container {
 width: 75%;
 float: left;
}

.test-container {
 width: 25%;
 float: left;
 margin-top: -10px;
}

.move-up {
 margin-top: -2em;
}

.move-down {
 margin-top: 2em;
}

.img-center {
 display: block;
 margin: 0 auto;
}

.content-heading {
 color: rgb(3, 17, 85);
 font-family: 'Montserrat', sans-serif;
 font-weight: 600;
 line-height: 1.50em;
}

.services li {
 color: rgb(3, 17, 85);
 font-family: 'Montserrat', sans-serif;
 text-transform: uppercase;
 font-size: 1.25em;
 font-weight: 600;
}

.emergency-services li {
 color: rgb(3, 17, 85);
 font-family: 'Montserrat', sans-serif;
 text-transform: uppercase;
 font-size: 1.25em;
 font-weight: 600;
}

.contact-box {
 background-color: rgb(3, 17, 85);
 padding: 2em 0 6.50em 0;
}

.contact-box h3 {
 color: white;
 text-transform: uppercase;
 margin-left: 15px;
 font-family: 'Montserrat', sans-serif;
 font-weight: 600;
}

.contact-info {
 color: white;
 margin-left: 15px;
}

.eztouselogo {
 margin-left: 15px;
 margin-bottom: 15px;
}

.services-left {
 margin-right: 0.50em;
}

.content-paragraph {
 font-family: 'Open Sans', sans-serif;
 margin-bottom: 5em;
 line-height: 2.25em;
}

@media (max-width: 991px) {
 .test-container {
  display: none;
 }

 .content-container {
  display: block;
  margin: 0 auto;
  padding: 0 0 0 0;
  float: none;
  clear: both;
 }

 .container {
  display: block;
  margin: 0 auto;
  float: none;
  clear: both;
 }

 .pipes-img {
  width: 75%;
  height: 75%;
  display: block;
  margin: 0 auto;
  float: none;
 }
}

Gas, Water, & Sewer Line Inspection and Replacement in the Pittsburgh Area

Vivamus id ante molestie, vehicula justo nec, facilisis justo. Sed efficitur feugiat accumsan. Nunc vitae fermentum nulla. Aliquam imperdiet nunc felis, et malesuada ligula molestie eget. Proin sodales dictum semper. Proin nec sodales quam. Maecenas ac erat non mauris laoreet volutpat. Proin egestas enim ut magna sagittis vulputate. Aenean non odio lacus. Nam vehicula metus viverra quam laoreet, nec interdum orci porttitor. Etiam gravida velit sit amet commodo suscipit. Cras est erat, scelerisque quis velit non, luctus molestie ex.

Sewer Lines

Gas Lines

Water Lines

Sewer Inspections

Water Heaters

Full-Service Plumbing


问:
How to handle errors with Express-JWT
I am trying to incorporate the express-jwt library and I do not quite understand how it's error handling works.

The documentation says:

Error handling

The default behavior is to throw an error when the token is invalid, so you can >add your custom logic to manage unauthorized access as follows:

```<code>    app.use(function (err, req, res, next) {
      if (err.name === 'UnauthorizedError') {
        res.status(401).send('invalid token...');
      }
    });
</code>```

But I am confused how that works. If I have a simple req res situation, and I want to call next if the token is valid, or call next with an error if it is not, where to I put that app.use function?

For instance, here is my code:

```<code>router.post('/', expressJwt({
  secret: jwtSecret,
  credentialsRequired: false
}), (req, res, next) => {
  databaseController.findUser(req.user.email, (err, user) => {
    if (err) {
      return next(err)
    }
    res.json(user)
  })
})
</code>```

The err here would come from my DB call, not from the express-jwt validation.
Any help is appreciated.

答:
Another way is you could place the middleware with app.use to scan all the routes for a valid jwt in the header or the query string.
Any public endpoints can be exempted using the unless keyword.
Ex:</p>

```<code>app.use(expressjwt({credentialsRequired: true, secret: config.TOKEN_SECRET, requestProperty: 'user'}).unless({path: config.PUBLIC_URLs}));

app.use(function(err, req, res, next) {
    if(err.name === 'UnauthorizedError') {
      res.status(err.status).send({message:err.message});
      logger.error(err);
      return;
    }
 next();
});
</code>```

Title: How to handle errors with Express-JWT

Body:
I am trying to incorporate the express-jwt library and I do not quite understand how it's error handling works.

The documentation says:

Error handling

The default behavior is to throw an error when the token is invalid, so you can >add your custom logic to manage unauthorized access as follows:

    app.use(function (err, req, res, next) {
      if (err.name === 'UnauthorizedError') {
        res.status(401).send('invalid token...');
      }
    });

But I am confused how that works. If I have a simple req res situation, and I want to call next if the token is valid, or call next with an error if it is not, where to I put that app.use function?

For instance, here is my code:

router.post('/', expressJwt({
  secret: jwtSecret,
  credentialsRequired: false
}), (req, res, next) => {
  databaseController.findUser(req.user.email, (err, user) => {
    if (err) {
      return next(err)
    }
    res.json(user)
  })
})

The err here would come from my DB call, not from the express-jwt validation.
Any help is appreciated.

Body:
Another way is you could place the middleware with app.use to scan all the routes for a valid jwt in the header or the query string.
Any public endpoints can be exempted using the unless keyword.
Ex:

app.use(expressjwt({credentialsRequired: true, secret: config.TOKEN_SECRET, requestProperty: 'user'}).unless({path: config.PUBLIC_URLs}));

app.use(function(err, req, res, next) {
    if(err.name === 'UnauthorizedError') {
      res.status(err.status).send({message:err.message});
      logger.error(err);
      return;
    }
 next();
});


问:
What is alertcontroller.recyclelistview
What is alertcontroller.recyclelistview ? How it differ from Normal RecyclerView and What are the new Features and How to use it ?</p>

答:
According to other questions asked, links below, RecyclerListView is an internal class which is not intended for use other than a code block for other classes.
I can't find any document about it in developer.android.com as well.
Hope it clarifies a little bit.

Error inflating class android.support.v7.app.AlertController.RecycleListView

difference between android.support.v7.app.AlertController.RecycleListView and android.support.v7.widget.RecyclerView

Title: What is alertcontroller.recyclelistview


问:
MongoDB Throwing Syntax error while creating Date() in python file
When I am running the following command in mongodb shell its is running fine </p>

```<code>db.abcd_vehiclestate.count({"createdAt" : {"$lt": new Date("2017-03-27T00:00:00.000Z")}})
</code>```

<p>but when I am putting that inside a python script its throwing syntax error </p>

```<code>""testcount = db[col].count({"CreatedAt" : {'$lt':new Date("2017-03-28") }})                                                           ^
SyntaxError: invalid syntax""
</code>```

答:
Cause db[col].count({"CreatedAt" : {'$lt':new Date("2017-03-28") }}) is a javascript syntax. You should convert it to python syntax.

Try it:

```<code>from datetime import datetime

db[col].count({'CreatedAt': {'$lt': datetime.datetime(2017, 3, 28)}})
</code>```

Body:
When I am running the following command in mongodb shell its is running fine

db.abcd_vehiclestate.count({"createdAt" : {"$lt": new Date("2017-03-27T00:00:00.000Z")}})

but when I am putting that inside a python script its throwing syntax error

""testcount = db[col].count({"CreatedAt" : {'$lt':new Date("2017-03-28") }})                                                           ^
SyntaxError: invalid syntax""

Body:
Cause db[col].count({"CreatedAt" : {'$lt':new Date("2017-03-28") }}) is a javascript syntax. You should convert it to python syntax.

Try it:

from datetime import datetime

db[col].count({'CreatedAt': {'$lt': datetime.datetime(2017, 3, 28)}})


答:
no need of scope and your factory injection should be like below

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope, getFoo) {
   $scope.myArr = getFoo.getCommi(4,1);

});

app.factory('getFoo', function () {
  return {
       getCommi: function(val,id){
          var array = ["hello","world"];
          return array;
       }
     }
});    ```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <meta charset="utf-8" />
    <title>AngularJS Plunker</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <link rel="stylesheet" href="style.css" />
    <script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.28/angular.js" data-semver="1.2.28"></script>
    <script src="app.js"></script>
  </head>

  <body ng-controller="MainCtrl">
    <p>{{myArr}}!</p>
  </body>

</html></code>```

Title: How to create factory in AngularJS?

Body:
no need of scope and your factory injection should be like below

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope, getFoo) {
   $scope.myArr = getFoo.getCommi(4,1);

});

app.factory('getFoo', function () {
  return {
       getCommi: function(val,id){
          var array = ["hello","world"];
          return array;
       }
     }
});

<!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <meta charset="utf-8" />
    <title>AngularJS Plunker</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <link rel="stylesheet" href="style.css" />
    <script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.28/angular.js" data-semver="1.2.28"></script>
    <script src="app.js"></script>
  </head>

  <body ng-controller="MainCtrl">
    <p>{{myArr}}!</p>
  </body>

</html>


问:
sizewithFont and drawinRect Formatting
I have an iPhone app and each year some code elements generate deprecated issues. My app appears to run fine except for some slight format issues.  I've tried to use the suggested code, but it just result in errors.  I'd really like to fix these to see if solves the formatting issues.  Could someone help me with these.

First Issue:'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:  Tried to use the suggested replacement, but it just resulted in an error (see code below).  Not sure where to fit the current code in the option, attributes, and context.

Second Issue:  'drawInRect:withFont:lineBreakMode:alignment:' is deprecated: first deprecated in iOS 7.0 - Use -drawInRect:withAttributes:  Tried to use the suggested replacement, but it just resulted in an error (see code below).   Not sure where to fit the current code re withAttributes.

```<code> //Draw text fo our header.
        CGContextRef    currentContextHeader = UIGraphicsGetCurrentContext();
        CGContextSetRGBFillColor(currentContextHeader, 0.3, 0.7, 0.2, 1.0);

        NSString *textToDrawHeader = [NSString stringWithFormat:@"%@", enterSubject.text];

        UIFont *fontHeader = [UIFont systemFontOfSize:24.0];

        //Original Code that generated the issue
        //CGSize stringSizeHeader = [textToDrawHeader sizeWithFont:fontHeader constrainedToSize:CGSizeMake(_pageSize.width - 2*kBorderInset-2*kMarginInset, _pageSize.height - 2*kBorderInset - 2*kMarginInset) lineBreakMode:NSLineBreakByWordWrapping];

        //Proposed change that resulted in an error
        CGSize stringSizeHeader = [textToDrawHeader boundingRectWithSize:fontHeader options:attributes:context:constrainedToSize:CGSizeMake(_pageSize.width - 2*kBorderInset-2*kMarginInset, _pageSize.height - 2*kBorderInset - 2*kMarginInset) lineBreakMode:NSLineBreakByWordWrapping];

        CGRect renderingRectHeader = CGRectMake(kBorderInset + kMarginInset, kBorderInset + kMarginInset, _pageSize.width - 2*kBorderInset - 2*kMarginInset, stringSizeHeader.height);

        int ydistanceToLine = kBorderInset + kMarginInset + stringSizeHeader.height +kMarginInset;

        //Original Code that generated the issue
        //[textToDrawHeader drawInRect:renderingRectHeader withFont:fontHeader lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentLeft];

        //Proposed change that resulted in an error
        [textToDrawHeader drawInRect:withAttributes:renderingRectHeader withFont:fontHeader lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentLeft];
</code>```

答:
The return type of -boundingRectWithSize:options:attributes:context: is CGRect. But in your code you are assigning the value to CGSize.

Eg:

```<code>CGRect textRect = [_lbl_title.text boundingRectWithSize:boundingSize options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes: @{NSFontAttributeName:font} context:nil];
</code>```

Sample:

```<code>   - (float)expectedLabelHeight
{
    CGSize boundingSize = CGSizeMake(CGRectGetWidth(_lbl_title.bounds), CGFLOAT_MAX);
    UIFont *font = [UIFont fontWithName:@"Roboto-Light" size:14];
    CGRect textRect = [_lbl_title.text boundingRectWithSize:boundingSize options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes: @{NSFontAttributeName:font} context:nil];

    return (textRect.size.height+20.0);
}
</code>```

Change your code in accordance with the above example.

Title: sizewithFont and drawinRect Formatting

Body:
I have an iPhone app and each year some code elements generate deprecated issues. My app appears to run fine except for some slight format issues.  I've tried to use the suggested code, but it just result in errors.  I'd really like to fix these to see if solves the formatting issues.  Could someone help me with these.

First Issue:'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:  Tried to use the suggested replacement, but it just resulted in an error (see code below).  Not sure where to fit the current code in the option, attributes, and context.

Second Issue:  'drawInRect:withFont:lineBreakMode:alignment:' is deprecated: first deprecated in iOS 7.0 - Use -drawInRect:withAttributes:  Tried to use the suggested replacement, but it just resulted in an error (see code below).   Not sure where to fit the current code re withAttributes.

 //Draw text fo our header.
        CGContextRef    currentContextHeader = UIGraphicsGetCurrentContext();
        CGContextSetRGBFillColor(currentContextHeader, 0.3, 0.7, 0.2, 1.0);

        NSString *textToDrawHeader = [NSString stringWithFormat:@"%@", enterSubject.text];

        UIFont *fontHeader = [UIFont systemFontOfSize:24.0];

        //Original Code that generated the issue
        //CGSize stringSizeHeader = [textToDrawHeader sizeWithFont:fontHeader constrainedToSize:CGSizeMake(_pageSize.width - 2*kBorderInset-2*kMarginInset, _pageSize.height - 2*kBorderInset - 2*kMarginInset) lineBreakMode:NSLineBreakByWordWrapping];

        //Proposed change that resulted in an error
        CGSize stringSizeHeader = [textToDrawHeader boundingRectWithSize:fontHeader options:attributes:context:constrainedToSize:CGSizeMake(_pageSize.width - 2*kBorderInset-2*kMarginInset, _pageSize.height - 2*kBorderInset - 2*kMarginInset) lineBreakMode:NSLineBreakByWordWrapping];

        CGRect renderingRectHeader = CGRectMake(kBorderInset + kMarginInset, kBorderInset + kMarginInset, _pageSize.width - 2*kBorderInset - 2*kMarginInset, stringSizeHeader.height);

        int ydistanceToLine = kBorderInset + kMarginInset + stringSizeHeader.height +kMarginInset;

        //Original Code that generated the issue
        //[textToDrawHeader drawInRect:renderingRectHeader withFont:fontHeader lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentLeft];

        //Proposed change that resulted in an error
        [textToDrawHeader drawInRect:withAttributes:renderingRectHeader withFont:fontHeader lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentLeft];

Body:
The return type of -boundingRectWithSize:options:attributes:context: is CGRect. But in your code you are assigning the value to CGSize.

Eg:

CGRect textRect = [_lbl_title.text boundingRectWithSize:boundingSize options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes: @{NSFontAttributeName:font} context:nil];

Sample:

   - (float)expectedLabelHeight
{
    CGSize boundingSize = CGSizeMake(CGRectGetWidth(_lbl_title.bounds), CGFLOAT_MAX);
    UIFont *font = [UIFont fontWithName:@"Roboto-Light" size:14];
    CGRect textRect = [_lbl_title.text boundingRectWithSize:boundingSize options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes: @{NSFontAttributeName:font} context:nil];

    return (textRect.size.height+20.0);
}

Change your code in accordance with the above example.


问:
What is the equivalent of <template *ngFor in Angular 2?
I want to do something like this:

```<code><div *ngFor="let parent of parents">
    <div *ngFor="let child of parent.children">
    </div>
</div>
</code>```

but I don't want that extra outer div. From what i've been able to find searching, in Angular 1 I could achieve this by doing this:

```<code><template *ngFor="let parent of parents">
    <div *ngFor="let child of parent.children">
    </div>
</template>
</code>```

This doesn't seem to work in Angular 2 though. What's the correct way to do this?

答:
And for index use let-i="index":

```<code><template ngFor let-hero [ngForOf]="heroes" let-i="index" let-odd="odd">
  <div [class.odd]="odd">({{i}}) {{hero.name}}</div>
</template>
</code>```

More here:
https://angular.io/docs/ts/latest/guide/structural-directives.html#!#microsyntax

Body:
I want to do something like this:

but I don't want that extra outer div. From what i've been able to find searching, in Angular 1 I could achieve this by doing this:

<template *ngFor="let parent of parents">

</template>

This doesn't seem to work in Angular 2 though. What's the correct way to do this?

Body:
And for index use let-i="index":

<template ngFor let-hero [ngForOf]="heroes" let-i="index" let-odd="odd">
  <div [class.odd]="odd">({{i}}) {{hero.name}}</div>
</template>

More here:
https://angular.io/docs/ts/latest/guide/structural-directives.html#!#microsyntax