问:
Why *ngFor in angular not printing the last value that is entered by the push method
I don't know why logs i.e string array is not printing it's value "on Destroy--child" in list item
{{ log }}
 and the same string array prints correctly "On Destroy--child" in {{ logs.join(', ') }}.

 That means value is inserted in array, what is the reason it's not printing??

plz explain, i am totally confused.

link for same example: http://plnkr.co/edit/kBHV6AximaHAC26kYEOA?p=gitter

open this link and run it.

app.component.ts

```<code>import { Component, OnInit } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `
      <h5>Lifecycle Events Log</h5>
      {{ logs.join(', ') }}

      <ul>
        <li *ngFor="let log of logs">
          <code>{{ log }}</code>
        </li>
      </ul>

      <app-child
        *ngIf="showChild"
        [name]="name"
        (log)="onLog($event)">
      </app-child>
    `
})
export class AppComponent implements OnInit {
  name = 'Alice';
  logs: string[] = [];
  showChild = true;

  ngOnInit() {
    setTimeout(() => this.updateName(), 3000);
    setTimeout(() => this.hideChild(), 4000);
  }

  updateName() {
    this.name = 'Bob';
  }

  hideChild() {
    this.showChild = false;
    this.logs.push(`onDestroy--app`);
  }

  onLog(data) {
    this.logs.push(data);
  }

}
</code>```

child.component.ts

```<code>import {
  Component,
  Input,
  Output,
  SimpleChange,
  OnChanges,
  OnInit,
  DoCheck,
  AfterContentInit,
  AfterContentChecked,
  AfterViewInit,
  AfterViewChecked,
  OnDestroy,
  EventEmitter
} from '@angular/core';

@Component({
    selector: 'app-child',
    template: `
      <div>
        <h4>Child Component</h4>
        <p>{{ name }}</p>
    </div>
    `,
    styles: [`
      :host > div {
        border: 2px solid blue;
        padding: 0.5rem 1rem;
        margin-top: 4rem;
      }
    `]
})
export class ChildComponent implements OnChanges, OnInit, DoCheck, AfterContentInit,
  AfterContentChecked, AfterViewInit, AfterViewChecked, OnDestroy {

  @Input() name = '';

  @Output() log = new EventEmitter<string>();

  _verb = 'set';
  _onChangesCounter: number = 0;

  // Only called if there is an [input] variable set by parent.
  ngOnChanges(changes: { [propertyName: string]: SimpleChange }) {
    let changesMsgs: string[] = [];

    for (let propName in changes) {
      if (propName === 'name') {
        let name = changes['name'].currentValue;
        changesMsgs.push(`name ${this._verb} to "${name}"`);
      } else {
        changesMsgs.push(propName + ' ' + this._verb);
      }
    }
    this.log.emit(`onChanges (${this._onChangesCounter++}): ${changesMsgs.join('; ')}`);
    this._verb = 'changed';
  }

  ngOnInit() {
    this.log.emit(`onInit`);
  }

  ngDoCheck() {
    this.log.emit(`doCheck`);
  }

  ngAfterContentInit() {
    this.log.emit(`afterContentInit`);
  }

  // Called after every change detection check
  // of the component (directive) CONTENT
  // Beware! Called frequently!
  ngAfterContentChecked() {
    this.log.emit('afterContentChecked');
  }

  ngAfterViewInit() {
    this.log.emit(`afterViewInit`);
  }

  // Called after every change detection check
  // of the component (directive) VIEW
  // Beware! Called frequently!
  ngAfterViewChecked() {
    this.log.emit(`afterViewChecked`);
  }

  ngOnDestroy() {
    this.log.emit(`onDestroy--child`);
  }
}
</code>```

Output:
after all the methods executed

```<code>onChanges (0): name set to "Alice", onInit, doCheck, afterContentInit, afterContentChecked, afterViewInit, afterViewChecked, doCheck, afterContentChecked, afterViewChecked, onChanges (1): name changed to "Bob", doCheck, afterContentChecked, afterViewChecked, onDestroy--app, onDestroy--child

onChanges (0): name set to "Alice"
onInit
doCheck
afterContentInit
afterContentChecked
afterViewInit
afterViewChecked
doCheck
afterContentChecked
afterViewChecked
onChanges (1): name changed to "Bob"
doCheck
afterContentChecked
afterViewChecked
onDestroy--app
</code>```

答:
Seems to be a bug, the change detection does not get properly executed after the ngDestroy of the child component. If you add a detectChanges in the log method you will get the desired effect.

plnkr

You should only do it when there is a ngOnDestroy event, because if you do it on an ngDoCheck or anything similar you'll end up in an infinite loop. It keeps checking, and logging :)

I don't know your use-case though, but if you really need this functionality, you can post a bug report on github

Body:
I don't know why logs i.e string array is not printing it's value "on Destroy--child" in list item
{{ log }}
 and the same string array prints correctly "On Destroy--child" in {{ logs.join(', ') }}.

 That means value is inserted in array, what is the reason it's not printing??

plz explain, i am totally confused.

link for same example: http://plnkr.co/edit/kBHV6AximaHAC26kYEOA?p=gitter

open this link and run it.

app.component.ts

import { Component, OnInit } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `

Lifecycle Events Log

      {{ logs.join(', ') }}

          {{ log }}

      <app-child
        *ngIf="showChild"
        [name]="name"
        (log)="onLog($event)">
      </app-child>
    `
})
export class AppComponent implements OnInit {
  name = 'Alice';
  logs: string[] = [];
  showChild = true;

  ngOnInit() {
    setTimeout(() => this.updateName(), 3000);
    setTimeout(() => this.hideChild(), 4000);
  }

  updateName() {
    this.name = 'Bob';
  }

  hideChild() {
    this.showChild = false;
    this.logs.push(`onDestroy--app`);
  }

  onLog(data) {
    this.logs.push(data);
  }

}

child.component.ts

import {
  Component,
  Input,
  Output,
  SimpleChange,
  OnChanges,
  OnInit,
  DoCheck,
  AfterContentInit,
  AfterContentChecked,
  AfterViewInit,
  AfterViewChecked,
  OnDestroy,
  EventEmitter
} from '@angular/core';

@Component({
    selector: 'app-child',
    template: `

Child Component

{{ name }}

    `,
    styles: [`
      :host > div {
        border: 2px solid blue;
        padding: 0.5rem 1rem;
        margin-top: 4rem;
      }
    `]
})
export class ChildComponent implements OnChanges, OnInit, DoCheck, AfterContentInit,
  AfterContentChecked, AfterViewInit, AfterViewChecked, OnDestroy {

  @Input() name = '';

  @Output() log = new EventEmitter<string>();

  _verb = 'set';
  _onChangesCounter: number = 0;

  // Only called if there is an [input] variable set by parent.
  ngOnChanges(changes: { [propertyName: string]: SimpleChange }) {
    let changesMsgs: string[] = [];

    for (let propName in changes) {
      if (propName === 'name') {
        let name = changes['name'].currentValue;
        changesMsgs.push(`name ${this._verb} to "${name}"`);
      } else {
        changesMsgs.push(propName + ' ' + this._verb);
      }
    }
    this.log.emit(`onChanges (${this._onChangesCounter++}): ${changesMsgs.join('; ')}`);
    this._verb = 'changed';
  }

  ngOnInit() {
    this.log.emit(`onInit`);
  }

  ngDoCheck() {
    this.log.emit(`doCheck`);
  }

  ngAfterContentInit() {
    this.log.emit(`afterContentInit`);
  }

  // Called after every change detection check
  // of the component (directive) CONTENT
  // Beware! Called frequently!
  ngAfterContentChecked() {
    this.log.emit('afterContentChecked');
  }

  ngAfterViewInit() {
    this.log.emit(`afterViewInit`);
  }

  // Called after every change detection check
  // of the component (directive) VIEW
  // Beware! Called frequently!
  ngAfterViewChecked() {
    this.log.emit(`afterViewChecked`);
  }

  ngOnDestroy() {
    this.log.emit(`onDestroy--child`);
  }
}

Output:
after all the methods executed

onChanges (0): name set to "Alice", onInit, doCheck, afterContentInit, afterContentChecked, afterViewInit, afterViewChecked, doCheck, afterContentChecked, afterViewChecked, onChanges (1): name changed to "Bob", doCheck, afterContentChecked, afterViewChecked, onDestroy--app, onDestroy--child

onChanges (0): name set to "Alice"
onInit
doCheck
afterContentInit
afterContentChecked
afterViewInit
afterViewChecked
doCheck
afterContentChecked
afterViewChecked
onChanges (1): name changed to "Bob"
doCheck
afterContentChecked
afterViewChecked
onDestroy--app


来源: stackexchange

问:
Get data from nested foreach
I'm building an app using firebase and Node.js. I need to get data from nested foreach. How to do it correctly? Need to return the results of all iterations simultaneously.</p>

