问:
retrieve data from table and that data use to login
I want to create a login form to log system in php. But I can't do it, below I mentioned my code. I have coded registration form also. It works successfully, but the login form does not works properly. The registration form code is included in the index page. But the login code is include in login.php page.

Help me to solve this problem.

```<code>    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
 aria-hidden="true">
<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                ×</button>
            <h4 style="text-align: center" class="modal-title" id="myModalLabel">
                Login & Registration</a></h4>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-md-8" style="border-right: 1px dotted #C2C2C2;padding-right: 30px;">
                    <!-- Nav tabs -->
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#Login" data-toggle="tab">Login</a></li>
                        <li><a href="#Registration" data-toggle="tab">Registration</a></li>
                    </ul>
                    <!-- Tab panes -->
                    <div class="tab-content">
                        <div class="tab-pane active" id="Login">
                            <form  class="form-horizontal" actoin="login.php" method="post" >
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        Username</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="username2" id="username2" placeholder="Username" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label  class="col-sm-2 control-label">
                                        Password</label>
                                    <div class="col-sm-10">
                                        <input type="password" class="form-control" name="pwd2" id="pwd2" placeholder="Password" />
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        User Type</label>
                                    <div class="col-sm-10">
                                        <select class="form-control" name="utype" id="utype">
                                            <option selected disabled>User Type</option>
                                            <option value="Admin">Admin</option>
                                            <option value="Student">Student</option>
                                            <option value="Company">Company</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-sm-2">
                                    </div>
                                    <div class="col-sm-10">
                                        <input type="submit" class="btn btn-primary btn-sm" name="buttonsubmit" id="buttonsubmit" value="Login">
                                        <a href="">Forgot your password?</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="tab-pane" id="Registration">
                            <form  class="form-horizontal" action="index.php" method="post">
                                <div class="form-group">
                                    <label  class="col-sm-2 control-label">
                                        Title</label>
                                    <div class="col-sm-10">
                                        <div class="row">
                                            <div class="col-md-3">
                                                <select class="form-control" id="uutypex" name="uutype">
                                                    <option>Mr.</option>
                                                    <option>Ms.</option>
                                                    <option>Mrs.</option>
                                                </select>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        Name</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="name" id="name" placeholder="Name" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        User Name</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="username1" id="username1" placeholder="User Name" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        Password</label>
                                    <div class="col-sm-10">
                                        <input class="form-control" name="pwd" id="pwd" type="password" placeholder="Password" />
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        Birth Date
                                    </label>
                                    <div class="col-sm-10">
                                        <input class="form-control" name="bdate" id="bdate" type="date">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        Email</label>
                                    <div class="col-sm-10">
                                        <input type="email" class="form-control" name="email" id="email" placeholder="User Name" />
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        Mobile
                                    </label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="mobile" id="mobile" placeholder="Mobile" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        University</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="uni" id="uni" placeholder="University" />
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        User Type
                                    </label>
                                    <div class="col-sm-10">
                                        <select class="form-control" name="type" id="type">
                                            <option selected disabled>User Type</option>
                                            <option value="Admin">Admin</option>
                                            <option value="Student">Student</option>
                                            <option value="Company">Company</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        GPA</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="gpa" id="gpa" placeholder="GPA" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">
                                        Address</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="address" id="address" placeholder="Address" />
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-sm-2">
                                    </div>
                                    <div class="col-sm-10">
                                        <input type="submit" class="btn btn-primary btn-sm" name="buttonregister" id="buttonregister" value="Submit and Save">

                                        <button type="button" class="btn btn-default btn-sm">
                                            Cancel
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div id="OR" class="hidden-xs">
                        OR</div>
                </div>
                <div class="col-md-4">
                    <div class="row text-center sign-with">
                        <div class="col-md-12">
                            <h3>
                                Sign in with
                            </h3>
                        </div>
                        <div class="col-md-12">
                            <div class="btn-group btn-group-justified">
                                <a href="#" class="btn btn-primary">Facebook</a> <a href="#" class="btn btn-danger">
                                Google
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</code>```

php code

```<code>    <?php
$conn=mysqli_connect("localhost","root","","internship");

if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

if(isset($_POST['buttonsubmit'])){

$username=$_POST['username2'];
$password=$_POST['pwd2'];
$type=$_POST['utype'];

$result=mysqli_query($conn,'select * from registration where username="'.$username.'" and password="'.$password.'" and usertype="'.$type.'"');

if(mysqli_num_rows($result)==1 && $type=="Student"){
    header('Location: student.php');
}

else
    ?>
    <script>  alert("Account invalid!!!! Enter valid Username Password and Usertype")</script>
    <?php
}

?>
</code>```

答:
Can you post the error that you are getting...?
Plus Your code is not secure. You should use php's hash functions to match passwords and use must use PDO to avoid sql injection.</p>

Body:
I want to create a login form to log system in php. But I can't do it, below I mentioned my code. I have coded registration form also. It works successfully, but the login form does not works properly. The registration form code is included in the index page. But the login code is include in login.php page.

Help me to solve this problem.

            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                ×</button>

                Login & Registration

Login

Registration

                            <form  class="form-horizontal" actoin="login.php" method="post" >

                                        Username

                                        <input type="text" class="form-control" name="username2" id="username2" placeholder="Username" />

                                        Password

                                        <input type="password" class="form-control" name="pwd2" id="pwd2" placeholder="Password" />

                                        User Type

                                        <select class="form-control" name="utype" id="utype">
                                            <option selected disabled>User Type</option>
                                            <option value="Admin">Admin</option>
                                            <option value="Student">Student</option>
                                            <option value="Company">Company</option>
                                        </select>

                                        <input type="submit" class="btn btn-primary btn-sm" name="buttonsubmit" id="buttonsubmit" value="Login">
                                        Forgot your password?

                            </form>

                            <form  class="form-horizontal" action="index.php" method="post">

                                        Title

                                                <select class="form-control" id="uutypex" name="uutype">
                                                    <option>Mr.</option>
                                                    <option>Ms.</option>
                                                    <option>Mrs.</option>
                                                </select>

                                        Name

                                        <input type="text" class="form-control" name="name" id="name" placeholder="Name" />

                                        User Name

                                        <input type="text" class="form-control" name="username1" id="username1" placeholder="User Name" />

                                        Password

                                        <input class="form-control" name="pwd" id="pwd" type="password" placeholder="Password" />

                                        Birth Date

                                        <input class="form-control" name="bdate" id="bdate" type="date">

                                        Email

                                        <input type="email" class="form-control" name="email" id="email" placeholder="User Name" />

                                        Mobile

                                        <input type="text" class="form-control" name="mobile" id="mobile" placeholder="Mobile" />

                                        University

                                        <input type="text" class="form-control" name="uni" id="uni" placeholder="University" />

                                        User Type

                                        <select class="form-control" name="type" id="type">
                                            <option selected disabled>User Type</option>
                                            <option value="Admin">Admin</option>
                                            <option value="Student">Student</option>
                                            <option value="Company">Company</option>
                                        </select>

                                        GPA

                                        <input type="text" class="form-control" name="gpa" id="gpa" placeholder="GPA" />

                                        Address

                                        <input type="text" class="form-control" name="address" id="address" placeholder="Address" />

                                        <input type="submit" class="btn btn-primary btn-sm" name="buttonregister" id="buttonregister" value="Submit and Save">

                                        <button type="button" class="btn btn-default btn-sm">
                                            Cancel
                                        </button>

                            </form>

                        OR

                                Sign in with

                                Facebook
                                Google

php code

    <?php
$conn=mysqli_connect("localhost","root","","internship");

if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

if(isset($_POST['buttonsubmit'])){

$username=$_POST['username2'];
$password=$_POST['pwd2'];
$type=$_POST['utype'];

$result=mysqli_query($conn,'select * from registration where username="'.$username.'" and password="'.$password.'" and usertype="'.$type.'"');

if(mysqli_num_rows($result)==1 && $type=="Student"){
    header('Location: student.php');
}

else
    ?>

    <?php
}

?>


来源: stackexchange

问:
Separating 2 div equally
Image 1

I want to get rid of the padding-left of DIV 1 and padding-right of DIV 2 in order to separate the 2 divs in the middle equall. I want to . Please take note that I am not using Bootstrap. (Please See Image 1)

Here is my HTML code:

```<code><div class="row">
        <div class="col-50">
            <div class="card-box">
                <h4 class="header-title">View Data</h4>
                <div class="col-100">
                    <div class="row">
                        <div class="col-50">
                            <div class="btn-group">
                                <a class="btn-excel" href="#"><span>Excel</span></a>
                                <a class="btn-pdf" href="#"><span>PDF</span></a>
                            </div>
                        </div>
                        <div class="col-50">
                            <form class="pull-right">
                            <input type="text" placeholder="Search..." class="form-control">
                            <span><i class="fa fa-search"></i></span>
                        </form>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-100">

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-50">
            <div class="card-box">
                <h4 class="header-title">View Data</h4>
                <div class="table-container">
                    <div class="row">
                        <div class="col-50">
                            <div class="btn-group">
                                <a class="btn-excel" href="#"><span>Excel</span></a>
                                <a class="btn-pdf" href="#"><span>PDF</span></a>
                            </div>
                        </div>
                        <div class="col-50">
                            <form class="pull-right">
                            <input type="text" placeholder="Search..." class="form-control">
                            <span><i class="fa fa-search"></i></span>
                        </form>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-100">

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</code>```

And here is my CSS Code:

```<code>*, *::before, *::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
</code>```

}

```<code>.row::after {
content: "";
display: table;
clear: both;
</code>```

}

```<code>.row {
margin-left: -0.75rem !important;
margin-right: -0.75rem !important;
</code>```

}

```<code>.col-50 {
width: 50%;
float: left;
position: relative;
min-height: 1px;
padding-left: 0.75rem;
padding-right: 0.75rem;
</code>```

}

