问:
How can I put an animation in the path of my circular progress bar?
I have a circular progress bar that has two paths. On one of those paths increases in length as the data comes in, eventually turning the entire circle red.

SVG HTML

```<code><path d="M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94" stroke="#A9B0B7" stroke-width="4" fill-opacity="0">
  </path>

  <path id="path2" d="M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94" stroke="#EB483F" stroke-width="6" fill-opacity="0" style="stroke-dasharray: 295.416, 295.416; stroke-dashoffset: 250"></path>
  </svg>
</code>```

CSS (Just makes loading of red path smoother)

```<code>#path2 {
  -webkit-transition-property: stroke-dashoffset; /* Safari */
  transition-property: stroke-dashoffset;
  -webkit-transition-duration: 1s; /* Safari */
  transition-duration: 0.3s;
}

.viewbox {
  width: 50%;
}
</code>```

https://jsfiddle.net/z5yb5kr9/

I would like for the remaining gray portion to have an animation such as a small div running through it lighting it up. Something similar to this

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_loader

I believe that I need to add some sort of keyframe animation and put the div inside the Path of the svg but I am not sure exactly what the method for doing so is.

答:
Here's one way you could do the pulsing anumation on a circular progress bar.

In order to get the pulse effect showing inside a growing progress bar, the most obvious way is to create the pulse effect as it's own animation, then mask it with the actually progress arc.

Firstly, let's start with the plain red progress bar.  I've added a grow animation for testing.

.viewbox {
  width: 50%;
}

#progress {
  stroke-dasharray: 296 296;
  stroke-dashoffset: 296;
  animation: grow 5s ease-out infinite;
}

@keyframes grow {
  100% { stroke-dashoffset: 0; }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><svg class="viewbox" viewBox="0 0 100 100">

  <circle id="grey" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)"
          stroke="#A9B0B7" stroke-width="4" fill="none"/>

  <circle id="progress" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)" pointer-events="all"
          stroke="#EB483F" stroke-width="6" fill="none"/>
</svg></code>```

Next, let's create our pulse animation which mimics the example you gave in an answer that was deleted.

.viewbox {
  width: 50%;
}

#pulse {
  stroke-dasharray: 0 0 0 296;
  animation: pulse 1.5s linear infinite;
}

@keyframes pulse {
   33% { stroke-dasharray: 0   0 148 296; }
   66% { stroke-dasharray: 0  50 200 296; }
  100% { stroke-dasharray: 0 296   0 296; }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><svg class="viewbox" viewBox="0 0 100 100">

  <rect width="100" height="100" fill="#EB483F"/>
  <circle id="pulse" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)" pointer-events="all"
          stroke="white" stroke-width="8" stroke-opacity="0.4" fill="none"/>
</svg></code>```

It's just a translucent circle (with a dash animation) on a red background.

The penultimate step is to convert the first example into the form we need for a mask. In masks, black is transparent and white is opaque.

.viewbox {
  width: 50%;
}

#progress {
  stroke-dasharray: 296 296;
  stroke-dashoffset: 296;
  animation: grow 5s ease-out infinite;
}

@keyframes grow {
  100% { stroke-dashoffset: 0; }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><svg class="viewbox" viewBox="0 0 100 100">

  <rect width="100" height="100" fill="black"/>

  <circle id="progress" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)" pointer-events="all"
          stroke="white" stroke-width="6" fill="none"/>
</svg></code>```

The final step is to combine the last two steps. We turn the previous step into a proper <mask> and use it to mask the pulse animation.

.viewbox {
  width: 50%;
}

#progress {
  stroke-dasharray: 296 296;
  stroke-dashoffset: 296;
  animation: grow 5s ease-out infinite;
}

@keyframes grow {
  100% { stroke-dashoffset: 0; }
}

#pulse {
  stroke-dasharray: 0 0 0 296;
  animation: pulse 1.5s linear infinite;
}

@keyframes pulse {
   33% { stroke-dasharray: 0   0 148 296; }
   66% { stroke-dasharray: 0  50 200 296; }
  100% { stroke-dasharray: 0 296   0 296; }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><svg class="viewbox" viewBox="0 0 100 100">

  <defs>
    <mask id="progress-as-mask" >
      <rect width="100" height="100" fill="black"/>
      <circle id="progress" cx="50" cy="50" r="47"
              transform="rotate(-90 50 50)" pointer-events="all"
              stroke="white" stroke-width="6" fill="none"/>
    </mask>
  </defs>

  <circle id="grey" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)"
          stroke="#A9B0B7" stroke-width="4" fill="none"/>

  <g mask="url(#progress-as-mask)">
    <rect width="100" height="100" fill="#EB483F"/>
    <circle id="pulse" cx="50" cy="50" r="47"
            transform="rotate(-90 50 50)" pointer-events="all"
            stroke="white" stroke-width="8" stroke-opacity="0.4" fill="none"/>
  </g>
</svg></code>```

You weren't entirely clear on what you wanted. But hopefully, this has at least got you started.

Body:
I have a circular progress bar that has two paths. On one of those paths increases in length as the data comes in, eventually turning the entire circle red.

SVG HTML

<path d="M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94" stroke="#A9B0B7" stroke-width="4" fill-opacity="0">
  </path>

  <path id="path2" d="M 50,50 m 0,-47 a 47,47 0 1 1 0,94 a 47,47 0 1 1 0,-94" stroke="#EB483F" stroke-width="6" fill-opacity="0" style="stroke-dasharray: 295.416, 295.416; stroke-dashoffset: 250"></path>
  </svg>

CSS (Just makes loading of red path smoother)

#path2 {
  -webkit-transition-property: stroke-dashoffset; /* Safari */
  transition-property: stroke-dashoffset;
  -webkit-transition-duration: 1s; /* Safari */
  transition-duration: 0.3s;
}

.viewbox {
  width: 50%;
}

https://jsfiddle.net/z5yb5kr9/

I would like for the remaining gray portion to have an animation such as a small div running through it lighting it up. Something similar to this

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_loader

I believe that I need to add some sort of keyframe animation and put the div inside the Path of the svg but I am not sure exactly what the method for doing so is.

Body:
Here's one way you could do the pulsing anumation on a circular progress bar.

In order to get the pulse effect showing inside a growing progress bar, the most obvious way is to create the pulse effect as it's own animation, then mask it with the actually progress arc.

Firstly, let's start with the plain red progress bar.  I've added a grow animation for testing.

.viewbox {
  width: 50%;
}

#progress {
  stroke-dasharray: 296 296;
  stroke-dashoffset: 296;
  animation: grow 5s ease-out infinite;
}

@keyframes grow {
  100% { stroke-dashoffset: 0; }
}

<svg class="viewbox" viewBox="0 0 100 100">

  <circle id="grey" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)"
          stroke="#A9B0B7" stroke-width="4" fill="none"/>

  <circle id="progress" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)" pointer-events="all"
          stroke="#EB483F" stroke-width="6" fill="none"/>
</svg>

Next, let's create our pulse animation which mimics the example you gave in an answer that was deleted.

.viewbox {
  width: 50%;
}

#pulse {
  stroke-dasharray: 0 0 0 296;
  animation: pulse 1.5s linear infinite;
}

@keyframes pulse {
   33% { stroke-dasharray: 0   0 148 296; }
   66% { stroke-dasharray: 0  50 200 296; }
  100% { stroke-dasharray: 0 296   0 296; }
}

<svg class="viewbox" viewBox="0 0 100 100">

  <rect width="100" height="100" fill="#EB483F"/>
  <circle id="pulse" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)" pointer-events="all"
          stroke="white" stroke-width="8" stroke-opacity="0.4" fill="none"/>
</svg>

It's just a translucent circle (with a dash animation) on a red background.

The penultimate step is to convert the first example into the form we need for a mask. In masks, black is transparent and white is opaque.

