text:
Q: Geomesa: Radius query DWITHIN(geo, POINT (80.57944937597278 69.63928679990498), 130.0, meters) is very long I have cassandra with geomesa, in there I have next schema
 ~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra describe-schema -P localhost:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder
INFO  Describing attributes of feature 'SignalBuilder'
geo           | Point   (Spatio-temporally indexed)
time          | Date    (Spatio-temporally indexed) (Attribute indexed)
cam           | String  (Attribute indexed) (Attribute indexed)
imei          | String  (Attribute indexed)
dir           | Double
alt           | Double
vlc           | Double
sl            | Integer
ds            | Integer
dir_y         | Double
poi_azimuth_x | Double
poi_azimuth_y | Double

User data:
  geomesa.attr.splits     | 4
  geomesa.feature.expiry  | time(30 days)
  geomesa.index.dtg       | time
  geomesa.indices         | z3:7:3:geo:time,attr:8:3:time,attr:8:3:cam,attr:8:3:cam:time,attr:8:3:imei
  geomesa.stats.enable    | true
  geomesa.table.partition | time
  geomesa.z.splits        | 4
  geomesa.z3.interval     | week

when I do the next request, it is really fast:
 ~  date
Tues 11 Jan 2022 18:24:24 MSK
 ~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra export -P 10.200.217.24:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder -q "cam='5798a065-d51e-47a1-b04b-ab48df9f1324'" -m 10
INFO  Running export - please wait...
id,*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double
5798a065-d51e-47a1-b04b-ab48df9f1324-1638361381456,POINT (37.715528122 55.713859037),2021-12-01T12:23:01.456Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,0.0,60.0,5,1,0.0,0.0,0.0
5798a065-d51e-47a1-b04b-ab48df9f1324-1640706820000,POINT (31.970000000000002 56.88),2021-12-28T15:53:40.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,0.0,1.23,1,1,0.0,0.0,0.0
5798a065-d51e-47a1-b04b-ab48df9f1324-1640797130000,POINT (31.39951572344312 68.98547135697989),2021-12-29T16:58:50.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1640797434000,POINT (31.399484359174057 69.07515114832239),2021-12-29T17:03:54.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1640797627000,POINT (31.39948363272515 69.09555283117254),2021-12-29T17:07:07.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1640797784000,POINT (31.39948340746396 69.10451379934774),2021-12-29T17:09:44.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1640797993000,POINT (31.39948291171159 69.11711406549725),2021-12-29T17:13:13.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1640798006000,POINT (31.399482907612764 69.11813926100234),2021-12-29T17:13:26.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1640798020000,POINT (31.39948286587965 69.12141054010591),2021-12-29T17:13:40.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1640798414000,POINT (31.399453814973754 69.20771971657824),2021-12-29T17:20:14.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
 ~  date
Tues 11 Jan 2022 18:24:31 MSK

But when I make next request by radius
DWITHIN(geo, POINT (80.57944937597278 69.63928679990498), 130.0, meters)
It takes more than 4 minutes
✘  ~  date
Tues 11 Jan 2022 17:42:10 MSK
 ~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra export -P 10.200.217.24:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder -q "DWITHIN(geo, POINT (80.57944937597278 69.63928679990498), 130.0, meters)"
INFO  Running export - please wait...
id,*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double
5798a065-d51e-47a1-b04b-ab48df9f1324-1641900233000,POINT (80.57844937597278 69.63828679990498),2022-01-11T11:23:53.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
 ~  date
Tues 11 Jan 2022 17:46:49 MSK

Explain shows it uses Z3Index:
 ✘  ~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra explain -P 10.200.217.24:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder -q "DWITHIN(geo, POINT (80.57944937597278 69.63928679990498), 130.0, meters)"
Planning 'SignalBuilder' DWITHIN(geo, POINT (80.57944937597279 69.63928679990498), 130.0, meters)
  Original filter: DWITHIN(geo, POINT (80.57944937597279 69.63928679990498), 130.0, meters)
  Hints: bin[false] arrow[false] density[false] stats[false] sampling[none]
  Sort: none
  Transforms: none
  Max features: none
  Strategy selection:
    Query processing took 19ms for 1 options
    Filter plan: FilterPlan[Z3Index(geo,time)[INCLUDE][DWITHIN(geo, POINT (80.57944937597279 69.63928679990498), 130.0, meters)](Infinity)]
    Strategy selection took 3ms for 1 options
  Strategy 1 of 1: Z3Index(geo,time)
    Strategy filter: Z3Index(geo,time)[INCLUDE][DWITHIN(geo, POINT (80.57944937597279 69.63928679990498), 130.0, meters)](Infinity)
    Plan: org.locationtech.geomesa.cassandra.data.StatementPlan
      Tables: gsm_events_SignalBuilder_z3_geo_time_v7_02576, gsm_events_SignalBuilder_z3_geo_time_v7_02579, gsm_events_SignalBuilder_z3_geo_time_v7_02708, gsm_events_SignalBuilder_z3_geo_time_v7_02711, gsm_events_SignalBuilder_z3_geo_time_v7_02712, gsm_events_SignalBuilder_z3_geo_time_v7_02713, gsm_events_SignalBuilder_z3_geo_time_v7_02714, gsm_events_SignalBuilder_z3_geo_time_v7_02715
      Ranges (8): SELECT * FROM geomesa.gsm_events_SignalBuilder_z3_geo_time_v7_02576;, SELECT * FROM geomesa.gsm_events_SignalBuilder_z3_geo_time_v7_02579;, SELECT * FROM geomesa.gsm_events_SignalBuilder_z3_geo_time_v7_02708;, SELECT * FROM geomesa.gsm_events_SignalBuilder_z3_geo_time_v7_02711;, SELECT * FROM geomesa.gsm_events_SignalBuilder_z3_geo_time_v7_02712;
      Client-side filter: DWITHIN(geo, POINT (80.57944937597279 69.63928679990498), 130.0, meters)
      Reduce: class:LocalTransformReducer, state:{name=SignalBuilder, tnam=, tsft=, tdef=, hint=RETURN_SFT,"SignalBuilder,""*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double;geomesa.stats.enable='true',geomesa.z.splits='4',geomesa.feature.expiry='time(30 days)',geomesa.table.partition='time',geomesa.index.dtg='time',geomesa.indices='z3:7:3:geo:time,attr:8:3:time,attr:8:3:cam,attr:8:3:cam:time',geomesa.attr.splits='4',geomesa.z3.interval='week'""", spec=*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double;geomesa.stats.enable='true',geomesa.z.splits='4',geomesa.feature.expiry='time(30 days)',geomesa.table.partition='time',geomesa.index.dtg='time',geomesa.indices='z3:7:3:geo:time,attr:8:3:time,attr:8:3:cam,attr:8:3:cam:time',geomesa.attr.splits='4',geomesa.z3.interval='week', filt=DWITHIN(geo, POINT (80.57944937597279 69.63928679990498), 130.0, meters)}
    Plan creation took 87ms
  Query planning took 263ms

Why this last query is so long? And is there any way to make faster the request?
P.s. All db has 4_754_928 records
P.s.s Found that any query by geo figure takes about five minutes.
BBox has the same behavior, and takes something like 5 minutes, on cassandra cluster
 ~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra export -P 10.200.217.24:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder -q "BBOX(geo, 79.01240030621715, 68.63828679990498, 81.01240030621715, 70.63828679990498)"
INFO  Running export - please wait...
id,*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double
5798a065-d51e-47a1-b04b-ab48df9f1324-1641895055000,POINT (80.01240030621715 69.63828679990498),2022-01-11T09:57:35.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1641895317000,POINT (80.13819338413361 69.63828679990498),2022-01-11T10:01:57.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,
5798a065-d51e-47a1-b04b-ab48df9f1324-1641900233000,POINT (80.57844937597278 69.63828679990498),2022-01-11T11:23:53.000Z,5798a065-d51e-47a1-b04b-ab48df9f1324,1234-2222-3333-4444-55555,10.8,,1.23,5,1,0.0,,

P.S.S.S
For geom like BBOX I needed to have z2 index.
Why when I have z3 (POINT(lat,lon),time) index this query is long too
bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra export -P 10.200.217.24:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder -q "BBOX(geo, 79.0, 30.0, 81.0, 40.0) AND time AFTER 2021-09-23T13:05:00.0Z"
^C%                                                                              ✘  ~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra explain -P 10.200.217.24:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder -q "BBOX(geo, 79.0, 30.0, 81.0, 40.0) AND time AFTER 2021-09-23T13:05:00.0Z"
Planning 'SignalBuilder' BBOX(geo, 79.0,30.0,81.0,40.0) AND time AFTER 2021-09-23T13:05:00+00:00
  Original filter: BBOX(geo, 79.0,30.0,81.0,40.0) AND time AFTER 2021-09-23T13:05:00+00:00
  Hints: bin[false] arrow[false] density[false] stats[false] sampling[none]
  Sort: none
  Transforms: none
  Max features: none
  Strategy selection:
    Query processing took 35ms for 2 options
    Filter plan selected: FilterPlan[AttributeIndex(time)[time AFTER 2021-09-23T13:05:00+00:00][BBOX(geo, 79.0,30.0,81.0,40.0)](2.5)] (Cost 250 in 0ms)
    Filter plans not selected: FilterPlan[Z3Index(geo,time)[BBOX(geo, 79.0,30.0,81.0,40.0) AND time AFTER 2021-09-23T13:05:00+00:00][None](3.0)] (Cost 300 in 0ms)
    Strategy selection took 12ms for 2 options
  Strategy 1 of 1: AttributeIndex(time)
    Strategy filter: AttributeIndex(time)[time AFTER 2021-09-23T13:05:00+00:00][BBOX(geo, 79.0,30.0,81.0,40.0)](2.5)
    Plan: org.locationtech.geomesa.cassandra.data.StatementPlan
      Tables: gsm_events_SignalBuilder_attr_time_v8_02576, gsm_events_SignalBuilder_attr_time_v8_02579, gsm_events_SignalBuilder_attr_time_v8_02708, gsm_events_SignalBuilder_attr_time_v8_02711, gsm_events_SignalBuilder_attr_time_v8_02712, gsm_events_SignalBuilder_attr_time_v8_02713, gsm_events_SignalBuilder_attr_time_v8_02714, gsm_events_SignalBuilder_attr_time_v8_02715
      Ranges (32): SELECT * FROM geomesa.gsm_events_SignalBuilder_attr_time_v8_02576 WHERE shard=0 AND attrVal>'8000017c12c25c60';, SELECT * FROM geomesa.gsm_events_SignalBuilder_attr_time_v8_02576 WHERE shard=1 AND attrVal>'8000017c12c25c60';, SELECT * FROM geomesa.gsm_events_SignalBuilder_attr_time_v8_02576 WHERE shard=2 AND attrVal>'8000017c12c25c60';, SELECT * FROM geomesa.gsm_events_SignalBuilder_attr_time_v8_02576 WHERE shard=3 AND attrVal>'8000017c12c25c60';, SELECT * FROM geomesa.gsm_events_SignalBuilder_attr_time_v8_02579 WHERE shard=0 AND attrVal>'8000017c12c25c60';
      Client-side filter: BBOX(geo, 79.0,30.0,81.0,40.0)
      Reduce: class:LocalTransformReducer, state:{name=SignalBuilder, tnam=, tsft=, tdef=, hint=RETURN_SFT,"SignalBuilder,""*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double;geomesa.stats.enable='true',geomesa.z.splits='4',geomesa.feature.expiry='time(30 days)',geomesa.table.partition='time',geomesa.index.dtg='time',geomesa.indices='z3:7:3:geo:time,attr:8:3:time,attr:8:3:cam,attr:8:3:cam:time',geomesa.attr.splits='4',geomesa.z3.interval='week'""", spec=*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double;geomesa.stats.enable='true',geomesa.z.splits='4',geomesa.feature.expiry='time(30 days)',geomesa.table.partition='time',geomesa.index.dtg='time',geomesa.indices='z3:7:3:geo:time,attr:8:3:time,attr:8:3:cam,attr:8:3:cam:time',geomesa.attr.splits='4',geomesa.z3.interval='week', filt=BBOX(geo, 79.0,30.0,81.0,40.0)}
    Plan creation took 9061ms
  Query planning took 9324ms

