问:
How do I use the setDate() function on a date generated from a cursor?
How do I use the setDate() function on a date generated from a cursor?

I am trying to correctly generate a query that returns a cursor with values between the One day before the expiry date and the expiry date itself.

Find below my code:

```<code>var currentDate = new Date();
var expiryDate;
var dayBeforeExpiry;

var loopThruCollection = buyList.find({});

loopThruCollection.forEach(function (row) {
        console.log (row.expiryDate)
        expiryDate = row.expiryDate;
});

 // expiryDate minus one day, should equal the day before the expiry date.
 dayBeforeExpiry = expiryDate.setDate(expiryDate.getDate() -1);

 if(currentDate == dayBeforeExpiry){
      return buyList.find({ expiryDate : {'$gte': dayBeforeExpiry, '$lte': expiryDate } }).fetch();

      }

 else {
       return buyList.find({ expiryDate : {'$lte': expiryDate}} ).fetch();
      }
</code>```

The results from the code above is:

```<code>Thu Mar 30 2017 16:29:35 GMT+0300 (EAT)
2017-02-22T14:46:33+03:00
2017-03-21T17:17:22+03:00
2017-03-21T17:18:45+03:00
2017-01-30T17:42:21+03:00
2017-02-22T15:10:50+03:00
2017-01-27T21:45:57+03:00

Uncaught TypeError: expiryDate.getDate is not a function(…)
</code>```

I am not sure how I should go about generating the day before variable from the expiryDate.

Kindly point me in the correction.

答:
Based on your output, it looks like not all your expiryDate fields are actually stored as ISODate in mongodb (since they are outputting differently).  If they are not stored as ISODate then they won't get mapped automatically to a Date object in Meteor.  This is most likely why you are getting your .getDate is not a function(…) error.

You can verify this by querying mongodb directly and looking at the stored values for your field.  Check and see if some are being stored as strings vs. ISODate.  I'm betting some are strings and some are ISODate.

Also, you cannot use equality operators (e.g. ==, ===, !=, !==) to compare the value of javascript dates, because that is actually comparing the objects themselves (not their value) and it will always be false.  Per the javascript comparison operators reference docs...

An expression comparing Objects is only true if the operands reference the same Object.

You should compare the value of dates using the .getTime() method instead.

```<code>// won't work...will always return false
if (currentDate == dayBeforeExpiry) {
  // do stuff
}

// correct way
if (currentDate.getTime() == dayBeforeExpiry.getTime()) {
  // do stuff
}
</code>```

However, even this may not do what you are wanting because the comparison is down to the millisecond.  It might make more sense for you to change your logic and compare the year, month, and day only and exclude time altogether.

With that said, I would highly recommend using moment.js in your meteor app to handle all your date logic.  It has built in functions to add/subtract units of time and compare dates.  I deal with dates a lot in my app and I find using it a life saver.

You can install it in your meteor app via npm (meteor npm install moment --save) or as a meteor package (meteor add momentjs:moment).

Body:
How do I use the setDate() function on a date generated from a cursor?

I am trying to correctly generate a query that returns a cursor with values between the One day before the expiry date and the expiry date itself.

Find below my code:

var currentDate = new Date();
var expiryDate;
var dayBeforeExpiry;

var loopThruCollection = buyList.find({});

loopThruCollection.forEach(function (row) {
        console.log (row.expiryDate)
        expiryDate = row.expiryDate;
});

 // expiryDate minus one day, should equal the day before the expiry date.
 dayBeforeExpiry = expiryDate.setDate(expiryDate.getDate() -1);

 if(currentDate == dayBeforeExpiry){
      return buyList.find({ expiryDate : {'$gte': dayBeforeExpiry, '$lte': expiryDate } }).fetch();

      }

 else {
       return buyList.find({ expiryDate : {'$lte': expiryDate}} ).fetch();
      }

The results from the code above is:

Thu Mar 30 2017 16:29:35 GMT+0300 (EAT)
2017-02-22T14:46:33+03:00
2017-03-21T17:17:22+03:00
2017-03-21T17:18:45+03:00
2017-01-30T17:42:21+03:00
2017-02-22T15:10:50+03:00
2017-01-27T21:45:57+03:00

Uncaught TypeError: expiryDate.getDate is not a function(…)

I am not sure how I should go about generating the day before variable from the expiryDate.

Kindly point me in the correction.

Body:
Based on your output, it looks like not all your expiryDate fields are actually stored as ISODate in mongodb (since they are outputting differently).  If they are not stored as ISODate then they won't get mapped automatically to a Date object in Meteor.  This is most likely why you are getting your .getDate is not a function(…) error.

You can verify this by querying mongodb directly and looking at the stored values for your field.  Check and see if some are being stored as strings vs. ISODate.  I'm betting some are strings and some are ISODate.

Also, you cannot use equality operators (e.g. ==, ===, !=, !==) to compare the value of javascript dates, because that is actually comparing the objects themselves (not their value) and it will always be false.  Per the javascript comparison operators reference docs...

An expression comparing Objects is only true if the operands reference the same Object.

You should compare the value of dates using the .getTime() method instead.

// won't work...will always return false
if (currentDate == dayBeforeExpiry) {
  // do stuff
}

// correct way
if (currentDate.getTime() == dayBeforeExpiry.getTime()) {
  // do stuff
}

However, even this may not do what you are wanting because the comparison is down to the millisecond.  It might make more sense for you to change your logic and compare the year, month, and day only and exclude time altogether.

With that said, I would highly recommend using moment.js in your meteor app to handle all your date logic.  It has built in functions to add/subtract units of time and compare dates.  I deal with dates a lot in my app and I find using it a life saver.

You can install it in your meteor app via npm (meteor npm install moment --save) or as a meteor package (meteor add momentjs:moment).


来源: stackexchange

问:
Is it better to replace an image src with JS, or to use CSS filters to manipulate it?
I have a button with an icon, whose source is an SVG of ~4kb. When I hover over the button, I want the icon to invert in color, changing from black to white. To achieve this effect, is it better to use CSS like so: </p>

```<code>#btn:hover #icon-img {
    -webkit-filter: invert(1);
    filter: invert(1);
}
</code>```

<p>...or is it better (e.g. faster/best practice/better for memory) to manipulate the image source directly and add a white version of the icon like so?</p>

```<code>document.getElementById('btn').addEventListener('mouseover', (e) => {
    document.getElementById('icon-img').src = 'white-image.svg';
}
</code>```

答:
As a rule of thumb, CSS solutions are a better approach that JS-based ones.

The main problem with CSS (specially regarding new fancy features) is support:

Browser support for filter property (MDN)

As you can see, you are out of luck if you want to support IE (althought Internet Explorer 4.0 to 9.0 implemented a non-standard and deprecated filter property).

As @guest271314 has pointed out, your JS solution will trigger a new request to the server... you could consider using sprites or data URIs to avoid it.

ContentLicense: CC BY-SA 3.0

Body:
I have a button with an icon, whose source is an SVG of ~4kb. When I hover over the button, I want the icon to invert in color, changing from black to white. To achieve this effect, is it better to use CSS like so:

#btn:hover #icon-img {
    -webkit-filter: invert(1);
    filter: invert(1);
}

...or is it better (e.g. faster/best practice/better for memory) to manipulate the image source directly and add a white version of the icon like so?

