问:
Modal is not opening in boottrap java script file
I am currently learning the course of front end web developer. I am currently learning about modals. I am pasting my code below. I have uploaded an image of my file structure. I hope someone can find an answer to why my java script is not working. The code worked fine when I linked the code to the CDN javascript file. Please find a solution to my problem in the code

```<code>    <!DOCTYPE html>
    <html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Kitten Portfolio</title>
    <link href="https://fonts.googleapis.com/css?family=Lato:100,300" rel="stylesheet">
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/styles.css">
    <script type="text/javascript" src="js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-6">
                <img class="title-logo" src="udacity logo.jpg" alt="udacity logo">
            </div>
            <div class="col-md-6 text-right text-uppercase">
                <h1 class="title-super text-thin">Jane Doette</h1>
                <h4>Front-end Ninja</h4>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <hr>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <img class="img-fluid" src="http://placekitten.com/1140/350" alt="Main kitten image">
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <h2 class="text-muted">Featured Work</h2>
            </div>
        </div>
        <div class="row text-center">
            <div class="col-md-4">
                <img class="img-fluid" src="http://via.placeholder.com/555x300" data-toggle="modal" data-target="#project1" alt="Appify Kitten Image">
                <h3 class="text-uppercase">Appify</h3>
                <p>https://github.com/udacity/appify</p>
            </div>
            <div class="col-md-4">
                <img class="img-fluid" src="http://via.placeholder.com/555x300" alt="Sunflower Kitten Image">
                <h3 class="text-uppercase">Sunflower</h3>
                <p>https://github.com/udacity/sunflower</p>
            </div>
            <div class="col-md-4">
                <img class="img-fluid" src="http://via.placeholder.com/555x300" alt="Bokeh Kitten Image">
                <h3 class="text-uppercase">Bokeh</h3>
                <p>https://github.com/udacity/bokeh</p>
            </div>
        </div>
    </div>
     <!-- Modal -->
    <div class="modal fade" id="project1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel">Favorite App Page</h4>
                </div>
                <div class="modal-body">
                    <img class="img-responsive" src="images/555.jpeg">
                    This was my first project in this class. I learned a lot about HTML and CSS.
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
</body>
</code>```

File structure:

答:
A couple steps in debugging this problem is to have your developer tools open in your browser. First and foremost when you see that the page is not rendering to your assumptions, you need to clarify what you expected to see in order to diagnose well.

Based off some of the things you describe, it may be that the reference to the file is incorrect. To check this, on your developer tools, switch the network tab and press record if not already recording and refresh the page. You may find that there are some 404's showing up that will indicate the page may have the wrong reference to the file.

Next, if there are still problems, your developer tools should inform you of issues in the console output. Try there next.

Body:
I am currently learning the course of front end web developer. I am currently learning about modals. I am pasting my code below. I have uploaded an image of my file structure. I hope someone can find an answer to why my java script is not working. The code worked fine when I linked the code to the CDN javascript file. Please find a solution to my problem in the code

    <!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Kitten Portfolio</title>
    <link href="https://fonts.googleapis.com/css?family=Lato:100,300" rel="stylesheet">
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/styles.css">

Jane Doette

Front-end Ninja

Featured Work

Appify

https://github.com/udacity/appify

Sunflower

https://github.com/udacity/sunflower

Bokeh

https://github.com/udacity/bokeh

Favorite App Page

                    This was my first project in this class. I learned a lot about HTML and CSS.

                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

File structure:


来源: stackexchange

问:
MEL Script Button deletes object if it exists
My MEL knowledge isn't great and I have created a small script that duplicates your object and brings it next to your main one. I want to make it like when you click the MEL button the object appears but when you click it again the object gets deleted (if exists). Any help would be great as I'm almost at the point where I'm gonna start hitting my head on the wall.

Thanks

答:
Let's create our test object. It's a nurbsSphere1:

```<code>sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3;
</code>```

if...else statement in MEL is quite simple. Use the following code to select and delete a nurbsSphere1 if it exists in your scene:

```<code>if(`objExists nurbsSphere1`) {
    select nurbsSphere1;
    delete nurbsSphere1;
} else {
    warning("No NURBS Sphere exists");
}
</code>```

To execute just several lines of MEL code (not all) in Script Editor, select all the lines you need and press ctrl+enter on a keyboard for execution.

ContentLicense: CC BY-SA 3.0

Body:
Let's create our test object. It's a nurbsSphere1:

sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -d 3;

if...else statement in MEL is quite simple. Use the following code to select and delete a nurbsSphere1 if it exists in your scene:

if(`objExists nurbsSphere1`) {
    select nurbsSphere1;
    delete nurbsSphere1;
} else {
    warning("No NURBS Sphere exists");
}

To execute just several lines of MEL code (not all) in Script Editor, select all the lines you need and press ctrl+enter on a keyboard for execution.


问:
How to write a SQL statement to sum data using group by the same day of every two neighboring months
I have a data table like this:

```<code>datetime       data
-----------------------
...
2017/8/24       6.0
2017/8/25       5.0
...
2017/9/24       6.0
2017/9/25       6.2
...
2017/10/24      8.1
2017/10/25      8.2
</code>```

I want to write a SQL statement to sum the data using group by the 24th of every two neighboring months in certain range of time such as : from 2017/7/20 to 2017/10/25 as above.

How to write this SQL statement? I'm using SQL Server 2008 R2.

The expected results table is like this:

```<code>datetime_range          data_sum
------------------------------------
...
2017/8/24~2017/9/24       100.9
2017/9/24~2017/10/24      120.2
...
</code>```

Body:
I have a data table like this:

datetime       data
-----------------------
...
2017/8/24       6.0
2017/8/25       5.0
...
2017/9/24       6.0
2017/9/25       6.2
...
2017/10/24      8.1
2017/10/25      8.2

I want to write a SQL statement to sum the data using group by the 24th of every two neighboring months in certain range of time such as : from 2017/7/20 to 2017/10/25 as above.

How to write this SQL statement? I'm using SQL Server 2008 R2.

The expected results table is like this:

datetime_range          data_sum
------------------------------------
...
2017/8/24~2017/9/24       100.9
2017/9/24~2017/10/24      120.2
...

Body:
I would suggest  dynamically building some date range rows so that you can then join you data to those for aggregation, like this example:

+----+---------------------+---------------------+----------------+
|    |   period_start_dt   |    period_end_dt    | your_data_here |
+----+---------------------+---------------------+----------------+
|  1 | 24.04.2017 00:00:00 | 24.05.2017 00:00:00 |              1 |
|  2 | 24.05.2017 00:00:00 | 24.06.2017 00:00:00 |              1 |
|  3 | 24.06.2017 00:00:00 | 24.07.2017 00:00:00 |              1 |
|  4 | 24.07.2017 00:00:00 | 24.08.2017 00:00:00 |              1 |
|  5 | 24.08.2017 00:00:00 | 24.09.2017 00:00:00 |              1 |
|  6 | 24.09.2017 00:00:00 | 24.10.2017 00:00:00 |              1 |
|  7 | 24.10.2017 00:00:00 | 24.11.2017 00:00:00 |              1 |
|  8 | 24.11.2017 00:00:00 | 24.12.2017 00:00:00 |              1 |
|  9 | 24.12.2017 00:00:00 | 24.01.2018 00:00:00 |              1 |
| 10 | 24.01.2018 00:00:00 | 24.02.2018 00:00:00 |              1 |
| 11 | 24.02.2018 00:00:00 | 24.03.2018 00:00:00 |              1 |
| 12 | 24.03.2018 00:00:00 | 24.04.2018 00:00:00 |              1 |
+----+---------------------+---------------------+----------------+

DEMO

declare @start_dt date;
set @start_dt = '20170424';

select
       period_start_dt, period_end_dt, sum(1) as your_data_here
from (
        select
               dateadd(month,m.n,start_dt)   period_start_dt
             , dateadd(month,m.n+1,start_dt) period_end_dt
        from (
               select @start_dt start_dt ) seed
        cross join (
                    select 0 n union all
                    select 1 union all
                    select 2 union all
                    select 3 union all
                    select 4 union all
                    select 5 union all
                    select 6 union all
                    select 7 union all
                    select 8 union all
                    select 9 union all
                    select 10 union all
                    select 11
                   ) m
     ) r
-- LEFT JOIN YOUR DATA
-- ON yourdata.date >= r.period_start_dt and data.date < r.period_end_dt
group by
       period_start_dt, period_end_dt

Please don't be tempted to use "between" when it comes to joining to your data. Follow the note above and use yourdata.date >= r.period_start_dt and data.date < r.period_end_dt otherwise you could double count information as between is inclusive of both lower and upper boundaries.


