问:
Cant figure out IF(number) in Google Sheets macro to hide rows with a zero value
I'm brand new at this, so I may be way off base here. this is my code:

```<code>function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("To Order");
  var maxRows = sheet.getMaxRows();

  //show all the rows
  sheet.showRows(1, maxRows);

  //get data from clumn B
  var data = sheet.getRange('B:B').getValues();

  //iterate over all rows
  for(var i=0; i< data.length; i++){
    //compare first character, if asterisk, then hide row
    if(Number == "0"){
      sheet.hideRows(i+1);
    }
  }
}
</code>```

My trouble seems to be that the if(number) isn't only selecting cells with 0 to hide. please help!

答:
The code in the question compares an undefined variable called Number with "0" using the abstract equality comparator. This comparison always will return false.

Instead of Number, use data[i][0].

Body:
I'm brand new at this, so I may be way off base here. this is my code:

function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("To Order");
  var maxRows = sheet.getMaxRows();

  //show all the rows
  sheet.showRows(1, maxRows);

  //get data from clumn B
  var data = sheet.getRange('B:B').getValues();

  //iterate over all rows
  for(var i=0; i< data.length; i++){
    //compare first character, if asterisk, then hide row
    if(Number == "0"){
      sheet.hideRows(i+1);
    }
  }
}

My trouble seems to be that the if(number) isn't only selecting cells with 0 to hide. please help!


来源: stackexchange

问:
Trying to form a half triangle using a for loop, nothing is printing out
This is a practice exam question I was given to study for my java exam approaching...I was given the main method and cannot change the input, only alter the two other methods and their code. I need to print out

```<code>     &
    &&
   &&&
  &&&&
 &&&&&
&&&&&&
</code>```

I think I have written my for loop wrong to create the blank spaces, I cannot seem to get this write with the main method I have been give, any ideas?

```<code>public static void main(String[] args) {
    int size = 6;
    char c = '&';
    for (int i = 1; i < size + 1; i++) {
        drawBlanks(size, size - i);
        drawChars(size, size - i, c);
        System.out.println();
    }
    System.out.println();

}

public static void drawChars(int size, int i, char c) {

    for (int j = size; j < 1; j--) {
        System.out.print(c);
    }

}

public static void drawBlanks(int size, int i) {

    for (int k = 0; k <= i; k++) {
        System.out.print(" ");
    }
}
</code>```

答:
Alternative solution within one loop:</p>

```<code>public class Main {

    public static void main(String[] args) {
        int rowCount = 10;
        int whiteSpaceCount = rowCount - 1;

        for (int i = 0; i < rowCount; i++) {
            for (int j = 0; j < rowCount; j++) {
                char ch = ' ';
                if (j >= whiteSpaceCount)
                    ch = '&';
                System.out.print(ch);
            }
            System.out.println();
            whiteSpaceCount = rowCount - (i + 2);
        }
    }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
This is a practice exam question I was given to study for my java exam approaching...I was given the main method and cannot change the input, only alter the two other methods and their code. I need to print out

     &
    &&
   &&&
  &&&&
 &&&&&
&&&&&&

I think I have written my for loop wrong to create the blank spaces, I cannot seem to get this write with the main method I have been give, any ideas?

public static void main(String[] args) {
    int size = 6;
    char c = '&';
    for (int i = 1; i < size + 1; i++) {
        drawBlanks(size, size - i);
        drawChars(size, size - i, c);
        System.out.println();
    }
    System.out.println();

}

public static void drawChars(int size, int i, char c) {

    for (int j = size; j < 1; j--) {
        System.out.print(c);
    }

}

public static void drawBlanks(int size, int i) {

    for (int k = 0; k <= i; k++) {
        System.out.print(" ");
    }
}

Body:
Alternative solution within one loop:

public class Main {

    public static void main(String[] args) {
        int rowCount = 10;
        int whiteSpaceCount = rowCount - 1;

        for (int i = 0; i < rowCount; i++) {
            for (int j = 0; j < rowCount; j++) {
                char ch = ' ';
                if (j >= whiteSpaceCount)
                    ch = '&';
                System.out.print(ch);
            }
            System.out.println();
            whiteSpaceCount = rowCount - (i + 2);
        }
    }
}


问:
In this code, Why am I getting wrong output only for input value of 4.2 while it is working well for other values?
The following code converts dollars (floating values) into cents (integer values). Here 1 dollar == 100 cents. The code works flawlessly except for one value i.e 4.2. It gives output as 419 instead of 420 for 4.2 as input. Where is the bug?</p>

```<code>#include <stdio.h>
int main(void)
{
    float change;

    do
    {
        printf("O hai! Enter amount in dollars to convert in cents.\n");

        scanf("%f",&change);   //accepts input in dollars

    } while(change < 0.00);

    int i = change * 100;    //converts dollars into cents

    printf("The equivalent cents are %d\n",i);
}
</code>```

答:
In this case that you know that the decimals for work with money are 2, I suggest that work with float representation with 3 decimals, and then the result must do round up to 2 decimals. Is important be carefully, because the working with money is very delicate.
Hope this help.</p>

Body:
The following code converts dollars (floating values) into cents (integer values). Here 1 dollar == 100 cents. The code works flawlessly except for one value i.e 4.2. It gives output as 419 instead of 420 for 4.2 as input. Where is the bug?

#include <stdio.h>
int main(void)
{
    float change;

    do
    {
        printf("O hai! Enter amount in dollars to convert in cents.\n");

        scanf("%f",&change);   //accepts input in dollars

    } while(change < 0.00);

    int i = change * 100;    //converts dollars into cents

    printf("The equivalent cents are %d\n",i);
}


问:
Creating SQL users and restricting their permissions
Greetings,

My program creates a SQL database using ADO.NET APIs to connect to a SQL server and manipulate SQL connections/transactions. When the database is created, I'm connecting to the server using 'sa' credentials. This will be the only time I will connect to the database using 'sa' credentials. During this same initial connection, I need to create a couple of logins and users, so that from there on credentials of these users will be used. Now, I know how I can create logins and users, but I cant seem to get restrictions of access right. Specifically, I need to create 1 db login and user that will have access to all stored procedured created for the database - sort of like a db admin, but very restricted (to only stored procs). And the second db login/user will be given access only to a couple of specific stored procs. Any pointers? Thanks!

答:
I would create a database role and then add the users to it. For the second user, I've included in the role and then denied permission to 2 sprocs. If you are denying permission to many sprocs and only granting permissions to a few sprocs, it may be better/easier to not include the second user in the role and individually grant permissions, for each object that you'd like to grant on. That's up to you and which way is most manageable for your situation.</p>

```<code>
--Replace db with your database name
USE db

--Create a database role
CREATE ROLE db_execonly

--Grant EXEC permissions to the role
GRANT EXECUTE TO db_execonly

--Add users to the new role
EXEC sp_addrolemember 'db_execonly', 'user1'
EXEC sp_addrolemember 'db_execonly', 'user2'

--Deny permissions to specific objects for user2
DENY EXEC ON OBJECT::dbo.usp_sproc1 TO user2
DENY EXEC ON OBJECT::dbo.usp_sproc2 TO user2
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I would create a database role and then add the users to it. For the second user, I've included in the role and then denied permission to 2 sprocs. If you are denying permission to many sprocs and only granting permissions to a few sprocs, it may be better/easier to not include the second user in the role and individually grant permissions, for each object that you'd like to grant on. That's up to you and which way is most manageable for your situation.

--Replace db with your database name
USE db

--Create a database role
CREATE ROLE db_execonly

--Grant EXEC permissions to the role
GRANT EXECUTE TO db_execonly

--Add users to the new role
EXEC sp_addrolemember 'db_execonly', 'user1'
EXEC sp_addrolemember 'db_execonly', 'user2'

--Deny permissions to specific objects for user2
DENY EXEC ON OBJECT::dbo.usp_sproc1 TO user2
DENY EXEC ON OBJECT::dbo.usp_sproc2 TO user2


问:
CockroachDB 2-phase commits with or without blocking?
Two-phase commits are supposed to suffer from blocking problems. Is that the case with CockroachDB, and if not, how is it avoided?</p>

答:
Summary: 2-phase commits are blocking, so it is important to keep the thing that is being 2-phase committed as "small" as possible, so that the set of all actions that are blocked is minimal. CockroachDB does this using MVCC with intents, 2-phase committing only on a single intent. Because CockroachDB provides serializable transactions, it reorders transaction timestamps to minimize blocking only to where absolutely necessary.

Longer answer

2-phase commits are blocking after the first phase, while all participants wait for a reply from the coordinator as to whether the second phase is to be committed or aborted. During this time period, participants that have already sent a "Yes" vote cannot unilaterally revoke their vote, but also cannot treat it as committed (as the coordinator might get back with an abort). So they are forced to block all subsequent actions that need to concretely know what the state of this transaction is. The key in the above sentence is in the "need": it is on us to design our system to reduce that set to the bare minimum. CockroachDB uses write intents and [MVCC] to minimize these dependencies.