```<code>.card-box {
padding: 5px 20px 20px 20px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-border-radius: 5px;
background-clip: padding-box;
margin-top: 15px;
margin-bottom: 20px;
background-color: #ffffff;
box-shadow: 0 0px 24px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);
display: block;
min-height: 0.01%;
overflow-x: auto;
</code>```

}

答:
Use first-of-type and last-of-type selectors to select the first and last columns and then, remove the left padding of the first column and right padding of the last column like this:

```<code>.col-50:first-of-type {
  padding-left: 0rem;
}

.col-50:last-of-type {
  padding-right: 0rem;
}
</code>```

The class .col-50 already has padding-left: 0.75rem; and padding-right: 0.75rem; which will add equal spacing between the columns, so no need to edit this.

```<code>.col-50 {
  width: 50%;
  float: left;
  position: relative;
  min-height: 1px;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
</code>```

Here's the working codepen example: http://codepen.io/anon/pen/evxyNb

ContentLicense: CC BY-SA 3.0

Title: Separating 2 div equally

Body:
Image 1

I want to get rid of the padding-left of DIV 1 and padding-right of DIV 2 in order to separate the 2 divs in the middle equall. I want to . Please take note that I am not using Bootstrap. (Please See Image 1)

Here is my HTML code:

View Data

                                Excel
                                PDF

                            <form class="pull-right">
                            <input type="text" placeholder="Search..." class="form-control">

                        </form>

View Data

                                Excel
                                PDF

                            <form class="pull-right">
                            <input type="text" placeholder="Search..." class="form-control">

                        </form>

And here is my CSS Code:

*, *::before, *::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;

}

.row::after {
content: "";
display: table;
clear: both;

}

.row {
margin-left: -0.75rem !important;
margin-right: -0.75rem !important;

}

.col-50 {
width: 50%;
float: left;
position: relative;
min-height: 1px;
padding-left: 0.75rem;
padding-right: 0.75rem;

}

.card-box {
padding: 5px 20px 20px 20px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-border-radius: 5px;
background-clip: padding-box;
margin-top: 15px;
margin-bottom: 20px;
background-color: #ffffff;
box-shadow: 0 0px 24px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);
display: block;
min-height: 0.01%;
overflow-x: auto;

}

Body:
Use first-of-type and last-of-type selectors to select the first and last columns and then, remove the left padding of the first column and right padding of the last column like this:

.col-50:first-of-type {
  padding-left: 0rem;
}

.col-50:last-of-type {
  padding-right: 0rem;
}

The class .col-50 already has padding-left: 0.75rem; and padding-right: 0.75rem; which will add equal spacing between the columns, so no need to edit this.