.viewbox {
  width: 50%;
}

#progress {
  stroke-dasharray: 296 296;
  stroke-dashoffset: 296;
  animation: grow 5s ease-out infinite;
}

@keyframes grow {
  100% { stroke-dashoffset: 0; }
}

<svg class="viewbox" viewBox="0 0 100 100">

  <rect width="100" height="100" fill="black"/>

  <circle id="progress" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)" pointer-events="all"
          stroke="white" stroke-width="6" fill="none"/>
</svg>

The final step is to combine the last two steps. We turn the previous step into a proper <mask> and use it to mask the pulse animation.

.viewbox {
  width: 50%;
}

#progress {
  stroke-dasharray: 296 296;
  stroke-dashoffset: 296;
  animation: grow 5s ease-out infinite;
}

@keyframes grow {
  100% { stroke-dashoffset: 0; }
}

#pulse {
  stroke-dasharray: 0 0 0 296;
  animation: pulse 1.5s linear infinite;
}

@keyframes pulse {
   33% { stroke-dasharray: 0   0 148 296; }
   66% { stroke-dasharray: 0  50 200 296; }
  100% { stroke-dasharray: 0 296   0 296; }
}

<svg class="viewbox" viewBox="0 0 100 100">

  <defs>
    <mask id="progress-as-mask" >
      <rect width="100" height="100" fill="black"/>
      <circle id="progress" cx="50" cy="50" r="47"
              transform="rotate(-90 50 50)" pointer-events="all"
              stroke="white" stroke-width="6" fill="none"/>
    </mask>
  </defs>

  <circle id="grey" cx="50" cy="50" r="47"
          transform="rotate(-90 50 50)"
          stroke="#A9B0B7" stroke-width="4" fill="none"/>

  <g mask="url(#progress-as-mask)">
    <rect width="100" height="100" fill="#EB483F"/>
    <circle id="pulse" cx="50" cy="50" r="47"
            transform="rotate(-90 50 50)" pointer-events="all"
            stroke="white" stroke-width="8" stroke-opacity="0.4" fill="none"/>
  </g>
</svg>

You weren't entirely clear on what you wanted. But hopefully, this has at least got you started.


来源: stackexchange

问:
Running Xposed inside Google Android Emulator with custom image
Problem description:

I need to get droidmon working on a specific android image with predefined parameters. Xposed framework shows an error on installation, that it requires root access.

Environment:

Google Android Emulator running a custom rooted Android 4.4.2 x86 image with kernel version 3.4.67+ (but i have the same problem with 3.10+)
Used parameters (+ extra params that have nothing to do with android itslef):

-avd

-kernel

-ramdisk

-no-cache

-selinux permissive

-no-snapstorage

-verbose

-show-kernel

SDK-Tools-Version: 25.2.2

SDK-Platform-Tools: 24.0.3

Android is configured to allow unkown sources for apks

Already tried:

Remounting /system RW

Using -selinux disabled (xposed however requires -selinux permissive)

Extracting the update-binary from xposed and run the script with su

Current Status:

If i try installing Xposed i get the following log messages from the emulator:

```<code>[  355.372965] type=1400 audit(1477138733.355:23): avc:  denied  { execute } for  pid=2796 comm="posed.installer" name="app_process" dev="mtdblock1" ino=7847 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
[  355.372984] type=1400 audit(1477138733.355:24): avc:  denied  { execute_no_trans } for  pid=2796 comm="posed.installer" path="/data/data/de.robv.android.xposed.installer/cache/app_process" dev="mtdblock1" ino=7847 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
[  355.440354] type=1400 audit(1477138733.415:25): avc:  denied  { read } for  pid=2769 comm="posed.installer" name="app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  355.440410] type=1400 audit(1477138733.415:26): avc:  denied  { open } for  pid=2769 comm="posed.installer" name="app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  355.440450] type=1400 audit(1477138733.415:27): avc:  denied  { getattr } for  pid=2769 comm="posed.installer" path="/system/bin/app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  365.476143] type=1400 audit(1477138743.455:28): avc:  denied  { execute } for  pid=2805 comm="Thread-110" name="su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
[  365.476280] type=1400 audit(1477138743.455:29): avc:  denied  { read open } for  pid=2805 comm="Thread-110" name="su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
[  365.476371] type=1400 audit(1477138743.455:30): avc:  denied  { execute_no_trans } for  pid=2805 comm="Thread-110" path="/system/xbin/su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
</code>```

Status-Update:

As i know for now, the image was not rooted properly. I rerooted the Image using the packaged su binary from SuperSU-2.78. I manipulated the system.img by mounting it to a folder on my linux machine and added su and daemonsu (basically su copied and renamed) to /system/xbin/ and changed permissions to 6755 for both files. Additionally for now i added 2 lines to the end of /etc/init.goldfish.sh

```<code>#remount /system rw
mount -o rw,remount /system

#start daemonsu as auto-daemon
/system/xbin/daemonsu --auto-daemon
</code>```

After installing both Superuser.apk from SuperSU and a suitable Xposed-Version, Xposed initially installs but after reboot it leads to segfaults in libdvm.so

答:
Finally managed to get this working (requires older sdk version (pre November 2016)

SuperSU still required as told in the question above

Kernel Image lower than version 3.10 (kernel-qemu or engine classic)

Start emulator in verbose-mode

note the temporary file which is used to mount /system inside qemu

Install Xposed but Cancel reboot

Copy temporary system.img from /tmp/android-{username}/emulator-{random chars} to lets say your home directory

Shutdown emulator

Overwrite existing system.img with the one from your home directory

Start Emulator again

Xposed should now be operating

Kernel Version 3.10+ (kernel-ranchu or real sandboxed emulator)

Unfortunatly there is currently no known way of modifying the system.img from within the ranchu-emulator, ranchu seems to block every write-operation.
The blocked operations let the system think, that the partition is broken, so the system remounts the partition readonly as a safty fallback.

Two found work-arounds:

1.) Use parameter -engine classic when starting the emulator (therefore forcing kernel-qemu) you can use the steps above to do your changes

2.) Use a kernel-image lower version 3.10 to avoid emulator ranchu. You can use the steps above and after your changes have been applied use the previous kernel-image again

ContentLicense: CC BY-SA 3.0

Body:
Problem description:

I need to get droidmon working on a specific android image with predefined parameters. Xposed framework shows an error on installation, that it requires root access.

Environment:

Google Android Emulator running a custom rooted Android 4.4.2 x86 image with kernel version 3.4.67+ (but i have the same problem with 3.10+)
Used parameters (+ extra params that have nothing to do with android itslef):

-avd

-kernel

-ramdisk

-no-cache

-selinux permissive

-no-snapstorage

-verbose

-show-kernel

SDK-Tools-Version: 25.2.2

SDK-Platform-Tools: 24.0.3

Android is configured to allow unkown sources for apks

Already tried:

Remounting /system RW

Using -selinux disabled (xposed however requires -selinux permissive)

Extracting the update-binary from xposed and run the script with su

Current Status:

If i try installing Xposed i get the following log messages from the emulator:

[  355.372965] type=1400 audit(1477138733.355:23): avc:  denied  { execute } for  pid=2796 comm="posed.installer" name="app_process" dev="mtdblock1" ino=7847 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
[  355.372984] type=1400 audit(1477138733.355:24): avc:  denied  { execute_no_trans } for  pid=2796 comm="posed.installer" path="/data/data/de.robv.android.xposed.installer/cache/app_process" dev="mtdblock1" ino=7847 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=1
[  355.440354] type=1400 audit(1477138733.415:25): avc:  denied  { read } for  pid=2769 comm="posed.installer" name="app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  355.440410] type=1400 audit(1477138733.415:26): avc:  denied  { open } for  pid=2769 comm="posed.installer" name="app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  355.440450] type=1400 audit(1477138733.415:27): avc:  denied  { getattr } for  pid=2769 comm="posed.installer" path="/system/bin/app_process" dev="mtdblock0" ino=96 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:zygote_exec:s0 tclass=file permissive=1
[  365.476143] type=1400 audit(1477138743.455:28): avc:  denied  { execute } for  pid=2805 comm="Thread-110" name="su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
[  365.476280] type=1400 audit(1477138743.455:29): avc:  denied  { read open } for  pid=2805 comm="Thread-110" name="su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1
[  365.476371] type=1400 audit(1477138743.455:30): avc:  denied  { execute_no_trans } for  pid=2805 comm="Thread-110" path="/system/xbin/su" dev="mtdblock0" ino=972 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:su_exec:s0 tclass=file permissive=1

Status-Update:

As i know for now, the image was not rooted properly. I rerooted the Image using the packaged su binary from SuperSU-2.78. I manipulated the system.img by mounting it to a folder on my linux machine and added su and daemonsu (basically su copied and renamed) to /system/xbin/ and changed permissions to 6755 for both files. Additionally for now i added 2 lines to the end of /etc/init.goldfish.sh

#remount /system rw
mount -o rw,remount /system

#start daemonsu as auto-daemon
/system/xbin/daemonsu --auto-daemon

After installing both Superuser.apk from SuperSU and a suitable Xposed-Version, Xposed initially installs but after reboot it leads to segfaults in libdvm.so


问:
Randomly generate more proportion of zeroes python
I want to simulate a variable which can have values between 0 and 1. But I also want that this random variable to have 80% zeroes. Currently I ma doing the following:

```<code>data['response']=np.random.uniform(0,1,15000)#simulate response
data['response']=data['response'].apply(lambda x:0 if x<0.85 else x)
</code>```

But this results in only the extreme values(0 and .8+) in the variable. I want to have 80 percent zeroes and rest 20% rows to have values between zero and one. This has to be done randomly.

答:
We could draw numbers from a uniform distribution extended to the negative side, then take max with zero:

```<code>>>> numpy.maximum(0, numpy.random.uniform(-4, 1, 15000))
array([ 0.57310319,  0.        ,  0.02696571, ...,  0.        ,
        0.        ,  0.        ])
>>> a = _
>>> sum(a <= 0)
12095
>>> sum(a > 0)
2905
>>> 12095 / 15000
0.8063333333333333
</code>```

Here -4 is used because 4 / (4 + 1) = 80%.

Since the result is a sparse array, perhaps a SciPy sparse matrix is more appropriate.

```<code>>>> a = scipy.sparse.rand(1, 15000, 0.2)
>>> a.toarray()
array([[ 0.        ,  0.03971366,  0.        , ...,  0.        ,
         0.        ,  0.9252341 ]])
</code>```

Here 0.2 = 1 − 0.8 is the density of the array. The nonzero numbers are distributed uniformly between 0 and 1.

Body:
I want to simulate a variable which can have values between 0 and 1. But I also want that this random variable to have 80% zeroes. Currently I ma doing the following:

data['response']=np.random.uniform(0,1,15000)#simulate response
data['response']=data['response'].apply(lambda x:0 if x<0.85 else x)

But this results in only the extreme values(0 and .8+) in the variable. I want to have 80 percent zeroes and rest 20% rows to have values between zero and one. This has to be done randomly.

Body:
We could draw numbers from a uniform distribution extended to the negative side, then take max with zero:

>>> numpy.maximum(0, numpy.random.uniform(-4, 1, 15000))
array([ 0.57310319,  0.        ,  0.02696571, ...,  0.        ,
        0.        ,  0.        ])
>>> a = _
>>> sum(a <= 0)
12095
>>> sum(a > 0)
2905
>>> 12095 / 15000
0.8063333333333333

Here -4 is used because 4 / (4 + 1) = 80%.

Since the result is a sparse array, perhaps a SciPy sparse matrix is more appropriate.

>>> a = scipy.sparse.rand(1, 15000, 0.2)
>>> a.toarray()
array([[ 0.        ,  0.03971366,  0.        , ...,  0.        ,
         0.        ,  0.9252341 ]])

Here 0.2 = 1 − 0.8 is the density of the array. The nonzero numbers are distributed uniformly between 0 and 1.


问:
how to get the selected cell values and unselected cell values in uitableview in different array using objective c
pls check the image

i am very new to iOS how to get the selected cell values in one array and unselected cell value in the another array using by using checkmarks in objective c

```<code> - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
  NSArray *selectedRows=[_mytableview indexPathsForSelectedRows];
indexofselectedcell = [[NSMutableArray alloc]init];

valueofselectedcell = [[NSMutableArray alloc]init];
for (int i=0; i<selectedRows.count; i++) {
   [indexofselectedcell addObject:indexPath
     customcell *cell = (customcell *)[_mytableview cellForRowAtIndexPath:indexPath];
    NSString *test = cell.balance.text;
    [valueofselectedcell addObject:test];
    NSLog(@"%@ the value of the selected cell value is ",valueofselectedcell);
    NSArray *array = [valueofselectedcell copy];
    NSNumber* sum = [array valueForKeyPath: @"@sum.self"];
    NSLog(@"the sum valuie is .... %@",sum);
    NSString *totalamount = [sum stringValue];
    _amountlabel.text=totalamount;
    NSInteger index = [valueofselectedcell indexOfObject:totalamount];
    NSLog(@"%ld the index value in the array is",(long)index);

}}
 -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *totalamount;
if ([indexofselectedcell containsObject: indexPath])
{
    NSInteger anIndex=[indexofselectedcell indexOfObject:indexPath];
    [indexofselectedcell removeObjectAtIndex:anIndex];
    [valueofselectedcell removeObjectAtIndex:anIndex];
    NSLog(@"the value of the unselected cell value is..... %@",valueofselectedcell);
    NSArray *array = [valueofselectedcell copy];
    NSNumber* sum = [array valueForKeyPath: @"@sum.self"];
   totalamount = [sum stringValue];
    _amountlabel.text=totalamount;
    totalamount= nil;
}   }
</code>```

答:
Pavithra I tried sample project for your question and output.If I get unselected and selected cells in separate array,it crashed as I could not check two array in cellForRowAtIndexPath.So that I save selected and unSelected values in one array.

I created simple understandable solution.I have set values in tableview as unselected as default.If you selected(when you click the cell) it shows UITableViewCellAccessoryCheckmark and other show UITableViewCellAccessoryNone.

It works perfectly.You can easily get.

ViewController.h

```<code>#import <UIKit/UIKit.h>
@interface ViewController :  UIViewController<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *tableViewSelectUnSelect;
@end
</code>```

ViewController.m

