问:
OAuth2 Authentication fails when attempting to change Gmail Signature for domain user
I'm trying to implement a script that will iterate through each user on my domain and set a custom signature to match company requirements. According to the forum post here I can do this if I create an Apps Script run as a service account with domain-wide delegation. I've created my service account, and made sure the delegation is set to domain-wide. I also added the OAuth2 library to my project. Running this code with my own email address, I get the error message 'Access not granted or expired. (line 352, file "Service", project "OAuth2").' I tried reaching out to Google cloud support for help implementing OAuth2, and they sent me here. Could I get assistance getting this to work on my domain and move in the right direction?

My current code version:

var EMAIL = Session.getActiveUser().getEmail();

var SERVICEACCT = {
  clientID: PropertiesService.getScriptProperties().getProperty('clientId'),
  fileText: PropertiesService.getScriptProperties().getProperty('clientSecretFile'),
  projectID: PropertiesService.getScriptProperties().getProperty('clientProjectID'),
  privateKeyID: PropertiesService.getScriptProperties().getProperty('privateKeyID'),
  privateKey: PropertiesService.getScriptProperties().getProperty('clientSecretKey'),
  clientEmail: PropertiesService.getScriptProperties().getProperty('clientEmail'),
  authURL: PropertiesService.getScriptProperties().getProperty('clientAuthURI'),
  tokenURL: PropertiesService.getScriptProperties().getProperty('clientTokenURI'),
  providerURL: PropertiesService.getScriptProperties().getProperty('providerCertURL'),
  clientURL: PropertiesService.getScriptProperties().getProperty('clientCertURL'),
  map : PropertiesService.getScriptProperties().getKeys()
};