```<code>exports.userParty = function (userInfo, cb) {

var userID = userInfo.userID;
var clubID = userInfo.clubID;

var refUserParty = ref.child(userID).child('my_party_id');

var party = {};

refUserParty.orderByValue().once("value", function (snapshot) {

    var party = {};

    snapshot.forEach(function (partyID) {

        var refParty = dbb.ref('clubs').child(clubID).child('party').child(partyID.val());

        refParty.once('value', function (partyBody) {
            party[partyID.val()] = partyBody.val();
            //console.log(party);
        });

    });
    cb(party); // {}

});

};
</code>```

答:
You need to call the callback after all the async functions in the forEach block have completed. You can do this using a simple counter to check all async functions are complete:

```<code>...

let completedSnapshots = 0;

snapshot.forEach(function (partyID) {

    var refParty = dbb.ref('clubs').child(clubID).child('party').child(partyID.val());

    refParty.once('value', function (partyBody) {
        party[partyID.val()] = partyBody.val();
        completedSnapshots++;
        if (completedSnapshots === snapshot.val().length) {
            cb(party);
        }
    });

});

...
</code>```

ContentLicense: CC BY-SA 3.0

Title: Get data from nested foreach

Body:
I'm building an app using firebase and Node.js. I need to get data from nested foreach. How to do it correctly? Need to return the results of all iterations simultaneously.

exports.userParty = function (userInfo, cb) {

var userID = userInfo.userID;
var clubID = userInfo.clubID;

var refUserParty = ref.child(userID).child('my_party_id');

var party = {};

refUserParty.orderByValue().once("value", function (snapshot) {

    var party = {};

    snapshot.forEach(function (partyID) {

        var refParty = dbb.ref('clubs').child(clubID).child('party').child(partyID.val());

        refParty.once('value', function (partyBody) {
            party[partyID.val()] = partyBody.val();
            //console.log(party);
        });

    });
    cb(party); // {}

});

};

Body:
You need to call the callback after all the async functions in the forEach block have completed. You can do this using a simple counter to check all async functions are complete:

...

let completedSnapshots = 0;

snapshot.forEach(function (partyID) {

    var refParty = dbb.ref('clubs').child(clubID).child('party').child(partyID.val());

    refParty.once('value', function (partyBody) {
        party[partyID.val()] = partyBody.val();
        completedSnapshots++;
        if (completedSnapshots === snapshot.val().length) {
            cb(party);
        }
    });

});

...


问:
Remove delivery address from Paypal checkout?
I have a Paypal form on my website, but for some reason when the user goes to the checkout Page on Paypal's website, it shows their 'delivery address'. Does anyone know how I can remove this? Thank you</p>

```<code>        <section style="background-color:white;border-radius:25px;"
id="three" class="wrapper style3 special">
                    <div class="container 50%">

                  <form id="Order" name="Order"
 action="https://www.paypal.com/cgi-bin/webscr" method="post">
<h2 style="color:black;">Your Page:</h2>    <input type="hidden"
name="on0" value="URL" />
<input style="border:1px solid grey;" name="os0" type="text"
class="formtext" />
<br />
<br />
<br />
<h2 style="color:black;">Your Email Address:</h2>
<input type="hidden" name="on1" value="EMAIL" />
 <input style="border:1px solid grey;" name="os1" type="text"
class="formtext" />
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $paypalemail; ?>">
<input type="hidden" name="lc" value="U">
<input type="hidden" name="item_name" value="My Product Name">
<input type="hidden" name="amount" value="<?php echo $bronze_price; ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the
seller">
<br />
<br />
<table width="50px" border="0" cellpadding="0" cellspacing="0">
<p style="color:black;">You have read and agreed to our <a style="text-
decoration:underline;" href="http://mywebsite.com/terms-of-service"
target="_blank">Terms of Service</a>
              <tr onclick="document['Order'].submit()">
  <td style="background-color:#3cadd4;width:5px;cursor: pointer;"><div><a
style="color:white;" href="#" onclick="document['Order'].submit()">PAY
NOW</a>
</div></td>

</tr>

</table>
    <p style="color:black;">Price: $<?php echo $bronze_price; ?></p>

</form>
</div>
</section>
</code>```

答:
Please pass the parameter "no_shipping =1" in the PayPal button code and on the PayPal checkout page Delivery address will be removed.

no_shipping No

Do not prompt buyers for a shipping address.

Valid value is:

0 - Prompt for an address, but do not require one.

1 - Do not prompt for an address.

2 - Prompt for an address and require one.

Default is 0.

Refer the following link for more information about PayPal Button HTML variables: https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/

Body:
I have a Paypal form on my website, but for some reason when the user goes to the checkout Page on Paypal's website, it shows their 'delivery address'. Does anyone know how I can remove this? Thank you

                  <form id="Order" name="Order"
 action="https://www.paypal.com/cgi-bin/webscr" method="post">

Your Page:
    <input type="hidden"
name="on0" value="URL" />
<input style="border:1px solid grey;" name="os0" type="text"
class="formtext" />

Your Email Address:

<input type="hidden" name="on1" value="EMAIL" />
 <input style="border:1px solid grey;" name="os1" type="text"
class="formtext" />
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php echo $paypalemail; ?>">
<input type="hidden" name="lc" value="U">
<input type="hidden" name="item_name" value="My Product Name">
<input type="hidden" name="amount" value="<?php echo $bronze_price; ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the
seller">

You have read and agreed to our Terms of Service

PAY
NOW

Price: $<?php echo $bronze_price; ?>

</form>


问:
Changing symmetric.key.master.password not working in 6.0
Same question

While installing new hybris instance, I trying to changed symmetric.key.master.password. But it throw following error while server startup.

Please note: I have created symmetric.key.master.password with random text/number e.g(JOSD53FJPjas1243ojdf9872rIJDFOJS3DioaIUOSI64Dj4foiaew12fIIOAS)

Error :

```<code>  [java] ERROR [main] [EncryptionUtil] pad block corrupted
  [java] javax.crypto.BadPaddingException: pad block corruptedWARN  [main] [CloseAwareApplicationContext] Exception encountered during context initialization - cancelling refresh attempt
  [java]     at org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(Unknown Source)
  [java]     at javax.crypto.Cipher.doFinal(Cipher.java:2165)
  [java]     at de.hybris.platform.util.encryption.EncryptionUtil.loadKey(EncryptionUtil.java:527)
  [java]     at de.hybris.platform.util.encryption.EncryptionUtil.loadKey(EncryptionUtil.java:484)
  [java]     at de.hybris.platform.util.encryption.EncryptionUtil.loadKey(EncryptionUtil.java:429)
  [java]
  [java]     at de.hybris.platform.core.MasterTenant.readKeyFiles(MasterTenant.java:235)
  [java]     at de.hybris.platform.core.MasterTenant.getValueEncryptor(MasterTenant.java:147)
  [java]     at de.hybris.platform.directpersistence.read.DefaultSLDItemDAO.init(DefaultSLDItemDAO.java:69)
  [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  [java]     at java.lang.reflect.Method.invoke(Method.java:498)
  [java]     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
  [java]     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
  [java]     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
  [java]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
  [java]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
  [java]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
  [java]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  [java]     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  [java]     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  [java]     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
  [java]     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  [java]     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
</code>```

Edit :-

local.properties changes :

```<code>symmetric.key.file.1=default-128-bit-aes-key.hybris
symmetric.key.file.2=Generated-256-Bit-AES-Key2.hybris
symmetric.key.file.default=2
symmetric.key.master.password=1234567
</code>```

with above configuration hybris server working fine(hybrisserver.sh/ant initialize etc). But if I try to change master.password to 1234568 it throws pad block corrupted while hybrisserver.sh/ant initialize. I also tried with fresh database(drop/create) and do ant initialize, getting same error. It is only working with OOTB master.password (1234567)

答:
From your stacktrace I think that issue may be with loading your symmetric.key.file.

Please try to regenerate symmetric key using recommendations given at help.hybris.com/Transparent Attribute Encryption (TAE) - Hybris V6

Body:
Same question

While installing new hybris instance, I trying to changed symmetric.key.master.password. But it throw following error while server startup.

Please note: I have created symmetric.key.master.password with random text/number e.g(JOSD53FJPjas1243ojdf9872rIJDFOJS3DioaIUOSI64Dj4foiaew12fIIOAS)

Error :

  [java] ERROR [main] [EncryptionUtil] pad block corrupted
  [java] javax.crypto.BadPaddingException: pad block corruptedWARN  [main] [CloseAwareApplicationContext] Exception encountered during context initialization - cancelling refresh attempt
  [java]     at org.bouncycastle.jce.provider.JCEBlockCipher.engineDoFinal(Unknown Source)
  [java]     at javax.crypto.Cipher.doFinal(Cipher.java:2165)
  [java]     at de.hybris.platform.util.encryption.EncryptionUtil.loadKey(EncryptionUtil.java:527)
  [java]     at de.hybris.platform.util.encryption.EncryptionUtil.loadKey(EncryptionUtil.java:484)
  [java]     at de.hybris.platform.util.encryption.EncryptionUtil.loadKey(EncryptionUtil.java:429)
  [java]
  [java]     at de.hybris.platform.core.MasterTenant.readKeyFiles(MasterTenant.java:235)
  [java]     at de.hybris.platform.core.MasterTenant.getValueEncryptor(MasterTenant.java:147)
  [java]     at de.hybris.platform.directpersistence.read.DefaultSLDItemDAO.init(DefaultSLDItemDAO.java:69)
  [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  [java]     at java.lang.reflect.Method.invoke(Method.java:498)
  [java]     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
  [java]     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
  [java]     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
  [java]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
  [java]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
  [java]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
  [java]     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  [java]     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  [java]     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  [java]     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
  [java]     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  [java]     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)