It is return nothing, but takes about 5 minutes
~  bin/geomesa-cassandra_2.11-3.3.0/bin/geomesa-cassandra export -P 10.200.217.24:9042 -u cassandra -p cassandra -k geomesa -c gsm_events -f SignalBuilder -q "BBOX(geo, 79.0, 30.0, 81.0, 40.0) AND time AFTER 2021-09-23T13:05:00.0Z";
INFO  Running export - please wait...
id,*geo:Point,time:Date,cam:String,imei:String,dir:Double,alt:Double,vlc:Double,sl:Integer,ds:Integer,dir_y:Double,poi_azimuth_x:Double,poi_azimuth_y:Double

Thank you!

A: The query is slow because it's doing a full scan of all your data. If you look at the explain output, you'll see:
Ranges (8): SELECT * FROM geomesa.gsm_events_SignalBuilder_z3_geo_time_v7_02576;...
Client-side filter: DWITHIN(geo, POINT (80.57944937597279 69.63928679990498), 130.0, meters)

If you want to query just by spatial predicates, you should re-enable the z2 index, which is designed for this use case. See Index Overview and Customizing Index Creation in the GeoMesa documentation for details.


text:
Q: How can this query be improved to be faster? I am trying to make a search in a db which contains tables poems and authors. I am using replace function to ignore accent characters in db while making the search.
If the title column matches the input it gets high order in search results.
If the content matches the input it gets a lower order in search results.
The below query works correctly but I want it to be faster.
I considered an extra column that will hold the accent-ignored copies of content and title columns but this almost doubles the db size so I skipped that option. It is around 7mb now. Since it is a mobile app, I don't want its size grow to 15mb just to ignore the accents.
Select poems._id, title, name, surname, photoName
from poems,authors
where ( replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(content, 'Â','a'),'İ','i'),'Î','i'),'Û','u'),'I','i'),'Ş','s'),'Ç','c'),'Ğ','g'),'Ö','o'),'Ü','u'),'â','a'),'ş','s'),'ı','i'),'ö','o'),'ç','c'),'ü','u'),'ğ','g'),'î','i'),'û','u'),'''','')
        LIKE '%input%'
      OR
        replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(title, 'Â','a'),'İ','i'),'Î','i'),'Û','u'),'I','i'),'Ş','s'),'Ç','c'),'Ğ','g'),'Ö','o'),'Ü','u'),'â','a'),'ş','s'),'ı','i'),'ö','o'),'ç','c'),'ü','u'),'ğ','g'),'î','i'),'û','u'),'''','')
        LIKE '%input%')
  AND authors._id = poems.authorId