问:
How can I one-hot encode data with numpy?
Suppose I have a dataset

```<code>sex    age hours
female 23  900
male   19  304
female 42  222
      ...
</code>```

If I use np.loadtxt or np.genfromtxt I can use a converter as a way to assign values to each of the categorical data in the sex column. Is there a way to instead create a one-hot column during the loading process? If not, where should I look to accomplish this?

答:
Here is a genfromtxt approach:

```<code>import numpy as np

def hot(s):
    rec = np.genfromtxt(s, dtype="i8,i4,i4", skip_header=1,
                        converters={0:{b'male':1<<32, b'female':1}.__getitem__})
    return rec.view(np.int32).reshape((-1, 4))

print(hot(<your_file_name>))
</code>```

Explanation: I think converters are required to return a single value. In order to get two we give the first column a double width dtype and the view cast the resulting recarray.

Body:
Suppose I have a dataset

sex    age hours
female 23  900
male   19  304
female 42  222
      ...

If I use np.loadtxt or np.genfromtxt I can use a converter as a way to assign values to each of the categorical data in the sex column. Is there a way to instead create a one-hot column during the loading process? If not, where should I look to accomplish this?

Body:
Here is a genfromtxt approach:

import numpy as np

def hot(s):
    rec = np.genfromtxt(s, dtype="i8,i4,i4", skip_header=1,
                        converters={0:{b'male':1<<32, b'female':1}.__getitem__})
    return rec.view(np.int32).reshape((-1, 4))

print(hot(<your_file_name>))

Explanation: I think converters are required to return a single value. In order to get two we give the first column a double width dtype and the view cast the resulting recarray.


问:
jpa entitymanager rollback not working
In my spring project i am using hibernate entitymanager. I have done transaction management in the project like below.

applicationContext.xml

```<code><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
        <property name="url" value="jdbc:oracle:thin:@xxxx:1527:selva" />
        <property name="username" value="xxx" />
        <property name="password" value="yyy" />
</bean>
<bean
            class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
        <bean id="entityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="packagesToScan">
                <list>
                    <value>com.selva.entity</value>
                </list>
            </property>
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    <property name="database" value="ORACLE" />
                    <property name="showSql" value="true" />
                </bean>
            </property>
        </bean>
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>
</code>```

TestTranService.java

```<code>@Transactional
    public String checkTranWork() {
        try {
            testTranDao.method1();
            int i=0;
            if(i==0)
                throw new ValidationException();
            testTranDao.method2();
            testTranDao.method3();
        } catch(Exception e) {
            e.printStackTrace();
        }
        return null;
    }
</code>```

TestTranDaoImpl.java

```<code>public class TestTranDaoImpl implements TestTranDao {

    public static final Logger LOGGER = Logger
            .getLogger(TestTranDaoImpl.class);

    @PersistenceContext
    private EntityManager entityManager;

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    public EntityManager getEntityManager() {
        return entityManager;
    }

    @Override
    public void method1() {
        try {
            String sql = "INSERT INTO CUST(MOBNUM,CUST_NAME) values ('1','dd')";
            Query query = entityManager.createNativeQuery(sql);
            query.executeUpdate();
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void method2() {
try {
    String sql = "INSERT INTO CUST(MOBNUM,CUST_NAME) values ('1','dd')";
    Query query = entityManager.createNativeQuery(sql);
    query.executeUpdate();
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

}
</code>```

In my code after method 1 executing the insert statement i am throwing the exception so the first statement should be rolled back.But in my case rollback is not happened.Is their any other configuration required for rollback.

Any help will be greatly appreciated!!!

答:
You Catch the Exceptions to log them, but then, you drop them. Don't do that!

An Exception has a meaning in a software, more than for logging, but also for all the framework around it.

Remove the try catch blocks so the @Transactional Aspect around your method can detect there's an error and rollback your transaction.

Title: jpa entitymanager rollback not working

Body:
In my spring project i am using hibernate entitymanager. I have done transaction management in the project like below.

applicationContext.xml

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
        <property name="url" value="jdbc:oracle:thin:@xxxx:1527:selva" />
        <property name="username" value="xxx" />
        <property name="password" value="yyy" />
</bean>
<bean
            class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
        <bean id="entityManagerFactory"
            class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="packagesToScan">
                <list>
                    <value>com.selva.entity</value>
                </list>
            </property>
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                    <property name="database" value="ORACLE" />
                    <property name="showSql" value="true" />
                </bean>
            </property>
        </bean>
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>

TestTranService.java

@Transactional
    public String checkTranWork() {
        try {
            testTranDao.method1();
            int i=0;
            if(i==0)
                throw new ValidationException();
            testTranDao.method2();
            testTranDao.method3();
        } catch(Exception e) {
            e.printStackTrace();
        }
        return null;
    }

TestTranDaoImpl.java

public class TestTranDaoImpl implements TestTranDao {

    public static final Logger LOGGER = Logger
            .getLogger(TestTranDaoImpl.class);

    @PersistenceContext
    private EntityManager entityManager;

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    public EntityManager getEntityManager() {
        return entityManager;
    }