```<code>#import "ViewController.h"

@interface ViewController (){
    NSMutableArray *arrVal,*arrSelectedUnSelectedValues,*arrSelectedValues,*arrUnSelectedValues;
    NSMutableArray *arrSubTitle;
}

@end

@implementation ViewController

@synthesize tableViewSelectUnSelect;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    arrVal= [[NSMutableArray alloc]initWithObjects:@"India",@"China",@"Korea",@"Japan",@"Peru",@"Italy",@"France",@"US",@"Dubai",@"UK",@"Nepal",nil];
    arrSubTitle = [[NSMutableArray alloc]initWithObjects:@"100",@"70",@"80",@"90",@"50",@"60",@"70",@"50",@"40",@"30",@"80",nil];
    arrSelectedUnSelectedValues= [[NSMutableArray alloc]init];
    arrSelectedValues = [[NSMutableArray alloc]init];
    arrUnSelectedValues = [[NSMutableArray alloc]init];
    for(int j=0;j<[arrVal count];j++)
    {
        [arrSelectedUnSelectedValues addObject:@"unselected"]; //As Default it is in UnSelected State
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource Methods
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return arrVal.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *strCell = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strCell];
    if(cell==nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:strCell];
    }
    if([[arrSelectedUnSelectedValues objectAtIndex:indexPath.row] isEqualToString:@"selected"])
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    else
        cell.accessoryType = UITableViewCellAccessoryNone;
    cell.textLabel.text = [arrVal objectAtIndex:indexPath.row];
    cell.detailTextLabel.text = [arrSubTitle objectAtIndex:indexPath.row];
    return cell;
}

#pragma mark - UITableViewDelegate Methods
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    @try
    {
        CGPoint touchPoint = [cell convertPoint:CGPointZero toView:tableViewSelectUnSelect];
        NSIndexPath *indexPath = [tableViewSelectUnSelect indexPathForRowAtPoint:touchPoint];
        NSLog(@"The arrSelectedUnSelectedValues  are %@",arrSelectedUnSelectedValues );
        NSString *strValue;

        if([arrSelectedUnSelectedValues count]==0)
        {
            for(int i=0; i<[arrVal count]; i++)
            {
                [arrSelectedUnSelectedValues addObject:@"unselected"];
            }
        }
        if([[arrSelectedUnSelectedValues objectAtIndex:indexPath.row] isEqualToString:@"selected"])
        {
            cell.accessoryType = UITableViewCellAccessoryNone;
            [arrSelectedUnSelectedValues replaceObjectAtIndex:indexPath.row withObject:@"unselected"];
            strValue = cell.detailTextLabel.text;
            [arrUnSelectedValues addObject:strValue];
            NSLog(@"The arrUnSelectedValues are - %@",arrUnSelectedValues);
        }
        else
        {
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
            [arrSelectedUnSelectedValues replaceObjectAtIndex:indexPath.row withObject:@"selected"];
            strValue = cell.detailTextLabel.text;
            [arrSelectedValues addObject:strValue];
            NSLog(@"The arrSelectedValues - %@",arrSelectedValues);
        }
    }
    @catch (NSException *exception) {
        NSLog(@"The exception is-%@",exception);
    }
}

@end
</code>```

First when I run the application it shows like below

Then when I select values from the tableView

Then finally printed results are

Body:
pls check the image

i am very new to iOS how to get the selected cell values in one array and unselected cell value in the another array using by using checkmarks in objective c

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
  NSArray *selectedRows=[_mytableview indexPathsForSelectedRows];
indexofselectedcell = [[NSMutableArray alloc]init];

valueofselectedcell = [[NSMutableArray alloc]init];
for (int i=0; i<selectedRows.count; i++) {
   [indexofselectedcell addObject:indexPath
     customcell *cell = (customcell *)[_mytableview cellForRowAtIndexPath:indexPath];
    NSString *test = cell.balance.text;
    [valueofselectedcell addObject:test];
    NSLog(@"%@ the value of the selected cell value is ",valueofselectedcell);
    NSArray *array = [valueofselectedcell copy];
    NSNumber* sum = [array valueForKeyPath: @"@sum.self"];
    NSLog(@"the sum valuie is .... %@",sum);
    NSString *totalamount = [sum stringValue];
    _amountlabel.text=totalamount;
    NSInteger index = [valueofselectedcell indexOfObject:totalamount];
    NSLog(@"%ld the index value in the array is",(long)index);

}}
 -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *totalamount;
if ([indexofselectedcell containsObject: indexPath])
{
    NSInteger anIndex=[indexofselectedcell indexOfObject:indexPath];
    [indexofselectedcell removeObjectAtIndex:anIndex];
    [valueofselectedcell removeObjectAtIndex:anIndex];
    NSLog(@"the value of the unselected cell value is..... %@",valueofselectedcell);
    NSArray *array = [valueofselectedcell copy];
    NSNumber* sum = [array valueForKeyPath: @"@sum.self"];
   totalamount = [sum stringValue];
    _amountlabel.text=totalamount;
    totalamount= nil;
}   }

Body:
Pavithra I tried sample project for your question and output.If I get unselected and selected cells in separate array,it crashed as I could not check two array in cellForRowAtIndexPath.So that I save selected and unSelected values in one array.

I created simple understandable solution.I have set values in tableview as unselected as default.If you selected(when you click the cell) it shows UITableViewCellAccessoryCheckmark and other show UITableViewCellAccessoryNone.

It works perfectly.You can easily get.

ViewController.h

#import <UIKit/UIKit.h>
@interface ViewController :  UIViewController<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *tableViewSelectUnSelect;
@end

ViewController.m

#import "ViewController.h"

@interface ViewController (){
    NSMutableArray *arrVal,*arrSelectedUnSelectedValues,*arrSelectedValues,*arrUnSelectedValues;
    NSMutableArray *arrSubTitle;
}

@end

@implementation ViewController

@synthesize tableViewSelectUnSelect;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    arrVal= [[NSMutableArray alloc]initWithObjects:@"India",@"China",@"Korea",@"Japan",@"Peru",@"Italy",@"France",@"US",@"Dubai",@"UK",@"Nepal",nil];
    arrSubTitle = [[NSMutableArray alloc]initWithObjects:@"100",@"70",@"80",@"90",@"50",@"60",@"70",@"50",@"40",@"30",@"80",nil];
    arrSelectedUnSelectedValues= [[NSMutableArray alloc]init];
    arrSelectedValues = [[NSMutableArray alloc]init];
    arrUnSelectedValues = [[NSMutableArray alloc]init];
    for(int j=0;j<[arrVal count];j++)
    {
        [arrSelectedUnSelectedValues addObject:@"unselected"]; //As Default it is in UnSelected State
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource Methods
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return arrVal.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *strCell = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strCell];
    if(cell==nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:strCell];
    }
    if([[arrSelectedUnSelectedValues objectAtIndex:indexPath.row] isEqualToString:@"selected"])
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    else
        cell.accessoryType = UITableViewCellAccessoryNone;
    cell.textLabel.text = [arrVal objectAtIndex:indexPath.row];
    cell.detailTextLabel.text = [arrSubTitle objectAtIndex:indexPath.row];
    return cell;
}

#pragma mark - UITableViewDelegate Methods
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    @try
    {
        CGPoint touchPoint = [cell convertPoint:CGPointZero toView:tableViewSelectUnSelect];
        NSIndexPath *indexPath = [tableViewSelectUnSelect indexPathForRowAtPoint:touchPoint];
        NSLog(@"The arrSelectedUnSelectedValues  are %@",arrSelectedUnSelectedValues );
        NSString *strValue;

        if([arrSelectedUnSelectedValues count]==0)
        {
            for(int i=0; i<[arrVal count]; i++)
            {
                [arrSelectedUnSelectedValues addObject:@"unselected"];
            }
        }
        if([[arrSelectedUnSelectedValues objectAtIndex:indexPath.row] isEqualToString:@"selected"])
        {
            cell.accessoryType = UITableViewCellAccessoryNone;
            [arrSelectedUnSelectedValues replaceObjectAtIndex:indexPath.row withObject:@"unselected"];
            strValue = cell.detailTextLabel.text;
            [arrUnSelectedValues addObject:strValue];
            NSLog(@"The arrUnSelectedValues are - %@",arrUnSelectedValues);
        }
        else
        {
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
            [arrSelectedUnSelectedValues replaceObjectAtIndex:indexPath.row withObject:@"selected"];
            strValue = cell.detailTextLabel.text;
            [arrSelectedValues addObject:strValue];
            NSLog(@"The arrSelectedValues - %@",arrSelectedValues);
        }
    }
    @catch (NSException *exception) {
        NSLog(@"The exception is-%@",exception);
    }
}

@end

First when I run the application it shows like below

Then when I select values from the tableView

Then finally printed results are


问:
using unallocated memory without error?
Why does that work?