.col-50 {
  width: 50%;
  float: left;
  position: relative;
  min-height: 1px;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

Here's the working codepen example: http://codepen.io/anon/pen/evxyNb


问:
Excel table to Access query connection, [Microsoft][ODBC Microsoft Access Drive] too few parameters. expected 1
I'm trying to create a table in Excel, which takes data from Access Query. I'm unable to find this query listed under Data->From Access. I'm using Data->From Other Sources -> From Data connection Wizard -> ODBC DSN. On final step it throws error [Microsoft][ODBC Microsoft Access Drive]  too few parameters. expected 1.

I will not post full query at this moment, it is long

I will post subquery part (with some formatting) , that already throws this error. Can someone take a look and pinpoint where is the problem.

All queries I have work properly in Access. But I need the results export to Excel, as whole reporting VBA tool is there. (I know I can make SELECT INTO and create table, but it is not as elegant and simple to update) Thank you all for your time. Have a nice day

```<code>SELECT
Employees.PersNo,
Employees.Employee_name,
Employees.Reporting_Month,
Employees.Gender_Key,
Employees.Start_Date,
Employees.Business_Unit,
Employees.Position_ID,
Employees.Position,
Employees.Local_Band,
Employees.PS_Group,
Employees.Wage_Amount,
val(Employees.Bonus) AS [Bonus_%],
val([Employees].[Commissions_(%)]) AS [Commisions_%],
Employees.Wage_type, Employees.Wkhrs,
Q1.Business_Unit,
Q1.Position_ID,
Q1.Position,
Q1.Local_Band,
Q1.PS_Group,
Q1.Wage_Amount,
[Q1].[Bonus_%],
[Q1].[Commisions_%],
Employees.Wage_type,
Employees.Wkhrs,
Employees.Evid_Status

FROM Employees LEFT JOIN (SELECT
Dateadd("m",1,[Employees.Reporting_Month]) AS Reporting_Month,
Employees.PersNo,
Employees.Local_Band,
Employees.PS_Group,
Employees.Wage_Amount,
val(Employees.Bonus) AS [Bonus_%],
val([Employees].[Commissions_(%)]) AS [Commisions_%],
Employees.Wage_type, Employees.Wkhrs,
Employees.Business_Unit,
Employees.Position_ID,
Employees.Position,
Employees.Evid_Status
FROM Employees WHERE Employees.Evid_Status=1 )  AS Q1
ON (Employees.Reporting_Month = [Q1].[Reporting_Month]) AND (Employees.PersNo = [Q1].[PersNo])
WHERE Employees.Evid_Status=1;
</code>```

答:
You can use Excel to query Access, like you see in the link below.

http://translate.google.pl/translate?js=n&prev=_t&hl=pl&ie=UTF-8&layout=2&eotf=1&sl=pl&tl=en&u=http%3A%2F%2Fafin.net%2FKsiazkaSQLwExcelu%2FGraficznyEdytorZapytanSqlNaPrzykladzieMsQuery.htm

Also, consider using a parameter query to do the export from Access to Excel.

```<code>Dim dbs As DAO.Database
Dim qdfTemp As DAO.QueryDef
Dim strSQL As String, strQDF As String
Set dbs = CurrentDb

' Replace NameOfTableOrQuery with the real name of the table or query,
' replace NameOfForm with the real name of the form, and replace
' ADateControlOnForm and AnotherDateControlOnForm with the real names
' of the controls on that form
strSQL = "SELECT NameOfTableOrQuery.* FROM NameOfTableOrQuery " & _
      "WHERE NameOfTableOrQuery.FieldName >= " & _
      Format(Forms!NameOfForm!ADateControlOnForm.Value,"\#mm\/dd\/yyyy\#") & _
      " And NameOfTableOrQuery.FieldName <=" & _
      Format(Forms!NameOfForm!AnotherDateControlOnForm.Value,"\#mm\/dd\/yyyy\#") & "';"

strQDF = "_TempQuery_"
Set qdfTemp = dbs.CreateQueryDef(strQDF, strSQL)
qdfTemp.Close
Set qdfTemp = Nothing

' Replace C:\MyFolderName\MyFileName.xls with the real path and filename for the
' EXCEL file that is to contain the exported data
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
      strQDF,"C:\MyFolderName\MyFileName.xls"

dbs.QueryDefs.Delete strQDF
dbs.Close
Set dbs = Nothing
</code>```

Or...write data from a record set in Access to Excel.

```<code>Dim lngColumn As Long
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim blnEXCEL As Boolean, blnHeaderRow As Boolean

blnEXCEL = False

' Replace True with False if you do not want the first row of
' the worksheet to be a header row (the names of the fields
' from the recordset)
blnHeaderRow = True

' Establish an EXCEL application object
On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
      Set xlx = CreateObject("Excel.Application")
      blnEXCEL = True
End If
Err.Clear
On Error GoTo 0

' Change True to False if you do not want the workbook to be
' visible when the code is running
xlx.Visible = True

' Replace C:\Filename.xls with the actual path and filename
' of the EXCEL file into which you will write the data
Set xlw = xlx.Workbooks.Open("C:\Filename.xls")

' Replace WorksheetName with the actual name of the worksheet
' in the EXCEL file
' (note that the worksheet must already be in the EXCEL file)
Set xls = xlw.Worksheets("WorksheetName")

' Replace A1 with the cell reference into which the first data value
' is to be written
Set xlc = xls.Range("A1") ' this is the first cell into which data go

Set dbs = CurrentDb()

' Replace QueryOrTableName with the real name of the table or query
' whose data are to be written into the worksheet
Set rst = dbs.OpenRecordset("QueryOrTableName", dbOpenDynaset, dbReadOnly)

If rst.EOF = False And rst.BOF = False Then

      rst.MoveFirst

      If blnHeaderRow = True Then
            For lngColumn = 0 To rst.Fields.Count - 1
                  xlc.Offset(0, lngColumn).Value = rst.Fields(lngColumn).Name
            Next lngColumn
            Set xlc = xlc.Offset(1,0)
      End If

      ' write data to worksheet
      Do While rst.EOF = False
            For lngColumn = 0 To rst.Fields.Count - 1
                  xlc.Offset(0, lngColumn).Value = rst.Fields(lngColumn).Value
            Next lngColumn
            rst.MoveNext
            Set xlc = xlc.Offset(1,0)
      Loop

End If

rst.Close
Set rst = Nothing

dbs.Close
Set dbs = Nothing

' Close the EXCEL file while saving the file, and clean up the EXCEL objects
Set xlc = Nothing
Set xls = Nothing
xlw.Close True   ' close the EXCEL file and save the new data
Set xlw = Nothing
If blnEXCEL = True Then xlx.Quit
Set xlx = Nothing
</code>```

Or, simply import the data from Access to Excel.

```<code>Sub ADOImportFromAccessTable(DBFullName As String, _
    TableName As String, TargetRange As Range)
' Example: ADOImportFromAccessTable "C:\FolderName\DataBaseName.mdb", _
    "TableName", Range("C1")
Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
    Set TargetRange = TargetRange.Cells(1, 1)
    ' open the database
    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
        DBFullName & ";"
    Set rs = New ADODB.Recordset
    With rs
        ' open the recordset
        .Open TableName, cn, adOpenStatic, adLockOptimistic, adCmdTable
        ' all records
        '.Open "SELECT * FROM " & TableName & _
            " WHERE [FieldName] = 'MyCriteria'", cn, , , adCmdText
        ' filter records

        RS2WS rs, TargetRange ' write data from the recordset to the worksheet

'        ' optional approach for Excel 2000 or later (RS2WS is not necessary)
'        For intColIndex = 0 To rs.Fields.Count - 1 ' the field names
'            TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name
'        Next
'        TargetRange.Offset(1, 0).CopyFromRecordset rs ' the recordset data

    End With
    rs.Close
    Set rs = Nothing
    cn.Close
    Set cn = Nothing
End Sub
</code>```

Body:
I'm trying to create a table in Excel, which takes data from Access Query. I'm unable to find this query listed under Data->From Access. I'm using Data->From Other Sources -> From Data connection Wizard -> ODBC DSN. On final step it throws error [Microsoft][ODBC Microsoft Access Drive]  too few parameters. expected 1.

I will not post full query at this moment, it is long

I will post subquery part (with some formatting) , that already throws this error. Can someone take a look and pinpoint where is the problem.

All queries I have work properly in Access. But I need the results export to Excel, as whole reporting VBA tool is there. (I know I can make SELECT INTO and create table, but it is not as elegant and simple to update) Thank you all for your time. Have a nice day

SELECT
Employees.PersNo,
Employees.Employee_name,
Employees.Reporting_Month,
Employees.Gender_Key,
Employees.Start_Date,
Employees.Business_Unit,
Employees.Position_ID,
Employees.Position,
Employees.Local_Band,
Employees.PS_Group,
Employees.Wage_Amount,
val(Employees.Bonus) AS [Bonus_%],
val([Employees].[Commissions_(%)]) AS [Commisions_%],
Employees.Wage_type, Employees.Wkhrs,
Q1.Business_Unit,
Q1.Position_ID,
Q1.Position,
Q1.Local_Band,
Q1.PS_Group,
Q1.Wage_Amount,
[Q1].[Bonus_%],
[Q1].[Commisions_%],
Employees.Wage_type,
Employees.Wkhrs,
Employees.Evid_Status

FROM Employees LEFT JOIN (SELECT
Dateadd("m",1,[Employees.Reporting_Month]) AS Reporting_Month,
Employees.PersNo,
Employees.Local_Band,
Employees.PS_Group,
Employees.Wage_Amount,
val(Employees.Bonus) AS [Bonus_%],
val([Employees].[Commissions_(%)]) AS [Commisions_%],
Employees.Wage_type, Employees.Wkhrs,
Employees.Business_Unit,
Employees.Position_ID,
Employees.Position,
Employees.Evid_Status
FROM Employees WHERE Employees.Evid_Status=1 )  AS Q1
ON (Employees.Reporting_Month = [Q1].[Reporting_Month]) AND (Employees.PersNo = [Q1].[PersNo])
WHERE Employees.Evid_Status=1;

Body:
You can use Excel to query Access, like you see in the link below.

http://translate.google.pl/translate?js=n&prev=_t&hl=pl&ie=UTF-8&layout=2&eotf=1&sl=pl&tl=en&u=http%3A%2F%2Fafin.net%2FKsiazkaSQLwExcelu%2FGraficznyEdytorZapytanSqlNaPrzykladzieMsQuery.htm

Also, consider using a parameter query to do the export from Access to Excel.

Dim dbs As DAO.Database
Dim qdfTemp As DAO.QueryDef
Dim strSQL As String, strQDF As String
Set dbs = CurrentDb

' Replace NameOfTableOrQuery with the real name of the table or query,
' replace NameOfForm with the real name of the form, and replace
' ADateControlOnForm and AnotherDateControlOnForm with the real names
' of the controls on that form
strSQL = "SELECT NameOfTableOrQuery.* FROM NameOfTableOrQuery " & _
      "WHERE NameOfTableOrQuery.FieldName >= " & _
      Format(Forms!NameOfForm!ADateControlOnForm.Value,"\#mm\/dd\/yyyy\#") & _
      " And NameOfTableOrQuery.FieldName <=" & _
      Format(Forms!NameOfForm!AnotherDateControlOnForm.Value,"\#mm\/dd\/yyyy\#") & "';"

strQDF = "_TempQuery_"
Set qdfTemp = dbs.CreateQueryDef(strQDF, strSQL)
qdfTemp.Close
Set qdfTemp = Nothing

' Replace C:\MyFolderName\MyFileName.xls with the real path and filename for the
' EXCEL file that is to contain the exported data
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
      strQDF,"C:\MyFolderName\MyFileName.xls"

dbs.QueryDefs.Delete strQDF
dbs.Close
Set dbs = Nothing

Or...write data from a record set in Access to Excel.

Dim lngColumn As Long
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim blnEXCEL As Boolean, blnHeaderRow As Boolean

blnEXCEL = False

' Replace True with False if you do not want the first row of
' the worksheet to be a header row (the names of the fields
' from the recordset)
blnHeaderRow = True

' Establish an EXCEL application object
On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
      Set xlx = CreateObject("Excel.Application")
      blnEXCEL = True
End If
Err.Clear
On Error GoTo 0

' Change True to False if you do not want the workbook to be
' visible when the code is running
xlx.Visible = True

' Replace C:\Filename.xls with the actual path and filename
' of the EXCEL file into which you will write the data
Set xlw = xlx.Workbooks.Open("C:\Filename.xls")

' Replace WorksheetName with the actual name of the worksheet
' in the EXCEL file
' (note that the worksheet must already be in the EXCEL file)
Set xls = xlw.Worksheets("WorksheetName")

' Replace A1 with the cell reference into which the first data value
' is to be written
Set xlc = xls.Range("A1") ' this is the first cell into which data go

Set dbs = CurrentDb()

' Replace QueryOrTableName with the real name of the table or query
' whose data are to be written into the worksheet
Set rst = dbs.OpenRecordset("QueryOrTableName", dbOpenDynaset, dbReadOnly)

If rst.EOF = False And rst.BOF = False Then

      rst.MoveFirst

      If blnHeaderRow = True Then
            For lngColumn = 0 To rst.Fields.Count - 1
                  xlc.Offset(0, lngColumn).Value = rst.Fields(lngColumn).Name
            Next lngColumn
            Set xlc = xlc.Offset(1,0)
      End If

      ' write data to worksheet
      Do While rst.EOF = False
            For lngColumn = 0 To rst.Fields.Count - 1
                  xlc.Offset(0, lngColumn).Value = rst.Fields(lngColumn).Value
            Next lngColumn
            rst.MoveNext
            Set xlc = xlc.Offset(1,0)
      Loop

End If

rst.Close
Set rst = Nothing

dbs.Close
Set dbs = Nothing

' Close the EXCEL file while saving the file, and clean up the EXCEL objects
Set xlc = Nothing
Set xls = Nothing
xlw.Close True   ' close the EXCEL file and save the new data
Set xlw = Nothing
If blnEXCEL = True Then xlx.Quit
Set xlx = Nothing

Or, simply import the data from Access to Excel.

Sub ADOImportFromAccessTable(DBFullName As String, _
    TableName As String, TargetRange As Range)
' Example: ADOImportFromAccessTable "C:\FolderName\DataBaseName.mdb", _
    "TableName", Range("C1")
Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
    Set TargetRange = TargetRange.Cells(1, 1)
    ' open the database
    Set cn = New ADODB.Connection
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
        DBFullName & ";"
    Set rs = New ADODB.Recordset
    With rs
        ' open the recordset
        .Open TableName, cn, adOpenStatic, adLockOptimistic, adCmdTable
        ' all records
        '.Open "SELECT * FROM " & TableName & _
            " WHERE [FieldName] = 'MyCriteria'", cn, , , adCmdText
        ' filter records

        RS2WS rs, TargetRange ' write data from the recordset to the worksheet

'        ' optional approach for Excel 2000 or later (RS2WS is not necessary)
'        For intColIndex = 0 To rs.Fields.Count - 1 ' the field names
'            TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name
'        Next
'        TargetRange.Offset(1, 0).CopyFromRecordset rs ' the recordset data

    End With
    rs.Close
    Set rs = Nothing
    cn.Close
    Set cn = Nothing
End Sub


问:
Let the user pick a connection to SQL Server
I want to create a Windows form that lets the user choose a SQL Server instance to connect to and run a query on that database that should be there.

Is this possible? How do I create a dynamic SQL connection?

答:
To create a connection string you can use SqlConnectionStringBuilder, after that you can pass created connection string into SqlConnection:</p>

```<code>SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder
{
    UserID = "Some User ID",
    Password = "Some Database Password",
    InitialCatalog = "Some Initial Catalog",
    DataSource = "Some Data Source"
};

string connectionString = builder.ToString();

using (SqlConnection conn = new SqlConnection(connectionString))
{
    //...
}
</code>```

Body:
To create a connection string you can use SqlConnectionStringBuilder, after that you can pass created connection string into SqlConnection:

SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder
{
    UserID = "Some User ID",
    Password = "Some Database Password",
    InitialCatalog = "Some Initial Catalog",
    DataSource = "Some Data Source"
};

string connectionString = builder.ToString();

using (SqlConnection conn = new SqlConnection(connectionString))
{
    //...
}


问:
Perl too slow concurrent download with both HTTP::Async & Net::Async::HTTP
I'm trying to GET about 7 dozens of urls in parallel with scripts: the first is below, with HTTP::Async, and the second one is on pastebin, with Net::Async::HTTP.
The problem is that I'm getting pretty same timing results - about 8..14 seconds for all urls list. It's inacceptable slow compared to curl+xargs started from shell, which gets all in less than 3 seconds with 10-20 "threads".
For example, Devel::Timer in first script shows that max queue length is even less than 6 ($queue->in_progress_count<=5, $queue->to_send_count=0 allways). So, it's looks like foreach with $queue->add is executing too slow, and I don't know why.
Pretty same situation I got with Net::Async::HTTP (second script on pastebin), which is even slower than the first.

So, please, does anybody know, what I'm doing wrong? How can I get concurrent download speed at least compared to curl+xargs started from shell?

```<code>#!/usr/bin/perl -w
use utf8;
use strict;
use POSIX qw(ceil);
use XML::Simple;
use Data::Dumper;
use HTTP::Request;
use HTTP::Async;
use Time::HiRes qw(usleep time);
use Devel::Timer;

#settings
use constant passwd => 'ultramegahypapassword';
use constant agent => 'supa agent dev.alpha';
use constant timeout => 10;
use constant slots => 10;
use constant debug => 1;

my @qids;
my @xmlz;
my $queue = HTTP::Async->new(slots => slots,max_request_time => 10, timeout => timeout, poll_interval => 0.0001);
my %responses;
my @urlz = (
'http://testpodarki.afghanet/api/products/4577',
'http://testpodarki.afghanet/api/products/4653',
'http://testpodarki.afghanet/api/products/4652',
'http://testpodarki.afghanet/api/products/4571',
'http://testpodarki.afghanet/api/products/4572',
'http://testpodarki.afghanet/api/products/4666',
'http://testpodarki.afghanet/api/products/4576',
'http://testpodarki.afghanet/api/products/4574',
'http://testpodarki.afghanet/api/products/4651',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[3294]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[3294]',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4577]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4577]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4577]',
'http://testpodarki.afghanet/api/product_option_values/188',
'http://testpodarki.afghanet/api/product_option_values/191',
'http://testpodarki.afghanet/api/product_option_values/187',
'http://testpodarki.afghanet/api/product_option_values/190',
'http://testpodarki.afghanet/api/product_option_values/189',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4653]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4653]',
'http://testpodarki.afghanet/api/images/products/4577/12176',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4652]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4652]',
'http://testpodarki.afghanet/api/images/products/4653/12390',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4571]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4571]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4571]',
'http://testpodarki.afghanet/api/images/products/4652/12388',
'http://testpodarki.afghanet/api/product_option_values/175',
'http://testpodarki.afghanet/api/product_option_values/178',
'http://testpodarki.afghanet/api/product_option_values/179',
'http://testpodarki.afghanet/api/product_option_values/180',
'http://testpodarki.afghanet/api/product_option_values/181',
'http://testpodarki.afghanet/api/images/products/3294/8965',
'http://testpodarki.afghanet/api/product_option_values/176',
'http://testpodarki.afghanet/api/product_option_values/177',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4572]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4572]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4572]',
'http://testpodarki.afghanet/api/product_option_values/176',
'http://testpodarki.afghanet/api/product_option_values/181',
'http://testpodarki.afghanet/api/product_option_values/180',
'http://testpodarki.afghanet/api/images/products/4571/12159',
'http://testpodarki.afghanet/api/product_option_values/177',
'http://testpodarki.afghanet/api/product_option_values/179',
'http://testpodarki.afghanet/api/product_option_values/175',
'http://testpodarki.afghanet/api/product_option_values/178',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4666]',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4576]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4666]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4576]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4576]',
'http://testpodarki.afghanet/api/images/products/4572/12168',
'http://testpodarki.afghanet/api/product_option_values/185',
'http://testpodarki.afghanet/api/product_option_values/182',
'http://testpodarki.afghanet/api/product_option_values/184',
'http://testpodarki.afghanet/api/product_option_values/183',
'http://testpodarki.afghanet/api/product_option_values/186',
'http://testpodarki.afghanet/api/images/products/4666/12413',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4574]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4574]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4574]',
'http://testpodarki.afghanet/api/product_option_values/177',
'http://testpodarki.afghanet/api/product_option_values/181',
'http://testpodarki.afghanet/api/images/products/4576/12174',
'http://testpodarki.afghanet/api/product_option_values/176',
'http://testpodarki.afghanet/api/product_option_values/180',
'http://testpodarki.afghanet/api/product_option_values/179',
'http://testpodarki.afghanet/api/product_option_values/175',
'http://testpodarki.afghanet/api/product_option_values/178',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4651]',
'http://testpodarki.afghanet/api/images/products/4574/12171',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4651]',
'http://testpodarki.afghanet/api/images/products/4651/12387'
);

my $timer = Devel::Timer->new();

foreach my $el (@urlz) {
    my $request = HTTP::Request->new(GET => $el);
    $request->header(User_Agent => agent);
    $request->authorization_basic(passwd,'');
    push @qids,$queue->add($request);
    $timer->mark("pushed [$el], to_send=".$queue->to_send_count().", to_return=".$queue->to_return_count().", in_progress=".$queue->in_progress_count());
}

$timer->mark('requestz pushed');

while ($queue->in_progress_count) {
    usleep(2000);
    $queue->poke();
}

$timer->mark('requestz complited');

process_responses();

$timer->mark('responzez processed');

foreach my $q (@xmlz) {
#    print ">>>>>>".Dumper($q)."<<<<<<<<\n";
}

$timer->report();
print "\n\n";
</code>```

答:
So, finally got working sample (full script). It uses Furl and fork_call from AnyEvent::Util. This example returnes in ~3 secs, what is good enough. If you need to use basic HTTP auth, just use URI with creds like this: username:password@hostdomain.org/path?param1=val1&param2=val2. You better add use EV; before using AnyEvent because EV is the fastest.

```<code>#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Devel::Timer;
use Furl;
use EV;
use AnyEvent;
use AnyEvent::Util 'fork_call';

#get full script
my @urls = (...);

sub fetch {
    my $url = shift;
    my $furl = Furl::HTTP->new(agent => 'Furl/0.31',timeout => 3);
    print "start $url\n";
    my ($ver, $code, $msg, $headers, $body) = $furl->get($url);
    my $size = length $body;
    print "finished $url, $size bytes\n";
    return ($code, $msg, $headers, $body);
}

my %resps;

my $timer = Devel::Timer->new();
$timer->mark('foreach');
$AnyEvent::Util::MAX_FORKS = 20;
my $cv = AE::cv;
foreach my $url (@urls) {
    $timer->mark('next foreach');
    $cv->begin;
    fork_call {
        print "getting $url... ";
        my ($code, $msg, $headers, $body)=fetch($url);
        print "[$code]\n";
        return ($url, $code, $msg, $headers, $body);
        }
        sub {
            print "adding 2 %resps\n";
            my ($url, $code, $msg, $headers, $body)=@_;
            $resps{$url}->{'code'}=$code;
            $resps{$url}->{'msg'}=$msg;
            $resps{$url}->{'headers'}=$headers;
            $resps{$url}->{'body'}=$body;
            $cv->end;
        };
}
$cv->recv;
$timer->mark('end');

print "\nall data is ready, press <ENTER>:";
<STDIN>;
print Dumper(%resps);
print "\n<PRESS ENTER>to print timer report\n";
<STDIN>;
$timer->report();
sleep(3);
</code>```

Body:
I'm trying to GET about 7 dozens of urls in parallel with scripts: the first is below, with HTTP::Async, and the second one is on pastebin, with Net::Async::HTTP.
The problem is that I'm getting pretty same timing results - about 8..14 seconds for all urls list. It's inacceptable slow compared to curl+xargs started from shell, which gets all in less than 3 seconds with 10-20 "threads".
For example, Devel::Timer in first script shows that max queue length is even less than 6 ($queue->in_progress_count<=5, $queue->to_send_count=0 allways). So, it's looks like foreach with $queue->add is executing too slow, and I don't know why.
Pretty same situation I got with Net::Async::HTTP (second script on pastebin), which is even slower than the first.

So, please, does anybody know, what I'm doing wrong? How can I get concurrent download speed at least compared to curl+xargs started from shell?

#!/usr/bin/perl -w
use utf8;
use strict;
use POSIX qw(ceil);
use XML::Simple;
use Data::Dumper;
use HTTP::Request;
use HTTP::Async;
use Time::HiRes qw(usleep time);
use Devel::Timer;

#settings
use constant passwd => 'ultramegahypapassword';
use constant agent => 'supa agent dev.alpha';
use constant timeout => 10;
use constant slots => 10;
use constant debug => 1;

my @qids;
my @xmlz;
my $queue = HTTP::Async->new(slots => slots,max_request_time => 10, timeout => timeout, poll_interval => 0.0001);
my %responses;
my @urlz = (
'http://testpodarki.afghanet/api/products/4577',
'http://testpodarki.afghanet/api/products/4653',
'http://testpodarki.afghanet/api/products/4652',
'http://testpodarki.afghanet/api/products/4571',
'http://testpodarki.afghanet/api/products/4572',
'http://testpodarki.afghanet/api/products/4666',
'http://testpodarki.afghanet/api/products/4576',
'http://testpodarki.afghanet/api/products/4574',
'http://testpodarki.afghanet/api/products/4651',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[3294]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[3294]',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4577]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4577]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4577]',
'http://testpodarki.afghanet/api/product_option_values/188',
'http://testpodarki.afghanet/api/product_option_values/191',
'http://testpodarki.afghanet/api/product_option_values/187',
'http://testpodarki.afghanet/api/product_option_values/190',
'http://testpodarki.afghanet/api/product_option_values/189',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4653]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4653]',
'http://testpodarki.afghanet/api/images/products/4577/12176',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4652]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4652]',
'http://testpodarki.afghanet/api/images/products/4653/12390',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4571]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4571]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4571]',
'http://testpodarki.afghanet/api/images/products/4652/12388',
'http://testpodarki.afghanet/api/product_option_values/175',
'http://testpodarki.afghanet/api/product_option_values/178',
'http://testpodarki.afghanet/api/product_option_values/179',
'http://testpodarki.afghanet/api/product_option_values/180',
'http://testpodarki.afghanet/api/product_option_values/181',
'http://testpodarki.afghanet/api/images/products/3294/8965',
'http://testpodarki.afghanet/api/product_option_values/176',
'http://testpodarki.afghanet/api/product_option_values/177',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4572]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4572]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4572]',
'http://testpodarki.afghanet/api/product_option_values/176',
'http://testpodarki.afghanet/api/product_option_values/181',
'http://testpodarki.afghanet/api/product_option_values/180',
'http://testpodarki.afghanet/api/images/products/4571/12159',
'http://testpodarki.afghanet/api/product_option_values/177',
'http://testpodarki.afghanet/api/product_option_values/179',
'http://testpodarki.afghanet/api/product_option_values/175',
'http://testpodarki.afghanet/api/product_option_values/178',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4666]',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4576]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4666]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4576]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4576]',
'http://testpodarki.afghanet/api/images/products/4572/12168',
'http://testpodarki.afghanet/api/product_option_values/185',
'http://testpodarki.afghanet/api/product_option_values/182',
'http://testpodarki.afghanet/api/product_option_values/184',
'http://testpodarki.afghanet/api/product_option_values/183',
'http://testpodarki.afghanet/api/product_option_values/186',
'http://testpodarki.afghanet/api/images/products/4666/12413',
'http://testpodarki.afghanet/api/combinations/?display=full&filter[id_product]=[4574]',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4574]',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4574]',
'http://testpodarki.afghanet/api/product_option_values/177',
'http://testpodarki.afghanet/api/product_option_values/181',
'http://testpodarki.afghanet/api/images/products/4576/12174',
'http://testpodarki.afghanet/api/product_option_values/176',
'http://testpodarki.afghanet/api/product_option_values/180',
'http://testpodarki.afghanet/api/product_option_values/179',
'http://testpodarki.afghanet/api/product_option_values/175',
'http://testpodarki.afghanet/api/product_option_values/178',
'http://testpodarki.afghanet/api/specific_prices/?display=full&filter[id_product]=[4651]',
'http://testpodarki.afghanet/api/images/products/4574/12171',
'http://testpodarki.afghanet/api/stock_availables/?display=full&filter[id_product]=[4651]',
'http://testpodarki.afghanet/api/images/products/4651/12387'
);