document.getElementById('btn').addEventListener('mouseover', (e) => {
    document.getElementById('icon-img').src = 'white-image.svg';
}


问:
wordpress, mulitsite missing wp_options table
I have one strange request here, one of my client's WordPress multi-site environment site needs to migrate to another server and change domain name but when I checked the database the main wp-options table does not exist there.

And am I not able to do migration of this setup getting blank page

Can anyone suggest on this?

答:
Impossible (Table most probably deleted or you don't't see it)

define WP_DEBUG as true, WP_DEBUG_LOG or WP_DEBUG_SHOW (on your choice) to see what's happening.


问:
Unresolved external symbol ___chkstk_ms and _gfortran* when installing HashPy in Windows via conda
I installed HashPy via conda (https://github.com/markcwill/hashpy) in Python 2.7. Before that I already installed gfortran - which is the requirement- from gcc-fortran package in Cygwin, following this instruction  Fortran sources but no Fortran compiler found. But then I encountered problem:

```<code>(obspy) C:\Users\dell>pip install https://github.com/markcwill/hashpy/archive/ma
ster.zip
Collecting https://github.com/markcwill/hashpy/archive/master.zip
  Downloading https://github.com/markcwill/hashpy/archive/master.zip
     / 1.2MB 93kB/s
Installing collected packages: HASHpy
  Running setup.py install for HASHpy ... error
    Complete output from command C:\Users\dell\Anaconda2\envs\obspy\python.exe -
u -c "import setuptools, tokenize;__file__='c:\\users\\dell\\appdata\\local\\tem
p\\pip-enmsua-build\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=
f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))"
install --record c:\users\dell\appdata\local\temp\pip-acc7xy-record\install-reco
rd.txt --single-version-externally-managed --compile:
    running install
    running build
    running config_cc
    unifing config_cc, config, build_clib, build_ext, build commands --compiler
options
    running config_fc
    unifing config_fc, config, build_clib, build_ext, build commands --fcompiler
 options
    running build_src
    build_src
    building extension "hashpy.libhashpy" sources
    f2py options: []
      adding 'build\src.win-amd64-2.7\fortranobject.c' to sources.
      adding 'build\src.win-amd64-2.7' to include_dirs.
      adding 'build\src.win-amd64-2.7\hashpy\libhashpy-f2pywrappers.f' to source
s.
    build_src: building npy-pkg config files
    running build_py
    creating build\lib.win-amd64-2.7
    creating build\lib.win-amd64-2.7\hashpy
    copying hashpy\doublecouple.py -> build\lib.win-amd64-2.7\hashpy
    copying hashpy\hashpype.py -> build\lib.win-amd64-2.7\hashpy
    copying hashpy\__init__.py -> build\lib.win-amd64-2.7\hashpy
    creating build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\antelopeIO.py -> build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\core.py -> build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\fpfitIO.py -> build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\obspyIO.py -> build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\__init__.py -> build\lib.win-amd64-2.7\hashpy\io
    creating build\lib.win-amd64-2.7\hashpy\plotting
    copying hashpy\plotting\focalmechplotter.py -> build\lib.win-amd64-2.7\hashp
y\plotting
    copying hashpy\plotting\__init__.py -> build\lib.win-amd64-2.7\hashpy\plotti
ng
    creating build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\param.inc -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\rot.inc -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\vel.inc -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\Makefile -> build\lib.win-amd64-2.7\hashpy\src
    creating build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\dbhash.pf -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.kds -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.kds_orig -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.lab1 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.north -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.pickema1 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.pickema2 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.pickema3 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.sgm1 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.socal -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.vb1 -> build\lib.win-amd64-2.7\hashpy\data
    creating build\lib.win-amd64-2.7\hashpy\scripts
    copying hashpy\scripts\dbhash -> build\lib.win-amd64-2.7\hashpy\scripts
    copying hashpy\scripts\hash_driver2.py -> build\lib.win-amd64-2.7\hashpy\scr
ipts
    copying hashpy\scripts\hash_utils.py -> build\lib.win-amd64-2.7\hashpy\scrip
ts
    copying hashpy\scripts\__init__.py -> build\lib.win-amd64-2.7\hashpy\scripts

    copying hashpy\src\fmamp_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\fmech_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\pol_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\station_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\station_subs_5char.f -> build\lib.win-amd64-2.7\hashpy\sr
c
    copying hashpy\src\uncert_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\util_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\vel_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\vel_subs2.f -> build\lib.win-amd64-2.7\hashpy\src
    running build_ext
    customize MSVCCompiler
    customize MSVCCompiler using build_ext
    customize GnuFCompiler
    Could not locate executable g77
    Could not locate executable f77
    customize IntelVisualFCompiler
    Could not locate executable ifort
    Could not locate executable ifl
    customize AbsoftFCompiler
    Could not locate executable f90
    customize CompaqVisualFCompiler
    Found executable C:\cygwin64\bin\DF.exe
    Found executable C:\cygwin64\bin\DF.exe
    customize IntelItaniumVisualFCompiler
    Could not locate executable efl
    customize Gnu95FCompiler
    Found executable C:\cygwin64\bin\gfortran.exe
    Found executable C:\cygwin64\bin\gfortran.exe
    customize Gnu95FCompiler
    customize Gnu95FCompiler using build_ext
    building 'hashpy.libhashpy' extension
    compiling C sources
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    creating build\temp.win-amd64-2.7\Release\build
    creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\hashpy
    C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\
9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd
64-2.7 -IC:\Users\dell\Anaconda2\envs\obspy\lib\site-packages\numpy\core\include
 -IC:\Users\dell\Anaconda2\envs\obspy\include -IC:\Users\dell\Anaconda2\envs\obs
py\PC /Tcbuild\src.win-amd64-2.7\hashpy\libhashpymodule.c /Fobuild\temp.win-amd6
4-2.7\Release\build\src.win-amd64-2.7\hashpy\libhashpymodule.obj
    Found executable C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visua
l C++ for Python\9.0\VC\Bin\amd64\cl.exe
    C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\
9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd
64-2.7 -IC:\Users\dell\Anaconda2\envs\obspy\lib\site-packages\numpy\core\include
 -IC:\Users\dell\Anaconda2\envs\obspy\include -IC:\Users\dell\Anaconda2\envs\obs
py\PC /Tcbuild\src.win-amd64-2.7\fortranobject.c /Fobuild\temp.win-amd64-2.7\Rel
ease\build\src.win-amd64-2.7\fortranobject.obj
    compiling Fortran sources
    Fortran f77 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fn
o-second-underscore -O0
    Fortran f90 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -fno-second-unde
rscore -O0
    Fortran fix compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fn
o-second-underscore -Wall -g -fno-second-underscore -O0
    creating build\temp.win-amd64-2.7\Release\hashpy
    creating build\temp.win-amd64-2.7\Release\hashpy\src
    compile options: '-Ibuild\src.win-amd64-2.7 -IC:\Users\dell\Anaconda2\envs\o
bspy\lib\site-packages\numpy\core\include -IC:\Users\dell\Anaconda2\envs\obspy\i
nclude -IC:\Users\dell\Anaconda2\envs\obspy\PC -c'
    gfortran.exe:f77: hashpy\src\fmamp_subs.f
    gfortran.exe:f77: hashpy\src\fmech_subs.f
    gfortran.exe:f77: hashpy\src\uncert_subs.f
    gfortran.exe:f77: hashpy\src\util_subs.f
    gfortran.exe:f77: hashpy\src\pol_subs.f
    gfortran.exe:f77: hashpy\src\vel_subs.f
    gfortran.exe:f77: hashpy\src\station_subs.f
    gfortran.exe:f77: hashpy\src\vel_subs2.f
    gfortran.exe:f77: build\src.win-amd64-2.7\hashpy\libhashpy-f2pywrappers.f
    Found executable C:\cygwin64\bin\cygpath.exe
    C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\
9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\cygwin64\lib\
gcc\x86_64-pc-cygwin\5.4.0 /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\libs /LIB
PATH:C:\Users\dell\Anaconda2\envs\obspy\PCbuild\amd64 /LIBPATH:C:\Users\dell\Ana
conda2\envs\obspy\PC\VS9.0\amd64 /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\lib
s /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\PCbuild\amd64 /LIBPATH:C:\Users\de
ll\Anaconda2\envs\obspy\PC\VS9.0\amd64 /EXPORT:initlibhashpy build\temp.win-amd6
4-2.7\Release\build\src.win-amd64-2.7\hashpy\libhashpymodule.obj build\temp.win-
amd64-2.7\Release\build\src.win-amd64-2.7\fortranobject.obj build\temp.win-amd64
-2.7\Release\hashpy\src\fmamp_subs.o build\temp.win-amd64-2.7\Release\hashpy\src
\fmech_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\uncert_subs.o build\te
mp.win-amd64-2.7\Release\hashpy\src\util_subs.o build\temp.win-amd64-2.7\Release
\hashpy\src\pol_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\vel_subs.o bu
ild\temp.win-amd64-2.7\Release\hashpy\src\station_subs.o build\temp.win-amd64-2.
7\Release\hashpy\src\vel_subs2.o build\temp.win-amd64-2.7\Release\build\src.win-
amd64-2.7\hashpy\libhashpy-f2pywrappers.o /OUT:build\lib.win-amd64-2.7\hashpy\li
bhashpy.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\has
hpy\libhashpy.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\build\src.win-a
md64-2.7\hashpy\libhashpy.pyd.manifest
    Found executable C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visua
l C++ for Python\9.0\VC\Bin\amd64\link.exe
    libhashpymodule.obj : warning LNK4197: export 'initlibhashpy' specified mult
iple times; using first specification
       Creating library build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7
\hashpy\libhashpy.lib and object build\temp.win-amd64-2.7\Release\build\src.win-
amd64-2.7\hashpy\libhashpy.exp
    vel_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    vel_subs2.o : error LNK2019: unresolved external symbol ___chkstk_ms referen
ced in function mk_table_add_
    fmamp_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    fmech_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    uncert_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    pol_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    fmamp_subs.o : error LNK2019: unresolved external symbol lroundf referenced
in function focalamp_mc_
    fmech_subs.o : error LNK2001: unresolved external symbol lroundf
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_writ
e
    vel_subs2.o : error LNK2019: unresolved external symbol _gfortran_st_write r
eferenced in function mk_table_add_
    fmamp_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write
    fmech_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write
    pol_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write
    vel_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_transfe
r_character_write
    vel_subs2.o : error LNK2019: unresolved external symbol _gfortran_transfer_c
haracter_write referenced in function mk_table_add_
    fmamp_subs.o : error LNK2001: unresolved external symbol _gfortran_transfer_
character_write
    fmech_subs.o : error LNK2001: unresolved external symbol _gfortran_transfer_
character_write
    pol_subs.o : error LNK2001: unresolved external symbol _gfortran_transfer_ch
aracter_write
    vel_subs.o : error LNK2001: unresolved external symbol _gfortran_transfer_ch
aracter_write
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_writ
e_done
    vel_subs2.o : error LNK2019: unresolved external symbol _gfortran_st_write_d
one referenced in function mk_table_add_
    fmamp_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write_
done
    fmech_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write_
done
    pol_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write_do
ne
    vel_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write_do
ne
    fmamp_subs.o : error LNK2019: unresolved external symbol _gfortran_rand refe
renced in function focalamp_mc_
    fmech_subs.o : error LNK2001: unresolved external symbol _gfortran_rand
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_in
teger_write referenced in function mk_table_
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_st_read ref
erenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_read

    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_st_read
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_in
teger referenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_transfe
r_integer
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_st_read_don
e referenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_read
_done
    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_st_read_do
ne
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_ch
aracter referenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_transfe
r_character
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_st_open ref
erenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_open

    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_st_open
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_re
al referenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_transfe
r_real
    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_transfer_r
eal
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_st_close re
ferenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_clos
e
    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_st_close
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_re
al_write referenced in function get_tts_
    build\lib.win-amd64-2.7\hashpy\libhashpy.pyd : fatal error LNK1120: 15 unres
olved externals
    error: Command "C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visual
 C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:
C:\cygwin64\lib\gcc\x86_64-pc-cygwin\5.4.0 /LIBPATH:C:\Users\dell\Anaconda2\envs
\obspy\libs /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\PCbuild\amd64 /LIBPATH:C
:\Users\dell\Anaconda2\envs\obspy\PC\VS9.0\amd64 /LIBPATH:C:\Users\dell\Anaconda
2\envs\obspy\libs /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\PCbuild\amd64 /LIB
PATH:C:\Users\dell\Anaconda2\envs\obspy\PC\VS9.0\amd64 /EXPORT:initlibhashpy bui
ld\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\hashpy\libhashpymodule.obj
 build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\fortranobject.obj buil
d\temp.win-amd64-2.7\Release\hashpy\src\fmamp_subs.o build\temp.win-amd64-2.7\Re
lease\hashpy\src\fmech_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\uncert
_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\util_subs.o build\temp.win-a
md64-2.7\Release\hashpy\src\pol_subs.o build\temp.win-amd64-2.7\Release\hashpy\s
rc\vel_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\station_subs.o build\t
emp.win-amd64-2.7\Release\hashpy\src\vel_subs2.o build\temp.win-amd64-2.7\Releas
e\build\src.win-amd64-2.7\hashpy\libhashpy-f2pywrappers.o /OUT:build\lib.win-amd
64-2.7\hashpy\libhashpy.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\build\src.w
in-amd64-2.7\hashpy\libhashpy.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release
\build\src.win-amd64-2.7\hashpy\libhashpy.pyd.manifest" failed with exit status
1120

    ----------------------------------------
Command "C:\Users\dell\Anaconda2\envs\obspy\python.exe -u -c "import setuptools,
 tokenize;__file__='c:\\users\\dell\\appdata\\local\\temp\\pip-enmsua-build\\set
up.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n',
 '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\user
s\dell\appdata\local\temp\pip-acc7xy-record\install-record.txt --single-version-
externally-managed --compile" failed with error code 1 in c:\users\dell\appdata\
local\temp\pip-enmsua-build\
</code>```

I'm new in coding, and don't understand the root cause of the problem. What should I do?

答: You should post your problems as a ticket at HashPy issue tracker: https://github.com/markcwill/hashpy/issues</p>

Body:
I installed HashPy via conda (https://github.com/markcwill/hashpy) in Python 2.7. Before that I already installed gfortran - which is the requirement- from gcc-fortran package in Cygwin, following this instruction  Fortran sources but no Fortran compiler found. But then I encountered problem:

(obspy) C:\Users\dell>pip install https://github.com/markcwill/hashpy/archive/ma
ster.zip
Collecting https://github.com/markcwill/hashpy/archive/master.zip
  Downloading https://github.com/markcwill/hashpy/archive/master.zip
     / 1.2MB 93kB/s
Installing collected packages: HASHpy
  Running setup.py install for HASHpy ... error
    Complete output from command C:\Users\dell\Anaconda2\envs\obspy\python.exe -
u -c "import setuptools, tokenize;__file__='c:\\users\\dell\\appdata\\local\\tem
p\\pip-enmsua-build\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=
f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))"
install --record c:\users\dell\appdata\local\temp\pip-acc7xy-record\install-reco
rd.txt --single-version-externally-managed --compile:
    running install
    running build
    running config_cc
    unifing config_cc, config, build_clib, build_ext, build commands --compiler
options
    running config_fc
    unifing config_fc, config, build_clib, build_ext, build commands --fcompiler
 options
    running build_src
    build_src
    building extension "hashpy.libhashpy" sources
    f2py options: []
      adding 'build\src.win-amd64-2.7\fortranobject.c' to sources.
      adding 'build\src.win-amd64-2.7' to include_dirs.
      adding 'build\src.win-amd64-2.7\hashpy\libhashpy-f2pywrappers.f' to source
s.
    build_src: building npy-pkg config files
    running build_py
    creating build\lib.win-amd64-2.7
    creating build\lib.win-amd64-2.7\hashpy
    copying hashpy\doublecouple.py -> build\lib.win-amd64-2.7\hashpy
    copying hashpy\hashpype.py -> build\lib.win-amd64-2.7\hashpy
    copying hashpy\__init__.py -> build\lib.win-amd64-2.7\hashpy
    creating build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\antelopeIO.py -> build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\core.py -> build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\fpfitIO.py -> build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\obspyIO.py -> build\lib.win-amd64-2.7\hashpy\io
    copying hashpy\io\__init__.py -> build\lib.win-amd64-2.7\hashpy\io
    creating build\lib.win-amd64-2.7\hashpy\plotting
    copying hashpy\plotting\focalmechplotter.py -> build\lib.win-amd64-2.7\hashp
y\plotting
    copying hashpy\plotting\__init__.py -> build\lib.win-amd64-2.7\hashpy\plotti
ng
    creating build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\param.inc -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\rot.inc -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\vel.inc -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\Makefile -> build\lib.win-amd64-2.7\hashpy\src
    creating build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\dbhash.pf -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.kds -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.kds_orig -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.lab1 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.north -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.pickema1 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.pickema2 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.pickema3 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.sgm1 -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.socal -> build\lib.win-amd64-2.7\hashpy\data
    copying hashpy\data\vz.vb1 -> build\lib.win-amd64-2.7\hashpy\data
    creating build\lib.win-amd64-2.7\hashpy\scripts
    copying hashpy\scripts\dbhash -> build\lib.win-amd64-2.7\hashpy\scripts
    copying hashpy\scripts\hash_driver2.py -> build\lib.win-amd64-2.7\hashpy\scr
ipts
    copying hashpy\scripts\hash_utils.py -> build\lib.win-amd64-2.7\hashpy\scrip
ts
    copying hashpy\scripts\__init__.py -> build\lib.win-amd64-2.7\hashpy\scripts

    copying hashpy\src\fmamp_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\fmech_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\pol_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\station_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\station_subs_5char.f -> build\lib.win-amd64-2.7\hashpy\sr
c
    copying hashpy\src\uncert_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\util_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\vel_subs.f -> build\lib.win-amd64-2.7\hashpy\src
    copying hashpy\src\vel_subs2.f -> build\lib.win-amd64-2.7\hashpy\src
    running build_ext
    customize MSVCCompiler
    customize MSVCCompiler using build_ext
    customize GnuFCompiler
    Could not locate executable g77
    Could not locate executable f77
    customize IntelVisualFCompiler
    Could not locate executable ifort
    Could not locate executable ifl
    customize AbsoftFCompiler
    Could not locate executable f90
    customize CompaqVisualFCompiler
    Found executable C:\cygwin64\bin\DF.exe
    Found executable C:\cygwin64\bin\DF.exe
    customize IntelItaniumVisualFCompiler
    Could not locate executable efl
    customize Gnu95FCompiler
    Found executable C:\cygwin64\bin\gfortran.exe
    Found executable C:\cygwin64\bin\gfortran.exe
    customize Gnu95FCompiler
    customize Gnu95FCompiler using build_ext
    building 'hashpy.libhashpy' extension
    compiling C sources
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    creating build\temp.win-amd64-2.7\Release\build
    creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\hashpy
    C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\
9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd
64-2.7 -IC:\Users\dell\Anaconda2\envs\obspy\lib\site-packages\numpy\core\include
 -IC:\Users\dell\Anaconda2\envs\obspy\include -IC:\Users\dell\Anaconda2\envs\obs
py\PC /Tcbuild\src.win-amd64-2.7\hashpy\libhashpymodule.c /Fobuild\temp.win-amd6
4-2.7\Release\build\src.win-amd64-2.7\hashpy\libhashpymodule.obj
    Found executable C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visua
l C++ for Python\9.0\VC\Bin\amd64\cl.exe
    C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\
9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd
64-2.7 -IC:\Users\dell\Anaconda2\envs\obspy\lib\site-packages\numpy\core\include
 -IC:\Users\dell\Anaconda2\envs\obspy\include -IC:\Users\dell\Anaconda2\envs\obs
py\PC /Tcbuild\src.win-amd64-2.7\fortranobject.c /Fobuild\temp.win-amd64-2.7\Rel
ease\build\src.win-amd64-2.7\fortranobject.obj
    compiling Fortran sources
    Fortran f77 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fn
o-second-underscore -O0
    Fortran f90 compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -fno-second-unde
rscore -O0
    Fortran fix compiler: C:\cygwin64\bin\gfortran.exe -Wall -g -ffixed-form -fn
o-second-underscore -Wall -g -fno-second-underscore -O0
    creating build\temp.win-amd64-2.7\Release\hashpy
    creating build\temp.win-amd64-2.7\Release\hashpy\src
    compile options: '-Ibuild\src.win-amd64-2.7 -IC:\Users\dell\Anaconda2\envs\o
bspy\lib\site-packages\numpy\core\include -IC:\Users\dell\Anaconda2\envs\obspy\i
nclude -IC:\Users\dell\Anaconda2\envs\obspy\PC -c'
    gfortran.exe:f77: hashpy\src\fmamp_subs.f
    gfortran.exe:f77: hashpy\src\fmech_subs.f
    gfortran.exe:f77: hashpy\src\uncert_subs.f
    gfortran.exe:f77: hashpy\src\util_subs.f
    gfortran.exe:f77: hashpy\src\pol_subs.f
    gfortran.exe:f77: hashpy\src\vel_subs.f
    gfortran.exe:f77: hashpy\src\station_subs.f
    gfortran.exe:f77: hashpy\src\vel_subs2.f
    gfortran.exe:f77: build\src.win-amd64-2.7\hashpy\libhashpy-f2pywrappers.f
    Found executable C:\cygwin64\bin\cygpath.exe
    C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\
9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\cygwin64\lib\
gcc\x86_64-pc-cygwin\5.4.0 /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\libs /LIB
PATH:C:\Users\dell\Anaconda2\envs\obspy\PCbuild\amd64 /LIBPATH:C:\Users\dell\Ana
conda2\envs\obspy\PC\VS9.0\amd64 /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\lib
s /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\PCbuild\amd64 /LIBPATH:C:\Users\de
ll\Anaconda2\envs\obspy\PC\VS9.0\amd64 /EXPORT:initlibhashpy build\temp.win-amd6
4-2.7\Release\build\src.win-amd64-2.7\hashpy\libhashpymodule.obj build\temp.win-
amd64-2.7\Release\build\src.win-amd64-2.7\fortranobject.obj build\temp.win-amd64
-2.7\Release\hashpy\src\fmamp_subs.o build\temp.win-amd64-2.7\Release\hashpy\src
\fmech_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\uncert_subs.o build\te
mp.win-amd64-2.7\Release\hashpy\src\util_subs.o build\temp.win-amd64-2.7\Release
\hashpy\src\pol_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\vel_subs.o bu
ild\temp.win-amd64-2.7\Release\hashpy\src\station_subs.o build\temp.win-amd64-2.
7\Release\hashpy\src\vel_subs2.o build\temp.win-amd64-2.7\Release\build\src.win-
amd64-2.7\hashpy\libhashpy-f2pywrappers.o /OUT:build\lib.win-amd64-2.7\hashpy\li
bhashpy.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\has
hpy\libhashpy.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\build\src.win-a
md64-2.7\hashpy\libhashpy.pyd.manifest
    Found executable C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visua
l C++ for Python\9.0\VC\Bin\amd64\link.exe
    libhashpymodule.obj : warning LNK4197: export 'initlibhashpy' specified mult
iple times; using first specification
       Creating library build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7
\hashpy\libhashpy.lib and object build\temp.win-amd64-2.7\Release\build\src.win-
amd64-2.7\hashpy\libhashpy.exp
    vel_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    vel_subs2.o : error LNK2019: unresolved external symbol ___chkstk_ms referen
ced in function mk_table_add_
    fmamp_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    fmech_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    uncert_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    pol_subs.o : error LNK2001: unresolved external symbol ___chkstk_ms
    fmamp_subs.o : error LNK2019: unresolved external symbol lroundf referenced
in function focalamp_mc_
    fmech_subs.o : error LNK2001: unresolved external symbol lroundf
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_writ
e
    vel_subs2.o : error LNK2019: unresolved external symbol _gfortran_st_write r
eferenced in function mk_table_add_
    fmamp_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write
    fmech_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write
    pol_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write
    vel_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_transfe
r_character_write
    vel_subs2.o : error LNK2019: unresolved external symbol _gfortran_transfer_c
haracter_write referenced in function mk_table_add_
    fmamp_subs.o : error LNK2001: unresolved external symbol _gfortran_transfer_
character_write
    fmech_subs.o : error LNK2001: unresolved external symbol _gfortran_transfer_
character_write
    pol_subs.o : error LNK2001: unresolved external symbol _gfortran_transfer_ch
aracter_write
    vel_subs.o : error LNK2001: unresolved external symbol _gfortran_transfer_ch
aracter_write
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_writ
e_done
    vel_subs2.o : error LNK2019: unresolved external symbol _gfortran_st_write_d
one referenced in function mk_table_add_
    fmamp_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write_
done
    fmech_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write_
done
    pol_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write_do
ne
    vel_subs.o : error LNK2001: unresolved external symbol _gfortran_st_write_do
ne
    fmamp_subs.o : error LNK2019: unresolved external symbol _gfortran_rand refe
renced in function focalamp_mc_
    fmech_subs.o : error LNK2001: unresolved external symbol _gfortran_rand
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_in
teger_write referenced in function mk_table_
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_st_read ref
erenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_read

    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_st_read
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_in
teger referenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_transfe
r_integer
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_st_read_don
e referenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_read
_done
    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_st_read_do
ne
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_ch
aracter referenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_transfe
r_character
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_st_open ref
erenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_open

    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_st_open
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_re
al referenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_transfe
r_real
    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_transfer_r
eal
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_st_close re
ferenced in function mk_table_
    station_subs.o : error LNK2001: unresolved external symbol _gfortran_st_clos
e
    vel_subs2.o : error LNK2001: unresolved external symbol _gfortran_st_close
    vel_subs.o : error LNK2019: unresolved external symbol _gfortran_transfer_re
al_write referenced in function get_tts_
    build\lib.win-amd64-2.7\hashpy\libhashpy.pyd : fatal error LNK1120: 15 unres
olved externals
    error: Command "C:\Users\dell\AppData\Local\Programs\Common\Microsoft\Visual
 C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:
C:\cygwin64\lib\gcc\x86_64-pc-cygwin\5.4.0 /LIBPATH:C:\Users\dell\Anaconda2\envs
\obspy\libs /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\PCbuild\amd64 /LIBPATH:C
:\Users\dell\Anaconda2\envs\obspy\PC\VS9.0\amd64 /LIBPATH:C:\Users\dell\Anaconda
2\envs\obspy\libs /LIBPATH:C:\Users\dell\Anaconda2\envs\obspy\PCbuild\amd64 /LIB
PATH:C:\Users\dell\Anaconda2\envs\obspy\PC\VS9.0\amd64 /EXPORT:initlibhashpy bui
ld\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\hashpy\libhashpymodule.obj
 build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\fortranobject.obj buil
d\temp.win-amd64-2.7\Release\hashpy\src\fmamp_subs.o build\temp.win-amd64-2.7\Re
lease\hashpy\src\fmech_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\uncert
_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\util_subs.o build\temp.win-a
md64-2.7\Release\hashpy\src\pol_subs.o build\temp.win-amd64-2.7\Release\hashpy\s
rc\vel_subs.o build\temp.win-amd64-2.7\Release\hashpy\src\station_subs.o build\t
emp.win-amd64-2.7\Release\hashpy\src\vel_subs2.o build\temp.win-amd64-2.7\Releas
e\build\src.win-amd64-2.7\hashpy\libhashpy-f2pywrappers.o /OUT:build\lib.win-amd
64-2.7\hashpy\libhashpy.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\build\src.w
in-amd64-2.7\hashpy\libhashpy.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release
\build\src.win-amd64-2.7\hashpy\libhashpy.pyd.manifest" failed with exit status
1120

    ----------------------------------------
Command "C:\Users\dell\Anaconda2\envs\obspy\python.exe -u -c "import setuptools,
 tokenize;__file__='c:\\users\\dell\\appdata\\local\\temp\\pip-enmsua-build\\set
up.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n',
 '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\user
s\dell\appdata\local\temp\pip-acc7xy-record\install-record.txt --single-version-
externally-managed --compile" failed with error code 1 in c:\users\dell\appdata\
local\temp\pip-enmsua-build\

I'm new in coding, and don't understand the root cause of the problem. What should I do?


问:
C++ behaviour when const
Here's a basic struct (I hope)

```<code>struct SomeType {
    float a;
    float b;
    float c;
    float d;

    SomeType(float, float, float, float);
};
</code>```

And source

```<code>SomeType::SomeType(float na, float nb, float nc, float nd) : a(na), b(nb), c(nc), d(nd) {}
</code>```

The I have a class

```<code>struct SomeClass {
    static const SomeType v;

    SomeClass();
};
</code>```

When I then initialise it

```<code>const SomeType SomeClass::v(0,0,0,0);
</code>```

My vales become inf or nan or -nan. Anyone seen this before, or know how to fix it?

Edit: Fixed type

Edit: This is quite close to my original example. I multiple classes with similar structure to SomeClass.

答:
Since SomeType  SomeClass::v is static do you really need to explicitly initialize the members of SomeType to zero?

You can avoid the initializing Ctor of SomeType if you are only using it for initializing the members of SomeType to zero (otherwise define the default Ctor SomeType) and just initialize the static member as const SomeType SomeClass::v;.

ContentLicense: CC BY-SA 2.5

Title: C++ behaviour when const

Body:
Here's a basic struct (I hope)

struct SomeType {
    float a;
    float b;
    float c;
    float d;

    SomeType(float, float, float, float);
};

And source

SomeType::SomeType(float na, float nb, float nc, float nd) : a(na), b(nb), c(nc), d(nd) {}

The I have a class

struct SomeClass {
    static const SomeType v;

    SomeClass();
};

When I then initialise it

const SomeType SomeClass::v(0,0,0,0);

My vales become inf or nan or -nan. Anyone seen this before, or know how to fix it?

Edit: Fixed type

Edit: This is quite close to my original example. I multiple classes with similar structure to SomeClass.


问:
Java HtmlUnit Memory Leak
I got the following code:

```<code>for (int i = 0; i < list.size(); i++) {
    navigate(list.get(i));
}
</code>```

And for the navigate method:

```<code>HtmlTextInput txtInput = page.getElementByName("input");
txtInput.setValueAttribute("random");

HtmlSubmitInput btnNext = page.getHtmlElementById("btn_next");
page = btnNext.click();

HtmlSubmitInput btnConfirm = page.getElementByName("submit");
page = btnConfirm.click();

System.out.println("before: " + webClient.getWebWindows().size());
page.cleanUp();
page.deregisterFramesIfNeeded();
System.out.println("after: " + webClient.getWebWindows().size());

return true;
</code>```

HtmlPage and WebClient have been declared globally.

To put it in perspective, I fill in a form, press OK, press Confirm and I got redirected to my initial page so I repeat the process. The problem is that my application is eating up all the memory. And later on this will throw a heap exception.

If I count the web windows I see that number growing and never decreasing. A lot of other topic about this memory leak suggests that I have to call the .CloseAllWindows() method but this feature has been removed.

Currently I am using HtmlUnit 2.25.

Did I make a mistake while redirecting so that older windows stay in the background?

UPDATED VERSION:

Creation of a new WebClient method:

```<code>private WebClient createNewWebClient(){
        WebClient webClient = new WebClient(BrowserVersion.FIREFOX_45);

        // no exceptions
        webClient.getOptions().setThrowExceptionOnScriptError(false);
        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
        // other settings
        webClient.getOptions().setJavaScriptEnabled(true);
        webClient.getOptions().setCssEnabled(false);
        webClient.getOptions().setRedirectEnabled(true);
        webClient.getOptions().setThrowExceptionOnScriptError(false);
        webClient.getOptions().setTimeout(300000);

        // enable sessions
        webClient.getCookieManager().setCookiesEnabled(true);

        // Set session if any
        if (cookieManager == null){
            cookieManager = new CookieManager();
        } else {
            webClient.setCookieManager(cookieManager);
        }
        return webClient;
    }
</code>```

Loop stayed the same. Navigate method:

```<code>     try (WebClient webClient = createNewWebClient()) {
                HtmlPage page = webClient.getPage("URL");
                HtmlTextInput txtInput = page.getElementByName("input");
                txtInput.setValueAttribute("random");

                HtmlSubmitInput btnNext = page.getHtmlElementById("btn_next");
                page = btnNext.click();

                HtmlSubmitInput btnConfirm = page.getElementByName("submit");
                page = btnConfirm.click();

             ...
       }
</code>```

Memory is still increasing with every method call.

答:
You need to call webClient.close(), or simply put it in try-with-resources, for example:

```<code>try (WebClient webClient = new WebClient()) {
    String url = "http://localhost:8080";
    HtmlPage page = webClient.getPage(url);

    // do something
}
</code>```

Update :

You can store the CookieManager of webClient.getCookieManager() and use it for other WebClients.

Title: Java HtmlUnit Memory Leak

Body:
I got the following code:

for (int i = 0; i < list.size(); i++) {
    navigate(list.get(i));
}

And for the navigate method:

HtmlTextInput txtInput = page.getElementByName("input");
txtInput.setValueAttribute("random");

HtmlSubmitInput btnNext = page.getHtmlElementById("btn_next");
page = btnNext.click();

HtmlSubmitInput btnConfirm = page.getElementByName("submit");
page = btnConfirm.click();

System.out.println("before: " + webClient.getWebWindows().size());
page.cleanUp();
page.deregisterFramesIfNeeded();
System.out.println("after: " + webClient.getWebWindows().size());

return true;

HtmlPage and WebClient have been declared globally.

To put it in perspective, I fill in a form, press OK, press Confirm and I got redirected to my initial page so I repeat the process. The problem is that my application is eating up all the memory. And later on this will throw a heap exception.

If I count the web windows I see that number growing and never decreasing. A lot of other topic about this memory leak suggests that I have to call the .CloseAllWindows() method but this feature has been removed.

Currently I am using HtmlUnit 2.25.

Did I make a mistake while redirecting so that older windows stay in the background?

UPDATED VERSION:

Creation of a new WebClient method:

private WebClient createNewWebClient(){
        WebClient webClient = new WebClient(BrowserVersion.FIREFOX_45);

        // no exceptions
        webClient.getOptions().setThrowExceptionOnScriptError(false);
        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
        // other settings
        webClient.getOptions().setJavaScriptEnabled(true);
        webClient.getOptions().setCssEnabled(false);
        webClient.getOptions().setRedirectEnabled(true);
        webClient.getOptions().setThrowExceptionOnScriptError(false);
        webClient.getOptions().setTimeout(300000);

        // enable sessions
        webClient.getCookieManager().setCookiesEnabled(true);

        // Set session if any
        if (cookieManager == null){
            cookieManager = new CookieManager();
        } else {
            webClient.setCookieManager(cookieManager);
        }
        return webClient;
    }

Loop stayed the same. Navigate method:

     try (WebClient webClient = createNewWebClient()) {
                HtmlPage page = webClient.getPage("URL");
                HtmlTextInput txtInput = page.getElementByName("input");
                txtInput.setValueAttribute("random");

                HtmlSubmitInput btnNext = page.getHtmlElementById("btn_next");
                page = btnNext.click();

                HtmlSubmitInput btnConfirm = page.getElementByName("submit");
                page = btnConfirm.click();

             ...
       }

Memory is still increasing with every method call.

Body:
You need to call webClient.close(), or simply put it in try-with-resources, for example:

try (WebClient webClient = new WebClient()) {
    String url = "http://localhost:8080";
    HtmlPage page = webClient.getPage(url);

    // do something
}

Update :

You can store the CookieManager of webClient.getCookieManager() and use it for other WebClients.


问:
Making a NxN tic tac toe GUI wpf c#
I am making a NxN tic tac toe game in WPF c#. I want user to enter Rows and Column count(NxN), and my code will generate those number of columns and rows. I can't figure it out, how will I produce that number of rows and columns dynamically. I have posted my XAML code, is there a way that I can loop my XAML code?
    thanks</p>

```<code><Grid x:Name="Container">
    <!-- First here i want to make N columns-->
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <!-- Here i want to make N rows-->
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!-- Then here i want to add that number of buttons in N x N columns and rows -->
    <Button x:Name="Button0_0" Grid.Row="0" Grid.Column="0" Click="Button_Click"/>
    <Button x:Name="Button0_1" Grid.Row="0" Grid.Column="1" Click="Button_Click" />
    <Button x:Name="Button0_2" Grid.Row="0" Grid.Column="2" Click="Button_Click"/>

    <Button x:Name="Button1_0" Grid.Row="1" Grid.Column="0" Click="Button_Click"/>
    <Button x:Name="Button1_1" Grid.Row="1" Grid.Column="1" Click="Button_Click"/>
    <Button x:Name="Button1_2" Grid.Row="1" Grid.Column="2" Click="Button_Click"/>

    <Button x:Name="Button2_0" Grid.Row="2" Grid.Column="0" Click="Button_Click"/>
    <Button x:Name="Button2_1" Grid.Row="2" Grid.Column="1" Click="Button_Click"/>
    <Button x:Name="Button2_2" Grid.Row="2" Grid.Column="2" Click="Button_Click"/>
</Grid>
</code>```

答:
ItemsControl + UniformGrid as a Panel is a good choice to display a rectangular game board. I have already posted similar solution (How to create and use matrix of (color) boxes C# WPF) but it is missing Rows and Columns binding. Here is a more elaborated example for TicTacToe.

Let's create view model classes:

```<code>public class BoardCell : INotifyPropertyChanged
{
    private string _sign;
    private bool _canSelect = true;

    public string Sign
    {
        get { return _sign; }
        set
        {
            _sign = value;
            if (value != null)
                CanSelect = false;
            OnPropertyChanged();
        }
    }

    public bool CanSelect
    {
        get { return _canSelect; }
        set
        {
            _canSelect = value;
            OnPropertyChanged();
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}
</code>```

```<code>public class Board
{
    public int Rows { get; set; }
    public int Columns { get; set; }

    private ObservableCollection<BoardCell> _cells;
    public ObservableCollection<BoardCell> Cells
    {
        get
        {
            if (_cells == null)
                _cells = new ObservableCollection<BoardCell>(Enumerable.Range(0, Rows*Columns).Select(i => new BoardCell()));
            return _cells;
        }
    }
}
</code>```

and then create a view:

```<code><Grid x:Name="Container">
    <Grid.DataContext>
        <wpfDemos:Board Rows="8" Columns="8"/>
    </Grid.DataContext>
    <ItemsControl x:Name="Board" ItemsSource="{Binding Path=Cells}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate >
                <UniformGrid Rows="{Binding Path=Rows}" Columns="{Binding Path=Columns}"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>

        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Button Content="{Binding Path=Sign}"
                        IsEnabled="{Binding Path=CanSelect}"
                        Click="CellClick"/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</Grid>
</code>```

in the code-behind we have one method to allow 2 players make thier moves in turn:

```<code>private bool _firstPlayer = true;
private void CellClick(object sender, RoutedEventArgs e)
{
    var cell = (sender as Button).DataContext as BoardCell;
    cell.Sign = _firstPlayer ? "X" : "O";
    _firstPlayer = !_firstPlayer;
    // TODO check winner
}
</code>```

to follow MVVM pattern this method should be wrapped into a command (ICommand), moved to Board class and attached to view via Button.Command binding.

summary: separate logic and presentation. work with data. let controls generate their content based on bindings and provided templates.

Title: Making a NxN tic tac toe GUI wpf c#

Body:
I am making a NxN tic tac toe game in WPF c#. I want user to enter Rows and Column count(NxN), and my code will generate those number of columns and rows. I can't figure it out, how will I produce that number of rows and columns dynamically. I have posted my XAML code, is there a way that I can loop my XAML code?
    thanks

<Grid x:Name="Container">

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Button x:Name="Button0_0" Grid.Row="0" Grid.Column="0" Click="Button_Click"/>
    <Button x:Name="Button0_1" Grid.Row="0" Grid.Column="1" Click="Button_Click" />
    <Button x:Name="Button0_2" Grid.Row="0" Grid.Column="2" Click="Button_Click"/>

    <Button x:Name="Button1_0" Grid.Row="1" Grid.Column="0" Click="Button_Click"/>
    <Button x:Name="Button1_1" Grid.Row="1" Grid.Column="1" Click="Button_Click"/>
    <Button x:Name="Button1_2" Grid.Row="1" Grid.Column="2" Click="Button_Click"/>

    <Button x:Name="Button2_0" Grid.Row="2" Grid.Column="0" Click="Button_Click"/>
    <Button x:Name="Button2_1" Grid.Row="2" Grid.Column="1" Click="Button_Click"/>
    <Button x:Name="Button2_2" Grid.Row="2" Grid.Column="2" Click="Button_Click"/>
</Grid>

Body:
ItemsControl + UniformGrid as a Panel is a good choice to display a rectangular game board. I have already posted similar solution (How to create and use matrix of (color) boxes C# WPF) but it is missing Rows and Columns binding. Here is a more elaborated example for TicTacToe.

Let's create view model classes:

public class BoardCell : INotifyPropertyChanged
{
    private string _sign;
    private bool _canSelect = true;

    public string Sign
    {
        get { return _sign; }
        set
        {
            _sign = value;
            if (value != null)
                CanSelect = false;
            OnPropertyChanged();
        }
    }

    public bool CanSelect
    {
        get { return _canSelect; }
        set
        {
            _canSelect = value;
            OnPropertyChanged();
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

public class Board
{
    public int Rows { get; set; }
    public int Columns { get; set; }

    private ObservableCollection<BoardCell> _cells;
    public ObservableCollection<BoardCell> Cells
    {
        get
        {
            if (_cells == null)
                _cells = new ObservableCollection<BoardCell>(Enumerable.Range(0, Rows*Columns).Select(i => new BoardCell()));
            return _cells;
        }
    }
}

and then create a view:

<Grid x:Name="Container">
    <Grid.DataContext>
        <wpfDemos:Board Rows="8" Columns="8"/>
    </Grid.DataContext>
    <ItemsControl x:Name="Board" ItemsSource="{Binding Path=Cells}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate >
                <UniformGrid Rows="{Binding Path=Rows}" Columns="{Binding Path=Columns}"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>

        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Button Content="{Binding Path=Sign}"
                        IsEnabled="{Binding Path=CanSelect}"
                        Click="CellClick"/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</Grid>

in the code-behind we have one method to allow 2 players make thier moves in turn:

private bool _firstPlayer = true;
private void CellClick(object sender, RoutedEventArgs e)
{
    var cell = (sender as Button).DataContext as BoardCell;
    cell.Sign = _firstPlayer ? "X" : "O";
    _firstPlayer = !_firstPlayer;
    // TODO check winner
}

to follow MVVM pattern this method should be wrapped into a command (ICommand), moved to Board class and attached to view via Button.Command binding.

summary: separate logic and presentation. work with data. let controls generate their content based on bindings and provided templates.


问:
Convert CSV to XML when CSV contains both character and number data
From this thread, I got the basic info on how to parse CSV to create XML. Unfortunately, the text fields (all enclosed in quotes) sometimes contain commas, so line.split(',') gives me too many columns. I can't figure out how to parse the CSV so line.split(',') distinguishes between commas within a text field, and commas separating fields. Any thoughts on how to do that?

Thanks!

答:
Here's a little trick if you don't want to use Regex. Instead of spliting with comma you can split with comma and quotes together ","

Assuming there's no space before and after comma:

```<code>line.Split("\",\"")
</code>```

You will need to remove the quote before the first field and after the last field however.

Body:
Here's a little trick if you don't want to use Regex. Instead of spliting with comma you can split with comma and quotes together ","

Assuming there's no space before and after comma:

line.Split("\",\"")

You will need to remove the quote before the first field and after the last field however.


问:
Split a string in Java by symbols
The request is simple in words, but then it took a twist
Basically what I need is not only to split a string, but save the"symbols"and later be able to show them

Here's how it works:

Input:

Once upon a time there was a kingdom far, far away

On this kingdom lived a princess

And she was happy by herself

Output:

Once, 1 time, line 1-column 1

upon, 1 time, line 1-column 6

a, 3 times, line 1-column 11, line 1-column 28, line 2-column 23

...

Also should be able to : not consider spaces, \n and \f on them, but like do consider the "," so splitting by spaces would not give "far," and "far" as different symbols, just as "," is a symbol on it's own

Is there any way on which the split method could consider multiple parameters?
Not to mention I am not sure if there is a better way than a for loop to count the line and column on which each "symbol" is repeated

答:
Split the string into symbols, keep the symbols as keys in the hash map and their count in corresponding hash map values.

Example:

```<code>Map<String, Integer> tokensWithCounts = new HashMap<String, Integer>();
String[] tokens = str.split("\\s*[a-zA-Z]+\\s*");
List<String> tokensList = Arrays.asList(tokens);
for(String token : tokenList){
    if(tokensWithCounts.get(token) == null){
        tokensWithCounts.put(token, 0);
    }
    tokensWithCounts.put(token, tokensWithCounts.get(token) + 1);
}
</code>```

EDIT: Sorry, I got the question wrong. You will keep the values in a HashMap<String, List<String>>. Tokens will still be keys, List will have all occurrences of the token in the form of "line 1-column 1". The count of occurrences is the .size() of the List<String> that is stored in the HashMap.

Title: Split a string in Java by symbols

Body:
Split the string into symbols, keep the symbols as keys in the hash map and their count in corresponding hash map values.

Example:

Map<String, Integer> tokensWithCounts = new HashMap<String, Integer>();
String[] tokens = str.split("\\s*[a-zA-Z]+\\s*");
List<String> tokensList = Arrays.asList(tokens);
for(String token : tokenList){
    if(tokensWithCounts.get(token) == null){
        tokensWithCounts.put(token, 0);
    }
    tokensWithCounts.put(token, tokensWithCounts.get(token) + 1);
}

EDIT: Sorry, I got the question wrong. You will keep the values in a HashMap<String, List<String>>. Tokens will still be keys, List will have all occurrences of the token in the form of "line 1-column 1". The count of occurrences is the .size() of the List<String> that is stored in the HashMap.


问:
url automatically encoding when using file_get_contents php?
When i tried to get image from url http://example.com/img.jpg?aa=11&bb=22 using file_get_contents() function, the url encoded to http://example.com/img.jpg?aa=11&bb=22.

And it showing an error file_get_contents(http://example.com/img.jpg?aa=11&bb=22) : failed to open stream: Connection timed out in filename.php

How can i avoid this url encoding?

my code is

```<code>$imgurl = "http://example.com/img.jpg?aa=11&bb=22";
file_get_contents($imgurl);
</code>```

答:
I'm not sure where the encoding is coming from, but you can decode it with html_entity_decode():

```<code>$imgurl = html_entity_decode($_POST['img']);
</code>```

Body:
When i tried to get image from url http://example.com/img.jpg?aa=11&bb=22 using file_get_contents() function, the url encoded to http://example.com/img.jpg?aa=11&bb=22.

And it showing an error file_get_contents(http://example.com/img.jpg?aa=11&bb=22) : failed to open stream: Connection timed out in filename.php

How can i avoid this url encoding?

my code is

$imgurl = "http://example.com/img.jpg?aa=11&bb=22";
file_get_contents($imgurl);

Body:
I'm not sure where the encoding is coming from, but you can decode it with html_entity_decode():

$imgurl = html_entity_decode($_POST['img']);


问:
Upload the file to a folder and saving the name to the database in yii2
Good afternoon!
There is a question about the file upload to yii2. There are two folders in it that will store the original and thumbnail image. At me files are loaded but here the name of a file does not load in a database

Model

```<code>namespace app\models;

use yii\base\Model;
use yii\db\ActiveRecord;
use yii\web\UploadedFile;

use yii\imagine\Image;
use Imagine\Image\Box;

/**
 * This is the model class for table "images".
 *
 * @property integer $id
 * @property string $original_image
 * @property string $prev_image
 */
class Images extends ActiveRecord
{

    public $imageFile;
    public $file_name;

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'images';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['prev_image'], 'string', 'max' => 255],
            [['original_image'], 'string'],
            [['imageFile'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg', 'maxSize' => 1024 * 1024 * 7],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'original_image' => 'Original Image',
            'prev_image' => 'Prev Image',
        ];
    }

    public function upload()
    {
        $temp=substr(md5(microtime() . rand(0, 9999)), 0, 20);

        if ($this->validate()) {
            $this->imageFile->saveAs('uploads/original/'.$temp.$this->imageFile->baseName . '.' . $this->imageFile->extension);
            $imagine = Image::getImagine();
            $image = $imagine->open('uploads/original/' . $temp.$this->imageFile);
            $image->resize(new Box(250, 150))->save('uploads/prev/' . $temp.$this
                    ->imageFile->baseName . '.' . $this->imageFile->extension, ['quality' => 70]);
            $this->file_name=$temp.$this->imageFile->baseName . '.' . $this->imageFile->extension;

            return true;
        } else {
            return false;
        }
    }
}
</code>```

Controller

```<code>namespace app\controllers;

use app\models\Images;
use Yii;
use yii\web\UploadedFile;

class ImageController extends \yii\web\Controller
{

        public function actionUpload()
    {
        $model = new Images();

        if ($model->load(Yii::$app->request->post())) {

            $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
            $model->prev_image=$model->file_name;
            $model->original_image=$model->file_name;
            $model->save();

            if ($model->upload()) {
                return;
            }
        }

        return $this->render('upload', ['model' => $model]);
    }

}
</code>```

A question how to save a file name in database? Thank you in advance

答:
It's because save happens before uplaod action, but you only define file_name in upload function. Save is what saves it in to the database. </p>

<p>Controller should look like this: </p>

```<code>namespace app\controllers;

use app\models\Images;
use Yii;
use yii\web\UploadedFile;

class ImageController extends \yii\web\Controller
{
    public function actionUpload(){

        $model = new Images();

        if ($model->load(Yii::$app->request->post())) {
            $uploadedFile = UploadedFile::getInstance($model, 'imageFile');
            $model->imageFile = $uploadedFile;
            $model->prev_image = $uploadedFile->name
            $model->original_image = $uploadedFile->name
            $model->save();

            if ($model->upload()) {
                return;
            }
        }

        return $this->render('upload', ['model' => $model]);
    }
}
</code>```

Body:
Good afternoon!
There is a question about the file upload to yii2. There are two folders in it that will store the original and thumbnail image. At me files are loaded but here the name of a file does not load in a database

Model

namespace app\models;

use yii\base\Model;
use yii\db\ActiveRecord;
use yii\web\UploadedFile;

use yii\imagine\Image;
use Imagine\Image\Box;

/**
 * This is the model class for table "images".
 *
 * @property integer $id
 * @property string $original_image
 * @property string $prev_image
 */
class Images extends ActiveRecord
{

    public $imageFile;
    public $file_name;

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'images';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['prev_image'], 'string', 'max' => 255],
            [['original_image'], 'string'],
            [['imageFile'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg', 'maxSize' => 1024 * 1024 * 7],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'original_image' => 'Original Image',
            'prev_image' => 'Prev Image',
        ];
    }

    public function upload()
    {
        $temp=substr(md5(microtime() . rand(0, 9999)), 0, 20);

        if ($this->validate()) {
            $this->imageFile->saveAs('uploads/original/'.$temp.$this->imageFile->baseName . '.' . $this->imageFile->extension);
            $imagine = Image::getImagine();
            $image = $imagine->open('uploads/original/' . $temp.$this->imageFile);
            $image->resize(new Box(250, 150))->save('uploads/prev/' . $temp.$this
                    ->imageFile->baseName . '.' . $this->imageFile->extension, ['quality' => 70]);
            $this->file_name=$temp.$this->imageFile->baseName . '.' . $this->imageFile->extension;

            return true;
        } else {
            return false;
        }
    }
}

Controller

namespace app\controllers;

use app\models\Images;
use Yii;
use yii\web\UploadedFile;

class ImageController extends \yii\web\Controller
{

        public function actionUpload()
    {
        $model = new Images();

        if ($model->load(Yii::$app->request->post())) {

            $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
            $model->prev_image=$model->file_name;
            $model->original_image=$model->file_name;
            $model->save();

            if ($model->upload()) {
                return;
            }
        }

        return $this->render('upload', ['model' => $model]);
    }

}

A question how to save a file name in database? Thank you in advance

Body:
It's because save happens before uplaod action, but you only define file_name in upload function. Save is what saves it in to the database.

Controller should look like this:

namespace app\controllers;

use app\models\Images;
use Yii;
use yii\web\UploadedFile;

class ImageController extends \yii\web\Controller
{
    public function actionUpload(){

        $model = new Images();

        if ($model->load(Yii::$app->request->post())) {
            $uploadedFile = UploadedFile::getInstance($model, 'imageFile');
            $model->imageFile = $uploadedFile;
            $model->prev_image = $uploadedFile->name
            $model->original_image = $uploadedFile->name
            $model->save();

            if ($model->upload()) {
                return;
            }
        }

        return $this->render('upload', ['model' => $model]);
    }
}


问:
retrieving json data from mysql and php into jquery
I am trying to bring mysql data into jquery by using php, I get the data into a JSON format like this.

```<code>{"uid":"33","title":"Apple, Peach, Grapefruit","ing1":"apple","qty1":"1","meas1":"whole","ing2":"peaches \/ halved and","qty2":"2","meas2":"each","ing3":"grapefruit \/ peeled","qty3":"2","meas3":"each","ing4":"","qty4":"0","meas4":"each","ing5":"","qty5":"0","meas5":"each","ing6":"","qty6":"0","meas6":"each","ing7":"","qty7":"0","meas7":"each","ing8":"","qty8":"0","meas8":"each","ing9":"","qty9":"0","meas9":"each","ing10":"","qty10":"0","meas10":"each","servings":"2","benefits":""}
</code>```

using this following code:

```<code>require_once'connect.php';
$uid = $_GET['uid'];
$sql = "SELECT * FROM recipes WHERE uid = '$uid'";
$result = mysqli_query($conn, $sql);

$num_rows = mysqli_affected_rows($conn);
while($row = mysqli_fetch_assoc($result)) {
$data = json_encode($row);
echo $data;
}
</code>```

I am using jquery .get to pull it into the web page with this code.

```<code>$(document).ready(function(e) {
var id = location.search;
uid=id.substring(4);
$.get('../jqm_juicing/data/get_json.php?uid=' + uid,function(data, status){
$("#display").append(data);
});
});
</code>```

It displays the json data as above.  I would like to be able to access the different elements individually, how do I do that?

答:
In your jQuery, add JSON.parse() before you append (data).

```<code>$(document).ready(function(e) {
    var id = location.search;
    uid=id.substring(4);
    $.get('../jqm_juicing/data/get_json.php?uid=' + uid,function(data, status){
        $("#display").append(JSON.parse(data));
    });
});
</code>```

I just changed this line:

```<code>$("#display").append(JSON.parse(data));
</code>```

Hope this helps!

Body:
I am trying to bring mysql data into jquery by using php, I get the data into a JSON format like this.

{"uid":"33","title":"Apple, Peach, Grapefruit","ing1":"apple","qty1":"1","meas1":"whole","ing2":"peaches \/ halved and","qty2":"2","meas2":"each","ing3":"grapefruit \/ peeled","qty3":"2","meas3":"each","ing4":"","qty4":"0","meas4":"each","ing5":"","qty5":"0","meas5":"each","ing6":"","qty6":"0","meas6":"each","ing7":"","qty7":"0","meas7":"each","ing8":"","qty8":"0","meas8":"each","ing9":"","qty9":"0","meas9":"each","ing10":"","qty10":"0","meas10":"each","servings":"2","benefits":""}

using this following code:

require_once'connect.php';
$uid = $_GET['uid'];
$sql = "SELECT * FROM recipes WHERE uid = '$uid'";
$result = mysqli_query($conn, $sql);

$num_rows = mysqli_affected_rows($conn);
while($row = mysqli_fetch_assoc($result)) {
$data = json_encode($row);
echo $data;
}

I am using jquery .get to pull it into the web page with this code.

$(document).ready(function(e) {
var id = location.search;
uid=id.substring(4);
$.get('../jqm_juicing/data/get_json.php?uid=' + uid,function(data, status){
$("#display").append(data);
});
});

It displays the json data as above.  I would like to be able to access the different elements individually, how do I do that?

Body:
In your jQuery, add JSON.parse() before you append (data).

$(document).ready(function(e) {
    var id = location.search;
    uid=id.substring(4);
    $.get('../jqm_juicing/data/get_json.php?uid=' + uid,function(data, status){
        $("#display").append(JSON.parse(data));
    });
});

I just changed this line:

$("#display").append(JSON.parse(data));

Hope this helps!


答:
If you wrap it with ";
```

<p>Now in your main page scripts, you can access this JSON like any other normal JSON.<br>
Here is an interval that you can place anywhere in your main page scripts:<br>
<em>It is just to test this ;)</em></p>

```var checkJson = setInterval(function(){

  if(typeof(myJson.uid)!="undefined"){

    clearInterval(checkJson);

    console.log("myJson uid: " + myJson.uid);
    console.log("myJson title: " + myJson.title);
    // etc...

  }else{
    console.log("JSON not loaded yet.");
  }

},500);
```

Title: retrieving json data from mysql and php into jquery

Body:
If you wrap it with <script> tags, and declare it as a variable, you will have it.

require_once'connect.php';
$uid = $_GET['uid'];
$sql = "SELECT * FROM recipes WHERE uid = '$uid'";
$result = mysqli_query($conn, $sql);

$num_rows = mysqli_affected_rows($conn);

echo "<script>";
while($row = mysqli_fetch_assoc($result)) {
  $data = json_encode($row);
  echo "var myJson=" . $data;
}
echo "</script>";

Now in your main page scripts, you can access this JSON like any other normal JSON.

Here is an interval that you can place anywhere in your main page scripts:

It is just to test this ;)

var checkJson = setInterval(function(){

  if(typeof(myJson.uid)!="undefined"){

    clearInterval(checkJson);

    console.log("myJson uid: " + myJson.uid);
    console.log("myJson title: " + myJson.title);
    // etc...

  }else{
    console.log("JSON not loaded yet.");
  }

},500);


问:
Determine subplot square dimensions from total number of plots
I'm trying to figure out how to calculate subplot dimensions when I know the total number of plots I need and I'd like the arrangement to be a square (with possibly a few empty subplots).

For example if I need 22 subplots then I would make a grid of 5x5 for a total of 25 subplots, then just leave three of them empty.

So I guess I'm looking for an algorithm where I'd input 22 and get out 5, for example. Anyone know of a short way to do this in python (maybe lambda function if possible)?

(Also open to other alternatives or pre-made solutions for doing this, I'm doing multiple subplot matrices for a dictionary of pandas dataframes)

答:
This should work for what you're trying to do. I haven't tried anything with a lambda function but I doubt it would be difficult to modify this. There won't be any empty plots because the algorithm stops once it's out of values to plot.

I broke up the dictionary into key and value lists because I was originally working with lists when I wrote this. Everything up to the try clause would work without converting your values to a list. If you wanted to fill in with empty plots rather than using the somewhat hack-y break_test bit, you can put all of your code for the subplots inside a try clause.

Weird break version:

```<code>fig = plt.figure()

# Makes organizing the plots easier
key_list, val_list = [k, v for k, v in dict.getitems()]

# We take advantage of the fact that int conversions always round down
floor = int(np.sqrt(len(val_list))

# If the number of plots is a perfect square, we're done.
# Otherwise, we take the next highest perfect square to build our subplots
if floor ** 2 == len(val_list):
    sq_chk = floor
else:
    sq_chk = floor + 1

plot_count = 0

# The try/except makes sure we can gracefully stop building plots once
# we've exhausted our dictionary values.
for i in range(sq_chk):
    for j in range(sq_chk):
        try:
            break_test = val_list[plot_count]
        except:
            break

        ax = fig.add_subplot(sq_chk, sq_chk, plot_count + 1)
        ax.set_title(key_list[plot_count])

        ...
        # Whatever you want to do with your plots
        ...

        plot_count += 1

plt.show()
</code>```

No break version:

```<code>fig = plt.figure()
key_list, val_list = [k, v for k, v in dict.getitems()]

floor = int(np.sqrt(len(dict))

if floor ** 2 == len(dict):
    sq_chk = floor
else:
    sq_chk = floor + 1

plot_count = 0

# Everything from the original snippet should be nested in the try clause
for i in range(sq_chk):
    for j in range(sq_chk):
        try:

            ax = fig.add_subplot(sq_chk, sq_chk, plot_count + 1)
            ax.set_title(key_list[plot_count])

            ...
            # Whatever you want to do with your plots
            ...

            plot_count += 1

        except:
            plot_count +=1

plt.show()
</code>```

Body:
This should work for what you're trying to do. I haven't tried anything with a lambda function but I doubt it would be difficult to modify this. There won't be any empty plots because the algorithm stops once it's out of values to plot.

I broke up the dictionary into key and value lists because I was originally working with lists when I wrote this. Everything up to the try clause would work without converting your values to a list. If you wanted to fill in with empty plots rather than using the somewhat hack-y break_test bit, you can put all of your code for the subplots inside a try clause.

Weird break version:

fig = plt.figure()

# Makes organizing the plots easier
key_list, val_list = [k, v for k, v in dict.getitems()]

# We take advantage of the fact that int conversions always round down
floor = int(np.sqrt(len(val_list))

# If the number of plots is a perfect square, we're done.
# Otherwise, we take the next highest perfect square to build our subplots
if floor ** 2 == len(val_list):
    sq_chk = floor
else:
    sq_chk = floor + 1

plot_count = 0

# The try/except makes sure we can gracefully stop building plots once
# we've exhausted our dictionary values.
for i in range(sq_chk):
    for j in range(sq_chk):
        try:
            break_test = val_list[plot_count]
        except:
            break

        ax = fig.add_subplot(sq_chk, sq_chk, plot_count + 1)
        ax.set_title(key_list[plot_count])

        ...
        # Whatever you want to do with your plots
        ...

        plot_count += 1

plt.show()

No break version:

fig = plt.figure()
key_list, val_list = [k, v for k, v in dict.getitems()]

floor = int(np.sqrt(len(dict))

if floor ** 2 == len(dict):
    sq_chk = floor
else:
    sq_chk = floor + 1

plot_count = 0

# Everything from the original snippet should be nested in the try clause
for i in range(sq_chk):
    for j in range(sq_chk):
        try:

            ax = fig.add_subplot(sq_chk, sq_chk, plot_count + 1)
            ax.set_title(key_list[plot_count])

            ...
            # Whatever you want to do with your plots
            ...

            plot_count += 1

        except:
            plot_count +=1

plt.show()


问:
qemu guest automation
I've not been able to find any documentation stating the existence of an API that can be used to automate things inside of a qemu guest.

For example, I would like to launch a process inside of the guest machine from the host machine. Libvirt does not appear to contain such functionality.

答:
If you're running Linux in the guest, couldn't you just use ssh/screen to launch remote processes on the guest?

Alternatively, I have seen people write python wrappers that use popen() to grab stdin/stdout and use those to automate some commands (i.e. when you see the login prompt, send the login name to stdin of QEMU.

Title: qemu guest automation


问:
unable to see output as expected when using forEach logic in js file
My requirement is to display the bar graph.I'm using angularjs and Zingchart to display the bar. Belowis the javascript code which gets invoked to generate the bar. I'm facing issue in iterating the logic(angular.forEach..) in the below mentioned code.

My alert statement inside angular.forEach is displayed 3 times, but on the UI i can only see one bar displayed(i.e.,bar with final data is displayed, first two bars are not getting displayed).
I know i'm missing something which draws each and every bar instead of the last displayed bar. Do i need to use any push statemetns. Please advice.

```<code>app.controller('myController',['$rootScope','$scope','$uibModal','myService',function($rootScope,$scope,$uibModal,myService)  {
    $scope.chart = {};
    $scope.chart.options = {
        "isStacked": "true",
         axisFontSize : 10,
        chartArea: {left:0, width: 400,}
    };
    $scope.chart.type = "bar";
    $scope.chart.cssStyle = "height:300px; width:650px;";

    $scope.loadChartData = function(){
        alert("Chart data loading");
        MyService.getChartData($rootScope.myID).then(
            function(response) {
                $scope.myJson=response;
                  angular.forEach($scope.myJson,function(value,key){
                      alert("in foreach"); //displaying 3 times
                      sub =  value.myResults.sub;
                      spread = value.myResults.spread;
                      active  =value.myResults.active;
                    $scope.data = {};
                    $scope.data.valuesOne = [sub];
                    $scope.data.valuesTwo = [spread];
                    $scope.data.valuesThree = [active];
                    $scope.aValues = [$scope.data.valuesOne,$scope.data.valuesTwo,$scope.data.valuesThree];
                    $scope.myJson = {
                        type : "bar",
                        "background-color": "white",
                        "plot": {
                            "stacked": true,
                            "stack-type":"normal"
                        },
                        title:{
                            backgroundColor : "transparent",
                            fontColor :"black",
                            text : "Hello world"
                        },
                        backgroundColor : "white",
                        series : [
                            {
                                backgroundColor : '#00baf2'
                            },
                            {
                                backgroundColor : '#4caf4f'
                            }
                        ]
                    };
             });
            },
            function(errResponse){
                console.error('Error while data retrieval');
            });
    }

}]);
</code>```

html code:

```<code>  <div ng-controller="myController">
            <div zingchart id="chart-2" zc-json="myJson" zc-width="700px" zc-height="568px" zc-values="aValues"></div>
  </div>
</code>```

With the above mentioned js code i should see 3 bars on the UI, i could able to view only one bar.Please suggest.

答:
There are a few things I have to add:

1. Zingchart Syntax

Did you already have a look at these docs: https://www.zingchart.com/docs/chart-types/bar-charts/

It says, the bar chart needs a series object as input with the following structure:

```<code>  "series": [
    {"values":[20,40,25,50,15,45,33,34]},
    {"values":[5,30,21,18,59,50,28,33]},
    {"values":[30,5,18,21,33,41,29,15]}
   ]
</code>```

Is it a must to feed the chart from HTML? Otherwise you just could copy the JS example from the link above.
IMHO this is much cleaner, as you do not push that much data in the scope.

2. Overwriting myJson

Something looks a little wrong with the forEach loop.

There is a angular.forEach that should iterate over the array $scope.myJson. But inside the iterator function, $scope.myJson gets overwrtitten by an object.

3. ng-repeat

ng-repeat will only repeat the chart tag. You need to pass several series to the directive.

Body:
My requirement is to display the bar graph.I'm using angularjs and Zingchart to display the bar. Belowis the javascript code which gets invoked to generate the bar. I'm facing issue in iterating the logic(angular.forEach..) in the below mentioned code.

My alert statement inside angular.forEach is displayed 3 times, but on the UI i can only see one bar displayed(i.e.,bar with final data is displayed, first two bars are not getting displayed).
I know i'm missing something which draws each and every bar instead of the last displayed bar. Do i need to use any push statemetns. Please advice.

app.controller('myController',['$rootScope','$scope','$uibModal','myService',function($rootScope,$scope,$uibModal,myService)  {
    $scope.chart = {};
    $scope.chart.options = {
        "isStacked": "true",
         axisFontSize : 10,
        chartArea: {left:0, width: 400,}
    };
    $scope.chart.type = "bar";
    $scope.chart.cssStyle = "height:300px; width:650px;";

    $scope.loadChartData = function(){
        alert("Chart data loading");
        MyService.getChartData($rootScope.myID).then(
            function(response) {
                $scope.myJson=response;
                  angular.forEach($scope.myJson,function(value,key){
                      alert("in foreach"); //displaying 3 times
                      sub =  value.myResults.sub;
                      spread = value.myResults.spread;
                      active  =value.myResults.active;
                    $scope.data = {};
                    $scope.data.valuesOne = [sub];
                    $scope.data.valuesTwo = [spread];
                    $scope.data.valuesThree = [active];
                    $scope.aValues = [$scope.data.valuesOne,$scope.data.valuesTwo,$scope.data.valuesThree];
                    $scope.myJson = {
                        type : "bar",
                        "background-color": "white",
                        "plot": {
                            "stacked": true,
                            "stack-type":"normal"
                        },
                        title:{
                            backgroundColor : "transparent",
                            fontColor :"black",
                            text : "Hello world"
                        },
                        backgroundColor : "white",
                        series : [
                            {
                                backgroundColor : '#00baf2'
                            },
                            {
                                backgroundColor : '#4caf4f'
                            }
                        ]
                    };
             });
            },
            function(errResponse){
                console.error('Error while data retrieval');
            });
    }

}]);

html code:

With the above mentioned js code i should see 3 bars on the UI, i could able to view only one bar.Please suggest.

Body:
There are a few things I have to add:

1. Zingchart Syntax

Did you already have a look at these docs: https://www.zingchart.com/docs/chart-types/bar-charts/

It says, the bar chart needs a series object as input with the following structure:

  "series": [
    {"values":[20,40,25,50,15,45,33,34]},
    {"values":[5,30,21,18,59,50,28,33]},
    {"values":[30,5,18,21,33,41,29,15]}
   ]

Is it a must to feed the chart from HTML? Otherwise you just could copy the JS example from the link above.
IMHO this is much cleaner, as you do not push that much data in the scope.

2. Overwriting myJson

Something looks a little wrong with the forEach loop.

There is a angular.forEach that should iterate over the array $scope.myJson. But inside the iterator function, $scope.myJson gets overwrtitten by an object.

3. ng-repeat

ng-repeat will only repeat the chart tag. You need to pass several series to the directive.


问:
Best way to render OpenType font preview in PHP
I am trying to render OpenType text (with ligatures... which is why I am using OTF vs TTF).  I can't find a good way to do so in PHP.  Is there a Cairo/Pango library that is easy to install to do this for PHP?  Or am I going about this all wrong?

Thanks in advance.

答: You can use https://github.com/PhenX/php-font-lib to get the outlines, I didn't tested it but it looks like you can even get an SVG.</p>


问:
How to align input forms in HTML
I'm new to HTML and I'm trying to learn how to use forms.

The biggest issue I am having so far is aligning the forms. Here is an example of my current HTML file:

```<code><form>
 First Name:<input type="text" name="first"><br />
 Last Name:<input type="text" name="last"><br />
 Email:<input type="text" name="email"><br />
</form>
</code>```

The problem with this is, the field box after 'Email' is drastically different in terms of spacing compared to first, and last name. What is the 'proper' way to make it so that they 'line-up' essentially?

I am trying to practice good form and syntax...a lot of people might do this with CSS I am not sure, I have only learned the very basics of HTML so far.

答:
Another example, this uses CSS, I simply put the form in a div with the container class. And specified that input elements contained within are to be 100% of the container width and not have any elements on either side.

.container {
  width: 500px;
  clear: both;
}

.container input {
  width: 100%;
  clear: both;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>

<head>
  <title>Example form</title>
</head>

<body>
  <div class="container">
    <form>
      <label>First Name</label>
      <input type="text" name="first"><br />
      <label>Last Name</label>
      <input type="text" name="last"><br />
      <label>Email</label>
      <input type="text" name="email"><br />
    </form>
  </div>
</body>

</html></code>```

Title: How to align input forms in HTML

Body:
I'm new to HTML and I'm trying to learn how to use forms.

The biggest issue I am having so far is aligning the forms. Here is an example of my current HTML file:

<form>
 First Name:<input type="text" name="first">

 Last Name:<input type="text" name="last">

 Email:<input type="text" name="email">

</form>

The problem with this is, the field box after 'Email' is drastically different in terms of spacing compared to first, and last name. What is the 'proper' way to make it so that they 'line-up' essentially?

I am trying to practice good form and syntax...a lot of people might do this with CSS I am not sure, I have only learned the very basics of HTML so far.

Body:
Another example, this uses CSS, I simply put the form in a div with the container class. And specified that input elements contained within are to be 100% of the container width and not have any elements on either side.

.container {
  width: 500px;
  clear: both;
}

.container input {
  width: 100%;
  clear: both;
}

<html>

<head>
  <title>Example form</title>
</head>

<body>
  <div class="container">
    <form>
      <label>First Name</label>
      <input type="text" name="first"><br />
      <label>Last Name</label>
      <input type="text" name="last"><br />
      <label>Email</label>
      <input type="text" name="email"><br />
    </form>
  </div>
</body>

</html>


问:
shared domain with scala.js, how?
Probably a basic question, but I'm confused with the various documentations and examples around scala.js.

I have a domain model I would like to share between scala and scala.js, let's say:

```<code>class Estimator(val nickname: String)
</code>```

... and of course I would like to send objects between the web-client (scala.js with angular via angulate) and the server (scala with spring-mvc on spring-boot).

Should the class extends js.Object? And be annotated with @ScalaJSDefined (not yet deprecated in v0.6.15)?

If yes, it would be an unwanted dependency that comes also in the server part. Neither @scalaJSDefined nor js.Object are in the dummy scalajs-stubs. Or am I missing something?

If no, how to pass them through $http.post which expects a js.Any? I also get some TypeError at other places. Should I picke/unpickle everywhere or is there an automatic way?

EDIT 2017-03-30:

Actually this relates to Angulate, the facade for AngularJS I choose. For 2 features (communications to an http server and displaying model fields in html), the domain classes have to be Javascript classes. In Angulate's example, the domain model is duplicated.

There are also (and sadly) no plan to include js.Object in scalajs-stubs to overcome this problem. Details in https://github.com/scala-js/scala-js/issues/2564 . Perhaps js.Object doesn't hurt so much on the jvm...

So, what web frameworks and facade for scala.js does / doesn't nicely support shared domain? Not angulate1, probably Udash, perhaps react?

答:
(Caveat: I don't know Angulate, which might affect some of this. Speaking generally, though...)

No, those shared objects shouldn't derive from js.Object or use @ScalaJSDefined -- those are only for objects that are designed to interface with JavaScript itself, and it doesn't sound like that's what you have in mind. Objects that are just for Scala don't need them.

But yes -- in general, you're usually going to need to pickle the communications in one way or another. Which pickling library you use is up to you (there are several), but remember that the communication is simply a stream of bytes -- you have to tell the system how to serialize and deserialize between your domain objects and those bytes.

There isn't anything automatic in Scala.js per se -- that's just a language, and doesn't dictate your library choices. You can use implicits to make the pickling semi-automatic, but I recommend being a bit careful with that. I don't see anything obvious in the Angulate docs that indicate that it does the pickling automatically.

Title: shared domain with scala.js, how?

Body:
Probably a basic question, but I'm confused with the various documentations and examples around scala.js.

I have a domain model I would like to share between scala and scala.js, let's say:

class Estimator(val nickname: String)

... and of course I would like to send objects between the web-client (scala.js with angular via angulate) and the server (scala with spring-mvc on spring-boot).

Should the class extends js.Object? And be annotated with @ScalaJSDefined (not yet deprecated in v0.6.15)?

If yes, it would be an unwanted dependency that comes also in the server part. Neither @scalaJSDefined nor js.Object are in the dummy scalajs-stubs. Or am I missing something?

If no, how to pass them through $http.post which expects a js.Any? I also get some TypeError at other places. Should I picke/unpickle everywhere or is there an automatic way?

EDIT 2017-03-30:

Actually this relates to Angulate, the facade for AngularJS I choose. For 2 features (communications to an http server and displaying model fields in html), the domain classes have to be Javascript classes. In Angulate's example, the domain model is duplicated.

There are also (and sadly) no plan to include js.Object in scalajs-stubs to overcome this problem. Details in https://github.com/scala-js/scala-js/issues/2564 . Perhaps js.Object doesn't hurt so much on the jvm...

So, what web frameworks and facade for scala.js does / doesn't nicely support shared domain? Not angulate1, probably Udash, perhaps react?


问:
handling SQL lite databases in adobe flash (air) for android
I want to develop an app using Adobe flash for android. I was wondering if I could use databases in it. That is a must for the app. I am pretty good with adobe flash already. But:
Is it possible to develop an app that is built in adobe air using adobe flash that implements database read/write actions for sqlite in android?</p>

答:
While building a mobile app, Adobe AIR does not have any built in capabilites for working with any SQL server.

It does, however, have great capabilities to call out web services. So in order to work with a database engine, you will have to implement a server with some kind of service provider for HTTP or SOAP requests sent from your AIR application.

Another option is to use internal data structures that you can save on the device, such as data tables. But per your question, these are not SQL structures.