Edit :-

local.properties changes :

symmetric.key.file.1=default-128-bit-aes-key.hybris
symmetric.key.file.2=Generated-256-Bit-AES-Key2.hybris
symmetric.key.file.default=2
symmetric.key.master.password=1234567

with above configuration hybris server working fine(hybrisserver.sh/ant initialize etc). But if I try to change master.password to 1234568 it throws pad block corrupted while hybrisserver.sh/ant initialize. I also tried with fresh database(drop/create) and do ant initialize, getting same error. It is only working with OOTB master.password (1234567)


问:
sgen TypeLoadException in Visual Studio for Mac when trying to build Xamarin.iOS app
When compiling our app on MacOS in Visual Studio (version 7.0.1 build 24), I'm presented with the error:

```<code>/Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Error MSB6006: "sgen.exe" exited with code 1. (MSB6006) (SyncWebClientLight)
</code>```

If I start a build in Visual Studio 2015 Pro (with VS2015 connecting to the Mac and compiling it there), then I can debug etc. This would be great, except that I can't generate an archive for submission into the App Store from VS2015 (for whatever reason, the "Archive" menu option is greyed out)

Is there a way to disable sgen.exe in Visual Studio for Mac (some msbuild switch or something?) Might that help?

Update 1:

VS 2015 gives the following error:

```<code>Could not load file or assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)   SyncWebClientLight  C:\projects\mWORKSPACE\trunk\Source\SyncWebClientLight\SGEN
</code>```

So that's a little more information, at least.

Update 2:

```<code>Target GenerateSerializationAssemblies:
    /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/4.5/sgen.exe /assembly:/Users/mj/Documents/projects/mWORKSPACE/Source/SyncWebClientLight/obj/iPhoneSimulator/Release/SBW.SyncWebClientLight.dll /proxytypes /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/mscorlib.dll /reference:/Users/mj/Documents/projects/mWORKSPACE/Release/SBW.Sync.dll /reference:/Users/mj/Documents/projects/mWORKSPACE/Debug/SBW.SystemBase.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Core.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Data.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Web.Services.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Xml.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Xamarin.iOS.dll

    Unhandled Exception:
    System.TypeLoadException: Could not load type of field 'SyncWebClientLight.ClientPackageController:_syncDef' (2) due to: Could not load file or assembly 'SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:<none>
      at (wrapper managed-to-native) System.RuntimeType:GetConstructors_native (System.RuntimeType,System.Reflection.BindingFlags)
      at System.RuntimeType.GetConstructors_internal (System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) [0x00008] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00034] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.RuntimeType.GetConstructorImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.Type.GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00032] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.Xml.Serialization.TypeScope.GetConstructorFlags (System.Type type, System.Exception& exception) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.ImportTypeDesc (System.Type type, System.Reflection.MemberInfo memberInfo, System.Boolean directReference) [0x00444] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference, System.Boolean throwOnError) [0x00050] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type, System.Boolean directReference) [0x00017] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00014] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at Driver.Run (System.String[] args) [0x00110] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
      at Driver.Main (System.String[] args) [0x00005] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
    [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'SyncWebClientLight.ClientPackageController:_syncDef' (2) due to: Could not load file or assembly 'SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:<none>
      at (wrapper managed-to-native) System.RuntimeType:GetConstructors_native (System.RuntimeType,System.Reflection.BindingFlags)
      at System.RuntimeType.GetConstructors_internal (System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) [0x00008] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00034] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.RuntimeType.GetConstructorImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.Type.GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00032] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.Xml.Serialization.TypeScope.GetConstructorFlags (System.Type type, System.Exception& exception) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.ImportTypeDesc (System.Type type, System.Reflection.MemberInfo memberInfo, System.Boolean directReference) [0x00444] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference, System.Boolean throwOnError) [0x00050] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type, System.Boolean directReference) [0x00017] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00014] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at Driver.Run (System.String[] args) [0x00110] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
      at Driver.Main (System.String[] args) [0x00005] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
    /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(3366,5): error MSB6006: "sgen.exe" exited with code 1.
Done building target "GenerateSerializationAssemblies" in project "SyncWebClientLight.csproj" -- FAILED.
</code>```

The Type is there though: I can drill down to its reference in VS4mac, the project SBW.Sync compiles fine, SyncWebClientLight is referencing the correct assembly.

It would be nice if I knew where it was loading the assembly from (is there a fuslogvw.exe in mono?)

答:
This is a partial answer to your question, it provides the solution for your general problem (submitting to the App Store), but not the one that you have mentioned in the title of the question.

It is possible to use Visual Studio for Windows and to create the package to be submitted (and use Apple's Application Loader to submit it). You need to set the build configuration to Ad-Hoc (not Debug or Release), build platform to iPhone, set your certificates and click Rebuild All, then .ipa file will be generated on both your Windows and Mac and you can use it to submit it to the Store.

See more on Xamarin site https://developer.xamarin.com/guides/ios/deployment,_testing,_and_metrics/app_distribution/app-store-distribution/publishing_to_the_app_store/

Body:
When compiling our app on MacOS in Visual Studio (version 7.0.1 build 24), I'm presented with the error:

/Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Error MSB6006: "sgen.exe" exited with code 1. (MSB6006) (SyncWebClientLight)

If I start a build in Visual Studio 2015 Pro (with VS2015 connecting to the Mac and compiling it there), then I can debug etc. This would be great, except that I can't generate an archive for submission into the App Store from VS2015 (for whatever reason, the "Archive" menu option is greyed out)

Is there a way to disable sgen.exe in Visual Studio for Mac (some msbuild switch or something?) Might that help?

Update 1:

VS 2015 gives the following error:

Could not load file or assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)   SyncWebClientLight  C:\projects\mWORKSPACE\trunk\Source\SyncWebClientLight\SGEN

So that's a little more information, at least.

Update 2:

Target GenerateSerializationAssemblies:
    /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/4.5/sgen.exe /assembly:/Users/mj/Documents/projects/mWORKSPACE/Source/SyncWebClientLight/obj/iPhoneSimulator/Release/SBW.SyncWebClientLight.dll /proxytypes /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/mscorlib.dll /reference:/Users/mj/Documents/projects/mWORKSPACE/Release/SBW.Sync.dll /reference:/Users/mj/Documents/projects/mWORKSPACE/Debug/SBW.SystemBase.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Core.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Data.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Web.Services.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/System.Xml.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Xamarin.iOS.dll

    Unhandled Exception:
    System.TypeLoadException: Could not load type of field 'SyncWebClientLight.ClientPackageController:_syncDef' (2) due to: Could not load file or assembly 'SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:<none>
      at (wrapper managed-to-native) System.RuntimeType:GetConstructors_native (System.RuntimeType,System.Reflection.BindingFlags)
      at System.RuntimeType.GetConstructors_internal (System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) [0x00008] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00034] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.RuntimeType.GetConstructorImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.Type.GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00032] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.Xml.Serialization.TypeScope.GetConstructorFlags (System.Type type, System.Exception& exception) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.ImportTypeDesc (System.Type type, System.Reflection.MemberInfo memberInfo, System.Boolean directReference) [0x00444] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference, System.Boolean throwOnError) [0x00050] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type, System.Boolean directReference) [0x00017] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00014] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at Driver.Run (System.String[] args) [0x00110] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
      at Driver.Main (System.String[] args) [0x00005] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
    [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'SyncWebClientLight.ClientPackageController:_syncDef' (2) due to: Could not load file or assembly 'SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:SBW.Sync, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:<none>
      at (wrapper managed-to-native) System.RuntimeType:GetConstructors_native (System.RuntimeType,System.Reflection.BindingFlags)
      at System.RuntimeType.GetConstructors_internal (System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) [0x00008] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) [0x00034] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.RuntimeType.GetConstructorImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.Type.GetConstructor (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00032] in <ffb99659fc1c47faa4d5f883014d08aa>:0
      at System.Xml.Serialization.TypeScope.GetConstructorFlags (System.Type type, System.Exception& exception) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.ImportTypeDesc (System.Type type, System.Reflection.MemberInfo memberInfo, System.Boolean directReference) [0x00444] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference, System.Boolean throwOnError) [0x00050] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.TypeScope.GetTypeDesc (System.Type type, System.Reflection.MemberInfo source, System.Boolean directReference) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type, System.Boolean directReference) [0x00017] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.ModelScope.GetTypeModel (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00014] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type) [0x00000] in <3a4ce9be61fd46ab845a4d68f2905e06>:0
      at Driver.Run (System.String[] args) [0x00110] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
      at Driver.Main (System.String[] args) [0x00005] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0
    /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(3366,5): error MSB6006: "sgen.exe" exited with code 1.