function gmailSignatureImage() {
   Logger.log(SERVICEACCT.clientEmail);
    var email = EMAIL;

  var service = getDomWideDelegationService('Gmail: ', 'https://www.googleapis.com/auth/gmail.settings.sharing', email);

    var resource = { signature: '
My signature image
' +
          '

' };

    var requestBody                = {};
    requestBody.headers            = {'Authorization': 'Bearer ' + service.getAccessToken()};
    requestBody.method             = "PUT";
    requestBody.contentType        = "application/json";
    requestBody.payload            = JSON.stringify(resource);
    requestBody.muteHttpExceptions = false;

    var emailForUrl = encodeURIComponent(email);
    var url = 'https://www.googleapis.com/gmail/v1/users/me/settings/sendAs/' + emailForUrl;
    var setSignatureResponse = UrlFetchApp.fetch(url, requestBody);
}

// these two things are included in the .JSON file that you download when creating the service account and service account key
    var OAUTH2_SERVICE_ACCOUNT_PRIVATE_KEY  = SERVICEACCT.privateKey;
    var OAUTH2_SERVICE_ACCOUNT_CLIENT_EMAIL = SERVICEACCT.clientEmail;

function getDomWideDelegationService(serviceName, scope, email) {

    Logger.log('starting getDomainWideDelegationService for email: ' + email);

    return OAuth2.createService(serviceName + email)
    // Set the endpoint URL.
    //.setTokenUrl('https://accounts.google.com/o/oauth2/token')
      .setTokenUrl(SERVICEACCT.tokenURL)
    // Set the private key and issuer.
    .setPrivateKey(OAUTH2_SERVICE_ACCOUNT_PRIVATE_KEY)
    .setIssuer(OAUTH2_SERVICE_ACCOUNT_CLIENT_EMAIL)

    // Set the name of the user to impersonate. This will only work for
    // Google Apps for Work/EDU accounts whose admin has setup domain-wide
    // delegation:
    // https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority
    .setSubject(email)

    // Set the property store where authorized tokens should be persisted.
    .setPropertyStore(PropertiesService.getScriptProperties())

    // Set the scope. This must match one of the scopes configured during the
    // setup of domain-wide delegation.
    .setScope(scope);

 }```
</div>
</div>
</p>

<p>Also, here are the results of printing my SERVICEACCT object to console (sanitized for privacy):</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>[17-03-28 13:32:13:515 EDT] Service Account
[17-03-28 13:32:13:515 EDT] Client ID: 1234567891011121314
[17-03-28 13:32:13:516 EDT] Project ID: project-id-12345678910112
[17-03-28 13:32:13:516 EDT] Private Key ID: 871**CONFIDENTIAL DATA**ad60
[17-03-28 13:32:13:517 EDT] Client Email: gsig-828@project-id-[Project ID].iam.gserviceaccount.com
[17-03-28 13:32:13:518 EDT] Auth URI: : https://accounts.google.com/o/oauth2/auth
[17-03-28 13:32:13:518 EDT] Token URI: https://accounts.google.com/o/oauth2/token
[17-03-28 13:32:13:519 EDT] Provider Certification URL: https://www.googleapis.com/oauth2/v1/certs
[17-03-28 13:32:13:519 EDT] Client Certification URL: https://www.googleapis.com/robot/v1/metadata/[projectID].iam.gserviceaccount.com
[17-03-28 13:32:13:519 EDT] Private Key:
--------------------------------------------------------------------------------------------------------------------------------------
-----BEGIN PRIVATE KEY-----***CONFIDENTIAL KEY***\n-----END PRIVATE KEY-----\n
--------------------------------------------------------------------------------------------------------------------------------------</code>```

答:
Make sure that your Service is authorized. You may refer with this related thread which suggested to reset the service / clear your use properties. Google only returns the refresh token the first time you authorize the service, so if it was lost then it won't be restored in future authorizations. Also, try revoking access for this script / project and reauthorizing.

I have revoked all access and then I generated the license again far it works, I'll wait a while and see if it does not expire again.

Once you give permission not remove access to the application. I guess with this permission Google refresh the token.

Here's another SO post which might help: Automated OAuth2 token not working - Google Apps Script

Body:
I'm trying to implement a script that will iterate through each user on my domain and set a custom signature to match company requirements. According to the forum post here I can do this if I create an Apps Script run as a service account with domain-wide delegation. I've created my service account, and made sure the delegation is set to domain-wide. I also added the OAuth2 library to my project. Running this code with my own email address, I get the error message 'Access not granted or expired. (line 352, file "Service", project "OAuth2").' I tried reaching out to Google cloud support for help implementing OAuth2, and they sent me here. Could I get assistance getting this to work on my domain and move in the right direction?

My current code version:

var EMAIL = Session.getActiveUser().getEmail();

var SERVICEACCT = {
  clientID: PropertiesService.getScriptProperties().getProperty('clientId'),
  fileText: PropertiesService.getScriptProperties().getProperty('clientSecretFile'),
  projectID: PropertiesService.getScriptProperties().getProperty('clientProjectID'),
  privateKeyID: PropertiesService.getScriptProperties().getProperty('privateKeyID'),
  privateKey: PropertiesService.getScriptProperties().getProperty('clientSecretKey'),
  clientEmail: PropertiesService.getScriptProperties().getProperty('clientEmail'),
  authURL: PropertiesService.getScriptProperties().getProperty('clientAuthURI'),
  tokenURL: PropertiesService.getScriptProperties().getProperty('clientTokenURI'),
  providerURL: PropertiesService.getScriptProperties().getProperty('providerCertURL'),
  clientURL: PropertiesService.getScriptProperties().getProperty('clientCertURL'),
  map : PropertiesService.getScriptProperties().getKeys()
};

function gmailSignatureImage() {
   Logger.log(SERVICEACCT.clientEmail);
    var email = EMAIL;

  var service = getDomWideDelegationService('Gmail: ', 'https://www.googleapis.com/auth/gmail.settings.sharing', email);

    var resource = { signature: '
My signature image
' +
          '

' };

    var requestBody                = {};
    requestBody.headers            = {'Authorization': 'Bearer ' + service.getAccessToken()};
    requestBody.method             = "PUT";
    requestBody.contentType        = "application/json";
    requestBody.payload            = JSON.stringify(resource);
    requestBody.muteHttpExceptions = false;

    var emailForUrl = encodeURIComponent(email);
    var url = 'https://www.googleapis.com/gmail/v1/users/me/settings/sendAs/' + emailForUrl;
    var setSignatureResponse = UrlFetchApp.fetch(url, requestBody);
}

// these two things are included in the .JSON file that you download when creating the service account and service account key
    var OAUTH2_SERVICE_ACCOUNT_PRIVATE_KEY  = SERVICEACCT.privateKey;
    var OAUTH2_SERVICE_ACCOUNT_CLIENT_EMAIL = SERVICEACCT.clientEmail;

function getDomWideDelegationService(serviceName, scope, email) {

    Logger.log('starting getDomainWideDelegationService for email: ' + email);

    return OAuth2.createService(serviceName + email)
    // Set the endpoint URL.
    //.setTokenUrl('https://accounts.google.com/o/oauth2/token')
      .setTokenUrl(SERVICEACCT.tokenURL)
    // Set the private key and issuer.
    .setPrivateKey(OAUTH2_SERVICE_ACCOUNT_PRIVATE_KEY)
    .setIssuer(OAUTH2_SERVICE_ACCOUNT_CLIENT_EMAIL)

    // Set the name of the user to impersonate. This will only work for
    // Google Apps for Work/EDU accounts whose admin has setup domain-wide
    // delegation:
    // https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority
    .setSubject(email)

    // Set the property store where authorized tokens should be persisted.
    .setPropertyStore(PropertiesService.getScriptProperties())

    // Set the scope. This must match one of the scopes configured during the
    // setup of domain-wide delegation.
    .setScope(scope);

 }

Also, here are the results of printing my SERVICEACCT object to console (sanitized for privacy):

[17-03-28 13:32:13:515 EDT] Service Account
[17-03-28 13:32:13:515 EDT] Client ID: 1234567891011121314
[17-03-28 13:32:13:516 EDT] Project ID: project-id-12345678910112
[17-03-28 13:32:13:516 EDT] Private Key ID: 871**CONFIDENTIAL DATA**ad60
[17-03-28 13:32:13:517 EDT] Client Email: gsig-828@project-id-[Project ID].iam.gserviceaccount.com
[17-03-28 13:32:13:518 EDT] Auth URI: : https://accounts.google.com/o/oauth2/auth
[17-03-28 13:32:13:518 EDT] Token URI: https://accounts.google.com/o/oauth2/token
[17-03-28 13:32:13:519 EDT] Provider Certification URL: https://www.googleapis.com/oauth2/v1/certs
[17-03-28 13:32:13:519 EDT] Client Certification URL: https://www.googleapis.com/robot/v1/metadata/[projectID].iam.gserviceaccount.com
[17-03-28 13:32:13:519 EDT] Private Key:
--------------------------------------------------------------------------------------------------------------------------------------
-----BEGIN PRIVATE KEY-----***CONFIDENTIAL KEY***\n-----END PRIVATE KEY-----\n
--------------------------------------------------------------------------------------------------------------------------------------


来源: stackexchange

问:
Using Google SpreadsheetApp setNumberFormat, setting format as percent and not multiplying by 100?
I'm building a Google Spreadsheet from Google Analytics data using the APIs, and I'm trying to format some numbers.

Based on the Sheets API Format page, I should be able to use .setNumberFormat("00.00\%"); to set the number to two decimal places and clear the % with the slash so that it won't run it's multiplier on the number. But it is not working as expected. According to that page, the \ character "Treats the next character as a literal value and not any special meaning it might have."

RAW DATA: 33.0923537840302

GOAL: 33.09%

ACTUAL RESULT: 3309.23%

If I use .setNumberFormat("00.00"); I get the result I want, but it lacks the % on the end.

答:
You can try this:

```<code>cell.setNumberFormat("00.00");
cell.setValue(cell.getValue() + "%")
</code>```

First you'll set the format to "00.00" then concatenate the percent sign to the format result.

Hope this workaround helps.

ContentLicense: CC BY-SA 3.0

Body:
You can try this:

cell.setNumberFormat("00.00");
cell.setValue(cell.getValue() + "%")

First you'll set the format to "00.00" then concatenate the percent sign to the format result.

Hope this workaround helps.


问:
How can I estimate the disk size of a string with JavaScript?
I need to try to estimate the DISK size of a text string (which could be raw text or a Base64 encoded string for an image/audio/etc) in JavaScript. I'm not sure how to estimate this. The only thing when Googling i can find is .length so i thought maybe someone on StackOverflow might know...

The reason i need to know is i have a localStorage script that needs (or would love to have) the ability to check when a user is nearing his 5MB (or 10MB in IE) quota and prompt them to increase the max size for the domain. So, if a user hits, lets say, 4.5MBs of data it'd prompt with

You're nearing your browsers 5MB data cap. Please increase your max data by... [instructions on increasing it for the browser]

答: If you are talking about memory usage, then no. There is no way of reliably determining the used memory (at least implementation-independently), since this is not part of the ECMAScript spec. It depends on your character encoding.</p>

ContentLicense: CC BY-SA 2.5


问:
how I can create synonym with "long refence object name"
After I created synonym, reference object name change;
my script:

```<code>create OR REPLACE SYNONYM [schema name].[synonym name] FOR [shema name]."long refence object name"@dblinkname;
</code>```

After created I look for "long refence object name":

It's changed to "/3248857lonobjectname"

答:
The table_name transformation comes from " you used in the synonym creation.

(You don't need the [schema name]. prior the synonym name. ) ? or is it my Oracle release that prevent doing this?

I would remove the " in the synonym creation, except if you did use them for the table creation in the source db.

The right syntax for this should rather be:

```<code>CREATE OR REPLACE SYNONYM [synonym name]
  FOR [shema name].long_refence_object_name@dblinkname;
</code>```

edit

Now we now a little more.

on the MSSQL, create a synonym too (adapt the syntax):

```<code>CREATE PUBLIC SYNONYM long_refence_object_name
      FOR [shema name]."long refence object name"
</code>```

then you can use it so from Oracle

```<code>CREATE OR REPLACE SYNONYM [synonym name]
  FOR long_refence_object_name@dblinkname;
</code>```

edit2:

No, in fact this is your synonym name that is too long. But you cannot have objects with more than 30 chars. See here why.

When I do this:

```<code>create or replace synonym "my" for SCHM.very_long_namevery_long_nameve@QGM1.WORLD;
</code>```

My synonym works (I can access remote table), and I see it in user synonyms:

```<code>OPS$CHOJ04A my  SCHM VERY_LONG_NAMEVERY_LONG_NAMEVE QGM1.WORLD
</code>```

But when I do that:

```<code>create or replace synonym "myvery_long_namevery_long_nameve"
   for SCHM.very_long_namevery_long_nameve@QGM1.WORLD;
</code>```

Then I can't access the object with

```<code>ORA-00972: identifier is too long
</code>```

and I this this horrible name:

```<code>OPS$CHOJ04A /1d23ec99_MYVERY_LONG_NAMEVERY  SCHM VERY_LONG_NAMEVERY_LONG_NAMEVE QGM1.WORLD
</code>```

Conclusion:

As far as I know, you can't have a synonym larger than 30 chars for any object in Oracle. This is a product limitation.

You still can use the synonym you created as follows:

```<code>SELECT * FROM "/1d23ec99_MYVERY_LONG_NAMEVERY";
</code>```

Not sure it helps if you can't change the queries in your application.

Body:
After I created synonym, reference object name change;
my script:

create OR REPLACE SYNONYM [schema name].[synonym name] FOR [shema name]."long refence object name"@dblinkname;

After created I look for "long refence object name":

It's changed to "/3248857lonobjectname"

Body:
The table_name transformation comes from " you used in the synonym creation.

(You don't need the [schema name]. prior the synonym name. ) ? or is it my Oracle release that prevent doing this?

I would remove the " in the synonym creation, except if you did use them for the table creation in the source db.

The right syntax for this should rather be:

CREATE OR REPLACE SYNONYM [synonym name]
  FOR [shema name].long_refence_object_name@dblinkname;

edit

Now we now a little more.

on the MSSQL, create a synonym too (adapt the syntax):

CREATE PUBLIC SYNONYM long_refence_object_name
      FOR [shema name]."long refence object name"

then you can use it so from Oracle

CREATE OR REPLACE SYNONYM [synonym name]
  FOR long_refence_object_name@dblinkname;

edit2:

No, in fact this is your synonym name that is too long. But you cannot have objects with more than 30 chars. See here why.

When I do this:

create or replace synonym "my" for SCHM.very_long_namevery_long_nameve@QGM1.WORLD;

My synonym works (I can access remote table), and I see it in user synonyms:

OPS$CHOJ04A my  SCHM VERY_LONG_NAMEVERY_LONG_NAMEVE QGM1.WORLD

But when I do that:

create or replace synonym "myvery_long_namevery_long_nameve"
   for SCHM.very_long_namevery_long_nameve@QGM1.WORLD;

Then I can't access the object with

ORA-00972: identifier is too long

and I this this horrible name:

OPS$CHOJ04A /1d23ec99_MYVERY_LONG_NAMEVERY  SCHM VERY_LONG_NAMEVERY_LONG_NAMEVE QGM1.WORLD

Conclusion:

As far as I know, you can't have a synonym larger than 30 chars for any object in Oracle. This is a product limitation.

You still can use the synonym you created as follows:

SELECT * FROM "/1d23ec99_MYVERY_LONG_NAMEVERY";

Not sure it helps if you can't change the queries in your application.


问:
Adding comma after MySQL query based on condition (desc or asc)
I am dynamically creating a query for search, based on search I need to append query with des|asc.

For example if the user click bydate I will append order by bydate desc, again if the user wants to search company name I append order by companyname asc. This is done on condition.

For example if the query is

```<code>select * from market
</code>```

and if the user searches by date query becomes

```<code> select * from market order by bydate desc
</code>```

and if the user searcher by companyname query becomes

Now if the previous query contains asc or desc I need to insert comma, so the query becomes

```<code>select * from market order by bydate desc, companyname
</code>```

If I don't check and insert comma query becomes

```<code>select * from market order by bydate desc companyname -- without comma
</code>```

So inserting comma based on condition

```<code> $query = 'select * from market order by bydate desc';

    if(  ($despos = false) && (  ( strripos($query, 'desc') !=== false && ($despos =  strripos($query, 'desc')) ) ||  ( strripos($query, 'asc') !=== false && ($despos =  strripos($query, 'asc'))  )   ) && $despost !===false   && $despos >(strlen($query)-7)  ) $query.=", ";
</code>```

But the query shows the following error:

( ! ) Parse error: syntax error, unexpected '=' in E:\wamp\www\sugumar\php\1.php on line 5

答:
Assuming that you know the order by params and their effective sorting order you could try something like this:

```<code>    $sortValues = [
    'bydate' => 'desc',
    'companyname' => 'asc'
];

$query = 'select * from market';

$count = count($sortValues);
$index = 0;
foreach($sortValues as $field => $sort){
    $index++;
    $query .= sprintf(' order by %s %s %s', $field, $sort, $index < $count ? ',' : '');
}
echo $query;
</code>```

Result: select * from market order by bydate desc , order by companyname asc

Body:
I am dynamically creating a query for search, based on search I need to append query with des|asc.

For example if the user click bydate I will append order by bydate desc, again if the user wants to search company name I append order by companyname asc. This is done on condition.

For example if the query is

select * from market

and if the user searches by date query becomes

 select * from market order by bydate desc

and if the user searcher by companyname query becomes

Now if the previous query contains asc or desc I need to insert comma, so the query becomes

select * from market order by bydate desc, companyname

If I don't check and insert comma query becomes

select * from market order by bydate desc companyname -- without comma

So inserting comma based on condition

 $query = 'select * from market order by bydate desc';

    if(  ($despos = false) && (  ( strripos($query, 'desc') !=== false && ($despos =  strripos($query, 'desc')) ) ||  ( strripos($query, 'asc') !=== false && ($despos =  strripos($query, 'asc'))  )   ) && $despost !===false   && $despos >(strlen($query)-7)  ) $query.=", ";

But the query shows the following error:

( ! ) Parse error: syntax error, unexpected '=' in E:\wamp\www\sugumar\php\1.php on line 5

Body:
Assuming that you know the order by params and their effective sorting order you could try something like this:

    $sortValues = [
    'bydate' => 'desc',
    'companyname' => 'asc'
];

$query = 'select * from market';

$count = count($sortValues);
$index = 0;
foreach($sortValues as $field => $sort){
    $index++;
    $query .= sprintf(' order by %s %s %s', $field, $sort, $index < $count ? ',' : '');
}
echo $query;

Result: select * from market order by bydate desc , order by companyname asc


问:
StackOverflowException occurred in mscorlib.dll
My project was working fine, but I'm having this weird error for some time while trying to print or even show report. Sometimes it works fine, but when I try to print this report multiple times like more than 50 or something it throws this error. I've spent weeks trying to figure out the solution. I've checked multiple times there's no recursive loop and now I'm just pulling my hairs. Any help would be highly appreciated.

Initialized at Form_Load:

```<code>ReportDocument cryRptEdu = new ReportDocument();
TableLogOnInfos crtableLogoninfosEdu = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfoEdu = new TableLogOnInfo();
ConnectionInfo crConnectionInfoEdu = new ConnectionInfo();

try
{
    cryRptEdu.Load(rptpathEdu);
}
catch (Exception x)
{
    KryptonMessageBox.Show(x.Message, "Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}

crConnectionInfoEdu.ServerName = Program.serverName;
crConnectionInfoEdu.DatabaseName = Program.dbName;
crConnectionInfoEdu.UserID = Program.saName;
crConnectionInfoEdu.Password = Program.pw;
Tables CrTables = cryRptEdu.Database.Tables;
foreach (Table CrTable in CrTables)
{
    crtableLogoninfoEdu = CrTable.LogOnInfo;
    crtableLogoninfoEdu.ConnectionInfo = crConnectionInfoEdu;
    CrTable.ApplyLogOnInfo(crtableLogoninfoEdu);
}
</code>```

On Print Button:

```<code>cryRptEdu.SetParameterValue("percentage", percentage);
cryRptEdu.SetParameterValue("grades", grade);
cryRptEdu.SetParameterValue("position", position);
cryRptEdu.SetParameterValue("attendance", attendance);
cryRptEdu.SetParameterValue("midTermPercentage", midTermPercentage);
cryRptEdu.SetParameterValue("finalPercentage", finalPercentage);
cryRptEdu.SetParameterValue("aggregatePercentage", aggregatePercentage);
cryRptEdu.SetParameterValue("midTermGrade", midTermGrade);
cryRptEdu.SetParameterValue("finalGrade", finalGrade);
cryRptEdu.SetParameterValue("aggrgateGrade", aggregateGrade);
cryRptEdu.SetParameterValue("tl1", tl1);
cryRptEdu.SetParameterValue("tl2", tl2);
cryRptEdu.SetParameterValue("pl1", pl1);
cryRptEdu.SetParameterValue("pl2", pl2);
if (print)
    cryRptEdu.PrintToPrinter(1, true, 1, 1);
else
    cryRptEdu.ExportToDisk(ExportFormatType.PortableDocFormat, exportPath + ID + ".pdf");
</code>```

While Printing:

Stack trace:

答: Finally I resolved the issue using backgroundworker.</p>

Body:
My project was working fine, but I'm having this weird error for some time while trying to print or even show report. Sometimes it works fine, but when I try to print this report multiple times like more than 50 or something it throws this error. I've spent weeks trying to figure out the solution. I've checked multiple times there's no recursive loop and now I'm just pulling my hairs. Any help would be highly appreciated.

Initialized at Form_Load:

ReportDocument cryRptEdu = new ReportDocument();
TableLogOnInfos crtableLogoninfosEdu = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfoEdu = new TableLogOnInfo();
ConnectionInfo crConnectionInfoEdu = new ConnectionInfo();

try
{
    cryRptEdu.Load(rptpathEdu);
}
catch (Exception x)
{
    KryptonMessageBox.Show(x.Message, "Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}

crConnectionInfoEdu.ServerName = Program.serverName;
crConnectionInfoEdu.DatabaseName = Program.dbName;
crConnectionInfoEdu.UserID = Program.saName;
crConnectionInfoEdu.Password = Program.pw;
Tables CrTables = cryRptEdu.Database.Tables;
foreach (Table CrTable in CrTables)
{
    crtableLogoninfoEdu = CrTable.LogOnInfo;
    crtableLogoninfoEdu.ConnectionInfo = crConnectionInfoEdu;
    CrTable.ApplyLogOnInfo(crtableLogoninfoEdu);
}

On Print Button:

cryRptEdu.SetParameterValue("percentage", percentage);
cryRptEdu.SetParameterValue("grades", grade);
cryRptEdu.SetParameterValue("position", position);
cryRptEdu.SetParameterValue("attendance", attendance);
cryRptEdu.SetParameterValue("midTermPercentage", midTermPercentage);
cryRptEdu.SetParameterValue("finalPercentage", finalPercentage);
cryRptEdu.SetParameterValue("aggregatePercentage", aggregatePercentage);
cryRptEdu.SetParameterValue("midTermGrade", midTermGrade);
cryRptEdu.SetParameterValue("finalGrade", finalGrade);
cryRptEdu.SetParameterValue("aggrgateGrade", aggregateGrade);
cryRptEdu.SetParameterValue("tl1", tl1);
cryRptEdu.SetParameterValue("tl2", tl2);
cryRptEdu.SetParameterValue("pl1", pl1);
cryRptEdu.SetParameterValue("pl2", pl2);
if (print)
    cryRptEdu.PrintToPrinter(1, true, 1, 1);
else
    cryRptEdu.ExportToDisk(ExportFormatType.PortableDocFormat, exportPath + ID + ".pdf");

While Printing:

Stack trace:


问:
Is here any method in HTML/CSS to transform both upper and lower letters to Capitalze?
https://www.w3schools.com/cssref/pr_text_text-transform.asp

From this link I have tried and it does transform text from lower case to Capitalize but it doesn't convert upper case into Capitalize.

For example, "HELLO" won't be converted into "Hello" using 'text-transform: capitalize;'.

Thanks in advance!

答:
try this .. that should work!:

```<code>.link { text-transform: lowercase; }
.link:first-letter { text-transform: uppercase; }
</code>```

(SRC: https://stackoverflow.com/a/10256138/7703846)

EDIT:

This isn't a clear solution, because there is no other way to fix ur problem via css, it will only uppercase the first letter for example... for a whole p / div element! If you want to use it on span you need to add display:block/display:inline-block too!
(thx to helb)

EDIT2: (Example)

```<code><!DOCTYPE html>
<html>
<head>
<style>

p.capitalize {
    text-transform: lowercase;
}
p.capitalize:first-letter {
    text-transform: uppercase;
}
</style>
</head>
<body>

<p class="capitalize">THIS IS SOME TEXT.</p>

</body>
</html>
</code>```

Body:
try this .. that should work!:

.link { text-transform: lowercase; }
.link:first-letter { text-transform: uppercase; }

(SRC: https://stackoverflow.com/a/10256138/7703846)

EDIT:

This isn't a clear solution, because there is no other way to fix ur problem via css, it will only uppercase the first letter for example... for a whole p / div element! If you want to use it on span you need to add display:block/display:inline-block too!
(thx to helb)

EDIT2: (Example)

<!DOCTYPE html>
<html>
<head>
<style>

p.capitalize {
    text-transform: lowercase;
}
p.capitalize:first-letter {
    text-transform: uppercase;
}
</style>
</head>
<body>

<p class="capitalize">THIS IS SOME TEXT.</p>

</body>
</html>


问:
Angularjs 1.5 component with typescript not working
I have created angularjs 1.5 component using typescript but it is not working and when I say it is not working it's binding not working at all. I can see the the data in my console when it fire $onInit function but it never puts any of that data on screen. This is my first shot at typescript and will really apprecuate if anyone can point me in right direction?

my component code is below

```<code>class Users implements ng.IComponentOptions {
    public bindings: any;
    public controller: any;
    public template: string;
    public templateUrl: string;
    public transclude: boolean;
    public controllerAs: string;

    constructor() {
        this.controller = UsersController;
        this.templateUrl = "Template/Index?feature=users&template=users";
        this.transclude = false;
        this.controllerAs = "vm";
    }
}

class UsersController {
    public name: string;
    public test: string;
    public Users: any[];

    static $inject: string[] = ["$http", "repository.user"];

    constructor(private $http: any, private RepositoryUser: any) {
    }

    public $onInit(): void {
        this.RepositoryUser.getUsers().then(function (response) {
            this.Users = response.data;
            console.dir(this.Users);
        });
    }

    public setUser(id: number, value: any): void {
        this.Users[this.Users.indexOf(value)] = value;

    }
}

angular.module("app.users").component("users", new Users());
</code>```

and my html is

```<code><div class="row">
    <div class="col-sm-12">
        <ng-form>
            <h2>Users</h2>

            <div ng-repeat="model in vm.Users track by $index" class="row top10">
                <div class="col-sm-8">
                    <a ui-sref="user-details({ id: model.id })"><strong ng-bind="model.name"></strong></a>
                </div>
                <div class="col-sm-4">
                    <button class="btn btn-default" type="button" ng-click="vm.selectedId=model.id">Select</button>
                </div>
            </div>

        </ng-form>
    </div>
</div>
</code>```

答:
Try using this syntax : https://blogs.infinitesquare.com/posts/web/creer-un-component-angularjs-en-typescript
The post is in French but you could just read the sample code.

Let me know if you have more questions.

Body:
I have created angularjs 1.5 component using typescript but it is not working and when I say it is not working it's binding not working at all. I can see the the data in my console when it fire $onInit function but it never puts any of that data on screen. This is my first shot at typescript and will really apprecuate if anyone can point me in right direction?

my component code is below

class Users implements ng.IComponentOptions {
    public bindings: any;
    public controller: any;
    public template: string;
    public templateUrl: string;
    public transclude: boolean;
    public controllerAs: string;

    constructor() {
        this.controller = UsersController;
        this.templateUrl = "Template/Index?feature=users&template=users";
        this.transclude = false;
        this.controllerAs = "vm";
    }
}

class UsersController {
    public name: string;
    public test: string;
    public Users: any[];

    static $inject: string[] = ["$http", "repository.user"];

    constructor(private $http: any, private RepositoryUser: any) {
    }

    public $onInit(): void {
        this.RepositoryUser.getUsers().then(function (response) {
            this.Users = response.data;
            console.dir(this.Users);
        });
    }

    public setUser(id: number, value: any): void {
        this.Users[this.Users.indexOf(value)] = value;

    }
}

angular.module("app.users").component("users", new Users());

and my html is

        <ng-form>

Users

                    <button class="btn btn-default" type="button" ng-click="vm.selectedId=model.id">Select</button>

        </ng-form>


问:
MVVM with multiple projects Xamarin
Hellow , i am a student and i am working on a project. It is a Xamarin native project (cross-platform). I Use MVVM. This was working perfect when i was using 1 shared project and my 3other projects (android,iOS,winphone). Now I have different projects for my shared code.

-Appname.Repositories

-Appname.Services

-Appname.Viewmodel

Now the problem is that when i start my app using an constructor in my viewmodel with an interface he is given me the next error :

//Constructor

```<code>public LoginViewModel(IMvxMessenger messenger, IUserDataService userDataService) : base(messenger)
        {
            _userDataService = userDataService;
        }
</code>```

Error:

MvvmCross.Platform.Exceptions.MvxException: Failed to construct and initialize ViewModel for type C_Tracker.Mobile.Domain.ViewModel.LoginViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information

InnerException :

MvvmCross.Platform.Exceptions.MvxIoCResolveException: Failed to resolve parameter for parameter userDataService of type IUserDataService

But when i use a constructor without this interface it is working.

```<code>public LoginViewModel(IMvxMessenger messenger) : base(messenger)
        {

        }
</code>```

Please help me.

答:
Probably you forgot about Dependencies Injection.
Add to Setup.cs something like this Mvx.RegisterType<IUserDataService, UserDataService>();
For more information about ServiceLocator please check https://github.com/MvvmCross/MvvmCross/wiki/service-location-and-inversion-of-control

Title: MVVM with multiple projects Xamarin

Body:
Hellow , i am a student and i am working on a project. It is a Xamarin native project (cross-platform). I Use MVVM. This was working perfect when i was using 1 shared project and my 3other projects (android,iOS,winphone). Now I have different projects for my shared code.

-Appname.Repositories

-Appname.Services

-Appname.Viewmodel

Now the problem is that when i start my app using an constructor in my viewmodel with an interface he is given me the next error :

//Constructor

public LoginViewModel(IMvxMessenger messenger, IUserDataService userDataService) : base(messenger)
        {
            _userDataService = userDataService;
        }

Error:

MvvmCross.Platform.Exceptions.MvxException: Failed to construct and initialize ViewModel for type C_Tracker.Mobile.Domain.ViewModel.LoginViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information

InnerException :

MvvmCross.Platform.Exceptions.MvxIoCResolveException: Failed to resolve parameter for parameter userDataService of type IUserDataService

But when i use a constructor without this interface it is working.

public LoginViewModel(IMvxMessenger messenger) : base(messenger)
        {

        }

Please help me.


问:
Delphi inspect shows {L at start of all Strings
I have this issue where if I inspect a string in Delphi it always starts with {L and ends with another }

So for an example, I create a variable tempStr that is a string. I do the following code:

```<code>tempStr := 'hello';
</code>```

When I put a break-point on the next line and stop there to inspect tempStr the yellow Delphi inspect window will show

```<code>{L"he"}
</code>```

This started happening recently, within the last 2 weeks. I was working on protobufs for java to delphi. At first I thought it was happening because I was passing a pointer to a pointer which was filling some of my variables with random characters but I've since moved onto another project with different code and I'm still getting this inspect issue.

Edit: my example was wrong, this issue ends up cutting off the last 3 characters of any of my strings, essentially the amount of characters that the {L  } take up. I have edited the above example to show exactly what I see upon inspection.

As far as Delphi addons go I have: DDev Extensions 2.83, CodeSiteExpress 5.1, Fast Report 4 and Mad Except 4.0.11

答: I too have had this problem not solved by any of the suggestions given.  In a project containing a significant number of packages there were one or two BPLs that would always show in the {L"he"} style.  These packages all had compiler warnings regarding implicitly imported units. Resolving these issues enabled strings to be displayed correctly in the debugger.</p>

Body:
I have this issue where if I inspect a string in Delphi it always starts with {L and ends with another }

So for an example, I create a variable tempStr that is a string. I do the following code:

tempStr := 'hello';

When I put a break-point on the next line and stop there to inspect tempStr the yellow Delphi inspect window will show

{L"he"}

This started happening recently, within the last 2 weeks. I was working on protobufs for java to delphi. At first I thought it was happening because I was passing a pointer to a pointer which was filling some of my variables with random characters but I've since moved onto another project with different code and I'm still getting this inspect issue.

Edit: my example was wrong, this issue ends up cutting off the last 3 characters of any of my strings, essentially the amount of characters that the {L  } take up. I have edited the above example to show exactly what I see upon inspection.

As far as Delphi addons go I have: DDev Extensions 2.83, CodeSiteExpress 5.1, Fast Report 4 and Mad Except 4.0.11


问:
Avoid dropdown menu close on click inside
I have a Twitter Bootstrap dropdown menu. As all Twitter Bootstrap users know, the dropdown menu closes on click (even clicking inside it).

To avoid this, I can easily attach a click event handler on the dropdown menu and simply add the famous event.stopPropagation().

```<code><ul class="nav navbar-nav">
  <li class="dropdown mega-dropdown">
    <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
      <i class="fa fa-list-alt"></i> Menu item 1
      <span class="fa fa-chevron-down pull-right"></span>
    </a>
    <ul class="dropdown-menu mega-dropdown-menu">
      <li>
        <div id="carousel" class="carousel slide" data-ride="carousel">
          <ol class="carousel-indicators">
            <li data-slide-to="0" data-target="#carousel"></li>
            <li class="active" data-slide-to="1" data-target="#carousel"></li>
          </ol>
          <div class="carousel-inner">
            <div class="item">
              <img alt="" class="img-rounded" src="img1.jpg">
            </div>
            <div class="item active">
              <img alt="" class="img-rounded" src="img2.jpg">
            </div>
          </div>
          <a data-slide="prev" role="button" href="#carousel"
             class="left carousel-control">
            <span class="glyphicon glyphicon-chevron-left"></span>
          </a>
          <a data-slide="next" role="button" href="#carousel"
             class="right carousel-control">
            <span class="glyphicon glyphicon-chevron-right"></span>
          </a>
        </div>
      </li>
    </ul>
  </li>
</ul>
</code>```

This looks easy and a very common behavior, however, and since carousel-controls (as well as carousel indicators) event handlers are delegated to the document object, the click event on these elements (prev/next controls, ...) will be “ignored”.

```<code>$('ul.dropdown-menu.mega-dropdown-menu').on('click', function(event){
    // The event won't be propagated up to the document NODE and
    // therefore delegated events won't be fired
    event.stopPropagation();
});
</code>```

Relying on Twitter Bootstrap dropdown hide/hidden events is not a solution for the following reasons:

The provided event object for both event handlers does not give reference to the clicked element

I don't have control over the dropdown menu content so adding a flag class or attribute is not possible

This fiddle is the normal behavior and this fiddle is with event.stopPropagation() added.

Update

Thanks to Roman for his answer. I also found an answer that you can find below.

答:
[Bootstrap 4 Alpha 6][Rails]
For rails developer, e.stopPropagation() will lead to undesirable behavior for link_to with data-method not equal to get since it will by default return all your request as get.

To remedy this problem, I suggest this solution, which is universal

```<code>$('.dropdown .dropdown-menu').on('click.bs.dropdown', function() {
  return $('.dropdown').one('hide.bs.dropdown', function() {
    return false;
  });
});
</code>```

$('.dropdown .dropdown-menu').on('click.bs.dropdown', function() {
  return $('.dropdown').one('hide.bs.dropdown', function() {
    return false;
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

<ul class="nav navbar-nav">
  <li class="dropdown mega-dropdown">

      <i class="fa fa-list-alt"></i> Menu item 1
      <span class="fa fa-chevron-down pull-right"></span>

    <ul class="dropdown-menu mega-dropdown-menu">
      <li>
        <div id="carousel" class="carousel slide" data-ride="carousel">
          <ol class="carousel-indicators">
            <li data-slide-to="0" data-target="#carousel"></li>
            <li class="active" data-slide-to="1" data-target="#carousel"></li>
          </ol>
          <div class="carousel-inner">
            <div class="item">
              <img alt="" class="img-rounded" src="img1.jpg">
            </div>
            <div class="item active">
              <img alt="" class="img-rounded" src="img2.jpg">
            </div>
          </div>

            <span class="glyphicon glyphicon-chevron-left"></span>

            <span class="glyphicon glyphicon-chevron-right"></span>

        </div>
      </li>
    </ul>
  </li>
</ul></code>```

ContentLicense: CC BY-SA 4.0

Body:
I have a Twitter Bootstrap dropdown menu. As all Twitter Bootstrap users know, the dropdown menu closes on click (even clicking inside it).

To avoid this, I can easily attach a click event handler on the dropdown menu and simply add the famous event.stopPropagation().

       Menu item 1

This looks easy and a very common behavior, however, and since carousel-controls (as well as carousel indicators) event handlers are delegated to the document object, the click event on these elements (prev/next controls, ...) will be “ignored”.

$('ul.dropdown-menu.mega-dropdown-menu').on('click', function(event){
    // The event won't be propagated up to the document NODE and
    // therefore delegated events won't be fired
    event.stopPropagation();
});

Relying on Twitter Bootstrap dropdown hide/hidden events is not a solution for the following reasons:

The provided event object for both event handlers does not give reference to the clicked element

I don't have control over the dropdown menu content so adding a flag class or attribute is not possible

This fiddle is the normal behavior and this fiddle is with event.stopPropagation() added.

Update

Thanks to Roman for his answer. I also found an answer that you can find below.

Body:
[Bootstrap 4 Alpha 6][Rails]
For rails developer, e.stopPropagation() will lead to undesirable behavior for link_to with data-method not equal to get since it will by default return all your request as get.

To remedy this problem, I suggest this solution, which is universal

$('.dropdown .dropdown-menu').on('click.bs.dropdown', function() {
  return $('.dropdown').one('hide.bs.dropdown', function() {
    return false;
  });
});

$('.dropdown .dropdown-menu').on('click.bs.dropdown', function() {
  return $('.dropdown').one('hide.bs.dropdown', function() {
    return false;
  });
});

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

<ul class="nav navbar-nav">
  <li class="dropdown mega-dropdown">
    <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
      <i class="fa fa-list-alt"></i> Menu item 1
      <span class="fa fa-chevron-down pull-right"></span>
    </a>
    <ul class="dropdown-menu mega-dropdown-menu">
      <li>
        <div id="carousel" class="carousel slide" data-ride="carousel">
          <ol class="carousel-indicators">
            <li data-slide-to="0" data-target="#carousel"></li>
            <li class="active" data-slide-to="1" data-target="#carousel"></li>
          </ol>
          <div class="carousel-inner">
            <div class="item">
              <img alt="" class="img-rounded" src="img1.jpg">
            </div>
            <div class="item active">
              <img alt="" class="img-rounded" src="img2.jpg">
            </div>
          </div>
          <a data-slide="prev" role="button" href="#carousel" class="left carousel-control">
            <span class="glyphicon glyphicon-chevron-left"></span>
          </a>
          <a data-slide="next" role="button" href="#carousel" class="right carousel-control">
            <span class="glyphicon glyphicon-chevron-right"></span>
          </a>
        </div>
      </li>
    </ul>
  </li>
</ul>


问:
Javascript - Display videoID using Youtube Data API
Trying to work through a program I currently have, where I am unable to view the videoID from a search query.

I have the following code at the moment:

```<code>function makeRequest() {
    var q = $('#query').val();
    var request = gapi.client.youtube.search.list({
    q: q,
    part: 'snippet',
    maxResults: 20
    });
}

request.execute(function(response) {
    $('#results').empty()
    var srchItems = response.result.items;
    $.each(srchItems, function(index, item){
        vidTitle = item.snippet.title;
        vidThumburl = item.snippet.thumbnails.default.url;
        vidThumbimg = '``````';
        vidID = item.id.videoId;
        $('#results').append('```' + vidTitle + vidThumbimg + vidID+ '```');
        })
    })
</code>```

Looking at the last two substantial lines, I thought that the code would be enough to display the videoID as plain text, however, that is not currently working.

Any advice on how to properly display the videoID would be greatly appreciated.

答:
As additional information, try using the sample code provided by Google.

Here is the code from this post (made some adjustment):

```<code><!doctype html>
<html>
  <head>
  <title>Search</title>
  </head>
  <body>
    <div id="buttons">
    <label> <input id="query" value='cats' type="text"/><button id="search-button"   onclick="keyWordsearch()">Search</button></label>
    <div id="container">
      <h1>Search Results</h1>
      <ul id="results"></ul>
    </div>
    <script>
     function keyWordsearch(){
        gapi.client.setApiKey('API_KEY');
        gapi.client.load('youtube', 'v3', function() {
                makeRequest();
        });
}
    function makeRequest() {
        var q = $('#query').val();
        var request = gapi.client.youtube.search.list({
                q: q,
                part: 'snippet',
                maxResults: 10
        });
        request.execute(function(response)  {
                $('#results').empty()
                var srchItems = response.result.items;
                $.each(srchItems, function(index, item) {
                vidTitle = item.snippet.title;
                vidThumburl =  item.snippet.thumbnails.default.url;
                vidID = "video ID : " + item.id.videoId
                vidThumbimg = '``````';

                $('#results').append('```' + vidTitle + vidThumbimg + vidID +'```');
        })
    })
}
  </script>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  <script src="https://apis.google.com/js/client.js?onload=googleApiClientReady">  </script>
</body>
</html>
</code>```

Result:

Hope this helps.

Body:
Trying to work through a program I currently have, where I am unable to view the videoID from a search query.

I have the following code at the moment:

function makeRequest() {
    var q = $('#query').val();
    var request = gapi.client.youtube.search.list({
    q: q,
    part: 'snippet',
    maxResults: 20
    });
}

request.execute(function(response) {
    $('#results').empty()
    var srchItems = response.result.items;
    $.each(srchItems, function(index, item){
        vidTitle = item.snippet.title;
        vidThumburl = item.snippet.thumbnails.default.url;
        vidThumbimg = '

';
        vidID = item.id.videoId;
        $('#results').append('
' + vidTitle + vidThumbimg + vidID+ '
');
        })
    })

Looking at the last two substantial lines, I thought that the code would be enough to display the videoID as plain text, however, that is not currently working.

Any advice on how to properly display the videoID would be greatly appreciated.

Body:
As additional information, try using the sample code provided by Google.

Here is the code from this post (made some adjustment):

<!doctype html>
<html>
  <head>
  <title>Search</title>
  </head>
  <body>
    <div id="buttons">
    <label> <input id="query" value='cats' type="text"/><button id="search-button"   onclick="keyWordsearch()">Search</button></label>
    <div id="container">
      <h1>Search Results</h1>
      <ul id="results"></ul>
    </div>
    <script>
     function keyWordsearch(){
        gapi.client.setApiKey('API_KEY');
        gapi.client.load('youtube', 'v3', function() {
                makeRequest();
        });
}
    function makeRequest() {
        var q = $('#query').val();
        var request = gapi.client.youtube.search.list({
                q: q,
                part: 'snippet',
                maxResults: 10
        });
        request.execute(function(response)  {
                $('#results').empty()
                var srchItems = response.result.items;
                $.each(srchItems, function(index, item) {
                vidTitle = item.snippet.title;
                vidThumburl =  item.snippet.thumbnails.default.url;
                vidID = "video ID : " + item.id.videoId
                vidThumbimg = '<pre><img id="thumb" src="'+vidThumburl+'" alt="No  Image Available." style="width:204px;height:128px"></pre>';

                $('#results').append('<pre>' + vidTitle + vidThumbimg + vidID +'</pre>');
        })
    })
}
  </script>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  <script src="https://apis.google.com/js/client.js?onload=googleApiClientReady">  </script>
</body>
</html>

Result:

Hope this helps.


问:
Script to copy collection of folders into subfolders seperated in parts
I have a collection of files sizing up to 33+GB ,

There are 415 folders of these files.

```<code>CD0001
CD0002
CD0003
CD0004
CD0005
CD0006
etc, etc...
</code>```

These are updated files/folders to a program that gets new updates every quarter, and its been racking up as you probably can tell.

We have them seperated in parts 1-27 , to divide them in about 800-1,5GB parts.
(started with about 1GB per part)

What I am hoping someone can help me create is a script that I can run, that will Copy the CD* folders, to their respective Parts folder, without me having to go into the folder every time and check that they are there.

ie.

```<code>See folder C:\temp\updates\CD0001
Looks for CD0001 in all parts folders (example \\\server1\program\part*\\*)
Removes Old CD* folder.
Copies in New CD* folder.
</code>```

When I started with the parts, there were gaps inbetween the CD's, as in there were CD0001-CD0255 and then CD0330-CD0880, etc.

And a few quarters later, they release CD0280, CD0281, CD0282, etc and they are too big.

So I needed to make a Part28 and then the continuance gets broken... :)

Its a SVN system aswell, so I cant move CD's from part2 to part3.

Any help is greatly appreciated!

答:
If anyone else stumbles upon this,

Made a quick one where I could have made the list better, but...

```<code>$Source = "<SourcePath>"

$Part01 = "Destination_Part01"
$Part02 = "Destination_Part02"
$Part03 = "Destination_Part03"
$Part04 = "Destination_Part04"
$Part05 = "Destination_Part05"
$Part06 = "Destination_Part06"
$Part07 = "Destination_Part07"
$Part08 = "Destination_Part08"
$Part09 = "Destination_Part09"
$Part10 = "Destination_Part10"
$Part11 = "Destination_Part11"
$Part12 = "Destination_Part12"
$Part13 = "Destination_Part13"
$Part14 = "Destination_Part14"
$Part15 = "Destination_Part15"
$Part16 = "Destination_Part16"
$Part17 = "Destination_Part17"
$Part18 = "Destination_Part18"
$Part19 = "Destination_Part19"
$Part20 = "Destination_Part20"
$Part21 = "Destination_Part21"
$Part22 = "Destination_Part22"
$Part23 = "Destination_Part23"
$Part24 = "Destination_Part24"
$Part25 = "Destination_Part25"
$Part26 = "Destination_Part26"
$Part27 = "Destination_Part27"

$PartList ($Part01,$Part02,$Part03,$Part04,$Part05,$Part06,$Part07,$Part08,$Part09,$Part10,$Part11,$Part12,$Part13,$Part14,$Part15,$Part16,$Part17,$Part18,$Part19,$Part20,$Part21,$Part22,$Part23,$Part24,$Part25,$Part26,$Part27)

ForEach ($Item in $PartList) {
$CDList = get-childitem -Directory -name $item
$PartPath = $item
ForEach ($Item in $CDList) {
    If (Test-Path "$PartPath\$Item") {
        If (Test-Path "$Source\$Item") {
            Write-Host "Replace is True"
            Write-host "Copying $Source\$Item to $PartPath\$Item"
            Robocopy "$Source\$Item" "$PartPath\$Item" /E /Purge /NP /TEE /FFT /R:1 /W:1 /Log:"C:\temp\Logs\$Item.log"
            write-host "$Source\$Item Processed"
            move-Item -Path "$Source\$Item" "$Source\Processed"
            }
        }
    }
}
</code>```

Body:
I have a collection of files sizing up to 33+GB ,

There are 415 folders of these files.

CD0001
CD0002
CD0003
CD0004
CD0005
CD0006
etc, etc...

These are updated files/folders to a program that gets new updates every quarter, and its been racking up as you probably can tell.

We have them seperated in parts 1-27 , to divide them in about 800-1,5GB parts.
(started with about 1GB per part)

What I am hoping someone can help me create is a script that I can run, that will Copy the CD* folders, to their respective Parts folder, without me having to go into the folder every time and check that they are there.

ie.

See folder C:\temp\updates\CD0001
Looks for CD0001 in all parts folders (example \\\server1\program\part*\\*)
Removes Old CD* folder.
Copies in New CD* folder.

When I started with the parts, there were gaps inbetween the CD's, as in there were CD0001-CD0255 and then CD0330-CD0880, etc.

And a few quarters later, they release CD0280, CD0281, CD0282, etc and they are too big.

So I needed to make a Part28 and then the continuance gets broken... :)

Its a SVN system aswell, so I cant move CD's from part2 to part3.

Any help is greatly appreciated!

Body:
If anyone else stumbles upon this,

Made a quick one where I could have made the list better, but...

$Source = "<SourcePath>"

$Part01 = "Destination_Part01"
$Part02 = "Destination_Part02"
$Part03 = "Destination_Part03"
$Part04 = "Destination_Part04"
$Part05 = "Destination_Part05"
$Part06 = "Destination_Part06"
$Part07 = "Destination_Part07"
$Part08 = "Destination_Part08"
$Part09 = "Destination_Part09"
$Part10 = "Destination_Part10"
$Part11 = "Destination_Part11"
$Part12 = "Destination_Part12"
$Part13 = "Destination_Part13"
$Part14 = "Destination_Part14"
$Part15 = "Destination_Part15"
$Part16 = "Destination_Part16"
$Part17 = "Destination_Part17"
$Part18 = "Destination_Part18"
$Part19 = "Destination_Part19"
$Part20 = "Destination_Part20"
$Part21 = "Destination_Part21"
$Part22 = "Destination_Part22"
$Part23 = "Destination_Part23"
$Part24 = "Destination_Part24"
$Part25 = "Destination_Part25"
$Part26 = "Destination_Part26"
$Part27 = "Destination_Part27"

$PartList ($Part01,$Part02,$Part03,$Part04,$Part05,$Part06,$Part07,$Part08,$Part09,$Part10,$Part11,$Part12,$Part13,$Part14,$Part15,$Part16,$Part17,$Part18,$Part19,$Part20,$Part21,$Part22,$Part23,$Part24,$Part25,$Part26,$Part27)

ForEach ($Item in $PartList) {
$CDList = get-childitem -Directory -name $item
$PartPath = $item
ForEach ($Item in $CDList) {
    If (Test-Path "$PartPath\$Item") {
        If (Test-Path "$Source\$Item") {
            Write-Host "Replace is True"
            Write-host "Copying $Source\$Item to $PartPath\$Item"
            Robocopy "$Source\$Item" "$PartPath\$Item" /E /Purge /NP /TEE /FFT /R:1 /W:1 /Log:"C:\temp\Logs\$Item.log"
            write-host "$Source\$Item Processed"
            move-Item -Path "$Source\$Item" "$Source\Processed"
            }
        }
    }
}


答:
It depends on the data in your string and the way it is stored. If your Base64 encoded string is stored as a Base64 encoded string, the length is the same as the size on disk. If not, you have to decode it

I found a solution (although it seems a bit icky) here

```<code> function checkLength() {
    var countMe = document.getElementById("someText").value
    var escapedStr = encodeURI(countMe)
    if (escapedStr.indexOf("%") != -1) {
        var count = escapedStr.split("%").length - 1
        if (count == 0) count++  //perverse case; can't happen with real UTF-8
        var tmp = escapedStr.length - (count * 3)
        count = count + tmp
    } else {
        count = escapedStr.length
    }
    alert(escapedStr + ": size is " + count)
 }
</code>```

Title: How can I estimate the disk size of a string with JavaScript?

Body:
I need to try to estimate the DISK size of a text string (which could be raw text or a Base64 encoded string for an image/audio/etc) in JavaScript. I'm not sure how to estimate this. The only thing when Googling i can find is .length so i thought maybe someone on StackOverflow might know...

The reason i need to know is i have a localStorage script that needs (or would love to have) the ability to check when a user is nearing his 5MB (or 10MB in IE) quota and prompt them to increase the max size for the domain. So, if a user hits, lets say, 4.5MBs of data it'd prompt with

You're nearing your browsers 5MB data cap. Please increase your max data by... [instructions on increasing it for the browser]

Body:
It depends on the data in your string and the way it is stored. If your Base64 encoded string is stored as a Base64 encoded string, the length is the same as the size on disk. If not, you have to decode it

I found a solution (although it seems a bit icky) here

 function checkLength() {
    var countMe = document.getElementById("someText").value
    var escapedStr = encodeURI(countMe)
    if (escapedStr.indexOf("%") != -1) {
        var count = escapedStr.split("%").length - 1
        if (count == 0) count++  //perverse case; can't happen with real UTF-8
        var tmp = escapedStr.length - (count * 3)
        count = count + tmp
    } else {
        count = escapedStr.length
    }
    alert(escapedStr + ": size is " + count)
 }


问:
Google Analytics Campaign tracking in Android App
We have implemented Google Analytics Campaign tracking code for our Android App. Everything looks fine except the users count.
Google Analytics Results

In the image you can see that New Users showing as zero and sessions showing the count. What could be the reason for new users not showing the count?

Here is my code:

```<code> <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.CampaignTrackingService"
        android:enabled="true"
        android:exported="false" />
</code>```

```<code>mTracker.send(new HitBuilders.ScreenViewBuilder()
            .setCampaignParamsFromUrl(campaignData).build());
</code>```

答:
Are your campaigns targeting new users? If not, the new users metric possibly will not increase. Another factor to not see new users in your campaigns might be that there was already tracking code installed in your app and you now added the campaign tracking feature(meaning that these users are recognises as returning by GA). That is because the ga:newUsers is described in GA as:
 The number of sessions marked as a user's first sessions
So if your campaign does not target new users this is to be expected.

Body:
We have implemented Google Analytics Campaign tracking code for our Android App. Everything looks fine except the users count.
Google Analytics Results

In the image you can see that New Users showing as zero and sessions showing the count. What could be the reason for new users not showing the count?

Here is my code:

 <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.CampaignTrackingService"
        android:enabled="true"
        android:exported="false" />

mTracker.send(new HitBuilders.ScreenViewBuilder()
            .setCampaignParamsFromUrl(campaignData).build());


问:
css not loading property using express .ejs nodejs
Good evening everyone,

I would appreciate any help.

I got these two routes:

```<code>app.get('/', function(req,res){

        res.render('index');
});

app.get('/registration/add', function(req,res){

        res.render('clientRegistration');
});
</code>```

and this is part of the server:

```<code>app.use( express.static(path.join( __dirname, './client/static/')));
app.use(body_parser.urlencoded());
app.set( "views", path.join(__dirname, "./client/views/"));
app.set( "view engine", 'ejs');
</code>```

Directory is:

```<code>MyApp/
    client/
        static/
            registration.css
            styles.css
        views/
            index.ejs
            clientRegistration.ejs
</code>```

On my index.ejs, I have:
    link rel="stylesheet" type="text/css" href="styles.css" which loads the .css file perfectly. But when I click the link:
    a href="/registration/add"> on index.ejs,
it takes me to the clientRegistration.ejs page but the registration.css does not load even though I have:
    link rel="stylesheet" type="text/css" href="registration.css"

What am I doing wrong?

Thanks for your time.

答:
Maybe missing /  is a problem

```<code><link rel="stylesheet" type="text/css" href="/registration.css">
</code>```

Body:
Good evening everyone,

I would appreciate any help.

I got these two routes:

app.get('/', function(req,res){

        res.render('index');
});

app.get('/registration/add', function(req,res){

        res.render('clientRegistration');
});

and this is part of the server:

app.use( express.static(path.join( __dirname, './client/static/')));
app.use(body_parser.urlencoded());
app.set( "views", path.join(__dirname, "./client/views/"));
app.set( "view engine", 'ejs');

Directory is:

MyApp/
    client/
        static/
            registration.css
            styles.css
        views/
            index.ejs
            clientRegistration.ejs

On my index.ejs, I have:
    link rel="stylesheet" type="text/css" href="styles.css" which loads the .css file perfectly. But when I click the link:
    a href="/registration/add"> on index.ejs,
it takes me to the clientRegistration.ejs page but the registration.css does not load even though I have:
    link rel="stylesheet" type="text/css" href="registration.css"

What am I doing wrong?

Thanks for your time.

Body:
Maybe missing /  is a problem

<link rel="stylesheet" type="text/css" href="/registration.css">


问:
matlab - line equation to 2D matrix with values of 1 and 0
As the title says, I want to covert a line(or any equation) to 2D matrix.

For example: If I have a line equation y = x, then I want it to be like:

```<code>0 0 0 0 0 1
0 0 0 0 1 0
0 0 0 1 0 0
0 0 1 0 0 0
0 1 0 0 0 0
1 0 0 0 0 0
</code>```

and the length of rows and columns can be variable.

Is there a function or method to implement that?

答:
Given x and y coordinates, how to fill in a matrix with those coordinates? As it is said, just do it in a for loop, or use the "sub2ind" function.

```<code>% x,y coordinates
x=0:.01:30;
y=10*sin(2*pi*.1*x);

% add offset so that (x,y)-coordinates are always  positive
x=x+abs(min(x))+1;
y=y+abs(min(y))+1;

figure,plot(x,y,'.');axis tight

x=ceil(x); y=ceil(y);
im=zeros(max(y),max(x));
ind=sub2ind(size(im),y,x);
im(ind)=1;

figure,imagesc(im),axis image, axis xy;colormap gray;axis tight
xlabel('x'); ylabel('y')
</code>```

Body:
As the title says, I want to covert a line(or any equation) to 2D matrix.

For example: If I have a line equation y = x, then I want it to be like:

0 0 0 0 0 1
0 0 0 0 1 0
0 0 0 1 0 0
0 0 1 0 0 0
0 1 0 0 0 0
1 0 0 0 0 0

and the length of rows and columns can be variable.

Is there a function or method to implement that?

Body:
Given x and y coordinates, how to fill in a matrix with those coordinates? As it is said, just do it in a for loop, or use the "sub2ind" function.

% x,y coordinates
x=0:.01:30;
y=10*sin(2*pi*.1*x);

% add offset so that (x,y)-coordinates are always  positive
x=x+abs(min(x))+1;
y=y+abs(min(y))+1;

figure,plot(x,y,'.');axis tight

x=ceil(x); y=ceil(y);
im=zeros(max(y),max(x));
ind=sub2ind(size(im),y,x);
im(ind)=1;

figure,imagesc(im),axis image, axis xy;colormap gray;axis tight
xlabel('x'); ylabel('y')


问:
Is Node's Crypto module blocking even for methods that are not defined as sync
Could someone please give me some clarity if Node's Crypto module is blocking or not?  From what I thought I understood, some core modules can yield to a separate thread in c++.

I'm mainly interested in:

crypto.createHmac

crypto.createSign

crypto.createVerify

If it does process on a separate thread, then fine.  If not, then I might have to think about using the cluster module.  I'm attempting to avoid blocking the main event loop.

Here is a trivial example of how I would implement crypto.createHmac.

```<code>function createHmac(algo, secret, data, callback) {
  var cryptoStream = crypto.createHmac(algo, secret);

  // Emitters
  cryptoStream
    .on('error', function (err) {
      return callback(err);
    });

  // Write the data
  cryptoStream.write(data, 'utf8', function(){
    cryptoStream.end();
    return callback(null, cryptoHmacStream.read());
  });
}
</code>```

答:
To contradict the previous answer, as far as I understand, the crypto.createHmac method does all computation on the main thread in C++, but this is still the same thread as the event loop.

Your snippet is not actually asynchronous and not actually non-blocking. The interface only looks asynchronous. It will still use up time on your event loop.

For truly asynchronous crypto methods and better throughput, use crypto-async.

Body:
Could someone please give me some clarity if Node's Crypto module is blocking or not?  From what I thought I understood, some core modules can yield to a separate thread in c++.

I'm mainly interested in:

crypto.createHmac

crypto.createSign

crypto.createVerify

If it does process on a separate thread, then fine.  If not, then I might have to think about using the cluster module.  I'm attempting to avoid blocking the main event loop.

Here is a trivial example of how I would implement crypto.createHmac.

function createHmac(algo, secret, data, callback) {
  var cryptoStream = crypto.createHmac(algo, secret);

  // Emitters
  cryptoStream
    .on('error', function (err) {
      return callback(err);
    });

  // Write the data
  cryptoStream.write(data, 'utf8', function(){
    cryptoStream.end();
    return callback(null, cryptoHmacStream.read());
  });
}


问:
How to fix NodeJS underutilizing CPU Cores?
According to this page Go vs Node.js, Node.js is not showing to be taking full advantage of CPU cores when running cpu-intensive code.

If I use virtualization and simply add more Node.js instances, will I achieve the same performance as Go? I suppose there still will be overheads and one won't be able to achieve the same performance.

答:
Multiple processes will do. For 4 cpus/threads you need 4 Node.js processes to make use of them. That requires a workload that can be split between processes though. </p>

<p>Node.js provides the Cluster module to distribute socket connections between multiple worker processes which may help in some workloads, but I doubt this would help any of the benchmark workloads. </p>

Body:
Multiple processes will do. For 4 cpus/threads you need 4 Node.js processes to make use of them. That requires a workload that can be split between processes though.

Node.js provides the Cluster module to distribute socket connections between multiple worker processes which may help in some workloads, but I doubt this would help any of the benchmark workloads.


问:
Java Regular Expression to search in String
How will you proceed the following string:

```<code>[p('WHITE'),p('GREEN'),p('GREEN','RED'),p('GREEN','YELLOW'),p('GREEN','YELLOW','RED')]
</code>```

to get a List of Nodes as suggested in the answers.

答:
It depends on how complex the expressions can get. I would definitely write a proper parser for it, since only then can I be confident to have done it properly. Plus, I will parse the string into an abstract syntax tree so that at the end I will automatically have a nicely modeled tree of objects:</p>

```<code>class Node { ... }

class StringLiteral extends Node {
  public String getValue() { ... }
}

class Term extends Node {
  public String getName() { ... }
  public int getArity() { ... }
  public Node getArgument(int index) { ... }
}
</code>```

Body:
How will you proceed the following string:

[p('WHITE'),p('GREEN'),p('GREEN','RED'),p('GREEN','YELLOW'),p('GREEN','YELLOW','RED')]

to get a List of Nodes as suggested in the answers.

Body:
It depends on how complex the expressions can get. I would definitely write a proper parser for it, since only then can I be confident to have done it properly. Plus, I will parse the string into an abstract syntax tree so that at the end I will automatically have a nicely modeled tree of objects:

class Node { ... }

class StringLiteral extends Node {
  public String getValue() { ... }
}

class Term extends Node {
  public String getName() { ... }
  public int getArity() { ... }
  public Node getArgument(int index) { ... }
}


问:
How to read environment variables in TypeSafe config in scala?
I am trying to read the environment variables in typesafe config in scala, configuring the slick database. Here is what I tried

```<code>remote_test_db = {
  dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
  properties = {
    driver = "org.postgresql.Driver"
    url = ${?REMOTE_TEST_DB_URL}
    user = ${?REMOTE_TEST_DB_USERNAME}
    password = ${?REMOTE_TEST_DB_PASSWORD}
  }
  connectionPool = disabled
  keepAliveConnection = true
}
</code>```

But I get this error:

```<code>Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.flyhomes.mls_pull.dump.MlsProvider.main(MlsProvider.scala)
Caused by: com.typesafe.config.ConfigException$NotResolved: need to Config#resolve(), see the API docs for Config#resolve(); substitution not resolved: ConfigConcatenation(${?REMOTE_TEST_DB_USERNAME})
    at com.typesafe.config.impl.ConfigConcatenation.notResolved(ConfigConcatenation.java:51)
    at com.typesafe.config.impl.ConfigConcatenation.valueType(ConfigConcatenation.java:58)
    at slick.util.ConfigExtensionMethods$$anonfun$slick$util$ConfigExtensionMethods$$toProps$1$1.apply(GlobalConfig.scala:71)
    at slick.util.ConfigExtensionMethods$$anonfun$slick$util$ConfigExtensionMethods$$toProps$1$1.apply(GlobalConfig.scala:69)
    at scala.collection.Iterator$class.foreach(Iterator.scala:893)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at slick.util.ConfigExtensionMethods$.slick$util$ConfigExtensionMethods$$toProps$1(GlobalConfig.scala:69)
    at slick.util.ConfigExtensionMethods$.toProperties$extension(GlobalConfig.scala:78)
    at slick.util.ConfigExtensionMethods$.getPropertiesOr$extension(GlobalConfig.scala:64)
    at slick.util.ConfigExtensionMethods$.getPropertiesOpt$extension(GlobalConfig.scala:84)
    at slick.jdbc.DataSourceJdbcDataSource$.forConfig(JdbcDataSource.scala:90)
    at slick.jdbc.DataSourceJdbcDataSource$.forConfig(JdbcDataSource.scala:86)
    at slick.jdbc.JdbcDataSource$.forConfig(JdbcDataSource.scala:48)
    at slick.jdbc.JdbcBackend$DatabaseFactoryDef$class.forConfig(JdbcBackend.scala:288)
    at slick.jdbc.JdbcBackend$$anon$3.forConfig(JdbcBackend.scala:33)
    at com.flyhomes.mls_pull.Databases$.remoteTestDb$lzycompute(Databases.scala:21)
    at com.flyhomes.mls_pull.Databases$.remoteTestDb(Databases.scala:21)
    at com.flyhomes.mls_pull.dump.MlsProvider$.<init>(MlsProvider.scala:18)
    at com.flyhomes.mls_pull.dump.MlsProvider$.<clinit>(MlsProvider.scala)
    ... 1 more
</code>```

How do I access the environment variables here?

答:
From the exception it seems that you need to call resolve - line 3: need to Config#resolve(). This will actually substitute every variable. Maybe this will help:

val config = ??? // load config here
config.resolve() // force the substitution of variables
```

Quoted from the docs of the class:

Resolving substitutions

Substitutions are the ${foo.bar} syntax in config files, described in the specification. Resolving substitutions replaces these references with real values.

Before using a Config it's necessary to call resolve() to handle substitutions (though ConfigFactory.load() and similar methods will do the resolve for you already).

Body:
I am trying to read the environment variables in typesafe config in scala, configuring the slick database. Here is what I tried

remote_test_db = {
  dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
  properties = {
    driver = "org.postgresql.Driver"
    url = ${?REMOTE_TEST_DB_URL}
    user = ${?REMOTE_TEST_DB_USERNAME}
    password = ${?REMOTE_TEST_DB_PASSWORD}
  }
  connectionPool = disabled
  keepAliveConnection = true
}

But I get this error:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.flyhomes.mls_pull.dump.MlsProvider.main(MlsProvider.scala)
Caused by: com.typesafe.config.ConfigException$NotResolved: need to Config#resolve(), see the API docs for Config#resolve(); substitution not resolved: ConfigConcatenation(${?REMOTE_TEST_DB_USERNAME})
    at com.typesafe.config.impl.ConfigConcatenation.notResolved(ConfigConcatenation.java:51)
    at com.typesafe.config.impl.ConfigConcatenation.valueType(ConfigConcatenation.java:58)
    at slick.util.ConfigExtensionMethods$$anonfun$slick$util$ConfigExtensionMethods$$toProps$1$1.apply(GlobalConfig.scala:71)
    at slick.util.ConfigExtensionMethods$$anonfun$slick$util$ConfigExtensionMethods$$toProps$1$1.apply(GlobalConfig.scala:69)
    at scala.collection.Iterator$class.foreach(Iterator.scala:893)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at slick.util.ConfigExtensionMethods$.slick$util$ConfigExtensionMethods$$toProps$1(GlobalConfig.scala:69)
    at slick.util.ConfigExtensionMethods$.toProperties$extension(GlobalConfig.scala:78)
    at slick.util.ConfigExtensionMethods$.getPropertiesOr$extension(GlobalConfig.scala:64)
    at slick.util.ConfigExtensionMethods$.getPropertiesOpt$extension(GlobalConfig.scala:84)
    at slick.jdbc.DataSourceJdbcDataSource$.forConfig(JdbcDataSource.scala:90)
    at slick.jdbc.DataSourceJdbcDataSource$.forConfig(JdbcDataSource.scala:86)
    at slick.jdbc.JdbcDataSource$.forConfig(JdbcDataSource.scala:48)
    at slick.jdbc.JdbcBackend$DatabaseFactoryDef$class.forConfig(JdbcBackend.scala:288)
    at slick.jdbc.JdbcBackend$$anon$3.forConfig(JdbcBackend.scala:33)
    at com.flyhomes.mls_pull.Databases$.remoteTestDb$lzycompute(Databases.scala:21)
    at com.flyhomes.mls_pull.Databases$.remoteTestDb(Databases.scala:21)
    at com.flyhomes.mls_pull.dump.MlsProvider$.<init>(MlsProvider.scala:18)
    at com.flyhomes.mls_pull.dump.MlsProvider$.<clinit>(MlsProvider.scala)
    ... 1 more

How do I access the environment variables here?

Body:
From the exception it seems that you need to call resolve - line 3: need to Config#resolve(). This will actually substitute every variable. Maybe this will help:

val config = ??? // load config here
config.resolve() // force the substitution of variables

Quoted from the docs of the class:

Resolving substitutions

Substitutions are the ${foo.bar} syntax in config files, described in the specification. Resolving substitutions replaces these references with real values.

Before using a Config it's necessary to call resolve() to handle substitutions (though ConfigFactory.load() and similar methods will do the resolve for you already).


问:
Spinner with transparent background?
I have a spinner with a white background which is animated through a keyframe. So, having this code pen, how could I remove this color to "smt-spinner-inner-circle" class without affecting the original desing? If the background is removed, the portion is visible. I have tried to apply a clip but the result is not the expected.

http://codepen.io/anon/pen/WpagJN

Html:

```<code><div class="smt-spinner-circle">
   <div class="smt-spinner"></div>
   <div class="smt-spinner-inner-circle"></div>
</div>
</code>```

To sum up, I need the background of the spinner transparent, not red, since the website will be different backgrounds depending on the page you are (grey, white, etc)...

答:
Your background-color hides triangle that rotates, so simply change background: white to match your background color.

body{
  background: red;
}
.smt-spinner-circle {
  width: 50px;
  height: 50px;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: auto;
  background: blue;
  border-radius: 50%;
}

.smt-spinner-inner-circle {
  width: 92%;
  height: 92%;
  background: red;
  border-radius: 50%;
  margin: auto;
  vertical-align: middle;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
}

.smt-spinner {
  height: 0;
  width: 0;
  border-radius: 50%;
  border-right: 25px solid rgba(255,255,255,0.6);
  border-top: 25px solid transparent;
  border-left: 25px solid transparent;
  border-bottom: 25px solid transparent;
  animation: rotate--spinner 1.6s infinite;
}

@keyframes rotate--spinner {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="smt-spinner-circle">
   <div class="smt-spinner"></div>
   <div class="smt-spinner-inner-circle"></div>
</div></code>```

Title: Spinner with transparent background?

Body:
I have a spinner with a white background which is animated through a keyframe. So, having this code pen, how could I remove this color to "smt-spinner-inner-circle" class without affecting the original desing? If the background is removed, the portion is visible. I have tried to apply a clip but the result is not the expected.

http://codepen.io/anon/pen/WpagJN

Html:

To sum up, I need the background of the spinner transparent, not red, since the website will be different backgrounds depending on the page you are (grey, white, etc)...

Body:
Your background-color hides triangle that rotates, so simply change background: white to match your background color.

body{
  background: red;
}
.smt-spinner-circle {
  width: 50px;
  height: 50px;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: auto;
  background: blue;
  border-radius: 50%;
}

.smt-spinner-inner-circle {
  width: 92%;
  height: 92%;
  background: red;
  border-radius: 50%;
  margin: auto;
  vertical-align: middle;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
}

.smt-spinner {
  height: 0;
  width: 0;
  border-radius: 50%;
  border-right: 25px solid rgba(255,255,255,0.6);
  border-top: 25px solid transparent;
  border-left: 25px solid transparent;
  border-bottom: 25px solid transparent;
  animation: rotate--spinner 1.6s infinite;
}

@keyframes rotate--spinner {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}

<div class="smt-spinner-circle">
   <div class="smt-spinner"></div>
   <div class="smt-spinner-inner-circle"></div>
</div>


问:
How do I implement UITextFieldDelegate
I'm still learning swift and I was curious on how I implement UITextFieldDelagate. I was also curious on how I should hide the Keyboard(FirstResponder) when it sees that I've finished editing.</p>

答:
Your ViewController should be an UITextFieldDelegate. You then set the current ViewController as the delegate of the textField, in this case in viewDidLoad().

Implement textFieldShouldReturn so the textField delegates the return task (textFieldShouldReturn) to the ViewController. In this method call resignFirstResponder, this way the keyboard will disappear. Example:

```<code>import UIKit

class ViewController: UIViewController, UITextFieldDelegate {

    @IBOutlet weak var someTextField: UITextField!

    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        return true
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        someTextField.delegate = self

    }
}
</code>```

Title: How do I implement UITextFieldDelegate

Body:
Your ViewController should be an UITextFieldDelegate. You then set the current ViewController as the delegate of the textField, in this case in viewDidLoad().

Implement textFieldShouldReturn so the textField delegates the return task (textFieldShouldReturn) to the ViewController. In this method call resignFirstResponder, this way the keyboard will disappear. Example:

import UIKit

class ViewController: UIViewController, UITextFieldDelegate {

    @IBOutlet weak var someTextField: UITextField!

    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        textField.resignFirstResponder()
        return true
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        someTextField.delegate = self

    }
}


问:
List assignment
I have lists like this,

```<code>a=['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
b=['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
c=['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']
</code>```

Here I am trying to replace each element of list 'a' one by one with the element of list 'c'.
I tried this code:

```<code>for i in range(len(a)):
    a[i]=c[i]
    print a
    a=['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
</code>```

With this code I am getting correct output which is:

```<code>['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 1']
</code>```

But when I replaced the last statement(assigning) as

```<code>for i in range(len(a)):
    a[i]=c[i]
    print a
    a=b
</code>```

list 'b' also updating. How can i achieve this with out assigning the entire list directly.

答:
Really unsure of what it is you are asking but seems to me you are trying to achieve something like:

```<code>for i in range(len(a)):
    a[i]=c[i] # change only the specified itemnr of list a with the same itemnr of list c.
    print a # prints (as you've seen and mentioned to be correct: list a with one of its items replaced by an item of list c)
    a[i]=b[i] # Since list a[i] has been set to c[i] earlier in the loop doesn't mean it can't be changed again in the same loop.
    print a
</code>```

Output:

```<code>['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 1']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
</code>```

Or, if you want to process list b similar to a you could also simply do (since list b has the exact same length as a):

```<code>for i in range(len(a)):
        a[i]=c[i]
        print a
        b[i]=c[i]
        print b
</code>```

Output:

```<code>['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']
</code>```

Or you could do:

```<code>for x in [a,b]:
    for i in range(len(x)):
        x[i]=c[i]
        print(x)
</code>```

Output:

```<code>['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']
</code>```

Title: List assignment

Body:
I have lists like this,

a=['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
b=['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
c=['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']

Here I am trying to replace each element of list 'a' one by one with the element of list 'c'.
I tried this code:

for i in range(len(a)):
    a[i]=c[i]
    print a
    a=['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']

With this code I am getting correct output which is:

['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 1']

But when I replaced the last statement(assigning) as

for i in range(len(a)):
    a[i]=c[i]
    print a
    a=b

list 'b' also updating. How can i achieve this with out assigning the entire list directly.

Body:
Really unsure of what it is you are asking but seems to me you are trying to achieve something like:

for i in range(len(a)):
    a[i]=c[i] # change only the specified itemnr of list a with the same itemnr of list c.
    print a # prints (as you've seen and mentioned to be correct: list a with one of its items replaced by an item of list c)
    a[i]=b[i] # Since list a[i] has been set to c[i] earlier in the loop doesn't mean it can't be changed again in the same loop.
    print a

Output:

['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 1']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']

Or, if you want to process list b similar to a you could also simply do (since list b has the exact same length as a):

for i in range(len(a)):
        a[i]=c[i]
        print a
        b[i]=c[i]
        print b

Output:

['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']

Or you could do:

for x in [a,b]:
    for i in range(len(x)):
        x[i]=c[i]
        print(x)

Output:

['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']
['name test', 'maximum-net-data-rate 4294967295', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 0', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967295', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 0']
['name test', 'maximum-net-data-rate 4294967296', 'minimum-expected-throughput 1', 'maximum-gamma-data-rate 4294967296', 'minimum-gamma-data-rate 1']