Consider a naïve implementation of a distributed (multi-key) transactional key-value store: I wish to transactionally commit some write transaction t1. t1 spans many keys across many machines, but of particular concern is that it writes k1 = v2. k1 is on machine m1 (let's say k1=v1 was the previous value).

Since t1 spans many keys on many machines, all of them are involved in a 2-phase commit transaction. Once that 2-phase transaction is begun, we have to note that we have an intent to write k1=v2, and the status of the transaction is unknown (the transaction may abort, because one of the other writes cannot proceed).

Now if some other transaction t2 comes along which wants to read the value of k1, we simply cannot give that transaction an authoritative answer, until we know the final result of the 2-phase commit. t2 is blocked.

But, we (and CockroachDB) can do better. We can keep multiple versions of values for each key, and have a concurrency control mechanism to keep all of these versions in order. Namely, we can assign our transactions timestamps, and have our writes look (loosely) as follows:

```<code>`k1 = v1 committed at time=1`
`k1 = v2 at time=110 INTENT (pending transaction t1)`
</code>```

Now, when t2 comes along, it has an option: it can choose to do the read at time<=109, which would not be blocked on t1. Of course, some transactions cannot do this (if say, they also are distributed, and there's a different component that simply requires a higher timestamp). Those transactions will be blocked. But in practice, this frees up the database to assign timestamps such that many types of transactions can proceed.

As the other answer says, Cockroach Labs has a post about CockroachDB's use of MVCC here, which explains some further details as well.

Body:
Summary: 2-phase commits are blocking, so it is important to keep the thing that is being 2-phase committed as "small" as possible, so that the set of all actions that are blocked is minimal. CockroachDB does this using MVCC with intents, 2-phase committing only on a single intent. Because CockroachDB provides serializable transactions, it reorders transaction timestamps to minimize blocking only to where absolutely necessary.

Longer answer

2-phase commits are blocking after the first phase, while all participants wait for a reply from the coordinator as to whether the second phase is to be committed or aborted. During this time period, participants that have already sent a "Yes" vote cannot unilaterally revoke their vote, but also cannot treat it as committed (as the coordinator might get back with an abort). So they are forced to block all subsequent actions that need to concretely know what the state of this transaction is. The key in the above sentence is in the "need": it is on us to design our system to reduce that set to the bare minimum. CockroachDB uses write intents and [MVCC] to minimize these dependencies.

Consider a naïve implementation of a distributed (multi-key) transactional key-value store: I wish to transactionally commit some write transaction t1. t1 spans many keys across many machines, but of particular concern is that it writes k1 = v2. k1 is on machine m1 (let's say k1=v1 was the previous value).

Since t1 spans many keys on many machines, all of them are involved in a 2-phase commit transaction. Once that 2-phase transaction is begun, we have to note that we have an intent to write k1=v2, and the status of the transaction is unknown (the transaction may abort, because one of the other writes cannot proceed).

Now if some other transaction t2 comes along which wants to read the value of k1, we simply cannot give that transaction an authoritative answer, until we know the final result of the 2-phase commit. t2 is blocked.

But, we (and CockroachDB) can do better. We can keep multiple versions of values for each key, and have a concurrency control mechanism to keep all of these versions in order. Namely, we can assign our transactions timestamps, and have our writes look (loosely) as follows:

`k1 = v1 committed at time=1`
`k1 = v2 at time=110 INTENT (pending transaction t1)`

Now, when t2 comes along, it has an option: it can choose to do the read at time<=109, which would not be blocked on t1. Of course, some transactions cannot do this (if say, they also are distributed, and there's a different component that simply requires a higher timestamp). Those transactions will be blocked. But in practice, this frees up the database to assign timestamps such that many types of transactions can proceed.

As the other answer says, Cockroach Labs has a post about CockroachDB's use of MVCC here, which explains some further details as well.


问:
React Native APK build failure Unable to process incoming event 'ProgressComplete'
Suddenly i cannot build a release apk with the following error:

[04/07/2017, 20:37:22]    Transforming files (18437ms) bundle:
  start bundle: finish bundle: Writing bundle output to:
  D:\likecounter\android\app\build\intermediates\assets\release\index.android.bundle
  bundle: Done writing bundle output bundle: Copying 13 asset files
  bundle: Done copying assets

FAILURE: Build failed with an exception.

What went wrong: Unable to process incoming event 'ProgressComplete '
  (ProgressCompleteEvent)

Try: Run with --stacktrace option to get the stack trace. Run with
  --info or --debug option to get more log output.

I tried to use the suggested flags, but they weren't helpful.

The only thing i can think that could cause this problem is when i tried to press the run button on Android Studio it suggested to allow something that has to do with "instant run" and i naively agreed.

I tried to take the following steps:

Change gradle version from 2.2.3 to 2.1.2

Cancel instant run in Android studio configuration by reaching Build,
Execution, Deployment -> Instant Run -> un-select everything

答:
I had the same problem and I solved it by running the command with plain console as follow:</p>

```<code>YOURCOMMAND --console plain
</code>```

Body:
I had the same problem and I solved it by running the command with plain console as follow:

YOURCOMMAND --console plain


问:
How can I remove in LibGDX bodys?
I can not destroy any bodys in LibGDX. I have already tried everything but I do not get it. Can someone give me an example?

Regards Timux

So here is the code where I try to remove the body object.

```<code>public class ObjectSpawner extends Timer {

public ObjectSpawner() {
    scheduleTask(new Task() {
        @Override
        public void run() {
            Objecte objecte = new Objecte(world);
            objecte.getBody().applyForceToCenter((float) (200 + Math.random() * 300), 0, true);
            worldController.objectArray.add(objecte);

            for (Iterator<Body> iter = world.getBodies(); iter.hasNext();) {
                Body body = iter.next();
                if(body!=null) {
                    world.destroyBody(body);
                    body.setUserData(null);
                    }
                }

            for(Objecte o : worldController.objectArray) {
                if(o.getBody().getPosition().y < camera.position.y) {
                    worldController.deleteBody(o.getBody());
                }
            }
        }
    }, 0, 0.5f);
  }
}
</code>```

On the Internet I've seen that I can do with an iterator.

Iterator iter = world.getBodies()

But Android Studio underlines it red because the iterator wants an array and "world.getBodies ()" apparently is a void.

答:
LibGDX bodys ? From box2d tag it's seems that you want to destroy box2d body.

```<code>World world=new World(new Vector2(0,-9.8f),true);

BodyDef bodyDef=new BodyDef();
bodyDef.position.set(100,100);
bodyDef.type= BodyDef.BodyType.DynamicBody;

Body body =world.createBody(bodyDef);    // body created

PolygonShape polygonShape=new PolygonShape();
polygonShape.setAsBox(2,2);
body.createFixture(polygonShape,1);

world.destroyBody(body);   // body destroyed
</code>```

EDIT

getBodies() needs Body type Array as in argument so create and pass.

```<code>Array<Body> bodies=new Array<Body>();

world.getBodies(bodies);

for (Body body: bodies){
     world.destroyBody(body);
}
</code>```

Title: How can I remove in LibGDX bodys?

Body:
I can not destroy any bodys in LibGDX. I have already tried everything but I do not get it. Can someone give me an example?

Regards Timux

So here is the code where I try to remove the body object.

public class ObjectSpawner extends Timer {

public ObjectSpawner() {
    scheduleTask(new Task() {
        @Override
        public void run() {
            Objecte objecte = new Objecte(world);
            objecte.getBody().applyForceToCenter((float) (200 + Math.random() * 300), 0, true);
            worldController.objectArray.add(objecte);

            for (Iterator iter = world.getBodies(); iter.hasNext();) {
                Body body = iter.next();
                if(body!=null) {
                    world.destroyBody(body);
                    body.setUserData(null);
                    }
                }

            for(Objecte o : worldController.objectArray) {
                if(o.getBody().getPosition().y < camera.position.y) {
                    worldController.deleteBody(o.getBody());
                }
            }
        }
    }, 0, 0.5f);
  }
}

On the Internet I've seen that I can do with an iterator.

Iterator iter = world.getBodies()

But Android Studio underlines it red because the iterator wants an array and "world.getBodies ()" apparently is a void.

Body:
LibGDX bodys ? From box2d tag it's seems that you want to destroy box2d body.

World world=new World(new Vector2(0,-9.8f),true);

BodyDef bodyDef=new BodyDef();
bodyDef.position.set(100,100);
bodyDef.type= BodyDef.BodyType.DynamicBody;

Body body =world.createBody(bodyDef);    // body created

PolygonShape polygonShape=new PolygonShape();
polygonShape.setAsBox(2,2);
body.createFixture(polygonShape,1);

world.destroyBody(body);   // body destroyed

EDIT

getBodies() needs Body type Array as in argument so create and pass.

Array<Body> bodies=new Array<Body>();

world.getBodies(bodies);

for (Body body: bodies){
     world.destroyBody(body);
}


问:
Desktop DirectX Surface (WDM)
I'm trying to make a screen recording app. Is there a way to use DirectX to capture the entire screen and store it as a texture? This would be in WDM. I know there's a way to get the texture for windows, but what about the entire screen. </p>

<p>I've tried the GDI method of using getDC(null) but that's rather slow for my uses. </p>

答:
There's three methods: gdi method, directx method and windows media api. When you need to capture entire screen as texture, you should use</p>

```<code>IDirect3DSurface9->GetFrontBufferData()
</code>```

Title: Desktop DirectX Surface (WDM)

Body:
I'm trying to make a screen recording app. Is there a way to use DirectX to capture the entire screen and store it as a texture? This would be in WDM. I know there's a way to get the texture for windows, but what about the entire screen.

I've tried the GDI method of using getDC(null) but that's rather slow for my uses.

Body:
There's three methods: gdi method, directx method and windows media api. When you need to capture entire screen as texture, you should use

IDirect3DSurface9->GetFrontBufferData()


问:
How to handle credit card information with cryptography on android and Rest
I have a Backend with ASP.NET WebApi and a Android client. Basically, when the user makes a payment I need to send a Credit Card information to my WebApi and make the payment there to my Gateway by REST. But I'm concerned because, somehow or someway these information could be intercepted in some cases. For saving these information on SQL I already have a Cryptography code to do this. I was thinking, should I implement a code to crypt the data from the android to Api and decrypt for making the payment and then use my current cryptography to storage in database? Should I use Rijndael? Thanks!</p>

答:
When using HTTPS you should pin the certificate, that means verify that the site you are directly connecting to is the correct site.

This is done be verifying that the certificate presented by the HTTPS connection is the correct site, this avoids MITM attacks.

The the Android client verifies that the connection is directly to your gateway and that your gateway connects directly to the payment site.

You do not need to add anymore security/encryption.

As henry states: consult the PCI DSS documents. See PCI Compliance Guide.


问:
call a Method from One Repository to another Repository Symfony2
Hi I am using symfony2 With ODM, I want to call a function from one reposotory to another repository to re-use it. I did not get a way to call it directly.

Following my code.

//My LedgerRepository.php

```<code>class LedgerRepository extends DocumentRepository
{

public function ProfitLoss(){
//Some re-usable code

  }
 }
</code>```

//My BudgetRepository.php

```<code>class BudgetRepository extends DocumentRepository
{
 //So here I want to call method ProfitLoss() from LedgerRepository

}
</code>```

how to make it possible please guide.

Thanks advance

答:
In this case good old inheritance may come to the rescue.  Both Ledger and Budget deal with financial transactions.  Why not this?:

```<code>class TransactionsRepository extends DocumentRepository
{
    public function ProfitLoss() {}
}

class LedgerRepository extends TransactionsRepository {}
class BudgetRepository extends TransactionsRepository {}
</code>```

In this case both Ledger and Budget can "share" methods in TransactionsRepository.

Body:
Hi I am using symfony2 With ODM, I want to call a function from one reposotory to another repository to re-use it. I did not get a way to call it directly.

Following my code.

//My LedgerRepository.php

class LedgerRepository extends DocumentRepository
{

public function ProfitLoss(){
//Some re-usable code

  }
 }

//My BudgetRepository.php

class BudgetRepository extends DocumentRepository
{
 //So here I want to call method ProfitLoss() from LedgerRepository

}

how to make it possible please guide.

Thanks advance

Body:
In this case good old inheritance may come to the rescue.  Both Ledger and Budget deal with financial transactions.  Why not this?:

class TransactionsRepository extends DocumentRepository
{
    public function ProfitLoss() {}
}

class LedgerRepository extends TransactionsRepository {}
class BudgetRepository extends TransactionsRepository {}

In this case both Ledger and Budget can "share" methods in TransactionsRepository.


问:
Proguard with Butterknife prevents obfuscation of class names
Since Butterknife uses reflection to generate classes associating with every activity or fragment used. due to which Proguard ignores those classes and not obfuscate it in its rules.

found one work around to this is to use Butterknife generated classes by Replacing ButterKnife.bind(this) with new Whatever_ViewBinder(this) and use them in my code. which does work and Progurad obfuscate my classes. but only problem here is i have to copy them from Debug folder to my package from getting changed/deleted. and update it every time i add/remove views. source

another question i found which says it better to use Data binding instead Butterknife vs Data Binding. but its too late now for me to change the whole code

Please share across if you'll have found any work around to this.
I am using Butterknife v8.6.0. if this is of any help

答:
You even linked to your answers yourself with #746.

[...] until I remove all imports of Butter Knife from the class, Proguard doesn't work on it.

This is because the Proguard rules are supplied with Butter Knife itself until version 9.0.

The ProGuard rules will be separated in 9.0 when using the generated
  code API becomes stable.

So basically it's not possible to do easily what you're intending to do. The best would be to fork Butter Knife and remove the consumerProguardFiles definition from build.gradle. Then wait for version 9.0 to be released and then use the original again.


问:
Filter by variable from expressions
I'm trying to do a test query, and I would like to filter based on a variable assigned from an expression. Here's a test query to find presidents of United States before Barrack Obama was born:

```<code>  PREFIX db: <http://dbpedia.org/resource/>
  PREFIX dbprop: <http://dbpedia.org/property/>
  PREFIX dbc: <http://dbpedia.org/resource/Category:>
  PREFIX dct: <http://purl.org/dc/terms/>

  SELECT ?president (min(?termStart) as ?minTermStart) ?birthDate
  WHERE {
    db:Barack_Obama dbprop:birthDate ?birthDate .
    ?president dct:subject dbc:Presidents_of_the_United_States .
    ?president dbprop:termStart ?termStart .
    filter($minTermStart < ?birthDate) .
  }
</code>```

which gives no results.

Taking away filter(minTermStart < ?birthDate) gives the following:

```<code>                                              president minTermStart  birthDate
1       <http://dbpedia.org/resource/John_Quincy_Adams>  -5527303492 -265456800
2     <http://dbpedia.org/resource/William_Howard_Taft>  -2454919492 -265456800
3        <http://dbpedia.org/resource/William_McKinley>  -2929428292 -265456800
4          <http://dbpedia.org/resource/Woodrow_Wilson>  -1860573600 -265456800
5       <http://dbpedia.org/resource/Chester_A._Arthur>  -3439706692 -265456800
6            <http://dbpedia.org/resource/James_Monroe>  -5653274692 -265456800
7          <http://dbpedia.org/resource/Zachary_Taylor>  -3813041092 -265456800
8         <http://dbpedia.org/resource/Calvin_Coolidge>  -1703757600 -265456800
9         <http://dbpedia.org/resource/John_F._Kennedy>   -725709600 -265456800
10  <http://dbpedia.org/resource/Franklin_D._Roosevelt>  -1792317600 -265456800
11         <http://dbpedia.org/resource/George_W._Bush>    790261200 -265456800
12            <http://dbpedia.org/resource/Gerald_Ford>   -662551200 -265456800
13           <http://dbpedia.org/resource/Barack_Obama>    852642000 -265456800
14           <http://dbpedia.org/resource/Bill_Clinton>    221058000 -265456800
15        <http://dbpedia.org/resource/Abraham_Lincoln>  -3876199492 -265456800
16          <http://dbpedia.org/resource/Richard_Nixon>   -725709600 -265456800
17       <http://dbpedia.org/resource/Millard_Fillmore>  -4317962692 -265456800
18    <http://dbpedia.org/resource/Rutherford_B._Hayes>  -3308119492 -265456800
19      <http://dbpedia.org/resource/Warren_G._Harding>  -2082016800 -265456800
20       <http://dbpedia.org/resource/Thomas_Jefferson>  -6138929092 -265456800
21       <http://dbpedia.org/resource/Martin_Van_Buren>  -4696653892 -265456800
22         <http://dbpedia.org/resource/Herbert_Hoover>  -1540893600 -265456800
23           <http://dbpedia.org/resource/Jimmy_Carter>   -219837600 -265456800
24          <http://dbpedia.org/resource/James_K._Polk>  -4570423492 -265456800
25      <http://dbpedia.org/resource/Lyndon_B._Johnson>  -1032861600 -265456800
26   <http://dbpedia.org/resource/Dwight_D._Eisenhower>   -777981600 -265456800
27      <http://dbpedia.org/resource/George_Washington>  -6142471492 -265456800
28         <http://dbpedia.org/resource/James_Buchanan>  -4696653892 -265456800
29             <http://dbpedia.org/resource/John_Tyler>  -4829537092 -265456800
30          <http://dbpedia.org/resource/Ronald_Reagan>    -94644000 -265456800
31      <http://dbpedia.org/resource/James_A._Garfield>  -3371277892 -265456800
32 <http://dbpedia.org/resource/William_Henry_Harrison>  -5412391492 -265456800
33             <http://dbpedia.org/resource/John_Adams>  -6142471492 -265456800
34      <http://dbpedia.org/resource/George_H._W._Bush>    -94557600 -265456800
35         <http://dbpedia.org/resource/Andrew_Johnson>  -4002429892 -265456800
36          <http://dbpedia.org/resource/James_Madison>  -5959130692 -265456800
37      <http://dbpedia.org/resource/Benjamin_Harrison>  -2803197892 -265456800
38       <http://dbpedia.org/resource/Ulysses_S._Grant>  -3339223492 -265456800
39         <http://dbpedia.org/resource/Andrew_Jackson>  -5461725892 -265456800
40       <http://dbpedia.org/resource/Grover_Cleveland>  -2776932292 -265456800
41        <http://dbpedia.org/resource/Franklin_Pierce>  -4317962692 -265456800
42        <http://dbpedia.org/resource/Harry_S._Truman>  -1356256800 -265456800
43     <http://dbpedia.org/resource/Theodore_Roosevelt>  -2777018692 -265456800
</code>```

Using filter(minTermStart < \"1961-08-03\"^^xsd:date) also gave no results.
Why doesn't the filter expression work? What have I missed?

答:
"Gives not results"?

Your query does not compile, and leads to an error if your run it on http://dbpedia.org/sparql:

minTermStart is missing the ?

it has to be termStart instead

PREFIX  dbc:  <http://dbpedia.org/resource/Category:>
PREFIX  dct:  <http://purl.org/dc/terms/>
PREFIX  db:   <http://dbpedia.org/resource/>
PREFIX  dbprop: <http://dbpedia.org/property/>

SELECT  ?president (MIN(?termStart) AS ?minTermStart) ?birthDate
WHERE
  { db:Barack_Obama
              dbprop:birthDate  ?birthDate .
    ?president  dct:subject     dbc:Presidents_of_the_United_States ;
              dbprop:termStart  ?termStart
    FILTER ( ?termStart < ?birthDate )
  }
GROUP BY ?president ?birthDate
```

<p>It's also not clear from where you get the results if you run it without the filter, mine shows the following (sample)</p>

```+-------------------------------------------------+--------------+------------+
|                    president                    | minTermStart | birthDate  |
+-------------------------------------------------+--------------+------------+
| http://dbpedia.org/resource/John_Quincy_Adams   | 1794-11-06   | 1961-08-04 |
| http://dbpedia.org/resource/William_Howard_Taft | 1892-03-17   | 1961-08-04 |
| http://dbpedia.org/resource/William_McKinley    | 1877-03-04   | 1961-08-04 |
| http://dbpedia.org/resource/Woodrow_Wilson      | 1911-01-17   | 1961-08-04 |
| http://dbpedia.org/resource/Chester_A._Arthur   | 1861-01-01   | 1961-08-04 |
| http://dbpedia.org/resource/James_Monroe        | 1790-11-09   | 1961-08-04 |
| http://dbpedia.org/resource/Zachary_Taylor      | 1849-03-04   | 1961-08-04 |
| ...                                             | ...          | ...        |
+-------------------------------------------------+--------------+------------+
```

Title: Filter by variable from expressions

Body:
I'm trying to do a test query, and I would like to filter based on a variable assigned from an expression. Here's a test query to find presidents of United States before Barrack Obama was born:

  PREFIX db: <http://dbpedia.org/resource/>
  PREFIX dbprop: <http://dbpedia.org/property/>
  PREFIX dbc: <http://dbpedia.org/resource/Category:>
  PREFIX dct: <http://purl.org/dc/terms/>

  SELECT ?president (min(?termStart) as ?minTermStart) ?birthDate
  WHERE {
    db:Barack_Obama dbprop:birthDate ?birthDate .
    ?president dct:subject dbc:Presidents_of_the_United_States .
    ?president dbprop:termStart ?termStart .
    filter($minTermStart < ?birthDate) .
  }

which gives no results.

Taking away filter(minTermStart < ?birthDate) gives the following:

                                              president minTermStart  birthDate
1       <http://dbpedia.org/resource/John_Quincy_Adams>  -5527303492 -265456800
2     <http://dbpedia.org/resource/William_Howard_Taft>  -2454919492 -265456800
3        <http://dbpedia.org/resource/William_McKinley>  -2929428292 -265456800
4          <http://dbpedia.org/resource/Woodrow_Wilson>  -1860573600 -265456800
5       <http://dbpedia.org/resource/Chester_A._Arthur>  -3439706692 -265456800
6            <http://dbpedia.org/resource/James_Monroe>  -5653274692 -265456800
7          <http://dbpedia.org/resource/Zachary_Taylor>  -3813041092 -265456800
8         <http://dbpedia.org/resource/Calvin_Coolidge>  -1703757600 -265456800
9         <http://dbpedia.org/resource/John_F._Kennedy>   -725709600 -265456800
10  <http://dbpedia.org/resource/Franklin_D._Roosevelt>  -1792317600 -265456800
11         <http://dbpedia.org/resource/George_W._Bush>    790261200 -265456800
12            <http://dbpedia.org/resource/Gerald_Ford>   -662551200 -265456800
13           <http://dbpedia.org/resource/Barack_Obama>    852642000 -265456800
14           <http://dbpedia.org/resource/Bill_Clinton>    221058000 -265456800
15        <http://dbpedia.org/resource/Abraham_Lincoln>  -3876199492 -265456800
16          <http://dbpedia.org/resource/Richard_Nixon>   -725709600 -265456800
17       <http://dbpedia.org/resource/Millard_Fillmore>  -4317962692 -265456800
18    <http://dbpedia.org/resource/Rutherford_B._Hayes>  -3308119492 -265456800
19      <http://dbpedia.org/resource/Warren_G._Harding>  -2082016800 -265456800
20       <http://dbpedia.org/resource/Thomas_Jefferson>  -6138929092 -265456800
21       <http://dbpedia.org/resource/Martin_Van_Buren>  -4696653892 -265456800
22         <http://dbpedia.org/resource/Herbert_Hoover>  -1540893600 -265456800
23           <http://dbpedia.org/resource/Jimmy_Carter>   -219837600 -265456800
24          <http://dbpedia.org/resource/James_K._Polk>  -4570423492 -265456800
25      <http://dbpedia.org/resource/Lyndon_B._Johnson>  -1032861600 -265456800
26   <http://dbpedia.org/resource/Dwight_D._Eisenhower>   -777981600 -265456800
27      <http://dbpedia.org/resource/George_Washington>  -6142471492 -265456800
28         <http://dbpedia.org/resource/James_Buchanan>  -4696653892 -265456800
29             <http://dbpedia.org/resource/John_Tyler>  -4829537092 -265456800
30          <http://dbpedia.org/resource/Ronald_Reagan>    -94644000 -265456800
31      <http://dbpedia.org/resource/James_A._Garfield>  -3371277892 -265456800
32 <http://dbpedia.org/resource/William_Henry_Harrison>  -5412391492 -265456800
33             <http://dbpedia.org/resource/John_Adams>  -6142471492 -265456800
34      <http://dbpedia.org/resource/George_H._W._Bush>    -94557600 -265456800
35         <http://dbpedia.org/resource/Andrew_Johnson>  -4002429892 -265456800
36          <http://dbpedia.org/resource/James_Madison>  -5959130692 -265456800
37      <http://dbpedia.org/resource/Benjamin_Harrison>  -2803197892 -265456800
38       <http://dbpedia.org/resource/Ulysses_S._Grant>  -3339223492 -265456800
39         <http://dbpedia.org/resource/Andrew_Jackson>  -5461725892 -265456800
40       <http://dbpedia.org/resource/Grover_Cleveland>  -2776932292 -265456800
41        <http://dbpedia.org/resource/Franklin_Pierce>  -4317962692 -265456800
42        <http://dbpedia.org/resource/Harry_S._Truman>  -1356256800 -265456800
43     <http://dbpedia.org/resource/Theodore_Roosevelt>  -2777018692 -265456800

Using filter(minTermStart < \"1961-08-03\"^^xsd:date) also gave no results.
Why doesn't the filter expression work? What have I missed?

Body:
"Gives not results"?

Your query does not compile, and leads to an error if your run it on http://dbpedia.org/sparql:

minTermStart is missing the ?

it has to be termStart instead

PREFIX  dbc:  <http://dbpedia.org/resource/Category:>
PREFIX  dct:  <http://purl.org/dc/terms/>
PREFIX  db:   <http://dbpedia.org/resource/>
PREFIX  dbprop: <http://dbpedia.org/property/>

SELECT  ?president (MIN(?termStart) AS ?minTermStart) ?birthDate
WHERE
  { db:Barack_Obama
              dbprop:birthDate  ?birthDate .
    ?president  dct:subject     dbc:Presidents_of_the_United_States ;
              dbprop:termStart  ?termStart
    FILTER ( ?termStart < ?birthDate )
  }
GROUP BY ?president ?birthDate

It's also not clear from where you get the results if you run it without the filter, mine shows the following (sample)

+-------------------------------------------------+--------------+------------+
|                    president                    | minTermStart | birthDate  |
+-------------------------------------------------+--------------+------------+
| http://dbpedia.org/resource/John_Quincy_Adams   | 1794-11-06   | 1961-08-04 |
| http://dbpedia.org/resource/William_Howard_Taft | 1892-03-17   | 1961-08-04 |
| http://dbpedia.org/resource/William_McKinley    | 1877-03-04   | 1961-08-04 |
| http://dbpedia.org/resource/Woodrow_Wilson      | 1911-01-17   | 1961-08-04 |
| http://dbpedia.org/resource/Chester_A._Arthur   | 1861-01-01   | 1961-08-04 |
| http://dbpedia.org/resource/James_Monroe        | 1790-11-09   | 1961-08-04 |
| http://dbpedia.org/resource/Zachary_Taylor      | 1849-03-04   | 1961-08-04 |
| ...                                             | ...          | ...        |
+-------------------------------------------------+--------------+------------+


问:
dpkg: error processing archive /var/cache/apt/archives/golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb (--unpack):
When I am running sudo apt-get -f install, it shows dpkg: error processing.
Please find the complete logs below and advise how to solve this.
I am running VB 5.0.10 with Ubuntu 16.04 and already installed go 1.8 and its working fine</p>

```<code>sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  bridge-utils containerd gir1.2-cogl-1.0 gir1.2-freedesktop:i386 gir1.2-gdkpixbuf-2.0:i386 gir1.2-glib-2.0:i386
  gir1.2-pango-1.0:i386 libc6-dev:i386 libcaca-dev libcairo-gobject2:i386 libcairo-script-interpreter2:i386 libdmx-dev libdmx1
  libedata-cal-1.2-28 libepoxy-dev libexpat1-dev:i386 libfontconfig1-dev:i386 libfontenc-dev libfreetype6-dev:i386 libfribidi-dev
  libfs-dev libfs6 libgeocode-glib0 libgirepository-1.0-1:i386 libglu1-mesa-dev libgmp-dev libgmpxx4ldbl libgweather-common
  libharfbuzz-gobject0:i386 libharfbuzz-icu0:i386 libice-dev:i386 libice6:i386 libicu55:i386 libilmbase12 libjpeg-turbo8-dev
  liblzo2-2:i386 libopenexr22 libpangox-1.0-0 libpciaccess-dev libpcre16-3:i386 libpcre3-dev:i386 libpcre32-3:i386
  libpcrecpp0v5:i386 libpng12-dev:i386 libsdl1.2debian libslang2-dev libsm-dev:i386 libsm6:i386 libvte-common libxaw7-dev
  libxcb-render0-dev:i386 libxcb-shm0-dev:i386 libxext-dev:i386 libxfont-dev libxkbfile-dev libxmu-dev libxmu-headers libxmuu-dev
  libxpm-dev libxrender-dev:i386 libxres-dev libxss-dev libxt-dev libxv-dev libxvmc-dev libxxf86dga-dev linux-headers-4.4.0-64
  linux-headers-4.4.0-64-generic linux-headers-4.4.0-66 linux-headers-4.4.0-66-generic linux-headers-4.4.0-67
  linux-headers-4.4.0-67-generic linux-headers-4.4.0-70 linux-headers-4.4.0-70-generic linux-headers-4.4.0-71
  linux-headers-4.4.0-71-generic linux-headers-4.4.0-72 linux-headers-4.4.0-72-generic linux-image-4.4.0-64-generic
  linux-image-4.4.0-66-generic linux-image-4.4.0-67-generic linux-image-4.4.0-70-generic linux-image-4.4.0-71-generic
  linux-image-4.4.0-72-generic linux-image-extra-4.4.0-64-generic linux-image-extra-4.4.0-66-generic
  linux-image-extra-4.4.0-67-generic linux-image-extra-4.4.0-70-generic linux-image-extra-4.4.0-71-generic
  linux-image-extra-4.4.0-72-generic linux-libc-dev:i386 mir-client-platform-mesa-dev nettle-dev par2 python-cairo python-gobject-2
  runc ubuntu-fan x11proto-bigreqs-dev x11proto-dmx-dev x11proto-dri3-dev x11proto-fonts-dev x11proto-present-dev
  x11proto-resource-dev x11proto-scrnsaver-dev x11proto-video-dev x11proto-xcmisc-dev x11proto-xf86bigfont-dev x11proto-xf86dga-dev
  x11proto-xf86dri-dev zlib1g-dev:i386
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  golang-1.6-go
Suggested packages:
  bzr
The following packages will be upgraded:
  golang-1.6-go
1 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
44 not fully installed or removed.
Need to get 0 B/20.3 MB of archives.
After this operation, 3,072 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 453044 files and directories currently installed.)
Preparing to unpack .../golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb ...
Unpacking golang-1.6-go (1.6.2-0ubuntu5~16.04.2) over (1.6.2-0ubuntu5~16.04) ...
dpkg: error processing archive /var/cache/apt/archives/golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/go-1.6/src', which is also in package golang-1.6-race-detector-runtime 0.0+svn252922-0ubuntu1
Errors were encountered while processing:
 /var/cache/apt/archives/golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
</code>```

答:
That is a bug in the packaging in Ubuntu. This was already reported here: https://bugs.launchpad.net/ubuntu/+source/golang-1.6/+bug/1691834

It is likely that as a workaround you can first uninstall golang-1.6-race-detector-runtime, then running apt-get install might work.

Body:
When I am running sudo apt-get -f install, it shows dpkg: error processing.
Please find the complete logs below and advise how to solve this.
I am running VB 5.0.10 with Ubuntu 16.04 and already installed go 1.8 and its working fine

sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  bridge-utils containerd gir1.2-cogl-1.0 gir1.2-freedesktop:i386 gir1.2-gdkpixbuf-2.0:i386 gir1.2-glib-2.0:i386
  gir1.2-pango-1.0:i386 libc6-dev:i386 libcaca-dev libcairo-gobject2:i386 libcairo-script-interpreter2:i386 libdmx-dev libdmx1
  libedata-cal-1.2-28 libepoxy-dev libexpat1-dev:i386 libfontconfig1-dev:i386 libfontenc-dev libfreetype6-dev:i386 libfribidi-dev
  libfs-dev libfs6 libgeocode-glib0 libgirepository-1.0-1:i386 libglu1-mesa-dev libgmp-dev libgmpxx4ldbl libgweather-common
  libharfbuzz-gobject0:i386 libharfbuzz-icu0:i386 libice-dev:i386 libice6:i386 libicu55:i386 libilmbase12 libjpeg-turbo8-dev
  liblzo2-2:i386 libopenexr22 libpangox-1.0-0 libpciaccess-dev libpcre16-3:i386 libpcre3-dev:i386 libpcre32-3:i386
  libpcrecpp0v5:i386 libpng12-dev:i386 libsdl1.2debian libslang2-dev libsm-dev:i386 libsm6:i386 libvte-common libxaw7-dev
  libxcb-render0-dev:i386 libxcb-shm0-dev:i386 libxext-dev:i386 libxfont-dev libxkbfile-dev libxmu-dev libxmu-headers libxmuu-dev
  libxpm-dev libxrender-dev:i386 libxres-dev libxss-dev libxt-dev libxv-dev libxvmc-dev libxxf86dga-dev linux-headers-4.4.0-64
  linux-headers-4.4.0-64-generic linux-headers-4.4.0-66 linux-headers-4.4.0-66-generic linux-headers-4.4.0-67
  linux-headers-4.4.0-67-generic linux-headers-4.4.0-70 linux-headers-4.4.0-70-generic linux-headers-4.4.0-71
  linux-headers-4.4.0-71-generic linux-headers-4.4.0-72 linux-headers-4.4.0-72-generic linux-image-4.4.0-64-generic
  linux-image-4.4.0-66-generic linux-image-4.4.0-67-generic linux-image-4.4.0-70-generic linux-image-4.4.0-71-generic
  linux-image-4.4.0-72-generic linux-image-extra-4.4.0-64-generic linux-image-extra-4.4.0-66-generic
  linux-image-extra-4.4.0-67-generic linux-image-extra-4.4.0-70-generic linux-image-extra-4.4.0-71-generic
  linux-image-extra-4.4.0-72-generic linux-libc-dev:i386 mir-client-platform-mesa-dev nettle-dev par2 python-cairo python-gobject-2
  runc ubuntu-fan x11proto-bigreqs-dev x11proto-dmx-dev x11proto-dri3-dev x11proto-fonts-dev x11proto-present-dev
  x11proto-resource-dev x11proto-scrnsaver-dev x11proto-video-dev x11proto-xcmisc-dev x11proto-xf86bigfont-dev x11proto-xf86dga-dev
  x11proto-xf86dri-dev zlib1g-dev:i386
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  golang-1.6-go
Suggested packages:
  bzr
The following packages will be upgraded:
  golang-1.6-go
1 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
44 not fully installed or removed.
Need to get 0 B/20.3 MB of archives.
After this operation, 3,072 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 453044 files and directories currently installed.)
Preparing to unpack .../golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb ...
Unpacking golang-1.6-go (1.6.2-0ubuntu5~16.04.2) over (1.6.2-0ubuntu5~16.04) ...
dpkg: error processing archive /var/cache/apt/archives/golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/go-1.6/src', which is also in package golang-1.6-race-detector-runtime 0.0+svn252922-0ubuntu1
Errors were encountered while processing:
 /var/cache/apt/archives/golang-1.6-go_1.6.2-0ubuntu5~16.04.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)


问:
Pulling container image from GitLab private registry fails after upgrading to Kubernetes v1.6
I've setup a Kubenetes cluster to pull container images from the registry of a GitLab private repository.

When I build an image using gitlab-ci.yml - I can use this to successfully login to the registry:

```<code>before_script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
</code>```

When deploying to my Kubernetes cluster, I generate a secret:

```<code>- kubectl create secret -n $KUBE_NAMESPACE docker-registry gitlab-registry \
  --docker-server="$CI_REGISTRY" \
  --docker-username="$CI_REGISTRY_USER" \
  --docker-password="$CI_REGISTRY_PASSWORD" \
  --docker-email="$GITLAB_USER_EMAIL" \
  -o yaml --dry-run | kubectl replace -n $KUBE_NAMESPACE --force -f -
</code>```

I then refer to this secret in my Deployment script using imagePullSecrets. This worked fine when my cluster was v1.5. However, since I upgraded to v1.6 I have not been able to pull a container image.

The error I get in my Kubernetes console is:

```<code>Failed to pull image "registry.gitlab.com/user/repo:branch":
rpc error: code = 2 desc = unauthorized: HTTP Basic: Access denied
Error syncing pod, skipping: failed to "StartContainer" for "helm-chart" with
ErrImagePull: "rpc error: code = 2 desc = unauthorized: HTTP Basic: Access denied"
</code>```

To test, I tried running the following on my own PC:

```<code>docker login registry.gitlab.com
</code>```

When I enter my GitLab username and password, everything is fine. However, if I try the following:

```<code>docker login \
  -u "gitlab-ci-token" \
  -p "the-auth-code-in-my-secret" \
  registry.gitlab.com
</code>```

I get the following error:

```<code>Error response from daemon: Get https://registry.gitlab.com/v2/:
unauthorized: HTTP Basic: Access denied
</code>```

I'm not sure if this is a GitLab issue or a Kubernetes issue. Am I just doing something wrong?

答:
As it turns out, this was a timing issue. My deployment script was creating Kubernetes objects and falling through without waiting. Because this worked in the past, I assumed that $CI_REGISTRY_PASSWORD was still valid after the deployment script finished.

I believe the fact that it worked was just coincidence (my Kubernetes cluster must have pulled the container before the CI pipeline had cleaned up its resources). After adding the following line to `gitlab-ci.yml':

```<code>- kubectl rollout status -n "$KUBE_NAMESPACE" -w "deployment/name"
</code>```

I no longer receive the "HTTP Basic: Access denied" message

Body:
I've setup a Kubenetes cluster to pull container images from the registry of a GitLab private repository.

When I build an image using gitlab-ci.yml - I can use this to successfully login to the registry:

before_script:
  - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

When deploying to my Kubernetes cluster, I generate a secret:

- kubectl create secret -n $KUBE_NAMESPACE docker-registry gitlab-registry \
  --docker-server="$CI_REGISTRY" \
  --docker-username="$CI_REGISTRY_USER" \
  --docker-password="$CI_REGISTRY_PASSWORD" \
  --docker-email="$GITLAB_USER_EMAIL" \
  -o yaml --dry-run | kubectl replace -n $KUBE_NAMESPACE --force -f -

I then refer to this secret in my Deployment script using imagePullSecrets. This worked fine when my cluster was v1.5. However, since I upgraded to v1.6 I have not been able to pull a container image.

The error I get in my Kubernetes console is:

Failed to pull image "registry.gitlab.com/user/repo:branch":
rpc error: code = 2 desc = unauthorized: HTTP Basic: Access denied
Error syncing pod, skipping: failed to "StartContainer" for "helm-chart" with
ErrImagePull: "rpc error: code = 2 desc = unauthorized: HTTP Basic: Access denied"

To test, I tried running the following on my own PC:

docker login registry.gitlab.com

When I enter my GitLab username and password, everything is fine. However, if I try the following:

docker login \
  -u "gitlab-ci-token" \
  -p "the-auth-code-in-my-secret" \
  registry.gitlab.com

I get the following error:

Error response from daemon: Get https://registry.gitlab.com/v2/:
unauthorized: HTTP Basic: Access denied

I'm not sure if this is a GitLab issue or a Kubernetes issue. Am I just doing something wrong?

Body:
As it turns out, this was a timing issue. My deployment script was creating Kubernetes objects and falling through without waiting. Because this worked in the past, I assumed that $CI_REGISTRY_PASSWORD was still valid after the deployment script finished.

I believe the fact that it worked was just coincidence (my Kubernetes cluster must have pulled the container before the CI pipeline had cleaned up its resources). After adding the following line to `gitlab-ci.yml':

- kubectl rollout status -n "$KUBE_NAMESPACE" -w "deployment/name"

I no longer receive the "HTTP Basic: Access denied" message


问:
Using mysql: column count doesn't match value count at row 1
I'm new to mysql, and can not figure out why this error keeps coming up. It's a simple table and I want id to be 1, 2, 3, 4 etc. alongside two other columns. Why does it keep reading, column count doesn't match value count at row 1?</p>

```<code>CREATE DATABASE thedatabase;

USE thedatabase;

CREATE TABLE cars (
    id INTEGER AUTO_INCREMENT,
    model INTEGER NOT NULL,
    mileage INTEGER NOT NULL,
    PRIMARY KEY (id)
);

INSERT INTO thedatabase.cars (
    model,
    mileage
) VALUES (
    (45, 34598),
    (22, 23847),
    (10, 3847),
    (487, 93229),
    (237, 238975),
    (23, 23987),
    (34, 3498),
    (57, 34984),
    (56, 34983),
    (20, 9845);
</code>```

答:
You have got an extra opening bracked in INSERT statement, after VALUES below should work fine:

```<code>INSERT INTO thedatabase.cars ( model,
mileage ) VALUES (45, 34598), (22, 23847), (10, 3847), (487, 93229), (237, 238975), (23, 23987), (34, 3498), (57, 34984), (56, 34983), (20, 9845);
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm new to mysql, and can not figure out why this error keeps coming up. It's a simple table and I want id to be 1, 2, 3, 4 etc. alongside two other columns. Why does it keep reading, column count doesn't match value count at row 1?

CREATE DATABASE thedatabase;

USE thedatabase;

CREATE TABLE cars (
    id INTEGER AUTO_INCREMENT,
    model INTEGER NOT NULL,
    mileage INTEGER NOT NULL,
    PRIMARY KEY (id)
);

INSERT INTO thedatabase.cars (
    model,
    mileage
) VALUES (
    (45, 34598),
    (22, 23847),
    (10, 3847),
    (487, 93229),
    (237, 238975),
    (23, 23987),
    (34, 3498),
    (57, 34984),
    (56, 34983),
    (20, 9845);

Body:
You have got an extra opening bracked in INSERT statement, after VALUES below should work fine:

INSERT INTO thedatabase.cars ( model,
mileage ) VALUES (45, 34598), (22, 23847), (10, 3847), (487, 93229), (237, 238975), (23, 23987), (34, 3498), (57, 34984), (56, 34983), (20, 9845);


问:
SQL 2005: NOLOCK hint dramatically increases reads. WTF?
I have a stored procedure that does a lot more reads when the NOLOCK hint is added to the query. I'm baffled - does anyone know why, please?

Details:
The query is:

```<code>SELECT * FROM dbo.<table-name> WITH (NOLOCK).
</code>```

It was doing 40,000 reads and there are less than 2,000 rows. I established that most of these reads are caused by 3 TEXT columns. (If I omit those it goes down to 59 reads!) But when I delete the WITH (NOLOCK) it goes from 40,000 reads to 13,000. I repeated this a few times because I thought I must have screwed up but it's really consistent both ways.

答: Maybe the read count includes page reads to read the locks? </p>

OwnerDisplayName: David Wimbush

Body:
I have a stored procedure that does a lot more reads when the NOLOCK hint is added to the query. I'm baffled - does anyone know why, please?

Details:
The query is:

SELECT * FROM dbo.
 WITH (NOLOCK).

It was doing 40,000 reads and there are less than 2,000 rows. I established that most of these reads are caused by 3 TEXT columns. (If I omit those it goes down to 59 reads!) But when I delete the WITH (NOLOCK) it goes from 40,000 reads to 13,000. I repeated this a few times because I thought I must have screwed up but it's really consistent both ways.

LastEditorDisplayName: rwmnau

OwnerDisplayName: Charles Bretana


问:
How to save exported excel at server directory
I want to export data table in Excel sheet and saving in server directory in MVC application. Here is my code-

//ManagEmployeeController.cs

```<code>public JsonResult ExportToExcel()
        {
            Excel.ExcelUtlity obj = new Excel.ExcelUtlity();
            DataTable dt = ConvertToDataTable(ListEmployee());
            string dir = string.Format("~/Clients/ExportedData/");
            var directoryToSaveFile = Server.MapPath(dir);
            string uniqueNumber = DateTime.Now.ToString("yyyyMMddHHmmss");
            string file = "ContactExportData.xlsx";
            string newFileName = string.Format("{0}{1}", uniqueNumber, file);
            if (!Directory.Exists(directoryToSaveFile))
            {
                Directory.CreateDirectory(directoryToSaveFile);
            }
            string fullFilePath = string.Format("{0}/{1}",dir,newFileName); ;
            //obj.WriteDataTableToExcel(dt, "Person Details", "D:\\testPersonExceldata.xlsx", "Details");
            obj.WriteDataTableToExcel(dt, "Person Details", fullFilePath, "Details");
            var result = new { Success = "Success", Messaage = "SuccessMessage" };
            return Json(result,JsonRequestBehavior.AllowGet);
        }
</code>```

The directory gets created but file does not saved here. But if I use commented code(obj.WriteDataTableToExcel(dt, "Person Details", "D:\\testPersonExceldata.xlsx", "Details");) the file gets saved on my local directory D.

//ExcelUtility.cs

```<code> public bool WriteDataTableToExcel(System.Data.DataTable dataTable, string worksheetName, string saveAsLocation, string ReporType)
        {
 Microsoft.Office.Interop.Excel.Workbook excelworkBook;
    //
    //
    excelworkBook.SaveAs(saveAsLocation);;
       }

What is missing in my code in order to save Excel to mentioned directory on server?
</code>```

答:
string fullFilePath = string.Format("{0}/{1}",dir,newFileName);

should be:

string fullFilePath = string.Format("{0}/{1}",directoryToSaveFile,newFileName);

Body:
I want to export data table in Excel sheet and saving in server directory in MVC application. Here is my code-

//ManagEmployeeController.cs

public JsonResult ExportToExcel()
        {
            Excel.ExcelUtlity obj = new Excel.ExcelUtlity();
            DataTable dt = ConvertToDataTable(ListEmployee());
            string dir = string.Format("~/Clients/ExportedData/");
            var directoryToSaveFile = Server.MapPath(dir);
            string uniqueNumber = DateTime.Now.ToString("yyyyMMddHHmmss");
            string file = "ContactExportData.xlsx";
            string newFileName = string.Format("{0}{1}", uniqueNumber, file);
            if (!Directory.Exists(directoryToSaveFile))
            {
                Directory.CreateDirectory(directoryToSaveFile);
            }
            string fullFilePath = string.Format("{0}/{1}",dir,newFileName); ;
            //obj.WriteDataTableToExcel(dt, "Person Details", "D:\\testPersonExceldata.xlsx", "Details");
            obj.WriteDataTableToExcel(dt, "Person Details", fullFilePath, "Details");
            var result = new { Success = "Success", Messaage = "SuccessMessage" };
            return Json(result,JsonRequestBehavior.AllowGet);
        }

The directory gets created but file does not saved here. But if I use commented code(obj.WriteDataTableToExcel(dt, "Person Details", "D:\\testPersonExceldata.xlsx", "Details");) the file gets saved on my local directory D.

//ExcelUtility.cs

 public bool WriteDataTableToExcel(System.Data.DataTable dataTable, string worksheetName, string saveAsLocation, string ReporType)
        {
 Microsoft.Office.Interop.Excel.Workbook excelworkBook;
    //
    //
    excelworkBook.SaveAs(saveAsLocation);;
       }

What is missing in my code in order to save Excel to mentioned directory on server?


问:
What means this classes in
```<code>  <header class="nk-header">
    <!--
    START: Navbar

    <nav class="nk-navbar nk-navbar-top nk-navbar-sticky nk-navbar-transparent nk-navbar-white-text-on-top">
    <div class="container">
</code>```

This is bootstrap framework, or what ? I tried understand this, google it, but fail.

答:
It's Godlike-html ...Classes ...

There Is Multiple Style Classes are define to  ..

nk-navbar : For Style to Navbar

nk-navbar-top : For Fixed Nav Bar On Top

.nk-navbar-sticky – sticky navbar on page scroll

.nk-navbar-transparent – transparent background color

.nk-navbar-white-text-on-top – white text when menu on the top of page (not sticky)

For Reference .. https://nkdev.info/docs/godlike-html/template-structure/side-navigation/

Title: What means this classes in <nav>

Body:
It's Godlike-html ...Classes ...

There Is Multiple Style Classes are define to <nav> .. </nav>

nk-navbar : For Style to Navbar

nk-navbar-top : For Fixed Nav Bar On Top

.nk-navbar-sticky – sticky navbar on page scroll

.nk-navbar-transparent – transparent background color

.nk-navbar-white-text-on-top – white text when menu on the top of page (not sticky)

For Reference .. https://nkdev.info/docs/godlike-html/template-structure/side-navigation/


问:
NodeJS request module stop working after 6 ajax requests
I have in node rest api function that receive ajax call with id to restart url link....it works when i call this ajax function 5 times...after i call 6 time it is not working..using console.log i see that line stops on getting request and if i call it again i get same log...getting request from url (url is valid)...so i see that request module is not returning any error even or request response code...here is my code:

```<code>apiRoutes.post('/restart_stream', function(req, res) {
/* GET - token */
var token = req.headers['x-access-token'];
    token = decrypt(token);
    console.log('called.../restart_stream');

/* GET - data id */
var data     = {};
data.id      = req.body.id;
data.type    = req.body.type;

    /* GET - connection */
    pool.getConnection(function(err,connection){
        if (err) {
            connection.release();
            res.json({"code" : 100, "status" : "Error in connection database"});
            return;
        }

        /* GET - stream url */
        connection.query("SELECT id, channel, JSON_UNQUOTE(json_extract(stream, '$[0]')) AS stream_url FROM streams WHERE id=?", [data.id],function(err, rows, fields){
       console.log('getting request to...'+rows[0].stream_url);
            /* GET - stream status */
            var r = request
                .get(rows[0].stream_url)
                .on('response', function(response) {
                    console.log('resoponse received....'+response.statusCode);
                    /* CHECK - stream exists */
                    if (response.statusCode != 200 && response.statusCode != 302) {
                        r.end();
                        /* RESET - live&streams info */
                        res.json({"status": "false", "message": "FAILED to Restart <b>"+rows[0].channel+"</b>!"});
                    } else {
                        /* RESET - live&streams info */
                        connection.query("UPDATE streams SET uptime=?, status=? WHERE id=?",['0', '1', data.id], function(err) {
                            /* CHECK - error */
                            if (err) {
                                res.json({"status": "false", "message": err.message});
                            } else {
                                /* STOP - url my code here that is not executed after 6 ajax call */

                                r.end();

                                res.json({"status": "true", "message": "RESTARTED Successfully!"});
                            };
                        });
                    };
                })
        });
    });
} else {
    res.json({"status": "false", "message": "FAILED"});
};
});
</code>```

I try using r.end() so that request connection is closed after each response but request module stop working after 5th ajax call..any clue what i im working wrong?

This is node request module that connects to url and get response code:

```<code>https://www.npmjs.com/package/request
</code>```

答: I was successfully today and resolve the problem...Problem was that i have using old version of node js (v0.10.25) now upgrade to v7.10.0 and all is working i was doing 100 requests and there is working just fine...also i have huge loading page that before..so new version of node js come with huge performance increase...</p>

Body:
I have in node rest api function that receive ajax call with id to restart url link....it works when i call this ajax function 5 times...after i call 6 time it is not working..using console.log i see that line stops on getting request and if i call it again i get same log...getting request from url (url is valid)...so i see that request module is not returning any error even or request response code...here is my code:

apiRoutes.post('/restart_stream', function(req, res) {
/* GET - token */
var token = req.headers['x-access-token'];
    token = decrypt(token);
    console.log('called.../restart_stream');

/* GET - data id */
var data     = {};
data.id      = req.body.id;
data.type    = req.body.type;

    /* GET - connection */
    pool.getConnection(function(err,connection){
        if (err) {
            connection.release();
            res.json({"code" : 100, "status" : "Error in connection database"});
            return;
        }

        /* GET - stream url */
        connection.query("SELECT id, channel, JSON_UNQUOTE(json_extract(stream, '$[0]')) AS stream_url FROM streams WHERE id=?", [data.id],function(err, rows, fields){
       console.log('getting request to...'+rows[0].stream_url);
            /* GET - stream status */
            var r = request
                .get(rows[0].stream_url)
                .on('response', function(response) {
                    console.log('resoponse received....'+response.statusCode);
                    /* CHECK - stream exists */
                    if (response.statusCode != 200 && response.statusCode != 302) {
                        r.end();
                        /* RESET - live&streams info */
                        res.json({"status": "false", "message": "FAILED to Restart "+rows[0].channel+"!"});
                    } else {
                        /* RESET - live&streams info */
                        connection.query("UPDATE streams SET uptime=?, status=? WHERE id=?",['0', '1', data.id], function(err) {
                            /* CHECK - error */
                            if (err) {
                                res.json({"status": "false", "message": err.message});
                            } else {
                                /* STOP - url my code here that is not executed after 6 ajax call */

                                r.end();

                                res.json({"status": "true", "message": "RESTARTED Successfully!"});
                            };
                        });
                    };
                })
        });
    });
} else {
    res.json({"status": "false", "message": "FAILED"});
};
});

I try using r.end() so that request connection is closed after each response but request module stop working after 5th ajax call..any clue what i im working wrong?

This is node request module that connects to url and get response code:

https://www.npmjs.com/package/request


问:
CUDA malloc, mmap/mremap
CUDA device memory can be allocated using cudaMalloc/cudaFree, sure. This is fine, but primitive.

I'm curious to know, is device memory virtualised in some way? Are there equivalent operations to mmap, and more importantly, mremap for device memory?
If device memory is virtualised, I expect these sorts of functions should exist. It seems modern GPU drivers implement paging when there is contention for limited video resources by multiple processes, which suggests it's virtualised in some way or another...

Does anyone know where I can read more about this?

Edit:

Okay, my question was a bit general. I've read the bits of the manual that talk about mapping system memory for device access. I was more interested in device-allocated memory however.

Specific questions:

- Is there any possible way to remap device memory? (ie, to grow a device allocation)

- Is it possible to map device allocated memory to system memory?

- Is there some performance hazard using mapped pinned memory? Is the memory duplicated on the device as needed, or will it always fetch the memory across the pci-e bus?

I have cases where the memory is used by the GPU 99% of the time; so it should be device-local, but it may be convenient to map device memory to system memory for occasional structured read-back without having to implement an awkward deep-copy.

Yes, unified memory exists, however I'm happy with explicit allocation, save for the odd moment when I want a sneaky read-back.

I've found the manual fairly light on detail in general.

答:
CUDA comes with a fine CUDA C Programming Guide as it's main manual which has sections on Mapped Memory as well as Unified Memory Programming.

Responding to your additional posted questions, and following your cue to leave UM out of the consideration:

Is there any possible way to remap device memory? (ie, to grow a device allocation)

There is no direct method.  You would have to manually create a new allocation of the desired size, and copy the old data to it, then free the old allocation.  If you expect to do this a lot, and don't mind the significant overhead associated with it, you could take a look at thrust device vectors which will hide some of the manual labor and allow you to resize an allocation in a single vector-style .resize() operation.  There's no magic, however, so thrust is just a template library built on top of CUDA C (for the CUDA device backend) and so it is going to do a sequence of cudaMalloc and cudaFree operations, just as you would "manually".

Is it possible to map device allocated memory to system memory?

Leaving aside UM, no.  Device memory cannot be mapped into host address space.

Is there some performance hazard using mapped pinned memory? Is the memory duplicated on the device as needed, or will it always fetch the memory across the pci-e bus?

no, host mapped data is never duplicated in device memory, and apart from L2 caching, mapped data needed by the GPU will always be fetched across the PCI-E bus

Title: CUDA malloc, mmap/mremap


问:
how to find and click elements have a specific class and doesn't have a specific class?
in fact,  I wanna find elements that have a specific class and doesn't have a specific class, for example, I mean this is code.

in this code, we have toggle-like and has-like but I wanna find all of the elements that have toggle-like but doesn't have has-like

please if you can write javascript and jquery code.

```<code> <button class="widget-button toggle-like has-like fade-out no-text" aria-label="شما این نوشته را پسندیده‌اید" title="شما این نوشته را پسندیده‌اید" disabled="true">
    <i class="fa fa-heart" aria-hidden="true"></i>
</button>
</code>```

=================================

```<code>var sad = document.querySelectorAll("button:not([.has-like])");
    for (var i = 0; i < happy.length; i++) {
        sad[i].click();
    }
</code>```

答:
Your selector is wrong, for class you need to prefix . with class name

```<code>var sad = document.querySelectorAll("button.toggle-like:not(.has-like)");
//jQuery code
var sad = $("button.toggle-like:not(.has-like)");
</code>```

console.log(document.querySelector("button.toggle-like:not(.has-like)"))```
<pre class="snippet-code-html lang-html prettyprint-override"><code><button class="widget-button toggle-like has-like fade-out no-text" aria-label="شما این نوشته را پسندیده‌اید" title="شما این نوشته را پسندیده‌اید" disabled="true">
    <i class="fa fa-heart" aria-hidden="true"></i>
</button></code>```

Body:
in fact,  I wanna find elements that have a specific class and doesn't have a specific class, for example, I mean this is code.

in this code, we have toggle-like and has-like but I wanna find all of the elements that have toggle-like but doesn't have has-like

please if you can write javascript and jquery code.

 <button class="widget-button toggle-like has-like fade-out no-text" aria-label="شما این نوشته را پسندیده‌اید" title="شما این نوشته را پسندیده‌اید" disabled="true">

</button>

=================================

var sad = document.querySelectorAll("button:not([.has-like])");
    for (var i = 0; i < happy.length; i++) {
        sad[i].click();
    }

Body:
Your selector is wrong, for class you need to prefix . with class name

var sad = document.querySelectorAll("button.toggle-like:not(.has-like)");
//jQuery code
var sad = $("button.toggle-like:not(.has-like)");

console.log(document.querySelector("button.toggle-like:not(.has-like)"))

<button class="widget-button toggle-like has-like fade-out no-text" aria-label="شما این نوشته را پسندیده‌اید" title="شما این نوشته را پسندیده‌اید" disabled="true">
    <i class="fa fa-heart" aria-hidden="true"></i>
</button>


问:
Facebook Graph API: Getting the total number of posts
I've been using the Facebook Graph API to display user posts.  When I get the initial "page" of posts, the resulting data object has a paging property object with a previous and next URL property.  I was hoping to generate navigation links based on this available paging information.  However, sometimes these URLs point to an empty set of data, so I obviously don't want to navigate the user to an empty page.

Is there a way to find the total count of objects in a collection so that better navigation can be derived?  Is there any way to get smarter paging data?

Update:
Sorry if my post isn't clear.  To illustrate, look at the data at https://graph.facebook.com/7901103/posts and its paging property URLs.  Then follow those URLs to see the issue: empty pages of data.

答: Since it pages the datas with date-time base. You can't get the knowledge of whether if there are datas or not before you actually send the request to it. But you can preload the data from previous url to determine is it suitable to dispaly a previous link in your web page.</p>


问:
React Native - Fetch POST not working
I am having huge troubles getting my fetch POST calls to work on iOS. My standard Fetch calls work and the Fetch POST calls work fine on android but not iOS.

The error that comes up is "Possible Unhandled Promise Rejection (id: 0): Unexpected token < in JSON at position 0"

It actually saves the post data to my server but throws that error.

I tried debugging the network request using GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest; before the API call coupled with using CORS in my chrome debug tools. From there I can see that it is making two post calls one after the other. The first one has type "OPTIONS" while the second one has type "POST". It should probably be noted that the call works in the App while using CORS and the line of code above.

I'm very confused and have exhausted all avenues.

My code im using for refrence is as follows.

```<code>return fetch(url,{
        method: 'post',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    }).then((res) => res.json());
</code>```

答:
server node.js? </p>

```<code>npm i cors --save

var cors = require('cors');
app.use(cors());

res.header("Access-Control-Allow-Origin: *");
</code>```

Title: React Native - Fetch POST not working

Body:
I am having huge troubles getting my fetch POST calls to work on iOS. My standard Fetch calls work and the Fetch POST calls work fine on android but not iOS.

The error that comes up is "Possible Unhandled Promise Rejection (id: 0): Unexpected token < in JSON at position 0"

It actually saves the post data to my server but throws that error.

I tried debugging the network request using GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest; before the API call coupled with using CORS in my chrome debug tools. From there I can see that it is making two post calls one after the other. The first one has type "OPTIONS" while the second one has type "POST". It should probably be noted that the call works in the App while using CORS and the line of code above.

I'm very confused and have exhausted all avenues.

My code im using for refrence is as follows.

return fetch(url,{
        method: 'post',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    }).then((res) => res.json());

Body:
server node.js?

npm i cors --save

var cors = require('cors');
app.use(cors());

res.header("Access-Control-Allow-Origin: *");


问:
How to cache images only in disk using Kingfisher?
I am using Kingfisher library for downloading and caching images. I am facing some issues in the implementation:

Are the images cached in both memory and disk?

Is there any provision to cache images only on disk?

I have already read multiple posts regarding this, but couldn't find any solution.

答:
Yes, Kingfisher caches images both in memory and on disk.

By default, the amount of RAM that will be used is not even limited, you have to set the value yourself:

```<code>ImageCache.default.maxMemoryCost = 1024 * 1024 * yourValue
</code>```

where 1024 * 1024 * yourValue is the global cost in megapixels (I know this is weird, but it's not megabytes, it's megapixels, because images can have different bit depth, etc).

For example, in my tests, the maximum RAM used with a value of 1024 * 1024 * 500 fluctuates between 120MB and 300MB.

Incidentally, this is also how you tell Kingfisher to never use the RAM and only cache to disk:

```<code>ImageCache.default.maxMemoryCost = 1
</code>```

This will force Kingfisher to only use the disk cache.

How to debug

The first thing is to check that you're setting the max value on the right cache. Maybe you did create a custom cache? My example is setting the value for the default cache, the one used if no other is defined.

You may also want to manually clear the memory cache and compare the RAM occupation before and after:

```<code>ImageCache.default.clearMemoryCache()
</code>```

If you think that some big image is in the memory cache when it shouldn't be, you can verify with isImageCached:

```<code>if let result = ImageCache.default.isImageCached(forKey: imageLink) {
    print(result.cached)
    print(result.cacheType)
}
</code>```

Body:
Yes, Kingfisher caches images both in memory and on disk.

By default, the amount of RAM that will be used is not even limited, you have to set the value yourself:

ImageCache.default.maxMemoryCost = 1024 * 1024 * yourValue

where 1024 * 1024 * yourValue is the global cost in megapixels (I know this is weird, but it's not megabytes, it's megapixels, because images can have different bit depth, etc).

For example, in my tests, the maximum RAM used with a value of 1024 * 1024 * 500 fluctuates between 120MB and 300MB.

Incidentally, this is also how you tell Kingfisher to never use the RAM and only cache to disk:

ImageCache.default.maxMemoryCost = 1

This will force Kingfisher to only use the disk cache.

How to debug

The first thing is to check that you're setting the max value on the right cache. Maybe you did create a custom cache? My example is setting the value for the default cache, the one used if no other is defined.

You may also want to manually clear the memory cache and compare the RAM occupation before and after:

ImageCache.default.clearMemoryCache()

If you think that some big image is in the memory cache when it shouldn't be, you can verify with isImageCached:

if let result = ImageCache.default.isImageCached(forKey: imageLink) {
    print(result.cached)
    print(result.cacheType)
}


问:
Consuming Wikipedia API by Universal App Windows 10 C#
I'm newbie in C# and I have no idea how to consume a JSON from an API. I would like to get this JSON: https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=java&origin=*

And transform it in an C# Object. How Can I make that? Anyone has a very simple example? Also, I would like to understand the code.

I'm using Visual Studio 2015 and I want to make a Universal App.
Sorry for the very simple question.

Thanks! =D

答:
you can use json.NET to get an json object. And the use
string serializedjson = JsonConvert.SerializeObject(obj); to create an serialized string.


问:
FB Page is subscribed to multiple webhooks
I've got a FB page, that I used on a bot creation platform, then I use it for another bot creation platform.

What I expected was FB to cancel the previous subscription before setting the second one but looks like no.

I always get 2 responses, one from each of the platform.

I'm testing a handmade webhook, now and I'm getting 3 responses, the previous 2 ones and mine.

Is there a way to make FB drop the 2 first webhooks ?

答: By going to your page Settings and then Messenger platform  you can uninstall any applications you do not wish to receive postbacks and/or send messages. </p>


问:
OAuth2 - Authorize with no user interaction
So I'm trying to access my own data from an external app via their API. I only need access to my own data. Not trying to receive data from any of my users' accounts, so they don't need to authorize anything. So obviously I need to avoid any redirects (which seems to be the standard process the more I research OAuth...)

The process is hit the /authorize endpoint, which returns a code. Then provide that code in a request to the /token endpoint. Which then allows me to access my account via the API. I'm 95% sure this process is standard for all OAuth, but figured I'd provide details in case it's not.

How do I provide credentials on the back end to get a code to enter into the request for a token, so that all user interaction is negated? The API I'm using forces me to use OAuth.

答:
The oauth2 grant you are describing is called Authorization Code Grant. This way of authentication has been designed so that applications which want to access resources of a user do not have access to the users credentials.

So if you found a way to interact with the user credentials in this grant it would be considered a hack.

If you do not want the individual user to enter the username and password but you want to access the api with a kind of "system account" this is not the oauth grant you should use.

There are multiple grants that would work for you. The question is which are supported by the authorization server and available to you.

Resource Owner Password Credentials Grant

This grant type is suitable for clients capable of obtaining the resource owner's credentials.

However

The resource owner password credentials grant type is suitable in
cases where the resource owner has a trust relationship with the
client, such as the device operating system or a highly privileged application.

It is very likely that this grant type is not avaiable as it could be misused to steal user credentials.

Client credential grant

The client can request an access token using only its client credentials.

How the resources are tied to a client is not part of the oauth specification and therefore provider specific.

If you want to read more about oauth2 here is a good article.