    @Override
    public void method1() {
        try {
            String sql = "INSERT INTO CUST(MOBNUM,CUST_NAME) values ('1','dd')";
            Query query = entityManager.createNativeQuery(sql);
            query.executeUpdate();
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void method2() {
try {
    String sql = "INSERT INTO CUST(MOBNUM,CUST_NAME) values ('1','dd')";
    Query query = entityManager.createNativeQuery(sql);
    query.executeUpdate();
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

}

In my code after method 1 executing the insert statement i am throwing the exception so the first statement should be rolled back.But in my case rollback is not happened.Is their any other configuration required for rollback.

Any help will be greatly appreciated!!!


问:
Detect non-null reference in an array
I just asked a similar question, but then I realized I actually need something else. Since that question already has two answers, I do not want to edit my question. So here is what I actually need:

I want to detect whether a subrange of an array contains null references only. Somehow like this:

```<code>public static <T> boolean nullReferencesOnly
(T[] array, int fromInclusive, int toExclusive)
{
    for (int i = fromInclusive; i < toExclusive; ++i)
    {
        if (array[i] != null) return false;
    }
    return true;
}
</code>```

Is there a method like this in the Java library so I don't have to manually loop over the array?

答:
Well, not exactly efficient, but you could use a Set to help out, like in this example:

```<code>  String[] test = {null, null, null, null};
  Set<String> set = new HashSet<String>(Arrays.asList(test));
  System.out.println(set.size() == 0 || (set.size() == 1 && set.contains(null)));
</code>```

This way, if it is all null, it will only have one element and that one element will be null.
If you need just a range, you could use subList on Arrays.asList(test).

Not efficient, but uses classes you can find in core Java library.

Hope this helps.

ContentLicense: CC BY-SA 2.5

Title: Detect non-null reference in an array

Body:
I just asked a similar question, but then I realized I actually need something else. Since that question already has two answers, I do not want to edit my question. So here is what I actually need:

I want to detect whether a subrange of an array contains null references only. Somehow like this:

public static <T> boolean nullReferencesOnly
(T[] array, int fromInclusive, int toExclusive)
{
    for (int i = fromInclusive; i < toExclusive; ++i)
    {
        if (array[i] != null) return false;
    }
    return true;
}

Is there a method like this in the Java library so I don't have to manually loop over the array?

Body:
Well, not exactly efficient, but you could use a Set to help out, like in this example:

  String[] test = {null, null, null, null};
  Set<String> set = new HashSet<String>(Arrays.asList(test));
  System.out.println(set.size() == 0 || (set.size() == 1 && set.contains(null)));

This way, if it is all null, it will only have one element and that one element will be null.
If you need just a range, you could use subList on Arrays.asList(test).

Not efficient, but uses classes you can find in core Java library.

Hope this helps.


问:
"Process with an Id of #### is not running" in Visual Studio
I am trying to run any program on visual studio 2013 update 3 and I get the following alert box:

Process with an Id of #### is not running.

Every time there is different ID number showing.

and in the error windows, I get this error message:

The program '[3148] iisexpress.exe' has exited with code -1073741816 (0xc0000008) 'An invalid handle was specified'.

Sometimes it runs and in the browser I get the following message:

The webpage is not available.

Why is this occurring and how can I resolve it?

答:
Running as administrator didn't seem to make a difference when I got this.

Make sure all iisexpress.exe processes had been closed

Edit <path_to_your_solution>\Solution\.vs\config\applicationhost.config

Change the site name.

<site name="MySite" id="1" serverAutoStart="true">

to :

<site name="MySite2" id="1" serverAutoStart="true">

That fixed it for me

ContentLicense: CC BY-SA 4.0


问:
Nullpointerexception in accessing interface method in retrofit calling
Nullpointerexception in accessing interface method in retrofit calling

Userservice.class

```<code>public interface UserService {

    @POST("login")
    Call<ResUser> login(@Body login login);
}
</code>```

RetrofitClient.class

```<code>public class RetrofitClient {

    private static Retrofit retrofit=null;

    public static Retrofit getClient(String url){

        if(retrofit==null){
            retrofit=new Retrofit.Builder()
                    .baseUrl(url)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();
        }

        return retrofit;
    }
}
</code>```

login.class

```<code>    private void doLogin(String username,String password){
    Call<ResUser> call=userService.login(new login(username,password));
    call.enqueue(new Callback<ResUser>() {
        @Override
        public void onResponse(Call<ResUser> call, Response<ResUser> response) {
            if(response.isSuccessful()){
             Log.e("succes");
            }
        }

        @Override
        public void onFailure(Call<ResUser> call, Throwable t) {

        }
    });

}
</code>```

ApiUtils.class

```<code>public class ApiUtils {

    public static final String BASE_URL="";

    public static UserService getUserService(){
        return RetrofitClient.getClient(BASE_URL).create(UserService.class);
    }
}
</code>```

i have nullpointerexception in this line

```<code>  Call<ResUser> call=userService.login(new login(username,password));
</code>```

答:
Buddy issue is that you are passing username and password here, so instead of using constructor try to use getter setters.

Also make object of userService class before calling it because it is not instantiated in your code.

```<code>UserService userservice = ApiUtils.getUserService();
</code>```

And then try in a following way:

```<code>Call<ResUser> call=userService.login(new login(username,password));
</code>```

You need to pass Object of class Login as you defined here it will get an object of login :

```<code>@POST("login")
Call<ResUser> login(@Body login login);
</code>```

Now solution is that if your server needs object of login class then:

Before this:

```<code>Call<ResUser> call=userService.login(new login(username,password));
</code>```

Make an obect of login class and set user name and password for that object and then pass this object as :

```<code>Login login = new Login();
login.setuserName(username);
login.setpassword(password);
UserService userservice = ApiUtils.getUserService();
Call<ResUser> call=userService.login(login);
</code>```

Now if your server requires user name and password in body separately without login object then you need to change this:

```<code>@POST("login")
Call<ResUser> login(@Body login login);
</code>```

to:

```<code>@POST("login")
Call<ResUser> login(@Path("userName") String userName,@Path("password") String password);
</code>```

But as your web service path here @POST("login") shows that you dont need username and password in there so first solution is your solution.Make an object of class login and pass it on calling as I described above.

Body:
Nullpointerexception in accessing interface method in retrofit calling

Userservice.class

public interface UserService {

    @POST("login")
    Call<ResUser> login(@Body login login);
}

RetrofitClient.class

public class RetrofitClient {

    private static Retrofit retrofit=null;

    public static Retrofit getClient(String url){

        if(retrofit==null){
            retrofit=new Retrofit.Builder()
                    .baseUrl(url)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();
        }

        return retrofit;
    }
}

login.class

    private void doLogin(String username,String password){
    Call<ResUser> call=userService.login(new login(username,password));
    call.enqueue(new Callback<ResUser>() {
        @Override
        public void onResponse(Call<ResUser> call, Response<ResUser> response) {
            if(response.isSuccessful()){
             Log.e("succes");
            }
        }

        @Override
        public void onFailure(Call<ResUser> call, Throwable t) {

        }
    });

}

ApiUtils.class

public class ApiUtils {

    public static final String BASE_URL="";

    public static UserService getUserService(){
        return RetrofitClient.getClient(BASE_URL).create(UserService.class);
    }
}

i have nullpointerexception in this line

  Call<ResUser> call=userService.login(new login(username,password));

Body:
Buddy issue is that you are passing username and password here, so instead of using constructor try to use getter setters.

Also make object of userService class before calling it because it is not instantiated in your code.

UserService userservice = ApiUtils.getUserService();

And then try in a following way:

Call<ResUser> call=userService.login(new login(username,password));

You need to pass Object of class Login as you defined here it will get an object of login :

@POST("login")
Call<ResUser> login(@Body login login);

Now solution is that if your server needs object of login class then:

Before this:

Call<ResUser> call=userService.login(new login(username,password));

Make an obect of login class and set user name and password for that object and then pass this object as :

Login login = new Login();
login.setuserName(username);
login.setpassword(password);
UserService userservice = ApiUtils.getUserService();
Call<ResUser> call=userService.login(login);

Now if your server requires user name and password in body separately without login object then you need to change this:

@POST("login")
Call<ResUser> login(@Body login login);

to:

@POST("login")
Call<ResUser> login(@Path("userName") String userName,@Path("password") String password);

But as your web service path here @POST("login") shows that you dont need username and password in there so first solution is your solution.Make an object of class login and pass it on calling as I described above.


问:
Angular template validation form
I am working on the form validation. I am using template-driven validation form whose coding is below. Its working fine now but when I try to add #username = "ngModel" and #password = "ngModel" in input to create validation classes it's showing me an error. Please find the error also.

```<code><div class="container">
  <div class="row">
    <div class="centering text-center">
      <div class="login-cont col-md-4 col-md-offset-4 vcenter">
        <form id="login_form" name="login-form" #f="ngForm"  role="form" (ngSubmit)="f.form.valid && login()" novalidate>

          <input id="username" [(ngModel)]="username"  name="username"  required  class="form-control"  type="text"   placeholder="Username" >
<input id="userPassword" class="form-control"  required type="password" name="userPassword" required placeholder="Password" [(ngModel)]="password" >
<button type="submit" class="btn login-btn">Login</button>
</form>
</div>
</div>
</div>
</div>
</code>```

```<code> Cannot assign to a reference or variable!
    at _AstToIrVisitor.visitPropertyWrite (webpack-internal:///../../../compiler/esm5/compiler.js:26226:23)
    at PropertyWrite.visit (webpack-internal:///../../../compiler/esm5/compiler.js:4803:24)
    at convertActionBinding (webpack-internal:///../../../compiler/esm5/compiler.js:25676:45)
    at eval (webpack-internal:///../../../compiler/esm5/compiler.js:28166:22)
    at Array.forEach (<anonymous>)
    at ViewBuilder._createElementHandleEventFn (webpack-internal:///../../../compiler/esm5/compiler.js:28162:18)
    at nodes.(anonymous function) (webpack-internal:///../../../compiler/esm5/compiler.js:27581:27)
    at eval (webpack-internal:///../../../compiler/esm5/compiler.js:28107:22)
    at Array.map (<anonymous>)
    at ViewBuilder._createNodeExpressions (webpack-internal:///../../../compiler/esm5/compiler.js:28106:56)
</code>```

This is what I tried but it gives me an error

```<code>   <input id="username" class="form-control"  type="text" required  name="username" placeholder="Username" [(ngModel)]="username" minlength="4"  #names="ngModel">

          <div *ngIf="names.invalid && (names.dirty || names.touched)"
               class="alert alert-danger">
          </div>
            <div *ngIf="names.errors.required">
              Name is required.
            </div>

            <div *ngIf="names.errors.minlength">
              Name must be at least 4 characters long.
            </div>
</code>```

答:
You are getting error because of your variable name and local variable name
  both are same

username is a variable that you are assigning to [(ngModel)]='username' , at the same time you are also trying to make local variable #username

Use different name like #username2 or #password2 , will solve your problem.

For more details read :

https://scotch.io/tutorials/using-angular-2s-template-driven-forms

Title: Angular template validation form

Body:
I am working on the form validation. I am using template-driven validation form whose coding is below. Its working fine now but when I try to add #username = "ngModel" and #password = "ngModel" in input to create validation classes it's showing me an error. Please find the error also.

        <form id="login_form" name="login-form" #f="ngForm"  role="form" (ngSubmit)="f.form.valid && login()" novalidate>

          <input id="username" [(ngModel)]="username"  name="username"  required  class="form-control"  type="text"   placeholder="Username" >
<input id="userPassword" class="form-control"  required type="password" name="userPassword" required placeholder="Password" [(ngModel)]="password" >
<button type="submit" class="btn login-btn">Login</button>
</form>

 Cannot assign to a reference or variable!
    at _AstToIrVisitor.visitPropertyWrite (webpack-internal:///../../../compiler/esm5/compiler.js:26226:23)
    at PropertyWrite.visit (webpack-internal:///../../../compiler/esm5/compiler.js:4803:24)
    at convertActionBinding (webpack-internal:///../../../compiler/esm5/compiler.js:25676:45)
    at eval (webpack-internal:///../../../compiler/esm5/compiler.js:28166:22)
    at Array.forEach (<anonymous>)
    at ViewBuilder._createElementHandleEventFn (webpack-internal:///../../../compiler/esm5/compiler.js:28162:18)
    at nodes.(anonymous function) (webpack-internal:///../../../compiler/esm5/compiler.js:27581:27)
    at eval (webpack-internal:///../../../compiler/esm5/compiler.js:28107:22)
    at Array.map (<anonymous>)
    at ViewBuilder._createNodeExpressions (webpack-internal:///../../../compiler/esm5/compiler.js:28106:56)

This is what I tried but it gives me an error

   <input id="username" class="form-control"  type="text" required  name="username" placeholder="Username" [(ngModel)]="username" minlength="4"  #names="ngModel">

              Name is required.

              Name must be at least 4 characters long.


问:
Make last few lines of UILabel or UITextView fade out in swift. Please check the attached image

How to make control like this?

答:
Here is what I have done:

I created a UIView with a height of my choice, trailing, leading and bottom constraints to the textView.  This is my gradientView which I also use to add additional controls like the 'Read more' button, for example.

In viewDidLayoutSubviews() I create a gradient layer for the gradientView.  (Note that you need to either remove the layer before creating it or ensure that it is added only once, otherwise your gradient will get darker every time viewDidLayoutSubviews is called)

When my text change, I determine if the gradientView should be displayed or not by examining textView.contentSize.height > textView.frame.height

Herewith a Playground example

```<code>import UIKit
import PlaygroundSupport

class MyViewController : UIViewController {

var gradientView: UIView?
var gradient:CAGradientLayer?

override func loadView() {
    let view = UIView()
    view.backgroundColor = .gray

    let textView = UITextView()
    textView.frame = CGRect(x: 20, y: 20, width: 200, height: 300)
    textView.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eu gravida ligula, vitae venenatis felis. Suspendisse volutpat posuere pretium. Pellentesque quis quam ac velit tincidunt egestas. Phasellus sed scelerisque augue, interdum luctus eros. Praesent non augue eu enim dignissim convallis. Nunc commodo eros quis quam euismod, a malesuada ipsum mattis. Sed sit amet ipsum in justo dictum rutrum a sit amet sem. Sed sit amet mi vel nulla ornare congue. Nam elit ante, aliquam id consequat ac, pretium vel augue. Vivamus hendrerit commodo lectus, vel feugiat mi tempus non. Donec porta, ipsum id porttitor sodales, tortor lectus porta lacus, quis blandit turpis enim at libero. Donec ante est, rutrum quis malesuada a, accumsan at tortor. Nam molestie commodo nulla non suscipit. Nullam pellentesque nunc quam, vitae tempus turpis sollicitudin id. Integer vel varius urna, eleifend eleifend diam."
    textView.textColor = .black
    view.addSubview(textView)

    let gradientViewFrame = CGRect(x:textView.frame.origin.x, y: textView.frame.origin.y + textView.frame.height - 100, width: textView.frame.width, height: 100)
    gradientView = UIView(frame:gradientViewFrame)
        view.addSubview(gradientView!)
    self.view = view
}

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        gradient?.removeFromSuperlayer()
        gradient = gradientView?.gradientBackground(from:.white, to: UIColor.white.withAlphaComponent(0), direction: .bottomToTop)
    }
}

enum GradientDirection {
    case leftToRight
    case rightToLeft
    case topToBottom
    case bottomToTop
}

extension UIView {
    func gradientBackground(from color1: UIColor, to color2: UIColor, direction: GradientDirection) -> CAGradientLayer {
        let gradient = CAGradientLayer()
        gradient.frame = self.bounds
        gradient.colors = [color1.cgColor, color2.cgColor]

        switch direction {
        case .leftToRight:
            gradient.startPoint = CGPoint(x: 0.0, y: 0.5)
            gradient.endPoint = CGPoint(x: 1.0, y: 0.5)
        case .rightToLeft:
            gradient.startPoint = CGPoint(x: 1.0, y: 0.5)
            gradient.endPoint = CGPoint(x: 0.0, y: 0.5)
        case .bottomToTop:
            gradient.startPoint = CGPoint(x: 0.5, y: 1.0)
            gradient.endPoint = CGPoint(x: 0.5, y: 0.0)
        case .topToBottom:
            gradient.startPoint = CGPoint(x: 0.5, y: 0.0)
            gradient.endPoint = CGPoint(x: 0.5, y: 1.0)
        default:
            break
        }

        self.layer.insertSublayer(gradient, at: 0)
        return gradient
    }
}

// Present the view controller in the Live View window
PlaygroundPage.current.liveView = MyViewController()
</code>```

Body: How to make control like this?

Body:
Here is what I have done:

I created a UIView with a height of my choice, trailing, leading and bottom constraints to the textView.  This is my gradientView which I also use to add additional controls like the 'Read more' button, for example.

In viewDidLayoutSubviews() I create a gradient layer for the gradientView.  (Note that you need to either remove the layer before creating it or ensure that it is added only once, otherwise your gradient will get darker every time viewDidLayoutSubviews is called)

When my text change, I determine if the gradientView should be displayed or not by examining textView.contentSize.height > textView.frame.height

Herewith a Playground example

import UIKit
import PlaygroundSupport

class MyViewController : UIViewController {

var gradientView: UIView?
var gradient:CAGradientLayer?

override func loadView() {
    let view = UIView()
    view.backgroundColor = .gray

    let textView = UITextView()
    textView.frame = CGRect(x: 20, y: 20, width: 200, height: 300)
    textView.text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eu gravida ligula, vitae venenatis felis. Suspendisse volutpat posuere pretium. Pellentesque quis quam ac velit tincidunt egestas. Phasellus sed scelerisque augue, interdum luctus eros. Praesent non augue eu enim dignissim convallis. Nunc commodo eros quis quam euismod, a malesuada ipsum mattis. Sed sit amet ipsum in justo dictum rutrum a sit amet sem. Sed sit amet mi vel nulla ornare congue. Nam elit ante, aliquam id consequat ac, pretium vel augue. Vivamus hendrerit commodo lectus, vel feugiat mi tempus non. Donec porta, ipsum id porttitor sodales, tortor lectus porta lacus, quis blandit turpis enim at libero. Donec ante est, rutrum quis malesuada a, accumsan at tortor. Nam molestie commodo nulla non suscipit. Nullam pellentesque nunc quam, vitae tempus turpis sollicitudin id. Integer vel varius urna, eleifend eleifend diam."
    textView.textColor = .black
    view.addSubview(textView)

    let gradientViewFrame = CGRect(x:textView.frame.origin.x, y: textView.frame.origin.y + textView.frame.height - 100, width: textView.frame.width, height: 100)
    gradientView = UIView(frame:gradientViewFrame)
        view.addSubview(gradientView!)
    self.view = view
}

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        gradient?.removeFromSuperlayer()
        gradient = gradientView?.gradientBackground(from:.white, to: UIColor.white.withAlphaComponent(0), direction: .bottomToTop)
    }
}

enum GradientDirection {
    case leftToRight
    case rightToLeft
    case topToBottom
    case bottomToTop
}

extension UIView {
    func gradientBackground(from color1: UIColor, to color2: UIColor, direction: GradientDirection) -> CAGradientLayer {
        let gradient = CAGradientLayer()
        gradient.frame = self.bounds
        gradient.colors = [color1.cgColor, color2.cgColor]

        switch direction {
        case .leftToRight:
            gradient.startPoint = CGPoint(x: 0.0, y: 0.5)
            gradient.endPoint = CGPoint(x: 1.0, y: 0.5)
        case .rightToLeft:
            gradient.startPoint = CGPoint(x: 1.0, y: 0.5)
            gradient.endPoint = CGPoint(x: 0.0, y: 0.5)
        case .bottomToTop:
            gradient.startPoint = CGPoint(x: 0.5, y: 1.0)
            gradient.endPoint = CGPoint(x: 0.5, y: 0.0)
        case .topToBottom:
            gradient.startPoint = CGPoint(x: 0.5, y: 0.0)
            gradient.endPoint = CGPoint(x: 0.5, y: 1.0)
        default:
            break
        }

        self.layer.insertSublayer(gradient, at: 0)
        return gradient
    }
}

// Present the view controller in the Live View window
PlaygroundPage.current.liveView = MyViewController()


问:
How to generate PDF using mPDF and add custom Google font to it?
I am generating PDF using mPDF PHP library. I am able to successfully generate it using the default font configuration. However, I want to render a Google font in my PDF. I tried using the steps mentioned in this link, but it did not work. Below is the code I use.

```<code>$mPDFO = new mPDF('utf-8', 'A4', 0, '', 10, 10, 10, 0, 0, 0, 'L');
</code>```

Can anyone help me using Google Font in mPDF ?

答:
As mentioned in mPDF's documentation, it's not possible to use remote fonts directly by referencing them in the HTML. Follow the below steps to use custom fonts:

Download the fonts & upload them to mPDF's fonts directory /ttfonts

Declare the font-family you need to use in config_fonts.php under: $this->fontdata

Now comes the main part. You need to mention the font-family in the instance that you create to call mPDF's object which is what you missed, like so:

$mPDFO = new mPDF('utf-8', 'A4', 0, 'Source Sans Pro', 10, 10, 10, 0, 0, 0, 'L');

Finally call the SetFont method like $mPDFO->SetFont('Source Sans Pro'); just below your instance

Body:
I am generating PDF using mPDF PHP library. I am able to successfully generate it using the default font configuration. However, I want to render a Google font in my PDF. I tried using the steps mentioned in this link, but it did not work. Below is the code I use.

$mPDFO = new mPDF('utf-8', 'A4', 0, '', 10, 10, 10, 0, 0, 0, 'L');

Can anyone help me using Google Font in mPDF ?


问:
How to target children in a each loop using GreenSock and ScrollMagic
I want to be able to have each div with the class of .fade-in target its children h1(slide in right) and span(slide in left) by using a each() loop. So my question is how do I target a child element using 'this' e.g tl.from('.fade-in h1', 1, {x: 300}) Replace .fade-in with "this"?

```<code>tl
  .from(
    ".fade-in h1",
    0.3,
    { autoAlpha: 0, scale: 0.5, x: 300, ease: Linear.easeNone },
    "x"
  )
  .from(
    ".fade-in span",
    0.3,
    { autoAlpha: 0, scale: 0.5, x: -300, color: "red", ease: Linear.easeNone },
    "x"
  );
</code>```

Demo Link

答:
Try this

Check Demo Here

```<code>// init controller
var controller = new ScrollMagic.Controller();

// loop through all elements
$(".fade-in").each(function() {
  var jh1 = $(this).find("h1");
  var jspan = $(this).find("span");
  var tl = new TimelineMax();

  tl
    .from(
      jh1,
      0.5,
      { autoAlpha: 0, scale: 0.5, x: 300, ease: Linear.easeNone },
      "x"
    )
    .from(
      jspan,
      0.5,
      {
        autoAlpha: 0,
        scale: 0.5,
        x: -300,
        color: "red",
        ease: Linear.easeNone
      },
      "x"
    );

  // build a scene
  var scene = new ScrollMagic.Scene({
    triggerElement: this,
    offset: 10,
    triggerHook: 0
  })
    .setTween(tl) // trigger a TweenMax.to tween
    .addIndicators()
    .addTo(controller);
});
</code>```

Body:
I want to be able to have each div with the class of .fade-in target its children h1(slide in right) and span(slide in left) by using a each() loop. So my question is how do I target a child element using 'this' e.g tl.from('.fade-in h1', 1, {x: 300}) Replace .fade-in with "this"?

tl
  .from(
    ".fade-in h1",
    0.3,
    { autoAlpha: 0, scale: 0.5, x: 300, ease: Linear.easeNone },
    "x"
  )
  .from(
    ".fade-in span",
    0.3,
    { autoAlpha: 0, scale: 0.5, x: -300, color: "red", ease: Linear.easeNone },
    "x"
  );

Demo Link

Body:
Try this

Check Demo Here

// init controller
var controller = new ScrollMagic.Controller();

// loop through all elements
$(".fade-in").each(function() {
  var jh1 = $(this).find("h1");
  var jspan = $(this).find("span");
  var tl = new TimelineMax();

  tl
    .from(
      jh1,
      0.5,
      { autoAlpha: 0, scale: 0.5, x: 300, ease: Linear.easeNone },
      "x"
    )
    .from(
      jspan,
      0.5,
      {
        autoAlpha: 0,
        scale: 0.5,
        x: -300,
        color: "red",
        ease: Linear.easeNone
      },
      "x"
    );

  // build a scene
  var scene = new ScrollMagic.Scene({
    triggerElement: this,
    offset: 10,
    triggerHook: 0
  })
    .setTween(tl) // trigger a TweenMax.to tween
    .addIndicators()
    .addTo(controller);
});


问:
copy data of a project(from a project table) from one database to other in Oracle
Could somebody tell me how to do this in Oracle:

I have a table named project in which there a multiple projects. I want to copy the data of a particular project from the source database to another database. The project doesn't exist(in the project table) in the destination database.

I want something like:
copy from sourceDatabase to destinationDatabase
           create new_table using select * from project where name='Name of the project to be copied'

答:
If you can and are allowed to create `database links, create one and then copy the data over the database link.
That would be: on the destination db:

```<code>create database link db_link
connect to <username>
identified by <password>
using '<connection_string>";
</code>```

then

```<code>insert into projects
select * from projects@db_link
where ....
</code>```

Or,alternatively, try the copy command of SQL*Plus.

```<code>SQL> copy from <db_src> to <db_dest> append projects using select * from projects where ....
</code>```

Body:
If you can and are allowed to create `database links, create one and then copy the data over the database link.
That would be: on the destination db:

create database link db_link
connect to <username>
identified by <password>
using '<connection_string>";

then

insert into projects
select * from projects@db_link
where ....

Or,alternatively, try the copy command of SQL*Plus.

SQL> copy from <db_src> to <db_dest> append projects using select * from projects where ....


问:
Sencha Touch dataview with paging plugin
Så i have noticed a very annoying bug in Sencha Touch. When i try to add the paging plugin to my dataview the "load more" text is placed above the items, not below like i want it to. It works with the standard listview.

I found another thread asking me to add "inifinte:true" to my dataview, but that did not help. Nor did "bottom:0" or "docked:'bottom'" options. Here is my code:

```<code>{
  xtype: 'dataview',
  plugins: {
     type: 'listpaging',
     loadMoreText: 'Indlæs flere..',
     autoPaging: true
  },
  flex: 1,
  cls: 'inspectionImages',
  itemId: 'imageContainer',
  padding: 10,
  style: 'background: #F7F7F7; color: black',
  emptyText: 'Der er ingen billeder på synet.',
  itemTpl: ['...'],
  loadingText: 'Henter billeder..',
  store: 'Images'
}
</code>```

Also here is an example sencha fiddle code - framework is 2.4.x:

```<code>Ext.application({
launch: function () {
    var touchTeam = Ext.create('Ext.DataView', {
        fullscreen: true,
        plugins: {
            type: 'listpaging',
            loadMoreText: 'Indlæs flere..',
            autoPaging: true
        },
        store: {
            fields: ['name', 'age'],
            data: [{
                name: 'Jamie',
                age: 100
            }, {
                name: 'Rob',
                age: 21
            }, {
                name: 'Tommy',
                age: 24
            }, {
                name: 'Jacky',
                age: 24
            }, {
                name: 'Ed',
                age: 26
            }]
        },
        itemTpl: '<div>{name} is {age} years old</div>'
    });

    touchTeam.getStore().add({
        name: 'Abe Elias',
        age: 33
    });

    touchTeam.getStore().getAt(0).set('age', 42);
  } // launch
}); // application()
</code>```

I have checked with the Ext.dataview.dataview in the sencha touch documentation, and this shows similar behaviour when adding the paging plugin so i know that this is probably not my own fault. I really would like the loadinText to be placed in the bottom of the dataview. Any suggestions would highly be appreciated!

答:
I have found the solution after gone through the code of List paging Plugin, Ext.dataview.DataView and Ext.dataview.List.

Initialize list paging plugin after dataview initialized, then the "load more component" position will be right.

Ext.define('MyDataView', {
    extend: 'Ext.dataview.DataView',

    config: {
        /* do not set here
        plugins: [{
            xclass: 'Ext.plugin.ListPaging',
            autoPaging: true
        }, {
            xclass: 'Ext.plugin.PullRefresh'
        }]
        */
    },

    initialize: function() {
        var me = this;

        me.callParent();

        // Initialize plugin here, so the listpaging component will append after dataview container
        me.setPlugins([{
            xclass: 'Ext.plugin.ListPaging',
            autoPaging: true
        }, {
            xclass: 'Ext.plugin.PullRefresh'
        }]);
    }
}```

Body:
Så i have noticed a very annoying bug in Sencha Touch. When i try to add the paging plugin to my dataview the "load more" text is placed above the items, not below like i want it to. It works with the standard listview.

I found another thread asking me to add "inifinte:true" to my dataview, but that did not help. Nor did "bottom:0" or "docked:'bottom'" options. Here is my code:

{
  xtype: 'dataview',
  plugins: {
     type: 'listpaging',
     loadMoreText: 'Indlæs flere..',
     autoPaging: true
  },
  flex: 1,
  cls: 'inspectionImages',
  itemId: 'imageContainer',
  padding: 10,
  style: 'background: #F7F7F7; color: black',
  emptyText: 'Der er ingen billeder på synet.',
  itemTpl: ['...'],
  loadingText: 'Henter billeder..',
  store: 'Images'
}

Also here is an example sencha fiddle code - framework is 2.4.x:

Ext.application({
launch: function () {
    var touchTeam = Ext.create('Ext.DataView', {
        fullscreen: true,
        plugins: {
            type: 'listpaging',
            loadMoreText: 'Indlæs flere..',
            autoPaging: true
        },
        store: {
            fields: ['name', 'age'],
            data: [{
                name: 'Jamie',
                age: 100
            }, {
                name: 'Rob',
                age: 21
            }, {
                name: 'Tommy',
                age: 24
            }, {
                name: 'Jacky',
                age: 24
            }, {
                name: 'Ed',
                age: 26
            }]
        },
        itemTpl: '
{name} is {age} years old
'
    });

    touchTeam.getStore().add({
        name: 'Abe Elias',
        age: 33
    });

    touchTeam.getStore().getAt(0).set('age', 42);
  } // launch
}); // application()

I have checked with the Ext.dataview.dataview in the sencha touch documentation, and this shows similar behaviour when adding the paging plugin so i know that this is probably not my own fault. I really would like the loadinText to be placed in the bottom of the dataview. Any suggestions would highly be appreciated!


问:
I am sending GET method to server but receiving POST method
I am sending GET command to the server but in the Apache log I am  getting POST method.

```<code>URL url = new URL("http://192.168.0.111/shakil/shakil.php/?data=shakil,123,123,123");
JSONObject postDataParams = new JSONObject();
postDataParams.put("name", "nazmul");
postDataParams.put("email", "hossainnazmul93@gmail.com");
Log.e("params",postDataParams.toString());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(3000 /* milliseconds */);
conn.setConnectTimeout(3000 /* milliseconds */);
conn.setRequestMethod("GET");
conn.setDoInput(true);
conn.setDoOutput(true);
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
writer.write(getPostDataString(postDataParams));
writer.flush();
writer.close();
os.close();
</code>```

Although the method is GET. Can Any one suggest me what is the problem?

答:
I am sending GET method

No you aren't. This line:

```<code>conn.setDoOutput(true);
</code>```

sets the request method to POST. You are also doing some output, which doesn't match with a GET request either. If you want a GET, remove the line above and the lines that do the output. Probably you should send the parameters encoded into the URL.

Body:
I am sending GET command to the server but in the Apache log I am  getting POST method.

URL url = new URL("http://192.168.0.111/shakil/shakil.php/?data=shakil,123,123,123");
JSONObject postDataParams = new JSONObject();
postDataParams.put("name", "nazmul");
postDataParams.put("email", "hossainnazmul93@gmail.com");
Log.e("params",postDataParams.toString());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(3000 /* milliseconds */);
conn.setConnectTimeout(3000 /* milliseconds */);
conn.setRequestMethod("GET");
conn.setDoInput(true);
conn.setDoOutput(true);
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, "UTF-8"));
writer.write(getPostDataString(postDataParams));
writer.flush();
writer.close();
os.close();

Although the method is GET. Can Any one suggest me what is the problem?

Body:
I am sending GET method

No you aren't. This line:

conn.setDoOutput(true);

sets the request method to POST. You are also doing some output, which doesn't match with a GET request either. If you want a GET, remove the line above and the lines that do the output. Probably you should send the parameters encoded into the URL.


问:
Java: is there a way to convert text into a class?
I have the input: "ListClients param1 param2"
which splits by " " to "ListClients", "param1", "param2";

and I want to call a static method from ListClients.

So it would do ListClients.someMethodThatTakesPraams(param1, param2);

is there a way to do that in java?

答:
Yes indeed!  You can use Class.getDeclaredMethod to look up a Method object given a name and the types of the parameters.  For example, to find your someMethodThatTakesParams method, you could write

```<code>Method m = ListClients.class.getDeclaredMethod("someMethodThatTakesParams", ArgType1.class, ArgType2.class);
</code>```

Here, ArgType1 and ArgType2 are the types of the arguments.

Once you have the method, you can invoke it as follows:

```<code>m.invoke(null, arg1, arg2);
</code>```

Where arg1 and arg2 are the parameters you want to pass.  Note that the first argument to invoke is null because the method is static.

This approach omits all sorts of weirdness with exceptions you have to catch and security permissions you might have to acquire, but fortunately those aren't that hard to pick up.

Body:
Yes indeed!  You can use Class.getDeclaredMethod to look up a Method object given a name and the types of the parameters.  For example, to find your someMethodThatTakesParams method, you could write

Method m = ListClients.class.getDeclaredMethod("someMethodThatTakesParams", ArgType1.class, ArgType2.class);

Here, ArgType1 and ArgType2 are the types of the arguments.

Once you have the method, you can invoke it as follows:

m.invoke(null, arg1, arg2);

Where arg1 and arg2 are the parameters you want to pass.  Note that the first argument to invoke is null because the method is static.

This approach omits all sorts of weirdness with exceptions you have to catch and security permissions you might have to acquire, but fortunately those aren't that hard to pick up.


问:
Azure Blob Storage - Set an alert when a new uploaded file is greater than your size limit
Azure Blob Storage - How to set an alert inside azure portal when a new uploaded file is greater than my size limit? i.e if someone upload 500mb file by hitting upload endpoint directly i want to get alert to prevent high billing.</p>

答:
How to set an alert when a new uploaded file is greater than my size limit?

We could check the file sizes before upload to azure blob action. We could do that with javascript easilly in the client side.

Demo code:

```<code>if (typeof FileReader !== "undefined") {
    var size = document.getElementById('myfile').files[0].size;
    // check file size
}
</code>```

Updated:

if someone upload 500mb file by hitting upload endpoint directly i want to get alert to prevent high billing.

Based on my experience, it is not recommonded to check it after it is uploaded.
Becasue it has been uploaded to azure storage. Suggestion way is that you limit it on the client side.

Now it is not supported to add the alert rule for storage resource. If you still stick to doing that,you could use Azure function with blob trigger to do that. You also could give your idea to Azure storage team

```<code>[FunctionName("BlobTriggerCSharp")]
public static void Run([BlobTrigger("samples-workitems/{name}")] Stream myBlob, string name, TraceWriter log)
{
    log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
   //add you logicial here.
}
</code>```

Body:
How to set an alert when a new uploaded file is greater than my size limit?

We could check the file sizes before upload to azure blob action. We could do that with javascript easilly in the client side.

Demo code:

if (typeof FileReader !== "undefined") {
    var size = document.getElementById('myfile').files[0].size;
    // check file size
}

Updated:

if someone upload 500mb file by hitting upload endpoint directly i want to get alert to prevent high billing.

Based on my experience, it is not recommonded to check it after it is uploaded.
Becasue it has been uploaded to azure storage. Suggestion way is that you limit it on the client side.

Now it is not supported to add the alert rule for storage resource. If you still stick to doing that,you could use Azure function with blob trigger to do that. You also could give your idea to Azure storage team

[FunctionName("BlobTriggerCSharp")]
public static void Run([BlobTrigger("samples-workitems/{name}")] Stream myBlob, string name, TraceWriter log)
{
    log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
   //add you logicial here.
}


问:
Bean must be of 'org.hibernate.SessionFactory' type
I have been following an online training ( https://www.udemy.com/building-an-e-commerce-store-using-java-spring-framework ) and when i finish the applicationContext.xml i get the following errors.

ref="sessionFactory" indicates the following:

Bean must be of org.hibernate.SessionFactory type less... (Ctrl+F1) Checks value types for Spring injections (properties & constructor arguments)

And ref="dataSource" indicates datasource unexpected.

I do not understand what i am missing. How should i correct this?

I have uploaded my project to github: https://github.com/arendkolk/Wholesaleproducts

applicationContext.xml :

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.h2.Driver" />
        <property name="url" value="jdbc:h2:tcp://localhost/~/test" />
        <property name="username" value="sa" />
        <property name="password" value="" />
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
        <property name="dataSource" ref="dataSource"></property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
            </props>
        </property>
        <property name="packagesToScan">
            <list>
                <value>com.wholesaleproducts</value>
            </list>
        </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

</beans>
</code>```

This is my pom.xml :

```<code><?xml version="1.0" encoding="UTF-8"?>
<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>club.wholesaleproducts</groupId>
    <artifactId>wholesaleproducts</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.190</version>
    </dependency>

    <dependencies>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
    </dependencies>

</project>
</code>```

答:
In the pom.xml file put all your dependency inside the dependencies tag.Then it will build perfectly.

```<code><dependencies>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.190</version>
    </dependency>
</dependencies>
</code>```

Body:
I have been following an online training ( https://www.udemy.com/building-an-e-commerce-store-using-java-spring-framework ) and when i finish the applicationContext.xml i get the following errors.

ref="sessionFactory" indicates the following:

Bean must be of org.hibernate.SessionFactory type less... (Ctrl+F1) Checks value types for Spring injections (properties & constructor arguments)

And ref="dataSource" indicates datasource unexpected.

I do not understand what i am missing. How should i correct this?

I have uploaded my project to github: https://github.com/arendkolk/Wholesaleproducts

applicationContext.xml :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.h2.Driver" />
        <property name="url" value="jdbc:h2:tcp://localhost/~/test" />
        <property name="username" value="sa" />
        <property name="password" value="" />
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
        <property name="dataSource" ref="dataSource"></property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
            </props>
        </property>
        <property name="packagesToScan">
            <list>
                <value>com.wholesaleproducts</value>
            </list>
        </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

</beans>

This is my pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<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>club.wholesaleproducts</groupId>
    <artifactId>wholesaleproducts</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.190</version>
    </dependency>

    <dependencies>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
    </dependencies>

</project>

Body:
In the pom.xml file put all your dependency inside the dependencies tag.Then it will build perfectly.

<dependencies>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>4.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.190</version>
    </dependency>
</dependencies>


问:
Join SQL Tables with Unique Data (Not same number of columns!)
How can I join three or four SQL tables that DO NOT have an equal amount of rows while ensuring that there are no duplicates of a primary/foreign key?

Structure:

Table1: id, first_name, last_name, email

Table2: id (independent of id in table 1), name, location, table1_id, table2_id

Table3: id, name, location

I want all of the data from table 1, then all of the data from table 2 corresponding with the table1_id without duplicates.

Kind of tricky for a new guy...

答:
Not sure what do you want to do with Table3.

A LEFT JOIN returns all records from the LEFT table, and the matched records from the right table. If there is no match (from the right side), then the result is NULL.

So per example:

```<code>SELECT * FROM Table1 AS t
LEFT JOIN Table2 AS tt
ON t.id = tt.id
</code>```

The LEFT table refers to the table statement before the LEFT JOIN, and the RIGHT table refers to the table statement after the LEFT JOIN. If you want to add in Table3 as well, use the same logic:

```<code>SELECT * FROM Table1 AS t
LEFT JOIN Table2 AS tt
ON t.id = tt.id
LEFT JOIN Table3 AS ttt
ON t.id = ttt.id
</code>```

Note, that I use alias names for the tables (by using AS), so that I can more easily refer to a specific table. For example, t refers to Table1, tt refers to Table2, and ttt refers to Table3.

Joins are often used in SQL, therefore it is useful to look into: INNER JOIN, RIGHT JOIN, FULL JOIN, and SELF JOIN, as well.

Hope this helps.

Good luck with learning!

Body:
Not sure what do you want to do with Table3.

A LEFT JOIN returns all records from the LEFT table, and the matched records from the right table. If there is no match (from the right side), then the result is NULL.

So per example:

SELECT * FROM Table1 AS t
LEFT JOIN Table2 AS tt
ON t.id = tt.id

The LEFT table refers to the table statement before the LEFT JOIN, and the RIGHT table refers to the table statement after the LEFT JOIN. If you want to add in Table3 as well, use the same logic:

SELECT * FROM Table1 AS t
LEFT JOIN Table2 AS tt
ON t.id = tt.id
LEFT JOIN Table3 AS ttt
ON t.id = ttt.id

Note, that I use alias names for the tables (by using AS), so that I can more easily refer to a specific table. For example, t refers to Table1, tt refers to Table2, and ttt refers to Table3.

Joins are often used in SQL, therefore it is useful to look into: INNER JOIN, RIGHT JOIN, FULL JOIN, and SELF JOIN, as well.

Hope this helps.

Good luck with learning!


问:
How to link RCTCameraRoll for Android
I'm trying to use the CameraRoll library, but the documentation does not specify how to link it for Android. Instead, it only contains steps for iOS. It states that Android is supported but I have no idea how to link it in order to use it.

答:
I came thru the same question. The fact is

We have to create a project using React Init method then it automatically created Android and IOS folder.

Later you can install and link the Native libraries automatically. Here are the code snippets.

react-native init Cameraroll

npm i react-native-camera --save

react-native link

```<code>export default class App extends Component<{}> {
  render() {
    return (
       <View style={styles.container}>
        <Camera
          ref={(cam) => {
            this.camera = cam;
          }}
          style={styles.preview}
          aspect={Camera.constants.Aspect.fill}>
          <Text style={styles.capture} onPress={this.takePicture.bind(this)}>[CAPTURE]</Text>
        </Camera>
      </View>
    );
  }
  takePicture() {
    const options = {};
    //options.location = ...
    this.camera.capture({metadata: options})
      .then((data) => console.log(data))
      .catch(err => console.error(err));
  }
}
</code>```

Useful links
https://github.com/chrisbianca/react-native-cameraroll#install

Title: How to link RCTCameraRoll for Android

Body:
I came thru the same question. The fact is

We have to create a project using React Init method then it automatically created Android and IOS folder.

Later you can install and link the Native libraries automatically. Here are the code snippets.

react-native init Cameraroll

npm i react-native-camera --save

react-native link

export default class App extends Component<{}> {
  render() {
    return (
       <View style={styles.container}>
        <Camera
          ref={(cam) => {
            this.camera = cam;
          }}
          style={styles.preview}
          aspect={Camera.constants.Aspect.fill}>
          <Text style={styles.capture} onPress={this.takePicture.bind(this)}>[CAPTURE]</Text>
        </Camera>
      </View>
    );
  }
  takePicture() {
    const options = {};
    //options.location = ...
    this.camera.capture({metadata: options})
      .then((data) => console.log(data))
      .catch(err => console.error(err));
  }
}

Useful links
https://github.com/chrisbianca/react-native-cameraroll#install


问:
App Getting Crash while Continuous open and close Activity between 2 activities
My Android App having multiple activities, now my problem is unable to findable.

A Activity have one recyclerView it get data from local database, If I click the items it will open B Activity, this same flow continuously then app getting crash(like open B Activity come back to A Activity and open again B activity- up to 5 to 6 time do same action then app getting crash)

The Crash message is related to SQLite DATABASE but unable to find where it occurs. Please help me... already spend more time for this...

Note: open DB on Oncreate and Close DB on OnDestroy in both activities

Error Message

```<code>E/SQLiteQuery: exception: unable to open database file (code 14); query: SELECT DISTINCT * FROM parameters WHERE inspection_no LIKE '%TEST-123%'
E/InputChannel-JNI: Error 24 dup channel fd 1023.
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.testapp.testprocess, PID: 13078
                  java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
                      at android.view.InputChannel.nativeReadFromParcel(Native Method)
                      at android.view.InputChannel.readFromParcel(InputChannel.java:148)
                      at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:841)
                      at android.view.ViewRootImpl.setView(ViewRootImpl.java:640)
                      at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
                      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
                      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3518)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2733)
                      at android.app.ActivityThread.-wrap12(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6121)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
</code>```

答:
This error usually occurs when you forget to close the database.
try closing the cursor and database after the transaction.</p>

Body:
My Android App having multiple activities, now my problem is unable to findable.

A Activity have one recyclerView it get data from local database, If I click the items it will open B Activity, this same flow continuously then app getting crash(like open B Activity come back to A Activity and open again B activity- up to 5 to 6 time do same action then app getting crash)

The Crash message is related to SQLite DATABASE but unable to find where it occurs. Please help me... already spend more time for this...

Note: open DB on Oncreate and Close DB on OnDestroy in both activities

Error Message

E/SQLiteQuery: exception: unable to open database file (code 14); query: SELECT DISTINCT * FROM parameters WHERE inspection_no LIKE '%TEST-123%'
E/InputChannel-JNI: Error 24 dup channel fd 1023.
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.testapp.testprocess, PID: 13078
                  java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
                      at android.view.InputChannel.nativeReadFromParcel(Native Method)
                      at android.view.InputChannel.readFromParcel(InputChannel.java:148)
                      at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:841)
                      at android.view.ViewRootImpl.setView(ViewRootImpl.java:640)
                      at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:342)
                      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
                      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3518)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2733)
                      at android.app.ActivityThread.-wrap12(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6121)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)


问:
Unknown column '$data' in 'field list' in codeigniter
Im trying to insert data in my database and this error appears:

Error Number: 1054

Unknown column '$data' in 'field list'

INSERT INTO crud ($data) VALUES ('')

Filename: C:/AppServ/www/parcial/system/database/DB_driver.php

Line Number: 691

This is my form:

```<code> <?php echo form_open('home/save',['class'=>'form-horizontal']); ?>
  <fieldset>

      <label for="exampleInputEmail1">Titulo</label>
    <?php echo form_input(['name'=>'id','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('')]); ?>

      <?php echo form_input(['name'=>'titulo','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('titulo')]); ?>

      <label for="exampleInputEmail1">Resumen</label>
  <?php echo form_input(['name'=>'resumen','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('resumen')]); ?>

      <label for="exampleInputEmail1">Ano</label>
    <?php echo form_input(['name'=>'ano','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('ano')]); ?>

          <label for="exampleInputEmail1">Pais</label>
      <?php echo form_input(['name'=>'pais','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('pais')]); ?>
      <label for="exampleInputEmail1">Protagonista</label>
        <?php echo form_input(['name'=>'progatonista','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('protagonista')]); ?>
  <br>

  <?php echo form_close(); ?>
<?php echo form_submit(['value'=>'Submit', 'class'=>'btn btn-primary']); ?>
</code>```

This is my function to save records:

```<code>  public function save() {

    $data = $this->input->post();
$this->load->model('Crudmodel');
if($this->Crudmodel->saveRecords($data)) {

}
}
</code>```

this is my code to insert:

```<code>public function saveRecords($data) {

  return  $this->db->insert('crud','$data');

}
</code>```

What can i do? please help me

答:
in your controller </p>

```<code>public function save() {

    $data = $this->input->post();
$this->load->model('Crudmodel');

$data = array (
            'database-fieldname' => $this->input->post('input-fieldname'),
            );

if($this->Crudmodel->saveRecords($data)) {

  }
}
</code>```

Body:
Im trying to insert data in my database and this error appears:

Error Number: 1054

Unknown column '$data' in 'field list'

INSERT INTO crud ($data) VALUES ('')

Filename: C:/AppServ/www/parcial/system/database/DB_driver.php

Line Number: 691

This is my form:

 <?php echo form_open('home/save',['class'=>'form-horizontal']); ?>
  <fieldset>

      Titulo
    <?php echo form_input(['name'=>'id','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('')]); ?>

      <?php echo form_input(['name'=>'titulo','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('titulo')]); ?>

      Resumen
  <?php echo form_input(['name'=>'resumen','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('resumen')]); ?>

      Ano
    <?php echo form_input(['name'=>'ano','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('ano')]); ?>

          Pais
      <?php echo form_input(['name'=>'pais','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('pais')]); ?>
      Protagonista
        <?php echo form_input(['name'=>'progatonista','class'=>'form-control','placeholder'=>'Titulo', 'value'=>set_value('protagonista')]); ?>

  <?php echo form_close(); ?>
<?php echo form_submit(['value'=>'Submit', 'class'=>'btn btn-primary']); ?>

This is my function to save records:

  public function save() {

    $data = $this->input->post();
$this->load->model('Crudmodel');
if($this->Crudmodel->saveRecords($data)) {

}
}

this is my code to insert:

public function saveRecords($data) {

  return  $this->db->insert('crud','$data');

}

What can i do? please help me

Body:
in your controller

public function save() {

    $data = $this->input->post();
$this->load->model('Crudmodel');

$data = array (
            'database-fieldname' => $this->input->post('input-fieldname'),
            );

if($this->Crudmodel->saveRecords($data)) {

  }
}


问:
delete from three tables
Please Anyone there

if any conditions or query

i need to delete the details are matching accroding to
Table adl_auth_user A

```<code>id      user_id     type_id     type_value
66428     1919          1           97
</code>```

table user_details B

```<code>user_id     first_name      last_nam
1919        Rins TE       Kola
</code>```

table adl_user C

```<code>id         email                   password
1919    email@DOMAIN.COM         SOME PASSWORD
</code>```

i want delete from these three

```<code>tables table1. user_id = table2.
> user_id and table1. user_id = table3.id
</code>```

and group by

table1.type_id,table1.type_value

答:
try this . delete the records from table according to the table dependencies.</p>

```<code>i think grouping is not required as you are trying to delete the records

DELETE FROM adl_auth_user
from adl_auth_user  A
INNER JOIN user_details  B ON a.user_id=B.user_id
INNER JOIN adl_user  C ON b.user_id=c.id
WHERE A.user_id =1919 AND A.type_id =1

DELETE FROM user_details
FROM user_details B
INNER JOIN adl_user C ON b.user_id=c.id
WHERE B.user_id =1919

DELETE FROM adl_user
WHERE adl_user .id =1919
</code>```

Title: delete from three tables

Body:
Please Anyone there

if any conditions or query

i need to delete the details are matching accroding to
Table adl_auth_user A

id      user_id     type_id     type_value
66428     1919          1           97

table user_details B

user_id     first_name      last_nam
1919        Rins TE       Kola

table adl_user C

id         email                   password
1919    email@DOMAIN.COM         SOME PASSWORD

i want delete from these three

tables table1. user_id = table2.
> user_id and table1. user_id = table3.id

and group by

table1.type_id,table1.type_value

Body:
try this . delete the records from table according to the table dependencies.

i think grouping is not required as you are trying to delete the records

DELETE FROM adl_auth_user
from adl_auth_user  A
INNER JOIN user_details  B ON a.user_id=B.user_id
INNER JOIN adl_user  C ON b.user_id=c.id
WHERE A.user_id =1919 AND A.type_id =1

DELETE FROM user_details
FROM user_details B
INNER JOIN adl_user C ON b.user_id=c.id
WHERE B.user_id =1919

DELETE FROM adl_user
WHERE adl_user .id =1919


问:
Check javascript compatibility with Internet explorer
I have some javascript code that does not run in IE 11. Is there a quick way to check where the incompatibly is other than going through the code line by line to see what commands and statements are supported by that version of Internet Explorer?</p>

答: Solved the issue by using JSHint (installed as package on Sublime Text 3) with option "esversion" set to 3 (compatibility with ECMAScript 3).  This got me 90% of the way there and I did the rest manually.</p>


问:
Use Connect or pass data as props to children
I am new to react and redux. I have a scenario where there are nested components like this.

A > B > C > D

There is a property used in A component and it will be used in D component. So, I have two approaches:

Get state from redux store in component A and then pass it along as props to all it's child components even though it will be used only in D component.

I should connect to redux store in component D and fetch that property from there.

What is the correct approach?

答:
I would suggest if you are already using redux in your app then set the property in the redux store and fetch it in the component D.

But if the work flow is really simple and all the data is fetched from a single source per view, you can avoid redux as it is for complex state management.


问:
How to generate .angular-cli.json file in Angular Cli?
I have installed Angular CLI package separately using npm:

```<code>npm install --save-dev @angular/cli@latest
</code>```

When I try to use commands cli I get an error:

```<code>Unable to find any apps in `.angular-cli.json`.
</code>```

How to generate .angular-cli.json for current project?

答: You are just outside the directory which you are working. Enter into the directory which your project is there and run command ng g c name.

Body:
I have installed Angular CLI package separately using npm:

npm install --save-dev @angular/cli@latest

When I try to use commands cli I get an error:

Unable to find any apps in `.angular-cli.json`.

How to generate .angular-cli.json for current project?


问:
How to iterate a list within a list into columns?
Suppose I have a list of numbers divided into 3 lists:

```<code>numbers = [[0,1,2], [3,4,5], [6,7,8]]
</code>```

And I want to iterate through each 3 lists and divide them into columns:

```<code>0  1  2
3  4  5
6  7  8
</code>```

How would I go about doing this?
So far, I can only print out 1 column:

```<code>for column in numbers[0:3]:
    column1 = column[0]
    print( column1 )
</code>```

答:
This works for me in python 2.7</p>

```<code>i=0
for column in numbers[0:3]:
     print column[i],column[i+1],column[i+2]
</code>```

Body:
Suppose I have a list of numbers divided into 3 lists:

numbers = [[0,1,2], [3,4,5], [6,7,8]]

And I want to iterate through each 3 lists and divide them into columns:

0  1  2
3  4  5
6  7  8

How would I go about doing this?
So far, I can only print out 1 column:

for column in numbers[0:3]:
    column1 = column[0]
    print( column1 )

Body:
This works for me in python 2.7

i=0
for column in numbers[0:3]:
     print column[i],column[i+1],column[i+2]