```<code>#include <iostream>
using namespace std;

int main() {
    float* tab[3];

    int i = 0;
    while(i < 3) {
        tab[i] = new float[3-i];
        i++;
    }

    cout << tab[2][7] << endl;
    tab[2][7] = 6.87;
    cout << tab[2][7] << endl;

    i = 0;
    while(i < 3)
        delete[] tab[i];
}
</code>```

while this one doesn't?

```<code>#include <iostream>
using namespace std;

int main() {
    float* tab = new float[3];

    cout << tab[7] << endl;
    tab[7] = 6.87;
    cout << tab[7] << endl;

    delete[] tab;
}
</code>```

I tried both programs on Win XP with MS VS 2008, both compiled without errors and the first one ran without any errors. The second made pop up some error window, however I can't remember it and can't reproduce (no access to Windows at the moment).

I tried them also on Linux (Kubuntu 10.10 with precompiled kernel package version 2.6.35.23.25) with g++ and both compile and run without any errors.

Why? Shouldn't there be any pop-ups with something like "Wrong access to unallocated memory"?

I know it should (and, luckily, does) compile without errors, but I thought it shouldn't run without them... And why the second example makes errors on Windows and not on Linux?

答:
Memory access protection isn't very fine grained.  When you allocate some memory, you get a whole page worth of memory allocated to your program.  When you try and access that extra memory, it's likely to succeed, but you're also likely to run over other memory allocated to your program.

This is why buffer overruns work as an attack.  In many cases it's predictable what that extra memory after your array is being used for.  If I can control what you put there, I can overwrite data you don't want me overwriting.  If I can overwrite your call stack, then I can execute any code I want in your process context.  If this is a service running as an admin user, then I have a local privilege escalation.  If this is a internet-facing service of some sort, then I have a remote execution attack.

Your best bet is to work with more robust structures like std::vector unless you have a specific purpose for using arrays.  (And even then you might be able to get away with vectors).

ContentLicense: CC BY-SA 2.5

Title: using unallocated memory without error?

Body:
Why does that work?

#include <iostream>
using namespace std;

int main() {
    float* tab[3];

    int i = 0;
    while(i < 3) {
        tab[i] = new float[3-i];
        i++;
    }

    cout << tab[2][7] << endl;
    tab[2][7] = 6.87;
    cout << tab[2][7] << endl;

    i = 0;
    while(i < 3)
        delete[] tab[i];
}

while this one doesn't?

#include <iostream>
using namespace std;

int main() {
    float* tab = new float[3];

    cout << tab[7] << endl;
    tab[7] = 6.87;
    cout << tab[7] << endl;

    delete[] tab;
}

I tried both programs on Win XP with MS VS 2008, both compiled without errors and the first one ran without any errors. The second made pop up some error window, however I can't remember it and can't reproduce (no access to Windows at the moment).

I tried them also on Linux (Kubuntu 10.10 with precompiled kernel package version 2.6.35.23.25) with g++ and both compile and run without any errors.

Why? Shouldn't there be any pop-ups with something like "Wrong access to unallocated memory"?

I know it should (and, luckily, does) compile without errors, but I thought it shouldn't run without them... And why the second example makes errors on Windows and not on Linux?


问:
Creating an array of System.ValueTuple in c# 7
In my code I have:

```<code>private static readonly ValueTuple<string, string>[] test = {("foo", "bar"), ("baz", "foz")};
</code>```

But when I compile my code, I get:

```<code>TypoGenerator.cs(52,76):  error CS1026: Unexpected symbol `,', expecting `)'
TypoGenerator.cs(52,84):  error CS1026: Unexpected symbol `)', expecting `)'
TypoGenerator.cs(52,94):  error CS1026: Unexpected symbol `,', expecting `)'
TypoGenerator.cs(52,103):  error CS1026: Unexpected symbol `)', expecting `)'
TypoGenerator.cs(117,42):  error CS1525: Unexpected symbol `('
TypoGenerator.cs(117,58):  error CS1525: Unexpected symbol `['
</code>```

What is the correct way to create and initialize an array of ValueTuples?

答:
Try to create an instance of array with new and instances of tuple with new keyword

```<code>private static readonly ValueTuple<string, string>[] test = new ValueTuple<string, string>[]{
        new ValueTuple<string, string>("foo", "bar"),
        new ValueTuple<string, string>("baz", "foz")
};
</code>```

or with C#7 tuple syntax

```<code>private static readonly ValueTuple<string, string>[] test = new ValueTuple<string, string>[]{
        ("foo", "bar"),
        ("baz", "foz")
};
</code>```

Update:

Right now all declarations from the question and this answer works fine with Rider 2017.1 build #RD-171.4456.1432 and .NET Core 1.0.4. The simplest one is that @ZevSpitz mentioned in comments and it looks as follows:

```<code>private static readonly (string, string)[] test = {("foo", "bar"), ("baz", "foz")};
</code>```

There is no need to add specific type for ValueTuple. Notice that for .NET Core the NuGet package System.ValueTuple has to be installed.

Body:
In my code I have:

private static readonly ValueTuple<string, string>[] test = {("foo", "bar"), ("baz", "foz")};

But when I compile my code, I get:

TypoGenerator.cs(52,76):  error CS1026: Unexpected symbol `,', expecting `)'
TypoGenerator.cs(52,84):  error CS1026: Unexpected symbol `)', expecting `)'
TypoGenerator.cs(52,94):  error CS1026: Unexpected symbol `,', expecting `)'
TypoGenerator.cs(52,103):  error CS1026: Unexpected symbol `)', expecting `)'
TypoGenerator.cs(117,42):  error CS1525: Unexpected symbol `('
TypoGenerator.cs(117,58):  error CS1525: Unexpected symbol `['

What is the correct way to create and initialize an array of ValueTuples?

Body:
Try to create an instance of array with new and instances of tuple with new keyword

private static readonly ValueTuple<string, string>[] test = new ValueTuple<string, string>[]{
        new ValueTuple<string, string>("foo", "bar"),
        new ValueTuple<string, string>("baz", "foz")
};

or with C#7 tuple syntax

private static readonly ValueTuple<string, string>[] test = new ValueTuple<string, string>[]{
        ("foo", "bar"),
        ("baz", "foz")
};

Update:

Right now all declarations from the question and this answer works fine with Rider 2017.1 build #RD-171.4456.1432 and .NET Core 1.0.4. The simplest one is that @ZevSpitz mentioned in comments and it looks as follows:

private static readonly (string, string)[] test = {("foo", "bar"), ("baz", "foz")};

There is no need to add specific type for ValueTuple. Notice that for .NET Core the NuGet package System.ValueTuple has to be installed.


问:
why are images not showing in my rails app?
i have made a simple website using a free template.  i am confused because the images on my version are not showing but the images on the demo version are working and both have exactly the same css files and html because i copy pasted. i will post them below. my confusion lies in the fact that i dont see any of the images reffered to in either the html or the css stylesheet.  the styling is there for the images but no link to the file location. 2 questions.

this is what the site should look like:

http://www.quackit.com/html/templates/download/bryantsmith/greenmountain/

this is what my site looks like:

https://cherry-cupcake-30790.herokuapp.com/

as you can see background, background to the navbar and main images are missing but other styling and css are implemented.

why are the images not showing on my version?

why are the images showing on the demo version 0hen there seems to be no reference to the actual file location of the image (only styling of the image)?

thanks.

html file:

```<code>    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>NightBeach | florida web design</title>
</head>

<body>
<div id="container">
        <div id="mainpic">
            <h1>Green<span class="off">Mountain</span></h1>
            <h2>A template by Bryant Smith</h2>
        </div>

        <div id="menu">
            <ul>
                <li class="menuitem"><a href="#">Home</a></li>
                <li class="menuitem"><a href="#">About</a></li>
                <li class="menuitem"><a href="#">Products</a></li>
                <li class="menuitem"><a href="#">Services</a></li>
                <li class="menuitem"><a href="#">Design</a></li>
              <li class="menuitem"><a href="#">Contact</a></li>
            </ul>
        </div>

        <div id="content">
            <h2>You may use this template in any manner you like. All I ask is that you leave the link back to my site at the bottom of the page. </h2>
            <p> </p>
            <p> </p>
          <h3>Template Notes</h3>
            <p>The main image can be changed by either replacing the current image with another one of the same size (900x402), or using a new one of what ever dimensions you'd like.  If you choose the latter, you must open up style.css and change the dimensions of #mainpic, as well as the file name if that is different. If you would like to move the heading around in the above image, find "#mainpic h1" in style.css and modify it's "left" and "top" properties, this is also true for the h2 tag.</p>
            <p> </p>
<h3>More information</h3>
            <p>I decided to leave the content portion open for the templates users to do as they wish with a blank canvas. I don't like to restrict my users too much, and for this reason I leave the defining of any content related styles to you.</p>
            <p> </p>
            <h3>Template Notes</h3>
            <p>The main image can be changed by either replacing the current image with another one of the same size (900x402), or using a new one of what ever dimensions you'd like.  If you choose the latter, you must open up style.css and change the dimensions of #mainpic, as well as the file name if that is different. If you would like to move the heading around in the above image, find "#mainpic h1" in style.css and modify it's "left" and "top" properties, this is also true for the h2 tag.</p>
            <p> </p>
            <h3>More information</h3>
            <p>I decided to leave the content portion open for the templates users to do as they wish with a blank canvas. I don't like to restrict my users too much, and for this reason I leave the defining of any content related styles to you.</p>
            <p> </p>
            <p> </p>
            <p> </p>
<p> </p>

            <div id="footer"><h3><a href="http://www.bryantsmith.com">florida web design</a></div>
      </div>
   </div>
</body>
</html>
</code>```

css file:

```<code>/* A Free Design by Bryant Smith (bryantsmith.com) */

body {
    margin: 0;
    padding: 0;
    text-align: left;
    font: 12px Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #061C37;
    background: #EEEFE4;
    background-image:url(images/background.png);
    background-repeat:repeat-x;
}
*
{
  margin: 0 auto 0 auto;
 text-align:left;}

#container
{
  display: block;
  height:auto;
  position: relative;
  width: 940px;
}

#mainpic h1
{
    position:absolute;
text-align:right;
color:#F8FDEE;
font-size:30px;
color:#FFF;
left:60px;
top:20px;
}

#mainpic h2
{
position:absolute;
text-align:right;
color:#E1E7F7;
left:60px;
top:50px;
}

#mainpic
{
background-image:url(images/main.jpg);
background-repeat:no-repeat;
width:900px;
height:354px;
}

.off
{
color:#3A6028;

}

#menu
{
background-image:url(images/menu.png);
background-repeat:no-repeat;
width:940px;
height:69px;
float:left;
clear:both;
}

#content
{
width:880px;
height:auto;
background-color:#FFF;
padding-left:10px;
padding-right:10px;
padding-bottom:5px;
}

#footer
{
width:inherit;
height:auto;
}

#footer h3 a,#footer h3 a:visited
{
display:inline;
text-align:center;
font-size:12px;
text-decoration:none;
color:#7198E1;
}

#menu ul {
    list-style: none;
    padding: 0px;
    margin-left:auto;
    width:900px;
}

#menu li {
    list-style: none;
    padding: 0px;
    display: inline;

}

#menu a {
    float: left;
    width: 150px;
    height: 40px;
    display: block;
    text-align: center;
    text-decoration: none;
    color: #ffffff;
    font-weight: bold;
    padding-top: 17px;
    font-size: 15px;
}

#menu a:hover{
    color:#BEE399;
}

#content p
{

}

html, body {
text-align: center;
}
p {text-align: left;}

  [1]: http://www.quackit.com/html/templates/download/bryantsmith/greenmountain/
</code>```

答:
for problem 1, because your website's css is empty, nothing in. The css link is https://cherry-cupcake-30790.herokuapp.com/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css .

for problem 2, the image link refer is not in the html, but in the css file.

```<code>#mainpic {
  background-image: url(images/main.jpg);
  background-repeat: no-repeat;
  width: 900px;
  height: 354px;
}
</code>```

the image link is http://www.quackit.com/html/templates/download/bryantsmith/greenmountain/images/main.jpg

Body:
i have made a simple website using a free template.  i am confused because the images on my version are not showing but the images on the demo version are working and both have exactly the same css files and html because i copy pasted. i will post them below. my confusion lies in the fact that i dont see any of the images reffered to in either the html or the css stylesheet.  the styling is there for the images but no link to the file location. 2 questions.

this is what the site should look like:

http://www.quackit.com/html/templates/download/bryantsmith/greenmountain/

this is what my site looks like:

https://cherry-cupcake-30790.herokuapp.com/

as you can see background, background to the navbar and main images are missing but other styling and css are implemented.

why are the images not showing on my version?

why are the images showing on the demo version 0hen there seems to be no reference to the actual file location of the image (only styling of the image)?

thanks.

html file:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>NightBeach | florida web design</title>

GreenMountain

A template by Bryant Smith

Home

About

Products

Services

Design

Contact

You may use this template in any manner you like. All I ask is that you leave the link back to my site at the bottom of the page.

Template Notes

The main image can be changed by either replacing the current image with another one of the same size (900x402), or using a new one of what ever dimensions you'd like.  If you choose the latter, you must open up style.css and change the dimensions of #mainpic, as well as the file name if that is different. If you would like to move the heading around in the above image, find "#mainpic h1" in style.css and modify it's "left" and "top" properties, this is also true for the h2 tag.

More information

I decided to leave the content portion open for the templates users to do as they wish with a blank canvas. I don't like to restrict my users too much, and for this reason I leave the defining of any content related styles to you.

Template Notes

The main image can be changed by either replacing the current image with another one of the same size (900x402), or using a new one of what ever dimensions you'd like.  If you choose the latter, you must open up style.css and change the dimensions of #mainpic, as well as the file name if that is different. If you would like to move the heading around in the above image, find "#mainpic h1" in style.css and modify it's "left" and "top" properties, this is also true for the h2 tag.

More information

I decided to leave the content portion open for the templates users to do as they wish with a blank canvas. I don't like to restrict my users too much, and for this reason I leave the defining of any content related styles to you.

florida web design

css file:

/* A Free Design by Bryant Smith (bryantsmith.com) */

body {
    margin: 0;
    padding: 0;
    text-align: left;
    font: 12px Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #061C37;
    background: #EEEFE4;
    background-image:url(images/background.png);
    background-repeat:repeat-x;
}
*
{
  margin: 0 auto 0 auto;
 text-align:left;}

#container
{
  display: block;
  height:auto;
  position: relative;
  width: 940px;
}

#mainpic h1
{
    position:absolute;
text-align:right;
color:#F8FDEE;
font-size:30px;
color:#FFF;
left:60px;
top:20px;
}

#mainpic h2
{
position:absolute;
text-align:right;
color:#E1E7F7;
left:60px;
top:50px;
}

#mainpic
{
background-image:url(images/main.jpg);
background-repeat:no-repeat;
width:900px;
height:354px;
}

.off
{
color:#3A6028;

}

#menu
{
background-image:url(images/menu.png);
background-repeat:no-repeat;
width:940px;
height:69px;
float:left;
clear:both;
}

#content
{
width:880px;
height:auto;
background-color:#FFF;
padding-left:10px;
padding-right:10px;
padding-bottom:5px;
}

#footer
{
width:inherit;
height:auto;
}

#footer h3 a,#footer h3 a:visited
{
display:inline;
text-align:center;
font-size:12px;
text-decoration:none;
color:#7198E1;
}

#menu ul {
    list-style: none;
    padding: 0px;
    margin-left:auto;
    width:900px;
}