my $timer = Devel::Timer->new();

foreach my $el (@urlz) {
    my $request = HTTP::Request->new(GET => $el);
    $request->header(User_Agent => agent);
    $request->authorization_basic(passwd,'');
    push @qids,$queue->add($request);
    $timer->mark("pushed [$el], to_send=".$queue->to_send_count().", to_return=".$queue->to_return_count().", in_progress=".$queue->in_progress_count());
}

$timer->mark('requestz pushed');

while ($queue->in_progress_count) {
    usleep(2000);
    $queue->poke();
}

$timer->mark('requestz complited');

process_responses();

$timer->mark('responzez processed');

foreach my $q (@xmlz) {
#    print ">>>>>>".Dumper($q)."<<<<<<<<\n";
}

$timer->report();
print "\n\n";

Body:
So, finally got working sample (full script). It uses Furl and fork_call from AnyEvent::Util. This example returnes in ~3 secs, what is good enough. If you need to use basic HTTP auth, just use URI with creds like this: username:password@hostdomain.org/path?param1=val1&param2=val2. You better add use EV; before using AnyEvent because EV is the fastest.

#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Devel::Timer;
use Furl;
use EV;
use AnyEvent;
use AnyEvent::Util 'fork_call';

#get full script
my @urls = (...);

sub fetch {
    my $url = shift;
    my $furl = Furl::HTTP->new(agent => 'Furl/0.31',timeout => 3);
    print "start $url\n";
    my ($ver, $code, $msg, $headers, $body) = $furl->get($url);
    my $size = length $body;
    print "finished $url, $size bytes\n";
    return ($code, $msg, $headers, $body);
}