Done building target "GenerateSerializationAssemblies" in project "SyncWebClientLight.csproj" -- FAILED.

The Type is there though: I can drill down to its reference in VS4mac, the project SBW.Sync compiles fine, SyncWebClientLight is referencing the correct assembly.

It would be nice if I knew where it was loading the assembly from (is there a fuslogvw.exe in mono?)


问:
Ng2-Smart-table not working, returns 404 not found error and system.js error
I am trying to implement the ng2-smarttable in my Angular2 project and returns me the following errors in the console,

```<code>GET http://localhost:3000/traceur 404 (Not Found)
</code>```

I tried running a command "npm install" by deleting the ng2-smart-table , but then it returns the same error.

```<code> **My System.js file**
   /**
   * System configuration for Angular 2 samples
   * Adjust as necessary for your application needs.
  */
    (function (global) {
  System.config({
    paths: {
        // paths serve as alias
        'npm:': 'node_modules/',
        'underscore': './node_modules/underscore/underscore.js'
    },
    // map tells the System loader where to look for things
    map: {
        // our app is within the app folder
        app: 'app',

        // angular bundles
        '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
        '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
        '@angular/compiler':
 'npm:@angular/compiler/bundles/compiler.umd.js',
        '@angular/platform-browser': 'npm:@angular/platform-
  browser/bundles/platform-browser.umd.js',
        '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-
   dynamic/bundles/platform-browser-dynamic.umd.js',
        '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
        '@angular/http/testing': 'npm:@angular/http/bundles/http-
     testing.umd.js',
        '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
        '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

        // other libraries
        'rxjs': 'npm:rxjs',
        'ng2-smart-table': 'npm:ng2-smart-table',
        'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
        /** Path for ng2-file-upload */
        'ng2-file-upload' : 'npm:ng2-file-upload',
        'ng2-drag-drop': 'npm:ng2-drag-drop',
        'ng2-dnd': 'npm:ng2-dnd',
        'underscore': 'npm:underscore'
    },
    // packages tells the System loader how to load when no filename and/or
  no extension
    packages: {
        app: {
            main: './main.js',
            defaultExtension: 'js'
        },
        rxjs: {
            defaultExtension: 'js'
        },
        'angular-in-memory-web-api': {
    main: './index.js',
    defaultExtension: 'js'
  },
  /** Configuration for ng2-file-upload */
  'ng2-file-upload' : {
    main: './ng2-file-upload.js',
    defaultExtension: 'js'
  },
  'ng2-smart-table':   {main: 'index.js', defaultExtension: 'js' } ,
  'ng2-drag-drop':  { main: '/index.js',  defaultExtension: 'js' },
  'underscore':  { main: '/underscore.js',  defaultExtension: 'js' },
    'ng2-dnd':  { main: '/bundles/index.umd.js',  defaultExtension: 'js' }
    },

  });
})(this);

 My app.module.ts if file is as follows,
 import { NgModule } from '@angular/core';
 import { BrowserModule } from '@angular/platform-browser';
 import { FormsModule } from '@angular/forms';
 import { HttpModule } from '@angular/http';
 import { FileSelectDirective, FileDropDirective } from 'ng2-file-upload';
 import { Ng2DragDropModule } from 'ng2-drag-drop';
 import {DndModule} from 'ng2-dnd';
 import { Ng2SmartTableModule } from 'ng2-smart-table';

 import { AppComponent } from './app.component';
 import { routing } from './app.routing';
 import { AppConfig } from './app.config';

 import { AlertComponent } from './_directives/index';
 import { AuthGuard } from './_guards/index';
 import { AlertService, AuthenticationService, UserService, SchemaService }
 from
 './_services/index';
 import { HomeComponent } from './home/index';
 import { LoginComponent } from './login/index';
 import { RegisterComponent } from './register/index';
 import { UploadComponent } from './upload/index';
 import { ReadComponent } from './read/index';
 import { DragComponent } from './drag/index';

  @NgModule({
    imports: [
    BrowserModule,
    DndModule.forRoot(),
    FormsModule,
    HttpModule,
    routing,
    Ng2DragDropModule,
    Ng2SmartTableModule
],
declarations: [
    AppComponent,
    AlertComponent,
    HomeComponent,
    LoginComponent,
    RegisterComponent,
    FileSelectDirective,
    UploadComponent,
    ReadComponent,
    DragComponent
  ],
  providers: [
    AppConfig,
    AuthGuard,
    AlertService,
    AuthenticationService,
    UserService,
    SchemaService
],
bootstrap: [AppComponent]
})

export class AppModule { }
</code>```

The Error message I get when I use 'ng2-smart-table':  { main: 'bundles/table.umd.js',  defaultExtension: 'js' },

My "app.module.ts" file is as shown below:

答:
You cannot use ng2-smart-table like this.
The ng2-smart-table release target is not ES5, but ES5. SystemJS knows that the index.js is in ES6 (and will not run in many browsers by default) and tries to transpile it using traceur to ES5. Although, there is bundled ES5 file which can be loaded by SystemJS. It is located in ng2-smart-table/bundles/table.umd.js. I am not very familiar with SystemJS, but you may try this:

```<code>'ng2-smart-table':   {main: 'bundles/table.umd.js', defaultExtension: 'js' }
</code>```

For the future, please remember that traceur problems in SystemJS usually means that you need to point bundled ES5 library file instead of, for example, index.js.

P.S.: This would not be a problem with angular-cli.

Body:
I am trying to implement the ng2-smarttable in my Angular2 project and returns me the following errors in the console,

GET http://localhost:3000/traceur 404 (Not Found)

I tried running a command "npm install" by deleting the ng2-smart-table , but then it returns the same error.

 **My System.js file**
   /**
   * System configuration for Angular 2 samples
   * Adjust as necessary for your application needs.
  */
    (function (global) {
  System.config({
    paths: {
        // paths serve as alias
        'npm:': 'node_modules/',
        'underscore': './node_modules/underscore/underscore.js'
    },
    // map tells the System loader where to look for things
    map: {
        // our app is within the app folder
        app: 'app',

        // angular bundles
        '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
        '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
        '@angular/compiler':
 'npm:@angular/compiler/bundles/compiler.umd.js',
        '@angular/platform-browser': 'npm:@angular/platform-
  browser/bundles/platform-browser.umd.js',
        '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-
   dynamic/bundles/platform-browser-dynamic.umd.js',
        '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
        '@angular/http/testing': 'npm:@angular/http/bundles/http-
     testing.umd.js',
        '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
        '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

        // other libraries
        'rxjs': 'npm:rxjs',
        'ng2-smart-table': 'npm:ng2-smart-table',
        'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
        /** Path for ng2-file-upload */
        'ng2-file-upload' : 'npm:ng2-file-upload',
        'ng2-drag-drop': 'npm:ng2-drag-drop',
        'ng2-dnd': 'npm:ng2-dnd',
        'underscore': 'npm:underscore'
    },
    // packages tells the System loader how to load when no filename and/or
  no extension
    packages: {
        app: {
            main: './main.js',
            defaultExtension: 'js'
        },
        rxjs: {
            defaultExtension: 'js'
        },
        'angular-in-memory-web-api': {
    main: './index.js',
    defaultExtension: 'js'
  },
  /** Configuration for ng2-file-upload */
  'ng2-file-upload' : {
    main: './ng2-file-upload.js',
    defaultExtension: 'js'
  },
  'ng2-smart-table':   {main: 'index.js', defaultExtension: 'js' } ,
  'ng2-drag-drop':  { main: '/index.js',  defaultExtension: 'js' },
  'underscore':  { main: '/underscore.js',  defaultExtension: 'js' },
    'ng2-dnd':  { main: '/bundles/index.umd.js',  defaultExtension: 'js' }
    },

  });
})(this);

 My app.module.ts if file is as follows,
 import { NgModule } from '@angular/core';
 import { BrowserModule } from '@angular/platform-browser';
 import { FormsModule } from '@angular/forms';
 import { HttpModule } from '@angular/http';
 import { FileSelectDirective, FileDropDirective } from 'ng2-file-upload';
 import { Ng2DragDropModule } from 'ng2-drag-drop';
 import {DndModule} from 'ng2-dnd';
 import { Ng2SmartTableModule } from 'ng2-smart-table';

 import { AppComponent } from './app.component';
 import { routing } from './app.routing';
 import { AppConfig } from './app.config';

 import { AlertComponent } from './_directives/index';
 import { AuthGuard } from './_guards/index';
 import { AlertService, AuthenticationService, UserService, SchemaService }
 from
 './_services/index';
 import { HomeComponent } from './home/index';
 import { LoginComponent } from './login/index';
 import { RegisterComponent } from './register/index';
 import { UploadComponent } from './upload/index';
 import { ReadComponent } from './read/index';
 import { DragComponent } from './drag/index';

  @NgModule({
    imports: [
    BrowserModule,
    DndModule.forRoot(),
    FormsModule,
    HttpModule,
    routing,
    Ng2DragDropModule,
    Ng2SmartTableModule
],
declarations: [
    AppComponent,
    AlertComponent,
    HomeComponent,
    LoginComponent,
    RegisterComponent,
    FileSelectDirective,
    UploadComponent,
    ReadComponent,
    DragComponent
  ],
  providers: [
    AppConfig,
    AuthGuard,
    AlertService,
    AuthenticationService,
    UserService,
    SchemaService
],
bootstrap: [AppComponent]
})