ORDER BY (CASE WHEN replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(title, 'Â','a'),'İ','i'),'Î','i'),'Û','u'),'I','i'),'Ş','s'),'Ç','c'),'Ğ','g'),'Ö','o'),'Ü','u'),'â','a'),'ş','s'),'ı','i'),'ö','o'),'ç','c'),'ü','u'),'ğ','g'),'î','i'),'û','u'),'''','')
                    LIKE 'input%' THEN 1
               WHEN replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(title, 'Â','a'),'İ','i'),'Î','i'),'Û','u'),'I','i'),'Ş','s'),'Ç','c'),'Ğ','g'),'Ö','o'),'Ü','u'),'â','a'),'ş','s'),'ı','i'),'ö','o'),'ç','c'),'ü','u'),'ğ','g'),'î','i'),'û','u'),'''','')
                    LIKE '%input%' THEN 2
               WHEN replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(content, 'Â','a'),'İ','i'),'Î','i'),'Û','u'),'I','i'),'Ş','s'),'Ç','c'),'Ğ','g'),'Ö','o'),'Ü','u'),'â','a'),'ş','s'),'ı','i'),'ö','o'),'ç','c'),'ü','u'),'ğ','g'),'î','i'),'û','u'),'''','')
                    LIKE '%input%' THEN 3
               ELSE 4 END)

A:
I considered an extra column that will hold the accent-ignored copies
  of content and title columns but this almost doubles the db size so I
  skipped that option.

Do this. Add the extra column. The cost of the additional memory is nothing compared to anything else you try.

redpajama_set_name: RedPajamaStackExchange


text:
Q: In Serverless Framework, is there a way update environment variables populated by ssm variables at lambda runtime? I'm using serverless.yml ssm variables (AWS parameter store) to set lambda environment variables. They're looked up and set at Serverless deploy time. I'd like the environment variables to be up to date at lambda runtime, so that I can change them in parameter store and not re-deploy. Is there a way to achieve this with Serverless?
P.S. I know I could achieve this by looking them up in my lambda code instead of relying on Serverless to set them. I'd just like to know if Serverless has this capability.

A: Call the SSM client from your code:
const SSM = require('aws-sdk/clients/ssm')

const getParameter = async (paramName) => {
   const client = new SSM()

  try {
    const { Parameter } = await getSSMClient()
      .getParameter({ Name: paramName })
      .promise()

    return Parameter.Value ? JSON.parse(Parameter.Value) : null
  } catch (e) {
    console.error(e)
  }
}

You can put this outside of your default handler export which will call it only on lambda launch (which might be less than on invoke depending on traffic)
const foo = await getParameter('foo')
module.exports = (event, context) => {
 console.log(foo)
 ...
}

But as far as redeploying - it can be extremely fast. I personally separate my stuff into multiple services and redeploying lambda is a separate process than say DynamoDB setup so it goes fast.

A: Environment variables are designed to be set at deployment because they pertain to the environment of the Lambda. If you need values that are changed regularly there are many other options; DynamoDB sticks out as the perfect solution to that issue. If all you need is a Key Value store (which is what environment variables are), then DynamoDB absolutely excels. Its super fast and way cheaper than SSM that can be used to do the same thing.


text:
Q: Looking for a +simple php framework for a rapid deployment I'm looking for a very, very simple php framework that has a simple mysql database class and routing built-in. A default style would be great. If it's geared toward html5 or mobile devices, perfect.
I know there are several out there, but I'd like to get the consensus.

A: I'd recommend you use CodeIgniter - it's not really all that small and probably has a few featured you don't need, but it's easiest to pick up I feel
In terms of the style/theme, I'd throw Foundation in to the mix or alternatively, Twitter's Bootstrap (however Foundation has built-in responsive layout)

A: Sounds like you want a micro-framework.
Flight - a fast, simple, extensible micro-framework
Slim - a Sinatra clone in PHP
FatFree - a single file framework with lots of features
Limonade - another framework inspired by Sinatra
Klein - a lightning fast router for PHP
Silex - a micro-framework from the Symfony developers


text:
Q: Unable to select a column on sqlite3 database I am trying to select a particular column of a table in a sqlite database. I am using the following:
cursor = connection.execute('select Case from SUMMARY')
Even though the column name is correct, whenever I run the code, i receive the following error.
The same happens when I try to fetch the column index.
Whenever i try any other column, I can fetch all the column's data.
OperationalError                          Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_15288/2883478922.py in <module>
      1 import sqlite3
      2 connection = sqlite3.connect("../DB_Cases.sqlite")
----> 3 cursor = connection.execute('select Case from SUMMARY')

OperationalError: near "from": syntax error

A: case is reserved keyword in SQLite.
Using double quotes in the query as mentioned in the SQLite documentation should get your query working.


text:
Q: Unable to run clisp on Solaris 10 with opencsw Solaris Package I have tried to run the Clisp which is already available in opt/csw/bin path
I didn't manage to get it working.
Expected result:
To see a prompt.
Actual results (terminal output):

*

*when I tried to run clisp using ./clisp inside the path opt/csw/bin,
I get the below error.
# ./clisp
ld.so.1: lisp.run: fatal: libavcall.so.0: open failed: No such file or directory
Killed

*I tried to list available library for the package clisp, I get the
following but no libavcall.so.0 file is present.
# ldd clisp
libc.so.1 =>     /lib/libc.so.1
libm.so.2 =>     /lib/libm.so.2

What I tried to fix the issue:

*

*Updated the package, still throws the same error after running ./clisp command.

*Added /opt/csw/bin to the path variable, still the error persists.

My Observations:

*

*I tried to run ldd clisp command on the root path, I get
# ldd clisp
ldd: clisp: cannot open file: No such file or directory

*When I tried to run the same command after entering into the path
opt/csw/bin, I get
# ldd clisp
libc.so.1 =>     /lib/libc.so.1
libm.so.2 =>     /lib/libm.so.2

I tried to follow the instructions given in the below link:
https://www.opencsw.org/package/clisp/
Did I miss anything to install clisp so I am getting this error? I am new to clisp. Any help to resolve the issue is appreciated.


text:
Q: Delete by field value [MEAN] I'm learning MEAN stack. I want to perform CRUD operations and I'm using mongoose. I am following this question on stackoverflow. I want to delete a document by specific value. In my case it is an article with a unique articleid which should get deleted. Unknowingly I'm doing some terrible mistake with params. Please correct me.
Sample document in mongodb.
{
  _id: objectId("5d77de7ff5ae9e27bd787bd6"),
  articleid:"art5678",
  title:"Installing JDK 8 in Ubuntu 18.04 and later",
  content:"
Step 1: Add repository

$ sudo add-apt-repository pp..."
  date:"Tue, 10 Sep 2019 17:33:51 GMT"
  contributor:"Tanzeel Mirza",
  __v:0
}

article.component.html

{{article.title}}

          Delete

(click)="onPress(article.articleid") calls a method in ts file.
article.component.ts
import { Component, OnInit } from '@angular/core';
import { ArticleService } from '../article.service';

@Component({
  selector: 'app-articles',
  templateUrl: './articles.component.html',
  styleUrls: ['./articles.component.css']
})
export class ArticlesComponent implements OnInit {

  articles = []

  constructor(private _articleService: ArticleService) { }

  ngOnInit() {
    this._articleService.getEvents()
    .subscribe(
      res => this.articles = res,
      err => console.log(err)
    )
  }

  onPress(id) {
    this._articleService.deleteArticle()
    .subscribe (
      data => {
        console.log("hello");
      }
    );
  }
}

I have created a service article.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class ArticleService {
  private _deleteUrl = "http://localhost:3000/api/delete/:id";
  constructor(private http: HttpClient) { }
  getAllArticles() {
    ...
  }

  deleteArticle(id) {
    return this.http.delete<any>(this._deleteUrl);
  }
}

And here is my api.js
const express = require('express');
const router = express.Router();
const mongoose = require('mongoose');
const Article = require('../models/article');
const dbstring = ...

mongoose.connect(dbstring, { useNewUrlParser: true }, err => {
  ...
})

router.delete('/delete/:id', (req, res) => {
  let articleData=req.params.id;

  console.log(articleData); //Output: {}
  console.log('on delete url '+articleData); //Output: on delete url undefined

  Article.deleteOne({articleid: articleData}, (error, article) => {
    if(error) {
      console.log(error)
    }
    else {
      if(!article) {
        res.status(401).send('Something went wrong')
      }
      else {
        //res.json(article);
      }
    }
  })
})

module.exports = router;

Ok dont write the code for me, but please at least tell me some study material.

A: Ok. I did more and more research and figured out the problem. Here are the changes.
api.js
router.delete('/delete/:id', (req, res) => {
  let articleId=req.params.id;
  Article.deleteOne({articleid: articleId}, (error, article) => {
    if(error) {
      console.log(error)
    }
    else {
      if(!article) {
        ...
      }
      else {
        ...
      }
    }
  })
})

and article.service.ts
private _deleteUrl = "http://localhost:3000/api/delete";
deleteArticle method should be.
deleteArticle(id) {
    return this.http.delete<any>(this._deleteUrl+'/'+id);
}


text:
Q: Are operating systems able to run on different hardware? My friend boots Linux from an external hard disk (500 GB). My question is he installs the operating system for one particular motherboard processor; the system may have additional stuff like a graphics card, etc, etc. What if he plugs this disk to another completely different machine and tries to boot. Will the OS load/boot?

A: It depends.
It might boot but run the hardware in some sort of standard mode - for example running the graphics card at a low resolution with no accelerated 3D graphics.
Or it might not boot at all.
For Windows XP it will probably detect the graphics card and other peripherals as new hardware and try to load new drivers, but might not boot for a new motherboard. It will mean that when you plug the hard drive back into your original machine it will try to load new drivers again.
For Linux I'm not so sure, but it might work more often than not.

A: Linux installations are specific to a processor type. An amd64¹ installation will only work on an amd64 processor. An ix86 installation will only work on an i386 processor (but all amd64 processors are ix86-compatible). A powerpc installation will only work on a powerpc processor. And so on.
Beyond that, unless the installation has been tweaked in a way that's irrelevant to ~99% of Linux users, there's only one setting that might depend on the hardware: many systems need a specific video driver to take advantage of their graphics card. If the system on the drive is configured to use a driver for the wrong graphics card, or not to use a driver that the graphics card requires, the driver may be ignored, and the GUI may not appear (you'll just get a text mode login prompt).
¹
amd64 means "64-bit PC". Intel makes such processors as well as AMD.

A: It depends on the OS, and how it is setup.
For my portable Arch Linux installation I made sure to, in the boot loader, address the disk by UUID (instead of /dev/sdX) so it would always find the correct disk when trying to boot in a different machine with different numbers/arrangements of disks.


text:
Q: Parallel reduction using local memory in OpenCL I implemented a reduce kernel in OpenCL to sum up all entries in the input vector of size N. For a easier testing I initialize the input vector with 1.0f. So the result should be N. But it is not!
Here is my reduce-kernel:
kernel void reduce(global float* input, global float* output, const unsigned int N, local float* cache)
{
    const uint local_id = get_local_id(0);
    const uint global_id = get_global_id(0);
    const uint local_size = get_local_size(0);

    cache[local_id] = (global_id < N) ? input[global_id] : 0.0f;
    barrier(CLK_LOCAL_MEM_FENCE);

    for (unsigned int s = local_size >> 1; s > 0; s >>= 1) {
        if (local_id < s) {
            cache[local_id] += cache[local_id + s];
        }
        barrier(CLK_LOCAL_MEM_FENCE);
    }

    if (local_id == 0) output[local_size] = cache[0];
}

And here is the setting for OpenCL:
 const uint N = 8196;

 cl_float a[N];
 cl_float b[N];

 for (uint i=0; i<N; i++) {
      a[i] = 1.0f;
      b[i] = 0.0f;
 }

 cl::Buffer inputBuffer(context, CL_MEM_WRITE_ONLY, sizeof(cl_float)*N);
 cl::Buffer resultBuffer(context, CL_MEM_READ_ONLY, sizeof(cl_float)*N);

 queue.enqueueWriteBuffer(inputBuffer, CL_TRUE, 0, sizeof(cl_float)*N, a);
 queue.enqueueWriteBuffer(resultBuffer, CL_TRUE, 0, sizeof(cl_float)*N, b);

 cl::Kernel addVectorKernel = cl::Kernel(program, "reduce");

 size_t localSize = addVectorKernel.getWorkGroupInfo<CL_KERNEL_WORK_GROUP_SIZE>(device); // e.g. => 512

 size_t globalSize = roundUp(localSize, N); // rounds up to a multiple of localSize

 addVectorKernel.setArg(0, inputBuffer);
 addVectorKernel.setArg(1, resultBuffer);
 addVectorKernel.setArg(2, N);
 addVectorKernel.setArg(3, (sizeof(cl_float) * localSize), NULL);

 queue.enqueueNDRangeKernel(
      addVectorKernel,
      cl::NullRange,
      cl::NDRange(globalSize),
      cl::NDRange(localSize)
 );
 queue.finish(); // wait for ending

 queue.enqueueReadBuffer(resultBuffer, CL_TRUE, 0, sizeof(cl_float)*N, b); // e.g. => 1024

The result depends on the workgroup size. What am I doing wrong? Is it the kernel itself or is it the settings for OpenCL?

A: You should be using the group's id when writing the sum back to global memory.
if (local_id == 0) output[local_size] = cache[0];

That line will write to output[512] repeatedly. You need each work group to write to a dedicated location in the output.
kernel void reduce(global float* input, global float* output, const unsigned int N, local float* cache)
{
    const uint local_id = get_local_id(0);
    const uint global_id = get_global_id(0);
    const uint group_id = get_group_id(0);
    const uint local_size = get_local_size(0);

    cache[local_id] = (global_id < N) ? input[global_id] : 0.0f;
    barrier(CLK_LOCAL_MEM_FENCE);

    for (unsigned int s = local_size >> 1; s > 0; s >>= 1) {
        if (local_id < s) {
            cache[local_id] += cache[local_id + s];
        }
        barrier(CLK_LOCAL_MEM_FENCE);
    }

    if (local_id == 0) output[group_id] = cache[0];
}

Then you need to sum the values from the output on the host. Note that 'b' in the host code does not need to hold N elements. Only one element for each work group will be used.
//replace (globalSize/localSize) with the pre-calculated/known number of work groups
for (i=1; i<(globalSize/localSize); i++) {
    b[0] += b[i];
}

Now b[0] is your grand total.

A: In the reduction for loop, you need this:
for(unsigned int s = localSize >> 1; s > 0; s >>= 1)

You are shifting one more bit than you should when initializing s.
After that's fixed, let's look at what your kernel is doing. The host code executes it with globalSize of 8192 and localSize of 512, which results in 16 work groups. Inside the kernel you first sum the data from the two consecutive memory locations at index 2*global_id. For work group with id 15, work item 0, that will be at index 15*512*2 = 15,360 and 15,361, which is outside the boundaries of your input array. I am surprised you don't get a crash. At the same time, this explains why you have double the values that you expect.
To fix it, you can do this:
cache[localID] = input[globalID];

Or specify a global size that's half of the number of the current one.


text:
Q: How can I solve the error "Dataset was not found in location US" in BigQuery? I'm trying to run some tests with Google BigQuery to calculate data from my Google Spreadsheets. When trying to run the code, I am getting the error: "Dataset was not found in location US".
I have already tried processing the site in "Automatic" or "EU" in the query settings but neither of each has brought any useful results.
The code I used is this one here:
SELECT a.Customer AS Customer,
       round(100.00*sum(b.Online_Sales)/sum(a.Sales), 2) AS PctOnlineSales
FROM
    Dataset.Big_Data_Test_1_Sales a
JOIN
    Dataset.Big_Data_Test_1_Online_Sales b
ON a.Customer = b.Customer
--WHERE a.Customer IN ('1002')
GROUP BY 1
ORDER BY 1

I expected to multiply the data of two sheets that are schemed in my dataset.
Can you guys help me fix the location issue?
Thanks in advance!
Nes

A: Add your project Id before the dataset so BigQuery can locate it. This is an example based on your code
SELECT a.Customer AS Customer,
       round(100.00*sum(b.Online_Sales)/sum(a.Sales), 2) AS PctOnlineSales
FROM
 ProjectId.Dataset.Big_Data_Test_1_Sales a
JOIN ProjectId.Dataset.Big_Data_Test_1_Online_Sales b
ON a.Customer = b.Customer
--WHERE a.Customer IN ('1002')
GROUP BY 1
ORDER BY 1```

A: FROM
Dataset.Big_Data_Test_1_Sales a
project_id was missing from the above syntax, thats why it returns "Dataset not found in location US".


text:
Q: Twitter bootstrap popover close all before opening a new one I'm not JavaScript wizard, so I'm missing something obvious here I'm sure. I have a unorder-list  that has multiple links & When user do hover on the
 then they can see the link to click on it in order to see  Twitter Bootstrap's pop-over behavior.
My problem is

*

*It does not closes previous pop-over if i open a new one.

*And also it does show  up again the tweet link if again mouse over on the same "Tweet" image.

Here is fiddle http://jsfiddle.net/ZnJ6b/17/ , please take a look & try to help me.
js code looks like
 $("[data-toggle='popover']").popover({
    placement: 'right',
    html: 'true',
    title : 'title',
    content : '<input id="subproject_id" type="text"/>'
});

$('.add_btn').click(function(e) {
          $('.popover-title').append('<button id="popovercloseid" type="button" class="close">×</button>');
         $("#subproject_id").focus();//textbox focus
          $(this).css("display","inline");
          $(this).removeClass( "add_btn" ).addClass( "new_add_btn" );
      });
  $(document).click(function(e) {
     if(e.target.id=="popovercloseid" ) {
          $('.new_add_btn').popover('hide');
          $('.new_add_btn').css("display","none");
          $('.new_add_btn').removeClass( "new_add_btn" ).addClass( "add_btn" );

     }

  });

http://blog.alysson.net/lang/pt-br/twitter-bootstrap-popover-close-all-before-opening-a-new-one/  is the link seems tutorial, but i am unable to implement it to above code. Any help please?

A: Your code has some unnecessary lines that deflect the behavior of the popover.
I've commented some of the lines and added this statement:
$('.add_btn').not(this).popover('hide');

so that only one popover is displayed at a time.
Demo
This bit of code to close your popover with a button:
$('html').on('click', '#popovercloseid', function (e) {
        $('.add_btn').not(this).popover('hide');
 });

Demo 2

A: this actually fix the issue:
$('.popover').each(function() { $(this).modal('hide'); });


text:
Q: Material UI multiple dropdown menus in navbar I am trying to create a navbar with a series of material ui dropdown menus, but I am running into an issue that I can't seem to solve. When I click a navbar item all of the dropdowns open on top of each other under the menu item I clicked. Below is the code:
import styles from "./AppNav.module.css";
import { navData } from "./navData.js";
import Link from "next/link";
import {Button, Menu, MenuItem } from '@mui/material';
import { style } from "@mui/system";
import { useState } from "react";

export default function AppNav(props:any){
    const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
    const open = Boolean(anchorEl);
    const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
      setAnchorEl(event.currentTarget);
    };
    const handleClose = () => {
      setAnchorEl(null);
    };
    return(
        <>

<Button><Link className={styles.homeLink} href="/">Home</Link></Button>

            {navData.map((navItem, index) => {
                return

                    <Button
                        id={navItem.navHeading}
                        key={navItem.id}
                        aria-controls={open ? navItem.navHeading : undefined}
                        aria-haspopup="true"
                        aria-expanded={open ? 'true' : undefined}
                        onClick={handleClick}
                    >
                        {navItem.navHeading}
                    </Button>
                    <Menu
                        id={navItem.navHeading}
                        anchorEl={anchorEl}
                        open={open}
                        onClose={handleClose}
                        MenuListProps={{
                            'aria-labelledby': navItem.navHeading,
                        }}
                    >
                        {navItem.lvlTwo.map((subNav, index) =>
                            <MenuItem
                                key={index}
                                onClick={handleClose}
                            >
                                <Link href={subNav.link}>
                                    {subNav.subNavHeading}
                                </Link>
                            </MenuItem>
                        )}
                    </Menu>

            })}

        </>
    )
}

and the data:
   {
        id: 2,
        navHeading: 'Merchant',
        link: '',
        hasSubs:true,
        lvlTwo:[
            {
                subNavHeading: 'Statement',
                link:"Merchant/Statement.tsx",
            },
            {
                subNavHeading: 'Invoice',
                link:"",
            },
            {
                subNavHeading: 'Transaction Lookup',
                link:"",
            },{
                subNavHeading: 'Batch Lookup',
                link:"",
            },{
                subNavHeading: 'Funding Lookup',
                link:"",
            },{
                subNavHeading: 'Funded Transaction',
                link:"",
            },{
                subNavHeading: 'Statement',
                link:"",
            },{
                subNavHeading: 'Submitted Transaction',
                link:"",
            },{
                subNavHeading: 'Returns',
                link:"",
            }
        ]
    },{
        id: 3,
        navHeading: 'Partner',
        link: '',
        hasSubs:true,
        lvlTwo:[
            {
                subNavHeading: 'Statement',
                link:"",
            },{
                subNavHeading: 'Invoice',
                link:"",
            },{
                subNavHeading: 'Funded Transaction',
                link:"",
            },{
                subNavHeading: 'Submitted Transaction',
                link:"",
            },
        ]
    },{
        id: 4,
        navHeading: 'Processing',
        link: '',
        hasSubs:true,
        lvlTwo:[
            {
                subNavHeading: 'Transaction Detail',
                link:"",
            },{
                subNavHeading: 'Transaction Summary',
                link:"",
            },{
                subNavHeading: 'Transactions By Merchant',
                link:"",
            },{
                subNavHeading: 'Transactions By Batch',
                link:"",
            },{
                subNavHeading: 'Return Summary',
                link:"",
            },{
                subNavHeading: 'Boarding Stats',
                link:"",
            },{
                subNavHeading: 'Risk Summary',
                link:"",
            },{
                subNavHeading: 'Uncollected Invoices/ACH Exceptions',
                link:"",
            },{
                subNavHeading: 'ACH Exceptions',
                link:"",
            },{
                subNavHeading: 'Unsettled Transation Voids',
                link:"",
            },{
                subNavHeading: 'Bank account Update Logs',
                link:"",
            },
        ]
    },{
        id: 5,
        navHeading: 'Accounting',
        link: '',
        hasSubs:true,
        lvlTwo:[
            {
                subNavHeading: 'Returns',
                link:"",
            },{
                subNavHeading: 'Compensation',
                link:"",
            },{
                subNavHeading: 'Income Statement',
                link:"",
            },{
                subNavHeading: 'Income/Charges',
                link:"",
            },{
                subNavHeading: 'Processing Balances',
                link:"",
            },{
                subNavHeading: 'Return Balances',
                link:"",
            },{
                subNavHeading: 'Colonnade 1099k',
                link:"",
            },{
                subNavHeading: 'Colonnade 1099k Summary',
                link:"",
            },{
                subNavHeading: 'ODFI Exposure',
                link:"",
            },{
                subNavHeading: 'File Entries',
                link:"",
            },{
                subNavHeading: 'Activated Merchant',
                link:"",
            },{
                subNavHeading: 'Aging Deposits',
                link:"",
            },
        ]
    },
]

I don't understand how to make only the one menu item open at a time.

A: You have one open prop for all of the menus.
Try to store opened menu name or id and then in menu check if current menu name\id is equal to one that you store in state.
UPDATE
I'll add here a basic explanation, this wouldn't be with your actual code, just a minimal example to get you some better understanding
const menus = ["profile", "items", "cart"];

const Menu = () => {
  const [openedItem, setOpenedItem] = useState("") // here you can set some menu item so it can be opened by default

  const handleMenuItemOpen = (itemId) => {
    setOpenedItem(itemId)
  }

  return (
    <Menu>
       {menus.map(menuItem => (
          <MenuItemComponent
             isOpened={openedItem === menuItem}
             handleOpen={() => setOpenedItem(menuItem)}
          >
            {menuItem}
          </MenuItemComponent>
       ))}
    </Menu>
  )
}

(Menu and MenuItemComponent are just some abstract components, in your case you should use what you are currently use, I used them just to get rid of a lot of code and make more focus on main part)
This is just a basic example. Here is what happened here, when you click on some item, you set its id (any unique property that you have, in case of predefined static list of menus you can use even index of menu item, it will not affect your app behavior, but I do not recommend using indexes just because you can develop a bad habit), and when you render your menu items components, it will check for each component is it's id equal to id that is currently set as opened. So only one component will have an isOpened={true} in case if you have unique menu items list.
In your case, you have one boolean prop "open" that you use for all of your menu items, so when it became true, each of your menu items became opened.
Hope it helped!


text:
Q: $@ stores every argument into the first index So, in a script I have this at the top:
declare -ar OPT=$1
shift
declare -ar FLAGS=$@

And then, later in the script it has this:
echo ${FLAGS[0]}

So, if you use commandname opt flag1 flag2 flag3, you would expect it to echo flag1, but instead, it echos every argument, flag1 flag2 flag3. This clearly isn't supposed to happen, but I have no idea why it happens.

A: Even if the array attribute on FLAGS is set, assigning to the name with a regular assignment still just assigns something to the first element. You want
declare -ar FLAGS=("$@")

You might notice the -a option becomes redundant, as any assignment of the form x=(...) automatically sets the array attribute.


text:
Q: Symbols or Case Classes for sending messages to Scala Actors? In the Scala actor examples I have seen where a parameterless message is sent to an actor (such as this), case classes (or case objects) have been created and then used as messages. Symbols work just as well and look a bit neater and, after reading a book on Erlang, seem more natural. I assume that symbol equality would work for remote actors.
For messages with parameters case classes would be the obvious choice, so perhaps consistency between message types is one issue?
Are there any reasons to go for either approach?

A: The short answer is compile-time checking.
Even thought symbols can be used as messages and they are even more succinct than case objects (no need to define them), compiler can not detect the misspelled symbols and you will have a hard time figuring out why actors aren't receiving specific messages when they are supposed to.
If case classes and/or objects are used as messages, compiler will tell you if you are trying to send and/or receive non-existent messages before the program is even executed.

A: I don't think that Symbols are a substitute for using case classes. In fact, I'm not entirely sure what use Symbol is at all, given it lacks the power of symbols in other languages (e.g. Ruby, Smalltalk) - it's just an interned String.
For example, in the standard auction example, it's difficult to see how you would represent the complexity of a bid / offer using symbols alone.
As for case objects, I also believe that these are preferable to symbols. For example, they can be instances of traits etc, and hence supply functionality.


text:
Q: add new event to button protected void Page_Load(object sender, EventArgs e)
{
        Button a = new Button();
        a.Width = 100;
        a.Height = 100;
        a.Text = "one";
        a.Click += new EventHandler(test);
        form1.Controls.Add(a);
}

protected void test(object sender, EventArgs e)
{
    Button b = new Button();
    b.Width = 100;
    b.Height = 100;
    b.Text = "two";
    b.Click += new EventHandler(test2);
    form1.Controls.Add(b );
    Response.Write("aaaaaaaaaaaaaaaaaa");
}

protected void test2(object sender, EventArgs e)
{
    Response.Write("bbbbbbbbbbbbbbb");
}

when click on one show Button two but when click on twobutton does not run test2????
when click on two page refresh.
i want first click on 'one' and then 'two'
show the button only after button a has been clicked

A: Try this:
protected void Page_Init(object sender, EventArgs e)
{
    Button a = new Button();
    a.Width = 100;
    a.Height = 100;
    a.Text = "one";
    a.Click += new EventHandler(test);
    form1.Controls.Add(a);

    Button b = new Button();
    b.Visible = false;
    b.Width = 100;
    b.Height = 100;
    b.Text = "two";
    b.Click += new EventHandler(test2);
    form1.Controls.Add(b);
}

protected void test(object sender, EventArgs e)
{
    b.Visible = true;
    Response.Write("aaaaaaaaaaaaaaaaaa");
}

protected void test2(object sender, EventArgs e)
{
    Response.Write("bbbbbbbbbbbbbbb");
}

A: You have to recreate dynamic controls (such as your new button b) and associate their event handlers again on each postback. Thus, you need to move the code from test to Page_Load. If you want to show the button only after button a has been clicked, either make button b invisible (simple  solution) or store some Boolean in the viewstate that triggers creation of b (more complicated solution).

A: Each time an ASP page is accessed (or refreshed), the object is recreated and the Page_Load event is run. This means that when you hit the first button, the second is created and the event is subscribed to in that instance of the page object.
When you hit the button the next time, a new page object is created and in that page object the event has never been subscribed to.
Creating controls dynamically is often a bad idea, instead create all controls and hide those that you don't want to display right away. Also you should add a check for IsPostBack in your page load, so that you can differentiate between first-time initialization and when the object is recreated on postback.


text:
Q: "Plot.new has not been called yet" issue using plot() Here is the code:
barplot(avg_df_deer, col = c("chartreuse3", "cornflowerblue"),
        xlab = "Week",
        ylab = "Average Number of Deer Tick Incidents", main = "Average Number of Deer Tick Incidents From\n2006 to 2019",
        ylim =c(0, 0.35))
legend(x = 10, y = 0.35, legend = c("Deer found", "Deer bite"), fill = c("chartreuse3", "cornflowerblue"), xpd=TRUE)


text:
Q: UI getting set repeatedly - Data binding, MVVM, Navigation Components I am using databinding and MVVM in my current project. Here's the code to one of the screens I am working on :
class ActivePlansFragment : Fragment() {

    private lateinit var savingPlanViewModel: SavingPlanViewModel
    private var isFinancialFreedomPlanOpted = false

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        printLog("On Create View")
        return inflater.inflate(R.layout.fragment_active_plans, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        savingPlanViewModel = activityViewModels {
            printLog("Setting Adapter For Active plans")
            rvAllPlans.apply {
                adapter = ActivePlansAdapter().apply {
                    mBaseAdapterClickListener = { view, position, item ->
                        if( view.id == R.id.tvAction ) {
                            if( isCurrentDestination(R.id.savingPlanListFragment) ) {
                                selectedNeoSavingPlan = item
                                findNavController().navigate(SavingPlanListFragmentDirections.actionSavingPlanListFragmentToAddFundsFragment())
                            }
                        } else {
                            if( isCurrentDestination(R.id.savingPlanListFragment) ) {
                                selectedNeoSavingPlan = item
                                findNavController().navigate(SavingPlanListFragmentDirections.actionSavingPlanListFragmentToSavingPlanDetailsFragment())
                            }
                        }
                    }
                    onEmptyOrNot = { isEmpty ->
                        emptyPlansLayout.changeVisibility(isEmpty)
                    }
                    //Update : getAllSavingPlan()
                    observe(allSavingPlanResponsesMutableLiveData) {
                        it?.onChanged { inProgress, failure, list ->
                            //fabCreatePlan.isEnabled = !inProgress
                            planRefreshLayout.isRefreshing = inProgress
                            if (!inProgress)
                                if (failure != null) {
                                    handleFailures(failure) { getAllSavingPlan() }
                                    allSavingPlanResponsesMutableLiveData.clearValue()
                                } else if (list != null) {
                                    removeAll()
                                    val filteredList = list.filter { plan ->
                                        plan.active
                                                || plan.status == NeoSavingPlanResponse.COMPLETED
                                                || plan.status == NeoSavingPlanResponse.CREATE_INITIATED
                                                || plan.status == NeoSavingPlanResponse.DELETE_INITIATED
                                    }
                                    addAll(filteredList)
                                    isFinancialFreedomPlanOpted = list.find { plan -> plan.planType == NeoMasterSavingPlan.FINANCIAL_FREEDOM_PLAN } != null
                                }
                        }
                    }
                }
            }
            planRefreshLayout.setOnRefreshListener {
                getAllSavingPlan()
            }
        }

    }
}

The problem I am facing is the adapter and the rest of the logic is getting set all over again when I navigate back to the screen. I am looking for some help in terms of where to set the UI logic so as to avoid resetting the UI.
> Logcat logs :
>
> D/ActivePlansFragment: On Create View
> D/ActivePlansFragment: Setting Adapter For Active plans
> D/ActivePlansFragment: On Create View
> D/ActivePlansFragment: Setting Adapter For Active plans

Update : I moved the plan fetch logic to onResume, that handled the flicker of UI. But the adapter is set again when user comes back to the screen. This has to do with the fragment lifecycle so I am thinking there is no way around this. Correct me if I am wrong.
override fun onResume() {
        super.onResume()
        savingPlanViewModel.getAllSavingPlan()
 }

Additional Note : I am using android navigation components.
The fragment itself is a part of a parent fragment with viewpager in its xml. The viewpager is a host to active / inactive plans child fragments. The parent class view pager has the offscreen page limit set to 2.
savingPlanViewPager.adapter = SavingPlanViewPagerAdapter(childFragmentManager)
savingPlanViewPager.offscreenPageLimit = 2
savingPlanTabLayout.setupWithViewPager(savingPlanViewPager)

A: I ended up using lazy initialisation to set the adapter only once. Here's the solution in case someone is looking for it :
class ActivePlansFragment : Fragment() {

    private lateinit var savingPlanViewModel: SavingPlanViewModel
    private var isFinancialFreedomPlanOpted = false
    private val navController : NavController by lazy { findNavController() }

    private val adapterClickListener : ((view : View, position : Int, item : NeoSavingPlanResponse) -> Unit) = { view, _, item ->
        if( view.id == R.id.tvAction ) {
            if( isCurrentDestination(R.id.savingPlanListFragment) ) {
                savingPlanViewModel.selectedNeoSavingPlan = item
                navController.navigate(SavingPlanListFragmentDirections.actionSavingPlanListFragmentToAddFundsFragment())
            }
        } else {
            if( isCurrentDestination(R.id.savingPlanListFragment) ) {
                savingPlanViewModel.selectedNeoSavingPlan = item
                navController.navigate(SavingPlanListFragmentDirections.actionSavingPlanListFragmentToSavingPlanDetailsFragment())
            }
        }
    }

    private val onEmptyAdapterListener : ((isEmpty: Boolean) -> Unit) = {
            isEmpty -> emptyPlansLayout.changeVisibility(isEmpty)
    }

    private val activePlansAdapter: ActivePlansAdapter by lazy {
        ActivePlansAdapter().apply {
            mBaseAdapterClickListener = adapterClickListener
            onEmptyOrNot = onEmptyAdapterListener
        }
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_active_plans, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        savingPlanViewModel = activityViewModels {
            getAllSavingPlan()
        }
        rvAllPlans.apply { adapter = activePlansAdapter }
        planRefreshLayout.setOnRefreshListener { savingPlanViewModel.getAllSavingPlan() }
        setupObserver()
    }

    private fun setupObserver() {
        savingPlanViewModel.apply {
            observe(allSavingPlanResponsesMutableLiveData) {
                it?.onChanged { inProgress, failure, list ->
                    planRefreshLayout.isRefreshing = inProgress
                    if (!inProgress)
                        if (failure != null) {
                            handleFailures(failure) { savingPlanViewModel.getAllSavingPlan() }
                            allSavingPlanResponsesMutableLiveData.clearValue()
                        } else if (list != null) {
                            activePlansAdapter.removeAll()
                            val filteredList = list.filter { plan ->
                                plan.active
                                        || plan.status == NeoSavingPlanResponse.COMPLETED
                                        || plan.status == NeoSavingPlanResponse.CREATE_INITIATED
                                        || plan.status == NeoSavingPlanResponse.DELETE_INITIATED
                            }
                            activePlansAdapter.addAll(filteredList)
                            isFinancialFreedomPlanOpted = list.find {
                                    plan -> plan.planType == NeoMasterSavingPlan.FINANCIAL_FREEDOM_PLAN
                            } != null
                        }
                }
            }
        }
    }

}

The onCreateView is bound to trigger over and over again, however, we can control the adapter and data initialisation via lazy as illustrated in the above code.


text:
Q: How to get all elements from webpage using Selenium? My Python code is only finding the first article of the HTML, so it is printing the same link. How do I get all article tags from the HTML? Thanks.
Python code:
links = driver.find_elements_by_tag_name("article")
for i in links:
    if driver.find_element_by_xpath("//div[@class='inner-article']/a//div[@class='sold_out_tag']").get_attribute("innerHTML") == "sold out":
        print("sold out")
        link = ((driver.find_element_by_xpath("//div[@class='inner-article']/a").get_attribute("href")))
        print(link)
    else:
        print("available")
time.sleep(5)
driver.quit()

HTML:

sold out

sold out

A: To do this, you'll need a special maneuver by Selenium called Action Chains. You can import it at the top like so:
from selenium.webdriver.common.action_chains import ActionChains

Then proceed as follows:
articles = driver.find_elements_by_tag_name('article')
for article in articles:
    ActionChains(driver).move_to_element(article).perform()
    if article.find_element_by_tag_name('a').text == "sold out":
         print("sold out")
         link = article.find_element_by_xpath('div/a').get_attribute('href')
         print(link)
    else:
         print("available")

For each article web element, you can call the same methods from the driver to look in just that element. XPath's double slash (//) dictates that it searches the whole DOM without regards to any specific element (which is why it locates the same element each time), so you'd need to search it's direct children (ie. /).
Edit: The element with the sold out text, by default, has a CSS property of display: none;. The only way to trigger the sold out text is by doing a mouseover each element. Luckily, Selenium has this capability too. I've also changed my original code a bit, items that aren't sold out don't have a div with a "sold out tag" class, so that would lead to an error.

A: As per the HTML you have shared if you want to print the hrefs of the nodes with text sold out you can use the following code block :
links = driver.find_elements_by_tag_name("article")
for i in links:
    if "sold out" in i.find_elements_by_xpath("//div[@class='inner-article']/a//div[@class='sold_out_tag']").get_attribute("innerHTML") :
        print("sold out")
        print(i.find_element_by_xpath("//div[@class='inner-article']/a").get_attribute("href"))


text:
Q: strcpy with strings array I'm working with arrays, I've done passing strings array to functions and other bit banging with strings and ints arrays.
Now, I have a problem with strcpy, what I did and want to know:

*

*It crashes with if I assign strcpy(temp, str1[i]); while temp is char *temp.

*single string array temp[100]. However, I didn't figure out how to calculate the size of the temp to the string element of the array. I understood that I have to give 17 as the size of temp so fit the bytes from the string array.
Like:
char *temp[17]; then, I can apply strcpy(temp, str1[i]);
Where *str1[] = {"sweepsweepsweepsweep"} 20 chars. And crashes with size of 16.

*I can't assign one member of stings array to another member.
But I saw one code which do that.

*Another thing that is why if I declared other empty string arrays str2 & str3, they have the same values as str1? It's included at the end of the code example.
This is my code:
#include <stdio.h>
#include <string.h>
#include <stdint.h>

int main()
{
    int m = 0, j = 1, n, i;
    char *str1[] = {"sweep", "forward"}, *str2[] = {}, *str3[] = {}, *temp;
    uint8_t cnt = sizeof(str1) / sizeof(str1[0]);

    if (strcmp(str1[m], str1[j]) > 0) {
        strcpy(temp, str1[m]);
        strcpy(str1[m], str1[j]);
        strcpy(str1[j], temp);
        printf("OK\n");
    } else {
        printf("NOPE\n");
    }
    printf("The sorted string\n");
    for (i = 0; i < cnt; i++)
        puts(str1[i]);
    printf("%d\n", strcmp(str1[0], str1[1]));
    printf("-----------------\n");

    printf("temp: %s\n", temp);
    printf("str2: %s\n", str2[0]);
    printf("str3: %s\n", str3[0]);
    return 0;
}

Code Example from online:
#include<stdio.h>

int main(){
int i,j,n;
char str[20][20],temp[20];
puts("Enter the no. of string to be sorted");
scanf("%d",&n);
for(i=0;i<=n;i++)
  gets(str[i]);
for(i=0;i<=n;i++)
  for(j=i+1;j<=n;j++)
  {
       if(strcmp(str[i],str[j])>0)
       {
          strcpy(temp,str[i]);
          strcpy(str[i],str[j]);
          strcpy(str[j],temp);
       }
   }
printf("The sorted string\n");
for(i=0;i<=n;i++)
  puts(str[i]);
return 0;
}

A: I think your error is because temp is a pointer and you use it as a string (Char array)
when you call strcpy(str1[j],temp), is where the problem is, i think.
Also notice that the online solution doesnt use *temp pointer, it uses an array


text:
Q: Get value from  tag from XML in PHP I have a XML and I want to retrieve the value inside
 tag in PHP. How do I do that? I am trying getElementbyId, getAttribute but I am unable to get the data.
$xmlDoc = new DOMDocument();$path_to_dir = "/var/www/html/Dalai/Annotation/0001.xml";
$xmlDoc->load($path_to_dir);$elements1 = $xmlDoc->getElementsByTagName('text');
foreach($elements1 as $node)
{
    foreach($node->childNodes as $child)
    {
       if($child->nodeName=='p')
       {
        $path=$child->getAttribute();
        echo $path;
       }
    }
}

A: I think in this line $path=$child->getAttribute(); getAttribute should take a string as a parameter, which then returns a string.

A: Assuming that, by the value inside
, you mean the text content like foo in
foo
, then you can access it via textContent or nodeValue * :
$path = $child->textContent;
//or $path = $child->nodeValue;
echo $path;

*) either one will do since it will be called on a DOMElement in this case. For more subtle differences between textContent and nodeValue, see : PHP DOM textContent vs nodeValue?


text:
Q: set something on GUI form and thread sleep I have a GUI window form. I want to set image to pictureBox and next sleep 3 seconds.
   pictureBox.Image = image;
   Thread.Sleep( 3000 );

But if I do it like my code above, my form try to set image, next go to sleep for 3 seconds, and just after that my form draws itself. So my picture show after this 3 seconds. How can I set image, show it and just after that "go to sleep" ?
edit 1
exactly I want to do something like that:
I have two thread, UI and GUI. UI reads from net socket and call right method from GUI. And can be script like that:

*

*UI call on GUI: set image

*UI call on GUI: do something (then GUI must clear image)

But I want to have sure, that I will be able to see this image. So after GUI set image, I call this thread for 3 seconds. So, how can I do it?
Example:
(function from GUI)
public void f1() {
     MethodInvoker method = () => {
            pictureBox.Image = image;
            pictureBox.Update();
           // do something more
     };

     if ( InvokeRequired ) {
           Invoke( method );
     } else {
           method();
     }

 }

public void f2() {
     MethodInvoker method = () => {
            pictureBox.Image = null;
            pictureBox.Update();
           // do something more
     };

     if ( InvokeRequired ) {
           Invoke( method );
     } else {
           method();
     }

 }

And other function f3...fn
 public void f3() {
     MethodInvoker method = () => {
           // do something
     };

     if ( InvokeRequired ) {
           Invoke( method );
     } else {
           method();
     }

 }

And, I my UI thread call function f1 and after it f2, I want to be sure that my user will be able to see this picture. But if my UI thread call function f1 and some between f3..fn call it normally.
edit 2
No I make it that:
I define function in GUI form (which is called by UI ):
  public void f1() {
         MethodInvoker method = () => {
                pictureBox.Image = image;
                pictureBox.Update();
         };

         MethodInvoker method2 = () => {
                // something
         }

        if ( InvokeRequired ) {
                Invoke( method );
                Thread.Sleep( 3000 );  // sleep UI thread
                Invoke( method2 );
        } else {
                method();
                method2();
        }
  }

It works, but it isn't the best solution. If will be script like this:
- UI call f1
- UI call f3

UI will be sleep for 3 seconds and I don't expect it.
What is the best solution for my problem?

A: You should never let your GUI sleep. At least not the way you are doing. If you use Thread.Sleep or other blocking mechanisms you will prevent the UI from doing what it is suppose to be doing; dispatching and processing messages.
If you really want to cause a delayed action then you would be better off using a System.Windows.Forms.Timer. Here is what I think you need to do. This of course is based on my vague understanding of what you mean by "go to sleep".

*

*Set your image.

*Then immediately disable all of the controls necessary that simulates whatever "go to sleep" means for you.

*Then start the timer.

*Finally in the Tick event add code that reverses whatever "go to sleep" means for you.

A: Try one of these:
Form.Refresh ();
Application.DoEvents;

Application.DoEvents
I'm assuming WindowsForms.


text:
Q: Spark 2.2.0 intermittently produces `org.apache.spark.SparkException: Failed to register classes with Kryo` error I'm running a Spark application in cluster mode via spark-submit, and I have a custom Kryo registrator. The JAR is built with sbt "+assembly". Occasionally, after letting the job run for a while, some of the executors will produce errors like the below during a treeAggregate operation. What's weird is that the error only happens occasionally, after many, many objects have already been successfully serialized by Kryo. Often the entire Spark job finishes without apparent issue. When this error does pop up, it's usually accompanied by the task seeming to hang, and I need to kill Spark manually.
17/08/29 22:39:04 ERROR TransportRequestHandler: Error opening block StreamChunkId{streamId=542074019336, chunkIndex=0} for request from /10.0.29.65:34332
org.apache.spark.SparkException: Failed to register classes with Kryo
    at org.apache.spark.serializer.KryoSerializer.newKryo(KryoSerializer.scala:139)
    at org.apache.spark.serializer.KryoSerializerInstance.borrowKryo(KryoSerializer.scala:292)
    at org.apache.spark.serializer.KryoSerializerInstance.<init>(KryoSerializer.scala:277)
    at org.apache.spark.serializer.KryoSerializer.newInstance(KryoSerializer.scala:186)
    at org.apache.spark.serializer.SerializerManager.dataSerializeStream(SerializerManager.scala:169)
    at org.apache.spark.storage.BlockManager$$anonfun$dropFromMemory$3.apply(BlockManager.scala:1382)
    at org.apache.spark.storage.BlockManager$$anonfun$dropFromMemory$3.apply(BlockManager.scala:1377)
    at org.apache.spark.storage.DiskStore.put(DiskStore.scala:69)
    at org.apache.spark.storage.BlockManager.dropFromMemory(BlockManager.scala:1377)
    at org.apache.spark.storage.memory.MemoryStore.org$apache$spark$storage$memory$MemoryStore$$dropBlock$1(MemoryStore.scala:524)
    at org.apache.spark.storage.memory.MemoryStore$$anonfun$evictBlocksToFreeSpace$2.apply(MemoryStore.scala:545)
    at org.apache.spark.storage.memory.MemoryStore$$anonfun$evictBlocksToFreeSpace$2.apply(MemoryStore.scala:539)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    at org.apache.spark.storage.memory.MemoryStore.evictBlocksToFreeSpace(MemoryStore.scala:539)
    at org.apache.spark.memory.StorageMemoryPool.acquireMemory(StorageMemoryPool.scala:92)
    at org.apache.spark.memory.StorageMemoryPool.acquireMemory(StorageMemoryPool.scala:73)
    at org.apache.spark.memory.StaticMemoryManager.acquireStorageMemory(StaticMemoryManager.scala:72)
    at org.apache.spark.storage.memory.MemoryStore.putBytes(MemoryStore.scala:147)
    at org.apache.spark.storage.BlockManager.maybeCacheDiskBytesInMemory(BlockManager.scala:1143)
    at org.apache.spark.storage.BlockManager.org$apache$spark$storage$BlockManager$$doGetLocalBytes(BlockManager.scala:594)
    at org.apache.spark.storage.BlockManager$$anonfun$getLocalBytes$2.apply(BlockManager.scala:559)
    at org.apache.spark.storage.BlockManager$$anonfun$getLocalBytes$2.apply(BlockManager.scala:559)
    at scala.Option.map(Option.scala:146)
    at org.apache.spark.storage.BlockManager.getLocalBytes(BlockManager.scala:559)
    at org.apache.spark.storage.BlockManager.getBlockData(BlockManager.scala:353)
    at org.apache.spark.network.netty.NettyBlockRpcServer$$anonfun$1.apply(NettyBlockRpcServer.scala:61)
    at org.apache.spark.network.netty.NettyBlockRpcServer$$anonfun$1.apply(NettyBlockRpcServer.scala:60)
    at scala.collection.Iterator$$anon$11.next(Iterator.scala:409)
    at scala.collection.convert.Wrappers$IteratorWrapper.next(Wrappers.scala:31)
    at org.apache.spark.network.server.OneForOneStreamManager.getChunk(OneForOneStreamManager.java:89)
    at org.apache.spark.network.server.TransportRequestHandler.processFetchRequest(TransportRequestHandler.java:125)
    at org.apache.spark.network.server.TransportRequestHandler.handle(TransportRequestHandler.java:103)
    at org.apache.spark.network.server.TransportChannelHandler.channelRead(TransportChannelHandler.java:118)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)
    at org.apache.spark.network.util.TransportFrameDecoder.channelRead(TransportFrameDecoder.java:85)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:643)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:566)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:131)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.foo.bar.MyKryoRegistrator
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.spark.serializer.KryoSerializer$$anonfun$newKryo$5.apply(KryoSerializer.scala:134)
    at org.apache.spark.serializer.KryoSerializer$$anonfun$newKryo$5.apply(KryoSerializer.scala:134)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
    at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:186)
    at org.apache.spark.serializer.KryoSerializer.newKryo(KryoSerializer.scala:134)
    ... 60 more

My Spark session looks like this:
val spark = SparkSession.builder()
                .appName("FooBar")
                .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
                .config("spark.kryoserializer.buffer.max", "2047m")
                .config("spark.kryo.registrator","com.foo.bar.MyKryoRegistrator")
                .config("spark.kryo.registrationRequired", "true")
                .config("spark.network.timeout", "3600s")
                .config("spark.driver.maxResultSize", "0")
                .config("spark.rdd.compress", "true")
                .config("spark.shuffle.spill", "true")
                .getOrCreate()

and I'm passing these configuration options to spark-submit:
--conf "spark.executor.heartbeatInterval=400s"
--conf "spark.speculation=true"
--conf "spark.speculation.multiplier=30"
--conf "spark.speculation.quantile=0.95"
--conf "spark.memory.useLegacyMode=true"
--conf "spark.shuffle.memoryFraction=0.8"
--conf "spark.storage.memoryFraction=0.2"
--driver-java-options "-XX:+UseG1GC"

This is what my registrator code looks like:
package com.foo.bar

import com.esotericsoftware.kryo.Kryo
import org.apache.spark.serializer.KryoRegistrator

class MyKryoRegistrator extends KryoRegistrator {
  override def registerClasses(kryo: Kryo) {
    kryo.register(classOf[Array[Array[Byte]]])
    kryo.register(classOf[Array[Double]])
    kryo.register(classOf[Array[Int]])
    kryo.register(classOf[Array[Object]])
    kryo.register(classOf[Array[scala.collection.immutable.Range.Inclusive]])
    kryo.register(classOf[scala.collection.mutable.WrappedArray.ofRef[_]])
    kryo.register(Class.forName("scala.reflect.ClassTag$$anon$1"))
    kryo.register(classOf[scala.util.matching.Regex])

    kryo.register(classOf[java.lang.Class[_]])
    kryo.register(classOf[java.util.Date])

    kryo.register(classOf[awscala.s3.Bucket])
    kryo.register(classOf[com.amazonaws.services.s3.model.Owner])

    kryo.register(Class.forName("org.apache.spark.broadcast.TorrentBroadcast"))

    kryo.register(Class.forName("org.apache.spark.ml.feature.Instance"))
    kryo.register(classOf[org.apache.spark.ml.linalg.DenseVector])
    kryo.register(classOf[org.apache.spark.ml.linalg.SparseVector])
    kryo.register(classOf[org.apache.spark.ml.linalg.Vector])
    kryo.register(classOf[org.apache.spark.mllib.stat.MultivariateOnlineSummarizer])
    kryo.register(classOf[org.apache.spark.sql.catalyst.expressions.GenericInternalRow])
    kryo.register(Class.forName("org.apache.spark.sql.execution.columnar.CachedBatch"))
    kryo.register(classOf[org.apache.spark.storage.BroadcastBlockId])
  }
}

I found some discussion of what sounds like a very similar issue (KryoSerializer cannot find my SparkKryoRegistrator), but there's unfortunately no answer.
Any idea what the issue might be? Is this a bug in Spark?


text:
Q: Selecting cell in a specific sheet which has hide/unhide row macros I have a series of macros with the following format:
Sub EUCheck_Click()
If Range("EU_Tick").Value = "True" Then
    ActiveSheet.Rows("54:60").EntireRow.Hidden = False
Else:
    ActiveSheet.Rows("54:60").EntireRow.Hidden = True
End If
End Sub

This works, however when I select a cell within this sheet it often selects a cell 8/9 cells up or down from the one I am trying to select.
I think this starts by selecting where the cell would be if the first 1/2 tick boxes were click and cells were hidden, however this gap between where I try and click and where is selected is then maintained.

A: This is a bug in VBA. Selections count hidden Row numbers even if you cannot access them. The best workaround is the comment of Toddleson.
Another solution is to show all Rows at the beginning with Rows.EntireRow.Hidden = False and hide all relevant rows at once at the end of your macro.
I faced the same problem in MS Project since there is no way to use paths. The solution for MS project is Application.FilterClear and Application.OutlineShowAllTasks.


text:
Q: What is the difference between Apple's "Safari Technology Preview" for the public and the Safari beta download for developers? It is my guess that the Safari Technology Preview (STP) is updated less frequently than the Beta for Developers (BD).
I wonder if Apple publishes an explainer on the differences between the two, apart from the observable update cadence difference, and the marketing to different audiences.
April 15, 2021 - I see that the last BD release was on April 6, 2021. I speculate that STP was last updated in early March 2021 based on the tickets in the release log.
Safari download page


text:
Q: Core Plot - Plot label going beyond boundary Am using Core Plot to display a line chart. The label for plot gets cut when it is near (though not outside) the border as seen below

though, as you can see in the XCode Storyboard (below pic) that the border of each graph is well above (height) and there doesn't seem to be a reason why the label of the plot is getting cut.

I have set the graph Hosting View's frame to match the frame size in XCode.
    self.graphHostView = [(CPTGraphHostingView *) [CPTGraphHostingView alloc]
                          initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y,
                                                   self.view.frame.size.width, self.view.frame.size.height)];
    self.graph = [[CPTXYGraph alloc] initWithFrame:self.graphHostView.bounds];

Also, how do I get rid of the label name in X-Axis (the leftmost 1.0 and rightmost 5.0)?
EDITED
@EricSkroch , I tried the following :
CASE 1
Setting
    plotAreaFrame.paddingTop=20.0
    plotAreaFrame.paddingBottom=15.0

CASE 2
    graph.paddingTop=20.0
    graph.paddingBottom=15.0
(didn't set anything for plotAreaFrame)

CASE 3
Setting both the above (plotAreaFrame & graph padding)
    plotAreaFrame.paddingTop=20.0
    plotAreaFrame.paddingBottom=15.0
    graph.paddingTop=20.0
    graph.paddingBottom=15.0

CASE 4  - Seems to be the best output! (though the top is still cropped)
Setting top padding to 0 for both plotArea & frame
    graph.paddingTop=0.0
    plotAreaFrame.paddingTop=0.0

CASE 5
If I try to increase either plotAreaFrame or graph's top-padding, this is what i get
    graph.paddingTop=5.0

A: Add some padding to the graph and/or plot area frame (paddingLeft, paddingRight, etc.). This will push the plot area in away from the edges of the graph leaving room for the labels.


text:
Q: Packing a static AngularJS website with any web server (e.g. nginx) into a single rpm package And thank you very much to everyone who responded :)

I have no experience building rpm packages with such requirements

For several days now, I can't defeat the task of packing a static website (AngularJS) by a web server in one rpm package. That it would be possible to install and receive a ready site on any rhel/centos server.
What did I do.

*

*Install all needed tools for creating rpmbuild and create non-root
user for this action

*rpmdev-setuptree && rpm -Uvh
http://nginx.org/packages/centos/7/SRPMS/nginx-1.16.1-1.el7.ngx.src.rpm

*copy my website folder to SOURCE

*edit rpmbuild/SPECS/nginx.spec

*add Source14: website

*add to section %install, after

%{__mkdir} -p $RPM_BUILD_ROOT%{_datadir}/nginx
%{__mv} $RPM_BUILD_ROOT%{_sysconfdir}/nginx/html $RPM_BUILD_ROOT%{_datadir}/nginx/

I tried use
cp -r -f %{SOURCE14}/*.* $RPM_BUILD_ROOT%{_datadir}/nginx/html/

and
%{__install} -D -pm 755 %{SOURCE14}/*.* $RPM_BUILD_ROOT%{_datadir}/nginx/html/

But after rpmbuild -bb nginx.spec I didn`t have any changes in rpmbuild/BUILD/nginx-1.16.1/html/ folder, it contains only index.html and 50x.html

Pls help me with resolve this task.
  Where in the spec file I need add my website copy step?
  What the best way to modify Nginx default.conf? Because I need to add support AngularJS (add servername, HTTP to https rewrite allow some type of fonts and etc)

A: *

*You should create a tarball from your website folder. Here is relevant documentation https://rpm-packaging-guide.github.io/#preparing-source-code-for-packaging

*Then you need to alter %prep section. Which will be tricky if you want to keep the Source0 of original nginx. The documentation is here: https://rikers.org/rpmbook/node70.html#SECTION03541000000000000000 See section "Using %setup in a Multi-source Spec File"

Instead of modifying existing nginx spec file, I would suggest you to create new spec file from scratch. Read through existing documentation like:

*

*https://rpm-packaging-guide.github.io/

*https://docs.fedoraproject.org/en-US/quick-docs/creating-rpm-packages/index.html

*https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html-single/RPM_Guide/index.html
Back to the core of your issue.
When you do:
Source14: website

then rpmbuild will include only the directory - or should, I actually never tried it, every case and source code assume only one filename there. The wildcards do not work there. Therefore later cp -r -f %{SOURCE14}/*.* does not match anything, because it expands to cp -r -f website/*.* but the folder is actually empty.
If you try to do:
Source14: website/foo
Source15: website/bar/foo

then it will 1) be hell of manual work 2) not work, because SourceX takes only the basename and expect it to be present in rpmbuild/SOURCES/ - and obviously you will have collision sooner or later. Therefore you want to tarball your work.


text:
Q: Servise vs IntentService для проигрывания музыки Делаю плеер, который проигрывает музыку.
Что выбрать IntentService или Service?
Что обычно используется для такой задачи?

A: IntentService - расширение Service, предназначенное для долгих задач (музыка - самое то). К IntentService можно будет отправлять намерения (интенты) - например, прервать исполнение или ускорить воспроизведение - это уже как Вы реализуете.
Т.е. IntentService - самое то, что надо.
Подробнее тут: http://developer.alexanderklimov.ru/android/theory/intentservice.php


text:
Q: Running MPI program on linux makefile How can I execute I MPI c++ file on linux? I compile with:
mpic++ myprog.cpp -o myprog

but I don't know how to run the file... and how can I choose the number of processor?

A: To execute an MPI program in parallel, you use mpiexec. Typically, you can use something like this:
mpiexec -n <num_procs> ./myprog

You'll usually also want to include a list of hosts on which to run your processes. This argument varies based on which MPI implementation you have. For MPICH (and derivatives such as MS-MPI, IBM's MPI implementations, Intel MPI, Cray MPI, etc.), it's:
mpiexec -n <num_procs> -hosts host1,host2 ./myprog

For Open MPI, it looks like this:
mpiexec -n <num_procs> -host host1,host2 ./myprog

It's possible that some of these have alternate versions that are more compatible between implementations, but I don't remember off the top of my head.


text: Q: Как получить ссылку поста из канала telegram Мне нужно получать ссылку последнего поста из канала и направлять еë на апи другого сервиса. Отследить появление нового поста и узнать его id у меня, конечно, получилось, но вот сделать из этого ссылку не получилось. Как я понял, telethon блокирует некоторые действия с данными во время сессии. Может, есть некоторые альтернативные способы получить ссылку на пост?


text:
Q: Selenium Testing: Programming a more robust test I am attempting to automate a task involving a JavaServer Page using the Selenium Webdriver. I have built a test that works about 90% of the time, meaning that the Webdriver makes it through all the tasks without any errors. During the test the browser executes the actions below:

*

*opens a page

*clicks on a link and switches windows

*closes the original window

*logs into a system

*switches frames

*clicks a link

*fills out a form

*submits the form

*...more similar tasks

Unfortunatly, some of the time the Webdriver will randomly fail on one of the steps. This is because it could not find something, for example 'no frame found', 'unable to find element with link text...' and other similar errors. I am not sure why this happens sometimes and it appears to happen randomly at different stages in the test. I searched around for a solution and the best I could do was slow down the Webdriver with thread.sleep at various stages in the program. This seems like a very haphazard way to solve the problem to me and I am not even sure the problem is that the driver is moving too quickly. Even if I slow it down half a second I still sometimes get errors. I am a new user of Selenium and I do not know if this is usually a problem. Does anyone have a better way to address this problem? Am I overlooking something simple?

A: It's a common issue, instead of using Thread.sleep(duration) you should better create some utility method like
public WebElement waitForElementPresent(By by, int timeout) {

    WebDriverWait wait = new WebDriverWait(driver, timeout);
    WebElement element = null;
    try {
        element = wait.until(ExpectedConditions.presenceOfElementLocated(by));
    } catch (TimeoutException e) {
        e.printStackTrace();
    }
    return element;
}

This way if the element is already there you won't wait, and if it's loading it will wait until it finds it or until the timeout is triggered

A: I did the same initially using thread sleep to develop my scripts. However, even though the scripts work while development, but it will be unrealiable on a production run as it fail inconsistently --which adds to the frustration. This is because thread sleep utilizes fixed waiting time and if elements do not get attached in time, it will fail the tests. singe31 has given a valid solution. Another solution would be by using fluentWait:
public void fluentWait(final By by)
{
    FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver)
               .withTimeout(60, TimeUnit.SECONDS)
               .pollingEvery(5, TimeUnit.SECONDS)
               .ignoring(NoSuchElementException.class);

           WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
             public WebElement apply(WebDriver driver) {
               return driver.findElement(by);
             }
           });
}

Here, the Selenium Webdriver will wait for at least 60 seconds to find an element until it throws of an TimeOutException. Otherwise, it will poll the DOM to find the element every 5 seconds and if the element is not found "NoSuchElementException" exception will be ignored.
Another problem which you are bound to face is, StaleStateReference or NoSuchElementException. You can check this link for solving that issue.
Hope it helps.


text:
Q: How to find() and filter() models for Ember.Select content I have a model which is many-to-many related to itself (depended objects). I want to use Ember.Select to set relatinships between objects. But not all objects may be ralted, so I need to filter them twice:

*

*has certain filed value

*id !== current object's id

Here is template:
{{view Em.Select
    contentBinding="others"
    multiple="true" }}

And here is JS CoffeeScript code:
App.Monster = DS.Model.extend
    location: DS.belongsTo('App.Location')
    requirements: DS.hasMany('App.Monster')

App.LessonEditController  = Em.ObjectController.extend
    ...
    others: (->
        _this = this
        App.Monster.find(location: this.get('model').get('location').get('id')).rejectProperty('id', this.get('model').get('id'))
        ).property()

Problems is that find() apperas to be lazy or something. It works only when i remove rejectProperty, so it's only one filtering. How to do both??


text:
Q: Azure Databricks cluster init script - Install wheel from mounted storage I have a python wheel uploaded to an azure storage account that is mounted in a databricks service. I'm trying to install the wheel using a cluster init script as described in the databricks documentation.
My storage is definitely mounted and my file path looks correct to me. Running the command display(dbutils.fs.ls("/mnt/package-source")) in a notebook yields the result:
path: dbfs:/mnt/package-source/parser-3.0-py3-none-any.whl
name: parser-3.0-py3-none-any.whl

I have tried to install the wheel from a cluster init file using this command:
/databricks/python/bin/pip install "dbfs:/mnt/package-source/parser-3.0-py3-none-any.whl"

but the cluster fails to start. It's logs give me an error saying it can't find the file:
WARNING: Requirement 'dbfs:/mnt/package-source/parser-3.0-py3-none-any.whl' looks like a filename, but the file does not exist
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/dbfs:/mnt/package-source/parser-3.0-py3-none-any.whl'

I have also tried it this way:
/databricks/python/bin/pip install /mnt/package-source/parser-3.0-py3-none-any.whl

but I get a similar error:
WARNING: Requirement '/mnt/package-source/parser-3.0-py3-none-any.whl' looks like a filename, but the file does not exist
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/mnt/package-source/parser-3.0-py3-none-any.whl'

I've even tried using relative paths such as ../../mnt/package-source/... but to no avail. Can anyone tell me what I'm doing wrong please?
Related question: Azure Databricks cluster init script - install python wheel

A: I got it working using a relative path. It turns out ../../mnt/ wasn't the correct path. It worked using ../../../dbfs/mnt/. It just took a bit of exploring the file system using the bash ls command to find it.
For anyone else experiencing the same problem, I suggest starting with something like this in a notebook:
%%sh
ls ../../../


text:
Q: How to send push notification from asp.net core server with SignalR to Flutter / (Without Firebase) I made a chat application with flutter, Implement the chat server with Asp.net core and SignalR. Now I want to send notification from asp.net core server to my app with SignalR push notification in flutter without Firebase.
Does anyone know how I can do this?


text:
Q: Ajax calendar extender start date and end date differ by 60 Days I am using 2 ajax calender extender
1) Start Date
2) End Date.
I want end date should be 60 days ahead from start date.
My Date format from calender extender is 08-May-2014 (dd-MMM-yyyy)
Code :

    <asp:TextBox ID="EFF_START_DATEDVTextBox" runat="server"      onchange="javascript:EndDateTimeEndDate();" Width="100px" CssClass="txtbox"></asp:TextBox>
    <ajax:CalendarExtender ID="EFF_START_DATEDVCalendarExtender" runat="server" TargetControlID="EFF_START_DATEDVTextBox" Format="dd-MMM-yyyy">

    <asp:TextBox ID="EFF_END_DATEDVTextBox" onchange="javascript:EndDateTimeEndDate();" runat="server" Width="100px" CssClass="txtbox"></asp:TextBox>
    <ajax:CalendarExtender ID="EFF_END_DATEDVCalendarExtender" runat="server" TargetControlID="EFF_END_DATEDVTextBox" Format="dd-MMM-yyyy">                                                           </ajax:CalendarExtender>

like say for example when I select start date, the end date should be 60 Days ahead from start date vice versa..
I am trying to do in the following way but it's fail in converting the date time.
 function EndDateTimeEndDate() {

            var datestart = new Date(document.getElementById('<%=EFF_START_DATEDVTextBox.ClientID %>').value)
            var dateEnd = new Date(document.getElementById('<%=EFF_END_DATEDVTextBox.ClientID %>').value)
            alert(datestart);
            document.getElementById('<%=EFF_START_DATEDVTextBox.ClientID %>').value = datestart + 60

        }

A: Try this..
document.getElementById('<%=EFF_START_DATEDVTextBox.ClientID %>').value = datestart.getDate() - 60;

EDIT:
    var startdate = new Date(document.getElementById('<%=EFF_START_DATEDVTextBox.ClientID %>').value);
    var EndDate= new Date();
    EndDate.setDate(startdate .getDate() + 60);
    alert(EndDate);

A: Here is the Answer
function StartDateTimeEndDate1()
                {
                        var startDate = document.getElementById('<%=EFF_START_DATEDVTextBox.ClientID %>').value
                        var arrstartdate = startDate.split('-');
                        var newdate = arrstartdate[0] + ' ' + arrstartdate[1] + ' ' + arrstartdate[2]
                        var actualDate = new Date(newdate); // convert to actual date
                        var newDate = new Date(actualDate.getFullYear(), actualDate.getMonth(), actualDate.getDate() + 60); // create new increased date
                        // now extract the bits we want to crete the text version of the new date..
                        var newDateString = ("0" + newDate.getDate()).substr(-2) + '-' + newDate.toDateString().substr(4, 3) + '-' + newDate.getFullYear();
                        var charstr = newDateString.split('-')
                        if (charstr[0].length == 3)
                        {
                              document.getElementById('<%=EFF_END_DATEDVTextBox.ClientID %>').value = newDateString.substr(1)
                        }
                        else
                        {
                             document.getElementById('<%=EFF_END_DATEDVTextBox.ClientID %>').value = newDateString
                        }
                }


text:
Q: How to notate a subtraction of a matrix columns with a vector? According to matrix algebra, I cannot subtract a vector from a matrix, because they don't have the same size.

I want to notate that every column of $R_i^t$ is subtracted by vector $R_f^t$, but I don't want to either merge them into 1 matrix, nor change the vector to matrix in order to emphasise the nature of the variables.

A: Given matrix $\mathbf A \in \mathbb R^{n \times p}$, we can subtract vector $\mathbf b \in \mathbb R^n$ from all $p$ columns of $\bf A$ via $\color{blue}{\mathbf A - \mathbf b {\bf 1}_p^{\top}}$.


text:
Q: ORMLite SqlProcedure - how to tell the SP name? I'm tring to use the SqlProcedure method but I see the first parameter as an anon object... I think it's for passing the parameters of the store but I don't see where to pass the SP name... what am I doing wrong?
   string sp = StoredProcedureHelper.Instance.GetStoreProcedureName("mySP");

           var dataTable =  dbConn.SqlProcedure<myPOCO>(new
            {
                ID_ISTITUTO = header.Istituto,
                ID_CANALE = header.MC_CHANNEL,
                OPERATORE = header.MC_USERID,
                NDG = header.MC_NDG,
                DOSSIER = header.Dossier
            });

where I specify the command text?
I'm under v4 Thanks

A: You can use SqlList to invoke custom SQL:
List<Poco> results = db.SqlList<Poco>("EXEC GetAnalyticsForWeek @weekNo",
                                          new { weekNo = 1 });

via https://github.com/ServiceStack/ServiceStack.OrmLite/#new-apis-to-execute-custom-sql
and here are some unit tests for more examples
https://github.com/ServiceStack/ServiceStack.OrmLite/blob/master/tests/ServiceStack.OrmLite.Tests/SqlServerProviderTests.cs

A: Check out the SqlProcedure example here
You need to create a class to represent the parameter and alias it to the stored procedure name.
[Alias("SUB_TOT_BUDGET")]
public class ProcedureSubTotalBudgetParameters
{

    [Alias("HEAD_DEPT")]
    public string HeadDepartment
    {
        get;
        set;
    }

}

public class ProcedureSubTotalBudgetResult
{

    [Alias("TOT_BUDGET")]
    public decimal Total
    {
        get;
        set;
    }

    [Alias("AVG_BUDGET")]
    public decimal Average
    {
        get;
        set;
    }

    [Alias("MAX_BUDGET")]
    public decimal Max
    {
        get;
        set;
    }

    [Alias("MIN_BUDGET")]
    public decimal Min
    {
        get;
        set;
    }
}

ProcedureSubTotalBudgetParameters p = new ProcedureSubTotalBudgetParameters() {
    HeadDepartment = "000"
};

var results = db.SqlProcedure<ProcedureSubTotalBudgetResult>(p, "");


text:
Q: Add new data into PHP JSON string I have $data as JSON encoded data and I have this string:
$new_data = "color:'red'";

that needs to be added to $data so that I can read it from it as a json string.
How can I achieve this ?

A: I was just searching for the solution to this and stumbled across this question (already one year old).  The answers provided so far were not very helpful to me.  So, hopefully this helps the next person.
The answer I was looking for was
$json = json_decode($data,true);

which returns the result in an array structure, not an object.  Then, it is quite simple to add new values:
$json['foo'] = 'bar';

After this, the data can of course be returned into a string with json_encode().

A: $dataToAugment = json_decode($data);

// add you data here at the proper position

$data = json_encode($dataToAugment);

A: you need to json_decode($data) first, then add the new key/value, and json_encode() it.