text:
Q: HOC example in React+Typescript doesn't work I am trying to create an HOC example in React+Typescript, but my code doesn't work.
codesandbox
This is the HOC component:
Hello.jsx
import * as React from "react";

export interface Props {
  name: string;
  itemClicked: () => void;
}

interface State {
  inc: number;
}

export const makeHello =
(Component: React.ComponentType
) =>
  class Hello extends React.Component<Props, State> {
    constructor(props: Props) {
      super(props);

      this.state = {
        inc: 0
      };
    }

    itemClicked = () => {
      this.setState({ inc: inc + 1 }, () => {
        console.log("itemClicked");
      });
    };

    render() {
      return (
        <Component itemClicked={this.itemClicked} {...this.props}>
          Inc state is: {this.state.inc}!
        </Component>
      );
    }
  };

export default makeHello;

And component ChildHello:
import * as React from "react";
import { Props } from "./Hello";
import { makeHello } from "./Hello";

export class ChildHello extends React.Component<Props, {}> {
  static defaultProps = {
    className: ""
  };

  constructor(props: Props) {
    super(props);
  }

  render() {
    return
Child component
;
  }
}

export default makeHello(ChildHello);

I don't get any error, but method itemClicked in Hello.jsx is not triggered when I click div element in ChildHello.tsx.

A: Looks like you made an import/export mistake.
You were importing the named class from the ChildHello instead of the HOC wrapped default export.
import * as React from "react";
import { Props } from "./Hello";
import makeHello from "./Hello";

// In index.tsx import { ChildHello } refers to this, not the default export below
export class ChildHello extends React.Component<Props, {}> {
  static defaultProps = {
    className: ""
  };

  constructor(props) {
    super(props);
  }

  render() {
    console.log(this);
    return
Child component
;
  }
}

export default makeHello(ChildHello);

In your index.tsx make sure you remove the named import
import ChildHello from "./ChildHello";