my %resps;

my $timer = Devel::Timer->new();
$timer->mark('foreach');
$AnyEvent::Util::MAX_FORKS = 20;
my $cv = AE::cv;
foreach my $url (@urls) {
    $timer->mark('next foreach');
    $cv->begin;
    fork_call {
        print "getting $url... ";
        my ($code, $msg, $headers, $body)=fetch($url);
        print "[$code]\n";
        return ($url, $code, $msg, $headers, $body);
        }
        sub {
            print "adding 2 %resps\n";
            my ($url, $code, $msg, $headers, $body)=@_;
            $resps{$url}->{'code'}=$code;
            $resps{$url}->{'msg'}=$msg;
            $resps{$url}->{'headers'}=$headers;
            $resps{$url}->{'body'}=$body;
            $cv->end;
        };
}
$cv->recv;
$timer->mark('end');

print "\nall data is ready, press <ENTER>:";
<STDIN>;
print Dumper(%resps);
print "\n<PRESS ENTER>to print timer report\n";
<STDIN>;
$timer->report();
sleep(3);


问:
Why does $("body") == $("body") return false?
How come the equation in the title is false? How do check if two jQuery selectors point to the same DOM object?</p>

答:
Because jQuery creates a new wrapper object for each $ call, and in Javascript all objects are distinct, even if they have the exact same properties/methods.

On the other hand, document.body == document.body would evaluate to true.

ContentLicense: CC BY-SA 2.5


答:
```<code> <?php
$conn=mysqli_connect("localhost","root","","internship");

if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

if(isset($_POST['buttonsubmit'])){

$username=$_POST['username2'];
$password=$_POST['pwd2'];
$type=$_POST['utype'];

$result=mysqli_query($conn,'select * from registration where username="'.$username.'" and password="'.$password.'" and usertype="'.$type.'"');

if(mysqli_num_rows($result)==1 && $type=="Student"){
session_start();
$_SESSION['user'] = $result;
    header('Location: student.php');
}

else
    ?>
    <script>  alert("Account invalid!!!! Enter valid Username Password and Usertype")</script>
    <?php
}
</code>```

Title: retrieve data from table and that data use to login


问:
Cloudera Manager Administration
I newbie to Cloudera Hadoop,i want to learn cloudera hadoop administration myself,i am having  12 GB ram installed on windows laptop, for virtual machine around 9 GB available to use, do anyone know how to install and use Cloudera manager in virtual environment to practice cloudera administration.is there any way to work on cloudera manager with only 8 gb ram available?</p>

答:
You can install

Install CentOS 6.x or 7.2 from the Centos DVD and choosing "Minimal
Server" or "Minimal Workstation" depending if you want a graphical interface

Install Cloudera Manager from scratch using the Cloudera Documentation, selecting Path B with external PostgreSQL. It's more representative of the administration tasks than Path A. Path C is just a nightmare to begin with CM.

With 9GB RAM, your cluster can run a little slowly if you had an eclipse instance to develop some proof of concept, but it's acceptable. When your cluster is up, you can stop Cloudera Manager and use Hadoop services as well.

Title: Cloudera Manager Administration


问:
Javascript string object to array
I want to pass some data from html to jquery using data-attribute like this:

```<code><div data-frames="[
    { src: 'artwork-96.png',  sizes: '96x96',   type: 'image/png' },
    { src: 'artwork-128.png', sizes: '128x128', type: 'image/png' },
    { src: 'artwork-192.png', sizes: '192x192', type: 'image/png' },
    { src: 'artwork-256.png', sizes: '256x256', type: 'image/png' },
    { src: 'artwork-384.png', sizes: '384x384', type: 'image/png' },
    { src: 'artwork-512.png', sizes: '512x512', type: 'image/png' }
]"></div>
</code>```

I don't know a way how could I use this structure in jquery so it keeps the same format (array with objects). Is there a way to do this?

Using string.split(',') doesn't help me here.

答:
If the dataset is rigid then in pure JS you can do as follows

var datas = document.getElementById("datas");
     data = JSON.parse(datas.dataset.frames.replace(/(\w+):\s*'([\w\:\.\-\\\/]+)'/g, "\"$1\": \"$2\""));
console.log(data);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0; }</code>```

```

Title: Javascript string object to array

Body:
I want to pass some data from html to jquery using data-attribute like this:

I don't know a way how could I use this structure in jquery so it keeps the same format (array with objects). Is there a way to do this?

Using string.split(',') doesn't help me here.

Body:
If the dataset is rigid then in pure JS you can do as follows

var datas = document.getElementById("datas");
     data = JSON.parse(datas.dataset.frames.replace(/(\w+):\s*'([\w\:\.\-\\\/]+)'/g, "\"$1\": \"$2\""));
console.log(data);

.as-console-wrapper { max-height: 100% !important; top: 0; }

<div id="datas" data-frames="[
    { src: 'artwork-96.png',  sizes: '96x96',   type: 'image/png' },
    { src: 'artwork-128.png', sizes: '128x128', type: 'image/png' },
    { src: 'artwork-192.png', sizes: '192x192', type: 'image/png' },
    { src: 'artwork-256.png', sizes: '256x256', type: 'image/png' },
    { src: 'artwork-384.png', sizes: '384x384', type: 'image/png' },
    { src: 'artwork-512.png', sizes: '512x512', type: 'image/png' } ]"></div>


问:
How to center position navbar content in Bootstrap
I am learning bootstrap 4 navbar but i was not able to understand clearly how to position objects in navbar i want a search box to be placed at the center of navbar and a button on right but i was only able to do it navbar is not getting aligned at center.</p>