#menu li {
    list-style: none;
    padding: 0px;
    display: inline;

}

#menu a {
    float: left;
    width: 150px;
    height: 40px;
    display: block;
    text-align: center;
    text-decoration: none;
    color: #ffffff;
    font-weight: bold;
    padding-top: 17px;
    font-size: 15px;
}

#menu a:hover{
    color:#BEE399;
}

#content p
{

}

html, body {
text-align: center;
}
p {text-align: left;}

  [1]: http://www.quackit.com/html/templates/download/bryantsmith/greenmountain/

Body:
for problem 1, because your website's css is empty, nothing in. The css link is https://cherry-cupcake-30790.herokuapp.com/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css .

for problem 2, the image link refer is not in the html, but in the css file.

#mainpic {
  background-image: url(images/main.jpg);
  background-repeat: no-repeat;
  width: 900px;
  height: 354px;
}

the image link is http://www.quackit.com/html/templates/download/bryantsmith/greenmountain/images/main.jpg


问:
styling marker icon and info window
This is an image with some points having info window. when the cursor move to that point it shows info window.

```<code><div id="map"></div>
</div>
<script type="text/javascript">
    function myMap() {
        var locations = [
  ['some info', 30.118802, 31.410364],
  ['some info', 33.616455, 73.096199],
  ['some info', 33.598394, 73.044135],
  ['some info', 21.673434, 39.160065],
  ['some info', 34.011382, 71.523476], ];
        var map = new google.maps.Map(document.getElementById('map'), {
            zoom: 5,
            center: new google.maps.LatLng(31.571394, 74.310374),
            mapTypeId: google.maps.MapTypeId.SATELLITE
        });
        var infowindow = new google.maps.InfoWindow();
        var marker, i;
        for (i = 0; i < locations.length; i++) {
            marker = new google.maps.Marker({
                position: new google.maps.LatLng(locations[i][1], locations[i][2]),
                map: map
            });
            google.maps.event.addListener(marker, 'mouseover', (function(marker, i) {
                return function() {
                    infowindow.setContent(locations[i][0]);
                    infowindow.open(map, marker);
                }
            })(marker, i));
        }
    }
</script>
<script src="https://maps.googleapis.com/maps/api/js?callback=myMap"></script>
</code>```

This is the simple marker with simple info window code. but I need more marker icon and style for info.window and also the text without info.window like in image.

答:
I suggest you take one step at a time .. starting from the marker icon

you can assign a new icon to a marker this way :

```<code>var image = 'your_path/your_file.png';
// you can use the path below for test
// var image = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';

var myMarker = new google.maps.Marker({
   position: {lat: -33.890, lng: 151.274},
   map: map,
   icon: image
 });
</code>```

or if you have a marker already you can use

```<code>   marker.setIcon( image);
</code>```

Title: styling marker icon and info window

Body:
This is an image with some points having info window. when the cursor move to that point it shows info window.

This is the simple marker with simple info window code. but I need more marker icon and style for info.window and also the text without info.window like in image.

Body:
I suggest you take one step at a time .. starting from the marker icon

you can assign a new icon to a marker this way :

var image = 'your_path/your_file.png';
// you can use the path below for test
// var image = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';

var myMarker = new google.maps.Marker({
   position: {lat: -33.890, lng: 151.274},
   map: map,
   icon: image
 });

or if you have a marker already you can use

   marker.setIcon( image);


问:
Error creating bean : NameController Injection of autowired dependencies failed;
the problem is that  @autowiring doesn't work , i followed all the search results but still getting this error "Error creating bean : NameController Injection of autowired dependencies failed;",any help would be much appreciated.

Stacktrace:

```<code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'travailController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.pcd.service.TravailService com.pcd.restcontroller.TravailController.travailServ; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'travailServ': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pcd.repository.TravailRepository com.pcd.serviceImpl.TravailServiceImpl.travailRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'travailRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property saveTravail found for type Travail!
</code>```

Controller:

```<code>@Controller
public class TravailController {

@Autowired
TravailService travailServ;
@Autowired
MatiereService matiereServ;
@Autowired
GroupeService groupeServ;

@RequestMapping(value = "/add", method = RequestMethod.POST)
public ModelAndView saveEmployee(@ModelAttribute("travail")Travail travail,
  BindingResult result) {

  travailServ.saveTravail(new Travail());
  return new ModelAndView("redirect:/travail");
 }

  @RequestMapping(value = { "/list" }, method = RequestMethod.GET)
    public String newGroupe(@ModelAttribute("travail") Travail travail,ModelMap model,BindingResult result ) {

        model.addAttribute("travail", travail);
        model.addAttribute("matieres", matiereServ.findAlmatieres());

        model.addAttribute("groupes", groupeServ.findAllGroupes());
        model.addAttribute("listTravail", travailServ.findAllTravail());

        return "travail";
    }

    @RequestMapping("/remove/{id}")
    public String removePerson(@PathVariable("id") int id){

        this.travailServ.deleteTravailById(id);
        return "redirect:/travail";
    }

    @RequestMapping("/edit/{id}")
    public String editPerson(@PathVariable("id") int id, Model model){
        model.addAttribute("travail", travailServ.findById(id));
        model.addAttribute("listTravail", travailServ.findAllTravail());
        return "travail";
    }
</code>```

TravailServiceImpl:

```<code>@Service("travailServ")

public class TravailServiceImpl implements TravailService{

@Autowired
 private TravailRepository travailRepository;
@Override
public List<Travail> findAllTravail() {
    try{
        return (List<Travail>) travailRepository.findAll();
    }catch(Exception e){
        return null;
    }
}
@Override

public Travail findById(int id) {
    return travailRepository.findById(id);
}
@Override

public Travail findByTitre(String titre) {

      return travailRepository.findByTitre(titre);
}
@Override
@Transactional
public Travail findByDescription(String description) {
      return travailRepository.findByDescription(description);
}
@Override
public void deleteTravailById(int id) {
      travailRepository.delete(id);

}
@Override
public void saveTravail(Travail travail) {
    travailRepository.save(travail);

}
</code>```

TravailService:

```<code>public interface TravailService {

 List<Travail> findAllTravail();

 Travail findById(int id);

 Travail findByTitre(String titre);

 Travail findByDescription(String description);
 void saveTravail(Travail travail);

 void deleteTravailById(int id);

}
</code>```

TravailRepository:

```<code>public interface TravailRepository extends CrudRepository<Travail, Integer> {
 List<Travail> findAllTravail();

 Travail findById(int id);
 Travail findByTitre(String titre);
 Travail findByDescription(String description);
 void saveTravail(Travail travail);

 void deleteTravailById(int id);}
</code>```

答:
The problem is with your TravailRepository interface methods for which Spring container is going to provide the implementation at runtime during startup.

Basically, Spring data JPA has got few rules to implement (during container startup) the methods in the Repository interface and it is failing because of your method names saveTravail and deleteTravailById.

So, remove the following methods from your TravailRepository interface:

```<code> void saveTravail(Travail travail);

 void deleteTravailById(int id);
</code>```

Rather, you can directly use those methods (i.e., save(S entity) and delete(ID id)) from CrudRepository (look API here)

Body:
the problem is that  @autowiring doesn't work , i followed all the search results but still getting this error "Error creating bean : NameController Injection of autowired dependencies failed;",any help would be much appreciated.

Stacktrace:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'travailController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.pcd.service.TravailService com.pcd.restcontroller.TravailController.travailServ; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'travailServ': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pcd.repository.TravailRepository com.pcd.serviceImpl.TravailServiceImpl.travailRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'travailRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property saveTravail found for type Travail!