Then in your Hello.tsx update the itemClicked method, because it's erroring out
// UPDATED added "this.state" to inc
this.setState({ inc: this.state.inc + 1 }, () => {


text:
Q: Matplotlib: Color bar not working as it should? I am trying to create a plot similar to this, but without the letters below the coloured squres:

So far I have been able to create:

I am pretty happy with it so far, but my problem is with the colour bar. If you look at the last position on my figure (position 614). A colour map has been plotted over this postion and the colour bar is next to it.
How can I plot only the colour bar and move it to the side if the figure, so the colour bar is larger and clearer to see.
My code is:
def plot_solv_acc_graph(self):
    '''
    PLots the average data from the make_solv_access_table function
    '''

import math
import numpy as np
from pylab import *
from matplotlib import mpl
import matplotlib.pyplot as plt

aa_key = {'ARG':'R', 'HIS':'H', 'LYS':'K', 'ASP':'D', 'GLU':'E', 'SER':'S', 'THR':'T', 'ASN':'N', 'GLN':'Q', 'CYS':'C', 'SEC':'C', 'GLY':'G', 'PRO':'P', 'ALA':'A', 'VAL':'V', 'ILE':'I', 'LEU':'L', 'MET':'M', 'PHE':'F', 'TYR':'Y', 'TRP':'W'}

avg = [93.89, 69.34, 62.14, 33.65, 59.14, 41.73, 22.27, 0.81, 43.57, 5.12, 0.06, 32.58, 18.07, 77.43, 38.97, 83.38, 31.26, 75.33, 68.95, 142.75, 19.71, 0.16, 57.19, 59.74, 0.2, 27.25, 125.09, 116.5, 7.9, 7.49, 131.04, 64.21, 18.45, 62.13, 51.68, 96.93, 80.49, 35.64, 153.67, 28.97, 117.85, 67.19, 4.77, 86.98, 40.65, 56.09, 28.04, 97.77, 25.68, 0.0, 21.36, 47.02, 0.0, 37.21, 66.44, 4.63, 5.51, 43.05, 42.99, 125.41, 100.06, 91.02, 59.16, 32.02, 63.1, 0.58, 5.66, 54.43, 40.13, 67.42, 74.4, 76.45, 105.18, 68.41, 75.86, 74.01, 103.7, 117.79, 90.08, 139.55, 89.3, 136.44, 104.58, 105.68, 42.46, 91.42, 35.22, 93.86, 48.37, 120.37, 66.23, 50.54, 64.71, 41.54, 71.54, 49.17, 60.97, 85.65, 111.92, 51.99, 53.2, 113.7, 126.62, 38.5, 102.27, 116.62, 60.34, 131.57, 78.68, 46.47, 120.32, 90.04, 122.09, 126.92, 72.98, 65.15, 82.23, 20.38, 50.95, 39.32, 20.96, 75.01, 14.44, 88.34, 1.94, 51.8, 2.06, 90.28, 3.36, 64.76, 31.06, 0.51, 29.15, 87.07, 84.27, 65.24, 128.51, 38.39, 94.71, 16.21, 85.0, 31.2, 59.57, 6.18, 33.06, 33.73, 60.79, 61.36, 95.3, 197.35, 26.78, 112.83, 64.85, 131.5, 97.56, 94.93, 79.31, 95.74, 60.12, 89.47, 19.11, 87.26, 16.72, 110.99, 1.96, 33.8, 18.2, 21.86, 13.52, 24.27, 62.86, 31.47, 39.23, 80.43, 38.0, 85.39, 48.59, 136.98, 35.9, 45.6, 4.45, 17.14, 70.42, 34.51, 124.57, 116.16, 66.84, 23.42, 109.71, 58.46, 6.64, 11.81, 0.2, 43.98, 0.2, 15.75, 2.59, 47.25, 11.7, 30.86, 81.7, 30.13, 104.47, 69.54, 7.08, 67.92, 56.72, 63.09, 47.24, 45.87, 23.58, 0.05, 41.5, 3.43, 72.93, 5.42, 60.21, 1.23, 20.09, 1.81, 39.74, 47.41, 0.08, 3.54, 67.77, 19.85, 26.79, 124.72, 33.09, 78.66, 0.99, 55.68, 13.74, 16.07, 119.38, 93.24, 64.98, 43.75, 107.65, 14.95, 69.54, 3.25, 68.41, 56.43, 16.03, 4.43, 61.51, 24.86, 46.78, 43.31, 87.59, 24.02, 108.74, 15.55, 128.87, 35.05, 31.09, 3.57, 6.79, 40.17, 23.66, 116.78, 131.23, 81.16, 58.18, 3.68, 13.18, 0.0, 28.06, 0.0, 25.68, 3.37, 51.95, 1.15, 24.84, 4.6, 22.33, 33.47, 108.62, 16.1, 49.53, 135.2, 71.43, 5.79, 15.91, 48.61, 13.73, 9.4, 87.11, 63.19, 7.91, 21.25, 94.15, 45.86, 26.36, 80.05, 105.57, 52.3, 51.13, 56.83, 113.51, 92.92, 67.0, 148.45, 35.13, 114.23, 108.02, 94.94, 68.44, 62.22, 31.15, 60.04, 38.47, 22.3, 0.78, 39.35, 4.7, 0.09, 28.1, 17.58, 73.04, 37.55, 83.03, 31.78, 75.43, 69.08, 142.08, 19.87, 0.12, 57.8, 56.07, 0.33, 27.34, 124.44, 98.74, 6.57, 7.63, 126.51, 54.26, 16.13, 62.16, 51.03, 96.26, 78.31, 33.71, 142.46, 25.05, 101.93, 59.35, 5.0, 82.65, 36.26, 52.16, 27.37, 96.5, 24.5, 0.0, 21.25, 46.08, 0.0, 37.11, 62.57, 4.14, 5.19, 40.52, 38.78, 122.3, 97.2, 87.08, 57.43, 31.35, 61.98, 0.47, 5.45, 52.48, 41.73, 61.9, 73.38, 76.32, 104.43, 69.92, 78.78, 76.66, 107.05, 121.75, 91.06, 137.56, 91.2, 135.56, 107.81, 103.62, 41.7, 91.29, 35.24, 95.06, 48.72, 120.38, 65.02, 51.42, 63.83, 42.03, 72.09, 46.49, 58.56, 88.6, 111.84, 51.98, 53.78, 113.33, 126.69, 39.08, 101.86, 118.26, 59.34, 131.83, 79.09, 46.05, 119.72, 88.5, 121.97, 124.3, 72.72, 64.42, 83.82, 21.05, 52.81, 39.94, 21.72, 74.56, 12.92, 83.91, 1.73, 50.29, 1.86, 90.79, 3.81, 63.99, 31.36, 0.57, 29.63, 84.77, 89.53, 63.56, 125.84, 35.8, 92.01, 15.26, 83.0, 30.76, 59.25, 6.29, 34.43, 33.28, 62.53, 61.09, 95.55, 196.45, 27.62, 113.44, 63.2, 129.38, 94.13, 92.39, 78.32, 91.58, 60.28, 89.43, 19.21, 88.07, 16.92, 114.43, 1.85, 41.76, 18.49, 24.06, 14.87, 26.1, 62.6, 33.32, 47.49, 87.78, 43.66, 89.01, 50.82, 137.19, 36.07, 45.04, 4.74, 17.27, 70.76, 34.06, 122.94, 115.74, 67.75, 22.31, 109.71, 58.98, 6.2, 11.94, 0.17, 44.87, 0.2, 13.79, 2.98, 45.03, 10.99, 29.79, 79.91, 29.46, 100.54, 66.28, 6.74, 68.25, 56.62, 70.73, 50.56, 58.69, 26.22, 0.2, 42.1, 2.29, 65.71, 5.29, 54.8, 0.74, 17.54, 1.47, 28.1, 38.62, 0.3, 4.99, 67.47, 18.73, 25.92, 125.97, 26.34, 60.35, 0.94, 52.67, 13.45, 15.84, 117.19, 92.53, 62.5, 43.79, 106.85, 16.62, 71.9, 2.93, 68.08, 71.72, 10.62, 4.19, 46.87, 24.12, 47.09, 42.94, 92.39, 26.66, 109.61, 13.34, 129.23, 34.47, 31.0, 3.22, 7.69, 42.03, 28.05, 149.01, 156.76, 92.83, 57.73, 3.86, 14.9, 0.0, 29.23, 0.03, 25.92, 3.87, 45.65, 1.09, 20.81, 3.66, 27.06, 28.97, 94.28, 12.82, 63.89, 134.81, 81.96, 10.38, 17.27, 47.6, 23.26, 11.64, 94.27, 71.8, 2.46, 33.86, 93.88, 44.6, 20.61, 80.47, 97.13, 47.26, 50.87, 56.86, 126.64, 84.4, 57.84, 167.2, 37.38, 118.34, 106.89]
aa = ['ALA', 'SER', 'ALA', 'LEU', 'LYS', 'ASP', 'TYR', 'TYR', 'ALA', 'ILE', 'MET', 'GLY', 'VAL', 'LYS', 'PRO', 'THR', 'ASP', 'ASP', 'LEU', 'LYS', 'THR', 'ILE', 'LYS', 'THR', 'ALA', 'TYR', 'ARG', 'ARG', 'LEU', 'ALA', 'ARG', 'LYS', 'TYR', 'HIS', 'PRO', 'ASP', 'VAL', 'SER', 'LYS', 'GLU', 'PRO', 'ASP', 'ALA', 'GLU', 'ALA', 'ARG', 'PHE', 'LYS', 'GLU', 'VAL', 'ALA', 'GLU', 'ALA', 'TRP', 'GLU', 'VAL', 'LEU', 'SER', 'ASP', 'GLU', 'GLN', 'ARG', 'ARG', 'ALA', 'GLU', 'TYR', 'ASP', 'GLN', 'MET', 'TRP', 'GLN', 'HIS', 'ARG', 'ASN', 'ASP', 'PRO', 'GLN', 'PHE', 'ASN', 'ARG', 'GLN', 'PHE', 'HIS', 'HIS', 'GLY', 'ASP', 'GLY', 'GLN', 'SER', 'PHE', 'ASN', 'ALA', 'GLU', 'ASP', 'PHE', 'ASP', 'ASP', 'ILE', 'PHE', 'SER', 'SER', 'ILE', 'PHE', 'GLY', 'GLN', 'HIS', 'ALA', 'ARG', 'GLN', 'SER', 'ARG', 'GLN', 'ARG', 'PRO', 'ALA', 'THR', 'ARG', 'GLY', 'HIS', 'ASP', 'ILE', 'GLU', 'ILE', 'GLU', 'VAL', 'ALA', 'VAL', 'PHE', 'LEU', 'GLU', 'GLU', 'THR', 'LEU', 'THR', 'GLU', 'HIS', 'LYS', 'ARG', 'THR', 'ILE', 'SER', 'TYR', 'ASN', 'LEU', 'PRO', 'VAL', 'TYR', 'ASN', 'ALA', 'PHE', 'GLY', 'MET', 'ILE', 'GLU', 'GLN', 'GLU', 'ILE', 'PRO', 'LYS', 'THR', 'LEU', 'ASN', 'VAL', 'LYS', 'ILE', 'PRO', 'ALA', 'GLY', 'VAL', 'GLY', 'ASN', 'GLY', 'GLN', 'ARG', 'ILE', 'ARG', 'LEU', 'LYS', 'GLY', 'GLN', 'GLY', 'THR', 'PRO', 'GLY', 'GLU', 'ASN', 'GLY', 'GLY', 'PRO', 'ASN', 'GLY', 'ASP', 'LEU', 'TRP', 'LEU', 'VAL', 'ILE', 'HIS', 'ILE', 'ALA', 'PRO', 'HIS', 'PRO', 'LEU', 'PHE', 'ASP', 'ILE', 'VAL', 'GLY', 'GLN', 'ASP', 'LEU', 'GLU', 'ILE', 'VAL', 'VAL', 'PRO', 'VAL', 'SER', 'PRO', 'TRP', 'GLU', 'ALA', 'ALA', 'LEU', 'GLY', 'ALA', 'LYS', 'VAL', 'THR', 'VAL', 'PRO', 'THR', 'LEU', 'LYS', 'GLU', 'SER', 'ILE', 'LEU', 'LEU', 'THR', 'ILE', 'PRO', 'PRO', 'GLY', 'SER', 'GLN', 'ALA', 'GLY', 'GLN', 'ARG', 'LEU', 'ARG', 'VAL', 'LYS', 'GLY', 'LYS', 'GLY', 'LEU', 'VAL', 'SER', 'LYS', 'LYS', 'GLN', 'THR', 'GLY', 'ASP', 'LEU', 'TYR', 'ALA', 'VAL', 'LEU', 'LYS', 'ILE', 'VAL', 'MET', 'PRO', 'PRO', 'LYS', 'PRO', 'ASP', 'GLU', 'ASN', 'THR', 'ALA', 'ALA', 'LEU', 'TRP', 'GLN', 'GLN', 'LEU', 'ALA', 'ASP', 'ALA', 'GLN', 'SER', 'SER', 'PHE', 'ASP', 'PRO', 'ARG', 'LYS', 'ASP', 'TRP', 'GLY', 'LYS', 'ALA', 'ALA', 'SER', 'ALA', 'LEU', 'LYS', 'ASP', 'TYR', 'TYR', 'ALA', 'ILE', 'MET', 'GLY', 'VAL', 'LYS', 'PRO', 'THR', 'ASP', 'ASP', 'LEU', 'LYS', 'THR', 'ILE', 'LYS', 'THR', 'ALA', 'TYR', 'ARG', 'ARG', 'LEU', 'ALA', 'ARG', 'LYS', 'TYR', 'HIS', 'PRO', 'ASP', 'VAL', 'SER', 'LYS', 'GLU', 'PRO', 'ASP', 'ALA', 'GLU', 'ALA', 'ARG', 'PHE', 'LYS', 'GLU', 'VAL', 'ALA', 'GLU', 'ALA', 'TRP', 'GLU', 'VAL', 'LEU', 'SER', 'ASP', 'GLU', 'GLN', 'ARG', 'ARG', 'ALA', 'GLU', 'TYR', 'ASP', 'GLN', 'MET', 'TRP', 'GLN', 'HIS', 'ARG', 'ASN', 'ASP', 'PRO', 'GLN', 'PHE', 'ASN', 'ARG', 'GLN', 'PHE', 'HIS', 'HIS', 'GLY', 'ASP', 'GLY', 'GLN', 'SER', 'PHE', 'ASN', 'ALA', 'GLU', 'ASP', 'PHE', 'ASP', 'ASP', 'ILE', 'PHE', 'SER', 'SER', 'ILE', 'PHE', 'GLY', 'GLN', 'HIS', 'ALA', 'ARG', 'GLN', 'SER', 'ARG', 'GLN', 'ARG', 'PRO', 'ALA', 'THR', 'ARG', 'GLY', 'HIS', 'ASP', 'ILE', 'GLU', 'ILE', 'GLU', 'VAL', 'ALA', 'VAL', 'PHE', 'LEU', 'GLU', 'GLU', 'THR', 'LEU', 'THR', 'GLU', 'HIS', 'LYS', 'ARG', 'THR', 'ILE', 'SER', 'TYR', 'ASN', 'LEU', 'PRO', 'VAL', 'TYR', 'ASN', 'ALA', 'PHE', 'GLY', 'MET', 'ILE', 'GLU', 'GLN', 'GLU', 'ILE', 'PRO', 'LYS', 'THR', 'LEU', 'ASN', 'VAL', 'LYS', 'ILE', 'PRO', 'ALA', 'GLY', 'VAL', 'GLY', 'ASN', 'GLY', 'GLN', 'ARG', 'ILE', 'ARG', 'LEU', 'LYS', 'GLY', 'GLN', 'GLY', 'THR', 'PRO', 'GLY', 'GLU', 'ASN', 'GLY', 'GLY', 'PRO', 'ASN', 'GLY', 'ASP', 'LEU', 'TRP', 'LEU', 'VAL', 'ILE', 'HIS', 'ILE', 'ALA', 'PRO', 'HIS', 'PRO', 'LEU', 'PHE', 'ASP', 'ILE', 'VAL', 'GLY', 'GLN', 'ASP', 'LEU', 'GLU', 'ILE', 'VAL', 'VAL', 'PRO', 'VAL', 'SER', 'PRO', 'TRP', 'GLU', 'ALA', 'ALA', 'LEU', 'GLY', 'ALA', 'LYS', 'VAL', 'THR', 'VAL', 'PRO', 'THR', 'LEU', 'LYS', 'GLU', 'SER', 'ILE', 'LEU', 'LEU', 'THR', 'ILE', 'PRO', 'PRO', 'GLY', 'SER', 'GLN', 'ALA', 'GLY', 'GLN', 'ARG', 'LEU', 'ARG', 'VAL', 'LYS', 'GLY', 'LYS', 'GLY', 'LEU', 'VAL', 'SER', 'LYS', 'LYS', 'GLN', 'THR', 'GLY', 'ASP', 'LEU', 'TYR', 'ALA', 'VAL', 'LEU', 'LYS', 'ILE', 'VAL', 'MET', 'PRO', 'PRO', 'LYS', 'PRO', 'ASP', 'GLU', 'ASN', 'THR', 'ALA', 'ALA', 'LEU', 'TRP', 'GLN', 'GLN', 'LEU', 'ALA', 'ASP', 'ALA', 'GLN', 'SER', 'SER', 'PHE', 'ASP', 'PRO', 'ARG', 'LYS', 'ASP', 'TRP', 'GLY', 'LYS', 'ALA']
colours = ['#FFFFFF','#CCFFFF','#99FFFF','#00CCFF','#0099FF','#0066FF','#0033FF','#0000CC','#000066']

high_val = max(avg)
segments = high_val/9.0
divider = segments
boundaries = []

for z in xrange(9):
    boundaries.append(divider)
    divider = divider + segments

rows = math.ceil(len(aa)/40.0)

list_numbers = [i for i in range(1, len(aa), 10)]

fig = plt.figure(figsize=(20,20),facecolor='white')
fig.subplots_adjust(top=0.99, bottom=0.40, left=0.01, right=0.45, wspace = 0.0, hspace = 2)

its = 0
for i in xrange(len(aa)):
    for bound in boundaries:
        if avg[i] <= bound:
            ax = plt.subplot(rows, 40, i+1, axisbg=colours[its])
            if colours[its] == '#000066':
                ax.text(0.5, 0.5, "%s" % aa_key[aa[i]], ha="center", va="center", size=15, color='white')
            else:
                ax.text(0.5, 0.5, "%s" % aa_key[aa[i]], ha="center", va="center", size=15, color='black')
        else:
            its +=1

    for spine in ax.spines.itervalues():
        spine.set_visible(False)

    ax.axes.get_xaxis().set_ticks([])
    ax.axes.get_yaxis().set_ticks([])

    if i+1 in list_numbers:
        ax.set_xlabel(i+1)
        ax.xaxis.set_label_position('top')

    its = 0

a = np.linspace(0, high_val, 9)
a = np.vstack((a,a))
cmap = mpl.colors.ListedColormap(['#FFFFFF','#CCFFFF','#99FFFF','#00CCFF','#0099FF','#0066FF','#0033FF','#0000CC','#000066'])
im = imshow(a, aspect='auto', cmap=plt.get_cmap(cmap), origin='lower')
colorbar()

plt.show()

A: Instead of creating so many axes, you can add Rectangles to one axes, here is the code:
import math
import numpy as np
from pylab import *
from matplotlib import mpl
import matplotlib.pyplot as plt

aa_key = {'ARG':'R', 'HIS':'H', 'LYS':'K', 'ASP':'D', 'GLU':'E', 'SER':'S', 'THR':'T', 'ASN':'N', 'GLN':'Q', 'CYS':'C', 'SEC':'C', 'GLY':'G', 'PRO':'P', 'ALA':'A', 'VAL':'V', 'ILE':'I', 'LEU':'L', 'MET':'M', 'PHE':'F', 'TYR':'Y', 'TRP':'W'}

avg = [93.89, 69.34, 62.14, 33.65, 59.14, 41.73, 22.27, 0.81, 43.57, 5.12, 0.06, 32.58, 18.07, 77.43, 38.97, 83.38, 31.26, 75.33, 68.95, 142.75, 19.71, 0.16, 57.19, 59.74, 0.2, 27.25, 125.09, 116.5, 7.9, 7.49, 131.04, 64.21, 18.45, 62.13, 51.68, 96.93, 80.49, 35.64, 153.67, 28.97, 117.85, 67.19, 4.77, 86.98, 40.65, 56.09, 28.04, 97.77, 25.68, 0.0, 21.36, 47.02, 0.0, 37.21, 66.44, 4.63, 5.51, 43.05, 42.99, 125.41, 100.06, 91.02, 59.16, 32.02, 63.1, 0.58, 5.66, 54.43, 40.13, 67.42, 74.4, 76.45, 105.18, 68.41, 75.86, 74.01, 103.7, 117.79, 90.08, 139.55, 89.3, 136.44, 104.58, 105.68, 42.46, 91.42, 35.22, 93.86, 48.37, 120.37, 66.23, 50.54, 64.71, 41.54, 71.54, 49.17, 60.97, 85.65, 111.92, 51.99, 53.2, 113.7, 126.62, 38.5, 102.27, 116.62, 60.34, 131.57, 78.68, 46.47, 120.32, 90.04, 122.09, 126.92, 72.98, 65.15, 82.23, 20.38, 50.95, 39.32, 20.96, 75.01, 14.44, 88.34, 1.94, 51.8, 2.06, 90.28, 3.36, 64.76, 31.06, 0.51, 29.15, 87.07, 84.27, 65.24, 128.51, 38.39, 94.71, 16.21, 85.0, 31.2, 59.57, 6.18, 33.06, 33.73, 60.79, 61.36, 95.3, 197.35, 26.78, 112.83, 64.85, 131.5, 97.56, 94.93, 79.31, 95.74, 60.12, 89.47, 19.11, 87.26, 16.72, 110.99, 1.96, 33.8, 18.2, 21.86, 13.52, 24.27, 62.86, 31.47, 39.23, 80.43, 38.0, 85.39, 48.59, 136.98, 35.9, 45.6, 4.45, 17.14, 70.42, 34.51, 124.57, 116.16, 66.84, 23.42, 109.71, 58.46, 6.64, 11.81, 0.2, 43.98, 0.2, 15.75, 2.59, 47.25, 11.7, 30.86, 81.7, 30.13, 104.47, 69.54, 7.08, 67.92, 56.72, 63.09, 47.24, 45.87, 23.58, 0.05, 41.5, 3.43, 72.93, 5.42, 60.21, 1.23, 20.09, 1.81, 39.74, 47.41, 0.08, 3.54, 67.77, 19.85, 26.79, 124.72, 33.09, 78.66, 0.99, 55.68, 13.74, 16.07, 119.38, 93.24, 64.98, 43.75, 107.65, 14.95, 69.54, 3.25, 68.41, 56.43, 16.03, 4.43, 61.51, 24.86, 46.78, 43.31, 87.59, 24.02, 108.74, 15.55, 128.87, 35.05, 31.09, 3.57, 6.79, 40.17, 23.66, 116.78, 131.23, 81.16, 58.18, 3.68, 13.18, 0.0, 28.06, 0.0, 25.68, 3.37, 51.95, 1.15, 24.84, 4.6, 22.33, 33.47, 108.62, 16.1, 49.53, 135.2, 71.43, 5.79, 15.91, 48.61, 13.73, 9.4, 87.11, 63.19, 7.91, 21.25, 94.15, 45.86, 26.36, 80.05, 105.57, 52.3, 51.13, 56.83, 113.51, 92.92, 67.0, 148.45, 35.13, 114.23, 108.02, 94.94, 68.44, 62.22, 31.15, 60.04, 38.47, 22.3, 0.78, 39.35, 4.7, 0.09, 28.1, 17.58, 73.04, 37.55, 83.03, 31.78, 75.43, 69.08, 142.08, 19.87, 0.12, 57.8, 56.07, 0.33, 27.34, 124.44, 98.74, 6.57, 7.63, 126.51, 54.26, 16.13, 62.16, 51.03, 96.26, 78.31, 33.71, 142.46, 25.05, 101.93, 59.35, 5.0, 82.65, 36.26, 52.16, 27.37, 96.5, 24.5, 0.0, 21.25, 46.08, 0.0, 37.11, 62.57, 4.14, 5.19, 40.52, 38.78, 122.3, 97.2, 87.08, 57.43, 31.35, 61.98, 0.47, 5.45, 52.48, 41.73, 61.9, 73.38, 76.32, 104.43, 69.92, 78.78, 76.66, 107.05, 121.75, 91.06, 137.56, 91.2, 135.56, 107.81, 103.62, 41.7, 91.29, 35.24, 95.06, 48.72, 120.38, 65.02, 51.42, 63.83, 42.03, 72.09, 46.49, 58.56, 88.6, 111.84, 51.98, 53.78, 113.33, 126.69, 39.08, 101.86, 118.26, 59.34, 131.83, 79.09, 46.05, 119.72, 88.5, 121.97, 124.3, 72.72, 64.42, 83.82, 21.05, 52.81, 39.94, 21.72, 74.56, 12.92, 83.91, 1.73, 50.29, 1.86, 90.79, 3.81, 63.99, 31.36, 0.57, 29.63, 84.77, 89.53, 63.56, 125.84, 35.8, 92.01, 15.26, 83.0, 30.76, 59.25, 6.29, 34.43, 33.28, 62.53, 61.09, 95.55, 196.45, 27.62, 113.44, 63.2, 129.38, 94.13, 92.39, 78.32, 91.58, 60.28, 89.43, 19.21, 88.07, 16.92, 114.43, 1.85, 41.76, 18.49, 24.06, 14.87, 26.1, 62.6, 33.32, 47.49, 87.78, 43.66, 89.01, 50.82, 137.19, 36.07, 45.04, 4.74, 17.27, 70.76, 34.06, 122.94, 115.74, 67.75, 22.31, 109.71, 58.98, 6.2, 11.94, 0.17, 44.87, 0.2, 13.79, 2.98, 45.03, 10.99, 29.79, 79.91, 29.46, 100.54, 66.28, 6.74, 68.25, 56.62, 70.73, 50.56, 58.69, 26.22, 0.2, 42.1, 2.29, 65.71, 5.29, 54.8, 0.74, 17.54, 1.47, 28.1, 38.62, 0.3, 4.99, 67.47, 18.73, 25.92, 125.97, 26.34, 60.35, 0.94, 52.67, 13.45, 15.84, 117.19, 92.53, 62.5, 43.79, 106.85, 16.62, 71.9, 2.93, 68.08, 71.72, 10.62, 4.19, 46.87, 24.12, 47.09, 42.94, 92.39, 26.66, 109.61, 13.34, 129.23, 34.47, 31.0, 3.22, 7.69, 42.03, 28.05, 149.01, 156.76, 92.83, 57.73, 3.86, 14.9, 0.0, 29.23, 0.03, 25.92, 3.87, 45.65, 1.09, 20.81, 3.66, 27.06, 28.97, 94.28, 12.82, 63.89, 134.81, 81.96, 10.38, 17.27, 47.6, 23.26, 11.64, 94.27, 71.8, 2.46, 33.86, 93.88, 44.6, 20.61, 80.47, 97.13, 47.26, 50.87, 56.86, 126.64, 84.4, 57.84, 167.2, 37.38, 118.34, 106.89]
aa = ['ALA', 'SER', 'ALA', 'LEU', 'LYS', 'ASP', 'TYR', 'TYR', 'ALA', 'ILE', 'MET', 'GLY', 'VAL', 'LYS', 'PRO', 'THR', 'ASP', 'ASP', 'LEU', 'LYS', 'THR', 'ILE', 'LYS', 'THR', 'ALA', 'TYR', 'ARG', 'ARG', 'LEU', 'ALA', 'ARG', 'LYS', 'TYR', 'HIS', 'PRO', 'ASP', 'VAL', 'SER', 'LYS', 'GLU', 'PRO', 'ASP', 'ALA', 'GLU', 'ALA', 'ARG', 'PHE', 'LYS', 'GLU', 'VAL', 'ALA', 'GLU', 'ALA', 'TRP', 'GLU', 'VAL', 'LEU', 'SER', 'ASP', 'GLU', 'GLN', 'ARG', 'ARG', 'ALA', 'GLU', 'TYR', 'ASP', 'GLN', 'MET', 'TRP', 'GLN', 'HIS', 'ARG', 'ASN', 'ASP', 'PRO', 'GLN', 'PHE', 'ASN', 'ARG', 'GLN', 'PHE', 'HIS', 'HIS', 'GLY', 'ASP', 'GLY', 'GLN', 'SER', 'PHE', 'ASN', 'ALA', 'GLU', 'ASP', 'PHE', 'ASP', 'ASP', 'ILE', 'PHE', 'SER', 'SER', 'ILE', 'PHE', 'GLY', 'GLN', 'HIS', 'ALA', 'ARG', 'GLN', 'SER', 'ARG', 'GLN', 'ARG', 'PRO', 'ALA', 'THR', 'ARG', 'GLY', 'HIS', 'ASP', 'ILE', 'GLU', 'ILE', 'GLU', 'VAL', 'ALA', 'VAL', 'PHE', 'LEU', 'GLU', 'GLU', 'THR', 'LEU', 'THR', 'GLU', 'HIS', 'LYS', 'ARG', 'THR', 'ILE', 'SER', 'TYR', 'ASN', 'LEU', 'PRO', 'VAL', 'TYR', 'ASN', 'ALA', 'PHE', 'GLY', 'MET', 'ILE', 'GLU', 'GLN', 'GLU', 'ILE', 'PRO', 'LYS', 'THR', 'LEU', 'ASN', 'VAL', 'LYS', 'ILE', 'PRO', 'ALA', 'GLY', 'VAL', 'GLY', 'ASN', 'GLY', 'GLN', 'ARG', 'ILE', 'ARG', 'LEU', 'LYS', 'GLY', 'GLN', 'GLY', 'THR', 'PRO', 'GLY', 'GLU', 'ASN', 'GLY', 'GLY', 'PRO', 'ASN', 'GLY', 'ASP', 'LEU', 'TRP', 'LEU', 'VAL', 'ILE', 'HIS', 'ILE', 'ALA', 'PRO', 'HIS', 'PRO', 'LEU', 'PHE', 'ASP', 'ILE', 'VAL', 'GLY', 'GLN', 'ASP', 'LEU', 'GLU', 'ILE', 'VAL', 'VAL', 'PRO', 'VAL', 'SER', 'PRO', 'TRP', 'GLU', 'ALA', 'ALA', 'LEU', 'GLY', 'ALA', 'LYS', 'VAL', 'THR', 'VAL', 'PRO', 'THR', 'LEU', 'LYS', 'GLU', 'SER', 'ILE', 'LEU', 'LEU', 'THR', 'ILE', 'PRO', 'PRO', 'GLY', 'SER', 'GLN', 'ALA', 'GLY', 'GLN', 'ARG', 'LEU', 'ARG', 'VAL', 'LYS', 'GLY', 'LYS', 'GLY', 'LEU', 'VAL', 'SER', 'LYS', 'LYS', 'GLN', 'THR', 'GLY', 'ASP', 'LEU', 'TYR', 'ALA', 'VAL', 'LEU', 'LYS', 'ILE', 'VAL', 'MET', 'PRO', 'PRO', 'LYS', 'PRO', 'ASP', 'GLU', 'ASN', 'THR', 'ALA', 'ALA', 'LEU', 'TRP', 'GLN', 'GLN', 'LEU', 'ALA', 'ASP', 'ALA', 'GLN', 'SER', 'SER', 'PHE', 'ASP', 'PRO', 'ARG', 'LYS', 'ASP', 'TRP', 'GLY', 'LYS', 'ALA', 'ALA', 'SER', 'ALA', 'LEU', 'LYS', 'ASP', 'TYR', 'TYR', 'ALA', 'ILE', 'MET', 'GLY', 'VAL', 'LYS', 'PRO', 'THR', 'ASP', 'ASP', 'LEU', 'LYS', 'THR', 'ILE', 'LYS', 'THR', 'ALA', 'TYR', 'ARG', 'ARG', 'LEU', 'ALA', 'ARG', 'LYS', 'TYR', 'HIS', 'PRO', 'ASP', 'VAL', 'SER', 'LYS', 'GLU', 'PRO', 'ASP', 'ALA', 'GLU', 'ALA', 'ARG', 'PHE', 'LYS', 'GLU', 'VAL', 'ALA', 'GLU', 'ALA', 'TRP', 'GLU', 'VAL', 'LEU', 'SER', 'ASP', 'GLU', 'GLN', 'ARG', 'ARG', 'ALA', 'GLU', 'TYR', 'ASP', 'GLN', 'MET', 'TRP', 'GLN', 'HIS', 'ARG', 'ASN', 'ASP', 'PRO', 'GLN', 'PHE', 'ASN', 'ARG', 'GLN', 'PHE', 'HIS', 'HIS', 'GLY', 'ASP', 'GLY', 'GLN', 'SER', 'PHE', 'ASN', 'ALA', 'GLU', 'ASP', 'PHE', 'ASP', 'ASP', 'ILE', 'PHE', 'SER', 'SER', 'ILE', 'PHE', 'GLY', 'GLN', 'HIS', 'ALA', 'ARG', 'GLN', 'SER', 'ARG', 'GLN', 'ARG', 'PRO', 'ALA', 'THR', 'ARG', 'GLY', 'HIS', 'ASP', 'ILE', 'GLU', 'ILE', 'GLU', 'VAL', 'ALA', 'VAL', 'PHE', 'LEU', 'GLU', 'GLU', 'THR', 'LEU', 'THR', 'GLU', 'HIS', 'LYS', 'ARG', 'THR', 'ILE', 'SER', 'TYR', 'ASN', 'LEU', 'PRO', 'VAL', 'TYR', 'ASN', 'ALA', 'PHE', 'GLY', 'MET', 'ILE', 'GLU', 'GLN', 'GLU', 'ILE', 'PRO', 'LYS', 'THR', 'LEU', 'ASN', 'VAL', 'LYS', 'ILE', 'PRO', 'ALA', 'GLY', 'VAL', 'GLY', 'ASN', 'GLY', 'GLN', 'ARG', 'ILE', 'ARG', 'LEU', 'LYS', 'GLY', 'GLN', 'GLY', 'THR', 'PRO', 'GLY', 'GLU', 'ASN', 'GLY', 'GLY', 'PRO', 'ASN', 'GLY', 'ASP', 'LEU', 'TRP', 'LEU', 'VAL', 'ILE', 'HIS', 'ILE', 'ALA', 'PRO', 'HIS', 'PRO', 'LEU', 'PHE', 'ASP', 'ILE', 'VAL', 'GLY', 'GLN', 'ASP', 'LEU', 'GLU', 'ILE', 'VAL', 'VAL', 'PRO', 'VAL', 'SER', 'PRO', 'TRP', 'GLU', 'ALA', 'ALA', 'LEU', 'GLY', 'ALA', 'LYS', 'VAL', 'THR', 'VAL', 'PRO', 'THR', 'LEU', 'LYS', 'GLU', 'SER', 'ILE', 'LEU', 'LEU', 'THR', 'ILE', 'PRO', 'PRO', 'GLY', 'SER', 'GLN', 'ALA', 'GLY', 'GLN', 'ARG', 'LEU', 'ARG', 'VAL', 'LYS', 'GLY', 'LYS', 'GLY', 'LEU', 'VAL', 'SER', 'LYS', 'LYS', 'GLN', 'THR', 'GLY', 'ASP', 'LEU', 'TYR', 'ALA', 'VAL', 'LEU', 'LYS', 'ILE', 'VAL', 'MET', 'PRO', 'PRO', 'LYS', 'PRO', 'ASP', 'GLU', 'ASN', 'THR', 'ALA', 'ALA', 'LEU', 'TRP', 'GLN', 'GLN', 'LEU', 'ALA', 'ASP', 'ALA', 'GLN', 'SER', 'SER', 'PHE', 'ASP', 'PRO', 'ARG', 'LYS', 'ASP', 'TRP', 'GLY', 'LYS', 'ALA']
colours = ['#FFFFFF','#CCFFFF','#99FFFF','#00CCFF','#0099FF','#0066FF','#0033FF','#0000CC','#000066']

high_val = max(avg)
boundaries = np.linspace(0, np.max(avg), 10)[1:]
rows = math.ceil(len(aa)/40.0)
list_numbers = set(range(1, len(aa), 10))

fig = plt.figure(figsize=(10, 10), facecolor="white")
ax = plt.subplot(111)
ax.set_axis_off()
color_index = np.searchsorted(boundaries, avg)
x, y = 0, -1
for i in xrange(len(aa)):
    rect = plt.Rectangle((x, y), 1, 1, facecolor=colours[color_index[i]])
    ax.add_artist(rect)
    ax.text(x+0.5, y+0.5, aa_key[aa[i]], ha="center", va="center", color="white" if color_index[i]==8 else "black")
    if i+1 in list_numbers:
        ax.text(x+0.5, y+1.6, "%d" % (i+1), ha="center", va="center")
    x += 1
    if x == 40:
        y -= 3.0
        x = 0
ax.set_xlim(-1, 41)
ax.set_ylim(y-3, 3)

a = np.linspace(0, high_val, 9)
a = np.vstack((a,a))
cmap = mpl.colors.ListedColormap(['#FFFFFF','#CCFFFF','#99FFFF','#00CCFF','#0099FF','#0066FF','#0033FF','#0000CC','#000066'])
im = imshow(a, aspect='auto', cmap=plt.get_cmap(cmap), origin='lower')
im.set_visible(False)
colorbar()
plt.show()

The result is:

redpajama_set_name: RedPajamaStackExchange


text:
Q: Leaflet issue: Marker and polygon not agreeing on locations? I've got a leaflet map, to which I added a GeoJSON object (a polygon, specifically) and a number of Markers. The markers should all be inside the polygon, but they're not being displayed that way:

In the example below, the GeoJSON is:
{"type":"Polygon","coordinates":[[[29.53125,49.921875],[29.53125,50.625],[30.9375,50.625],[30.9375,49.921875],[29.53125,49.921875]]]}
And the green-highlighted marker's coordinates are:
[30.9332103729, 50.3615112305]
As you can see that marker is showing up well outside the outline of the polygon. The problem is considerably worse at wider zoom levels -- zoomed all the way in, the green marker makes its way just barely inside the polygon outline.
Any idea what could be causing this?
UPDATE:
Turns out the issue appears to be the Markers, not the GeoJSON... when I zoom in on the map, the markers move. In this example, they all move to the northwest as I zoom in.

A: Judging by the data, the comments, and some tests, it seems that the problem was in the misuse of the iconAnchor option for the marker's icons.
Even though the "tip" of the marker icon image is out of the rectangle, the top-left corner of the markers is always within the rectangle, which indicates that the iconAnchor option has a value of [0, 0]. Adjusting this value to fit the "tip" should fix the visual issue.


text:
Q: If $a^3=20a^2+b^2+c^2-a-340$, $b^3=20b^2+c^2+a^2-b-340$, $a^3=20a^2+a^2+b^2-c-340$, what is value of $abc$? Question : If $a^3=20a^2+b^2+c^2-a-340$,  $b^3=20b^2+c^2+a^2-b-340$, $a^3=20a^2+a^2+b^2-c-340$, what is value of $abc$?
I think I should add this and get close to $abc$, but I can't think about this. I know that answer is 19. Please help me

A: $$20a^2+b^2+c^2-a-340-a^3=0$$
$$20b^2+c^2+a^2-b-340-b^3=0$$
$$20c^2+a^2+b^2-c-340-c^3=0$$
Taking note of @Ishraaqparvez comments
Maybe before you find the product of $abc$, you should first know what their corresponding values are
$$(a-19)^4(a^2+1)^4(a^3-22a^2+a+340)(a^4+5a^2-38a-356)(a^4-41a^3+422a^2+283a-6459)^2=0$$
$$(b-19)^4(b^2+1)^4(b^3-22b^2+b+340)(b^4+5b^2-38b-356)(b^4-41b^3+422b^2+283b-6459)^2=0$$
$$(c-19)^4(c^2+1)^4(c^3-22c^2+c+340)(c^4+5c^2-38c-356)(c^4-41c^3+422c^2+283c-6459)^2=0$$
Note that the equations are symmetric, so $a,b,c$ are different solutions of the same equation
$$(x-19)(x^2+1)$$
$$x^3-22x^2+x+340$$
Then their real product is $-340$


text:
Q: Simplify CoffeeScript statement I am trying to handle a simple case where i could be getting an object, or a dictionary.  So i am either going to get a object like:
obj.fields.nick

or its going to be a dictionary like
obj['nick']

I was wondering if there was a simpler way to do the following:
value = (eval("obj.fields." + field[1]) if obj?.fields ) ? eval("obj['#{field[1]}']")

I was hoping to do something like:
value = (obj?.fields?."#{field[1]}" ) ? eval("obj['#{field[1]}']")

But if that worked I wouldn't be writing this post...
I am basically looking for a way to execute a string as part of the if

A: value = obj.fields?[field] ? obj[field]
# or
value = (obj.fields ? obj)[field]

This is the same as
if obj.fields?
    obj.fields[field]
else
    obj[field]

There is absolutely no need for eval.

A: The string interpolation construct ("Equals four: #{2+2}") is something that is handled by the coffeescript compiler, and will therefore not work inside an eval. But assuming the naming of the stuff inside the string does not change, you could easily rewrite it, so that eval("obj['#{field[1]}']") becomes eval("obj['"+field[1]+"']"). Assuming I got your question right of course.


text:
Q: Is the ELSE of an IF (p) statement including a method the "NOT METHOD" (not p)? If I write a statement:
if(!(method())
{
    // do something
}
else
{
    //do something
}

And method returns a boolean value, is the else - without writing else if (method() - automatically the opposite of if, i.e. does else have a relationship to the method called in the opening if statement?

A: Yes - implicitly, IF .. ELSE is a boolean test that essentially looks like this:
IF (condition)
{
<< condition evaluated to TRUE >>
}
ELSE
{
<< condition evaluated to FALSE >>
}

A: Yes, if method on IF return TRUE, as it's negated, ELSE statement will execute.
It's like:
if(!myMethod()) {

    //RUN SOMETHING
}
else {
    //RUN OTHER THING HERE
}

If MyMethod Returns "TRUE", the if statement will se a "FALSE" because it's inverting it, so as it's not true, will run the ELSE code (//RUN OTHER THING).


text:
Q: Setting up virtualenv in windows with specific interpreter I have a number of django projects organized with the following directory structure using win7 (I'm using GIT_BASH/mingw for my command line) :
envs--s1--project1
        --project2
python275--

I want to create a virtualenv inside s1 using python275 as the interpreter so the directory structure looks like:
envs--s1--project1
        --project2
        --Include
        --Library
        --Scripts
python275--

I tried:
/c/envs/s1
$ pip install virtualenv
sh: pip: command not found

How can I set up this up?

A: It seems like you don't have pip installed on your system. If you have installed using the get-pip.py installer you need to make sure the Scripts directory of you python installation is included in your PATH environment variable.
For more detail regarding installing pip check out the doc


text:
Q: return char array function error
Possible Duplicate:
Is it a good idea to return " const char * " from a function?
how to return char array in c++?

What is wrong with this return? I'm trying to return the current path using the following function but it doesn't seems to be correct:
Please Not: I need an char return not string.
char* getINIfile(void)
{
    char buffer[MAX_PATH];
    GetModuleFileName( NULL, buffer, MAX_PATH );
    string::size_type pos = string( buffer ).find_last_of( "\\/" );
    string path = string( buffer ).substr( 0, pos) + "\\setup.ini";

    char *ini_local= (char*)path.c_str();

    printf(ini_local); // so far output OK!

    return ini_local;
}

main
{
    printf(getINIfile()); // output Not OK!

    char mybuffer[200];
    GetPrivateProfileStringA( "files","DLL","0",  mybuffer,200, getINIfile());
    printf(mybuffer);

}

A: path goes out of scope at the end of the function and you are returning an internal pointer in that out of scope object. try returning an std::string instead
std::string getINIfile(void)
{
    char buffer[MAX_PATH];
    GetModuleFileName( NULL, buffer, MAX_PATH );
    string::size_type pos = string( buffer ).find_last_of( "\\/" );
    string path = string( buffer ).substr( 0, pos) + "\\setup.ini";

    char *ini_local= (char*)path.c_str();

    printf(ini_local); // so far output OK!

    return path;
}

A: You're returning an address that goes out of scope when the function exits, and so it's no longer valid: std::string path is local to the function getINIFile and so it's invalid after the function exits, as is the address that you get from path.c_str().
In this case you can just return the std::string from your function. If you really need a C string later, you can use c_str() then:
std::string getINIfile(void)
{
    //...

    return path;
}

int main()
{
    string path = getINIFile();

    // do something with path.c_str():
    const char *cPath = path.c_str();
}

Given your code I can't think of any reason that you must have a char* return, but if so you'll need to allocate a buffer on the heap:
char *getINIfile(void)
{
    char *buffer[MAX_PATH];
    GetModuleFileName(NULL, buffer, MAX_PATH);
    string::size_type pos = string(buffer).find_last_of( "\\/" );
    string path = string(buffer).substr( 0, pos) + "\\setup.ini";

    char *ini_local = new[path.size()];
    strncpy(ini_local, path.c_str(), path.size());

    printf(ini_local); // so far output OK!

    return ini_local;
}

But this is a really awful mix of standard C strings and std::string: just using string to manipulate the path and passing around char* everywhere else.
Using only standard C, replacing find_last_of with strrchr - note the lack of error handling:
char *getINIfile(void)
{
    char *buffer = new[MAX_PATH];
    char *pos = NULL;
    char *ini_local = NULL;

    GetModuleFileName(NULL, buffer, MAX_PATH);
    pos = strrchr(buffer, "\\/");
    // check for and handle pos == NULL

    buffer[pos] = '\0';

    strncat(buffer, "\\setup.ini", MAX_PATH - strlen(buffer));

    printf(buffer);

    return buffer;
}

A: The function is returning a pointer to a local variable, which goes out of scope, leaving you with a dangling pointer. Why not just return an std::string by value?
std::string getINIfile() {
   ....
   return path;
}

Then you can just use the string's underlying char* on the caller side:
const std::string s = getINIfile();
const char* c = s.c_str();


text:
Q: ASP.NET: Will cookies be deleted after expiry even though the page is not refreshed/reloaded I am developing an asp.net site.
I set like this, I worry if the page is not reloaded(keeping on the same page) the cookies won't be deleted after a day.
YourCookies.Expires = DateTime.Now.AddDays(1)

A: The cookies expires, not auto delete him self.
What is means expires ? the cookies stays there but if you ask for them again, and have expires, you just don't read them.
If the browser stays open and the cookie expires, the page is still there - the cookie is still there until you make refresh. If you need to close the user browser after the cookie expires, you need to add extra javasript call to verify that every few seconds or so.
If you wish to create something that deletes him self, then include on the cookie string, more information's encrypted, for example, include the datetime that you wish to "delete" them and then when you read that cookie, check that datetime and act accordingly. This is how the verification of user cookie works


text:
Q: How can I find a div element with style? How do I find a div element by its style?
I "view source" in IE6 and have this:
...an>
<img alt="Google"...

How can I get this in JavaScript?

A: The question isn't very clear. Is this what you're looking for?
var div_style = document.getElementById('lga').style;

A: Why would you want to get the div by its style? It's much simpler to get it by its ID.
Standard JavaScript:
document.getElementById("lga");

If using jQuery:
$("#lga");

A: Use document.getElementById()
document.getElementById("lga");

A: If you really want to find element by its style (I not recommended)
via jQuery do this
// jQuery attr equal value selector [1]
$('[style="{your_style_value}"]');

// in your case
$('[style="height:231px;margin-top:-22px"]')

[1] http://api.jquery.com/attribute-equals-selector/
Hope this help :)

A: The real WTF is that you are using Internet explorer 6 even though internet explorer 8 is the standard for windows 7, internet explorer 9 and above for 9, and even if you have an old version of windows there is still firefox and Chrome which is > Internet explorer 6.


text:
Q: why getting the menu listing from bottom to top in css? I want a right aligned simple menu.but i am getting the menu listing the li tag from bottom to top. I want to display it from top to bottom in right aligned menu.
html:

HOME

ABOUT

HOW it WORKS

SERVICE PROVIDERS

css:
.menu{
    list-style:none;
}
.menu li{
    float:right;
    padding:10px;
}

i am getting the output as the image below

A: At-present you are adding float to li elements instead add that to .menu and change li display as inline-blocks, this would be one way of doing this.
Update -

float:right- The element floats to the right of its container.

As per above statement float right floats element to right-side of container thus here the first li element floats right to the end of container and then followed by other. Add width properties between li tags to understand more clearly and even change the float property to see the difference how elements are floated.

.menu {
  list-style: none;
  float: right; /*Add this*/
}

.menu li {
 display:inline-block; /*Add this*/
 padding: 10px;
}

HOME

ABOUT

HOW it WORKS

SERVICE PROVIDERS


text:
Q: Graph diameter algorithm Does anyone know what the complexity of Mathematica's GraphDiameter algorithm is? I have a family of very large (and very regular and very sparse) graphs, and if Mathematica uses something like the Johnson algorithm, it is feasible, but $O(V^3)$ algorithms are right out - $V$ is in the several million range.

A: If you need to compute diameters for large graphs, you should be aware that GraphDiameter tends to use an unreasonable amount of memory (up to gigabytes).  Based on its memory use, I believe that it computes the complete GraphDistanceMatrix first, and then just takes the largest element.
I have reported this to WRI on Feb 13 this year, and support confirmed the problem.
Because of this problem, I exposed igraph's diameter calculation function in IGraph/M.  How it compares in performance to Mathematica's builtin depends on the problem (the performance tends to be similar).  But I simply wasn't able to do the calculation for large graphs with GraphDiameter because it ran out of memory.

The methods available for the builtin are documented:
{"Dijkstra", "FloydWarshall", "Johnson", "PseudoDiameter"}

I am not familiar with all of these so I cannot tell you about their complexity.  "PseudoDiameter" does an approximation only.
Here is a test for a sparse graph, both weighted and unweighted versions.  igraph is supposed to use Dijkstra for weighted graphs.
SeedRandom[42];

g =
  First@ConnectedGraphComponents@
    RandomGraph[BernoulliGraphDistribution[4000, 0.001]];

wg =
  SetProperty[g, EdgeWeight -> RandomReal[1, EdgeCount[g]]];

Unweighted:
Table[
 {m, AbsoluteTiming@GraphDiameter[g, Method -> m]},
 {m, {"Dijkstra", "FloydWarshall", "Johnson", "PseudoDiameter"}}
 ]

(* {{"Dijkstra", {1.64515, 13.}}, {"FloydWarshall", {48.7639, 13.}},
    {"Johnson", {1.77069, 13.}}, {"PseudoDiameter", {0.000592, 13}}} *)

Weighted:
Table[
 {m, AbsoluteTiming@GraphDiameter[wg, Method -> m]},
 {m, {"Dijkstra", "FloydWarshall", "Johnson", "PseudoDiameter"}}
 ]

(*
{{"Dijkstra", {2.54546, 6.07364}}, {"FloydWarshall", {51.3041, 6.07364}},
 {"Johnson", {2.68918, 6.07364}}, {"PseudoDiameter", {2.70202, 6.07364}}}
*)

IGraph/M unweighted:
 << IGraphM`

IGDiameter[g] // AbsoluteTiming
(* {0.613409, 13} *)

Weighted:
IGDiameter[wg] // AbsoluteTiming
(* {34.0476, 6.07364} *)

Here's some more benchmarking for the weighted one with IGraph/M:
IGDistanceMatrix[wg, Method -> "Johnson"] // Max // AbsoluteTiming
(* {4.46778, 6.07364} *)

IGDistanceMatrix[wg, Method -> "BellmanFord"] // Max // AbsoluteTiming
(* {3.95098, 6.07364} *)

IGDistanceMatrix[wg, Method -> "Dijkstra"] // Max // AbsoluteTiming
(* {4.43047, 6.07364} *)

I will have to look into what is going on and why this is so much faster than IGDiameter.  The underlying C layer of igraph has the habit of overriding the user's method choice.  I am simply exposing this C layer to Mathematica.

Update: I reported the performance problem with igraph's diameter calculation function.  It has been fixed.  IGraph/M version 0.3.0 will include the fix.  New timing is 3.2 s instead of 34 s.

A: Hiding behind Details and Options on the documentation page is
Method  Automatic  Method to use

and
Possible Method Settings include "Dijkstra", "FloydWarshall", "Johnson", and "PseudoDiameter".


text:
Q: How to organize several independent git repos as a tree inside another folder (or repo) in git - don't need submodules? the gist of my question is about organizing my independent repos as a tree within git.
I only care about being able to place several repos inside a folder within BB
(Or several repos inside another repo, I don't care.)
Also don't care about tracking, say, push history to all three repos from one central place.  The repos are independent.
Submodules and such are way too much headache for the dead-simple thing I want to do.
I just want git to mirror the way I have my code organized on my local drive.
The big reason: Otherwise I would have to flatten out my tree in git.
I would have to give my git repos clunky names like projectOne-crappyOldDeprecatedVersion-perlStuff
Suppose my code looks like this, with a crappy / new / and common organization like so:
projectOne (can be a repo or a folder, don't care)
      crappyOldDeprecatedVersion (independent repo)
            perlStuff
            jqueryStuff
            rubyStuff
      shinyNewVersion (independent repo)
            javaBackEnd
            nodeServerSide
            reactFacade
      commonToCrappyAndShiny (independent repo)
            dbStoredProcedures

How can I accomplish this in git?


text:
Q: Training Word2Vec is extremely slow I'm currently trying to train a Word2Vec skip-gram model with negative sampling using keras from tensorflow 2.0 based on this tutorial (without the auxiliary output). My model looks like this:
# vocab_size = about 1 million
# embedding_dim = 300

# Target word and context word as integers
input_target = keras.Input((1,))
input_context = keras.Input((1,))

# Retrieve word embeddings of target and context word
embeddings = keras.layers.Embedding(vocab_size + 1, embedding_dim, input_length=1, name="embeddings")
embedding_target = embeddings(input_target)
embedding_context = embeddings(input_context)

# Reshape embeddings
reshape = keras.layers.Reshape((embedding_dim, 1))
embedding_target = reshape(embedding_target)
embedding_context = reshape(embedding_context)

# Compute dot product of embedding vectors
dot = keras.layers.Dot(1)([embedding_target, embedding_context])
dot = keras.layers.Reshape((1,))(dot)

# Compute output
output = keras.layers.Dense(1, activation="sigmoid")(dot)

# Create mode
model = keras.Model(inputs=[input_target, input_context], outputs=output)
model.compile(loss="binary_crossentropy", optimizer="rmsprop")

The data set I'm using is the english wikipedia data set provided by tensorflow. However I do not train on the full data set (5,824,596 articles), just on 3,000,000 articles. As you can imagine, the number of unique words (~1 million) and the total number of words (~1.2 billion) are still huge. However the authors of the original Word2Vec paper state in the abstract that learning high quality word vectors of a corpus of 1.6 billion words takes less than a day.
My implementation needs 3 seconds per article to train on average. This looks really slow to me as it would take more than 100 days to train on all 3 million articles once.
I have an Nvidia GTX 1080 TI, and nvidia-smi shows that the GPU utilization is at 0% most of the time with short "peaks" to about 5%.
My first thought was that the preprocessing steps are too slow. So I tested the training with dummy-data generated with numpy:
target = np.random.randint(0, vocab_size, 2048 * 1000, np.int32)
context = np.random.randint(0, vocab_size, 2048 * 1000, np.int32)
label = np.random.randint(0, 2, 2048 * 1000, np.int32)

model.fit([target, context], label, 4096)

I tested different values for batch_size (32, 1024, 2048, 4096), but the GPU utilization was still at 0% most of the time. The whole target, context and label arrays fit into memory.
As I changed the fit method to train_on_batch (but with no batching - put the whole arrays into the function) the GPU utilization at least varied between 0% and almost 40%.
Besides tensorflow-gpu is installed and tensorflow does recognize the GPU: 2020-03-13 15:44:52.424589: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10349 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:b1:00.0, compute capability: 6.1)
Am I missing something obvious? Could be possible as I'm new to keras/tensorflow and to machine learning in general.


text:
Q: Current ChildView Controller I am trying to implement a SwipeGesture on my viewcontroller.
The issue I am facing currently is that I cannot determine what the currently displayed childview controller is.
The swipeGesture is added to the container view controller.  And then must determine what is the currently displayed VC is in the parent-child relationship, then move to the right or left.

A: If you are talking about custom container view controller, it's the job of the container controller to keep track of this. So, you might have your own @property that keeps track of which one you're on, and adjust it as you transitionFromController as a result of a swipe. So you might have a numeric property that you increment as you go to the right and that you decrement as you go to the left.
In general (if you're just trying to keep track of which "from" controller you're passing to transitionFromViewController), there are two approaches. One approach is implied by listing 14-3 in Adding a child controller of the View Controller Programming Guide.
In this scenario, in viewDidLoad you perform addChildViewController for the first view controller with. You do not, in this scenario, load the other child view controllers via addChildViewController at this point, though, but rather you let your method that does the transitioning take care of that (as in Listing 14-3).
If you do it this way, you can just grab [self.childViewControllers lastObject], and that will be your "current" child controller. So, that might look like:
@interface ViewController ()

@property (nonatomic) NSInteger currentIndex;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIViewController *initialController = ... // set your initial controller

    [self addChildViewController:initialController];
    initialController.view.frame = self.containerView.bounds;
    [self.containerView addSubview:initialController.view];
    [initialController didMoveToParentViewController:self];

    UISwipeGestureRecognizer *gesture;

    gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
    gesture.direction = UISwipeGestureRecognizerDirectionRight;
    [self.containerView addGestureRecognizer:gesture];

    gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
    gesture.direction = UISwipeGestureRecognizerDirectionLeft;
    [self.containerView addGestureRecognizer:gesture];

}

- (void) handleSwipe:(UISwipeGestureRecognizer *)gesture
{
    if (gesture.direction == UISwipeGestureRecognizerDirectionLeft && self.currentIndex < (kMaxIndex - 1))
    {
        self.currentIndex++;

        UIViewController *newController = ... // set your new controller
        UIViewController *oldController = [self.childViewControllers lastObject];

        [self cycleFromViewController:oldController
                     toViewController:newController
                            direction:gesture.direction];

    }
    else if (gesture.direction == UISwipeGestureRecognizerDirectionRight && self.currentIndex > 0)
    {
        self.currentIndex--;

        UIViewController *newController = ... // set your new controller
        UIViewController *oldController = [self.childViewControllers lastObject];

        [self cycleFromViewController:oldController
                     toViewController:newController
                            direction:gesture.direction];
    }
}

- (void) cycleFromViewController:(UIViewController*) oldController
                toViewController:(UIViewController*) newController
                       direction:(UISwipeGestureRecognizerDirection)direction
{
    [oldController willMoveToParentViewController:nil];
    [self addChildViewController:newController];

    newController.view.frame = oldController.view.frame;

    UIViewAnimationOptions options;

    if (direction == UISwipeGestureRecognizerDirectionRight)
        options = UIViewAnimationOptionTransitionFlipFromLeft;
    else if (direction == UISwipeGestureRecognizerDirectionLeft)
        options = UIViewAnimationOptionTransitionFlipFromRight;

    [self transitionFromViewController:oldController
                      toViewController:newController
                              duration:0.33
                               options:options
                            animations:^{
                                [oldController removeFromParentViewController];
                            }
                            completion:^(BOOL finished) {
                                [newController didMoveToParentViewController:self];
                            }];
}

The other model that I've seen some people do is to load all of the potential child controllers via addChildViewController in viewDidLoad. I don't personally like this approach, but I know people do it this way and it works fine.
But if you do it this way, you can no longer rely upon childViewControllers to know which controller is the current one. In that case, you have to define your own class property for the currentChildController. So it might look something like:
@interface ViewController ()

@property (nonatomic, strong) UIViewController *currentChildController;
@property (nonatomic) NSInteger currentIndex;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ChildOne"]];
    [self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ChildTwo"]];
    [self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ChildThree"]];

    self.currentChildController = self.childViewControllers[0];

    self.currentChildController.view.frame = self.containerView.bounds;
    [self.containerView addSubview:self.currentChildController.view];

    for (UIViewController *controller in self.childViewControllers)
        [controller didMoveToParentViewController:self];

    UISwipeGestureRecognizer *gesture;

    gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
    gesture.direction = UISwipeGestureRecognizerDirectionRight;
    [self.containerView addGestureRecognizer:gesture];

    gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
    gesture.direction = UISwipeGestureRecognizerDirectionLeft;
    [self.containerView addGestureRecognizer:gesture];
}

- (void) cycleFromViewController:(UIViewController*) oldController
                toViewController:(UIViewController*) newController
                       direction:(UISwipeGestureRecognizerDirection) direction
{
    self.currentChildController = newController;

    newController.view.frame = oldController.view.frame;

    UIViewAnimationOptions options;

    if (direction == UISwipeGestureRecognizerDirectionRight)
        options = UIViewAnimationOptionTransitionFlipFromLeft;
    else if (direction == UISwipeGestureRecognizerDirectionLeft)
        options = UIViewAnimationOptionTransitionFlipFromRight;

    [self transitionFromViewController:oldController
                      toViewController:newController
                              duration:0.33
                               options:options
                            animations:^{
                            }
                            completion:nil];
}

- (void) handleSwipe:(UISwipeGestureRecognizer *)gesture
{
    if (gesture.direction == UISwipeGestureRecognizerDirectionLeft && self.currentIndex < (kMaxIndex - 1))
    {
        self.currentIndex++;

        UIViewController *oldController = self.currentChildController;
        UIViewController *newController = self.childViewControllers[self.currentIndex];

        [self cycleFromViewController:oldController
                     toViewController:newController
                            direction:gesture.direction];

    }
    else if (gesture.direction == UISwipeGestureRecognizerDirectionRight && self.currentIndex > 0)
    {
        self.currentIndex--;

        UIViewController *oldController = self.currentChildController;
        UIViewController *newController = self.childViewControllers[self.currentIndex];

        [self cycleFromViewController:oldController
                     toViewController:newController
                            direction:gesture.direction];
    }
}

Those are the two logical approaches.
By the way, the first approach doesn't preclude having your own class property to know which controller you're on, and sometimes that's useful (e.g. if the type of animation you employ is contingent upon whether you're going to the "right" or to the "left), but unless that's the case, you can get away with just looking at [self.childViewControllers lastObject].

A: In a project i'm working on, I have many View Controllers each with their own Navigation Controller added to a Parent View Controller. I know the initial entry child, but I do the following to find the currently displayed children of the child:
[myKnownViewController.childViewControllers objectAtIndex:0].navigationController.topViewController


text:
Q: How to solve integration involving delta functions I have an integration $I$
$$
I = \int d^3\mathbf{r} \Bigg[ \bigg(\nabla^2 f^\dagger(\mathbf{r})\bigg) f(\mathbf{r}) \bigg(\big(\nabla\delta(\mathbf{r}-\mathbf{r}')\big)\cdot \mathbf{A(r)}\bigg)\Bigg]
$$
here $f(\mathbf{r})$ is a scalar field which goes to zero at $\mathbf{r}\to\pm\infty$, $\mathbf{A}(\mathbf{r})$ is a vector field, $\nabla$ is del operator, and $\dagger$ shows complex conjugate.


text:
Q: How to Erase InkCanvas Strokes in Universal Windows Platform (Windows 10) app? Working with the InkCanvas control using the Universal Windows Platform (UWP) I can't seem to determine the correct method to erase ink strokes when using the InkCanvas - there's an event "StrokeErased" that can be handled.
Ideally the "InkCanvasEditingMode" on "InkCanvas.EditingMode" value to be set to either "InkCanvasEditingMode.EraseByPoint" or "InkCanvasEditingMode.EraseByStroke" would be used but these aren't available in the InkCanvas under Windows 10.
The example https://github.com/Microsoft/Windows-universal-samples/tree/master/simpleink mentions "Erase ink strokes" but the example just handles the StrokeErased event with no actual support for the erasing of them that I can see, what am I missing?

A: To let the user erase strokes (similar to WPF's InkCanvasEditingMode) set the InkCanvas's InkPresenter's InputProcessingConfiguration.Mode to InkInputProcessingMode.Erasing .
canvas.InkPresenter.InputProcessingConfiguration.Mode = Windows.UI.Input.Inking.InkInputProcessingMode.Erasing;


text:
Q: Parse Migration I have photo sharing application running on Parse. So if I will migrate to Parse Server, should I change my Android Code or it's just backend thing? And what is the best and the easiest way to migrate from parse without building new system on my own physical server.
Thank you.

A: If you are migrating to parse server, you shouldn't need to change your Android code. You will need to update to the latest android sdk and initialize parse with your own serverURL however. The serverURL is wherever you decide to host your parse server.
Hosting parse server is straight forward. Check out the parse server example here. They have links to one click deployment to a bunch of different paas providers such as heroku. If you have a lot of cloud code the migration process can become more complicated and is probably out of scope for this question. Most of it is outlined in the docs however.


text:
Q: Drupal6: Accessing node info from hook_preprocess_page(&$vars) For a certain content type, I want to alter the access denied error message. What is the best way to go about doing this?
function mytheme_preprocess_page(&$vars) {

  if ($vars['title'] == 'Access denied' && $node->type == 'ODP') {
    $vars['content'] = 'OMG WHAT R U DOING!1!?!!1';
  }

I was hoping to do something like that. However, after a print_r(get_defined_vars()), I was unable to find anything that could help me figure out what type the node being displayed is.

A: I don't think that this can be done - an access denied message in Drupal is generated by calling drupal_access_denied(). If you read the linked API entry, you will see that it doesn't pass any information about what type of page was being visited.


text:
Q: How to create table then insert data by sh (in Docker supplement)? I have docker-compose.yml
services:
    postgres:
        image: postgres:latest
        container_name: postgres
        ports:
            - "5432:5432"
        restart: unless-stopped
        volumes:
            - ./create-databases.sh:/docker-entrypoint-initdb.d/create-databases.sh
            - ./db_persist:/var/lib/postgresql/data
        environment:
            POSTGRES_USER: postgres
            POSTGRES_PASSWORD: postgres
            POSTGRES_DB: tenant_master
            POSTGRES_DB2: tenant_1
            POSTGRES_DB3: tenant_2

and File create-databases.sh
#!/bin/bash

set -eu

function create_database() {
  local database=$1
  echo "  Creating database '$database'"
  psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
    CREATE DATABASE $database;
    GRANT ALL PRIVILEGES ON DATABASE $database TO $POSTGRES_USER;
EOSQL
}

create_database $POSTGRES_DB2
create_database $POSTGRES_DB3

I need run below SQL snippet in database tenant_master (POSTGRES_DB)
CREATE TABLE public.tbl_tenant_master
(
    tenant_client_id serial NOT NULL,
    db_name character varying(128),
    url character varying(512) NOT NULL,
    user_name character varying(256) NOT NULL,
    password character varying(256) NOT NULL,
    driver_class character varying(512) NOT NULL,
    status character varying(64),
    PRIMARY KEY (tenant_client_id)
);

ALTER TABLE IF EXISTS public.tbl_tenant_master
    OWNER to postgres;

(1)
use master_db;

INSERT INTO `master_db`.`tbl_tenant_master` (`tenant_client_id`, `db_name`, `url`, `user_name`, `password`, `driver_class`, `status`)
VALUES ('200', 'testdb', 'jdbc:mysql://127.0.0.1:3306/testdb?useSSL=false', 'root', 'root', 'com.mysql.cj.jdbc.Driver', 'Active');
SELECT * FROM master_db.tbl_tenant_master;

(2)
How to inject (1), then (2) to sh script (I mean create table then insert data by sh in Docker supplement)?


text:
Q: Some confusions regarding electrostatic shielding
A spherical conductor A contains two spherical cavities as shown. The total charge on conductor itself is zero. However, there is a point charge q1 at the centre of one cavity and q2 at the centre of other. Another charge q3 is placed at a large distance r from the centre of the spherical conductor.

Now my confusion is about the force exerted by q3 on the charges q1 and q2.
I think that q3 should exert exactly the same force on the other two charges as it would have exerted in the absence of the sphere and to nullify the aforesaid forces the induced charges on the sphere should exert an equal and opposite force on both the charges.
But its not what the case is, Why?

A: q1 and q2 induce charges of the same magnitude and of the opposite sign on the surface of the spherical cavities.  This in turn means that on the outside surface of the sphere there are charges induced of the same magnitude and the same sign as charges q1 and q2.
These charges are distributed on the outside surface of the spherical conductor.  That is there is no way that just by looking at the surface charges can you deduce the location of the charge q1 and q2 or the location of the spherical cavities.
To find the force the relevant distance is that from the centre of the spherical conductor to charge q3.  The charge on the spherical conductor is to be taken as q1 + q2.
Added later
This idea that the field from the sphere with charges inside it can be thought as the field from a single point charge at the centre of the conducting sphere can be explained as follows.
The surface of the sphere is an equipotential.  E-field lines are always at right angles to an equipotential.  So the E-field lines at the surface of the sphere are a normal to the sphere and so when produced backwards all appear to come from the centre of the conducting sphere.

A: You're correct. And you're not. Depending on how you read the question. There's more than one way to interpret the phrase "the force exerted by q3 on q1."
You've interpreted it as just one in a bunch of terms in a net force equation, such that the net force on q1 is q1 times the sum of all the electric fields produced by all the charges in the problem. One of those terms is the usual Coulomb field between q1 and q3. Other terms happen to cancel that term out, and the net force on q1 is zero, but that' incidental; that q1q3 Coulomb term is still there regardless. Your interpretation makes sense and I think it's quite reasonable. Explicitly, I take it that you're interpreting "the force exerted by q3 on q1" to mean the force directly exerted, irrespective of all of the other terms cause by the surface charges. Under this (very reasonable) interpretation, your answer is quite correct.
But there's another way of interpreting the question. One might consider the phrase "the force exerted by q3 on q1" to mean "the net force exerted on q1 due to the presence of q3," which would of course be zero because (as you've surmised) the presence of q3 causes a rearrangement of surface charge such that the net effect on q1 is zero. And I suspect that this is how the majority of people would interpret it, to the extent that many people might not even realize that your understanding of the physics is fine but you're interpreting the question differently. It's a subconscious assumption. Under this interpretation (which I think is also a reasonable way to read the question), your answer would be wrong.
In short, it seems to me that you understand the physics just fine and the only problem is communication. The more I think about it, the more I think your interpretation is probably the better one even if it's not the first that comes to mind for many people. Still, I think both interpretations are reasonable and it may be of value for you to keep in mind both ways of describing the problem, and just be aware that there may be miscommunication because other people are interpreting the problem differently than you are.


text:
Q: Adding state to a function which gets called via pool.map -- how to avoid pickling errors I've hit the common problem of getting a pickle error when using the multiprocessing module.
My exact problem is that I need to give the function I'm calling some state before I call it in the pool.map function, but in doing so, I cause the attribute lookup __builtin__.function failed error found here.
Based on the linked SO answer, it looks like the only way to use a function in pool.map is to call the defined function itself so that it is looked up outside the scope of the current function.
I feel like I explained the above poorly, so here is the issue in code. :)
Testing without pool
# Function to be called by the multiprocessing pool
def my_func(x):
    massive_list, medium_list, index1, index2 = x
    result = [massive_list[index1 + x][index2:] for x in xrange(10)]
    return result in medium_list

if __name__ == '__main__':

    data = [comprehension which loads a ton of state]
    source = [comprehension which also loads a medium amount of state]

    for num in range(100):
        to_crunch = ((massive_list, small_list, num, x) for x in range(1000))
        result = map(my_func, to_crunch)

This works A-OK and just as expected. The only thing "wrong" with it is that it's slow.
Pool Attempt 1
# (Note: my_func() remains the same)
if __name__ == '__main__':

    data = [comprehension which loads a ton of state]
    source = [comprehension which also loads a medium amount of state]

    pool = multiprocessing.Pool(2)
    for num in range(100):
        to_crunch = ((massive_list, small_list, num, x) for x in range(1000))
        result = pool.map(my_func, to_crunch)

This technically works, but it is a stunning 18x slower! The slow down must be coming from not only copying the two massive data structures on each call, but also pickling/unpickling them as they get passed around. The non-pool version benefits from only having to pass the reference to the massive list around, rather than the actual list.
So, having tracked down the bottleneck, I try to store the two massive lists as state inside of my_func. That way, if I understand correctly, it will only need to be copied once for each worker (in my case, 4).
Pool Attempt 2:
I wrap up my_func in a closure passing in the two lists as stored state.
def build_myfunc(m,s):
    def my_func(x):
        massive_list = m # close the state in there
        small_list = s

        index1, index2 = x
        result = [massive_list[index1 + x][index2:] for x in xrange(10)]
        return result in medium_list
    return my_func

if __name__ == '__main__':

    data = [comprehension which loads a ton of state]
    source = [comprehension which also loads a medium amount of state]

    modified_func = build_myfunc(data, source)

    pool = multiprocessing.Pool(2)
    for num in range(100):
        to_crunch = ((massive_list, small_list, num, x) for x in range(1000))
        result = pool.map(modified_func, to_crunch)

However, this returns the pickle error as (based on the above linked SO question) you cannot call a function with multiprocessing from inside of the same scope.
Error:
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

So, is there a way around this problem?

A: Map is a way to distribute workload. If you store the data in the func i think you vanish the initial purpose.
Let's try to find why it is slower. It's not normal and there must be something else.
First, the number of processes must be suitable for the machine running them. In your example you're using a pool of 2 processes so a total of 3 processes is involved. How many cores are on the system you're using? What else is running? What's the system load while crunching data?
What does the function do with the data? Does it access disk? Or maybe it uses DB which means there is probably another process accessing disk and cores.
What about memory? Is it sufficient for storing the initial lists?
The right implementation is your Attempt 1.
Try to profile the execution using iostat for example. This way you can spot the bottlenecks.
If it stalls on the cpu then you can try some tweaks to the code.
From another answer on Stackoverflow (by me so no problem copy and pasting it here :P ):
You're using .map() which collect the results and then returns. So for large dataset probably you're stuck in the collecting phase.
You can try using .imap() which is the iterator version on .map() or even the .imap_unordered() if the order of results is not important (as it seems from your example).
Here's the relevant documentation. Worth noting the line:

For very long iterables using a large value for chunksize can make the job complete much faster than using the default value of 1.


text:
Q: How to serve one image at multiple urls in Laravel I manage a Laravel (Laravel 4.2 on Apache) web site that serves images for 'items' at a url like the following:
http://<domain>/images/<item-key>/<img-name>

We are trying to work with another organization to pull information from our site, and they are requiring our images to have one base url for all images instead of one base url for the images for each item.  So we need to have a URL something like this:
http://<domain>/image_base/<item-key>-<img-name>

Is there a good way to allow for both url formats to be used for any item image?  My first attempt used a redirect so that using the latter url redirected to the the former, but apparently that is not acceptable.

A: Instead of redirecting, I was able to return a regular Laravel Response from my controller, as in:
$response = Response::make(File::get($image_path), 200);
$response->header('Content-Type', File::type($image_path));

A: In your routes:
Route::get('images/{item-key}/{img-name}', 'ImageController@show');
Route::get('image_base/{item-key}-{img-name}', 'ImageController@show');

In your controller:
public function show($key, $name)
{
    // Show image
}

Where ImageController@show is your controller and method, both should be the same, as you are passing the same variables to it.
Hope this helps


text:
Q: Extract data if between substrings else full string I have string pattern like these:
Beginning through June 18, 2022 at Noon standard time\n
Jan 20, 2022
Beginning through April 26, 2022 at 12:01 a.m. standard time

I want to extract the data part presetnt after "through" and before "at" word using python regex.
June 18, 2022
Jan 20, 2022
April 26, 2022

I can extract for the long text using re group.
s ="Beginning through June 18, 2022 at Noon standard time"
re.search(r'(.*through)(.*) (at.*)', s).group(2)

However it will not work for
s ="June 18, 2022"

Can anyone help me on that.

A: You may use this regex with a capture group:
(?:.* through |^)(.+?)(?: at |$)

RegEx Demo
RegEx Details:

*

*(?:.* through |^): Match anything followed by " though " or start position

*(.+?): Match 1+ of any character and capture it in group #1

*(?: at |$): Match " at " or end of string

Code:
import re
arr = ['Beginning through June 18, 2022 at Noon standard time',
'Jan 20, 2022',
'Beginning through April 26, 2022 at 12:01 a.m. standard time']

for i in arr:
     print (re.findall(r'(?:.* through |^)(.+?)(?: at |$)', i))

Output:
['June 18, 2022']
['Jan 20, 2022']
['April 26, 2022']

A: How about playing with optional groups and backtracking.
^(?:.*?through )?(.*?)(?: at.*)?$

See this demo at regex101 or a Python demo at tio.run
Note that if just one of the substrings are present, it will either match from the first to end of the string or from start of string to the latter. If none are present, it will match the full string.

Another idea could be to use PyPI regex which supports branch reset groups.
^(?|.*?through (.+?) at|(.+))

This one extracts the part between if both are present, else the full string. Afaik the regex module is widely compatible to Python's regex functions, just use import regex as re instead.
Demo at regex101 or Python demo at tio.run


text:
Q: Figure out logical function from a CMOS logic circuit "Given that Vdd > 0, determine the logical function that this CMOS circuit represents."
Any help on how to approach this problem would be great.
Many thanks!

A: Look at the T3/T4 structure, with regard to input B ... Work out what that does, then consider how T1/T2 must work with regard to input A ... Once you have an understanding of those subsections, figuring out how T5/T6 come into the equation should be easy.


text:
Q: How to sort javascript object collection by boolean string field I want to sort the collection like:
1) Only having "shared==true" column result should be appear first and all other should be after words.
tried with below approach but it does not work and show random.

var cmp= function (a, b) {

            if (a.shared == 'true' && b.shared != 'true') return -1;
            if (a.shared != 'true' && b.shared == 'true') return 0;
            return 1;
        }

var data= [{'id':1, 'name':'addd', 'shared':'true'},{'id':2, 'name':'addd1', 'shared':'false'},{'id':3, 'name':'addd2', 'shared':'true'}]
data.sort(cmp);
console.log(data);

A: Almost there. In your second if, you want to return 1. If both are true, you want to return 0. So you last return should be return 0.

var cmp = function(a, b) {
  if (a.shared == 'true' && b.shared != 'true') return -1;
  if (a.shared != 'true' && b.shared == 'true') return 1;
  return 0;
}

var data = [{
  'id': 1,
  'name': 'addd',
  'shared': 'true'
}, {
  'id': 2,
  'name': 'addd1',
  'shared': 'false'
}, {
  'id': 1,
  'name': 'addd2',
  'shared': 'true'
}]
data.sort(cmp);
console.log(data);

From the description:
if (a is greater than b by the ordering criterion) {
    return 1;
}

A: with filter and concat

var data = [{
  'id': 1,
  'name': 'addd',
  'shared': 'true'
}, {
  'id': 2,
  'name': 'addd1',
  'shared': 'false'
}, {
  'id': 1,
  'name': 'addd2',
  'shared': 'true'
}]

const sorted = data.filter(x => x.shared === 'true').concat(data.filter(x => x.shared !== 'true'));
console.log(sorted);


text:
Q: matplotlib: TypeError: float() argument must be a string or a number, not 'AxesSubplot' I'm working the matplotlib tutorials.  I have a working plot I would like to generalize with a function.  The plot works, however, when I define the red_grid_plot() function below, I get an error:
TypeError: float() argument must be a string or a number, not 'AxesSubplot'

and I can't tell from the traceback the source of the error.  The working plot is:
from alpha_vantage.timeseries import TimeSeries
import pandas as pd
import datetime
import matplotlib.pyplot as plt

ts = TimeSeries(key="XXXXXX", output_format='pandas')
df, meta_data = ts.get_daily_adjusted(symbol='TSLA', outputsize='full')

df.columns = df.columns.str[3:]
tesla = df[(df.index > '2019-05-01')]

fig, ax = plt.subplots(figsize=(12,6))

ax.plot(tesla['close'], 'r-', linewidth=2)

kwargs=dict(labelsize=12, direction='inout',
            length=6, color='r', width=2)

ax.tick_params(axis="x", rotation=45, **kwargs)
ax.tick_params(axis="y", **kwargs)

ax.minorticks_on()
ax.grid(axis="x", linestyle=':', linewidth='0.5', color='red')
ax.grid(axis="y", linestyle=':', linewidth='0.5', color='black')

fig.suptitle('TSLA Daily Close', fontsize=16)

plt.show()

produces:

I define the red_grid_plot() function as:
def red_grid_plot(x, y, ax, param_dict):

tic_kwargs=dict(labelsize=12,
                direction='inout',
                length=6,
                color='r',
                width=2)

grd_kwargs=dict(linestyle=':',
                linewidth='0.5')

ax.tick_params(axis="x", rotation=45, **tic_kwargs)
ax.tick_params(axis="y", **tic_kwargs)

ax.minorticks_on()

ax.grid(axis="x", color='red', **grd_kwargs)
ax.grid(axis="y", color='black', **grd_kwargs)

if isinstance(x, pd.DataFrame):
    x = x.values
else:
    x = x.to_numpy()

if isinstance(y, pd.DataFrame):
    y = y.values
else:
    y = y.to_numpy()

out = ax.plot(x, y, ax, **param_dict)
return out

When I call this function I get a:
TypeError: float() argument must be a string or a number, not 'AxesSubplot'

What float argument is the traceback complaining about?  I assumed it was complaining about a Pandas column or index needing conversion to a numpy array before calling the plot() method, hence the if/else tests, but that is not the issue.
Here is the entire traceback:
TypeError                                 Traceback (most recent call last)
<ipython-input-5-02ee0c0b3a19> in <module>
      1 fig, ax = plt.subplots(figsize=(12,6))
----> 2 red_grid_plot(tesla.index, tesla['close'], ax, {'linewidth': 2})

<ipython-input-4-e35299a48436> in red_grid_plot(x, y, ax, param_dict)
     28         y = y.to_numpy()
     29
---> 30     out = ax.plot(x, y, ax, **param_dict)
     31     return out

~\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
   1665         lines = [*self._get_lines(*args, data=data, **kwargs)]
   1666         for line in lines:
-> 1667             self.add_line(line)
   1668         self.autoscale_view(scalex=scalex, scaley=scaley)
   1669         return lines

~\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in add_line(self, line)
   1900             line.set_clip_path(self.patch)
   1901
-> 1902         self._update_line_limits(line)
   1903         if not line.get_label():
   1904             line.set_label('_line%d' % len(self.lines))

~\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in _update_line_limits(self, line)
   1922         Figures out the data limit of the given line, updating self.dataLim.
   1923         """
-> 1924         path = line.get_path()
   1925         if path.vertices.size == 0:
   1926             return

~\Anaconda3\lib\site-packages\matplotlib\lines.py in get_path(self)
   1025         """
   1026         if self._invalidy or self._invalidx:
-> 1027             self.recache()
   1028         return self._path
   1029

~\Anaconda3\lib\site-packages\matplotlib\lines.py in recache(self, always)
    673         if always or self._invalidy:
    674             yconv = self.convert_yunits(self._yorig)
--> 675             y = _to_unmasked_float_array(yconv).ravel()
    676         else:
    677             y = self._y

~\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py in _to_unmasked_float_array(x)
   1388         return np.ma.asarray(x, float).filled(np.nan)
   1389     else:
-> 1390         return np.asarray(x, float)
   1391
   1392

~\Anaconda3\lib\site-packages\numpy\core\_asarray.py in asarray(a, dtype, order)
     83
     84     """
---> 85     return array(a, dtype, copy=False, order=order)
     86
     87

TypeError: float() argument must be a string or a number, not 'AxesSubplot'


text:
Q: Euler (equidimensional) equation question Consider the equation $$x^2y''-8xy'+20y=0.$$ From an undergraduate ODE course, it is known that the two linearly are $y_1=x^5$ and $y_2=x^4$. However, why don't we consider solutions, for example, like the following one:
$$
y=\left\{
\begin{array}{c}
x^5\;\;{\mbox{if}}\;\;x\leq 0\\
0\;\;{\mbox{if}}\;\;x> 0.
\end{array}
\right.
$$
While the solution above is only differentiable 4 times, it is a perfectly good solution to the equation.
I understand that the point $x=0$ is singular and thus the uniqueness theorem does not apply there. Also this is not unique to that equation or that solution. The same type of solutions could be obtained for other equations with singular points. The example above is convenient because it is a simple differential equation with explicit solutions.
But my question is this: is there a reason why solutions such as the one above are not considered? Is it just because it is too complicated to be included in textbooks? Perhaps because they do not extend to solutions when the independent variable is allowed to be complex? Or perhaps people shy away to solutions that are not smooth (i.e. not in $C^\infty$) when smooth solutions exist?

A: Most likely, the answer is pedagogical. It is a shame, though, that this idea isn't at least mentioned in standard undergraduate textbooks.
I will say, though, that you come across this sort of solution in quantum mechanics. For example, the finite square well problem requires you to solve the Schrödinger equation in three different regions, and then stitch them together to get continuity of the wave function and its derivative. You can see the solution method at the wiki for the Finite potential well.
So there are certainly applications for this kind of solution!
Incidentally, what's particularly intriguing to me about your question is that your proposed solution is continuous at the origin, and even its first few derivatives are continuous at the origin! So your problem there could certainly have physical significance.


text:
Q: Java 1.6 Applet and Mac OS X, is there an official issue here? I'm developing an applet in Java 1.6 which is supposed (ofcourse) to run on Mac and PC.
However people with Mac seems to all have Java 1.5 installed even due they keep thier software updated with the Mac update tool.
This seems very strange to me that Java isn't automatically updated by Apple as Java 1.6 was released in 2006. Is there an official reason for this?
Also; if I go to http://www.java.com/en/download/help/testvm.xml , Mac OSX isn't listed?

A: Sun does not release Java for OS X, Apple does that (they have an agreement about it), and it comes out of the box (and with OS updates).
And, in general, Java releases lag significantly behind all other platforms on which Java runs because of it.


text:
Q: SQL : query large table I want to query a large data set in SQL - which is the right approach?
declare @datetime Datetime

select *
from sales
where salesdate <= @datetme

or:
select *
from sales
where salesdate < (select GetDate())

or:
select *
from sales
where salesdate < GetDate()

or by using NOW()

A: All three will have same execution plan other than 0% ASSIGN stage for variable in query no. 1. But it will turn out to be a good practice in the long run to always initialize variable as DATETIME and then use for comparison. When you have long comparisons to make this way, user will get the habit of formatting datetime in a variable and comparing column against those variables. Otherwise, it becomes a habit of formatting SQL column and then comapring it with date. That formats datetime field in every data row for comparison with value and makes datetime comparisons slow.
For this particular query, for readability and ease of use, you can select query no. 3 [Select * from sales where salesdate < GetDate()].

A: Select * from sales where salesdate < GetDate() would seem the most logical way of doing it, its less SQL than Select * from sales where salesdate < ( Select GetDate()) and there's not much point in declaring a variable like the first option if your only running a one off query, if you're going to use this a lot or in a stored procedure then adding the variable in would make sense.
But look at the Execution Plans and see which performs the best


text:
Q: Selenium: Unable to run code Hey I'm trying to convert the information below into two steps to be run in selenium.
For some reason even the xpath won't run in selenium, can someone please help.
Thank you!

A: xpath is case sensitive. Try //a[@href="http://google.com"]


text:
Q: Why don't I see Principal Name when I run az role assignment list from Azure Devops? I m running az role assignment list -g  from Azure Devops on Microsofts Hosted Agent
I dont see principalName parameter in result. But same command when I run on my local in VsCode I see principalName. I checked az cli versions  both MS agent and on my local, they are same 2.5.1
Wondering what I m missing....
below is what i get in Azure Devops after running the above command
{
    "canDelegate": xxx,
    "id": xxx,
    "name": xxx,
    "principalId": xxx,
    "principalType": xxx,
    "resourceGroup": xxx,
    "roleDefinitionId": xxx,
    "scope": xxx,
    "type": "Microsoft.Authorization/roleAssignments"
}

A:
Why don't I see Principal Name when I run az role assignment list from Azure Devops?

I could reproduce this issue with Azure CLI task on my side.
I found there is a similar issue about the Azure cli on the github, so, I am afraid this issue has not been fixed on the azure cli task, it still exists.
To resolve/verify this issue, you could try to use the Azure Powershell task to login and execute that command line:
az login -u <username> -p <password>

az role assignment list --resource-group rgname

The result:

Hope this helps.

A: Microsoft helped to resolve this issue. Your Service Principal needs Directory Read access on App Permissions. This would solve the problem.


text:
Q: Assignment of objects in VB6 I am attempting to create two identical objects in VB6 by assignment statements; something like this...
Dim myobj1 As Class1
Dim myobj2 As Class1

Set myobj1 = New Class1
myobj1.myval = 1
Set myobj2 = myobj1

It has become apparent that this doesn't create two objects but rather two references to the same object, which isn't what I am after. Is there any way to create a second object in this sort of way, or do I have to copy the object one member at a time...
Set myobj2 = new Class1
myobj2.mem1 = myobj1.mem1
...

?
Edit 2 Scott Whitlock has updated his excellent answer and I have incorporated his changes into this now-working code snippet.
Private Type MyMemento
     Value1 As Integer
     Value2 As String
End Type

Private Memento As MyMemento

Public Property Let myval(ByVal newval As Integer)
Memento.Value1 = newval
End Property

Public Property Get myval() As Integer
myval = Memento.Value1
End Property

Friend Property Let SetMemento(new_memento As MyMemento)
    Memento = new_memento
End Property

Public Function Copy() As Class1
     Dim Result As Class1
     Set Result = New Class1
     Result.SetMemento = Memento
     Set Copy = Result
End Function

One then performs the assignment in the code thus...
Set mysecondobj = myfirstobj.Copy

A: Like many modern languages, VB6 has value types and reference types.  Classes define reference types.  On the other hand, your basic types like Integer are value types.
The basic difference is in assignment:
Dim a as Integer
Dim b as Integer
a = 2
b = a
a = 1

The result is that a is 1 and b is 2.  That's because assignment in value types makes a copy.  That's because each variable has space allocated for the value on the stack (in the case of VB6, an Integer takes up 2 bytes on the stack).
For classes, it works differently:
Dim a as MyClass
Dim b as MyClass
Set a = New MyClass
a.Value1 = 2
Set b = a
a.Value1 = 1

The result is that both a.Value1 and b.Value1 are 1.  That's because the state of the object is stored in the heap, not on the stack.  Only the reference to the object is stored on the stack, so Set b = a overwrites the reference.  Interestingly, VB6 is explicit about this by forcing you to use the Set keyword.  Most other modern languages don't require this.
Now, you can create your own value types (in VB6 they're called User Defined Types, but in most other languages they're called structs or structures).  Here's a tutorial.
The differences between a class and a user defined type (aside from a class being a reference type and a UDT being a value type) is that a class can contain behaviors (methods and properties) where a UDT cannot.  If you're just looking for a record-type class, then a UDT may be your solution.
You can use a mix of these techniques.  Let's say you need a Class because you have certain behaviors and calculations that you want to include along with the data.  You can use the memento pattern to hold the state of an object inside of a UDT:
Type MyMemento
    Value1 As Integer
    Value2 As String
End Type

In your class, make sure that all your internal state is stored inside a private member of type MyMemento.  Write your properties and methods so they only use data in that one private member variable.
Now making a copy of your object is simple.  Just write a new method on your class called Copy() that returns a new instance of your class and initialize it with a copy of its own memento:
Private Memento As MyMemento

Friend Sub SetMemento(NewMemento As MyMemento)
    Memento = NewMemento
End Sub

Public Function Copy() as MyClass
    Dim Result as MyClass
    Set Result = new MyClass
    Call Result.SetMemento(Memento)
    Set Copy = Result
End Function

The Friend only hides it from stuff outside your project, so it doesn't do much to hide the SetMemento sub, but it's all you can do with VB6.
HTH

A: @Scott Whitlock, I was not able to make your code work but if it works it would be great.
I've created a regular module where I put the memento type
Type MyMemento
    Value1 As Integer
    Value2 As String
End Type

Then I create a class module called MyClass with the code
Private Memento As MyMemento

Friend Sub SetMemento(NewMemento As MyMemento)
        Memento = NewMemento
End Sub

Public Function Copy() as MyClass
    Dim Result as MyClass
    Set Result = new MyClass
    Result.SetMemento(Memento)
    Set Copy = Result
End Function

Finally I try to call the copy function in another regular module like this
Sub Pruebas()
    Dim Primero As MyClass, segundo As MyClass
    Set Primero = New MyClass
    Set segundo = New MyClass
    Set segundo = Primero.Copy
End Sub

I get the message (below the picture): Error de compilacion: El tipo de agumento de ByRef no coincide
Here is an image (short of 10 points so here is the link): http://i.stack.imgur.com/KPdBR.gif
I was not able to get the message in English, I live in Spain.
Would you be so kind to provide with an example in VBA Excel?, I have been really trying to make this work.
Thanks for your work
===============================================
EDIT: Problem Solved:
The problem was on line "Result.SetMemento(Memento)", in VBA it needed to be called with "Call"
Public Function Copy() As MyClass
    Dim Result As MyClass
    Set Result = New MyClass
    Call Result.SetMemento(Memento)
    Set Copy = Result
End Function

It works great, thanks Scott Whitlock, you are a genius

A:
or do I have to copy the object one member at a time...

Unfortunately yes.
It is possible (but technically very very difficult) to write a COM server in C++ that - using the IDispatch interface - will copy the value of each property, but really this is High Temple programming, if I had to do it, I don't I know if I could do it, but I'd be looking at something like 10 days work ( and I know how COM is implemented in C++, I'd also need to investigate to see if ATL framework has anything to help etc).
I worked with Vb3, 4,5 & 6 for something like 10 years (hands on, 5 days a week) and never found a good way to do this, beyond manually implementing serialisation patterns like Mementos and Save & Store, which really just boiled down to fancy ways of copying each member, one at a time.


text:
Q: Open A pop window in spring i have controller through which it navigate to home.jsp in home .jsp there is two button FindEmployeeByid FindEmployeeByName now as i click on FindEmployeeByid new popup window is opened but in pop window i got this message The requested resource (/EmployeeWebSpring/search/Search.jsp) is not available. ,because in Search.jsp i have use form tag of spring so it does not able to get model object so plz tell how i can perform this to open a pop window with input fields active so that i can submit the data a perform some operation on that data
this is my controller
    package com.nousinfo.tutorial.controllers;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.nousinfo.tutorial.model.EmployeeForm;
import com.nousinfo.tutorial.service.impl.EmployeeServiceImpl;
import com.nousinfo.tutorial.service.model.EmployeeBO;

@Controller
@RequestMapping("/search")
public class SearchEmployeeController {

    private EmployeeServiceImpl employeeServiceImpl;

    public void setEmployeeServiceImpl(EmployeeServiceImpl employeeServiceImpl) {
        this.employeeServiceImpl = employeeServiceImpl;
    }

    @RequestMapping(value = "/searchspring", method = RequestMethod.GET)
    public String view(@Validated EmployeeForm employeeForm)
            throws Exception {
    return "home";
    }

    @RequestMapping(value = "/employeeNo", method = RequestMethod.POST)
    public ModelAndView searchByEmpNo(
            @ModelAttribute("employeeForm") EmployeeForm employeeForm)
            throws Exception {
        ModelAndView model = new ModelAndView();
        model.addObject("employeeForm", employeeForm);
        Long i = Long.parseLong(employeeForm.getEmployeeNumber());

        EmployeeBO employeeBO = employeeServiceImpl.getEmployee(i);
        System.out.println(employeeBO);
        model.addObject("employeeBO", employeeBO);

        model.setViewName("EmployeeDetail");
        return model;
    }

    @RequestMapping(value = "/empByName", method = RequestMethod.POST)
    public ModelAndView searchByEmployeeName(
            @ModelAttribute("employeeForm") EmployeeForm employeeForm) {
        ModelAndView model = new ModelAndView();
        model.addObject("employeeForm", employeeForm);
        List<EmployeeBO> employeeBOs = employeeServiceImpl
                .findEmployees(employeeForm.getFirstName());
        model.addObject("listEmployeeBO", employeeBOs);
        model.setViewName("EmployeeList");
        return model;

    }

    @RequestMapping(value = "/empByDeptId", method = RequestMethod.POST)
    public ModelAndView searchByDeptId(
            @ModelAttribute("employeeForm") EmployeeForm employeeForm) {
        ModelAndView model = new ModelAndView();
        model.addObject("employeeForm", employeeForm);
        List<EmployeeBO> employeeBOs = employeeServiceImpl
                .getAllEmployeeByDeptid(employeeForm.getDepartmentId());
        model.addObject("listEmployeeBO", employeeBOs);
        model.setViewName("EmployeeList");

        return model;

    }

}

this is my home.jsp
  <%@page import="java.util.List"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="css/style.css" type="text/css"></link>
<link rel="stylesheet" href="css/styles.css" type="text/css"></link>
<title>Home</title>

NOUS
                INFOSYSTEMS

        <input id="findid" name="button"
            type="submit" value="Find Employee By Number or ID"
            onClick="LoadById(250,500)" />

        <input id="findname" name="submit2" type="button"
            value="Find Employee By Name" onClick="LoadByName(250,500)" />

        <form id="form2" action="get.spring" method="get">
                <input type="submit" name="submit3" value="Get All Employees" />
            </form>

        <form id="form3" action="CreateEmployee.jsp">
                <input type="submit" name="submit3" value="Create An Employee" />
            </form>

    <form>

                EmployeeNumber
                First Name
                Last Name
                Title
                Address1
                Address2
                City
                Details

            <c:forEach var="employeeBO" items="${model.listEmployeeBO}">

                    ${employeeBO.employeeNumber}

                    ${employeeBO.firstName}

                    ${employeeBO.lastName}

                    ${employeeBO.title}

                    ${employeeBO.address1}

                    ${employeeBO.address2}

                    ${employeeBO.city}

            </c:forEach>

    </form>

and this is my search.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<fmt:setBundle basename="ApplicationResources" />

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Employee Search Page</title>

    <form:form action="/EmployeeWebSpring/search/empByName"  commandName="employeeForm" method="post">

                Employee_ID
                <form:input path="employeeNumber"  />
                <input type="submit" name="method" value="FindById" />

                Employee_Name
                <form:input path="firstName" />
                <input type="submit" name="method" value="FindByName" />

                Employee_Name
                <form:input path="departmentId" />
                <input type="submit" name="method" value="FindByDeptNO" />

                For
                        Searching the employees byEmployee Name
you can use %
                        match all the records with the given pattern

  e.g  for search byEmployeeName

                            matches alL the employees whose name starts with character S

    </form:form>

A: You can do the following in java script and run your java script function as your function run it takes  control to controller ,their you can provide the jsp view or any view

and in controller you have to do something like this which will navigate your request to desired page cause in spring controller decide the navigation of view pages
 @RequestMapping(value = "/searchspring", method = RequestMethod.GET)
    public String view(Model model) throws Exception {
        EmployeeBO employeeBO = new EmployeeBO();
        model.addAttribute("employeeBO", employeeBO);
        return "EmployeeForm";
    }

A: I have solved it in my Spring MVC Project by the following way:
The Controller class is like this:
@RequestMapping(value = "viewPicture.dispatch", method = RequestMethod.GET)
public String viewPicture(HttpServletRequest request, RequestParam(value="fileName")String fileName, @RequestParam(value="filePath")String filePath) {

    //some code..

    return "viewDCPicture";   //the View where it will go.
}

The JSP page on which I have written JS and Html code also, is like this:

        SUPPORTING DOCS.
        <c:forEach items="${attachmentDtlList}" var="data">

                ${data.key}
                <input type="hidden" id="filePath" value="${data.value}">

        </c:forEach>

In my template.xml where the JSP files are mapped with the perticular name = "viewDCPicture", I have made changes like this:
I have created a template inside the template.xml file as:
<definition name = "viewDocTemplate" template = "/viewDoc.jsp">
    <put-attribute name = "body" value = "" />
</definition>

And used it inside the temlate.xml file as:
<definition extends = "viewDocTemplate" name = "viewDCPicture">
    <put-attribute name = "body" value = "/enquiry_management/viewDCPicture.jsp" />
</definition>

The viewDoc.jsp file which will help the Pop-up window file viewDCPicture.jsp to bind it inside body of viewDoc.jsp is as follows:
<%@ page language = "java" contentType = "text/html; charset = UTF-8"
pageEncoding = "UTF-8"%>
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri = "http://tiles.apache.org/tags-tiles" prefix = "tiles"%>
<%@ taglib uri = "http://www.springframework.org/tags" prefix = "spring"%>
<!DOCTYPE html>

<meta charset = "UTF-8">
<title>Insert title here</title>

    <%-- Adding spring attribute for adding body, header, footer etc tag. --%>
    <spring:htmlEscape defaultHtmlEscape = "true" />
    <tiles:insertAttribute name = "body" />

The viewDCPicture.jsp file is like this:

                            <img alt="" src="<%=path%>" border="0" align="top" />