```<code>        <div class="collapse navbar-collapse text-xs-center" id="mynavbar">

        <div class="col-lg-4 form-inline navbar-form">
            <div class="input-group">
                <form class="form-inline my-lg-0">
                    <input class="form-control " type="text" placeholder="Search">
                    <button class="btn btn-outline-default my-2 my-sm-0" type="submit">Search</button>
                </form>

            </div>
        </div>

        <ul class="navbar-nav w-100 justify-content-end">

            <li class="nav-item" style="margin-right: 15px;">
                <div class="btn-group">
                    <a class="btn nav-link dropdown-toggle" data-toggle="dropdown"
                        href="#" role="button" aria-haspopup="true" aria-expanded="false">
                        <i class="fa fa-plus" aria-hidden="true"></i>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right">
                        <a class="dropdown-item" href="#">Action</a> <a
                            class="dropdown-item" href="#">Another action</a> <a
                            class="dropdown-item" href="#">Something else here</a>
                    </div>
                </div>
            </li>
          </ul>
         </div>
</code>```

答:
There are different methods for Navbar alignment in Bootstrap 4. One way is to use mx-auto on the content to center (the form)...

```<code><nav class="navbar navbar-expand navbar-light bg-faded">
    <div class="navbar-collapse collapse" id="mynavbar">
        <form class="form-inline mx-auto">
            <div class="input-group my-lg-0">
                <input class="form-control " type="text" placeholder="Search">
                <span class="input-group-btn">
                <button class="btn" type="submit">Search</button>
                </span>
            </div>
        </form>
        <ul class="navbar-nav">
            <li class="nav-item">
                 <div class="btn-group">
                    <a class="btn nav-link dropdown-toggle" data-toggle="dropdown"
                        href="#" role="button" aria-haspopup="true" aria-expanded="false">
                        <i class="fa fa-plus" aria-hidden="true"></i>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right">
                        <a class="dropdown-item" href="#">Action</a> <a
                            class="dropdown-item" href="#">Another action</a> <a
                            class="dropdown-item" href="#">Something else here</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</nav>
</code>```

But the search form will not be perfectly centered because there is no content in the left, and the form will be pushed slight left by the button on the right.

So in this case, I'd recommend using the flexbox utility classes..

```<code><nav class="navbar navbar-expand navbar-light bg-faded">
    <div class="navbar-collapse collapse" id="mynavbar">
        <span class="navbar-text w-100"> </span>
        <form class="form-inline w-100 justify-content-center">
            <div class="input-group my-lg-0">
                <input class="form-control " type="text" placeholder="Search">
                <span class="input-group-btn">
                <button class="btn" type="submit">Search</button>
                </span>
            </div>
        </form>
        <ul class="navbar-nav w-100 justify-content-end">
            <li class="nav-item">
                 <div class="btn-group">
                    <a class="btn nav-link dropdown-toggle" data-toggle="dropdown"
                        href="#" role="button" aria-haspopup="true" aria-expanded="false">
                        <i class="fa fa-plus" aria-hidden="true"></i>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right">
                        <a class="dropdown-item" href="#">Action</a> <a
                            class="dropdown-item" href="#">Another action</a> <a
                            class="dropdown-item" href="#">Something else here</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</nav>
</code>```

Demo of both centering methods

ContentLicense: CC BY-SA 4.0

Body:
I am learning bootstrap 4 navbar but i was not able to understand clearly how to position objects in navbar i want a search box to be placed at the center of navbar and a button on right but i was only able to do it navbar is not getting aligned at center.

                <form class="form-inline my-lg-0">
                    <input class="form-control " type="text" placeholder="Search">
                    <button class="btn btn-outline-default my-2 my-sm-0" type="submit">Search</button>
                </form>

                        Action Another action Something else here

Body:
There are different methods for Navbar alignment in Bootstrap 4. One way is to use mx-auto on the content to center (the form)...

<nav class="navbar navbar-expand navbar-light bg-faded">
    <div class="navbar-collapse collapse" id="mynavbar">
        <form class="form-inline mx-auto">
            <div class="input-group my-lg-0">
                <input class="form-control " type="text" placeholder="Search">
                <span class="input-group-btn">
                <button class="btn" type="submit">Search</button>
                </span>
            </div>
        </form>
        <ul class="navbar-nav">
            <li class="nav-item">
                 <div class="btn-group">
                    <a class="btn nav-link dropdown-toggle" data-toggle="dropdown"
                        href="#" role="button" aria-haspopup="true" aria-expanded="false">
                        <i class="fa fa-plus" aria-hidden="true"></i>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right">
                        <a class="dropdown-item" href="#">Action</a> <a
                            class="dropdown-item" href="#">Another action</a> <a
                            class="dropdown-item" href="#">Something else here</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</nav>

But the search form will not be perfectly centered because there is no content in the left, and the form will be pushed slight left by the button on the right.

So in this case, I'd recommend using the flexbox utility classes..

<nav class="navbar navbar-expand navbar-light bg-faded">
    <div class="navbar-collapse collapse" id="mynavbar">
        <span class="navbar-text w-100"> </span>
        <form class="form-inline w-100 justify-content-center">
            <div class="input-group my-lg-0">
                <input class="form-control " type="text" placeholder="Search">
                <span class="input-group-btn">
                <button class="btn" type="submit">Search</button>
                </span>
            </div>
        </form>
        <ul class="navbar-nav w-100 justify-content-end">
            <li class="nav-item">
                 <div class="btn-group">
                    <a class="btn nav-link dropdown-toggle" data-toggle="dropdown"
                        href="#" role="button" aria-haspopup="true" aria-expanded="false">
                        <i class="fa fa-plus" aria-hidden="true"></i>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right">
                        <a class="dropdown-item" href="#">Action</a> <a
                            class="dropdown-item" href="#">Another action</a> <a
                            class="dropdown-item" href="#">Something else here</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</nav>

Demo of both centering methods


问:
How to remove all debug logging calls before building the release version of an Android app?
According to Google, I must "deactivate any calls to Log methods in the source code" before publishing my Android app to Google Play. Extract from section 3 of the publication checklist:

Make sure you deactivate logging and disable the debugging option before you build your application for release. You can deactivate logging by removing calls to Log methods in your source files.

My open-source project is large and it is a pain to do it manually every time I release. Additionally, removing a Log line is potentially tricky, for instance:

```<code>if(condition)
  Log.d(LOG_TAG, "Something");
data.load();
data.show();
</code>```

If I comment the Log line, then the condition applies to the next line, and chances are load() is not called. Are such situations rare enough that I can decide it should not exist?

So, is there a better source code-level way to do that? Or maybe some clever ProGuard syntax to efficiently but safely remove all Log lines?

答:
Add following to your proguard-rules.txt file

```<code>-assumenosideeffects class android.util.Log {
  public static *** d(...);
  public static *** w(...);
  public static *** v(...);
  public static *** i(...);
}
</code>```

Body:
According to Google, I must "deactivate any calls to Log methods in the source code" before publishing my Android app to Google Play. Extract from section 3 of the publication checklist:

Make sure you deactivate logging and disable the debugging option before you build your application for release. You can deactivate logging by removing calls to Log methods in your source files.

My open-source project is large and it is a pain to do it manually every time I release. Additionally, removing a Log line is potentially tricky, for instance:

if(condition)
  Log.d(LOG_TAG, "Something");
data.load();
data.show();

If I comment the Log line, then the condition applies to the next line, and chances are load() is not called. Are such situations rare enough that I can decide it should not exist?

So, is there a better source code-level way to do that? Or maybe some clever ProGuard syntax to efficiently but safely remove all Log lines?

Body:
Add following to your proguard-rules.txt file

-assumenosideeffects class android.util.Log {
  public static *** d(...);
  public static *** w(...);
  public static *** v(...);
  public static *** i(...);
}


问:
Why is my page not being cached?
This is just making me angry. I can't figure out why all the resources in my page are being requested EVERY single time.

E.g. my site.css returns the following headers (using fiddler):

```<code>HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Mon, 29 Nov 2010 17:36:21 GMT
X-AspNet-Version: 2.0.50727
Content-Length: 9093
Cache-Control: public, max-age=2592000
Expires: Wed, 29 Dec 2010 17:36:21 GMT
Last-Modified: Mon, 08 Nov 2010 17:20:16 GMT
Content-Type: text/css
Connection: Close
</code>```

But every time I hit refresh I see all the resources (css,js,images) getting re-requested. I have control over the headers returned for any and all of these resources, but I haven't figured it out yet.

I have even debugged my ASP.NET app and the HttpModule is definitely being asked for the resources again.

Can someone give me an idea of what to do?

EDIT:
Ok, I removed must-revalidate, proxy-revalidate from the headers and that is getting me closer to where I want to be, now when I press back it still requests my css/js files when I press back.

Is there anything more I can do to avoid this?

答:
The following links might be of help to you.

Differences in reload behavior between FF and IE

http://blog.httpwatch.com/2008/10/15/two-important-differences-between-firefox-and-ie-caching/

In a nutshell, your caching behavior is going to be determined by the headers and the browser you are using.

What browser are you using for testing?  The back button is also handled differently.

Back Button (Browser Behavior)

And, finally, a breakdown of f5/ctrl f5, click, shift click, etc behavior between browsers:
What requests do browsers' "F5" and "Ctrl + F5" refreshes generate?

Title: Why is my page not being cached?

Body:
This is just making me angry. I can't figure out why all the resources in my page are being requested EVERY single time.

E.g. my site.css returns the following headers (using fiddler):

HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Mon, 29 Nov 2010 17:36:21 GMT
X-AspNet-Version: 2.0.50727
Content-Length: 9093
Cache-Control: public, max-age=2592000
Expires: Wed, 29 Dec 2010 17:36:21 GMT
Last-Modified: Mon, 08 Nov 2010 17:20:16 GMT
Content-Type: text/css
Connection: Close

But every time I hit refresh I see all the resources (css,js,images) getting re-requested. I have control over the headers returned for any and all of these resources, but I haven't figured it out yet.