export class AppModule { }

The Error message I get when I use 'ng2-smart-table':  { main: 'bundles/table.umd.js',  defaultExtension: 'js' },

My "app.module.ts" file is as shown below:

Body:
You cannot use ng2-smart-table like this.
The ng2-smart-table release target is not ES5, but ES5. SystemJS knows that the index.js is in ES6 (and will not run in many browsers by default) and tries to transpile it using traceur to ES5. Although, there is bundled ES5 file which can be loaded by SystemJS. It is located in ng2-smart-table/bundles/table.umd.js. I am not very familiar with SystemJS, but you may try this:

'ng2-smart-table':   {main: 'bundles/table.umd.js', defaultExtension: 'js' }

For the future, please remember that traceur problems in SystemJS usually means that you need to point bundled ES5 library file instead of, for example, index.js.

P.S.: This would not be a problem with angular-cli.


问:
Equivalent to GOTO in conditions, Python
Since there is no goto operator in Python, what technique can be used instead?

Condition
If it is true, go to thread 1, if is false, go to thread 2
In thread we do something small and after that we go to thread 2 where all other actions take place.

答:
To the best of my knowledge it's not present (thankfully), but you should check this link

The "goto" module was an April Fool's joke, published on 1st April
  2004. Yes, it works, but it's a joke nevertheless. Please don't use it in real code!

ContentLicense: CC BY-SA 2.5


问:
Tableau map filter
Has anyone encountered an issue like this before:

I've created a very basic map plotting 39 places in England using Longitude and Latitude points.

I have a table that accompanies the map, and when you select one of the 39 places on the map, I want this to update the table to show only values for this selection.

I've set up the map as a filter but for some reason, only 7 of the 39 work when selected.

I decided to extract the data and save the file as a packaged workbook, to send to a colleague to investigate. However, when I extract the data and save as a packaged workbook and open in Reader or Desktop, everything works as it should do. All 39 places on the map filter other sheets correctly.

So I guess my question is, why would my original desktop version not work, but by saving it/extracting the data, it works perfectly?

For additional information, I am connecting to a live SQL server data source.

Edit: Added screenshots. I don't have this problem when I extract data and save as a packaged workbook. All the filters work.

答:
I have finally solved this one.

I was clicking on the actual map to 'Use as Filter'. What I have done instead is, go to Dashboard > Actions and Add Action making sure that the Target Filters are set to Selected Fields and not All Fields.

I think I'll avoid the 'Use as Filter' option from now on as that was a massive pain. It still makes no sense that it worked when extracted/saved as a packaged workbook, but then Tableau has lots of these little issues when you start using it more and more.

Title: Tableau map filter


问:
function loads only on change, i would it to load on document load
My knowledge of this is very limited, but I figured that the problem that I have is in this function. What it does is that it displays some options to be selected in an item post. From what I see it only loads when a category is changed. Because of that when you edit this post, this function will not display unless you change category to another one and then revert back to the one you want. I would like it to display every time, except for those categories that are in the if statement.

Please assist....

```<code>   $(document).on('change', "#catId", function () {
var optgroups = $(this).children("optgroup[label='Nekretnine'], optgroup[label='Posao'], optgroup[label='Usluge'], optgroup[label='Poljoprivredni oglasi'], optgroup[label='Kućni ljubimci'], optgroup[label='Turizam']");
$(optgroups).each(function(){
    if($(optgroups).children("option:selected").length){
        $("#condition-container").html('');
    } else {
        $.ajax({
            url: ajaxURL,
            type: "get",
            data: "request=condition-fields",
            dataType: "html",
            success: function(data) {
                if(data) {
                    $("#condition-container").html(data);
                }
            }
        });
    }
});
});
</code>```

答:
You just need to trigger your change event on document load. So under you on change function put this code</p>

```<code>$(document).on('change', "#catId", function () {
                var optgroups = $(this).children("optgroup[label='Nekretnine'], optgroup[label='Posao'], optgroup[label='Usluge'], optgroup[label='Poljoprivredni oglasi'], optgroup[label='Kućni ljubimci'], optgroup[label='Turizam']");
                $(optgroups).each(function () {
                    if ($(optgroups).children("option:selected").length) {
                        $("#condition-container").html('');
                    } else {
                        $.ajax({
                            url: ajaxURL,
                            type: "get",
                            data: "request=condition-fields",
                            dataType: "html",
                            success: function (data) {
                                if (data) {
                                    $("#condition-container").html(data);
                                }
                            }
                        });
                    }
                });
            });

            //Trigger change
             $(document).ready(function () {
                 $("#catId").trigger("change");
             });
</code>```

Body:
My knowledge of this is very limited, but I figured that the problem that I have is in this function. What it does is that it displays some options to be selected in an item post. From what I see it only loads when a category is changed. Because of that when you edit this post, this function will not display unless you change category to another one and then revert back to the one you want. I would like it to display every time, except for those categories that are in the if statement.

Please assist....

   $(document).on('change', "#catId", function () {
var optgroups = $(this).children("optgroup[label='Nekretnine'], optgroup[label='Posao'], optgroup[label='Usluge'], optgroup[label='Poljoprivredni oglasi'], optgroup[label='Kućni ljubimci'], optgroup[label='Turizam']");
$(optgroups).each(function(){
    if($(optgroups).children("option:selected").length){
        $("#condition-container").html('');
    } else {
        $.ajax({
            url: ajaxURL,
            type: "get",
            data: "request=condition-fields",
            dataType: "html",
            success: function(data) {
                if(data) {
                    $("#condition-container").html(data);
                }
            }
        });
    }
});
});

Body:
You just need to trigger your change event on document load. So under you on change function put this code

$(document).on('change', "#catId", function () {
                var optgroups = $(this).children("optgroup[label='Nekretnine'], optgroup[label='Posao'], optgroup[label='Usluge'], optgroup[label='Poljoprivredni oglasi'], optgroup[label='Kućni ljubimci'], optgroup[label='Turizam']");
                $(optgroups).each(function () {
                    if ($(optgroups).children("option:selected").length) {
                        $("#condition-container").html('');
                    } else {
                        $.ajax({
                            url: ajaxURL,
                            type: "get",
                            data: "request=condition-fields",
                            dataType: "html",
                            success: function (data) {
                                if (data) {
                                    $("#condition-container").html(data);
                                }
                            }
                        });
                    }
                });
            });

            //Trigger change
             $(document).ready(function () {
                 $("#catId").trigger("change");
             });


问:
How to get date & month using date in mysql
I want to get date & month from date. example 2017-06-15 so I want date & month i.e. -06-15. Do u have any idea? Really appreciated.

From Below query I am getting month from date. but I want both date & month

```<code>SELECT MONTHNAME(`date`) AS month_name FROM table_name;
</code>```

答:
```<code>SELECT DATE_FORMAT(date, '-%m-%d') AS month_name FROM table_name;
</code>```

<p>see the date_format documentation to see all the possible formats </p>

Body:
I want to get date & month from date. example 2017-06-15 so I want date & month i.e. -06-15. Do u have any idea? Really appreciated.

From Below query I am getting month from date. but I want both date & month

SELECT MONTHNAME(`date`) AS month_name FROM table_name;

Body:
SELECT DATE_FORMAT(date, '-%m-%d') AS month_name FROM table_name;

see the date_format documentation to see all the possible formats


问:
Count of islands of negative and positive numbers in a NumPy array
I have an array containing chunks of negative and chunks of positive elements. A much simplified example of it would be an array a looking like: array([-3, -2, -1,  1,  2,  3,  4,  5,  6, -5, -4])

(a<0).sum() and (a>0).sum() give me the total number of negative and positive elements but how do I count these in order? By this I mean I want to know that my array contains first 3 negative elements, 6 positive and 2 negative.

This sounds like a topic that have been addressed somewhere, and there may be a duplicate out there, but I can't find one.

A method is to use numpy.roll(a,1) in a loop over the whole array and count the number of elements of a given sign appearing in e.g. the first element of the array as it rolls, but it doesn't look much numpyic (or pythonic) nor very efficient to me.

答:
My (rather simple and probably inefficient) solution would be:</p>