Controller:

@Controller
public class TravailController {

@Autowired
TravailService travailServ;
@Autowired
MatiereService matiereServ;
@Autowired
GroupeService groupeServ;

@RequestMapping(value = "/add", method = RequestMethod.POST)
public ModelAndView saveEmployee(@ModelAttribute("travail")Travail travail,
  BindingResult result) {

  travailServ.saveTravail(new Travail());
  return new ModelAndView("redirect:/travail");
 }

  @RequestMapping(value = { "/list" }, method = RequestMethod.GET)
    public String newGroupe(@ModelAttribute("travail") Travail travail,ModelMap model,BindingResult result ) {

        model.addAttribute("travail", travail);
        model.addAttribute("matieres", matiereServ.findAlmatieres());

        model.addAttribute("groupes", groupeServ.findAllGroupes());
        model.addAttribute("listTravail", travailServ.findAllTravail());

        return "travail";
    }

    @RequestMapping("/remove/{id}")
    public String removePerson(@PathVariable("id") int id){

        this.travailServ.deleteTravailById(id);
        return "redirect:/travail";
    }

    @RequestMapping("/edit/{id}")
    public String editPerson(@PathVariable("id") int id, Model model){
        model.addAttribute("travail", travailServ.findById(id));
        model.addAttribute("listTravail", travailServ.findAllTravail());
        return "travail";
    }

TravailServiceImpl:

@Service("travailServ")

public class TravailServiceImpl implements TravailService{

@Autowired
 private TravailRepository travailRepository;
@Override
public List<Travail> findAllTravail() {
    try{
        return (List<Travail>) travailRepository.findAll();
    }catch(Exception e){
        return null;
    }
}
@Override

public Travail findById(int id) {
    return travailRepository.findById(id);
}
@Override

public Travail findByTitre(String titre) {

      return travailRepository.findByTitre(titre);
}
@Override
@Transactional
public Travail findByDescription(String description) {
      return travailRepository.findByDescription(description);
}
@Override
public void deleteTravailById(int id) {
      travailRepository.delete(id);

}
@Override
public void saveTravail(Travail travail) {
    travailRepository.save(travail);

}

TravailService:

public interface TravailService {

 List<Travail> findAllTravail();

 Travail findById(int id);

 Travail findByTitre(String titre);

 Travail findByDescription(String description);
 void saveTravail(Travail travail);

 void deleteTravailById(int id);

}

TravailRepository:

public interface TravailRepository extends CrudRepository<Travail, Integer> {
 List<Travail> findAllTravail();

 Travail findById(int id);
 Travail findByTitre(String titre);
 Travail findByDescription(String description);
 void saveTravail(Travail travail);

 void deleteTravailById(int id);}

Body:
The problem is with your TravailRepository interface methods for which Spring container is going to provide the implementation at runtime during startup.

Basically, Spring data JPA has got few rules to implement (during container startup) the methods in the Repository interface and it is failing because of your method names saveTravail and deleteTravailById.

So, remove the following methods from your TravailRepository interface:

 void saveTravail(Travail travail);

 void deleteTravailById(int id);

Rather, you can directly use those methods (i.e., save(S entity) and delete(ID id)) from CrudRepository (look API here)


问:
Only read new events from Firebase Database
I was halfway done with implementing Core Data in my iOS app when I realized that Firebase has offline capabilities that would pretty much mimic what I was trying to accomplish the whole time.

In my database which is structured as such:

```<code>- Users
    - user1
    - user2
- Groups
    - group1
        - members
            - user1
        - events
            - event1_By_Auto_Key
            - event2_By_Auto_Key
</code>```

I wanted to locally store all the events that have already been fetched by a user so that I wouldn't have to read all of them every single time I need to get a group's events. Now that I think I'm just going to stick with Firebase's offline capabilities instead of using Core Data, I have a question regarding how to efficiently read events from the database.

As seen from my database's structure the events are stored using the childByAutoId().setValue(data) method, meaning the keys are unknown when inserted. So my console for a given group might look like this:

My question is: how can I only read the new events from a group? The reason I was implementing Core Data was so that I could cache already fetched events, but I'm not sure how I can make sure that I don't re-read data.

答:
Firebase provide you 10MB persistent memory to cache recently fetch records. In normal scenario 10MB is enough space.

You need to enable offline capabilities.

Body:
I was halfway done with implementing Core Data in my iOS app when I realized that Firebase has offline capabilities that would pretty much mimic what I was trying to accomplish the whole time.

In my database which is structured as such:

- Users
    - user1
    - user2
- Groups
    - group1
        - members
            - user1
        - events
            - event1_By_Auto_Key
            - event2_By_Auto_Key

I wanted to locally store all the events that have already been fetched by a user so that I wouldn't have to read all of them every single time I need to get a group's events. Now that I think I'm just going to stick with Firebase's offline capabilities instead of using Core Data, I have a question regarding how to efficiently read events from the database.

As seen from my database's structure the events are stored using the childByAutoId().setValue(data) method, meaning the keys are unknown when inserted. So my console for a given group might look like this:

My question is: how can I only read the new events from a group? The reason I was implementing Core Data was so that I could cache already fetched events, but I'm not sure how I can make sure that I don't re-read data.


问:
Rselenium driver methods inside a function
I am trying to use some methods like sendKeysToElement() inside a function. My problem is similar to this but even if I pass the reference remote drive as a function argument, I still get an error. I have no problem in executing this code when not a function.

```<code>question <- "Which hormone concentrations are altered in patients with the Allan Herndon Dudley syndrome?"

searchMM <- function(x, remDr){
  remDr$findElement("css","textarea")$clearElement()
  remDr$findElement("css","textarea")$sendKeysToElement(list(x))
  remDr$findElement("css", "#note > input[type='button']:nth-child(12)")$clickElement()
  concept <- remDr$findElement("css","table:nth-child(31) pre")$getElementText()
  remDr$goBack()
  concept <- unlist(concept)
  test <- unlist(str_split(concept, "\n"))
}

searchMM(x=question, remDr=remDr)
test
</code>```

After running the function, when I try to see what's in test, I get Error: object 'test' not found. For that matter, concept also doesn't exist. What am I doing wrong?

答:
```<code>question <- "Which hormone concentrations are altered in patients with the Allan Herndon Dudley syndrome?"

searchMM <- function(x, remDr){
  remDr$findElement("css","textarea")$clearElement()
  remDr$findElement("css","textarea")$sendKeysToElement(list(x))
  remDr$findElement("css", "#note > input[type='button']:nth-child(12)")$clickElement()
  concept <- remDr$findElement("css","table:nth-child(31) pre")$getElementText()
  remDr$goBack()
  concept <- unlist(concept)
  test <- unlist(str_split(concept, "\n"))

output <- list(test,concept)
return(output)
}

test <- searchMM(x=question, remDr=remDr)
</code>```

Body:
I am trying to use some methods like sendKeysToElement() inside a function. My problem is similar to this but even if I pass the reference remote drive as a function argument, I still get an error. I have no problem in executing this code when not a function.

question <- "Which hormone concentrations are altered in patients with the Allan Herndon Dudley syndrome?"

searchMM <- function(x, remDr){
  remDr$findElement("css","textarea")$clearElement()
  remDr$findElement("css","textarea")$sendKeysToElement(list(x))
  remDr$findElement("css", "#note > input[type='button']:nth-child(12)")$clickElement()
  concept <- remDr$findElement("css","table:nth-child(31) pre")$getElementText()
  remDr$goBack()
  concept <- unlist(concept)
  test <- unlist(str_split(concept, "\n"))
}

searchMM(x=question, remDr=remDr)
test

After running the function, when I try to see what's in test, I get Error: object 'test' not found. For that matter, concept also doesn't exist. What am I doing wrong?