I have even debugged my ASP.NET app and the HttpModule is definitely being asked for the resources again.

Can someone give me an idea of what to do?

EDIT:
Ok, I removed must-revalidate, proxy-revalidate from the headers and that is getting me closer to where I want to be, now when I press back it still requests my css/js files when I press back.

Is there anything more I can do to avoid this?


问:
VueJs, Vue-chartjs - mutating props
So im getting this error

[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "chartData" (found in )

now this seems to be a common error but im not sure how to get around it in this case

im using Vue with Vue-chartjs and ive got the following

bar_chart.vue

```<code><script>
  import { Bar, mixins } from 'vue-chartjs'

  export default Bar.extend({
    name:"bar_chart",
    mixins: [mixins.reactiveProp],
    props: ["width","height","options"],
    mounted () {

      this.renderChart(this.chartData, {responsive: true, maintainAspectRatio: false});
    }
  })
</script>
</code>```

module_content.vue

```<code><template>
  <div id="module_content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-6 bar_chart_test">
          <bar_chart
            :chartData="DataSet"
            :width="400"
            :height="200">
          </bar_chart>
          <button v-on:click="getBarDate">Hey there!</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import bar_chart from 'components/controls/bar_chart.vue'

export default {
  name: 'module_content',
  components: {
    bar_chart
  },
  data: function () {
    return {
      data_source: {}
    }
  },
  methods: {
    getBarDate: function()
    {
        this.DataSet = ({
          labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
          datasets: [
            {
              label: 'GitHub Commits',
              backgroundColor: '#f87979',
              data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
            }
          ]
        });
    }
  },
  computed: {
    DataSet: {
     cached: false,
      get: function () {
        return this.data_source
      },
      // setter
      set: function (newValue) {
        this.data_source = newValue;
      }
    }
  }
}
</script>
</code>```

basically i want that function getBarDate to be able to set ChartData (replaced with an ajax call later down the line), been through hundreds of permutations and documents and still dont understand.

i think understand that you cant set it directly, thats fine, and the error is clear, but cant see any examples that work using the vue-chart mix in?

i have tried setting computed expressions or data variables in bar_chart.vue and same in module content.

i just cant seem to get it to behave

Can anyone help
Thanks

答: You may use vuex to store the data of the chart</p>

Title: VueJs, Vue-chartjs - mutating props

Body:
So im getting this error

[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "chartData" (found in )

now this seems to be a common error but im not sure how to get around it in this case

im using Vue with Vue-chartjs and ive got the following

bar_chart.vue

module_content.vue

<template>

          <bar_chart
            :chartData="DataSet"
            :width="400"
            :height="200">
          </bar_chart>
          <button v-on:click="getBarDate">Hey there!</button>

</template>

basically i want that function getBarDate to be able to set ChartData (replaced with an ajax call later down the line), been through hundreds of permutations and documents and still dont understand.

i think understand that you cant set it directly, thats fine, and the error is clear, but cant see any examples that work using the vue-chart mix in?

i have tried setting computed expressions or data variables in bar_chart.vue and same in module content.

i just cant seem to get it to behave

Can anyone help
Thanks


问:
Swift 3 Write String to binary file
How can I write a string to a binary file?
I have tried a lot,  but every time my file appear as a plain text file..

I am not interested in a plist file..

```<code>            string = String(data: data, encoding: String.Encoding.utf8)!;
            var buffer = [UInt8](string.utf8);

            var f = fopen("newdata.dat", "w");
            let success = fwrite(buffer, MemoryLayout<UInt8>.size, buffer.count, f);
            fsync(fileno(f));
            fclose(f);
            print("success: \(success)");
</code>```

答:
Are you clear on the difference between data and text? A plain-text file is data that when interpreted by a text editor is displayed as text. Are you expecting to see zeroes and ones or an array of numbers (hexadecimal perhaps)? Or the kind of jumble of characters you see if you try and open a Word doc as plain text? If so then you need to open the file in an app like More Info

Or, the DIY option is to view the byte buffer but the only way you are going to view the bytes in a text editor is to transform them into a string and save this, which will represent the values of the original file but ironically not of the file itself (if that makes sense).

Title: Swift 3 Write String to binary file

Body:
How can I write a string to a binary file?
I have tried a lot,  but every time my file appear as a plain text file..

I am not interested in a plist file..

            string = String(data: data, encoding: String.Encoding.utf8)!;
            var buffer = [UInt8](string.utf8);

            var f = fopen("newdata.dat", "w");
            let success = fwrite(buffer, MemoryLayout<UInt8>.size, buffer.count, f);
            fsync(fileno(f));
            fclose(f);
            print("success: \(success)");


问:
Quick guide to get started using Git + GitX with Xcode projects on the mac?
Using Git on the mac feels like a huge pain, and the Git documentation is just huuuuuuuuge. Maybe someone has a top secret blog article or even screencast to share, that explains the basics fairly simple and quickly?

Creating a repository. Big pain.

Opening that repository with GitX: Pain.

Working in Xcode and then committing changes: No idea, probably big pain too.

Cloning the repository to a few other developers with their own macs so they can start collaborate on the project: Oh man, my head explodes... need a doctor!

Merging those cloned repositories back somehow, so everyone gets an updated repository with the changes of anyone else: Red alert!

Right now I feel I'll need a month to grok it. Would be SO glad if someone can point out really helpful resources that don't force me to read for some days... or is there a great and thin book that explains this madness?

答:
Git is absolutely enormous, and you could certainly spend that month learning its processes, but you can stick to some basic concepts and end up with a really great workflow. I use the command line, as it allows you stick to these basics, and expand out if you need to. These basic commands are "pull", "push", "init", "commit -am "message"". Later, you can read about branches and rebasing at gitref.org.

As a mac Xcode + git user; I definitely recommend DTerm to make life easy. One key command brings up a floating terminal window, CDed to the directory of the file that's currently active. In XCode, this means that you'll be in a git-controlled directory immediately.

So, my workflow --

Use "git init" in the terminal to create a repository

Create github repository

follow github instructions to associate the two

When working in my project, press Shift-Command-Enter to bring up a floating terminal window

type "git commit -am "commit message" to commit all current changes

Same key combo plus "git pull" or "git push" for pulling in changes from code repository or pushing changes to code repository, respectively

I find that the command line allows a much easier working relationship with git than GitX, especially if you're using something like DTerm.

For a great reference, check out gitref.org. Good luck!


问:
Javascript select option application
I am trying to create the select application using Javascipt only. I got to know about this code on internet

```<code><!DOCTYPE html>
<html>
<head>
    <title>Select Options</title>
</head>
<body>

<h2>Choose your car</h2>
<hr>

Choose Car Make:
<select id="slct1" onchange="populate(this.id,'slct2')">
    <option value=""></option>
    <option value="Hyundai">Hyundai</option>
    <option value="Honda">Honda</option>
    <option value="Maruti">Maruti</option>
</select>

<hr>

Choose Car Model
<select id="slct2" ></select>

</body>

<script type="text/javascript">

    function populate(s1,s2){
        var s1,s2;
        s1 = document.getElementById(s1);
        s2 = document.getElementById(s2);

        if(s1.value=='Hyundai'){
            optionArray=['Please Select Car','i10','i20','Verna']
        } else
        if(s1.value=='Honda'){
            optionArray=['Please Select Car','Amaze','Jazz','City']
        } else
        if(s1.value=='Maruti'){
            optionArray=['Please Select Car','Swift','Dezire','Ciaze']
        }

        for (var i = 0; i < optionArray.length; i++) {
        var store = optionArray[i];
        var createNewEl = document.createElement('option');
        createNewEl.innerHTML = store;
        s2.appendChild(createNewEl);
        }

    }

</script>
</html>
</code>```

This is the full code I use now to write this apllication but I everytime I select option from car make ** and when I select another option fromcar make**, it does not delete the previous options from car model and the list gets increased so on everytime I select option from car make

答:
First, you need to import jQuery. Paste this between  tags:

```<code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</code>```

Your script is appending new values to end of the select list, so it have to remove all old values.

```<code>$("#slct2 option").remove();
</code>```

I tested it and works fine for me. Here is full, working code.

```<code><!DOCTYPE html>
<html>
<head>
    <title>Select Options</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>

<h2>Choose your car</h2>
<hr>

Choose Car Make:
<select id="slct1" onchange="populate(this.id,'slct2')">
    <option value=""></option>
    <option value="Hyundai">Hyundai</option>
    <option value="Honda">Honda</option>
    <option value="Maruti">Maruti</option>
</select>

<hr>

Choose Car Model
<select id="slct2"></select>

</body>

<script type="text/javascript">

    function populate(s1,s2){

        var s1,s2;
        s1 = document.getElementById(s1);
        s2 = document.getElementById(s2);

        $("#slct2 option").remove();

        if(s1.value=='Hyundai'){
            optionArray=['Please Select Car','i10','i20','Verna']
        } else
        if(s1.value=='Honda'){
            optionArray=['Please Select Car','Amaze','Jazz','City']
        } else
        if(s1.value=='Maruti'){
            optionArray=['Please Select Car','Swift','Dezire','Ciaze']
        }

        for (var i = 0; i < optionArray.length; i++) {
            var store = optionArray[i];
            var createNewEl = document.createElement('option');
            createNewEl.innerHTML = store;
            s2.appendChild(createNewEl);
        }
    }

</script>
</html>
</code>```

EDIT:
If you don't want to use jQuery just replace this $("#slct2 option").remove(); with this:

```<code>while (s2.firstChild) {
    s2.removeChild(s2.firstChild);
}
</code>```

Title: Javascript select option application

Body:
I am trying to create the select application using Javascipt only. I got to know about this code on internet

<!DOCTYPE html>

    <title>Select Options</title>

Choose your car

Choose Car Make:
<select id="slct1" onchange="populate(this.id,'slct2')">
    <option value=""></option>
    <option value="Hyundai">Hyundai</option>
    <option value="Honda">Honda</option>
    <option value="Maruti">Maruti</option>
</select>

Choose Car Model
<select id="slct2" ></select>

This is the full code I use now to write this apllication but I everytime I select option from car make ** and when I select another option fromcar make**, it does not delete the previous options from car model and the list gets increased so on everytime I select option from car make

Body:
First, you need to import jQuery. Paste this between <head> tags:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Your script is appending new values to end of the select list, so it have to remove all old values.

$("#slct2 option").remove();

I tested it and works fine for me. Here is full, working code.

<!DOCTYPE html>
<html>
<head>
    <title>Select Options</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>

<h2>Choose your car</h2>
<hr>

Choose Car Make:
<select id="slct1" onchange="populate(this.id,'slct2')">
    <option value=""></option>
    <option value="Hyundai">Hyundai</option>
    <option value="Honda">Honda</option>
    <option value="Maruti">Maruti</option>
</select>

<hr>

Choose Car Model
<select id="slct2"></select>

</body>

<script type="text/javascript">

    function populate(s1,s2){

        var s1,s2;
        s1 = document.getElementById(s1);
        s2 = document.getElementById(s2);

        $("#slct2 option").remove();

        if(s1.value=='Hyundai'){
            optionArray=['Please Select Car','i10','i20','Verna']
        } else
        if(s1.value=='Honda'){
            optionArray=['Please Select Car','Amaze','Jazz','City']
        } else
        if(s1.value=='Maruti'){
            optionArray=['Please Select Car','Swift','Dezire','Ciaze']
        }

        for (var i = 0; i < optionArray.length; i++) {
            var store = optionArray[i];
            var createNewEl = document.createElement('option');
            createNewEl.innerHTML = store;
            s2.appendChild(createNewEl);
        }
    }

</script>
</html>

EDIT:
If you don't want to use jQuery just replace this $("#slct2 option").remove(); with this:

while (s2.firstChild) {
    s2.removeChild(s2.firstChild);
}


问:
Android AppCompat dependency in custom library
I just created a new library, Powerful Image View.

My library is a custom AppCompatImageView, so I need the appcompat-v7 library. And here comes the question:

How should I add it to my library?

Should I use 'compile', or 'provided' and let the user add the library to its own dependencies?

And how should i handle different versions of the libraries used, since i'm not depending on a specific version?

I added to the library's gradle file this line:

```<code>provided 'com.android.support:appcompat-v7:+'
</code>```

I'd like to know your thoughts about this :)

答:
Should I use 'compile', or 'provided' and let the user add the library to its own dependencies?

I would use compile and make sure that the developer using your library understands that your library relies upon appcompat-v7, as that in turn places lots of other requirements (e.g., using AppCompatActivity, using Theme.AppCompat).

And how should i handle different versions of the libraries used, since i'm not depending on a specific version?

Well, you are requiring some version. AppCompatImageView does not exist in all versions of appcompat-v7. I recommend depending upon a concrete version (i.e., not +), ideally the latest-and-greatest version.

Body:
I just created a new library, Powerful Image View.

My library is a custom AppCompatImageView, so I need the appcompat-v7 library. And here comes the question:

How should I add it to my library?

Should I use 'compile', or 'provided' and let the user add the library to its own dependencies?

And how should i handle different versions of the libraries used, since i'm not depending on a specific version?

I added to the library's gradle file this line:

provided 'com.android.support:appcompat-v7:+'

I'd like to know your thoughts about this :)


问:
How to restrict which Google Home devices can interact with an action?
I want to build a Conversation Action for Google Home device and control its access. Only certain devices can invoke some actions. How can this be done, once the agent is publicly deployed?</p>

答:
Think of Google Home the same way you would think about a web browser and an Action the same as a web page or site. If you wanted to limit what web browsers can access a public site on the Internet, you're somewhat limited.

You could restrict access to certain IP addresses, and this will work in some cases - but it means that access via non-static IP addresses aren't possible, and if (ie - when) a machine gets a new static IP address, you have a lot of work to do. Similarly, the Google Home device can send a random user_id string for each unique user, and you can use this to limit who has access. But this string can change by the user resetting their Google Home device, and when it does, you will have to deal with that.

A better solution on the web is to allow people to log into your site. This way you can have a public facing web page, but only people with accounts can access. You can determine how to hand out accounts, so this is very flexible. The equivalent with Google Home is Account Linking where you will maintain an account as part of an OAuth2 system that you control. Google Home will ask for permission to access your system, and you will issue OAuth2 tokens to Actions - these tokens will be passed back to you for each request, and you can verify that the user has access.

I strongly suggest going with the Authorization Code Flow since this seems to be where Google is focusing on providing additional features - such as signing up to your service through Google Home.


问:
Python tkinter classes changing icon
I'm not that familar with classes or tkinter, but what i'm trying to do is, if
test1 is selected, than change the icon too favicon, i can't really figure it out, if you could help me that would be great, and if i'm doing something wrong

```<code>from tkinter import *

class GUI:
    def __init__(self, master):

        self.iconnum = IntVar()
        master.title('Testing')
        master.resizable(width=False, height=False)
        master.maxsize(500, 250)
        master.minsize(500, 250)

        self.test1= Radiobutton(master, text="test1", variable=0, value=1, )
        self.test2= Radiobutton(master, text="test2", variable=0, value=2, )
        self.test3= Radiobutton(master, text="test3", variable=0, value=3, )
        self.test4= Radiobutton(master, text="test4", variable=0, value=4,  )

        self.test1.grid(row=2, columnspan=1)
        self.test2.grid(row=2, columnspan=2)
        self.test3.grid(row=2, column=1)
        self.test4.grid(row=3, columnspan=1,)

        self.Test5= Radiobutton(master, text="Test5", indicatoron=0, height=1, width=35,  value=0, command=self.icon_switcher)
        self.Test6= Radiobutton(master, text="Test6", indicatoron=0, height=1, width=35, value=1, command=self.icon_switcher)

        self.Test5.grid(row=1)
        self.Test6.grid(row=1, column=1,)

    def icon_switcher(self):
        if self.iconnum == 1:
            self.master.iconbitmap('favicon.ico')

root = Tk()
gui = GUI(root)

root.mainloop()
</code>```

答:
You need to give a tkinter IntVarfor  RadioButton's variable keyword:

Change

```<code>self.test1= Radiobutton(master, text="test1", variable=0, value=1, )
</code>```

to

```<code>self.test1= Radiobutton(master, text="test1", variable=self.iconnum, value=1, )
</code>```

This will record the selected value in the IntVar.
Then in the icon_switcher function you can call self.iconnum.get() to get the selected value.

Title: Python tkinter classes changing icon

Body:
I'm not that familar with classes or tkinter, but what i'm trying to do is, if
test1 is selected, than change the icon too favicon, i can't really figure it out, if you could help me that would be great, and if i'm doing something wrong

from tkinter import *

class GUI:
    def __init__(self, master):

        self.iconnum = IntVar()
        master.title('Testing')
        master.resizable(width=False, height=False)
        master.maxsize(500, 250)
        master.minsize(500, 250)

        self.test1= Radiobutton(master, text="test1", variable=0, value=1, )
        self.test2= Radiobutton(master, text="test2", variable=0, value=2, )
        self.test3= Radiobutton(master, text="test3", variable=0, value=3, )
        self.test4= Radiobutton(master, text="test4", variable=0, value=4,  )

        self.test1.grid(row=2, columnspan=1)
        self.test2.grid(row=2, columnspan=2)
        self.test3.grid(row=2, column=1)
        self.test4.grid(row=3, columnspan=1,)

        self.Test5= Radiobutton(master, text="Test5", indicatoron=0, height=1, width=35,  value=0, command=self.icon_switcher)
        self.Test6= Radiobutton(master, text="Test6", indicatoron=0, height=1, width=35, value=1, command=self.icon_switcher)

        self.Test5.grid(row=1)
        self.Test6.grid(row=1, column=1,)

    def icon_switcher(self):
        if self.iconnum == 1:
            self.master.iconbitmap('favicon.ico')

root = Tk()
gui = GUI(root)

root.mainloop()

Body:
You need to give a tkinter IntVarfor  RadioButton's variable keyword:

Change

self.test1= Radiobutton(master, text="test1", variable=0, value=1, )

to

self.test1= Radiobutton(master, text="test1", variable=self.iconnum, value=1, )

This will record the selected value in the IntVar.
Then in the icon_switcher function you can call self.iconnum.get() to get the selected value.


问:
scala: assign null to primitive
I am trying to assign null to a variable which is Double like this:

```<code>var foo = 0.0
foo = null
</code>```

However, this gives an error that null cannot be implicitly converted to Double

So I do this instead:

```<code>foo = null.asInstanceOf[Double]
</code>```

however the new value for foo is 0.0

How can I set the value to null?

答:
You should never use null in Scala, instead take a look at Option, Option[Double] specifically

```<code>val foo = Some(0.0)
foo = Option.empty[Double]
</code>```

Even Java introduced it's Optional values, instead of null.

https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html
http://www.scala-lang.org/api/2.7.4/scala/Option.html

Title: scala: assign null to primitive

Body:
I am trying to assign null to a variable which is Double like this:

var foo = 0.0
foo = null

However, this gives an error that null cannot be implicitly converted to Double

So I do this instead:

foo = null.asInstanceOf[Double]

however the new value for foo is 0.0

How can I set the value to null?

Body:
You should never use null in Scala, instead take a look at Option, Option[Double] specifically

val foo = Some(0.0)
foo = Option.empty[Double]

Even Java introduced it's Optional values, instead of null.

https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html
http://www.scala-lang.org/api/2.7.4/scala/Option.html