```<code>import numpy as np
arr = np.array([-3, -2, -1,  1,  2,  3,  4,  5,  6, -5, -4])
sgn = np.sign(arr[0])
res = []
cntr = 1 # counting the first one
for i in range(1, len(arr)):
 if np.sign(arr[i]) != sgn:
  res.append(cntr)
  cntr = 0
  sgn *= -1
 cntr += 1
res.append(cntr)
print res
</code>```

Body:
My (rather simple and probably inefficient) solution would be:

import numpy as np
arr = np.array([-3, -2, -1,  1,  2,  3,  4,  5,  6, -5, -4])
sgn = np.sign(arr[0])
res = []
cntr = 1 # counting the first one
for i in range(1, len(arr)):
 if np.sign(arr[i]) != sgn:
  res.append(cntr)
  cntr = 0
  sgn *= -1
 cntr += 1
res.append(cntr)
print res


问:
Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php
This error message is being presented, any suggestions?

Allowed memory size of 33554432 bytes exhausted (tried to allocate
  43148176 bytes) in php

答: I hadn't renewed my hosting and the database was read-only. Joomla needed to write the session and couldn't do it.</p>

LastEditorDisplayName: macbirdie


答:
hi I assume you want the function fired on document load and on change, but for that you will need to use 2 triggers.

1) you allready have the on change trigger

2) use the $(document).ready() (https://learn.jquery.com/using-jquery-core/document-ready/) wrapper for onload.

There is possibly a much more gracefull solution, but I'm no JS expert so this will only get you to a working, although not the pretiest state

Title: function loads only on change, i would it to load on document load


问:
How might I obtain a Snapshot or Thumbnail of a web page using PHP?
I need to create Snapshots / Thumbshots / Site preview a-site.com.

There are some site as thumbshot.org that meets with I need. But I do not want to use an external service, not to depend on others for my project (What would happen if they close the site?)

For this reason, I am looking for some project to let me do this.

Any idea?

答:
There isn't anything in the PHP library to do this - you're looking at setting up an external application (with a queue) to take images, although you can of course use PHP to add items to the queue.

There are a couple of Windows functions in GD that takes screen shots of the computer (webserver - not the client) so perhaps you could write a script in PHP to do this.

Edit: Was thinking of these: imagegrabscreen and imagegrabwindow. I'm not sure they will do what you want however (even in full screen mode Firefox has  ablue bar at the top of the screen - not sure about other browsers). However, Pierre has something on these functions if you're interested.

I'd suggest writing an application in another language (I assume .NET has something) to do this for you.
Edit: This page tells you how to do it in C#

OwnerDisplayName: diego

OwnerDisplayName: Ross

ContentLicense: CC BY-SA 4.0

LastEditorDisplayName: Ross


问:
Updating an item in a FirebaseListObservable using AngularFire 2
I'm trying to update an item in a FirebaseListObservable object in an Angular2 project using Angularfire2. The definition for the FirebaseListObservable is as follows:

```<code>export declare type FirebaseOperation = string | firebase.database.Reference | firebase.database.DataSnapshot | AFUnwrappedDataSnapshot;
export declare class FirebaseListObservable<T> extends Observable<T> {
  _ref: firebase.database.Reference | firebase.database.Query;
  constructor(_ref: firebase.database.Reference | firebase.database.Query, subscribe?: <R>(subscriber: Subscriber<R>) => Subscription | Function | void);
  lift<T, R>(operator: Operator<T, R>): Observable<R>;
  push(val: any): firebase.database.ThenableReference;
  update(item: FirebaseOperation, value: Object): firebase.Promise<void>;
  remove(item?: FirebaseOperation): firebase.Promise<void>;
  _checkOperationCases(item: FirebaseOperation, cases: FirebaseOperationCases): firebase.Promise<void>;
}
</code>```

I have a service to show, save, delete, and update the houses that looks like the following:

```<code>@Injectable()
export class HousesService {
  private _houses$:FirebaseListObservable<IHouse[]>;
  constructor(private af:AngularFire) {
    this._houses$ = this.af.database.list('/houses');
  }
  save(house:IHouse) {
    if (house.hasOwnProperty('$key')) {
      this._houses.update('/houses/'+house.$key).set(house);
    } else {
      this._houses$.push(house);
    }
  }
  remove(id:any) {
    this._houses$.remove(id);
  }
}
</code>```

where houses$ is the FirebaseListObservable and house is an item from the list. House is an object that looks like the following:

```<code>{
  name: "Mrs. Friendly",
  notes: "Watch out for fence!",
  street: "2530 Adams Ave.",
  $key: "-KKQWsf26apDiXZNExZd"
 }
</code>```

When I try to save/update an existing item, I get the following error:

Uncaught Error: Firebase.update failed: First argument contains an
  invalid key ($key) in path /$key. Keys must be non-empty strings and
  can't contain ".", "#", "$", "/", "[", or "]"

I've tried putting the original object in the first parameter, putting the full URL there, and almost every combination you can think of. According to the definition for the Observable, the _ref should work there as well. I've also tried pulling the key out of the data to be stored and nothing seems to work. The only thing that seems to work is to remove the update line completely and use the following:

```<code>this.af.database.object('/houses/'+house.$key).set(house);
</code>```

I'm curious what I should have put in the first parameter so the update method would work.

I'm using Angular 2 rc-1, firebase 3.0.5, and angularfire 2.0.0-beta.1

答:
```<code>var key = house.$key
delete house.$key
this._houses.update(key, house)
</code>```

Body:
I'm trying to update an item in a FirebaseListObservable object in an Angular2 project using Angularfire2. The definition for the FirebaseListObservable is as follows:

export declare type FirebaseOperation = string | firebase.database.Reference | firebase.database.DataSnapshot | AFUnwrappedDataSnapshot;
export declare class FirebaseListObservable<T> extends Observable<T> {
  _ref: firebase.database.Reference | firebase.database.Query;
  constructor(_ref: firebase.database.Reference | firebase.database.Query, subscribe?: <R>(subscriber: Subscriber<R>) => Subscription | Function | void);
  lift<T, R>(operator: Operator<T, R>): Observable<R>;
  push(val: any): firebase.database.ThenableReference;
  update(item: FirebaseOperation, value: Object): firebase.Promise<void>;
  remove(item?: FirebaseOperation): firebase.Promise<void>;
  _checkOperationCases(item: FirebaseOperation, cases: FirebaseOperationCases): firebase.Promise<void>;
}

I have a service to show, save, delete, and update the houses that looks like the following:

@Injectable()
export class HousesService {
  private _houses$:FirebaseListObservable<IHouse[]>;
  constructor(private af:AngularFire) {
    this._houses$ = this.af.database.list('/houses');
  }
  save(house:IHouse) {
    if (house.hasOwnProperty('$key')) {
      this._houses.update('/houses/'+house.$key).set(house);
    } else {
      this._houses$.push(house);
    }
  }
  remove(id:any) {
    this._houses$.remove(id);
  }
}

where houses$ is the FirebaseListObservable and house is an item from the list. House is an object that looks like the following:

{
  name: "Mrs. Friendly",
  notes: "Watch out for fence!",
  street: "2530 Adams Ave.",
  $key: "-KKQWsf26apDiXZNExZd"
 }

When I try to save/update an existing item, I get the following error:

Uncaught Error: Firebase.update failed: First argument contains an
  invalid key ($key) in path /$key. Keys must be non-empty strings and
  can't contain ".", "#", "$", "/", "[", or "]"

I've tried putting the original object in the first parameter, putting the full URL there, and almost every combination you can think of. According to the definition for the Observable, the _ref should work there as well. I've also tried pulling the key out of the data to be stored and nothing seems to work. The only thing that seems to work is to remove the update line completely and use the following:

this.af.database.object('/houses/'+house.$key).set(house);

I'm curious what I should have put in the first parameter so the update method would work.

I'm using Angular 2 rc-1, firebase 3.0.5, and angularfire 2.0.0-beta.1


问:
Movesense cannot be put into DFU mode because it does not connect via the Movesense Android App
I wanted to use new sample codes, which have been recently updated on BitBucket (plippo/c85e1ba - Updated Movesense Core Lib to version 0.3.1.105 - Updated Movesense sample applications to version 0.3.1.105).

The new code compiled and built properly. After successfully putting the movesense into DFU mode and uploading this firmware I was unable to read out the characteristics with the Movesense android app.

The Movesense is detected by the Android App as well as by other BLE tools (e.g. nRF connect app). The Movesense app gets stuck while connecting to the device. Hence I cannot readout anything, or put the device into DFU mode in order to reprogramm it. However, with the nRF connect app I am able to connect to it.

Comparing the previous and current versions of the embedded code, I noticed that the sample apps have been split. However in the app_root.yaml file the section

```<code>apis:
  AccelerometerSample.*:
    apiId: 100
    defaultExecutionContext: PrimaryServices
  HelloWorld.*:
    apiId: 101
    defaultExecutionContext: PrimaryServices
</code>```

remained the same. I uploaded the sample app "accelerometer_app" where the HelloWorld Service is no longer available (compared to the old code). But is still listed in the yaml-file. I wonder if this is the reason why I cannot connect anymore with the Movesense App.

The last logged lines in the Android Monitor are the following ones

In the case of the old code, which is working:

```<code>05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: connect() - device: C2:4B:A6:1E:73:AE, auto: false
05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp()
05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp() - UUID=7eec028c-3252-434f-9dcf-cc5ced36dd30
05-24 15:52:05.352 29854-29866/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
05-24 15:52:05.414 29854-29854/com.movesense.android.sample_A_G_H.debug V/ViewRootImpl: Contents drawing finished : com.movesense.android.sample_A_G_H.debug/com.movesense.android.sample_A_G_H.MainActivity
05-24 15:52:07.548 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=C2:4B:A6:1E:73:AE
05-24 15:52:07.548 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: discoverServices() - device: C2:4B:A6:1E:73:AE
05-24 15:52:08.531 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onSearchComplete() = Device=C2:4B:A6:1E:73:AE Status=0
05-24 15:52:08.531 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: setCharacteristicNotification() - uuid: 34802252-7185-4d5d-b431-630e7050e8f0 enable: true
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/MovesenseAndroidWrapper: Connected device! serial ECKI5ABE47F3 address 10000001
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: adding device 10000001
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: getDevices 1
05-24 15:52:08.698 29854-30184/com.movesense.android.sample_A_G_H.debug D/RouteObserver: onNotify {"Serial": "ECKI5ABE47F3", "Type": "New"}
05-24 15:52:12.937 29854-30184/com.movesense.android.sample_A_G_H.debug D/addWhiteboardDevice: {"manufacturerName": "Suunto", "productName": "Movesense", "variant": "Unknown", "hwCompatibilityId": "C", "serial": "ECKI5ABE47F3", "pcbaSerial": "UNKNOWN", "sw": "0.3.0", "hw": "UNKNOW", "additionalVersionInfo": "UNKNOW", "addressInfo": "UNKNOW"}
05-24 15:52:13.022 29854-29854/com.movesense.android.sample_A_G_H.debug D/MainActivity: Connected to device: Peripheral [address: C2:4B:A6:1E:73:AE, name: Movesense ECKI5ABE47F3, RSSI: -43]
05-24 15:52:13.064 29854-29854/com.movesense.android.sample_A_G_H.debug I/Timeline: Timeline: Activity_launch_request id:com.movesense.android.sample_A_G_H.debug time:47413961
</code>```

In the case of the new code, which is not working:

```<code>05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: connect() - device: E8:E6:77:21:D1:45, auto: false
05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp()
05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp() - UUID=6c391ed2-8e59-42e5-9700-99758e9e8877
05-24 15:39:23.647 18160-18207/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
05-24 15:39:23.771 18160-18160/com.movesense.android.sample_A_G_H.debug V/ViewRootImpl: Contents drawing finished : com.movesense.android.sample_A_G_H.debug/com.movesense.android.sample_A_G_H.MainActivity
05-24 15:39:27.577 18160-18171/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=E8:E6:77:21:D1:45
05-24 15:39:27.577 18160-18171/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: discoverServices() - device: E8:E6:77:21:D1:45
05-24 15:39:28.647 18160-18190/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onSearchComplete() = Device=E8:E6:77:21:D1:45 Status=0
05-24 15:39:28.647 18160-18190/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: setCharacteristicNotification() - uuid: 34802252-7185-4d5d-b431-630e7050e8f0 enable: true
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/MovesenseAndroidWrapper: Connected device! serial ECKID9F62D52 address     10000001
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: adding device 10000001
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: getDevices 1
</code>```

It stops at the line D/BleEnumeratorImpl: getDevices 1.

This is an issue as I cannot put the movesense into DFU mode and reprogram it, so basically "it is broken" ;).

Question 1:
Are the services described in the yaml file the issue for this problem.

Question 2:
As I am able to see and connect to it via nRF connect App and be able to write data manually to the WRITE Characteristic, is there a way (command) which can be sent to the movesense, to put it into DFU mode.

Question 3: I cannot locate where the code gets stuck as I cannot track/follow BleEnumeratorImpl (see log lines). Where, in the entire android project is the BleEnumeratorImpl located?

I appreciate your help ))

答:
EDIT: The new movesense-device-lib is out that fixes this BLE connectivity issue

This is a known issue that was causing random builds to get stuck in BLE connection phase. The issue is fixed in the next release that should be out either today or tomorrow. Since the bug prevents booting into DFU firmware update mode, the sensors can be only saved using programming jig (J-TAG cable). For those customers that do not have the jig, please contact the Movesense support via email (info (at) movesense.com) and you'll get new sensors to replace the bricked ones.

I'm really sorry about the inconvenience.

Full disclosure: I work for Movesense team

Body:
I wanted to use new sample codes, which have been recently updated on BitBucket (plippo/c85e1ba - Updated Movesense Core Lib to version 0.3.1.105 - Updated Movesense sample applications to version 0.3.1.105).

The new code compiled and built properly. After successfully putting the movesense into DFU mode and uploading this firmware I was unable to read out the characteristics with the Movesense android app.

The Movesense is detected by the Android App as well as by other BLE tools (e.g. nRF connect app). The Movesense app gets stuck while connecting to the device. Hence I cannot readout anything, or put the device into DFU mode in order to reprogramm it. However, with the nRF connect app I am able to connect to it.

Comparing the previous and current versions of the embedded code, I noticed that the sample apps have been split. However in the app_root.yaml file the section

apis:
  AccelerometerSample.*:
    apiId: 100
    defaultExecutionContext: PrimaryServices
  HelloWorld.*:
    apiId: 101
    defaultExecutionContext: PrimaryServices

remained the same. I uploaded the sample app "accelerometer_app" where the HelloWorld Service is no longer available (compared to the old code). But is still listed in the yaml-file. I wonder if this is the reason why I cannot connect anymore with the Movesense App.

The last logged lines in the Android Monitor are the following ones

In the case of the old code, which is working:

05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: connect() - device: C2:4B:A6:1E:73:AE, auto: false
05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp()
05-24 15:52:05.350 29854-29854/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp() - UUID=7eec028c-3252-434f-9dcf-cc5ced36dd30
05-24 15:52:05.352 29854-29866/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
05-24 15:52:05.414 29854-29854/com.movesense.android.sample_A_G_H.debug V/ViewRootImpl: Contents drawing finished : com.movesense.android.sample_A_G_H.debug/com.movesense.android.sample_A_G_H.MainActivity
05-24 15:52:07.548 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=C2:4B:A6:1E:73:AE
05-24 15:52:07.548 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: discoverServices() - device: C2:4B:A6:1E:73:AE
05-24 15:52:08.531 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onSearchComplete() = Device=C2:4B:A6:1E:73:AE Status=0
05-24 15:52:08.531 29854-29881/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: setCharacteristicNotification() - uuid: 34802252-7185-4d5d-b431-630e7050e8f0 enable: true
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/MovesenseAndroidWrapper: Connected device! serial ECKI5ABE47F3 address 10000001
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: adding device 10000001
05-24 15:52:08.563 29854-29928/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: getDevices 1
05-24 15:52:08.698 29854-30184/com.movesense.android.sample_A_G_H.debug D/RouteObserver: onNotify {"Serial": "ECKI5ABE47F3", "Type": "New"}
05-24 15:52:12.937 29854-30184/com.movesense.android.sample_A_G_H.debug D/addWhiteboardDevice: {"manufacturerName": "Suunto", "productName": "Movesense", "variant": "Unknown", "hwCompatibilityId": "C", "serial": "ECKI5ABE47F3", "pcbaSerial": "UNKNOWN", "sw": "0.3.0", "hw": "UNKNOW", "additionalVersionInfo": "UNKNOW", "addressInfo": "UNKNOW"}
05-24 15:52:13.022 29854-29854/com.movesense.android.sample_A_G_H.debug D/MainActivity: Connected to device: Peripheral [address: C2:4B:A6:1E:73:AE, name: Movesense ECKI5ABE47F3, RSSI: -43]
05-24 15:52:13.064 29854-29854/com.movesense.android.sample_A_G_H.debug I/Timeline: Timeline: Activity_launch_request id:com.movesense.android.sample_A_G_H.debug time:47413961

In the case of the new code, which is not working:

05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: connect() - device: E8:E6:77:21:D1:45, auto: false
05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp()
05-24 15:39:23.643 18160-18160/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: registerApp() - UUID=6c391ed2-8e59-42e5-9700-99758e9e8877
05-24 15:39:23.647 18160-18207/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
05-24 15:39:23.771 18160-18160/com.movesense.android.sample_A_G_H.debug V/ViewRootImpl: Contents drawing finished : com.movesense.android.sample_A_G_H.debug/com.movesense.android.sample_A_G_H.MainActivity
05-24 15:39:27.577 18160-18171/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=E8:E6:77:21:D1:45
05-24 15:39:27.577 18160-18171/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: discoverServices() - device: E8:E6:77:21:D1:45
05-24 15:39:28.647 18160-18190/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: onSearchComplete() = Device=E8:E6:77:21:D1:45 Status=0
05-24 15:39:28.647 18160-18190/com.movesense.android.sample_A_G_H.debug D/BluetoothGatt: setCharacteristicNotification() - uuid: 34802252-7185-4d5d-b431-630e7050e8f0 enable: true
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/MovesenseAndroidWrapper: Connected device! serial ECKID9F62D52 address     10000001
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: adding device 10000001
05-24 15:39:28.688 18160-18171/com.movesense.android.sample_A_G_H.debug D/BleEnumeratorImpl: getDevices 1

It stops at the line D/BleEnumeratorImpl: getDevices 1.

This is an issue as I cannot put the movesense into DFU mode and reprogram it, so basically "it is broken" ;).

Question 1:
Are the services described in the yaml file the issue for this problem.

Question 2:
As I am able to see and connect to it via nRF connect App and be able to write data manually to the WRITE Characteristic, is there a way (command) which can be sent to the movesense, to put it into DFU mode.

Question 3: I cannot locate where the code gets stuck as I cannot track/follow BleEnumeratorImpl (see log lines). Where, in the entire android project is the BleEnumeratorImpl located?

I appreciate your help ))


问:
Can I register receiver for Download Manager's Download Incomplete action in Android?
I want to register receiver for Download manager's download incomplete action.
Actually I have a code where I am showing a loader while downloading a file and due to Insufficient Storage error.It ends up with Download incomplete notification in notification tray.
But As I have registered receiver forDownloadManager.ACTION_DOWNLOAD_COMPLETE . But It never got called as Actual action is Download incomplete. So My loader is not getting dismissed.
My Question is how should I detect INSUFFICIENT_SPACE_ERROR , So I can dismiss the loader and display appropriate message to User?

Another Alternative I  have tried is -
I am calculating Available space on SD Card before downloading the file, But in that case too, On which threshold value I should write condition?

My Code -

```<code>BroadcastReceiver attachmentDownloadCompleteReceive = new BroadcastReceiver() {
        @Override
        public void onReceive(@NonNull Context context, @NonNull Intent intent) {
            String action = intent.getAction();

            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                long downloadId = intent.getLongExtra(
                        DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                openDownloadedAttachment(context, downloadId);
            }
            else {
                // Loader Dismissed and Displayed appropriate Message to user.
            }
        }
    };
</code>```

Can you please help me with this?
Any help will be appreciated.
Thank you.

答:
Please refer this example. In this approach, your data status column will tell you the exact download status of the file.

Accordingly, hide the progress dialog and display the appropriate message.

Body:
I want to register receiver for Download manager's download incomplete action.
Actually I have a code where I am showing a loader while downloading a file and due to Insufficient Storage error.It ends up with Download incomplete notification in notification tray.
But As I have registered receiver forDownloadManager.ACTION_DOWNLOAD_COMPLETE . But It never got called as Actual action is Download incomplete. So My loader is not getting dismissed.
My Question is how should I detect INSUFFICIENT_SPACE_ERROR , So I can dismiss the loader and display appropriate message to User?

Another Alternative I  have tried is -
I am calculating Available space on SD Card before downloading the file, But in that case too, On which threshold value I should write condition?

My Code -

BroadcastReceiver attachmentDownloadCompleteReceive = new BroadcastReceiver() {
        @Override
        public void onReceive(@NonNull Context context, @NonNull Intent intent) {
            String action = intent.getAction();

            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                long downloadId = intent.getLongExtra(
                        DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                openDownloadedAttachment(context, downloadId);
            }
            else {
                // Loader Dismissed and Displayed appropriate Message to user.
            }
        }
    };

Can you please help me with this?
Any help will be appreciated.
Thank you.


问:
Why does the content overflow when mu content is set to 100% height
My layout has a header and footer and in between those a content div.

When I set my content height to 100% it overflows instead of expanding the div.

* {
  margin: 0;
  padding: 0;
}

body,
html {
  height: 100%;
}

.header,
.footer {
  height: 100px;
  width: 100%;
  background-color: red;
  color: white;
}

.content {
  width: 100%;
  height: 100%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="header">
  <h1>Heading</h1>
</div>
<div class="content">
  <p>Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy</p>

  <span>
                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy
            </span>
  <p>Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy</p>

  <span>
                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy
            </span>
  <p>Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy</p>

  <span>
                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy
            </span>
  <p>Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy</p>

  <span>
                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy
            </span>
  <p>Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy</p>

  <span>
                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy
            </span>
</div>
<div class="footer">
  <h1>Footer
    <h1>
</div></code>```

I already know the solution is to get rid of the 100% height.
But what I want to know is why does this happen. Shouldn't 100% height expand it's height to fit the parent?

Here is the fiddle for my code.

答:
Use min-height for html and content instead of height attribute,</p>

```<code><style>
* {
  margin: 0;
  padding: 0;
}

body,
html {
  min-height: 100%;
}

.header,
.footer {
  height: 100px;
  width: 100%;
  background-color: red;
  color: white;
}

.content {
  width: 100%;
  min-height: 100%;
}
</style>
</code>```

Body:
My layout has a header and footer and in between those a content div.

When I set my content height to 100% it overflows instead of expanding the div.

* {
  margin: 0;
  padding: 0;
}

body,
html {
  height: 100%;
}

.header,
.footer {
  height: 100px;
  width: 100%;
  background-color: red;
  color: white;
}

.content {
  width: 100%;
  height: 100%;
}

Heading

Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy

                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy

Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy

                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy

Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy

                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy

Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy

                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy

Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque
    montesque rhoncus quis eros. Vestnunc nonummy

                Sapibulumnibh phasellus nulla egestibulum enim pretium elit tincidunt estiquam ultrisque donectetur. Sedcondimentumsan odio hendrerit proin vitae dignis nibh ac justo id congue. Amesintesque vel curabitae volutpat donec alique nasceleifendimentesque montesque rhoncus quis eros. Vestnunc nonummy

Footer

I already know the solution is to get rid of the 100% height.
But what I want to know is why does this happen. Shouldn't 100% height expand it's height to fit the parent?

Here is the fiddle for my code.

Body:
Use min-height for html and content instead of height attribute,

<style>
* {
  margin: 0;
  padding: 0;
}

body,
html {
  min-height: 100%;
}

.header,
.footer {
  height: 100px;
  width: 100%;
  background-color: red;
  color: white;
}

.content {
  width: 100%;
  min-height: 100%;
}
</style>


问:
Run python in background
I've been searching a lot for this problem, but I didnt find any valuable answer.

I want to make a script (lets say it is a library) which runs some functions at reboot. Inside my library, there will be a function like

```<code>def randomfunction():
    print("randomtext")
</code>```

After loading this function, everytime a call for randomfunction() in any python run (I will .py as cgi scripts) will return me "randomtext".

Is that possible or I miss something?

It is working on python idle if I use exec, but I want this exec to be on system. That would be for a linux OS.

答:
Don't you need some kind of Interprocess Communication for this?

Might be worth taking a look at these docs: Python IPC

Also,
this SO post might help you. I think it offers a solution to what you are looking for.

Title: Run python in background

Body:
I've been searching a lot for this problem, but I didnt find any valuable answer.

I want to make a script (lets say it is a library) which runs some functions at reboot. Inside my library, there will be a function like

def randomfunction():
    print("randomtext")

After loading this function, everytime a call for randomfunction() in any python run (I will .py as cgi scripts) will return me "randomtext".

Is that possible or I miss something?

It is working on python idle if I use exec, but I want this exec to be on system. That would be for a linux OS.


问:
Jquery popup for images
there are three or more images in a single html page and need to show same image in popup after clicking on particular image. Is there anything which I can use for this?</p>

```<code><img class="wp-image-4596 size-medium" src="img1.jpg" alt="img1" width="232" height="300">
<img class="wp-image-4596 size-medium" src="img2.jpg" alt="img2" width="232" height="300">
<img class="wp-image-4596 size-medium" src="img3.jpg" alt="img3" width="232" height="300">
</code>```

答:
You can do it in javascript by adding an onclick function on your images

$('.wp-image-4596').click(function(){
    $('#popupimage').attr('src', $(this).attr('src'));
});

this will get the source of the clicked image and use it as the source for your popup image

Title: Jquery popup for images

Body:
You can do it in javascript by adding an onclick function on your images

$('.wp-image-4596').click(function(){
    $('#popupimage').attr('src', $(this).attr('src'));
});

<img class="wp-image-4596 size-medium" src="img1.jpg" alt="img1" width="232" height="300">
<img class="wp-image-4596 size-medium" src="img2.jpg" alt="img2" width="232" height="300">
<img class="wp-image-4596 size-medium" src="img3.jpg" alt="img3" width="232" height="300">
<div id="popup"><!--this is your pop for example-->
    <img src='' id="popupimage">
</div>

this will get the source of the clicked image and use it as the source for your popup image