diff --git a/.gitignore b/.gitignore
index 9807c50..48a9dc5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@
.DS_Store
# ignore any data
-^data/*$
+data
# ignore working bytecode
\.class$
diff --git a/python/src/stackdump/commands/default_settings.py b/python/src/stackdump/commands/default_settings.py
new file mode 120000
index 0000000..16e0032
--- /dev/null
+++ b/python/src/stackdump/commands/default_settings.py
@@ -0,0 +1 @@
+../default_settings.py
\ No newline at end of file
diff --git a/python/src/stackdump/commands/download_site_info.py b/python/src/stackdump/commands/download_site_info.py
index 8451be7..b22223f 100644
--- a/python/src/stackdump/commands/download_site_info.py
+++ b/python/src/stackdump/commands/download_site_info.py
@@ -1,33 +1,49 @@
#!/usr/bin/env python
# This script downloads the sites RSS file and associated logos from the net.
-
+import tarfile
import urllib.request
from xml.etree import ElementTree
import sys
-import os, ssl
+def printf(format, *args):
+ sys.stdout.write(format % args)
+from shutil import copy
+import os, ssl, fnmatch
+from optparse import OptionParser
+from xml.etree import ElementTree
+import elasticsearch
+
+import settings
+from sqlobject import sqlhub, connectionForURI,AND, IN, SQLObject, \
+ UnicodeCol, DateTimeCol, IntCol, DatabaseIndex, dbconnection
+from sqlobject.sqlbuilder import Delete, Insert
+from sqlobject.styles import DefaultStyle
+from pysolr import Solr, SolrError
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and
getattr(ssl, '_create_unverified_context', None)):
- ssl._create_default_https_context = ssl._create_unverified_context
+ ssl._create_defat_https_context = ssl._create_unverified_context
se_dir = os.path.join(os.environ.get('HOME'), 'stackexchange')
sites_path = os.path.join(se_dir, 'Sites.xml')
script_dir = os.path.dirname(sys.argv[0])
-sites_file_path = os.path.join(script_dir, '../../../../data/sites')
-
+sites_file_path = os.path.join(script_dir, ''
+ '../../../../data/')
# ensure the data directory exists\\\\
+# download the sites RSS file
+
if not os.path.exists(os.path.dirname(sites_file_path)):
os.mkdir(os.path.dirname(sites_file_path))
-# download the sites RSS file
print('Downloading StackExchange sites XML file...', )
-urllib.request.urlretrieve('https://archive.org/download/stackexchange/Sites.xml', sites_file_path)
+# urllib.request.urlretrieve('https://archive.org/download/stackexchange/Sites.xml', sites_file_path)
print('done.')
print('')
+
+
# parse sites RSS file and download logosc
images_dir_path = os.path.join(script_dir, '../../../media/images')
print(os.listdir(images_dir_path))
@@ -43,50 +59,80 @@ if not os.path.exists(badges_dir_path):
with open(sites_path) as f:
sites_file = ElementTree.parse(f)
- rows = sites_file.findall('row')
+ sites = sites_file.findall('row')
# print(rows[0].attrib)
- for row in rows:
- entry_title = row.attrib['Name']
- print('Entry: ' + entry_title)
-
+ for site in sites:
+ site_title = site.attrib['LongName']
+ site_name = site.attrib['Name']
# extract the key from the url - remove the http:// and .com
- site_key = row.attrib['TinyName']
- print('Site: ' + site_key)
- logo_url = row.attrib['ImageUrl']
- icon_url = row.attrib['IconUrl']
- badge_url = row.attrib['BadgeIconUrl']
+ site_key = site.attrib['TinyName']
+ site_url = site.attrib['Url'][8:]
+ logo_url = site.attrib['ImageUrl']
+ icon_url = site.attrib['IconUrl']
+ badge_url = site.attrib['BadgeIconUrl']
+
+
+ site_vars = (site_url, site_key, site_name, site_title)
+ # print(site_vars)
+ printf('Site: %s, key=%s, name="%s", longname="%s"\n' % site_vars)
+ try:
+ logo_file = os.path.join(logos_dir_path, 'logo-%s.png' % site_key)
+ if not os.path.exists(logo_file):
+ print('Downloading logo for %s...' % site_title, urllib.request.urlretrieve(logo_url, logo_file))
+ except:
+ print('Failed download logo for %s...' % site_title)
try:
- print('Downloading logo for %s...' % entry_title,
- urllib.request.urlretrieve(logo_url, os.path.join(logos_dir_path, 'logo-%s.png' % site_key)))
+ icon_path = os.path.join(icons_dir_path, 'icon-%s.png' % site_key)
+ if not os.path.exists(icon_path):
+ print('Downloading icon for %s...' % site_title, urllib.request.urlretrieve(icon_url, icon_path))
except:
- print('Failed download logo for %s...' % entry_title)
+ print('Failed download ico for %s...' % site_title)
try:
- print('Downloading icon for %s...' % entry_title,
- urllib.request.urlretrieve(icon_url, os.path.join(icons_dir_path, 'icon-%s.png' % site_key)))
+ badge_file = os.path.join(badges_dir_path, 'badge-%s.png' % site_key)
+ if not os.path.exists(icon_path):
+ print('Downloading badge for %s...' % site_title, urllib.request.urlretrieve(badge_url, badge_file))
except:
- print('Failed download ico for %s...' % entry_title)
+ printf('Failed download badge for %s...' % site_title)
- try:
- print('Downloading badge for %s...' % entry_title,
- urllib.request.urlretrieve(badge_url, os.path.join(badges_dir_path, 'badge-%s.png' % site_key)))
- except:
- print('Failed download badge for %s...' % entry_title)
+ site_files = []
+ print('Key: ' + site_url)
+ for root, dirs, files in os.walk(se_dir):
+ for name in files:
+ if fnmatch.fnmatch(name, site_url + '*'):
+ print('Match: ' + os.path.join(root, name))
+ site_files.append(os.path.join(root, name))
-print('done.')
+ sites_data = sites_file_path
+ for site_file in site_files:
+ dst = sites_data + os.sep + site_key[0] + os.sep + site_key + os.sep + '7z'\
+ + os.sep + os.path.basename(site_file)
+ os.makedirs(dst, exist_ok=True)
+ os.chdir(dst)
+ os.system('tar xzf '+site_file)
+ print('Data: ' + site_file)
+def prepare_site(xml_root, dump_date, site_key):
+ print('Using the XML root path: ' + xml_root + '\n')
+
+ if not os.path.exists(xml_root):
+ print('The given XML root path does not exist.')
+ sys.exit(1)
+
+ # connect to the database
+ print('Connecting to the Stackdump database...')
+ conn_str = settings.DATABASE_CONN_STR
+ sqlhub.processConnection = connectionForURI(conn_str)
+ print('Connected.\n')
# MAIN METHOD
if __name__ == '__main__':
- parser = OptionParser(usage='usage: %prog [options] xml_root_dir')
- parser.add_option('-n', '--site-name', help='Name of the site.')
- parser.add_option('-d', '--site-desc', help='Description of the site (if not in sites).')
+ parser = OptionParser(usage='usage: %pro'
+ 'g [options] xml_root_dir')
parser.add_option('-k', '--site-key', help='Key of the site (if not in sites).')
parser.add_option('-c', '--dump-date', help='Dump date of the site.')
- parser.add_option('-u', '--base-url', help='Base URL of the site on the web.')
- parser.add_option('-Y', help='Answer yes to any confirmation questions.', dest='answer_yes', action='store_true', default=False)
(cmd_options, cmd_args) = parser.parse_args()
@@ -94,6 +140,4 @@ if __name__ == '__main__':
print('The path to the directory containing the extracted XML files is required.')
sys.exit(1)
- prepare_site(cmd_args[0], cmd_options.site_name, cmd_options.dump_date,
- cmd_options.site_desc, cmd_options.site_key,
- cmd_options.base_url, answer_yes=cmd_options.answer_yes)
+ prepare_site(cmd_args[0], cmd_options.dump_date, cmd_options.site_key)
diff --git a/python/src/stackdump/commands/import_recent.py b/python/src/stackdump/commands/import_recent.py
new file mode 100644
index 0000000..44dc079
--- /dev/null
+++ b/python/src/stackdump/commands/import_recent.py
@@ -0,0 +1,911 @@
+#!/usr/bin/env python3
+
+# This script takes extracted site files and inserts them into the database.
+
+import sys
+import os
+import time
+import xml.sax
+from datetime import datetime
+import re
+import urllib2
+import socket
+import tempfile
+import traceback
+from optparse import OptionParser
+from xml.etree import ElementTree
+
+from sqlobject import sqlhub, connectionForURI, AND, IN, SQLObject, \
+ UnicodeCol, DateTimeCol, IntCol, DatabaseIndex, dbconnection
+from sqlobject.sqlbuilder import Delete, Insert
+from sqlobject.styles import DefaultStyle
+from pysolr import Solr, SolrError
+
+from stackdump.models import Site, Badge, User
+from stackdump import settings
+import json
+
+script_dir = os.path.dirname(sys.argv[0])
+
+# SAX HANDLERS
+ISO_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S.%f'
+
+class BaseContentHandler(xml.sax.ContentHandler):
+ """
+ Base content handler.
+ """
+ def __init__(self, conn, site, obj_class):
+ self.conn = conn
+ self.site = site
+ self.obj_class = obj_class
+ self.cur_props = None
+ self.row_count = 0
+ self.db_style = DefaultStyle()
+
+ def endElement(self, name):
+ if name != 'row':
+ return
+
+ if not self.cur_props:
+ return
+
+ # we want to count failed rows as well as successful ones as this is
+ # a count of rows processed.
+ self.row_count += 1
+
+ # the cur_props is now complete. Save it.
+ try:
+ # the object is automatically saved to the database on creation
+ # adding records using the SQLObject object takes too long
+ #self.obj_class(**self.cur_props)
+
+ # so we're going to go closer to the metal
+ props_for_db = { }
+ for k,v in self.cur_props.items():
+ # if this is a reference to a FK, massage the values to fit
+ if isinstance(v, SQLObject):
+ k += 'Id'
+ v = v.id
+ # need to convert the attr names to DB column names
+ props_for_db[self.db_style.pythonAttrToDBColumn(k)] = v
+
+ self.conn.query(self.conn.sqlrepr(Insert(self.obj_class.sqlmeta.table, values=props_for_db)))
+
+ except Exception, e:
+ # could not insert this, so ignore the row
+ print('Exception: ' + str(e))
+ import traceback
+ traceback.print_exc()
+ print('Could not insert the row ' + repr(self.cur_props))
+
+ self.cur_props = None
+
+ if self.row_count % 1000 == 0:
+ print('%-10s Processed %d rows.' % ('[%s]' % self.obj_class.sqlmeta.table,
+ self.row_count)
+ )
+
+class BadgeContentHandler(BaseContentHandler):
+ """
+ Parses the string -
+
+
The query I'm using does the job that I need it to do. Basically I need to take the maximum 'Fee' from each day in the past 7 days, then average those together to get a 7 day average for each ID.
\nThe data in 'table_one' has over 2 billion rows, however it contains data from the whole of 2021 whereas I only need data for the most recent week, which is why i've used the '_PARTITIONTIME' line, however there are likely still millions of records after filtering. I have a feeling the issue could be due to the two 'rank () over' lines. When I look in the 'Execution Details' in BQ, the wait times are the longest but the compute times are also considerably long.
\nselect TimeStamp\n, EXTRACT(DAYOFWEEK FROM TimeStamp) as day_of_week\n, RestaurantId\n, Fee\n, MinAmount\n, Zone\nfrom table_one to,\nunnest(calculatedfees) as fees,\nunnest(Bands) as bands\nwhere\ntimestamp between timestamp(date_sub(date_trunc(current_date, week(monday)), interval 1 week)) and timestamp(date_trunc(current_date, week(monday)))\nand _PARTITIONTIME >= timestamp(current_date()-8)\nand Fee < 500),\n\nranked_data as (\nselect *\n, rank() over(partition by RestaurantId, Zone, day_of_week order by TimeStamp desc) as restaurant_zone_timestamp_rank -- identify last update for restaurant / zone pair\n, rank() over(partition by RestaurantId, Zone, TimeStamp, day_of_week order by MinAmount desc) as restaurant_zone_timestamp_minamount_rank -- identify highest "MinAmount" band\nfrom raw_data),\n\ndaily_week_fee as (\nselect RestaurantId\n, day_of_week\n, max(Fee) as max_delivery_fee\nfrom ranked_data\nwhere restaurant_zone_timestamp_rank = 1\nand restaurant_zone_timestamp_minamount_rank = 1\ngroup by 1,2),\n\navg_max_fee as (\nselect \nRestaurantID\n, avg(max_delivery_fee) as weekly_avg_fee\nfrom daily_week_fee\ngroup by 1)\n\nSELECT restaurant.restaurant_id_local\n, restaurant.restaurant_name\n, amf.weekly_avg_fee/100 as avg_df\nFROM restaurants r\nLEFT JOIN avg_max_fee amf\nON CAST(r.restaurant_id AS STRING) = amf.RestaurantId\nWHERE company.brand_key = "Country"\n\n
\n"},{"tags":["reactjs","search","filter","null"],"owner":{"reputation":51,"user_id":13978077,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgyemKG89F21vxDsa8pYqEhOkJoZDtyN_r1AUZn9w=k-s128","display_name":"Chaz Cathcart","link":"https://stackoverflow.com/users/13978077/chaz-cathcart"},"is_answered":false,"view_count":1,"answer_count":0,"score":0,"last_activity_date":1623259454,"creation_date":1623259454,"question_id":67908982,"share_link":"https://stackoverflow.com/q/67908982","body_markdown":"I made a simple search function for filtering through a datatable filled with JSON objects from an API.\r\n\r\nIt works for most tables in my application but will crash it if any of the objects in the table have a null value.\r\n\r\nmy search function looks like this:\r\n\r\n\r\n const search = (rows) => {\r\n const columns = rows[0] && Object.keys(rows[0]);\r\n\r\n return rows.filter((row) =>\r\n columns.some(\r\n (column) =>\r\n row[column]\r\n .toString()\r\n .toLowerCase()\r\n .indexOf(q.toString().toLowerCase()) > -1\r\n )\r\n );\r\n };\r\n\r\nI just want to replace any null values in the objects with an empty string.\r\n\r\nCan anyone help me with this in a simple way?","link":"https://stackoverflow.com/questions/67908982/search-filter-a-table-in-react-replace-null-values-with-an-empty-string","title":"Search/Filter a table in React: Replace null values with an empty string","body":"I made a simple search function for filtering through a datatable filled with JSON objects from an API.
\nIt works for most tables in my application but will crash it if any of the objects in the table have a null value.
\nmy search function looks like this:
\nconst search = (rows) => {\nconst columns = rows[0] && Object.keys(rows[0]);
\nreturn rows.filter((row) =>\n columns.some(\n (column) =>\n row[column]\n .toString()\n .toLowerCase()\n .indexOf(q.toString().toLowerCase()) > -1\n )\n);\n
\n};
\nI just want to replace any null values in the objects with an empty string.
\nCan anyone help me with this in a simple way?
\n"},{"tags":["spring-boot","jpa"],"answers":[{"owner":{"reputation":43,"user_id":11388786,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/f42c9fb8ccbd1251fd02c56b39919d94?s=128&d=identicon&r=PG&f=1","display_name":"boomeran","link":"https://stackoverflow.com/users/11388786/boomeran"},"is_accepted":false,"score":0,"last_activity_date":1623259451,"creation_date":1623259451,"answer_id":67908981,"question_id":67901818,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":43,"user_id":11388786,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/f42c9fb8ccbd1251fd02c56b39919d94?s=128&d=identicon&r=PG&f=1","display_name":"boomeran","link":"https://stackoverflow.com/users/11388786/boomeran"},"is_answered":false,"view_count":14,"answer_count":1,"score":0,"last_activity_date":1623259451,"creation_date":1623232648,"question_id":67901818,"share_link":"https://stackoverflow.com/q/67901818","body_markdown":"I am trying to extract data from multiple databases in different servers. This has been successful after configuring different Data sources as shown in my code however i cannot see to configure 2 different Data sources on the same connection.\r\n\r\nI have tried to create 2 beans within the config file but i would still need to set the Data source.\r\n\r\n```java\r\n@Configuration\r\n@EnableJpaRepositories(basePackages = {"balances.Repository.World"},\r\n entityManagerFactoryRef = "ASourceEntityManager",transactionManagerRef = "ASourceTransactionManager")\r\n@EnableTransactionManagement\r\npublic class World{\r\n @Autowired\r\n private Environment env;\r\n\r\n @Bean\r\n public LocalContainerEntityManagerFactoryBean ASourceEntityManager() {\r\n\r\n LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();\r\n em.setDataSource(ASourceDatasource());\r\n em.setPackagesToScan(new String("balances.Repository.World"));\r\n em.setPersistenceUnitName("ASourceEntityManager");\r\n HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();\r\n em.setJpaVendorAdapter(vendorAdapter);\r\n HashMap<String, Object> properties = new HashMap<String, Object>();\r\n properties.put("hibernate.dialect",env.getProperty("app.datasource.ASource.hibernate.dialect"));\r\n properties.put("hibernate.show-sql",env.getProperty("app.datasource.ASource.show-sql"));\r\n em.setJpaPropertyMap(properties);\r\n return em;\r\n\r\n }\r\n \r\n @Bean\r\n @ConfigurationProperties(prefix = "app.datasource.ASource")\r\n public DataSource ASourceDatasource() {\r\n\r\n DriverManagerDataSource dataSource = new DriverManagerDataSource();\r\n \r\n dataSource.setDriverClassName(env.getProperty("app.datasource.ASource.driverClassName"));\r\n dataSource.setUrl(env.getProperty("app.datasource.ASource.url"));\r\n dataSource.setUsername(env.getProperty("app.datasource.ASource.username"));\r\n dataSource.setPassword(env.getProperty("app.datasource.ASource.password"));\r\n\r\n return dataSource;\r\n }\r\n\r\n @ConfigurationProperties(prefix = "app.datasource.ASourceB")\r\n public DataSource ASourceDatasource() {\r\n\r\n DriverManagerDataSource dataSource = new DriverManagerDataSource();\r\n dataSource.setDriverClassName(env.getProperty("app.datasource.ASourceB.driverClassName"));\r\n dataSource.setUrl(env.getProperty("app.datasource.ASourceB.url"));\r\n dataSource.setUsername(env.getProperty("app.datasource.ASourceB.username"));\r\n dataSource.setPassword(env.getProperty("app.datasource.ASourceB.password"));\r\n\r\n return dataSource;\r\n }\r\n\r\n\r\n @Bean\r\n public PlatformTransactionManager ASourceTransactionManager() {\r\n\r\n JpaTransactionManager transactionManager\r\n = new JpaTransactionManager();\r\n transactionManager.setEntityManagerFactory(\r\n ASourceEntityManager().getObject());\r\n return transactionManager;\r\n }\r\n\r\n\r\n```","link":"https://stackoverflow.com/questions/67901818/how-can-i-connect-to-2-different-schemas-on-one-datasource-in-springboot","title":"How can i connect to 2 different Schemas on one datasource in springboot","body":"I am trying to extract data from multiple databases in different servers. This has been successful after configuring different Data sources as shown in my code however i cannot see to configure 2 different Data sources on the same connection.
\nI have tried to create 2 beans within the config file but i would still need to set the Data source.
\n@Configuration\n@EnableJpaRepositories(basePackages = {"balances.Repository.World"},\n entityManagerFactoryRef = "ASourceEntityManager",transactionManagerRef = "ASourceTransactionManager")\n@EnableTransactionManagement\npublic class World{\n @Autowired\n private Environment env;\n\n @Bean\n public LocalContainerEntityManagerFactoryBean ASourceEntityManager() {\n\n LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();\n em.setDataSource(ASourceDatasource());\n em.setPackagesToScan(new String("balances.Repository.World"));\n em.setPersistenceUnitName("ASourceEntityManager");\n HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();\n em.setJpaVendorAdapter(vendorAdapter);\n HashMap<String, Object> properties = new HashMap<String, Object>();\n properties.put("hibernate.dialect",env.getProperty("app.datasource.ASource.hibernate.dialect"));\n properties.put("hibernate.show-sql",env.getProperty("app.datasource.ASource.show-sql"));\n em.setJpaPropertyMap(properties);\n return em;\n\n }\n \n @Bean\n @ConfigurationProperties(prefix = "app.datasource.ASource")\n public DataSource ASourceDatasource() {\n\n DriverManagerDataSource dataSource = new DriverManagerDataSource();\n \n dataSource.setDriverClassName(env.getProperty("app.datasource.ASource.driverClassName"));\n dataSource.setUrl(env.getProperty("app.datasource.ASource.url"));\n dataSource.setUsername(env.getProperty("app.datasource.ASource.username"));\n dataSource.setPassword(env.getProperty("app.datasource.ASource.password"));\n\n return dataSource;\n }\n\n @ConfigurationProperties(prefix = "app.datasource.ASourceB")\n public DataSource ASourceDatasource() {\n\n DriverManagerDataSource dataSource = new DriverManagerDataSource();\n dataSource.setDriverClassName(env.getProperty("app.datasource.ASourceB.driverClassName"));\n dataSource.setUrl(env.getProperty("app.datasource.ASourceB.url"));\n dataSource.setUsername(env.getProperty("app.datasource.ASourceB.username"));\n dataSource.setPassword(env.getProperty("app.datasource.ASourceB.password"));\n\n return dataSource;\n }\n\n\n @Bean\n public PlatformTransactionManager ASourceTransactionManager() {\n\n JpaTransactionManager transactionManager\n = new JpaTransactionManager();\n transactionManager.setEntityManagerFactory(\n ASourceEntityManager().getObject());\n return transactionManager;\n }\n\n\n
\n"},{"tags":["ms-word","pandoc","bibtex"],"owner":{"reputation":2958,"user_id":5596534,"user_type":"registered","accept_rate":92,"profile_image":"https://i.stack.imgur.com/mUhM3.jpg?s=128&g=1","display_name":"boshek","link":"https://stackoverflow.com/users/5596534/boshek"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623259448,"creation_date":1623259448,"question_id":67908980,"share_link":"https://stackoverflow.com/q/67908980","body_markdown":"I am having to work with word users who don't use bibtex. However I am trying to create a workflow where those users simply input [@citation] directly in the word doc. Then I use `pandoc` to convert that word doc back to markdown so I can more readily use bibtex. So here is what is in the word doc (`foo.docx`):\r\n\r\n```\r\nSentence with a citation [@foo]\r\n```\r\nThen I run this pandoc code:\r\n\r\n```\r\npandoc -s foo.docx -t markdown -o foo.md\r\n```\r\n\r\nThen resulting markdown is:\r\n\r\n```\r\nSentence with a citation \\[\\@foo\\]\r\n```\r\n\r\nBecause of these escaped characters, I can't actually generate the citations. Happy to entertain other ideas to make this work but merging markdown and office users seems to be always a bit friction-y. The ultimately question is how to maintain citation from word to markdown?","link":"https://stackoverflow.com/questions/67908980/dont-escape-bibtex-citation-in-pandoc-conversion","title":"Don't escape bibtex citation in pandoc conversion","body":"I am having to work with word users who don't use bibtex. However I am trying to create a workflow where those users simply input [@citation] directly in the word doc. Then I use pandoc
to convert that word doc back to markdown so I can more readily use bibtex. So here is what is in the word doc (foo.docx
):
Sentence with a citation [@foo]\n
\nThen I run this pandoc code:
\npandoc -s foo.docx -t markdown -o foo.md\n
\nThen resulting markdown is:
\nSentence with a citation \\[\\@foo\\]\n
\nBecause of these escaped characters, I can't actually generate the citations. Happy to entertain other ideas to make this work but merging markdown and office users seems to be always a bit friction-y. The ultimately question is how to maintain citation from word to markdown?
\n"},{"tags":["excel","google-sheets"],"answers":[{"owner":{"reputation":693,"user_id":15384825,"user_type":"registered","profile_image":"https://i.stack.imgur.com/m7FLv.gif?s=128&g=1","display_name":"Irvin Jay G.","link":"https://stackoverflow.com/users/15384825/irvin-jay-g"},"is_accepted":false,"score":0,"last_activity_date":1623259446,"creation_date":1623259446,"answer_id":67908979,"question_id":67905144,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":269,"user_id":5893819,"user_type":"registered","accept_rate":73,"profile_image":"https://www.gravatar.com/avatar/ca7fe4d986d66c41e00e194510efd2e6?s=128&d=identicon&r=PG&f=1","display_name":"greeny","link":"https://stackoverflow.com/users/5893819/greeny"},"is_answered":false,"view_count":24,"answer_count":1,"score":0,"last_activity_date":1623259446,"creation_date":1623245380,"question_id":67905144,"share_link":"https://stackoverflow.com/q/67905144","body_markdown":"I have a dataset of jobs for a gardening company.\r\n``` \r\nstatus # ID Date Name Frequency\r\n☐ 4 340 09/06/20 Jack Once Off\r\n☐ 1 543 22/05/20 Sarah Weekly\r\n☐ 3 121 01/05/20 Emily Fortnightly\r\n☐ 3 577 11/06/20 Peter Once Off\r\n```\r\n\r\nWhen a booking is complete I want to check the box in the first column which will then create a new row with the following conditions\r\n \r\n- row is created only for jobs that are "weekly" or "fortnighly". Once off jobs wont create a row when the box is checked\r\n- The date in the new row is a week or a fortnight in the future of the original row depending on its frequency value\r\n- The job # goes up by one from the original row #\r\n- The ID, name and frequency rows remain the same\r\n\r\nFor example if I ticked the checkbox for the 3rd row it would create a new row like this:\r\n\r\n``` \r\n☐ 4 121 15/05/20 Emily Fortnightly\r\n```\r\n\r\nIs this possible? Thanks!\r\n","link":"https://stackoverflow.com/questions/67905144/automatically-create-new-row-when-checkbox-is-ticked-in-google-sheets","title":"Automatically create new row when checkbox is ticked in Google Sheets","body":"I have a dataset of jobs for a gardening company.
\nstatus # ID Date Name Frequency\n☐ 4 340 09/06/20 Jack Once Off\n☐ 1 543 22/05/20 Sarah Weekly\n☐ 3 121 01/05/20 Emily Fortnightly\n☐ 3 577 11/06/20 Peter Once Off\n
\nWhen a booking is complete I want to check the box in the first column which will then create a new row with the following conditions
\nFor example if I ticked the checkbox for the 3rd row it would create a new row like this:
\n☐ 4 121 15/05/20 Emily Fortnightly\n
\nIs this possible? Thanks!
\n"},{"tags":["java","minecraft"],"owner":{"reputation":1,"user_id":16178381,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgkZAspUgcO3K9D6l9wxZzmp6iczMgNjd9KVvAUQw=k-s128","display_name":"Fabooxdedo","link":"https://stackoverflow.com/users/16178381/fabooxdedo"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623259437,"creation_date":1623259437,"question_id":67908978,"share_link":"https://stackoverflow.com/q/67908978","body_markdown":">09.06 17:14:21 [Server] INFO Exception in thread "main" java.lang.UnsupportedClassVersionError: net/minecraft/server/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0\r\n\r\nAlguien sabe como solucionar este problema? Someone knows how to fix this problem?","link":"https://stackoverflow.com/questions/67908978/java-lang-unsupportedclassversionerror-minecraft-java-server","title":"java.lang.UnsupportedClassVersionError minecraft JAVA server","body":"\n\n09.06 17:14:21 [Server] INFO Exception in thread "main" java.lang.UnsupportedClassVersionError: net/minecraft/server/Main has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0
\n
Alguien sabe como solucionar este problema? Someone knows how to fix this problem?
\n"},{"tags":["c#","winforms","events"],"comments":[{"owner":{"reputation":731,"user_id":1679220,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/8c48d48053758cff69118a29655c3675?s=128&d=identicon&r=PG","display_name":"hijinxbassist","link":"https://stackoverflow.com/users/1679220/hijinxbassist"},"edited":false,"score":1,"creation_date":1623256975,"post_id":67908181,"comment_id":120029754,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":731,"user_id":1679220,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/8c48d48053758cff69118a29655c3675?s=128&d=identicon&r=PG","display_name":"hijinxbassist","link":"https://stackoverflow.com/users/1679220/hijinxbassist"},"edited":false,"score":0,"creation_date":1623257153,"post_id":67908181,"comment_id":120029830,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":15648890,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1532f40a96faa3e8dbbde6e586db72e0?s=128&d=identicon&r=PG&f=1","display_name":"Blueonics","link":"https://stackoverflow.com/users/15648890/blueonics"},"reply_to_user":{"reputation":731,"user_id":1679220,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/8c48d48053758cff69118a29655c3675?s=128&d=identicon&r=PG","display_name":"hijinxbassist","link":"https://stackoverflow.com/users/1679220/hijinxbassist"},"edited":false,"score":0,"creation_date":1623258245,"post_id":67908181,"comment_id":120030271,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":731,"user_id":1679220,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/8c48d48053758cff69118a29655c3675?s=128&d=identicon&r=PG","display_name":"hijinxbassist","link":"https://stackoverflow.com/users/1679220/hijinxbassist"},"is_accepted":false,"score":0,"last_activity_date":1623259437,"creation_date":1623259437,"answer_id":67908977,"question_id":67908181,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":15648890,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1532f40a96faa3e8dbbde6e586db72e0?s=128&d=identicon&r=PG&f=1","display_name":"Blueonics","link":"https://stackoverflow.com/users/15648890/blueonics"},"is_answered":false,"view_count":22,"answer_count":1,"score":0,"last_activity_date":1623259437,"creation_date":1623256132,"question_id":67908181,"share_link":"https://stackoverflow.com/q/67908181","body_markdown":"I am writing up a C# application using Winforms, and I need to collect some data based on my selection from a comboBox. I also have a start button that enables data collection, and a stop button that halts the data collection. \r\n\r\n This is what I am capable of doing right now:\r\n Measure all data from all channels by switching my selection on the comboBox (one channel at a time). The process goes like: select a channel- start button click - wait for data collection - stop button click\r\n\r\n But here is what I want to do in code:\r\n Select a channel - start button click - wait for data collection - stop button click\r\n switch to next channel - start button click -wait for data collection - stop button click \r\n ................\r\n repeat this process until done. \r\n \r\n My question is: what should I adopt to achieve this?\r\n I have been trying to use startButton.PerformClick( ) to enabling the buttons, however, I need to stop for a few seconds in between starting and stopping to wait for data collection.\r\n\r\n You may ask why because this is very inefficient, but for some reason the DLL from the third party cannot collect data from all channels at the same time. So i have to manually switch my channel selection from the comboBox in order to collect all data at one go. \r\n\r\n Please let me know if you have any suggestions.\r\n\r\nThanks in advance. \r\n\r\n\r\n'''\r\n\r\n private void timer_Tick(object sender, EventArgs e)\r\n {\r\n startButton.PerformClick();\r\n \r\n }\r\n private void timer2_Tick(object sender, EventArgs e)\r\n {\r\n stopButton.PerformClick();\r\n }\r\n\r\n private void checkAll_CheckedChanged(object sender, EventArgs e)\r\n {\r\n int i = 0;\r\n while (i != 40) //there are a total of 40 channels\r\n {\r\n\r\n System.Windows.Forms.Timer mytimer = new System.Windows.Forms.Timer();\r\n mytimer.Interval = 5000;\r\n\r\n System.Windows.Forms.Timer mytimer2 = new System.Windows.Forms.Timer();\r\n mytimer2.Interval = 7000;\r\n\r\n mytimer.Start();\r\n mytimer.Tick += new EventHandler(timer_Tick);\r\n\r\n mytimer2.Start();\r\n mytimer2.Tick += new EventHandler(timer2_Tick);\r\n\r\n physicalChannelComboBox.SelectedIndex = i;\r\n i++;\r\n Thread.Sleep(5000);\r\n }\r\n\r\n }\r\n\r\n'''\r\n","link":"https://stackoverflow.com/questions/67908181/c-winforms-simulate-user-clicksstart-wait-for-data-collection-stop","title":"C# Winforms: Simulate user clicks(start- wait for data collection - stop)","body":"I am writing up a C# application using Winforms, and I need to collect some data based on my selection from a comboBox. I also have a start button that enables data collection, and a stop button that halts the data collection.
\nThis is what I am capable of doing right now:\nMeasure all data from all channels by switching my selection on the comboBox (one channel at a time). The process goes like: select a channel- start button click - wait for data collection - stop button click\n
\nBut here is what I want to do in code:\nSelect a channel - start button click - wait for data collection - stop button click\nswitch to next channel - start button click -wait for data collection - stop button click\n................\nrepeat this process until done.
\nMy question is: what should I adopt to achieve this?\nI have been trying to use startButton.PerformClick( ) to enabling the buttons, however, I need to stop for a few seconds in between starting and stopping to wait for data collection.
\nYou may ask why because this is very inefficient, but for some reason the DLL from the third party cannot collect data from all channels at the same time. So i have to manually switch my channel selection from the comboBox in order to collect all data at one go.
\nPlease let me know if you have any suggestions.
\nThanks in advance.
\n'''
\n private void timer_Tick(object sender, EventArgs e)\n {\n startButton.PerformClick();\n \n }\n private void timer2_Tick(object sender, EventArgs e)\n {\n stopButton.PerformClick();\n }\n\n private void checkAll_CheckedChanged(object sender, EventArgs e)\n {\n int i = 0;\n while (i != 40) //there are a total of 40 channels\n {\n\n System.Windows.Forms.Timer mytimer = new System.Windows.Forms.Timer();\n mytimer.Interval = 5000;\n\n System.Windows.Forms.Timer mytimer2 = new System.Windows.Forms.Timer();\n mytimer2.Interval = 7000;\n\n mytimer.Start();\n mytimer.Tick += new EventHandler(timer_Tick);\n\n mytimer2.Start();\n mytimer2.Tick += new EventHandler(timer2_Tick);\n\n physicalChannelComboBox.SelectedIndex = i;\n i++;\n Thread.Sleep(5000);\n }\n\n }\n
\n'''
\n"},{"tags":["mercurial"],"owner":{"reputation":7893,"user_id":3195477,"user_type":"registered","accept_rate":20,"profile_image":"https://i.stack.imgur.com/PK4P1.jpg?s=128&g=1","display_name":"StayOnTarget","link":"https://stackoverflow.com/users/3195477/stayontarget"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623259433,"creation_date":1623259433,"question_id":67908976,"share_link":"https://stackoverflow.com/q/67908976","body_markdown":"I'm running a batch graft between branches like this:\r\n\r\n hg graft --rev "file('libraries/project/**')"\r\n\r\nIn total a few dozen changesets are being grafted.\r\n\r\nPeriodically I am getting messages like this which interrupt the graft operation and wait for user input:\r\n\r\n grafting 16356:268ef234596a "commit message here"\r\n file 'project\\source\\filename.cs' was deleted in local [local] but was modified in other [graft].\r\n You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.\r\n What do you want to do? \r\n\r\nNow, I know that 100% of the time the "deleted" option is appropriate. But is there any way to force HG to automatically use that option?\r\n\r\nLooking in the [documentation][1] nothing is mentioned about this circumstance. Nor does `hg graft --help --verbose` (which seems to be the same content as the docs anyway).\r\n\r\n---\r\n\r\nAt first I thought I could use the \r\n\r\n -t\t--tool TOOL\tspecify merge tool\r\n\r\noption... but I don't think that would work, because none of the [available merge tools][2] would only affect deletions. There could be other kinds of merge conflicts which I'd have to deal with manually.\r\n\r\n\r\n [1]: https://www.mercurial-scm.org/repo/hg/help/graft\r\n [2]: https://www.mercurial-scm.org/repo/hg/help/merge-tools","link":"https://stackoverflow.com/questions/67908976/how-to-automatically-resolve-a-merge-conflict-because-of-a-deleted-file-during-a","title":"How to automatically resolve a merge conflict because of a deleted file during a graft?","body":"I'm running a batch graft between branches like this:
\nhg graft --rev "file('libraries/project/**')"\n
\nIn total a few dozen changesets are being grafted.
\nPeriodically I am getting messages like this which interrupt the graft operation and wait for user input:
\ngrafting 16356:268ef234596a "commit message here"\nfile 'project\\source\\filename.cs' was deleted in local [local] but was modified in other [graft].\nYou can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.\nWhat do you want to do? \n
\nNow, I know that 100% of the time the "deleted" option is appropriate. But is there any way to force HG to automatically use that option?
\nLooking in the documentation nothing is mentioned about this circumstance. Nor does hg graft --help --verbose
(which seems to be the same content as the docs anyway).
At first I thought I could use the
\n-t --tool TOOL specify merge tool\n
\noption... but I don't think that would work, because none of the available merge tools would only affect deletions. There could be other kinds of merge conflicts which I'd have to deal with manually.
\n"},{"tags":["pyspark","databricks"],"owner":{"reputation":19,"user_id":7466812,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/423e394f62c194d31f79cf032a671f80?s=128&d=identicon&r=PG&f=1","display_name":"Sagar Moghe","link":"https://stackoverflow.com/users/7466812/sagar-moghe"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623259426,"creation_date":1623259426,"question_id":67908975,"share_link":"https://stackoverflow.com/q/67908975","body_markdown":"I have a very large dataset like 1TB of flat file. I have computed a new column that is stored in another dataframe. I want to add this new column to my original dataframe without the overhead of performing a join. I made sure that the two dataframe have same number of rows and I do not need a join to merge this table.The 2 columns can be adjacently placed side by side without any errors. \r\n\r\nI also tried to create third df merging 2 df but failed.\r\n\r\n df3 = df1.withColumn('newColumn',df2['onlyColumnInThisDataframe'])\r\n\r\nNote: df2 is computed independent of df1 and cannot be done with some transformation on df1 using withColumn.","link":"https://stackoverflow.com/questions/67908975/append-a-column-to-pyspark-data-frame-from-another-data-frame-without-performing","title":"append a column to pyspark data frame from another data frame without performing a join","body":"I have a very large dataset like 1TB of flat file. I have computed a new column that is stored in another dataframe. I want to add this new column to my original dataframe without the overhead of performing a join. I made sure that the two dataframe have same number of rows and I do not need a join to merge this table.The 2 columns can be adjacently placed side by side without any errors.
\nI also tried to create third df merging 2 df but failed.
\ndf3 = df1.withColumn('newColumn',df2['onlyColumnInThisDataframe'])\n
\nNote: df2 is computed independent of df1 and cannot be done with some transformation on df1 using withColumn.
\n"},{"tags":["php","mysqli","error-handling"],"owner":{"reputation":1,"user_id":15805992,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Gizl0MCrJZs_EK1-tjjFh-X8Fh-WudDoYhArVmKaQ=k-s128","display_name":"Glitcher 2018","link":"https://stackoverflow.com/users/15805992/glitcher-2018"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259425,"creation_date":1623259425,"question_id":67908974,"share_link":"https://stackoverflow.com/q/67908974","body_markdown":"[Here is error code][1]\r\n\r\n\r\n [1]: https://i.stack.imgur.com/0CkAs.png\r\n\r\nI'm using UniController for php.\r\nI get this error when I view www.","link":"https://stackoverflow.com/questions/67908974/how-do-i-fix-no-such-file-or-directory-in-unknown-on-line-0","title":"How do I fix No such file or directory in Unknown on line 0?","body":"\nI'm using UniController for php.\nI get this error when I view www.
\n"},{"tags":["nginx","ffmpeg","rtmp","m3u8"],"answers":[{"owner":{"reputation":88257,"user_id":1109017,"user_type":"registered","profile_image":"https://i.stack.imgur.com/PX561.png?s=128&g=1","display_name":"llogan","link":"https://stackoverflow.com/users/1109017/llogan"},"is_accepted":false,"score":0,"last_activity_date":1623259420,"last_edit_date":1623259420,"creation_date":1623098370,"answer_id":67878436,"question_id":67877727,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":13,"user_id":7570267,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/89867ce1f3a5997a56e92b73e57540d0?s=128&d=identicon&r=PG&f=1","display_name":"rayjhp","link":"https://stackoverflow.com/users/7570267/rayjhp"},"is_answered":false,"view_count":13,"answer_count":1,"score":0,"last_activity_date":1623259420,"creation_date":1623094527,"question_id":67877727,"share_link":"https://stackoverflow.com/q/67877727","body_markdown":"I'm trying to do a Web TV for my Radio but i'm stucked into this problem.\r\n\r\nI'm trying to put a video loop (mp4) and trying to add into that loop the audio source of my radio who stream in m3u8 via Shoutcast. \r\n\r\nIs possible to do this? I try to search everything on internet without any particular result. ","link":"https://stackoverflow.com/questions/67877727/combine-two-input-audio-video-in-nginx-rtmp","title":"Combine two input audio/video in Nginx RTMP","body":"I'm trying to do a Web TV for my Radio but i'm stucked into this problem.
\nI'm trying to put a video loop (mp4) and trying to add into that loop the audio source of my radio who stream in m3u8 via Shoutcast.
\nIs possible to do this? I try to search everything on internet without any particular result.
\n"},{"tags":["ios","uigesturerecognizer","uipickerview"],"owner":{"reputation":1999,"user_id":544795,"user_type":"registered","accept_rate":69,"profile_image":"https://i.stack.imgur.com/rimwB.png?s=128&g=1","display_name":"Sjakelien","link":"https://stackoverflow.com/users/544795/sjakelien"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623259420,"creation_date":1623259420,"question_id":67908972,"share_link":"https://stackoverflow.com/q/67908972","body_markdown":"Bear with me. I did some investigations.\r\n\r\nWhat I want, is a UIPickerview to behave ***as if it was operated by me***, the user.\r\n\r\nI know this:\r\n\r\n self.picker.selectRow(43, inComponent: 0, animated: true)\r\n\r\nbut that doesn't include the scroll speed and the slow down.\r\n\r\nI'm looking for something that I can operate as follows:\r\n\r\n\r\n func scroll(picker:UIPickerView, direction: Int, speed: Double){\r\n // I might need some callback, but this would be great already.\r\n // likely, the parameters would include a simulated Gesture, but I don't know how to do that\r\n }\r\n\r\n\r\nI hope somebody understands what I mean\r\n\r\n\r\nthanks","link":"https://stackoverflow.com/questions/67908972/mimic-gesture-to-drive-uipickerview","title":"Mimic gesture to drive UIPickerview","body":"Bear with me. I did some investigations.
\nWhat I want, is a UIPickerview to behave as if it was operated by me, the user.
\nI know this:
\nself.picker.selectRow(43, inComponent: 0, animated: true)\n
\nbut that doesn't include the scroll speed and the slow down.
\nI'm looking for something that I can operate as follows:
\n func scroll(picker:UIPickerView, direction: Int, speed: Double){\n // I might need some callback, but this would be great already.\n // likely, the parameters would include a simulated Gesture, but I don't know how to do that\n }\n
\nI hope somebody understands what I mean
\nthanks
\n"},{"tags":["python","pandas","numpy"],"owner":{"reputation":325,"user_id":15492238,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5bb9116f49e2fd92ba919ad7f1fd1141?s=128&d=identicon&r=PG&f=1","display_name":"tj judge ","link":"https://stackoverflow.com/users/15492238/tj-judge"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623259417,"creation_date":1623259417,"question_id":67908971,"share_link":"https://stackoverflow.com/q/67908971","body_markdown":"I have a dataframe:\r\n\r\n 1 2 3 4 5\r\n Name Segment Axis Cost \r\n Amazon 1 slope 200 NaN 2.5 2.5 2.5 2.5\r\n x 200 0.0 1.0 2.0 3.0 4.0\r\n y 200 0.0 0.4 0.8 1.2 1.6\r\n 2 slope 100 NaN 2.0 2.0 2.0 2.0\r\n x 100 0.0 2.0 4.0 6.0 8.0\r\n y 100 0.0 1.0 2.0 3.0 4.0\r\n\r\nHow can a multiple the values in the corresponding slope rows on the Axis index, to the corresponding Cost index.\r\n\r\n\r\nExpected output:\r\n\r\n 1 2 3 4 5\r\n Name Segment Axis Cost \r\n Amazon 1 slope 200 NaN 500 500 500 500\r\n x 200 0.0 1.0 2.0 3.0 4.0\r\n y 200 0.0 0.4 0.8 1.2 1.6\r\n 2 slope 100 NaN 200 200 200 200\r\n x 100 0.0 2.0 4.0 6.0 8.0\r\n y 100 0.0 1.0 2.0 3.0 4.0","link":"https://stackoverflow.com/questions/67908971/multiple-by-corresponding-index-values","title":"Multiple by corresponding index values","body":"I have a dataframe:
\n 1 2 3 4 5\nName Segment Axis Cost \nAmazon 1 slope 200 NaN 2.5 2.5 2.5 2.5\n x 200 0.0 1.0 2.0 3.0 4.0\n y 200 0.0 0.4 0.8 1.2 1.6\n 2 slope 100 NaN 2.0 2.0 2.0 2.0\n x 100 0.0 2.0 4.0 6.0 8.0\n y 100 0.0 1.0 2.0 3.0 4.0\n
\nHow can a multiple the values in the corresponding slope rows on the Axis index, to the corresponding Cost index.
\nExpected output:
\n 1 2 3 4 5\nName Segment Axis Cost \nAmazon 1 slope 200 NaN 500 500 500 500\n x 200 0.0 1.0 2.0 3.0 4.0\n y 200 0.0 0.4 0.8 1.2 1.6\n 2 slope 100 NaN 200 200 200 200\n x 100 0.0 2.0 4.0 6.0 8.0\n y 100 0.0 1.0 2.0 3.0 4.0\n
\n"},{"tags":["java",".net","jsp","jakarta-ee","taglib"],"owner":{"reputation":1,"user_id":10162275,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/569e9b4f603907049eb1fe486ff54479?s=128&d=identicon&r=PG&f=1","display_name":"MD Burke","link":"https://stackoverflow.com/users/10162275/md-burke"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623259413,"creation_date":1623259413,"question_id":67908970,"share_link":"https://stackoverflow.com/q/67908970","body_markdown":"I need to make a call to a Java EE taglib that exists on another server. It is available via the web. What I need is the .Net equivalent code to implement this.\r\n\r\n <%@ taglib uri = "http://www.example.com/custlib" prefix = "mytag" %>\r\n <html>\r\n <body>\r\n <mytag:hello/>\r\n </body>\r\n </html>","link":"https://stackoverflow.com/questions/67908970/java-taglib-called-from-net-web-aplication","title":"Java taglib called from .Net web aplication","body":"I need to make a call to a Java EE taglib that exists on another server. It is available via the web. What I need is the .Net equivalent code to implement this.
\n<%@ taglib uri = "http://www.example.com/custlib" prefix = "mytag" %>\n<html>\n <body>\n <mytag:hello/>\n </body>\n</html>\n
\n"},{"tags":["spring-boot","spring-mvc","spring-security"],"owner":{"reputation":178,"user_id":939857,"user_type":"registered","accept_rate":0,"profile_image":"https://www.gravatar.com/avatar/717f0bfe9a70d20956f534822306af9f?s=128&d=identicon&r=PG","display_name":"user939857","link":"https://stackoverflow.com/users/939857/user939857"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623259404,"creation_date":1623259404,"question_id":67908969,"share_link":"https://stackoverflow.com/q/67908969","body_markdown":"I have started playing with Springboot and Spring MVC\r\n\r\nI have had no problems, but now I am attempting to utilize security.\r\n\r\nWith the following pom, controller and curl request the curl request is completely ignored.\r\n\r\nIf I run with debug, with a stop point in the controller, it never gets there.\r\nThere are no error messages, but there are hundreds of lines of negative matches.\r\n\r\nMy controller does not show up under Mappings.\r\n\r\nWhat do am I missing?\r\n\r\n\r\n## pom\r\n\r\n <?xml version="1.0" encoding="UTF-8"?>\r\n <project xmlns="http://maven.apache.org/POM/4.0.0"\r\n \txmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r\n \txsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">\r\n \t<modelVersion>4.0.0</modelVersion>\r\n \t<parent>\r\n \t\t<groupId>org.springframework.boot</groupId>\r\n \t\t<artifactId>spring-boot-starter-parent</artifactId>\r\n \t\t<version>2.5.0</version>\r\n \t\t<relativePath /> <!-- lookup parent from repository -->\r\n \t</parent>\r\n \t<groupId>org.xxx</groupId>\r\n \t<artifactId>address-services</artifactId>\r\n \t<version>0.0.1-SNAPSHOT</version>\r\n \t<name>address-services</name>\r\n \t<description>REST services for address validation</description>\r\n \t\r\n \t<properties>\r\n \t\t<java.version>11</java.version>\r\n \t\t\t<skip_unit_tests>false</skip_unit_tests>\r\n \t\t<org.slf4j.version>1.7.28</org.slf4j.version>\r\n \t\t<org.xxx.version>9.2.0</org.xxx.version>\r\n \t\t<com.h2database.version>1.4.199</com.h2database.version> \r\n \t\t<commons.lang.version>2.4</commons.lang.version>\r\n \t\t<commons.io.version>2.6</commons.io.version>\r\n \t\t<dom4j.version>1.6.1</dom4j.version>\r\n \t\t<!-- <org.springframework.version>5.2.7.RELEASE</org.springframework.version> -->\r\n \t</properties>\r\n \t\r\n \t<dependencies>\r\n \t <!-- spring -->\r\n \t <!-- \r\n \t\t<dependency>\r\n \t\t\t<groupId>org.springframework.boot</groupId>\r\n \t\t\t<artifactId>spring-boot-starter-data-rest</artifactId>\r\n \t\t</dependency>\r\n \t -->\t\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.springframework.boot</groupId>\r\n \t\t\t<artifactId>spring-boot-starter-security</artifactId>\r\n \t\t\t\t<exclusions>\r\n \t\t\t\t<exclusion>\r\n \t\t\t\t\t<groupId>ch.qos.logback</groupId>\r\n \t\t\t\t\t<artifactId>logback-classic</artifactId>\r\n \t\t\t\t</exclusion>\r\n \t\t\t</exclusions>\r\n \t\t</dependency>\r\n \t\t\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.springframework.boot</groupId>\r\n \t\t\t<artifactId>spring-boot-starter-thymeleaf</artifactId>\r\n \t\t\t\t<exclusions>\r\n \t\t\t\t<exclusion>\r\n \t\t\t\t\t<groupId>ch.qos.logback</groupId>\r\n \t\t\t\t\t<artifactId>logback-classic</artifactId>\r\n \t\t\t\t</exclusion>\r\n \t\t\t</exclusions>\r\n \t\t</dependency>\r\n \t\t\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.springframework.boot</groupId>\r\n \t\t\t<artifactId>spring-boot-starter-web</artifactId>\r\n \t\t\t\t<exclusions>\r\n \t\t\t\t<exclusion>\r\n \t\t\t\t\t<groupId>ch.qos.logback</groupId>\r\n \t\t\t\t\t<artifactId>logback-classic</artifactId>\r\n \t\t\t\t</exclusion>\r\n \t\t\t</exclusions>\r\n \t\t</dependency>\r\n \t\t\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.thymeleaf.extras</groupId>\r\n \t\t\t<artifactId>thymeleaf-extras-springsecurity5</artifactId>\r\n \t\t\t\t<exclusions>\r\n \t\t\t\t<exclusion>\r\n \t\t\t\t\t<groupId>ch.qos.logback</groupId>\r\n \t\t\t\t\t<artifactId>logback-classic</artifactId>\r\n \t\t\t\t</exclusion>\r\n \t\t\t</exclusions>\r\n \t\t</dependency>\r\n \r\n \t\t<dependency>\r\n \t\t\t<groupId>org.springframework.boot</groupId>\r\n \t\t\t<artifactId>spring-boot-starter-test</artifactId>\r\n \t\t\t<scope>test</scope>\r\n \t\t\t\t<exclusions>\r\n \t\t\t\t<exclusion>\r\n \t\t\t\t\t<groupId>ch.qos.logback</groupId>\r\n \t\t\t\t\t<artifactId>logback-classic</artifactId>\r\n \t\t\t\t</exclusion>\r\n \t\t\t</exclusions>\r\n \t\t</dependency>\r\n \t\t\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.springframework.security</groupId>\r\n \t\t\t<artifactId>spring-security-test</artifactId>\r\n \t\t\t<scope>test</scope>\r\n \t\t\t\t<exclusions>\r\n \t\t\t\t<exclusion>\r\n \t\t\t\t\t<groupId>ch.qos.logback</groupId>\r\n \t\t\t\t\t<artifactId>logback-classic</artifactId>\r\n \t\t\t\t</exclusion>\r\n \t\t\t</exclusions>\r\n \t\t</dependency>\r\n \t\t<!-- xxx -->\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.xxx</groupId>\r\n \t\t\t<artifactId>xxx-core</artifactId>\r\n \t\t\t<version>${org.xxx.version}</version>\r\n \t\r\n \t\t\t\t<exclusions>\r\n \t\t\t\t<exclusion>\r\n \t\t\t\t\t<groupId>ch.qos.logback</groupId>\r\n \t\t\t\t\t<artifactId>logback-classic</artifactId>\r\n \t\t\t\t</exclusion>\r\n \t\t\t</exclusions>\r\n \t\t</dependency>\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.xxx</groupId>\r\n \t\t\t<artifactId>xxx-test</artifactId>\r\n \t\t\t<version>${org.xxx.version}</version>\r\n \t\t\t<scope>test</scope>\r\n \t\t</dependency>\r\n \r\n \t\t<!-- <dependency> <groupId>org.xxx</groupId> <artifactId>xxx-hibernate</artifactId> \r\n \t\t\t<version>${org.xxx.hibernate.version}</version> </dependency> -->\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.xxx</groupId>\r\n \t\t\t<artifactId>xxx-jcmdline</artifactId>\r\n \t\t\t<version>${org.xxx.version}</version>\r\n \t\t</dependency>\r\n \t\t\r\n \t\t<dependency>\r\n \t\t\t<groupId>org.xxx</groupId>\r\n \t\t\t<artifactId>xxx-jcmdline</artifactId>\r\n \t\t\t<version>${org.xxx.version}</version>\r\n \t\t</dependency>\r\n \r\n \t\t<!-- others -->\r\n \t\t<!-- \r\n \t\t<dependency>\r\n \t\t\t<groupId>commons-dbcp</groupId>\r\n \t\t\t<artifactId>commons-dbcp</artifactId>\r\n \t\t\t<version>1.2.2</version>\r\n \t\t\t<scope>test</scope>\r\n \t\t</dependency>\r\n -->\r\n \t</dependencies>\r\n \r\n \t<build>\r\n \t\t<plugins>\r\n \t\t\t<plugin>\r\n \t\t\t\t<groupId>org.springframework.boot</groupId>\r\n \t\t\t\t<artifactId>spring-boot-maven-plugin</artifactId>\r\n \t\t\t</plugin>\r\n \t\t</plugins>\r\n \t</build>\r\n \r\n </project>\r\n\r\n## The controller \r\n\r\n package org.xxx.address.service;\r\n \r\n import java.util.ArrayList;\r\n import java.util.List;\r\n \r\n import org.xxx.address.beans.AddressBean;\r\n import org.xxx.address.beans.AddressList;\r\n import org.xxx.address.service.usps.UspsAddressValidator;\r\n import org.xxx.address.usps.AddressValidationException;\r\n import org.slf4j.Logger;\r\n import org.slf4j.LoggerFactory;\r\n import org.springframework.stereotype.Controller;\r\n import org.springframework.ui.Model;\r\n import org.springframework.web.bind.annotation.ModelAttribute;\r\n import org.springframework.web.bind.annotation.PostMapping;\r\n import org.springframework.web.bind.annotation.RequestBody;\r\n \r\n @Controller\r\n public class ValidationRest {\r\n \r\n \tLogger logger = LoggerFactory.getLogger(getClass());\r\n \t\r\n \tpublic ValidationRest() {\r\n \t}\r\n \t\r\n @PostMapping(value="/validateAddress")\r\n public String validateAddress(\r\n \t\t@ModelAttribute String address1,\r\n \t\t@ModelAttribute String address2,\r\n \t\t@ModelAttribute String city,\r\n \t\t@ModelAttribute String state,\r\n \t\t@ModelAttribute String zip,\r\n \t\tModel model) throws AddressValidationException {\r\n AddressBean address = new AddressBean(address1,address2,city,state,zip);\r\n List<AddressBean> list = new ArrayList<AddressBean>();\r\n list.add(address);\r\n UspsAddressValidator validator = new UspsAddressValidator();\r\n \t\t List<AddressBean> response = null;\r\n \t\ttry {\r\n \t\t response = validator.validate(list);\r\n \t\t} catch (AddressValidationException e) {\r\n \t\t\t// TODO Auto-generated catch block\r\n \t\t\te.printStackTrace();\r\n \t\t\tthrow e;\r\n \t\t}\r\n \t\tmodel.addAttribute("response",response);\r\n \treturn "validatedAddress";\r\n }\r\n\r\n## curl\r\n\r\necho rooter > curl -u root -X POST \\\r\nlocalhost:8080/validateAddress/&address1=410SouthMain&address2=&city=Romeo&state=MI&zip=78723\r\n\r\n## stdout/stderr\r\n\r\n /\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\\r\n ( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\\r\n \\\\/ ___)| |_)| | | | | || (_| | ) ) ) )\r\n ' |____| .__|_| |_|_| |_\\__, | / / / /\r\n =========|_|==============|___/=/_/_/_/\r\n :: Spring Boot :: (v2.5.0)\r\n \r\n INFO - 11:55:02,777 AddressApplication - Starting AddressApplication v0.0.1-SNAPSHOT using Java 14.0.2 on atx with PID 2737903 (/home/jjs/git/diamond-21-windoze/javautil/address-services/target/address-services-0.0.1-SNAPSHOT.jar started by jjs in /home/jjs/git/diamond-21-windoze/javautil/address-services)\r\n INFO - 11:55:02,777 AddressApplication - No active profile set, falling back to default profiles: default\r\n Jun 09, 2021 11:55:03 AM org.apache.catalina.core.StandardService startInternal\r\n INFO: Starting service [Tomcat]\r\n Jun 09, 2021 11:55:03 AM org.apache.catalina.core.StandardEngine startInternal\r\n INFO: Starting Servlet engine: [Apache Tomcat/9.0.46]\r\n Jun 09, 2021 11:55:03 AM org.apache.catalina.core.ApplicationContext log\r\n INFO: Initializing Spring embedded WebApplicationContext\r\n INFO - 11:55:04,220 AddressApplication - Started AddressApplication in 1.74 seconds (JVM running for 2.089)\r\n\r\n Negative matches:\r\n -----------------\r\n \r\n ActiveMQAutoConfiguration:\r\n Did not match:\r\n - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)\r\n \r\n AopAutoConfiguration.AspectJAutoProxyingConfiguration:\r\n Did not match:\r\n - @ConditionalOnClass did not find required class 'org.aspectj.weaver.Advice' (OnClassCondition)\r\n \r\n ArtemisAutoConfiguration:\r\n Did not match:\r\n - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)\r\n\r\n continues for hundreds of lines.\r\n\r\n## Mappings\r\n\r\n DEBUG Mappings - \r\n \to.s.d.r.w.RepositoryController:\r\n \t{OPTIONS [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForRepositories()\r\n \t{HEAD [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForRepositories()\r\n \t{GET [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: listRepositories()\r\n DEBUG Mappings - \r\n \to.s.d.r.w.RepositoryEntityController:\r\n \t{POST [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: postCollectionResource(RootResourceInformation,PersistentEntityResource,PersistentEntityResourceAssembler,String)\r\n \t{OPTIONS [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForItemResource(RootResourceInformation)\r\n \t{HEAD [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForItemResource(RootResourceInformation,Serializable,PersistentEntityResourceAssembler)\r\n \t{GET [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: getItemResource(RootResourceInformation,Serializable,PersistentEntityResourceAssembler,HttpHeaders)\r\n \t{PUT [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: putItemResource(RootResourceInformation,PersistentEntityResource,Serializable,PersistentEntityResourceAssembler,ETag,String)\r\n \t{PATCH [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: patchItemResource(RootResourceInformation,PersistentEntityResource,Serializable,PersistentEntityResourceAssembler,ETag,String)\r\n \t{DELETE [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deleteItemResource(RootResourceInformation,Serializable,ETag)\r\n \t{OPTIONS [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForCollectionResource(RootResourceInformation)\r\n \t{HEAD [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headCollectionResource(RootResourceInformation,DefaultedPageable)\r\n \t{GET [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: getCollectionResource(RootResourceInformation,DefaultedPageable,Sort,PersistentEntityResourceAssembler)\r\n \t{GET [/{repository}], produces [application/x-spring-data-compact+json || text/uri-list]}: getCollectionResourceCompact(RootResourceInformation,DefaultedPageable,Sort,PersistentEntityResourceAssembler)\r\n DEBUG Mappings - \r\n \to.s.d.r.w.RepositoryPropertyReferenceController:\r\n \t{GET [/{repository}/{id}/{property}/{propertyId}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: followPropertyReference(RootResourceInformation,Serializable,String,String,PersistentEntityResourceAssembler)\r\n \t{GET [/{repository}/{id}/{property}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: followPropertyReference(RootResourceInformation,Serializable,String,PersistentEntityResourceAssembler)\r\n \t{DELETE [/{repository}/{id}/{property}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deletePropertyReference(RootResourceInformation,Serializable,String)\r\n \t{GET [/{repository}/{id}/{property}], produces [text/uri-list]}: followPropertyReferenceCompact(RootResourceInformation,Serializable,String,HttpHeaders,PersistentEntityResourceAssembler)\r\n \t{[PATCH, PUT, POST] [/{repository}/{id}/{property}], consumes [application/json || application/x-spring-data-compact+json || text/uri-list], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: createPropertyReference(RootResourceInformation,HttpMethod,CollectionModel,Serializable,String)\r\n \t{DELETE [/{repository}/{id}/{property}/{propertyId}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deletePropertyReferenceId(RootResourceInformation,Serializable,String,String)\r\n DEBUG Mappings - \r\n \to.s.d.r.w.RepositorySearchController:\r\n \t{OPTIONS [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForSearches(RootResourceInformation)\r\n \t{HEAD [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForSearches(RootResourceInformation)\r\n \t{GET [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: listSearches(RootResourceInformation)\r\n \t{GET [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: executeSearch(RootResourceInformation,MultiValueMap,String,DefaultedPageable,Sort,PersistentEntityResourceAssembler,HttpHeaders)\r\n \t{GET [/{repository}/search/{search}], produces [application/x-spring-data-compact+json]}: executeSearchCompact(RootResourceInformation,HttpHeaders,MultiValueMap,String,String,DefaultedPageable,Sort,PersistentEntityResourceAssembler)\r\n \t{OPTIONS [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForSearch(RootResourceInformation,String)\r\n \t{HEAD [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForSearch(RootResourceInformation,String)\r\n DEBUG RepositoryRestHandlerMapping - 27 mappings in org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping\r\n DEBUG Mappings - \r\n \to.s.d.r.w.RepositorySchemaController:\r\n \t{GET [/profile/{repository}], produces [application/schema+json]}: schema(RootResourceInformation)\r\n DEBUG Mappings - \r\n \to.s.d.r.w.a.AlpsController:\r\n \t{GET [/profile/{repository}], produces [application/alps+json || */*]}: descriptor(RootResourceInformation)\r\n \t{OPTIONS [/profile/{repository}], produces [application/alps+json]}: alpsOptions()\r\n DEBUG Mappings - \r\n \to.s.d.r.w.ProfileController:\r\n \t{OPTIONS [/profile]}: profileOptions()\r\n \t{GET [/profile]}: listAllFormsOfMetadata()\r\n \r\n","link":"https://stackoverflow.com/questions/67908969/spring-mvc-controller-ignored","title":"Spring MVC controller ignored","body":"I have started playing with Springboot and Spring MVC
\nI have had no problems, but now I am attempting to utilize security.
\nWith the following pom, controller and curl request the curl request is completely ignored.
\nIf I run with debug, with a stop point in the controller, it never gets there.\nThere are no error messages, but there are hundreds of lines of negative matches.
\nMy controller does not show up under Mappings.
\nWhat do am I missing?
\n<?xml version="1.0" encoding="UTF-8"?>\n<project xmlns="http://maven.apache.org/POM/4.0.0"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">\n <modelVersion>4.0.0</modelVersion>\n <parent>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-parent</artifactId>\n <version>2.5.0</version>\n <relativePath /> <!-- lookup parent from repository -->\n </parent>\n <groupId>org.xxx</groupId>\n <artifactId>address-services</artifactId>\n <version>0.0.1-SNAPSHOT</version>\n <name>address-services</name>\n <description>REST services for address validation</description>\n \n <properties>\n <java.version>11</java.version>\n <skip_unit_tests>false</skip_unit_tests>\n <org.slf4j.version>1.7.28</org.slf4j.version>\n <org.xxx.version>9.2.0</org.xxx.version>\n <com.h2database.version>1.4.199</com.h2database.version> \n <commons.lang.version>2.4</commons.lang.version>\n <commons.io.version>2.6</commons.io.version>\n <dom4j.version>1.6.1</dom4j.version>\n <!-- <org.springframework.version>5.2.7.RELEASE</org.springframework.version> -->\n </properties>\n \n <dependencies>\n <!-- spring -->\n <!-- \n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-data-rest</artifactId>\n </dependency>\n --> \n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-security</artifactId>\n <exclusions>\n <exclusion>\n <groupId>ch.qos.logback</groupId>\n <artifactId>logback-classic</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n \n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-thymeleaf</artifactId>\n <exclusions>\n <exclusion>\n <groupId>ch.qos.logback</groupId>\n <artifactId>logback-classic</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n \n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-web</artifactId>\n <exclusions>\n <exclusion>\n <groupId>ch.qos.logback</groupId>\n <artifactId>logback-classic</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n \n <dependency>\n <groupId>org.thymeleaf.extras</groupId>\n <artifactId>thymeleaf-extras-springsecurity5</artifactId>\n <exclusions>\n <exclusion>\n <groupId>ch.qos.logback</groupId>\n <artifactId>logback-classic</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-test</artifactId>\n <scope>test</scope>\n <exclusions>\n <exclusion>\n <groupId>ch.qos.logback</groupId>\n <artifactId>logback-classic</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n \n <dependency>\n <groupId>org.springframework.security</groupId>\n <artifactId>spring-security-test</artifactId>\n <scope>test</scope>\n <exclusions>\n <exclusion>\n <groupId>ch.qos.logback</groupId>\n <artifactId>logback-classic</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n <!-- xxx -->\n <dependency>\n <groupId>org.xxx</groupId>\n <artifactId>xxx-core</artifactId>\n <version>${org.xxx.version}</version>\n \n <exclusions>\n <exclusion>\n <groupId>ch.qos.logback</groupId>\n <artifactId>logback-classic</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n <dependency>\n <groupId>org.xxx</groupId>\n <artifactId>xxx-test</artifactId>\n <version>${org.xxx.version}</version>\n <scope>test</scope>\n </dependency>\n\n <!-- <dependency> <groupId>org.xxx</groupId> <artifactId>xxx-hibernate</artifactId> \n <version>${org.xxx.hibernate.version}</version> </dependency> -->\n <dependency>\n <groupId>org.xxx</groupId>\n <artifactId>xxx-jcmdline</artifactId>\n <version>${org.xxx.version}</version>\n </dependency>\n \n <dependency>\n <groupId>org.xxx</groupId>\n <artifactId>xxx-jcmdline</artifactId>\n <version>${org.xxx.version}</version>\n </dependency>\n\n <!-- others -->\n <!-- \n <dependency>\n <groupId>commons-dbcp</groupId>\n <artifactId>commons-dbcp</artifactId>\n <version>1.2.2</version>\n <scope>test</scope>\n </dependency>\n -->\n </dependencies>\n\n <build>\n <plugins>\n <plugin>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-maven-plugin</artifactId>\n </plugin>\n </plugins>\n </build>\n\n</project>\n
\npackage org.xxx.address.service;
\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.xxx.address.beans.AddressBean;\nimport org.xxx.address.beans.AddressList;\nimport org.xxx.address.service.usps.UspsAddressValidator;\nimport org.xxx.address.usps.AddressValidationException;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.ui.Model;\nimport org.springframework.web.bind.annotation.ModelAttribute;\nimport org.springframework.web.bind.annotation.PostMapping;\nimport org.springframework.web.bind.annotation.RequestBody;\n\n@Controller\npublic class ValidationRest {\n\n Logger logger = LoggerFactory.getLogger(getClass());\n \n public ValidationRest() {\n }\n \n @PostMapping(value="/validateAddress")\n public String validateAddress(\n @ModelAttribute String address1,\n @ModelAttribute String address2,\n @ModelAttribute String city,\n @ModelAttribute String state,\n @ModelAttribute String zip,\n Model model) throws AddressValidationException {\n AddressBean address = new AddressBean(address1,address2,city,state,zip);\n List<AddressBean> list = new ArrayList<AddressBean>();\n list.add(address);\n UspsAddressValidator validator = new UspsAddressValidator();\n List<AddressBean> response = null;\n try {\n response = validator.validate(list);\n } catch (AddressValidationException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n throw e;\n }\n model.addAttribute("response",response);\n return "validatedAddress";\n }\n
\necho rooter > curl -u root -X POST
\nlocalhost:8080/validateAddress/&address1=410SouthMain&address2=&city=Romeo&state=MI&zip=78723
/\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\\n( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\\n \\\\/ ___)| |_)| | | | | || (_| | ) ) ) )\n ' |____| .__|_| |_|_| |_\\__, | / / / /\n =========|_|==============|___/=/_/_/_/\n :: Spring Boot :: (v2.5.0)\n\nINFO - 11:55:02,777 AddressApplication - Starting AddressApplication v0.0.1-SNAPSHOT using Java 14.0.2 on atx with PID 2737903 (/home/jjs/git/diamond-21-windoze/javautil/address-services/target/address-services-0.0.1-SNAPSHOT.jar started by jjs in /home/jjs/git/diamond-21-windoze/javautil/address-services)\nINFO - 11:55:02,777 AddressApplication - No active profile set, falling back to default profiles: default\nJun 09, 2021 11:55:03 AM org.apache.catalina.core.StandardService startInternal\nINFO: Starting service [Tomcat]\nJun 09, 2021 11:55:03 AM org.apache.catalina.core.StandardEngine startInternal\nINFO: Starting Servlet engine: [Apache Tomcat/9.0.46]\nJun 09, 2021 11:55:03 AM org.apache.catalina.core.ApplicationContext log\nINFO: Initializing Spring embedded WebApplicationContext\nINFO - 11:55:04,220 AddressApplication - Started AddressApplication in 1.74 seconds (JVM running for 2.089)\n\nNegative matches:\n-----------------\n\n ActiveMQAutoConfiguration:\n Did not match:\n - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)\n\n AopAutoConfiguration.AspectJAutoProxyingConfiguration:\n Did not match:\n - @ConditionalOnClass did not find required class 'org.aspectj.weaver.Advice' (OnClassCondition)\n\n ArtemisAutoConfiguration:\n Did not match:\n - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)\n\n continues for hundreds of lines.\n
\nDEBUG Mappings - \n o.s.d.r.w.RepositoryController:\n {OPTIONS [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForRepositories()\n {HEAD [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForRepositories()\n {GET [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: listRepositories()\nDEBUG Mappings - \n o.s.d.r.w.RepositoryEntityController:\n {POST [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: postCollectionResource(RootResourceInformation,PersistentEntityResource,PersistentEntityResourceAssembler,String)\n {OPTIONS [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForItemResource(RootResourceInformation)\n {HEAD [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForItemResource(RootResourceInformation,Serializable,PersistentEntityResourceAssembler)\n {GET [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: getItemResource(RootResourceInformation,Serializable,PersistentEntityResourceAssembler,HttpHeaders)\n {PUT [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: putItemResource(RootResourceInformation,PersistentEntityResource,Serializable,PersistentEntityResourceAssembler,ETag,String)\n {PATCH [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: patchItemResource(RootResourceInformation,PersistentEntityResource,Serializable,PersistentEntityResourceAssembler,ETag,String)\n {DELETE [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deleteItemResource(RootResourceInformation,Serializable,ETag)\n {OPTIONS [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForCollectionResource(RootResourceInformation)\n {HEAD [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headCollectionResource(RootResourceInformation,DefaultedPageable)\n {GET [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: getCollectionResource(RootResourceInformation,DefaultedPageable,Sort,PersistentEntityResourceAssembler)\n {GET [/{repository}], produces [application/x-spring-data-compact+json || text/uri-list]}: getCollectionResourceCompact(RootResourceInformation,DefaultedPageable,Sort,PersistentEntityResourceAssembler)\nDEBUG Mappings - \n o.s.d.r.w.RepositoryPropertyReferenceController:\n {GET [/{repository}/{id}/{property}/{propertyId}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: followPropertyReference(RootResourceInformation,Serializable,String,String,PersistentEntityResourceAssembler)\n {GET [/{repository}/{id}/{property}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: followPropertyReference(RootResourceInformation,Serializable,String,PersistentEntityResourceAssembler)\n {DELETE [/{repository}/{id}/{property}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deletePropertyReference(RootResourceInformation,Serializable,String)\n {GET [/{repository}/{id}/{property}], produces [text/uri-list]}: followPropertyReferenceCompact(RootResourceInformation,Serializable,String,HttpHeaders,PersistentEntityResourceAssembler)\n {[PATCH, PUT, POST] [/{repository}/{id}/{property}], consumes [application/json || application/x-spring-data-compact+json || text/uri-list], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: createPropertyReference(RootResourceInformation,HttpMethod,CollectionModel,Serializable,String)\n {DELETE [/{repository}/{id}/{property}/{propertyId}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deletePropertyReferenceId(RootResourceInformation,Serializable,String,String)\nDEBUG Mappings - \n o.s.d.r.w.RepositorySearchController:\n {OPTIONS [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForSearches(RootResourceInformation)\n {HEAD [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForSearches(RootResourceInformation)\n {GET [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: listSearches(RootResourceInformation)\n {GET [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: executeSearch(RootResourceInformation,MultiValueMap,String,DefaultedPageable,Sort,PersistentEntityResourceAssembler,HttpHeaders)\n {GET [/{repository}/search/{search}], produces [application/x-spring-data-compact+json]}: executeSearchCompact(RootResourceInformation,HttpHeaders,MultiValueMap,String,String,DefaultedPageable,Sort,PersistentEntityResourceAssembler)\n {OPTIONS [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForSearch(RootResourceInformation,String)\n {HEAD [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForSearch(RootResourceInformation,String)\nDEBUG RepositoryRestHandlerMapping - 27 mappings in org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping\nDEBUG Mappings - \n o.s.d.r.w.RepositorySchemaController:\n {GET [/profile/{repository}], produces [application/schema+json]}: schema(RootResourceInformation)\nDEBUG Mappings - \n o.s.d.r.w.a.AlpsController:\n {GET [/profile/{repository}], produces [application/alps+json || */*]}: descriptor(RootResourceInformation)\n {OPTIONS [/profile/{repository}], produces [application/alps+json]}: alpsOptions()\nDEBUG Mappings - \n o.s.d.r.w.ProfileController:\n {OPTIONS [/profile]}: profileOptions()\n {GET [/profile]}: listAllFormsOfMetadata()\n
\n"},{"tags":["flutter"],"comments":[{"owner":{"reputation":120,"user_id":15702670,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/22e4bff54c1a017062661f04eea08f73?s=128&d=identicon&r=PG&f=1","display_name":"sungkd123","link":"https://stackoverflow.com/users/15702670/sungkd123"},"edited":false,"score":0,"creation_date":1623257532,"post_id":67908426,"comment_id":120029990,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":49,"user_id":14363696,"user_type":"registered","profile_image":"https://lh4.googleusercontent.com/-7azapK1NJSI/AAAAAAAAAAI/AAAAAAAAAAA/AMZuucl-TROjxllcALgiTuCaonhIv3c_6Q/photo.jpg?sz=128","display_name":"sara s","link":"https://stackoverflow.com/users/14363696/sara-s"},"reply_to_user":{"reputation":120,"user_id":15702670,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/22e4bff54c1a017062661f04eea08f73?s=128&d=identicon&r=PG&f=1","display_name":"sungkd123","link":"https://stackoverflow.com/users/15702670/sungkd123"},"edited":false,"score":0,"creation_date":1623259194,"post_id":67908426,"comment_id":120030618,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":221,"user_id":11161388,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/38d79227cfe016067dd0713f46741bbc?s=128&d=identicon&r=PG&f=1","display_name":"Jaime Ortiz","link":"https://stackoverflow.com/users/11161388/jaime-ortiz"},"is_accepted":false,"score":0,"last_activity_date":1623259400,"last_edit_date":1623259400,"creation_date":1623257687,"answer_id":67908573,"question_id":67908426,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":49,"user_id":14363696,"user_type":"registered","profile_image":"https://lh4.googleusercontent.com/-7azapK1NJSI/AAAAAAAAAAI/AAAAAAAAAAA/AMZuucl-TROjxllcALgiTuCaonhIv3c_6Q/photo.jpg?sz=128","display_name":"sara s","link":"https://stackoverflow.com/users/14363696/sara-s"},"is_answered":false,"view_count":15,"answer_count":1,"score":0,"last_activity_date":1623259400,"creation_date":1623257032,"question_id":67908426,"share_link":"https://stackoverflow.com/q/67908426","body_markdown":"i want to generate signed apk in flutter but i dont have this option in build menu.\r\nwhen i open editing tool in new window, show me error of gradle. and buid menu dont have any option for genrate signed apk\r\n it is my gradle wrapper code.[![enter image description here][1]][1]\r\n\r\n \r\n\r\n \r\n\r\n #Fri Jun 23 08:50:38 CEST 2017\r\n distributionBase=GRADLE_USER_HOME\r\n distributionPath=wrapper/dists\r\n zipStoreBase=GRADLE_USER_HOME\r\n zipStorePath=wrapper/dists\r\n distributionUrl=https\\://services.gradle.org/distributions/gradle-6.7-all.zip\r\n\r\n[![enter image description here][2]][2]\r\n\r\n\r\n [![enter image description here][2]][2]\r\n [1]: https://i.stack.imgur.com/DJjw2.png\r\n [2]: https://i.stack.imgur.com/B4laZ.png","link":"https://stackoverflow.com/questions/67908426/how-generate-signed-apk-in-flutter","title":"how generate signed apk in flutter","body":"i want to generate signed apk in flutter but i dont have this option in build menu.\nwhen i open editing tool in new window, show me error of gradle. and buid menu dont have any option for genrate signed apk\nit is my gradle wrapper code.
\n#Fri Jun 23 08:50:38 CEST 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-6.7-all.zip\n
\n\n[![enter image description here][2]][2]\n
\n"},{"tags":["python"],"comments":[{"owner":{"reputation":37218,"user_id":4354477,"user_type":"registered","accept_rate":52,"profile_image":"https://i.stack.imgur.com/SuxtS.gif?s=128&g=1","display_name":"ForceBru","link":"https://stackoverflow.com/users/4354477/forcebru"},"edited":false,"score":2,"creation_date":1623250245,"post_id":67906523,"comment_id":120026601,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":16176951,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Gh4i1bLCTLQ1hTgQeGw_c7FjZQykuDKZO-mHYkQ=k-s128","display_name":"Zih69420","link":"https://stackoverflow.com/users/16176951/zih69420"},"reply_to_user":{"reputation":37218,"user_id":4354477,"user_type":"registered","accept_rate":52,"profile_image":"https://i.stack.imgur.com/SuxtS.gif?s=128&g=1","display_name":"ForceBru","link":"https://stackoverflow.com/users/4354477/forcebru"},"edited":false,"score":0,"creation_date":1623250622,"post_id":67906523,"comment_id":120026765,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16176951,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Gh4i1bLCTLQ1hTgQeGw_c7FjZQykuDKZO-mHYkQ=k-s128","display_name":"Zih69420","link":"https://stackoverflow.com/users/16176951/zih69420"},"is_answered":false,"view_count":19,"answer_count":0,"score":-1,"last_activity_date":1623259394,"creation_date":1623249984,"last_edit_date":1623259394,"question_id":67906523,"share_link":"https://stackoverflow.com/q/67906523","body_markdown":"using sublime text and when i do a simple print i get this error\r\n\r\n```none\r\nC:\\Python38\\python.exe: can't find '__main__' module in ''\r\n[Finished in 150ms]\r\n```\r\n\r\nI've used some other websites but can't really understand and or cant find a fix\r\nusing python\r\nlmk","link":"https://stackoverflow.com/questions/67906523/cant-find-main-module-in-in-sublime-text-using-python","title":"cant find _main_ module in' in sublime text using python","body":"using sublime text and when i do a simple print i get this error
\nC:\\Python38\\python.exe: can't find '__main__' module in ''\n[Finished in 150ms]\n
\nI've used some other websites but can't really understand and or cant find a fix\nusing python\nlmk
\n"},{"tags":["typescript","sorting","lodash"],"comments":[{"owner":{"reputation":99406,"user_id":3001761,"user_type":"registered","profile_image":"https://i.stack.imgur.com/feZwC.jpg?s=128&g=1","display_name":"jonrsharpe","link":"https://stackoverflow.com/users/3001761/jonrsharpe"},"edited":false,"score":0,"creation_date":1623258843,"post_id":67908720,"comment_id":120030484,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":908,"user_id":2547324,"user_type":"registered","accept_rate":57,"profile_image":"https://i.stack.imgur.com/bzaZD.png?s=128&g=1","display_name":"Peter The Angular Dude","link":"https://stackoverflow.com/users/2547324/peter-the-angular-dude"},"reply_to_user":{"reputation":99406,"user_id":3001761,"user_type":"registered","profile_image":"https://i.stack.imgur.com/feZwC.jpg?s=128&g=1","display_name":"jonrsharpe","link":"https://stackoverflow.com/users/3001761/jonrsharpe"},"edited":false,"score":0,"creation_date":1623259414,"post_id":67908720,"comment_id":120030713,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":908,"user_id":2547324,"user_type":"registered","accept_rate":57,"profile_image":"https://i.stack.imgur.com/bzaZD.png?s=128&g=1","display_name":"Peter The Angular Dude","link":"https://stackoverflow.com/users/2547324/peter-the-angular-dude"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623259390,"creation_date":1623258376,"last_edit_date":1623259390,"question_id":67908720,"share_link":"https://stackoverflow.com/q/67908720","body_markdown":"Based on my other question... https://stackoverflow.com/questions/67890798/i-need-to-loop-through-a-complex-json-array-of-objects-to-return-only-two-items\r\n\r\nI have an array of objects like so from the previous question\r\n\r\n[![enter image description here][1]][1]\r\n\r\nWhat I need done is and here's what I've tried, to sort on country_name only, the two character code is not necessary\r\n\r\nI used lodash to make the new array of objects. This will go into a dropdown.\r\n\r\n**I TRIED THIS FIRST: Nothing**\r\n\r\n // this.newJSONCountryArr.sort((a,b) => priorityIndex[a.country_name - b.country_alpha2_code]);\r\n\r\n**THEN THIS:**\r\n this.newJSONCountryArr.sort(this.compare);\r\n console.log('New Country Arr: ', self.newJSONCountryArr);\r\n\r\n compare(a: { country_name: string; }, b: { country_name: string; }): number{\r\n if (a.country_name < b.country_name) {\r\n return -1;\r\n }\r\n if (a.country_name > b.country_name) {\r\n return 1;\r\n }\r\n return 0;\r\n }\r\n\r\nI really don't need a number returned I simply want to sort the array of objects based on the objects I have by country_name.\r\n\r\nPerhaps I need to sort as they are placed or pushed into the new array as with this code snippet I used as the solution to the aforementioned question\r\n\r\n // Now to make a new array for only country code and name\r\n let results = _.map(this.countries, function (res) {\r\n let newResults = { country_name: res.columns[1].paramValue, country_alpha2_code: res.columns[2].paramValue };\r\n // console.log('New Results: ', newResults);\r\n self.newJSONCountryArr.push(newResults);\r\n });\r\n\r\n**UPDATE:**\r\n\r\nWhat I would like are all the countries sorted in the array of objects from this:\r\n\r\n {\r\n countries: [{\r\n "country_alpha2_code": "PW",\r\n "country_name": "PALAU"\r\n },{\r\n "country_alpha2_code": "US",\r\n "country_name": "UNITED STATES"\r\n }\r\n ]\r\n }\r\n\r\n**TO THIS:**\r\n\r\n {\r\n countries: [\r\n {\r\n "country_alpha2_code": "US",\r\n "country_name": "UNITED STATES"\r\n },{\r\n "country_alpha2_code": "PW",\r\n "country_name": "PALAU"\r\n }\r\n ]\r\n }\r\n\r\n [1]: https://i.stack.imgur.com/06kVt.png","link":"https://stackoverflow.com/questions/67908720/need-to-sort-an-array-of-objects-with-two-string-elements-countries-on-the-cou","title":"Need to sort an array of objects with two string elements (countries) on the country name typescript or lodash","body":"Based on my other question... I need to loop through a complex JSON ARRAY of objects to return only two items using LODASH with Typescript
\nI have an array of objects like so from the previous question
\n\nWhat I need done is and here's what I've tried, to sort on country_name only, the two character code is not necessary
\nI used lodash to make the new array of objects. This will go into a dropdown.
\nI TRIED THIS FIRST: Nothing
\n// this.newJSONCountryArr.sort((a,b) => priorityIndex[a.country_name - b.country_alpha2_code]);\n
\nTHEN THIS:\nthis.newJSONCountryArr.sort(this.compare);\nconsole.log('New Country Arr: ', self.newJSONCountryArr);
\ncompare(a: { country_name: string; }, b: { country_name: string; }): number{\n if (a.country_name < b.country_name) {\n return -1;\n }\n if (a.country_name > b.country_name) {\n return 1;\n }\n return 0;\n}\n
\nI really don't need a number returned I simply want to sort the array of objects based on the objects I have by country_name.
\nPerhaps I need to sort as they are placed or pushed into the new array as with this code snippet I used as the solution to the aforementioned question
\n// Now to make a new array for only country code and name\nlet results = _.map(this.countries, function (res) {\n let newResults = { country_name: res.columns[1].paramValue, country_alpha2_code: res.columns[2].paramValue };\n // console.log('New Results: ', newResults);\n self.newJSONCountryArr.push(newResults);\n});\n
\nUPDATE:
\nWhat I would like are all the countries sorted in the array of objects from this:
\n{\n countries: [{\n "country_alpha2_code": "PW",\n "country_name": "PALAU"\n },{\n "country_alpha2_code": "US",\n "country_name": "UNITED STATES"\n }\n ]\n}\n
\nTO THIS:
\n{\n countries: [\n {\n "country_alpha2_code": "US",\n "country_name": "UNITED STATES"\n },{\n "country_alpha2_code": "PW",\n "country_name": "PALAU"\n }\n ]\n}\n
\n"},{"tags":["reactjs","typescript","react-router-dom"],"answers":[{"owner":{"reputation":2480,"user_id":11360669,"user_type":"registered","profile_image":"https://graph.facebook.com/2103762023053861/picture?type=large","display_name":"Hagai Harari","link":"https://stackoverflow.com/users/11360669/hagai-harari"},"is_accepted":false,"score":0,"last_activity_date":1623259390,"creation_date":1623259390,"answer_id":67908967,"question_id":67904767,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":16,"user_id":10293700,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e73014f6225f56b4bef264efb26330be?s=128&d=identicon&r=PG&f=1","display_name":"Saurabh Anand","link":"https://stackoverflow.com/users/10293700/saurabh-anand"},"is_answered":false,"view_count":14,"answer_count":1,"score":0,"last_activity_date":1623259390,"creation_date":1623243948,"last_edit_date":1623258570,"question_id":67904767,"share_link":"https://stackoverflow.com/q/67904767","body_markdown":"\r\nProblem: Currently app is redirecting user from **PageA** to **ErrorPage** if some data is not found on **PageA** using react-router redirect. Now when the user is on **ErrorPage** and clicks on the browser back button. IT DOES NOT take back to **PageA**\r\nHere is a code example\r\n`\r\n//PageA - this component is inside BrowserRouter\r\n\r\n import React from 'react'\r\n \r\n const PageA = () = {\r\n \tconst data = null\r\n \treturn (\r\n \t\tdata ? (<PageAComponent />) : (\r\n \t\t<Redirect\r\n \t\t\t\tto={{\r\n \t\t\t\t\t\tpathname: "/errorPage",\r\n \t\t\t\t\t\tstate: { referrer: 'PageA' }\r\n \t\t\t\t}}\r\n \t\t/>\r\n \t\t)\r\n \t)\r\n }\r\n\r\n//ErrorPage\r\n\r\n import React from 'react'\r\n \r\n const ErrorPage = () = {\r\n \treturn (\r\n \t\t<>.....something is displayed.....</>)\r\n \t)\r\n }\r\n \r\n ","link":"https://stackoverflow.com/questions/67904767/not-able-to-go-back-to-original-page-from-where-react-router-redirect-was-call","title":"Not able to go back to original page from where React Router - Redirect was called","body":"Problem: Currently app is redirecting user from PageA to ErrorPage if some data is not found on PageA using react-router redirect. Now when the user is on ErrorPage and clicks on the browser back button. IT DOES NOT take back to PageA\nHere is a code example\n`\n//PageA - this component is inside BrowserRouter
\nimport React from 'react'\n\nconst PageA = () = {\n const data = null\n return (\n data ? (<PageAComponent />) : (\n <Redirect\n to={{\n pathname: "/errorPage",\n state: { referrer: 'PageA' }\n }}\n />\n )\n )\n}\n
\n//ErrorPage
\nimport React from 'react'\n\nconst ErrorPage = () = {\n return (\n <>.....something is displayed.....</>)\n )\n}\n
\n"},{"tags":["sql","arrays","string","select"],"comments":[{"owner":{"reputation":9568,"user_id":8651601,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/af7c1c409038facf6d3ee6f7f002350b?s=128&d=identicon&r=PG&f=1","display_name":"Kazi Mohammad Ali Nur","link":"https://stackoverflow.com/users/8651601/kazi-mohammad-ali-nur"},"edited":false,"score":0,"creation_date":1623258956,"post_id":67908843,"comment_id":120030532,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":15501638,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/357ed8eba8ad1a8e71d59d933d761d2b?s=128&d=identicon&r=PG&f=1","display_name":"Chris","link":"https://stackoverflow.com/users/15501638/chris"},"reply_to_user":{"reputation":9568,"user_id":8651601,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/af7c1c409038facf6d3ee6f7f002350b?s=128&d=identicon&r=PG&f=1","display_name":"Kazi Mohammad Ali Nur","link":"https://stackoverflow.com/users/8651601/kazi-mohammad-ali-nur"},"edited":false,"score":0,"creation_date":1623259239,"post_id":67908843,"comment_id":120030639,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":9568,"user_id":8651601,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/af7c1c409038facf6d3ee6f7f002350b?s=128&d=identicon&r=PG&f=1","display_name":"Kazi Mohammad Ali Nur","link":"https://stackoverflow.com/users/8651601/kazi-mohammad-ali-nur"},"edited":false,"score":0,"creation_date":1623259418,"post_id":67908843,"comment_id":120030715,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":9568,"user_id":8651601,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/af7c1c409038facf6d3ee6f7f002350b?s=128&d=identicon&r=PG&f=1","display_name":"Kazi Mohammad Ali Nur","link":"https://stackoverflow.com/users/8651601/kazi-mohammad-ali-nur"},"is_accepted":false,"score":0,"last_activity_date":1623259354,"creation_date":1623259354,"answer_id":67908954,"question_id":67908843,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":15501638,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/357ed8eba8ad1a8e71d59d933d761d2b?s=128&d=identicon&r=PG&f=1","display_name":"Chris","link":"https://stackoverflow.com/users/15501638/chris"},"is_answered":false,"view_count":15,"answer_count":1,"score":0,"last_activity_date":1623259388,"creation_date":1623258856,"last_edit_date":1623259388,"question_id":67908843,"share_link":"https://stackoverflow.com/q/67908843","body_markdown":"I think i did a big mistake and i can't figure how to do this thing:\r\n\r\nI have a table with a list of rooms and the column members (varchar) containing the list of accepted memberd id separated by commas (Es. 1,2,15,1000)\r\n\r\nI need to select all rooms where id IN members string. Any idea??? Something like\r\n\r\n SELECT * FROM rooms WHERE id IN rooms.members\r\n\r\n(I know it wont work, but i hope i explained myself ^^' )\r\n\r\n**EDIT**\r\n*I need to do a sql query with PDO in PHP, I'm using MySQL and the goal is to get a list of all the rows where the id is listed in the members list string*","link":"https://stackoverflow.com/questions/67908843/sql-how-to-select-rows-where-id-is-in-string-field","title":"SQL: how to select rows where id is in string field?","body":"I think i did a big mistake and i can't figure how to do this thing:
\nI have a table with a list of rooms and the column members (varchar) containing the list of accepted memberd id separated by commas (Es. 1,2,15,1000)
\nI need to select all rooms where id IN members string. Any idea??? Something like
\nSELECT * FROM rooms WHERE id IN rooms.members\n
\n(I know it wont work, but i hope i explained myself ^^' )
\nEDIT\nI need to do a sql query with PDO in PHP, I'm using MySQL and the goal is to get a list of all the rows where the id is listed in the members list string
\n"},{"tags":["node.js","google-app-engine","google-cloud-platform"],"answers":[{"owner":{"reputation":727,"user_id":9267296,"user_type":"registered","profile_image":"https://i.stack.imgur.com/6GnXc.png?s=128&g=1","display_name":"Edo Akse","link":"https://stackoverflow.com/users/9267296/edo-akse"},"is_accepted":false,"score":0,"last_activity_date":1623259384,"creation_date":1623259384,"answer_id":67908966,"question_id":67903298,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":119,"user_id":8734928,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/feaaefadcc84f8be4a598ce9f4b7e00e?s=128&d=identicon&r=PG&f=1","display_name":"Jul","link":"https://stackoverflow.com/users/8734928/jul"},"is_answered":false,"view_count":7,"answer_count":1,"score":0,"last_activity_date":1623259384,"creation_date":1623238293,"question_id":67903298,"share_link":"https://stackoverflow.com/q/67903298","body_markdown":"I've tried looking for a concrete answer to this but can't find an answer anywhere. I have a very long-running (but not particularly intensive) task that I want to run every 12 hours. \r\n\r\nI've set up a Google App Engine standard node.js Express server that runs this code, and it works perfectly when running locally. \r\n\r\nHowever, around halfway through (but completely at random) it fails with the following error messages:\r\n\r\n 2021-06-09T11:10:02.935685Z [start] 2021/06/09 11:10:02.934508 Quitting on terminated signal \r\n 2021-06-09T11:10:02.951563Z [start] 2021/06/09 11:10:02.951205 Start program failed: user application failed with exit code -1 (refer to stdout/stderr logs for more detail): signal: terminated \r\n 2021-06-09T11:10:10.891535Z [start] 2021/06/09 11:10:10.890652 Quitting on terminated signal \r\n 2021-06-09T11:10:10.997898Z [start] 2021/06/09 11:10:10.997488 Start program failed: user application failed with exit code -1 (refer to stdout/stderr logs for more detail): signal: terminated \r\n\r\nThose are the only logs I get that reference some kind of error - and there's a ton of error-handling in the code, none of which is triggered or logs anything at all. It's almost like the function just times out at some point - which leads me to wonder if there's a maximum execution time for Google App Engine?\r\n\r\nIs there a better way to do what I'm trying to do?","link":"https://stackoverflow.com/questions/67903298/google-app-engine-randomly-stops-executing","title":"Google App Engine randomly stops executing","body":"I've tried looking for a concrete answer to this but can't find an answer anywhere. I have a very long-running (but not particularly intensive) task that I want to run every 12 hours.
\nI've set up a Google App Engine standard node.js Express server that runs this code, and it works perfectly when running locally.
\nHowever, around halfway through (but completely at random) it fails with the following error messages:
\n2021-06-09T11:10:02.935685Z [start] 2021/06/09 11:10:02.934508 Quitting on terminated signal \n2021-06-09T11:10:02.951563Z [start] 2021/06/09 11:10:02.951205 Start program failed: user application failed with exit code -1 (refer to stdout/stderr logs for more detail): signal: terminated \n2021-06-09T11:10:10.891535Z [start] 2021/06/09 11:10:10.890652 Quitting on terminated signal \n2021-06-09T11:10:10.997898Z [start] 2021/06/09 11:10:10.997488 Start program failed: user application failed with exit code -1 (refer to stdout/stderr logs for more detail): signal: terminated \n
\nThose are the only logs I get that reference some kind of error - and there's a ton of error-handling in the code, none of which is triggered or logs anything at all. It's almost like the function just times out at some point - which leads me to wonder if there's a maximum execution time for Google App Engine?
\nIs there a better way to do what I'm trying to do?
\n"},{"tags":["sql","sql-server","tsql","sql-execution-plan"],"owner":{"reputation":5323,"user_id":1492229,"user_type":"registered","accept_rate":100,"profile_image":"https://i.stack.imgur.com/JpJrO.jpg?s=128&g=1","display_name":"asmgx","link":"https://stackoverflow.com/users/1492229/asmgx"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623259377,"creation_date":1623259377,"question_id":67908964,"share_link":"https://stackoverflow.com/q/67908964","body_markdown":"I have an insert statement in SQL Server.\r\n\r\nI tried it for a smaller subset, was fast\r\n\r\nincreased the number to 1milllion records and was fast 1 min 10 sec\r\n\r\nnow I doubled it and it seems stuck it has been running for 10 min now and no results\r\n\r\nI included the Plan when it was 5 min.\r\n\r\nhttps://www.brentozar.com/pastetheplan/?id=r15MPuC5u\r\n\r\nmaybe someone can tell me how to improve the process.\r\n\r\nPS. I added non clustered index on Tag (RepID).\r\n\r\nTag(iiD) is a primary Key\r\n\r\nReps(RepID) is a primary Key.\r\n\r\nWhile I am writing this. the process finished at 11:47\r\n\r\n\r\nhttps://www.brentozar.com/pastetheplan/?id=HJd9uOCcu\r\n\r\n\r\n\r\nHere is my code\r\n\r\n insert into R3..Tags (iID,DT,RepID,Tag,xmiID,iBegin,iEnd,Confidence,Polarity,Uncertainty,Conditional,Generic,HistoryOf,CodingScheme,Code,CUI,TUI,PreferredText,ValueBegin,ValueEnd,Value,Deleted,sKey,RepType)\r\n SELECT T.iID,T.DT,T.RepID,T.Tag,T.xmiID,T.iBegin,T.iEnd,T.Confidence,T.Polarity,T.Uncertainty,T.Conditional,T.Generic,T.HistoryOf,T.CodingScheme,T.Code,T.CUI,T.TUI,T.PreferredText,T.ValueBegin,T.ValueEnd,T.Value,T.Deleted,T.sKey,R.RepType\r\n FROM Recovery..tags T inner join Recovery..Reps R on T.RepID = R.RepID\r\n where T.iID between 2000001 and 4000000\r\n\r\n\r\n","link":"https://stackoverflow.com/questions/67908964/why-my-query-become-too-slow-when-number-of-records-increased","title":"Why my query become too slow when number of records increased","body":"I have an insert statement in SQL Server.
\nI tried it for a smaller subset, was fast
\nincreased the number to 1milllion records and was fast 1 min 10 sec
\nnow I doubled it and it seems stuck it has been running for 10 min now and no results
\nI included the Plan when it was 5 min.
\nhttps://www.brentozar.com/pastetheplan/?id=r15MPuC5u
\nmaybe someone can tell me how to improve the process.
\nPS. I added non clustered index on Tag (RepID).
\nTag(iiD) is a primary Key
\nReps(RepID) is a primary Key.
\nWhile I am writing this. the process finished at 11:47
\nhttps://www.brentozar.com/pastetheplan/?id=HJd9uOCcu
\nHere is my code
\ninsert into R3..Tags (iID,DT,RepID,Tag,xmiID,iBegin,iEnd,Confidence,Polarity,Uncertainty,Conditional,Generic,HistoryOf,CodingScheme,Code,CUI,TUI,PreferredText,ValueBegin,ValueEnd,Value,Deleted,sKey,RepType)\nSELECT T.iID,T.DT,T.RepID,T.Tag,T.xmiID,T.iBegin,T.iEnd,T.Confidence,T.Polarity,T.Uncertainty,T.Conditional,T.Generic,T.HistoryOf,T.CodingScheme,T.Code,T.CUI,T.TUI,T.PreferredText,T.ValueBegin,T.ValueEnd,T.Value,T.Deleted,T.sKey,R.RepType\nFROM Recovery..tags T inner join Recovery..Reps R on T.RepID = R.RepID\nwhere T.iID between 2000001 and 4000000\n
\n"},{"tags":["javascript"],"comments":[{"owner":{"reputation":4717,"user_id":479156,"user_type":"registered","accept_rate":92,"profile_image":"https://i.stack.imgur.com/x9N3C.jpg?s=128&g=1","display_name":"Ivar","link":"https://stackoverflow.com/users/479156/ivar"},"edited":false,"score":0,"creation_date":1623259424,"post_id":67908963,"comment_id":120030716,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16073880,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5526fcc45828a5008925a70dc290cc16?s=128&d=identicon&r=PG&f=1","display_name":"kaciy68680","link":"https://stackoverflow.com/users/16073880/kaciy68680"},"is_answered":false,"view_count":11,"answer_count":0,"score":0,"last_activity_date":1623259370,"creation_date":1623259370,"question_id":67908963,"share_link":"https://stackoverflow.com/q/67908963","body_markdown":"I'm new to JS can someone help me explain with words what is this\r\n```\r\n const newmode = pickBody.classList.contains('darkmode') ? 'darkmode' : 'lightmode';\r\n```\r\nso how if and else is used in this case","link":"https://stackoverflow.com/questions/67908963/if-and-else-shortened","title":"If and Else shortened","body":"I'm new to JS can someone help me explain with words what is this
\n const newmode = pickBody.classList.contains('darkmode') ? 'darkmode' : 'lightmode';\n
\nso how if and else is used in this case
\n"},{"tags":["flutter","android-studio","dart","flutter-layout"],"answers":[{"owner":{"reputation":613,"user_id":9138027,"user_type":"registered","profile_image":"https://i.stack.imgur.com/SpEvC.jpg?s=128&g=1","display_name":"Ali Yar Khan","link":"https://stackoverflow.com/users/9138027/ali-yar-khan"},"is_accepted":false,"score":0,"last_activity_date":1623259370,"creation_date":1623259370,"answer_id":67908962,"question_id":67902107,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":613,"user_id":9138027,"user_type":"registered","profile_image":"https://i.stack.imgur.com/SpEvC.jpg?s=128&g=1","display_name":"Ali Yar Khan","link":"https://stackoverflow.com/users/9138027/ali-yar-khan"},"is_answered":false,"view_count":21,"answer_count":1,"score":0,"last_activity_date":1623259370,"creation_date":1623233769,"question_id":67902107,"share_link":"https://stackoverflow.com/q/67902107","body_markdown":"I have this design which i want to create \r\n\r\n[![Bottom button image][1]][1]\r\n\r\n\r\nI have tried this code :\r\n\r\n @override\r\n Path getClip(Size size) {\r\n var path = Path();\r\n \r\n path.lineTo(0.0, size.height - 50);\r\n path.lineTo(size.width / 2 - 35 , size.height -50);\r\n \r\n path.quadraticBezierTo(size.width / 2 - 35 , size.height , size.width / 2 + 120 , size.height);\r\n \r\n path.quadraticBezierTo(size.width /2 + 35 , size.height, size.width / 2 + 35, size.height - 50);\r\n \r\n path.lineTo(size.width / 2 + size.width, size.height - 50);\r\n path.lineTo(size.width, 0.0);\r\n \r\n path.close();\r\n return path;\r\n \r\n \r\n }\r\n\r\nBut i am failing to do ... The result i am getting is \r\n\r\n[![My result][2]][2]\r\n\r\n\r\n [1]: https://i.stack.imgur.com/5GiXt.jpg\r\n [2]: https://i.stack.imgur.com/CVDhq.png\r\n\r\nI can't understand what i am doing wrong. Pleas help me also i want that shadow as well after clipping at the bottom. but i am not getting that to make things visible i change the colour of scaffold to grey","link":"https://stackoverflow.com/questions/67902107/how-to-clip-the-container-with-half-circle-outward-in-bottom-center","title":"How to clip the container with half circle outward in bottom center","body":"I have this design which i want to create
\n\nI have tried this code :
\n@override\n Path getClip(Size size) {\n var path = Path();\n\n path.lineTo(0.0, size.height - 50);\n path.lineTo(size.width / 2 - 35 , size.height -50);\n\n path.quadraticBezierTo(size.width / 2 - 35 , size.height , size.width / 2 + 120 , size.height);\n\n path.quadraticBezierTo(size.width /2 + 35 , size.height, size.width / 2 + 35, size.height - 50);\n\n path.lineTo(size.width / 2 + size.width, size.height - 50);\n path.lineTo(size.width, 0.0);\n\n path.close();\n return path;\n\n\n }\n
\nBut i am failing to do ... The result i am getting is
\n\nI can't understand what i am doing wrong. Pleas help me also i want that shadow as well after clipping at the bottom. but i am not getting that to make things visible i change the colour of scaffold to grey
\n"},{"tags":["javascript","google-sheets-api"],"comments":[{"owner":{"reputation":1411,"user_id":5103577,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Okf5j.png?s=128&g=1","display_name":"Luke Borowy","link":"https://stackoverflow.com/users/5103577/luke-borowy"},"edited":false,"score":0,"creation_date":1623255883,"post_id":67908008,"comment_id":120029253,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":11,"user_id":15790364,"user_type":"registered","profile_image":"https://lh6.googleusercontent.com/-Wl25wDidqNY/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuclne4ErijuCUDv6MilqD0L9JrTI8Q/s96-c/photo.jpg?sz=128","display_name":"light1","link":"https://stackoverflow.com/users/15790364/light1"},"reply_to_user":{"reputation":1411,"user_id":5103577,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Okf5j.png?s=128&g=1","display_name":"Luke Borowy","link":"https://stackoverflow.com/users/5103577/luke-borowy"},"edited":false,"score":0,"creation_date":1623257213,"post_id":67908008,"comment_id":120029862,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":1411,"user_id":5103577,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Okf5j.png?s=128&g=1","display_name":"Luke Borowy","link":"https://stackoverflow.com/users/5103577/luke-borowy"},"is_accepted":false,"score":0,"last_activity_date":1623259368,"last_edit_date":1623259368,"creation_date":1623258341,"answer_id":67908709,"question_id":67908008,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":11,"user_id":15790364,"user_type":"registered","profile_image":"https://lh6.googleusercontent.com/-Wl25wDidqNY/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuclne4ErijuCUDv6MilqD0L9JrTI8Q/s96-c/photo.jpg?sz=128","display_name":"light1","link":"https://stackoverflow.com/users/15790364/light1"},"is_answered":false,"view_count":18,"answer_count":1,"score":0,"last_activity_date":1623259368,"creation_date":1623255411,"question_id":67908008,"share_link":"https://stackoverflow.com/q/67908008","body_markdown":" var params1 = {\r\n spreadsheetId: 'Id', \r\n range: "sheet 1!A2",\r\n };\r\n \r\n var clearValuesRequestBody = {\r\n };\r\n \r\n var request = await gapi.client.sheets.spreadsheets.values.clear(params1, clearValuesRequestBody);\r\n\r\nI am trying to delete a row in google sheets using google sheets API in javascript. But I am able to delete only the first cell of the row. I believe there has to be something in clear values request body but I don't know what. Also if you can suggest me how to remove that blank row that has been created by deleting this row, that would be great.","link":"https://stackoverflow.com/questions/67908008/how-to-delete-row-in-google-sheets-using-api-v4-in-javascript","title":"how to delete row in google sheets using api v4 in Javascript?","body":" var params1 = {\n spreadsheetId: 'Id', \n range: "sheet 1!A2",\n };\n \n var clearValuesRequestBody = {\n };\n \n var request = await gapi.client.sheets.spreadsheets.values.clear(params1, clearValuesRequestBody);\n
\nI am trying to delete a row in google sheets using google sheets API in javascript. But I am able to delete only the first cell of the row. I believe there has to be something in clear values request body but I don't know what. Also if you can suggest me how to remove that blank row that has been created by deleting this row, that would be great.
\n"},{"tags":["azure","azure-active-directory","azure-ad-b2c","azure-ad-b2c-custom-policy"],"owner":{"reputation":541,"user_id":1918727,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/88505b04605caa05be0ad1606e5133e1?s=128&d=identicon&r=PG&f=1","display_name":"J.J","link":"https://stackoverflow.com/users/1918727/j-j"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259359,"creation_date":1623259359,"question_id":67908959,"share_link":"https://stackoverflow.com/q/67908959","body_markdown":"I want to allow multiple Azure AD customers to sign-in into my app using their own AAD accounts.\r\n\r\nFor that I was considering this tutorial [Set up sign-in for multi-tenant Azure Active Directory using custom policies in Azure Active Directory B2C](https://docs.microsoft.com/en-us/azure/active-directory-b2c/identity-provider-azure-ad-multi-tenant?pivots=b2c-custom-policy), but in the section "***Configure Azure AD as an identity provider***" **point 5** says "*Under the TechnicalProfile element, update the value for DisplayName, for example, Contoso Employee. This value is displayed on the sign-in button on your sign-in page.*"\r\n\r\nBy reading that section it seems to me that I will end up with an array of buttons, one for each AAD customer.\r\n\r\nIs it possible to have a single button, like "Work account" to encapsulate all possible AAD tenants? and then internally figure out which ones is the right one?(maybe based on email domain..)","link":"https://stackoverflow.com/questions/67908959/set-up-sign-in-for-multi-tenant-azure-active-directory-single-button-for-all-t","title":"Set up sign-in for multi-tenant Azure Active Directory - Single Button for all tenants","body":"I want to allow multiple Azure AD customers to sign-in into my app using their own AAD accounts.
\nFor that I was considering this tutorial Set up sign-in for multi-tenant Azure Active Directory using custom policies in Azure Active Directory B2C, but in the section "Configure Azure AD as an identity provider" point 5 says "Under the TechnicalProfile element, update the value for DisplayName, for example, Contoso Employee. This value is displayed on the sign-in button on your sign-in page."
\nBy reading that section it seems to me that I will end up with an array of buttons, one for each AAD customer.
\nIs it possible to have a single button, like "Work account" to encapsulate all possible AAD tenants? and then internally figure out which ones is the right one?(maybe based on email domain..)
\n"},{"tags":["sql","group-by"],"comments":[{"owner":{"reputation":3307,"user_id":1459036,"user_type":"registered","accept_rate":56,"profile_image":"https://i.stack.imgur.com/yeDJp.jpg?s=128&g=1","display_name":"Brad","link":"https://stackoverflow.com/users/1459036/brad"},"edited":false,"score":1,"creation_date":1623153965,"post_id":67886455,"comment_id":119991366,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":672,"user_id":4594961,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/30a5323629c0d684810a8c996965299c?s=128&d=identicon&r=PG&f=1","display_name":"Marko Ivkovic","link":"https://stackoverflow.com/users/4594961/marko-ivkovic"},"edited":false,"score":1,"creation_date":1623153977,"post_id":67886455,"comment_id":119991376,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":158,"user_id":16119285,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b406f241444f9a189020055819cb3c0b?s=128&d=identicon&r=PG&f=1","display_name":"banana_99","link":"https://stackoverflow.com/users/16119285/banana-99"},"edited":false,"score":0,"creation_date":1623155414,"post_id":67886455,"comment_id":119992042,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":38271,"user_id":905902,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a18869332564b1c3dfad9586d37095b2?s=128&d=identicon&r=PG","display_name":"wildplasser","link":"https://stackoverflow.com/users/905902/wildplasser"},"edited":false,"score":0,"creation_date":1623156765,"post_id":67886455,"comment_id":119992661,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":429,"user_id":10293830,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-Zs3buhL4ipA/AAAAAAAAAAI/AAAAAAAAAAA/APUIFaPvo3joFAuJJsZ8thzVW4kBg4gkdg/mo/photo.jpg?sz=128","display_name":"PankajSanwal","link":"https://stackoverflow.com/users/10293830/pankajsanwal"},"is_accepted":false,"score":0,"last_activity_date":1623157101,"creation_date":1623157101,"answer_id":67887452,"question_id":67886455,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":48,"user_id":9531348,"user_type":"registered","profile_image":"https://i.stack.imgur.com/9LPzr.png?s=128&g=1","display_name":"DvirB","link":"https://stackoverflow.com/users/9531348/dvirb"},"is_accepted":false,"score":0,"last_activity_date":1623157608,"creation_date":1623157608,"answer_id":67887587,"question_id":67886455,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16163856,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/acda53d44c9e7cecda2074ad6f40dbaf?s=128&d=identicon&r=PG&f=1","display_name":"Cancillero","link":"https://stackoverflow.com/users/16163856/cancillero"},"is_answered":false,"view_count":44,"closed_date":1623162012,"answer_count":2,"score":0,"last_activity_date":1623259358,"creation_date":1623153569,"last_edit_date":1623259358,"question_id":67886455,"share_link":"https://stackoverflow.com/q/67886455","body_markdown":"I have a table like attached. I want to write a query where the column `Status` changes if a `Group` has a row with type `Reexam` and if the corresponding `Group` has status `Passed`. E.g., the `Status` should change to `Passed` for the whole group.\r\n\r\nAttached example\r\n\r\n[![example][1]][1]\r\n\r\n\r\n [1]: https://i.stack.imgur.com/0tVNf.png","link":"https://stackoverflow.com/questions/67886455/select-rows-by-a-common-column-and-display-them-with-different-values","closed_reason":"Needs details or clarity","title":"SELECT rows by a common column and display them with different values","body":"I have a table like attached. I want to write a query where the column Status
changes if a Group
has a row with type Reexam
and if the corresponding Group
has status Passed
. E.g., the Status
should change to Passed
for the whole group.
Attached example
\n\n"},{"tags":["azure","azure-web-app-service"],"owner":{"reputation":48,"user_id":8545033,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ed98a45259e197b36dfb72f313a4cffd?s=128&d=identicon&r=PG&f=1","display_name":"Alec Jones","link":"https://stackoverflow.com/users/8545033/alec-jones"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259358,"creation_date":1623259358,"question_id":67908958,"share_link":"https://stackoverflow.com/q/67908958","body_markdown":"I'm trying to pull my changes from the git repository but I got the error **Filename too long**.\r\n\r\nTo resolve this issue, I tried running the command `git config --system core.longpaths true` but I get `Permission denied error: could not lock config file` error. I think this is normal because running the command above requires admin CLI.\r\n\r\nWould like to ask if there's any way I can enable the longpaths in azure web app service?\r\n\r\n","link":"https://stackoverflow.com/questions/67908958/file-name-too-long-in-azure-web-app-service-ci-cd","title":"File name too long in Azure Web App Service CI/CD","body":"I'm trying to pull my changes from the git repository but I got the error Filename too long.
\nTo resolve this issue, I tried running the command git config --system core.longpaths true
but I get Permission denied error: could not lock config file
error. I think this is normal because running the command above requires admin CLI.
Would like to ask if there's any way I can enable the longpaths in azure web app service?
\n"},{"tags":["c"],"comments":[{"owner":{"reputation":598476,"user_id":1491895,"user_type":"registered","accept_rate":69,"profile_image":"https://www.gravatar.com/avatar/82f9e178a16364bf561d0ed4da09a35d?s=128&d=identicon&r=PG","display_name":"Barmar","link":"https://stackoverflow.com/users/1491895/barmar"},"edited":false,"score":1,"creation_date":1623256295,"post_id":67908167,"comment_id":120029436,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":598476,"user_id":1491895,"user_type":"registered","accept_rate":69,"profile_image":"https://www.gravatar.com/avatar/82f9e178a16364bf561d0ed4da09a35d?s=128&d=identicon&r=PG","display_name":"Barmar","link":"https://stackoverflow.com/users/1491895/barmar"},"edited":false,"score":1,"creation_date":1623256343,"post_id":67908167,"comment_id":120029459,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":598476,"user_id":1491895,"user_type":"registered","accept_rate":69,"profile_image":"https://www.gravatar.com/avatar/82f9e178a16364bf561d0ed4da09a35d?s=128&d=identicon&r=PG","display_name":"Barmar","link":"https://stackoverflow.com/users/1491895/barmar"},"edited":false,"score":2,"creation_date":1623256363,"post_id":67908167,"comment_id":120029470,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":598476,"user_id":1491895,"user_type":"registered","accept_rate":69,"profile_image":"https://www.gravatar.com/avatar/82f9e178a16364bf561d0ed4da09a35d?s=128&d=identicon&r=PG","display_name":"Barmar","link":"https://stackoverflow.com/users/1491895/barmar"},"edited":false,"score":1,"creation_date":1623256408,"post_id":67908167,"comment_id":120029488,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":109,"user_id":11478529,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/29b4713b937df82a2612d28bd03b5564?s=128&d=identicon&r=PG&f=1","display_name":"Akil","link":"https://stackoverflow.com/users/11478529/akil"},"reply_to_user":{"reputation":598476,"user_id":1491895,"user_type":"registered","accept_rate":69,"profile_image":"https://www.gravatar.com/avatar/82f9e178a16364bf561d0ed4da09a35d?s=128&d=identicon&r=PG","display_name":"Barmar","link":"https://stackoverflow.com/users/1491895/barmar"},"edited":false,"score":0,"creation_date":1623256436,"post_id":67908167,"comment_id":120029509,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":175231,"user_id":140750,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/4c7af12cad08c95bc206a9636d164224?s=128&d=identicon&r=PG","display_name":"William Pursell","link":"https://stackoverflow.com/users/140750/william-pursell"},"is_accepted":false,"score":0,"last_activity_date":1623256517,"creation_date":1623256517,"answer_id":67908273,"question_id":67908167,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":3001,"user_id":4228131,"user_type":"registered","accept_rate":100,"profile_image":"https://i.stack.imgur.com/RyKUe.jpg?s=128&g=1","display_name":"WedaPashi","link":"https://stackoverflow.com/users/4228131/wedapashi"},"is_accepted":false,"score":0,"last_activity_date":1623258536,"last_edit_date":1623258536,"creation_date":1623257546,"answer_id":67908550,"question_id":67908167,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":109,"user_id":11478529,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/29b4713b937df82a2612d28bd03b5564?s=128&d=identicon&r=PG&f=1","display_name":"Akil","link":"https://stackoverflow.com/users/11478529/akil"},"is_answered":false,"view_count":41,"answer_count":2,"score":0,"last_activity_date":1623259358,"creation_date":1623256086,"last_edit_date":1623259358,"question_id":67908167,"share_link":"https://stackoverflow.com/q/67908167","body_markdown":"I am solving a problem in which I have a date (YYYY-MM-DD) as user input and I need to find out the day(Sunday, Monday,.. ). I have tried to remove the hyphen so that I can proceed with Zellor's rule. To achieve that I used a loop. However, it doesn't seem to work.\r\nHere's is my code:\r\n\r\n #include<stdio.h>\r\n int main(){\r\n char date[11], datenum[9]; \r\n int date_num;\r\n printf("Enter the date in yyyy-mm-dd format\\n");\r\n scanf("%s", &date);\r\n int j = 0;\r\n for (int i=0; i<10; i++){\r\n if (date[i]!='-' && j<8){\r\n datenum[j] = date[i];\r\n\r\n j++;\r\n }\r\n } \r\n printf("%s\\n", datenum);\r\n return 0;\r\n }\r\nI was expecting 20210609 as output when I gave 2021-06-09 as input but that doesn't seem to be the case. Instead, I got 202106092021-06-09.","link":"https://stackoverflow.com/questions/67908167/trying-to-remove-hyphens-from-a-string-in-c","title":"Trying to remove hyphens from a string in C","body":"I am solving a problem in which I have a date (YYYY-MM-DD) as user input and I need to find out the day(Sunday, Monday,.. ). I have tried to remove the hyphen so that I can proceed with Zellor's rule. To achieve that I used a loop. However, it doesn't seem to work.\nHere's is my code:
\n#include<stdio.h>\nint main(){\n char date[11], datenum[9]; \n int date_num;\n printf("Enter the date in yyyy-mm-dd format\\n");\n scanf("%s", &date);\n int j = 0;\n for (int i=0; i<10; i++){\n if (date[i]!='-' && j<8){\n datenum[j] = date[i];\n\n j++;\n }\n } \n printf("%s\\n", datenum);\n return 0;\n}\n
\nI was expecting 20210609 as output when I gave 2021-06-09 as input but that doesn't seem to be the case. Instead, I got 202106092021-06-09.
\n"},{"tags":["python","pandas","pandas-groupby"],"owner":{"reputation":53,"user_id":12489364,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AAuE7mC3ZFowV-wqtW5plJtElEs1g7LEbfYt9C6W6y58Sw=k-s128","display_name":"Dan Murphy","link":"https://stackoverflow.com/users/12489364/dan-murphy"},"is_answered":false,"view_count":9,"answer_count":0,"score":0,"last_activity_date":1623259358,"creation_date":1623259358,"question_id":67908957,"share_link":"https://stackoverflow.com/q/67908957","body_markdown":"I have a dataframe with 3 columns, Date, Time and Usage. The times are in 15 minute intervals (some intervals may/will be missing). The Date column lists every day in the month (possible to have more than one month).\r\n\r\nThe goal is to sum up the usage values by hour per day per month. I was able to accomplish this with a groupby, but it creates a multi-index Series. When I try adding "reset_index()" to the end of my groupby I get an error since I am using the same column twice (once by month and once by day). I have a feeling I need to alias my columns so I can then flatten the multi-index but I'm not sure how.\r\n\r\n*note I know I can just create "helper" columns for the day and hour and use those in my groupby, but I was hoping to not have to do that. \r\n\r\n import pandas as pd\r\n \r\n df = pd.read_csv('Interval Data', sep=';')\r\n \r\n df.columns = df.columns.str.replace(' ', '')\r\n df = df[['END_TIME', 'USAGE_DATE', 'USAGE']]\r\n df['END_TIME'] = pd.to_datetime(df['END_TIME'])\r\n df['USAGE_DATE'] = pd.to_datetime(df['USAGE_DATE'])\r\n \r\n grp_df = df.groupby([df.USAGE_DATE.dt.month, df.USAGE_DATE.dt.day, df.END_TIME.dt.hour])['USAGE'].sum()\r\n \r\n print(grp_df.head())\r\n\r\n","link":"https://stackoverflow.com/questions/67908957/python-pandas-dataframe-difficulties-flattening-after-groupby","title":"Python Pandas DataFrame difficulties flattening after GroupBy","body":"I have a dataframe with 3 columns, Date, Time and Usage. The times are in 15 minute intervals (some intervals may/will be missing). The Date column lists every day in the month (possible to have more than one month).
\nThe goal is to sum up the usage values by hour per day per month. I was able to accomplish this with a groupby, but it creates a multi-index Series. When I try adding "reset_index()" to the end of my groupby I get an error since I am using the same column twice (once by month and once by day). I have a feeling I need to alias my columns so I can then flatten the multi-index but I'm not sure how.
\n*note I know I can just create "helper" columns for the day and hour and use those in my groupby, but I was hoping to not have to do that.
\nimport pandas as pd\n\ndf = pd.read_csv('Interval Data', sep=';')\n\ndf.columns = df.columns.str.replace(' ', '')\ndf = df[['END_TIME', 'USAGE_DATE', 'USAGE']]\ndf['END_TIME'] = pd.to_datetime(df['END_TIME'])\ndf['USAGE_DATE'] = pd.to_datetime(df['USAGE_DATE'])\n\ngrp_df = df.groupby([df.USAGE_DATE.dt.month, df.USAGE_DATE.dt.day, df.END_TIME.dt.hour])['USAGE'].sum()\n\nprint(grp_df.head())\n
\n"},{"tags":["javascript","node.js","next.js","serverless","vercel"],"owner":{"reputation":23,"user_id":12302959,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/47ec7ff6e00b42135ec6a1effc594401?s=128&d=identicon&r=PG&f=1","display_name":"Alina Homyakova","link":"https://stackoverflow.com/users/12302959/alina-homyakova"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259357,"creation_date":1623259357,"question_id":67908956,"share_link":"https://stackoverflow.com/q/67908956","body_markdown":"This code gets the bitcoin rate on usual js.\r\n \r\n function getRate(){\r\n \t// https://api.coindesk.com/v1/bpi/currentprice.json\r\n \t$.get(\r\n \t\t"https://api.coindesk.com/v1/bpi/currentprice.json",\r\n \t\tfunction(data){\r\n \t\t\tdata = JSON.parse(data);\r\n \t\t\tconsole.log(data);\r\n \t\t}\r\n \t);\r\n }\r\n \r\n function getHistoryRate(){\r\n \t// https://api.coindesk.com/v1/bpi/currentprice.json\r\n \t$.get(\r\n \t\t"https://api.coindesk.com/v1/bpi/historical/close.json",\r\n \t\t{\r\n \t\t\t"start" : $('#date1').val(),\r\n \t\t\t"end" : $('#date2').val()\r\n \t\t},\r\n \t\tfunction(data){\r\n \t\t\tdata = JSON.parse(data);\r\n \t\t\tconsole.log(data);\r\n \t\t}\r\n \t);\r\n }\r\n\r\n\r\nHow to realize the same logic using Next.js and Vercel serverless functions?","link":"https://stackoverflow.com/questions/67908956/how-to-use-correctly-serverless-functions-to-get-bitcoin-rate","title":"How to use correctly serverless functions to get Bitcoin rate?","body":"This code gets the bitcoin rate on usual js.
\nfunction getRate(){\n // https://api.coindesk.com/v1/bpi/currentprice.json\n $.get(\n "https://api.coindesk.com/v1/bpi/currentprice.json",\n function(data){\n data = JSON.parse(data);\n console.log(data);\n }\n );\n}\n\nfunction getHistoryRate(){\n // https://api.coindesk.com/v1/bpi/currentprice.json\n $.get(\n "https://api.coindesk.com/v1/bpi/historical/close.json",\n {\n "start" : $('#date1').val(),\n "end" : $('#date2').val()\n },\n function(data){\n data = JSON.parse(data);\n console.log(data);\n }\n );\n}\n
\nHow to realize the same logic using Next.js and Vercel serverless functions?
\n"},{"tags":["flutter","dart"],"owner":{"reputation":1,"user_id":15454445,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a99de6a7ef1f09a888f0938f61b1c74b?s=128&d=identicon&r=PG&f=1","display_name":"Mohamed Salah","link":"https://stackoverflow.com/users/15454445/mohamed-salah"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259355,"creation_date":1623259355,"question_id":67908955,"share_link":"https://stackoverflow.com/q/67908955","body_markdown":"I'm using Flutter and I need to create a simple **mobile application** that open a webpage then click on the elements .\r\n\r\nfor example open YouTube and login with user and password then search for a word (**programmatically when I click a button**).\r\n\r\nI created python script that doing all of that using selenium but I couldn't convert it to apk.\r\n\r\nso I'm trying to learn flutter to build it (and if there is easier way to create mobile app just tell me) **so** just tell me the steps for creating this Flutter app that doing these tasks automatically. \r\n\r\nThanks. \r\n","link":"https://stackoverflow.com/questions/67908955/flutter-automatically-open-webpage-then-click-elements","title":"Flutter automatically open webpage, then click elements","body":"I'm using Flutter and I need to create a simple mobile application that open a webpage then click on the elements .
\nfor example open YouTube and login with user and password then search for a word (programmatically when I click a button).
\nI created python script that doing all of that using selenium but I couldn't convert it to apk.
\nso I'm trying to learn flutter to build it (and if there is easier way to create mobile app just tell me) so just tell me the steps for creating this Flutter app that doing these tasks automatically.
\nThanks.
\n"},{"tags":["javascript","css","slick.js"],"answers":[{"owner":{"reputation":1060,"user_id":6398325,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/166a2efcf4426448f22068976b35a281?s=128&d=identicon&r=PG&f=1","display_name":"Gunther","link":"https://stackoverflow.com/users/6398325/gunther"},"is_accepted":false,"score":0,"last_activity_date":1623259355,"last_edit_date":1623259355,"creation_date":1623254243,"answer_id":67907714,"question_id":67905648,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":27,"user_id":7873564,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-9qqKI43jxik/AAAAAAAAAAI/AAAAAAAAB1g/ptrCcxi77Lc/photo.jpg?sz=128","display_name":"Xavier Godbout","link":"https://stackoverflow.com/users/7873564/xavier-godbout"},"is_answered":false,"view_count":15,"answer_count":1,"score":1,"last_activity_date":1623259355,"creation_date":1623247147,"last_edit_date":1623252497,"question_id":67905648,"share_link":"https://stackoverflow.com/q/67905648","body_markdown":"I'm trying to create a timeline using Slick carousel. What I'm trying to achieve is as you progress in the timeline, all the previous slides stay colored and when you go back they turn back to grey. I tried my best with onAfterChange and onBeforeChange but I can't target multiple previous slides, only the last previous slides.\r\n\r\nHere's a JSFiddle of my timeline : https://jsfiddle.net/23wL9ymv/\r\n\r\n\r\n----------\r\nhtml\r\n\r\n <div class="wrapper">\r\n <div class="carrousel__candidature__timeline">\r\n <div class="timeline-item p">Architecture</div>\r\n <div class="timeline-item p">Design d’intérieur</div>\r\n <div class="timeline-item p">Accrédités LEED</div>\r\n <div class="timeline-item p">Spécialiste codes</div>\r\n </div>\r\n </div>\r\n\r\n\r\n----------\r\ncss\r\n\r\n .wrapper {\r\n max-width: 800px;\r\n }\r\n\r\n .slick-list {\r\n \twidth: 100%;\r\n }\r\n\r\n .carrousel__candidature__timeline {\r\n \t\t\t\t.timeline-item {\r\n \t\t\t\t\twidth: auto;\r\n \t\t\t\t\theight: auto;\r\n \t\t\t\t\tbackground: transparent;\r\n \t\t\t\t\tmargin-bottom: 20px !important;\r\n \t\t\t\t\tposition: relative;\r\n \t\t\t\t\tfont-size: 14px;\r\n \t\t\t\t\tline-height: 28px;\r\n \t\t\t\t\tfont-weight: 400;\r\n \t\t\t\t\toutline: none;\r\n \t\t\t\t\tcursor: pointer;\r\n \t\t\t\t\tcolor: grey;\r\n \r\n \t\t\t\t\t&::before {\r\n \t\t\t\t\t\tcontent: "";\r\n \t\t\t\t\t\tposition: absolute;\r\n \t\t\t\t\t\ttop: 36px;\r\n \t\t\t\t\t\tleft: -100%;\r\n \t\t\t\t\t\twidth: 100%;\r\n \t\t\t\t\t\theight: 2px;\r\n \t\t\t\t\t\tbackground-color: grey;\r\n \t\t\t\t\t\ttransition: 0.2s;\t\r\n \t\t\t\t\t}\r\n \r\n \t\t\t\t\t&::after {\r\n \t\t\t\t\t\tcontent: "";\r\n \t\t\t\t\t\tposition: absolute;\r\n \t\t\t\t\t\ttop: 30px;\r\n \t\t\t\t\t\tleft: 0;\r\n \t\t\t\t\t\twidth: 15px;\r\n \t\t\t\t\t\theight: 15px;\r\n \t\t\t\t\t\tborder-radius: 100%;\r\n \t\t\t\t\t\tbackground-color: grey;\r\n \t\t\t\t\t\ttransition: 0.2s;\r\n \t\t\t\t\t\tz-index: 1000;\r\n \t\t\t\t\t}\r\n \r\n \t\t\t\t\t&.slick-current {\r\n \t\t\t\t\t\tcolor: red;\r\n \t\t\t\t\t}\r\n\r\n &.slick-current::before {\r\n background-color: red;\r\n }\r\n\r\n &.slick-current::after {\r\n background-color: red;\r\n }\r\n \t\t\t\t}\r\n \t\t\t}\r\n\r\n\r\n----------\r\njs\r\n\r\n $('.carrousel__candidature__timeline').slick({\r\n \tslidesToShow: 4,\r\n \tSlideToScroll: 1,\r\n asNavFor: '.carrousel__candidature__content',\r\n centerMode: false,\r\n focusOnSelect: true,\r\n mobileFirst: true,\r\n \tarrows: false,\r\n \tdots: false,\r\n \tinfinite: false,\r\n \tvariableWidth: false\r\n });\r\n\r\n\r\n\r\n [1]: https://jsfiddle.net/23wL9ymv/","link":"https://stackoverflow.com/questions/67905648/add-class-to-multiple-previous-slides-with-slick-carrousel","title":"Add class to multiple previous slides with Slick carrousel","body":"I'm trying to create a timeline using Slick carousel. What I'm trying to achieve is as you progress in the timeline, all the previous slides stay colored and when you go back they turn back to grey. I tried my best with onAfterChange and onBeforeChange but I can't target multiple previous slides, only the last previous slides.
\nHere's a JSFiddle of my timeline : https://jsfiddle.net/23wL9ymv/
\nhtml
\n<div class="wrapper">\n <div class="carrousel__candidature__timeline">\n <div class="timeline-item p">Architecture</div>\n <div class="timeline-item p">Design d’intérieur</div>\n <div class="timeline-item p">Accrédités LEED</div>\n <div class="timeline-item p">Spécialiste codes</div>\n </div>\n</div>\n
\ncss
\n.wrapper {\n max-width: 800px;\n}\n\n.slick-list {\n width: 100%;\n}\n\n.carrousel__candidature__timeline {\n .timeline-item {\n width: auto;\n height: auto;\n background: transparent;\n margin-bottom: 20px !important;\n position: relative;\n font-size: 14px;\n line-height: 28px;\n font-weight: 400;\n outline: none;\n cursor: pointer;\n color: grey;\n\n &::before {\n content: "";\n position: absolute;\n top: 36px;\n left: -100%;\n width: 100%;\n height: 2px;\n background-color: grey;\n transition: 0.2s; \n }\n\n &::after {\n content: "";\n position: absolute;\n top: 30px;\n left: 0;\n width: 15px;\n height: 15px;\n border-radius: 100%;\n background-color: grey;\n transition: 0.2s;\n z-index: 1000;\n }\n\n &.slick-current {\n color: red;\n }\n\n &.slick-current::before {\n background-color: red;\n }\n\n &.slick-current::after {\n background-color: red;\n }\n }\n }\n
\njs
\n$('.carrousel__candidature__timeline').slick({\n slidesToShow: 4,\n SlideToScroll: 1,\n asNavFor: '.carrousel__candidature__content',\n centerMode: false,\n focusOnSelect: true,\n mobileFirst: true,\n arrows: false,\n dots: false,\n infinite: false,\n variableWidth: false\n});\n
\n"},{"tags":["python","deep-learning","google-colaboratory","streamlit"],"answers":[{"owner":{"reputation":1572,"user_id":13573168,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/526b271be828738bc7b071c5abdc8eff?s=128&d=identicon&r=PG&f=1","display_name":"Prakash Dahal","link":"https://stackoverflow.com/users/13573168/prakash-dahal"},"is_accepted":false,"score":0,"last_activity_date":1623162681,"last_edit_date":1623162681,"creation_date":1623161645,"answer_id":67888788,"question_id":67883973,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16162477,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyG2faDJHyB45cgXllXzMuM1wHf48aSBzODtpY1=k-s128","display_name":"Annadata Alekhya","link":"https://stackoverflow.com/users/16162477/annadata-alekhya"},"is_answered":false,"view_count":31,"answer_count":1,"score":-2,"last_activity_date":1623259354,"creation_date":1623140483,"last_edit_date":1623259354,"question_id":67883973,"share_link":"https://stackoverflow.com/q/67883973","body_markdown":"I am getting this error even after doing reset runtime . That process didn't work for me . Suggest another way.\r\n\r\n ContextualVersionConflict Traceback (most recent call last)\r\n <ipython-input-2-8f70969ba6d2> in <module>()\r\n 2 import numpy as np\r\n 3 import cv2\r\n ----> 4 import streamlit as st\r\n 5 from tensorflow import keras\r\n 6 from tensorflow.keras.models import load_model\r\n \r\n 4 frames\r\n /usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)\r\n 775 # Oops, the "best" so far conflicts with a dependency\r\n 776 dependent_req = required_by[req]\r\n --> 777 raise VersionConflict(dist, req).with_context(dependent_req)\r\n 778 \r\n 779 # push the new requirements onto the stack\r\n \r\n ContextualVersionConflict: (ipykernel 4.10.1 (/usr/local/lib/python3.7/dist-packages), Requirement.parse('ipykernel>=5.1.2; python_version >= "3.4"'), {'pydeck'})","link":"https://stackoverflow.com/questions/67883973/contextualversionconflict-error-while-importing-streamlit-in-google-colab","title":"ContextualVersionConflict : Error while importing streamlit in Google Colab","body":"I am getting this error even after doing reset runtime . That process didn't work for me . Suggest another way.
\nContextualVersionConflict Traceback (most recent call last)\n<ipython-input-2-8f70969ba6d2> in <module>()\n 2 import numpy as np\n 3 import cv2\n----> 4 import streamlit as st\n 5 from tensorflow import keras\n 6 from tensorflow.keras.models import load_model\n\n4 frames\n/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)\n 775 # Oops, the "best" so far conflicts with a dependency\n 776 dependent_req = required_by[req]\n--> 777 raise VersionConflict(dist, req).with_context(dependent_req)\n 778 \n 779 # push the new requirements onto the stack\n\nContextualVersionConflict: (ipykernel 4.10.1 (/usr/local/lib/python3.7/dist-packages), Requirement.parse('ipykernel>=5.1.2; python_version >= "3.4"'), {'pydeck'})\n
\n"},{"tags":["angular","checkbox"],"comments":[{"owner":{"reputation":812,"user_id":5964111,"user_type":"registered","profile_image":"https://i.stack.imgur.com/JMst9.jpg?s=128&g=1","display_name":"tmsbrndz","link":"https://stackoverflow.com/users/5964111/tmsbrndz"},"edited":false,"score":1,"creation_date":1623258248,"post_id":67908545,"comment_id":120030273,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":61,"user_id":10618245,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8bd6d582c65525950f7b6149af109345?s=128&d=identicon&r=PG&f=1","display_name":"Paul James","link":"https://stackoverflow.com/users/10618245/paul-james"},"edited":false,"score":0,"creation_date":1623258308,"post_id":67908545,"comment_id":120030292,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1011,"user_id":8760028,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/63b1af9245d3c42448c0a0b5efe04ce1?s=128&d=identicon&r=PG&f=1","display_name":"pranami","link":"https://stackoverflow.com/users/8760028/pranami"},"edited":false,"score":0,"creation_date":1623258498,"post_id":67908545,"comment_id":120030355,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":2939,"user_id":7025699,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0215d7583f9677b077a5a183d9bfd5d7?s=128&d=identicon&r=PG&f=1","display_name":"Apoorva Chikara","link":"https://stackoverflow.com/users/7025699/apoorva-chikara"},"edited":false,"score":0,"creation_date":1623258839,"post_id":67908545,"comment_id":120030480,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1011,"user_id":8760028,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/63b1af9245d3c42448c0a0b5efe04ce1?s=128&d=identicon&r=PG&f=1","display_name":"pranami","link":"https://stackoverflow.com/users/8760028/pranami"},"reply_to_user":{"reputation":2939,"user_id":7025699,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0215d7583f9677b077a5a183d9bfd5d7?s=128&d=identicon&r=PG&f=1","display_name":"Apoorva Chikara","link":"https://stackoverflow.com/users/7025699/apoorva-chikara"},"edited":false,"score":0,"creation_date":1623259374,"post_id":67908545,"comment_id":120030692,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1011,"user_id":8760028,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/63b1af9245d3c42448c0a0b5efe04ce1?s=128&d=identicon&r=PG&f=1","display_name":"pranami","link":"https://stackoverflow.com/users/8760028/pranami"},"is_answered":false,"view_count":17,"answer_count":0,"score":0,"last_activity_date":1623259350,"creation_date":1623257527,"last_edit_date":1623259350,"question_id":67908545,"share_link":"https://stackoverflow.com/q/67908545","body_markdown":"I have a list of checkboxes as shown below:\r\n\r\n <div class="col-md-4 md-padding" *ngFor="let node of nodeList; let j=index;">\r\n <md-checkbox-group>\r\n <md-checkbox\r\n class="md-h6 row md-padding--xs"\r\n name="{{node.FQDN}}"\r\n label="{{node.FQDN}}"\r\n value="{{node.FQDN}}"\r\n required="true"\r\n htmlId="filter_label_{{j}}"\r\n (click)="updatefilter(node.FQDN)"\r\n [formControlName]="servers"\r\n [(ngModel)]="node.selected">\r\n </md-checkbox>\r\n \r\n \r\n </md-checkbox-group>\r\n \r\n \r\n </div>\r\n\r\nI have to check if the checbox is checked or unchecked. How do I proceed?\r\n\r\nEdit 1: The node array object has the following attributes:\r\n\r\n [\r\n {\r\n DNSResolved: "true",\r\n FQDN: "sa-103.abc.com",\r\n HostName: "sa-103",\r\n Role: " Voice/Video",\r\n productTypeId: "1"\r\n },\r\n\r\n {\r\n DNSResolved: "true",\r\n FQDN: "sa-104.abc.com",\r\n HostName: "sa-104",\r\n Role: " Voice/Video",\r\n productTypeId: "1"\r\n },\r\n\r\n {\r\n DNSResolved: "true",\r\n FQDN: "sa-105.abc.com",\r\n HostName: "sa-105",\r\n Role: " Voice/Video",\r\n productTypeId: "1"\r\n }","link":"https://stackoverflow.com/questions/67908545/how-do-i-get-the-checked-and-unchecked-values-of-a-checkbox-in-angular","title":"How do I get the checked and unchecked values of a checkbox in angular","body":"I have a list of checkboxes as shown below:
\n <div class="col-md-4 md-padding" *ngFor="let node of nodeList; let j=index;">\n <md-checkbox-group>\n <md-checkbox\n class="md-h6 row md-padding--xs"\n name="{{node.FQDN}}"\n label="{{node.FQDN}}"\n value="{{node.FQDN}}"\n required="true"\n htmlId="filter_label_{{j}}"\n (click)="updatefilter(node.FQDN)"\n [formControlName]="servers"\n [(ngModel)]="node.selected">\n </md-checkbox>\n\n\n </md-checkbox-group>\n\n\n </div>\n
\nI have to check if the checbox is checked or unchecked. How do I proceed?
\nEdit 1: The node array object has the following attributes:
\n [\n {\n DNSResolved: "true",\n FQDN: "sa-103.abc.com",\n HostName: "sa-103",\n Role: " Voice/Video",\n productTypeId: "1"\n },\n\n {\n DNSResolved: "true",\n FQDN: "sa-104.abc.com",\n HostName: "sa-104",\n Role: " Voice/Video",\n productTypeId: "1"\n },\n\n {\n DNSResolved: "true",\n FQDN: "sa-105.abc.com",\n HostName: "sa-105",\n Role: " Voice/Video",\n productTypeId: "1"\n }\n
\n"},{"tags":["amazon-web-services","amazon-ec2","configuration","openvpn"],"owner":{"reputation":544,"user_id":13458882,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-NeIT50aX_fw/AAAAAAAAAAI/AAAAAAAAAAA/AAKWJJOea_cg3fhsaJ9qIOgcOrFUDjjslg/photo.jpg?sz=128","display_name":"Fenzox","link":"https://stackoverflow.com/users/13458882/fenzox"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259347,"creation_date":1623259347,"question_id":67908953,"share_link":"https://stackoverflow.com/q/67908953","body_markdown":"I have openvpn gui downloaded on my ec2 instance and have it linked to my config file. Upon connection, I'm getting this error on my browser. I have tested the config file on another PC and it works just fine. I have also added inbound rules on my ec2 instance based on the documentation by was on amazon vpc\r\n\r\n\r\n\r\n This site can’t be reached\r\n www.google.com’s DNS address could not be found. Diagnosing the problem.\r\n Try:\r\n Running Windows Network Diagnostics\r\n Changing DNS over HTTPS settings\r\n DNS_PROBE_STARTED\r\n Check your DNS over HTTPS settings\r\n Go to Opera > Preferences… > System > Use DNS-over-HTTPS instead of the system’s DNS settings and check your DNS-over-HTTPS provider.\r\n\r\nThe following is my logfile from OpenVPN. Any help is appreciated!\r\n\r\n Wed Jun 09 16:25:04 2021 OpenVPN 2.4.9 x86_64-w64-mingw32 [SSL (OpenSSL)] [LZO] [LZ4] [PKCS11] [AEAD] built on Apr 16 2020\r\n Wed Jun 09 16:25:04 2021 Windows version 6.2 (Windows 8 or greater) 64bit\r\n Wed Jun 09 16:25:04 2021 library versions: OpenSSL 1.1.1f 31 Mar 2020, LZO 2.10\r\n Enter Management Password:\r\n Wed Jun 09 16:25:04 2021 MANAGEMENT: TCP Socket listening on [AF_INET]127.0.0.1:25340\r\n Wed Jun 09 16:25:04 2021 Need hold release from management interface, waiting...\r\n Wed Jun 09 16:25:04 2021 MANAGEMENT: Client connected from [AF_INET]127.0.0.1:25340\r\n Wed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'state on'\r\n Wed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'log all on'\r\n Wed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'echo all on'\r\n Wed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'bytecount 5'\r\n Wed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'hold off'\r\n Wed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'hold release'\r\n Wed Jun 09 16:25:06 2021 MANAGEMENT: CMD 'username "Auth" "bryanlee544984-1"'\r\n Wed Jun 09 16:25:06 2021 MANAGEMENT: CMD 'password [...]'\r\n Wed Jun 09 16:25:06 2021 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.\r\n Wed Jun 09 16:25:06 2021 NOTE: --fast-io is disabled since we are running on Windows\r\n Wed Jun 09 16:25:06 2021 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication\r\n Wed Jun 09 16:25:06 2021 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication\r\n Wed Jun 09 16:25:06 2021 MANAGEMENT: >STATE:1623255906,RESOLVE,,,,,,\r\n Wed Jun 09 16:25:06 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]157.245.129.235:443\r\n Wed Jun 09 16:25:06 2021 Socket Buffers: R=[65536->65536] S=[65536->65536]\r\n Wed Jun 09 16:25:06 2021 Attempting to establish TCP connection with [AF_INET]157.245.129.235:443 [nonblock]\r\n Wed Jun 09 16:25:06 2021 MANAGEMENT: >STATE:1623255906,TCP_CONNECT,,,,,,\r\n Wed Jun 09 16:25:07 2021 TCP connection established with [AF_INET]157.245.129.235:443\r\n Wed Jun 09 16:25:07 2021 TCP_CLIENT link local: (not bound)\r\n Wed Jun 09 16:25:07 2021 TCP_CLIENT link remote: [AF_INET]157.245.129.235:443\r\n Wed Jun 09 16:25:07 2021 MANAGEMENT: >STATE:1623255907,WAIT,,,,,,\r\n Wed Jun 09 16:25:07 2021 MANAGEMENT: >STATE:1623255907,AUTH,,,,,,\r\n Wed Jun 09 16:25:07 2021 TLS: Initial packet from [AF_INET]157.245.129.235:443, sid=a3ac1635 90610b41\r\n Wed Jun 09 16:25:07 2021 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this\r\n Wed Jun 09 16:25:07 2021 VERIFY OK: depth=1, C=US, ST=CA, L=Kansas, O=DNSFlex, OU=Community, CN=DNSFlex CA, name=server, emailAddress=support@dnsflex.com\r\n Wed Jun 09 16:25:07 2021 VERIFY OK: depth=0, C=US, ST=CA, L=Kansas, O=DNSFlex, OU=Community, CN=server, name=server, emailAddress=support@dnsflex.com\r\n Wed Jun 09 16:25:07 2021 Control Channel: TLSv1.2, cipher TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA\r\n Wed Jun 09 16:25:07 2021 [server] Peer Connection Initiated with [AF_INET]157.245.129.235:443\r\n Wed Jun 09 16:25:09 2021 MANAGEMENT: >STATE:1623255909,GET_CONFIG,,,,,,\r\n Wed Jun 09 16:25:09 2021 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)\r\n Wed Jun 09 16:25:09 2021 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,ping 10,ping-restart 120,comp-lzo no,sndbuf 393216,rcvbuf 393216,tun-ipv6,route-ipv6 2000::/3,tun-ipv6,route-gateway 10.13.0.1,topology subnet,ping 10,ping-restart 120,ifconfig-ipv6 2604:aaa:bbb:ccc::1039/64 2604:aaa:bbb:ccc::1,ifconfig 10.13.0.59 255.255.255.0,peer-id 0,cipher AES-256-GCM'\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: timers and/or timeouts modified\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: compression parms modified\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: --sndbuf/--rcvbuf options modified\r\n Wed Jun 09 16:25:09 2021 Socket Buffers: R=[65536->393216] S=[65536->393216]\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: --ifconfig/up options modified\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: route options modified\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: route-related options modified\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: peer-id set\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: adjusting link_mtu to 1627\r\n Wed Jun 09 16:25:09 2021 OPTIONS IMPORT: data channel crypto options modified\r\n Wed Jun 09 16:25:09 2021 Data Channel: using negotiated cipher 'AES-256-GCM'\r\n Wed Jun 09 16:25:09 2021 Outgoing Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key\r\n Wed Jun 09 16:25:09 2021 Incoming Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key\r\n Wed Jun 09 16:25:09 2021 interactive service msg_channel=0\r\n Wed Jun 09 16:25:09 2021 ROUTE_GATEWAY 172.31.16.1/255.255.240.0 I=12 HWADDR=06:e2:32:04:b1:06\r\n Wed Jun 09 16:25:09 2021 GDG6: remote_host_ipv6=n/a\r\n Wed Jun 09 16:25:09 2021 NOTE: GetBestInterfaceEx returned error: Element not found. (code=1168)\r\n Wed Jun 09 16:25:09 2021 ROUTE6: default_gateway=UNDEF\r\n Wed Jun 09 16:25:09 2021 open_tun\r\n Wed Jun 09 16:25:09 2021 TAP-WIN32 device [Ethernet 3] opened: \\\\.\\Global\\{F237FC86-05B2-438C-8B9F-F72BE24473AD}.tap\r\n Wed Jun 09 16:25:09 2021 TAP-Windows Driver Version 9.21 \r\n Wed Jun 09 16:25:09 2021 Set TAP-Windows TUN subnet mode network/local/netmask = 10.13.0.0/10.13.0.59/255.255.255.0 [SUCCEEDED]\r\n Wed Jun 09 16:25:09 2021 Notified TAP-Windows driver to set a DHCP IP/netmask of 10.13.0.59/255.255.255.0 on interface {F237FC86-05B2-438C-8B9F-F72BE24473AD} [DHCP-serv: 10.13.0.254, lease-time: 31536000]\r\n Wed Jun 09 16:25:09 2021 Successful ARP Flush on interface [29] {F237FC86-05B2-438C-8B9F-F72BE24473AD}\r\n Wed Jun 09 16:25:09 2021 MANAGEMENT: >STATE:1623255909,ASSIGN_IP,,10.13.0.59,,,,,2604:aaa:bbb:ccc::1039\r\n Wed Jun 09 16:25:10 2021 NETSH: C:\\Windows\\system32\\netsh.exe interface ipv6 set address interface=29 2604:aaa:bbb:ccc::1039 store=active\r\n Wed Jun 09 16:25:10 2021 add_route_ipv6(2604:aaa:bbb:ccc::/64 -> 2604:aaa:bbb:ccc::1039 metric 0) dev Ethernet 3\r\n Wed Jun 09 16:25:10 2021 C:\\Windows\\system32\\netsh.exe interface ipv6 add route 2604:aaa:bbb:ccc::/64 interface=29 fe80::8 store=active\r\n Wed Jun 09 16:25:10 2021 env_block: add PATH=C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem\r\n Wed Jun 09 16:25:15 2021 TEST ROUTES: 1/1 succeeded len=0 ret=1 a=0 u/d=up\r\n Wed Jun 09 16:25:15 2021 C:\\Windows\\system32\\route.exe ADD 157.245.129.235 MASK 255.255.255.255 172.31.16.1\r\n Wed Jun 09 16:25:15 2021 ROUTE: CreateIpForwardEntry succeeded with dwForwardMetric1=10 and dwForwardType=4\r\n Wed Jun 09 16:25:15 2021 Route addition via IPAPI succeeded [adaptive]\r\n Wed Jun 09 16:25:15 2021 C:\\Windows\\system32\\route.exe ADD 0.0.0.0 MASK 128.0.0.0 10.13.0.1\r\n Wed Jun 09 16:25:15 2021 ROUTE: CreateIpForwardEntry succeeded with dwForwardMetric1=20 and dwForwardType=4\r\n Wed Jun 09 16:25:15 2021 Route addition via IPAPI succeeded [adaptive]\r\n Wed Jun 09 16:25:15 2021 C:\\Windows\\system32\\route.exe ADD 128.0.0.0 MASK 128.0.0.0 10.13.0.1\r\n Wed Jun 09 16:25:15 2021 ROUTE: CreateIpForwardEntry succeeded with dwForwardMetric1=20 and dwForwardType=4\r\n Wed Jun 09 16:25:15 2021 Route addition via IPAPI succeeded [adaptive]\r\n Wed Jun 09 16:25:15 2021 add_route_ipv6(2000::/3 -> 2604:aaa:bbb:ccc::1 metric -1) dev Ethernet 3\r\n Wed Jun 09 16:25:15 2021 C:\\Windows\\system32\\netsh.exe interface ipv6 add route 2000::/3 interface=29 fe80::8 store=active\r\n Wed Jun 09 16:25:15 2021 env_block: add PATH=C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem\r\n Wed Jun 09 16:25:15 2021 Initialization Sequence Completed\r\n Wed Jun 09 16:25:15 2021 MANAGEMENT: >STATE:1623255915,CONNECTED,SUCCESS,10.13.0.59,157.245.129.235,443,172.31.29.175,64549,2604:aaa:bbb:ccc::1039","link":"https://stackoverflow.com/questions/67908953/configuration-needed-to-run-openvpn-gui-on-aws-ec2","title":"Configuration needed to run OpenVPN GUI on AWS EC2","body":"I have openvpn gui downloaded on my ec2 instance and have it linked to my config file. Upon connection, I'm getting this error on my browser. I have tested the config file on another PC and it works just fine. I have also added inbound rules on my ec2 instance based on the documentation by was on amazon vpc
\nThis site can’t be reached\nwww.google.com’s DNS address could not be found. Diagnosing the problem.\nTry:\nRunning Windows Network Diagnostics\nChanging DNS over HTTPS settings\nDNS_PROBE_STARTED\nCheck your DNS over HTTPS settings\nGo to Opera > Preferences… > System > Use DNS-over-HTTPS instead of the system’s DNS settings and check your DNS-over-HTTPS provider.\n
\nThe following is my logfile from OpenVPN. Any help is appreciated!
\nWed Jun 09 16:25:04 2021 OpenVPN 2.4.9 x86_64-w64-mingw32 [SSL (OpenSSL)] [LZO] [LZ4] [PKCS11] [AEAD] built on Apr 16 2020\nWed Jun 09 16:25:04 2021 Windows version 6.2 (Windows 8 or greater) 64bit\nWed Jun 09 16:25:04 2021 library versions: OpenSSL 1.1.1f 31 Mar 2020, LZO 2.10\nEnter Management Password:\nWed Jun 09 16:25:04 2021 MANAGEMENT: TCP Socket listening on [AF_INET]127.0.0.1:25340\nWed Jun 09 16:25:04 2021 Need hold release from management interface, waiting...\nWed Jun 09 16:25:04 2021 MANAGEMENT: Client connected from [AF_INET]127.0.0.1:25340\nWed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'state on'\nWed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'log all on'\nWed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'echo all on'\nWed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'bytecount 5'\nWed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'hold off'\nWed Jun 09 16:25:04 2021 MANAGEMENT: CMD 'hold release'\nWed Jun 09 16:25:06 2021 MANAGEMENT: CMD 'username "Auth" "bryanlee544984-1"'\nWed Jun 09 16:25:06 2021 MANAGEMENT: CMD 'password [...]'\nWed Jun 09 16:25:06 2021 WARNING: No server certificate verification method has been enabled. See http://openvpn.net/howto.html#mitm for more info.\nWed Jun 09 16:25:06 2021 NOTE: --fast-io is disabled since we are running on Windows\nWed Jun 09 16:25:06 2021 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication\nWed Jun 09 16:25:06 2021 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication\nWed Jun 09 16:25:06 2021 MANAGEMENT: >STATE:1623255906,RESOLVE,,,,,,\nWed Jun 09 16:25:06 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]157.245.129.235:443\nWed Jun 09 16:25:06 2021 Socket Buffers: R=[65536->65536] S=[65536->65536]\nWed Jun 09 16:25:06 2021 Attempting to establish TCP connection with [AF_INET]157.245.129.235:443 [nonblock]\nWed Jun 09 16:25:06 2021 MANAGEMENT: >STATE:1623255906,TCP_CONNECT,,,,,,\nWed Jun 09 16:25:07 2021 TCP connection established with [AF_INET]157.245.129.235:443\nWed Jun 09 16:25:07 2021 TCP_CLIENT link local: (not bound)\nWed Jun 09 16:25:07 2021 TCP_CLIENT link remote: [AF_INET]157.245.129.235:443\nWed Jun 09 16:25:07 2021 MANAGEMENT: >STATE:1623255907,WAIT,,,,,,\nWed Jun 09 16:25:07 2021 MANAGEMENT: >STATE:1623255907,AUTH,,,,,,\nWed Jun 09 16:25:07 2021 TLS: Initial packet from [AF_INET]157.245.129.235:443, sid=a3ac1635 90610b41\nWed Jun 09 16:25:07 2021 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this\nWed Jun 09 16:25:07 2021 VERIFY OK: depth=1, C=US, ST=CA, L=Kansas, O=DNSFlex, OU=Community, CN=DNSFlex CA, name=server, emailAddress=support@dnsflex.com\nWed Jun 09 16:25:07 2021 VERIFY OK: depth=0, C=US, ST=CA, L=Kansas, O=DNSFlex, OU=Community, CN=server, name=server, emailAddress=support@dnsflex.com\nWed Jun 09 16:25:07 2021 Control Channel: TLSv1.2, cipher TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA\nWed Jun 09 16:25:07 2021 [server] Peer Connection Initiated with [AF_INET]157.245.129.235:443\nWed Jun 09 16:25:09 2021 MANAGEMENT: >STATE:1623255909,GET_CONFIG,,,,,,\nWed Jun 09 16:25:09 2021 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)\nWed Jun 09 16:25:09 2021 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,ping 10,ping-restart 120,comp-lzo no,sndbuf 393216,rcvbuf 393216,tun-ipv6,route-ipv6 2000::/3,tun-ipv6,route-gateway 10.13.0.1,topology subnet,ping 10,ping-restart 120,ifconfig-ipv6 2604:aaa:bbb:ccc::1039/64 2604:aaa:bbb:ccc::1,ifconfig 10.13.0.59 255.255.255.0,peer-id 0,cipher AES-256-GCM'\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: timers and/or timeouts modified\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: compression parms modified\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: --sndbuf/--rcvbuf options modified\nWed Jun 09 16:25:09 2021 Socket Buffers: R=[65536->393216] S=[65536->393216]\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: --ifconfig/up options modified\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: route options modified\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: route-related options modified\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: peer-id set\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: adjusting link_mtu to 1627\nWed Jun 09 16:25:09 2021 OPTIONS IMPORT: data channel crypto options modified\nWed Jun 09 16:25:09 2021 Data Channel: using negotiated cipher 'AES-256-GCM'\nWed Jun 09 16:25:09 2021 Outgoing Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key\nWed Jun 09 16:25:09 2021 Incoming Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key\nWed Jun 09 16:25:09 2021 interactive service msg_channel=0\nWed Jun 09 16:25:09 2021 ROUTE_GATEWAY 172.31.16.1/255.255.240.0 I=12 HWADDR=06:e2:32:04:b1:06\nWed Jun 09 16:25:09 2021 GDG6: remote_host_ipv6=n/a\nWed Jun 09 16:25:09 2021 NOTE: GetBestInterfaceEx returned error: Element not found. (code=1168)\nWed Jun 09 16:25:09 2021 ROUTE6: default_gateway=UNDEF\nWed Jun 09 16:25:09 2021 open_tun\nWed Jun 09 16:25:09 2021 TAP-WIN32 device [Ethernet 3] opened: \\\\.\\Global\\{F237FC86-05B2-438C-8B9F-F72BE24473AD}.tap\nWed Jun 09 16:25:09 2021 TAP-Windows Driver Version 9.21 \nWed Jun 09 16:25:09 2021 Set TAP-Windows TUN subnet mode network/local/netmask = 10.13.0.0/10.13.0.59/255.255.255.0 [SUCCEEDED]\nWed Jun 09 16:25:09 2021 Notified TAP-Windows driver to set a DHCP IP/netmask of 10.13.0.59/255.255.255.0 on interface {F237FC86-05B2-438C-8B9F-F72BE24473AD} [DHCP-serv: 10.13.0.254, lease-time: 31536000]\nWed Jun 09 16:25:09 2021 Successful ARP Flush on interface [29] {F237FC86-05B2-438C-8B9F-F72BE24473AD}\nWed Jun 09 16:25:09 2021 MANAGEMENT: >STATE:1623255909,ASSIGN_IP,,10.13.0.59,,,,,2604:aaa:bbb:ccc::1039\nWed Jun 09 16:25:10 2021 NETSH: C:\\Windows\\system32\\netsh.exe interface ipv6 set address interface=29 2604:aaa:bbb:ccc::1039 store=active\nWed Jun 09 16:25:10 2021 add_route_ipv6(2604:aaa:bbb:ccc::/64 -> 2604:aaa:bbb:ccc::1039 metric 0) dev Ethernet 3\nWed Jun 09 16:25:10 2021 C:\\Windows\\system32\\netsh.exe interface ipv6 add route 2604:aaa:bbb:ccc::/64 interface=29 fe80::8 store=active\nWed Jun 09 16:25:10 2021 env_block: add PATH=C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem\nWed Jun 09 16:25:15 2021 TEST ROUTES: 1/1 succeeded len=0 ret=1 a=0 u/d=up\nWed Jun 09 16:25:15 2021 C:\\Windows\\system32\\route.exe ADD 157.245.129.235 MASK 255.255.255.255 172.31.16.1\nWed Jun 09 16:25:15 2021 ROUTE: CreateIpForwardEntry succeeded with dwForwardMetric1=10 and dwForwardType=4\nWed Jun 09 16:25:15 2021 Route addition via IPAPI succeeded [adaptive]\nWed Jun 09 16:25:15 2021 C:\\Windows\\system32\\route.exe ADD 0.0.0.0 MASK 128.0.0.0 10.13.0.1\nWed Jun 09 16:25:15 2021 ROUTE: CreateIpForwardEntry succeeded with dwForwardMetric1=20 and dwForwardType=4\nWed Jun 09 16:25:15 2021 Route addition via IPAPI succeeded [adaptive]\nWed Jun 09 16:25:15 2021 C:\\Windows\\system32\\route.exe ADD 128.0.0.0 MASK 128.0.0.0 10.13.0.1\nWed Jun 09 16:25:15 2021 ROUTE: CreateIpForwardEntry succeeded with dwForwardMetric1=20 and dwForwardType=4\nWed Jun 09 16:25:15 2021 Route addition via IPAPI succeeded [adaptive]\nWed Jun 09 16:25:15 2021 add_route_ipv6(2000::/3 -> 2604:aaa:bbb:ccc::1 metric -1) dev Ethernet 3\nWed Jun 09 16:25:15 2021 C:\\Windows\\system32\\netsh.exe interface ipv6 add route 2000::/3 interface=29 fe80::8 store=active\nWed Jun 09 16:25:15 2021 env_block: add PATH=C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem\nWed Jun 09 16:25:15 2021 Initialization Sequence Completed\nWed Jun 09 16:25:15 2021 MANAGEMENT: >STATE:1623255915,CONNECTED,SUCCESS,10.13.0.59,157.245.129.235,443,172.31.29.175,64549,2604:aaa:bbb:ccc::1039\n
\n"},{"tags":["c"],"comments":[{"owner":{"reputation":3001,"user_id":4228131,"user_type":"registered","accept_rate":100,"profile_image":"https://i.stack.imgur.com/RyKUe.jpg?s=128&g=1","display_name":"WedaPashi","link":"https://stackoverflow.com/users/4228131/wedapashi"},"edited":false,"score":0,"creation_date":1623258778,"post_id":67908745,"comment_id":120030457,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":3001,"user_id":4228131,"user_type":"registered","accept_rate":100,"profile_image":"https://i.stack.imgur.com/RyKUe.jpg?s=128&g=1","display_name":"WedaPashi","link":"https://stackoverflow.com/users/4228131/wedapashi"},"edited":false,"score":1,"creation_date":1623258878,"post_id":67908745,"comment_id":120030500,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":31121,"user_id":10871073,"user_type":"registered","profile_image":"https://i.stack.imgur.com/ddBW9.png?s=128&g=1","display_name":"Adrian Mole","link":"https://stackoverflow.com/users/10871073/adrian-mole"},"is_accepted":false,"score":0,"last_activity_date":1623259343,"creation_date":1623259343,"answer_id":67908952,"question_id":67908745,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":15043462,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GjcrmUNncFNCy94XOvN33vw31WkJ_OSXutcJwsUsg=k-s128","display_name":"Gautam Bisht","link":"https://stackoverflow.com/users/15043462/gautam-bisht"},"is_answered":false,"view_count":20,"answer_count":1,"score":0,"last_activity_date":1623259343,"creation_date":1623258491,"last_edit_date":1623258633,"question_id":67908745,"share_link":"https://stackoverflow.com/q/67908745","body_markdown":"```\r\n#include <stdio.h>\r\nchar q[50];\r\nint doo(int p, int n, char* s) {\r\n int i = 0, j = 0;\r\n while (s[i] != '\\0') {\r\n if ((i < p) && (i > (p + n))) {\r\n q[j] = s[i];\r\n ++j;\r\n }\r\n i++;\r\n }\r\n puts(p);\r\n}\r\nint main() {\r\n char s[50];\r\n int n, p;\r\n printf("<--program by gautam-->\\n");\r\n printf("enter the string-->");\r\n gets(s);\r\n printf("\\nenter the numbers of character to be deleted and position-->");\r\n scanf("%d%d", &n, &p);\r\n --p;\r\n doo(p, n, s);\r\n return 0;\r\n}\r\n```\r\n\r\nso the question is to delete certain elements of string by asking user position and number of elements to delete from there. i m trying to copy all element except those whose position is provided by user","link":"https://stackoverflow.com/questions/67908745/its-not-printing-the-new-array-what-could-be-the-reason","title":"its not printing the new array. what could be the reason?","body":"#include <stdio.h>\nchar q[50];\nint doo(int p, int n, char* s) {\n int i = 0, j = 0;\n while (s[i] != '\\0') {\n if ((i < p) && (i > (p + n))) {\n q[j] = s[i];\n ++j;\n }\n i++;\n }\n puts(p);\n}\nint main() {\n char s[50];\n int n, p;\n printf("<--program by gautam-->\\n");\n printf("enter the string-->");\n gets(s);\n printf("\\nenter the numbers of character to be deleted and position-->");\n scanf("%d%d", &n, &p);\n --p;\n doo(p, n, s);\n return 0;\n}\n
\nso the question is to delete certain elements of string by asking user position and number of elements to delete from there. i m trying to copy all element except those whose position is provided by user
\n"},{"tags":["typescript","express","mysql-connector"],"answers":[{"owner":{"reputation":1521,"user_id":3388225,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/93628db6b26d48a6c44b7bbeda92264e?s=128&d=identicon&r=PG","display_name":"aleksxor","link":"https://stackoverflow.com/users/3388225/aleksxor"},"is_accepted":false,"score":0,"last_activity_date":1623259338,"creation_date":1623259338,"answer_id":67908950,"question_id":67906257,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1351,"user_id":11401460,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/442924dbecfe090e125cb9fdd1b7faa4?s=128&d=identicon&r=PG&f=1","display_name":"uber","link":"https://stackoverflow.com/users/11401460/uber"},"is_answered":false,"view_count":10,"answer_count":1,"score":0,"last_activity_date":1623259338,"creation_date":1623249071,"last_edit_date":1623249774,"question_id":67906257,"share_link":"https://stackoverflow.com/q/67906257","body_markdown":"I'm creating a connection to an AWS mysql database like so:\r\n```\r\nconst config = {\r\n host: process.env.RDS_HOSTNAME,\r\n user: process.env.RDS_USERNAME,\r\n password: process.env.RDS_PASSWORD,\r\n port: 3306,\r\n database: process.env.RDS_DB_NAME,\r\n}\r\n\r\nconst db = mysql.createConnection(config) // config gets highlighted\r\n```\r\nBut I get the following error:\r\n```\r\nArgument of type '{ host: string | undefined; user: string | undefined; password: string | undefined; port: number; database: string | undefined; }' is not assignable to parameter of type 'string | ConnectionConfig'.\r\n\r\nType '{ host: string | undefined; user: string | undefined; password: string | undefined; port: number; database: string | undefined; }' is not assignable to type 'ConnectionConfig'.\r\n\r\n Types of property 'host' are incompatible.\r\n Type 'string | undefined' is not assignable to type 'string'.\r\n Type 'undefined' is not assignable to type 'string'.ts(2345)\r\n```\r\nEarlier on, I had a problem with the port coming from `.env`. When I switched to hardcoding the port, I get this. \r\n\r\nI don't understand what the problem is nor how to solve it.","link":"https://stackoverflow.com/questions/67906257/argument-of-type-host-string-undefined-user-string-undefined-is","title":"Argument of type '{ host: string | undefined; user: string | undefined ... }' is not assignable to parameter of type 'string | ConnectionConfig'","body":"I'm creating a connection to an AWS mysql database like so:
\nconst config = {\n host: process.env.RDS_HOSTNAME,\n user: process.env.RDS_USERNAME,\n password: process.env.RDS_PASSWORD,\n port: 3306,\n database: process.env.RDS_DB_NAME,\n}\n\nconst db = mysql.createConnection(config) // config gets highlighted\n
\nBut I get the following error:
\nArgument of type '{ host: string | undefined; user: string | undefined; password: string | undefined; port: number; database: string | undefined; }' is not assignable to parameter of type 'string | ConnectionConfig'.\n\nType '{ host: string | undefined; user: string | undefined; password: string | undefined; port: number; database: string | undefined; }' is not assignable to type 'ConnectionConfig'.\n\n Types of property 'host' are incompatible.\n Type 'string | undefined' is not assignable to type 'string'.\n Type 'undefined' is not assignable to type 'string'.ts(2345)\n
\nEarlier on, I had a problem with the port coming from .env
. When I switched to hardcoding the port, I get this.
I don't understand what the problem is nor how to solve it.
\n"},{"tags":["java","eclipse"],"owner":{"reputation":13,"user_id":15194704,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GiKrIBX6eF-yStQgm7Fxj0xI-yKtC4mkQoHBkbpFw=k-s128","display_name":"developer531","link":"https://stackoverflow.com/users/15194704/developer531"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259336,"creation_date":1623259336,"question_id":67908949,"share_link":"https://stackoverflow.com/q/67908949","body_markdown":"So I'm using the Eclipse IDE for Java to work on exercises and store examples from my Java How to Program book. I organize them with folders for each chapter being inside the src folder, but the folders are automatically turned into packages. How can I make them just normal folders?\r\n\r\n[![Folder structure][1]][1]\r\n\r\n\r\n [1]: https://i.stack.imgur.com/I0lDo.png","link":"https://stackoverflow.com/questions/67908949/folders-showing-up-as-packages-in-eclipse","title":"Folders showing up as packages in Eclipse","body":"So I'm using the Eclipse IDE for Java to work on exercises and store examples from my Java How to Program book. I organize them with folders for each chapter being inside the src folder, but the folders are automatically turned into packages. How can I make them just normal folders?
\n\n"},{"tags":["ruby-on-rails","activerecord","ruby-on-rails-6"],"answers":[{"owner":{"reputation":145,"user_id":3756612,"user_type":"registered","profile_image":"https://graph.facebook.com/510650564/picture?type=large","display_name":"bryanfeller","link":"https://stackoverflow.com/users/3756612/bryanfeller"},"is_accepted":false,"score":0,"last_activity_date":1623259330,"creation_date":1623259330,"answer_id":67908948,"question_id":67905820,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":85,"user_id":6114401,"user_type":"registered","accept_rate":61,"profile_image":"https://www.gravatar.com/avatar/95358dfea7fa0c136721bc3a87f5ad0c?s=128&d=identicon&r=PG&f=1","display_name":"spacerobot","link":"https://stackoverflow.com/users/6114401/spacerobot"},"is_answered":false,"view_count":14,"answer_count":1,"score":0,"last_activity_date":1623259330,"creation_date":1623247728,"question_id":67905820,"share_link":"https://stackoverflow.com/q/67905820","body_markdown":"I have a form where people can either create one cardrequest or many via uploading a csv file with ids. I have it working to simply create the requests. There are two things left I need to do in this routine that I am not sure how to do and looking for advice on. \r\n\r\n1.) I need to check the ids either from the file upload or the single form field against an active table. If they are not active alert the person of that. \r\n\r\n2.) If a combination of empid and cardholdergroup already exist update that request with the new params that were passed through. \r\n\r\nHere is my action. Any thoughts on how/where I should do those? Any advice is appreciated.\r\n\r\n def create\r\n if cardrequest_params[:file].present?\r\n file_path = cardrequest_params[:file].path\r\n @cardholdergroups = cardrequest_params[:cardholdergroup_ids].map do |cardholdergroup_id|\r\n CSV.foreach(file_path) do |row|\r\n @cardrequest = Cardrequest.create(empid: row[0], startdate: cardrequest_params[:startdate], enddate: cardrequest_params[:enddate], user_id: current_user.id, cardholdergroup_ids: cardholdergroup_id)\r\n end\r\n end\r\n else\r\n @cardholdergroups = cardrequest_params[:cardholdergroup_ids].map do |cardholdergroup_id|\r\n @cardrequest = Cardrequest.create(empid: cardrequest_params[:empid], startdate: cardrequest_params[:startdate], enddate: cardrequest_params[:enddate], user_id: current_user.id, cardholdergroup_ids: cardholdergroup_id)\r\n end\r\n end\r\n respond_to do |format|\r\n if @cardrequest.save\r\n format.html { redirect_to cardrequests_path, notice: "Cardrequest was successfully created." }\r\n format.json { render :show, status: :created, location: @cardrequest }\r\n else\r\n format.html { render :new, status: :unprocessable_entity }\r\n format.json { render json: @cardrequest.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end","link":"https://stackoverflow.com/questions/67905820/rails-controller-loop-questions-update-where-exists","title":"Rails controller loop questions - update where exists","body":"I have a form where people can either create one cardrequest or many via uploading a csv file with ids. I have it working to simply create the requests. There are two things left I need to do in this routine that I am not sure how to do and looking for advice on.
\n1.) I need to check the ids either from the file upload or the single form field against an active table. If they are not active alert the person of that.
\n2.) If a combination of empid and cardholdergroup already exist update that request with the new params that were passed through.
\nHere is my action. Any thoughts on how/where I should do those? Any advice is appreciated.
\n def create\n if cardrequest_params[:file].present?\n file_path = cardrequest_params[:file].path\n @cardholdergroups = cardrequest_params[:cardholdergroup_ids].map do |cardholdergroup_id|\n CSV.foreach(file_path) do |row|\n @cardrequest = Cardrequest.create(empid: row[0], startdate: cardrequest_params[:startdate], enddate: cardrequest_params[:enddate], user_id: current_user.id, cardholdergroup_ids: cardholdergroup_id)\n end\n end\n else\n @cardholdergroups = cardrequest_params[:cardholdergroup_ids].map do |cardholdergroup_id|\n @cardrequest = Cardrequest.create(empid: cardrequest_params[:empid], startdate: cardrequest_params[:startdate], enddate: cardrequest_params[:enddate], user_id: current_user.id, cardholdergroup_ids: cardholdergroup_id)\n end\n end\n respond_to do |format|\n if @cardrequest.save\n format.html { redirect_to cardrequests_path, notice: "Cardrequest was successfully created." }\n format.json { render :show, status: :created, location: @cardrequest }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @cardrequest.errors, status: :unprocessable_entity }\n end\n end\n end\n
\n"},{"tags":["android","kotlin","many-to-many","android-room","relation"],"owner":{"reputation":1,"user_id":16177985,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a0ffdf208d8c2bf6fda513dc6c43439f?s=128&d=identicon&r=PG&f=1","display_name":"Zharkov Max","link":"https://stackoverflow.com/users/16177985/zharkov-max"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259326,"creation_date":1623259326,"question_id":67908947,"share_link":"https://stackoverflow.com/q/67908947","body_markdown":"Got a problem, where i have a third-party field in a cross reference class.\r\nI have a\r\nProject entity data class:\r\n\r\n @Entity(tableName = "projects")\r\n data class Project(\r\n \r\n @PrimaryKey(autoGenerate = true)\r\n val projectId: Int = 0,\r\n \r\n var title: String,\r\n \r\n var details: String,\r\n \r\n var date: Date,\r\n \r\n var price: Int\r\n )\r\nRecord entity data class:\r\n\r\n @Entity(tableName = "records")\r\n data class Record (\r\n \r\n @PrimaryKey(autoGenerate = true)\r\n val recordId: Int,\r\n \r\n var title: String,\r\n \r\n var details: String,\r\n \r\n var price: Int,\r\n \r\n )\r\n\r\nCross reference entity data class\r\n \r\n @Entity(\r\n tableName = "cross_ref",\r\n primaryKeys = ["projectId", "recordId"],\r\n foreignKeys = [\r\n ForeignKey(\r\n entity = Project::class,\r\n parentColumns = ["projectId"],\r\n childColumns = ["projectId"]\r\n ),\r\n ForeignKey(\r\n entity = Record::class,\r\n parentColumns = ["recordId"],\r\n childColumns = ["recordId"]\r\n )\r\n ]\r\n )\r\n data class ProjectRecordCrossRef(\r\n \r\n val projectId: Int,\r\n \r\n @ColumnInfo(index = true)\r\n val recordId: Int,\r\n \r\n val quantity: Int\r\n )\r\n\r\nand a POJO class\r\n\r\n data class ProjectWithRecords(\r\n @Embedded\r\n val project: Project,\r\n \r\n @Relation(\r\n parentColumn = "projectId",\r\n entityColumn = "recordId",\r\n associateBy = Junction(ProjectRecordCrossRef::class)\r\n )\r\n val records: MutableList<Record>,\r\n \r\n @Relation(\r\n entity = ProjectRecordCrossRef::class,\r\n parentColumn = "projectId",\r\n entityColumn = "quantity"\r\n )\r\n val quantities: MutableList<Int> = arrayListOf()\r\n )\r\n\r\nAlso I have a Dao class\r\n\r\n @Dao\r\n interface CrossRefDao {\r\n \r\n @Transaction\r\n @Query("SELECT * FROM projects WHERE projectId = :projectId")\r\n fun getProjectWithRecords(projectId: Int): LiveData<ProjectWithRecords>\r\n \r\n @Query("SELECT * FROM cross_ref WHERE projectId =:projectId")\r\n suspend fun getAllByProjectId(projectId: Int) : List<ProjectRecordCrossRef>\r\n \r\n @Query("SELECT * FROM cross_ref")\r\n suspend fun getAllCrosses(): List<ProjectRecordCrossRef>\r\n \r\n @Query("SELECT * FROM cross_ref WHERE projectId =:projectId AND recordId =:recordId")\r\n suspend fun getAllByProjectAndRecordIds(projectId: Int, recordId: Int) : List<ProjectRecordCrossRef>\r\n \r\n @Insert(onConflict = OnConflictStrategy.REPLACE)\r\n suspend fun insert(crossRef: ProjectRecordCrossRef)\r\n \r\n @Delete\r\n suspend fun delete(crossRefs: List<ProjectRecordCrossRef>)\r\n }\r\n\r\nThe problem is: I can't get quantities from Dao in a POJO\r\n\r\nSo, how can i get list of third-party values from cross reference?\r\n\r\nProjectWithRecords has\r\nProject, \r\nlist of records,\r\nlist of quantities of records.\r\n\r\nMay be I should make it another way? \r\n","link":"https://stackoverflow.com/questions/67908947/android-room-fetch-data-with-where-cross-reference-data-class-has-a-third-party","title":"Android Room fetch data with where cross reference data class has a third-party element","body":"Got a problem, where i have a third-party field in a cross reference class.\nI have a\nProject entity data class:
\n@Entity(tableName = "projects")\ndata class Project(\n\n @PrimaryKey(autoGenerate = true)\n val projectId: Int = 0,\n\n var title: String,\n\n var details: String,\n\n var date: Date,\n\n var price: Int\n)\n
\nRecord entity data class:
\n@Entity(tableName = "records")\ndata class Record (\n\n @PrimaryKey(autoGenerate = true)\n val recordId: Int,\n\n var title: String,\n\n var details: String,\n\n var price: Int,\n\n )\n
\nCross reference entity data class
\n@Entity(\n tableName = "cross_ref",\n primaryKeys = ["projectId", "recordId"],\n foreignKeys = [\n ForeignKey(\n entity = Project::class,\n parentColumns = ["projectId"],\n childColumns = ["projectId"]\n ),\n ForeignKey(\n entity = Record::class,\n parentColumns = ["recordId"],\n childColumns = ["recordId"]\n )\n ]\n)\ndata class ProjectRecordCrossRef(\n\n val projectId: Int,\n\n @ColumnInfo(index = true)\n val recordId: Int,\n\n val quantity: Int\n)\n
\nand a POJO class
\ndata class ProjectWithRecords(\n @Embedded\n val project: Project,\n\n @Relation(\n parentColumn = "projectId",\n entityColumn = "recordId",\n associateBy = Junction(ProjectRecordCrossRef::class)\n )\n val records: MutableList<Record>,\n\n @Relation(\n entity = ProjectRecordCrossRef::class,\n parentColumn = "projectId",\n entityColumn = "quantity"\n )\n val quantities: MutableList<Int> = arrayListOf()\n)\n
\nAlso I have a Dao class
\n@Dao\ninterface CrossRefDao {\n\n @Transaction\n @Query("SELECT * FROM projects WHERE projectId = :projectId")\n fun getProjectWithRecords(projectId: Int): LiveData<ProjectWithRecords>\n\n @Query("SELECT * FROM cross_ref WHERE projectId =:projectId")\n suspend fun getAllByProjectId(projectId: Int) : List<ProjectRecordCrossRef>\n\n @Query("SELECT * FROM cross_ref")\n suspend fun getAllCrosses(): List<ProjectRecordCrossRef>\n\n @Query("SELECT * FROM cross_ref WHERE projectId =:projectId AND recordId =:recordId")\n suspend fun getAllByProjectAndRecordIds(projectId: Int, recordId: Int) : List<ProjectRecordCrossRef>\n\n @Insert(onConflict = OnConflictStrategy.REPLACE)\n suspend fun insert(crossRef: ProjectRecordCrossRef)\n\n @Delete\n suspend fun delete(crossRefs: List<ProjectRecordCrossRef>)\n}\n
\nThe problem is: I can't get quantities from Dao in a POJO
\nSo, how can i get list of third-party values from cross reference?
\nProjectWithRecords has\nProject,\nlist of records,\nlist of quantities of records.
\nMay be I should make it another way?
\n"},{"tags":["javascript","jquery","salesforce","google-tag-manager","demandware"],"owner":{"reputation":1,"user_id":13316411,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgQvTgc-hzZiihLGpDlPE4p-JG_2ErjYhLjp-ZoYQ=k-s128","display_name":"Scott Peraza","link":"https://stackoverflow.com/users/13316411/scott-peraza"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623259322,"creation_date":1623259322,"question_id":67908946,"share_link":"https://stackoverflow.com/q/67908946","body_markdown":"I have a website that currently has GTM. We are trying to use FB conversion API for better targeted ads. I was informed today that our Demandware subscription (Sales force commerce cloud) only allows 8 api calls per page load. This is not a problem when people browse, but at checkout we have 6 api calls going off already, and if we exceed 8 api calls the system (SFCC) crashes. Any ideas as to how to either structure it so the tag firing can be bundled into one call, or how we can store the data on the server side elsewhere, to be fired in increments over night?","link":"https://stackoverflow.com/questions/67908946/how-to-intercept-gtm-data-implement-fb-conversion-api-with-only-3-api-calls-pe","title":"How to intercept GTM data / implement FB conversion API with only 3 api calls per page load","body":"I have a website that currently has GTM. We are trying to use FB conversion API for better targeted ads. I was informed today that our Demandware subscription (Sales force commerce cloud) only allows 8 api calls per page load. This is not a problem when people browse, but at checkout we have 6 api calls going off already, and if we exceed 8 api calls the system (SFCC) crashes. Any ideas as to how to either structure it so the tag firing can be bundled into one call, or how we can store the data on the server side elsewhere, to be fired in increments over night?
\n"},{"tags":["python","discord","discord.py"],"answers":[{"owner":{"reputation":1,"user_id":16178423,"user_type":"registered","profile_image":"https://i.stack.imgur.com/hhYby.png?s=128&g=1","display_name":"i-am-cal","link":"https://stackoverflow.com/users/16178423/i-am-cal"},"is_accepted":false,"score":0,"last_activity_date":1623259320,"last_edit_date":1623259320,"creation_date":1623259222,"answer_id":67908917,"question_id":67908882,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":11,"user_id":15601103,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b419e9b18f3522f2ee9d002932ba7198?s=128&d=identicon&r=PG&f=1","display_name":"Deyan Nikolov","link":"https://stackoverflow.com/users/15601103/deyan-nikolov"},"is_answered":false,"view_count":7,"answer_count":1,"score":0,"last_activity_date":1623259320,"creation_date":1623259067,"question_id":67908882,"share_link":"https://stackoverflow.com/q/67908882","body_markdown":"Okay, I know that the title isn't very descriptive, but please hear me out.\r\n\r\nI'm trying to create a help "log" command:\r\n\r\n```\r\n@client.command()\r\nasync def logs(ctx):\r\n for channel in ctx.guild.channels:\r\n if channel.name == "henry-logs":\r\n await ctx.send("Henry Logs channel is already setup. If you have access to it, it should be available in the channel list")\r\n else:\r\n await ctx.send("Henry logs channel is not found! If you have such access please create channel named **EXACTLY**")\r\n await ctx.send("```henry-logs```")\r\n```\r\n\r\nHowever it doesn't send the not found message once, but for every channel that is not "henry-logs", since I used for channel in guild.\r\nIs there a way I can fix it and send it only once if the channel doesn't exist and once if does exist?","link":"https://stackoverflow.com/questions/67908882/discord-py-find-channel","title":"Discord.py find channel","body":"Okay, I know that the title isn't very descriptive, but please hear me out.
\nI'm trying to create a help "log" command:
\n@client.command()\nasync def logs(ctx):\n for channel in ctx.guild.channels:\n if channel.name == "henry-logs":\n await ctx.send("Henry Logs channel is already setup. If you have access to it, it should be available in the channel list")\n else:\n await ctx.send("Henry logs channel is not found! If you have such access please create channel named **EXACTLY**")\n await ctx.send("```henry-logs```")\n
\nHowever it doesn't send the not found message once, but for every channel that is not "henry-logs", since I used for channel in guild.\nIs there a way I can fix it and send it only once if the channel doesn't exist and once if does exist?
\n"},{"tags":["python","pandas","multi-index"],"owner":{"reputation":25,"user_id":16061104,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5933e3c9706c4ffb950ab7cf460f5164?s=128&d=identicon&r=PG&f=1","display_name":"tillwss","link":"https://stackoverflow.com/users/16061104/tillwss"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623259319,"creation_date":1623259319,"question_id":67908945,"share_link":"https://stackoverflow.com/q/67908945","body_markdown":"I have a df in which some dates of the time period for each station are missing: How do I fill the missing dates per station and set "Value" to NaN within a multi index df?\r\n\r\nThe df looks like this:\r\n```\r\n Value\r\nStation_Number Date \r\nCA002100805 2003-01-01 -296\r\nCA002202570 2003-01-01 -269\r\nCA002203058 2003-01-01 -268\r\nCA002300551 2003-01-01 -23\r\nCA002300902 2003-01-01 -200\r\n... ...\r\nUSS0062S01S 2020-12-31 -94\r\nUSW00026533 2020-12-31 -216\r\nUSW00026616 2020-12-31 -100\r\nUSW00027401 2020-12-31 -223\r\nUSW00027502 2020-12-31 -273\r\n```\r\nThe time span goes from 01.01.2003 until 31.12.2020.","link":"https://stackoverflow.com/questions/67908945/fill-missing-dates-in-multi-index-df","title":"Fill missing dates in multi index df","body":"I have a df in which some dates of the time period for each station are missing: How do I fill the missing dates per station and set "Value" to NaN within a multi index df?
\nThe df looks like this:
\n Value\nStation_Number Date \nCA002100805 2003-01-01 -296\nCA002202570 2003-01-01 -269\nCA002203058 2003-01-01 -268\nCA002300551 2003-01-01 -23\nCA002300902 2003-01-01 -200\n... ...\nUSS0062S01S 2020-12-31 -94\nUSW00026533 2020-12-31 -216\nUSW00026616 2020-12-31 -100\nUSW00027401 2020-12-31 -223\nUSW00027502 2020-12-31 -273\n
\nThe time span goes from 01.01.2003 until 31.12.2020.
\n"},{"tags":["python","regex","grouping"],"owner":{"reputation":14283,"user_id":289011,"user_type":"registered","accept_rate":97,"profile_image":"https://www.gravatar.com/avatar/7fabc4413849953957908f8690c2c24c?s=128&d=identicon&r=PG","display_name":"BorrajaX","link":"https://stackoverflow.com/users/289011/borrajax"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623259317,"creation_date":1623259317,"question_id":67908944,"share_link":"https://stackoverflow.com/q/67908944","body_markdown":"So, this is just a learning exercise... I know there are easy substitutions and replacements that I can do, but I was wondering whether removing dashes/hyphens (erm...this character: `-`) from a string **using exclusively `re.match`**\r\n\r\nLet's say I have something like:\r\n\r\nInput -> `"123-456-78"`\r\n\r\nIs there a way of doing something along the lines of: `(?P<something>\\d+(?:-*)\\d+...)` so I could end up with just the digits in the matched group?\r\n\r\n```python\r\nimport re\r\ninput = "123-456-78"\r\nmatch = re.match(r"(?P<something>...)", input)\r\nprint(match.groupdict()['something'])\r\n\r\n12345678\r\n```\r\n\r\nJust curious, really (I'm trying to improve my regular expressions knowledge). Thank you in advance.\r\n\r\nPS: I am using Python 3.6, in case it's relevant.","link":"https://stackoverflow.com/questions/67908944/remove-dashes-hyphens-using-only-regex-matches-in-python","title":"Remove dashes (hyphens) using only regex matches in Python","body":"So, this is just a learning exercise... I know there are easy substitutions and replacements that I can do, but I was wondering whether removing dashes/hyphens (erm...this character: -
) from a string using exclusively re.match
Let's say I have something like:
\nInput -> "123-456-78"
Is there a way of doing something along the lines of: (?P<something>\\d+(?:-*)\\d+...)
so I could end up with just the digits in the matched group?
import re\ninput = "123-456-78"\nmatch = re.match(r"(?P<something>...)", input)\nprint(match.groupdict()['something'])\n\n12345678\n
\nJust curious, really (I'm trying to improve my regular expressions knowledge). Thank you in advance.
\nPS: I am using Python 3.6, in case it's relevant.
\n"},{"tags":["vue.js","data-binding","vuejs2","vue-component","2-way-object-databinding"],"owner":{"reputation":129,"user_id":14186234,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8fc20eef464612122fc743d0ca351184?s=128&d=identicon&r=PG&f=1","display_name":"Suzy","link":"https://stackoverflow.com/users/14186234/suzy"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259310,"creation_date":1623259310,"question_id":67908943,"share_link":"https://stackoverflow.com/q/67908943","body_markdown":"I am using Vue 2 and I'm trying to have a parent component pass in multiple values to the child, and have the child return back a specific object to the parent. It needs to be two way data binding for the data.\r\n\r\nFor example I have this school object:\r\n```\r\n school: {\r\n name: "Tech School",\r\n type: "highschool"\r\n }\r\n```\r\n\r\nA list of students with different properties: (The list can be huge, but this is pseudo code)\r\n```\r\n data () {\r\n return {\r\n totalStudents: [{\r\n school: {\r\n name: "Tech School",\r\n type: "highschool"\r\n },\r\n studentId: 123,\r\n city: "seattle"\r\n },\r\n school: {\r\n name: "Art School",\r\n type: "university"\r\n }\r\n studentId: 747,\r\n city: "toronto"\r\n },\r\n }],\r\n } \r\n }\r\n\r\n```\r\nThe parent calls this custom child component (I'm not sure how to write this part)\r\n```\r\n <CustomChildPicker :value="prop" @input="prop=\r\n totalStudents[index].school, // trying to pass these 3 fields from parent to child\r\n totalStudents[index].studentId,\r\n totalStudents[index].city"\r\n v-model=totalStudents[index].school //only want this updated data back from child\r\n />\r\n```\r\n\r\nHow do we pass in dynamic data to the child component, but only have the school object have two way data binding with the parent? \r\n\r\nI want to pass data from the parent to the child, and the child does some conversions to that data and pass the converted data back to the parent. (school object)\r\n\r\nBut also if the data in the parent changes, the child gets the updated changed data, redo the conversions above and give the updated data back to the parent. (if the student's city changes, then their school also changes) \r\n\r\nHow would we do this? Thanks for the help!","link":"https://stackoverflow.com/questions/67908943/how-to-pass-parent-to-child-dynamic-data-into-model-with-multiple-fields-vue","title":"How to pass parent to child dynamic data into model with multiple fields - Vue?","body":"I am using Vue 2 and I'm trying to have a parent component pass in multiple values to the child, and have the child return back a specific object to the parent. It needs to be two way data binding for the data.
\nFor example I have this school object:
\n school: {\n name: "Tech School",\n type: "highschool"\n }\n
\nA list of students with different properties: (The list can be huge, but this is pseudo code)
\n data () {\n return {\n totalStudents: [{\n school: {\n name: "Tech School",\n type: "highschool"\n },\n studentId: 123,\n city: "seattle"\n },\n school: {\n name: "Art School",\n type: "university"\n }\n studentId: 747,\n city: "toronto"\n },\n }],\n } \n }\n\n
\nThe parent calls this custom child component (I'm not sure how to write this part)
\n <CustomChildPicker :value="prop" @input="prop=\n totalStudents[index].school, // trying to pass these 3 fields from parent to child\n totalStudents[index].studentId,\n totalStudents[index].city"\n v-model=totalStudents[index].school //only want this updated data back from child\n />\n
\nHow do we pass in dynamic data to the child component, but only have the school object have two way data binding with the parent?
\nI want to pass data from the parent to the child, and the child does some conversions to that data and pass the converted data back to the parent. (school object)
\nBut also if the data in the parent changes, the child gets the updated changed data, redo the conversions above and give the updated data back to the parent. (if the student's city changes, then their school also changes)
\nHow would we do this? Thanks for the help!
\n"},{"tags":["python","pandas","matplotlib"],"owner":{"reputation":372,"user_id":14829523,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/074b5d61968152cfa3fdaf216aff7cc7?s=128&d=identicon&r=PG&f=1","display_name":"Exa","link":"https://stackoverflow.com/users/14829523/exa"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623259307,"creation_date":1623259307,"question_id":67908942,"share_link":"https://stackoverflow.com/q/67908942","body_markdown":"I have the following dummy dfs:\r\n\r\n # First df\r\n columns_One = ['count']\r\n data_One = [['1.0'],\r\n ['100.0'],\r\n ['100.0'],\r\n ['120.0'],\r\n ['500.0'],\r\n ['540.0'],\r\n ['590.0']]\r\n dummy_One = pd.DataFrame(columns=columns_One, data=data_One)\r\n \r\n # Second df\r\n columns_Two = ['count']\r\n data_Two = [['1.0'],\r\n ['100.0'],\r\n ['102.0'],\r\n ['300.0'],\r\n ['490.0'],\r\n ['400.0'],\r\n ['290.0']]\r\n dummy_Two = pd.DataFrame(columns=columns_Two, data=data_Two)\r\n\r\nI am trying to plot two charts next to each other like this:\r\n\r\n fig, axes = pyplot.subplots(1, 2)\r\n\r\n bins = numpy.linspace(1, 10)\r\n \r\n \r\n dummy_One.hist('dummy 1', bins, ax=axes[0])\r\n dummy_Two.hist('dummy 2', bins, ax=axes[1])\r\n pyplot.xticks(range(11))\r\n pyplot.xlabel('I am the x axis')\r\n pyplot.ylabel('I am the y axis')\r\n pyplot.legend(loc='upper right')\r\n \r\n pyplot.show()\r\n\r\nbut getting the error `ValueError: Grouper and axis must be same length`\r\n\r\nI do not understand why. The two dfs have the same shape.\r\n\r\n","link":"https://stackoverflow.com/questions/67908942/plotting-two-histograms-side-by-side-results-in-valueerror","title":"Plotting two histograms side by side results in ValueError","body":"I have the following dummy dfs:
\n# First df\ncolumns_One = ['count']\ndata_One = [['1.0'],\n ['100.0'],\n ['100.0'],\n ['120.0'],\n ['500.0'],\n ['540.0'],\n ['590.0']]\ndummy_One = pd.DataFrame(columns=columns_One, data=data_One)\n\n# Second df\ncolumns_Two = ['count']\ndata_Two = [['1.0'],\n ['100.0'],\n ['102.0'],\n ['300.0'],\n ['490.0'],\n ['400.0'],\n ['290.0']]\ndummy_Two = pd.DataFrame(columns=columns_Two, data=data_Two)\n
\nI am trying to plot two charts next to each other like this:
\nfig, axes = pyplot.subplots(1, 2)\n\nbins = numpy.linspace(1, 10)\n\n\ndummy_One.hist('dummy 1', bins, ax=axes[0])\ndummy_Two.hist('dummy 2', bins, ax=axes[1])\npyplot.xticks(range(11))\npyplot.xlabel('I am the x axis')\npyplot.ylabel('I am the y axis')\npyplot.legend(loc='upper right')\n\npyplot.show()\n
\nbut getting the error ValueError: Grouper and axis must be same length
I do not understand why. The two dfs have the same shape.
\n"},{"tags":["java","android","android-linearlayout","visibility","show-hide"],"comments":[{"owner":{"reputation":111,"user_id":11057391,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/06497cd1e589611aa9863dc56786060c?s=128&d=identicon&r=PG&f=1","display_name":"Saravanan","link":"https://stackoverflow.com/users/11057391/saravanan"},"edited":false,"score":1,"creation_date":1623258222,"post_id":67908594,"comment_id":120030261,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":16177674,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ghq1-kEBr_o9EZvxjj3eU7RT2_uVgmCW6yGY5DXOQ=k-s128","display_name":"Suraj Verma","link":"https://stackoverflow.com/users/16177674/suraj-verma"},"reply_to_user":{"reputation":111,"user_id":11057391,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/06497cd1e589611aa9863dc56786060c?s=128&d=identicon&r=PG&f=1","display_name":"Saravanan","link":"https://stackoverflow.com/users/11057391/saravanan"},"edited":false,"score":0,"creation_date":1623258655,"post_id":67908594,"comment_id":120030409,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":111,"user_id":11057391,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/06497cd1e589611aa9863dc56786060c?s=128&d=identicon&r=PG&f=1","display_name":"Saravanan","link":"https://stackoverflow.com/users/11057391/saravanan"},"edited":false,"score":0,"creation_date":1623259006,"post_id":67908594,"comment_id":120030552,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":16177674,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ghq1-kEBr_o9EZvxjj3eU7RT2_uVgmCW6yGY5DXOQ=k-s128","display_name":"Suraj Verma","link":"https://stackoverflow.com/users/16177674/suraj-verma"},"reply_to_user":{"reputation":111,"user_id":11057391,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/06497cd1e589611aa9863dc56786060c?s=128&d=identicon&r=PG&f=1","display_name":"Saravanan","link":"https://stackoverflow.com/users/11057391/saravanan"},"edited":false,"score":0,"creation_date":1623259392,"post_id":67908594,"comment_id":120030701,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":968,"user_id":9089370,"user_type":"registered","profile_image":"https://i.stack.imgur.com/5ofPv.jpg?s=128&g=1","display_name":"androidLearner","link":"https://stackoverflow.com/users/9089370/androidlearner"},"is_accepted":false,"score":0,"last_activity_date":1623259307,"creation_date":1623259307,"answer_id":67908941,"question_id":67908594,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16177674,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ghq1-kEBr_o9EZvxjj3eU7RT2_uVgmCW6yGY5DXOQ=k-s128","display_name":"Suraj Verma","link":"https://stackoverflow.com/users/16177674/suraj-verma"},"is_answered":false,"view_count":13,"answer_count":1,"score":0,"last_activity_date":1623259307,"creation_date":1623257797,"last_edit_date":1623258101,"question_id":67908594,"share_link":"https://stackoverflow.com/q/67908594","body_markdown":"**The main layout is a Linear layout inside that a scroll view is there which contain sublayouts. Here is my layout [omitted everything except the specific layout (marked with red) as it will be very long] :**\r\n\r\n <ScrollView\r\n android:layout_width="match_parent"\r\n android:layout_height="match_parent">\r\n\r\n <LinearLayout\r\n android:layout_width="match_parent"\r\n android:layout_height="match_parent"\r\n android:orientation="vertical">\r\n\r\n <androidx.cardview.widget.CardView\r\n android:layout_width="match_parent"\r\n android:layout_height="wrap_content"\r\n android:layout_gravity="center"\r\n android:layout_marginStart="10dp"\r\n android:layout_marginTop="8dp"\r\n android:layout_marginEnd="10dp"\r\n android:layout_marginBottom="8dp"\r\n android:foreground="?android:attr/selectableItemBackground"\r\n app:cardCornerRadius="8dp"\r\n app:cardElevation="10dp">\r\n\r\n <LinearLayout\r\n android:layout_width="match_parent"\r\n android:layout_height="match_parent"\r\n android:orientation="vertical"\r\n android:padding="8dp">\r\n\r\n\r\n <LinearLayout\r\n android:id="@+id/layoutIncomeTax"\r\n android:layout_width="match_parent"\r\n android:layout_height="wrap_content"\r\n android:orientation="horizontal">\r\n\r\n <TextView\r\n android:layout_width="wrap_content"\r\n android:layout_height="wrap_content"\r\n android:gravity="start"\r\n android:text="Income Tax:"\r\n android:textColor="@color/black"\r\n android:textSize="16sp" />\r\n\r\n <TextView\r\n android:id="@+id/tvIncomeTax"\r\n android:layout_width="wrap_content"\r\n android:layout_height="wrap_content"\r\n android:layout_weight="1"\r\n android:gravity="end"\r\n android:text="0"\r\n android:textColor="@color/black"\r\n android:textSize="16sp"\r\n android:textStyle="bold" />\r\n\r\n </LinearLayout>\r\n\r\n </LinearLayout>\r\n\r\n </androidx.cardview.widget.CardView>\r\n\r\n </LinearLayout>\r\n\r\n </ScrollView>\r\n\r\n\r\n</LinearLayout>\r\n\r\n\r\n**Here is my code (removed unnecessary codes) :**\r\n\r\npublic class ViewSalary extends AppCompatActivity {\r\n\r\n private Spinner selectShift, selectYear, selectMonth;\r\n private EditText edtEmployeeCode;\r\n private Button viewSalaryBtn;\r\n private String shift, year, month;\r\n\r\n\r\n DatabaseReference rootDatabaseRef;\r\n\r\n private LinearLayout layoutIncomeTax;\r\n\r\n private TextView tvIncomeTax;\r\n\r\n @Override\r\n protected void onCreate(Bundle savedInstanceState) {\r\n super.onCreate(savedInstanceState);\r\n setContentView(R.layout.activity_view_salary);\r\n\r\n\r\n viewSalaryBtn = findViewById(R.id.viewSalaryBtn);\r\n\r\n layoutIncomeTax = findViewById(R.id.layoutIncomeTax);\r\n\r\n tvIncomeTax = findViewById(R.id.tvIncomeTax);\r\n\r\n rootDatabaseRef = FirebaseDatabase.getInstance().getReference().child("Salary");\r\n\r\n viewSalaryBtn.setOnClickListener(new View.OnClickListener() {\r\n @Override\r\n public void onClick(View v) {\r\n\r\n viewSalary();\r\n\r\n String checkIncomeTax = tvIncomeTax.getText().toString();\r\n if (checkIncomeTax.equals("0.0")) {\r\n layoutIncomeTax.setVisibility(layoutIncomeTax.GONE);\r\n }\r\n\r\n }\r\n });\r\n\r\n\r\n }\r\n\r\n private void viewSalary() {\r\n\r\n final String empCode = edtEmployeeCode.getText().toString();\r\n\r\n DatabaseReference empRef = rootDatabaseRef.child(shift).child(year).child(month).child(empCode);\r\n\r\n empRef.addValueEventListener(new ValueEventListener() {\r\n @Override\r\n public void onDataChange(@NonNull DataSnapshot dataSnapshot) {\r\n if (dataSnapshot.exists()) {\r\n\r\n String incomeTax = dataSnapshot.child("IncomeTax").getValue(String.class);\r\n\r\n tvIncomeTax.setText(incomeTax);\r\n\r\n } else {\r\n Toast.makeText(ViewSalary.this, "Data does not exist!", Toast.LENGTH_SHORT).show();\r\n }\r\n }\r\n\r\n @Override\r\n public void onCancelled(@NonNull DatabaseError error) {\r\n Toast.makeText(ViewSalary.this, error.getMessage(), Toast.LENGTH_SHORT).show();\r\n }\r\n });\r\n\r\n }\r\n\r\n\r\n}\r\n\r\n**I want to hide all linear layouts on button click after getting the data loaded and if TextView value is "0.0" (like the one marked with red in screenshot)**\r\n\r\n[Screenshot][1]\r\n\r\n\r\n [1]: https://i.stack.imgur.com/LvAea.jpg","link":"https://stackoverflow.com/questions/67908594/how-to-set-visibility-gone-of-a-linear-layout-which-is-inside-a-scroll-view-and","title":"How to set visibility GONE of a Linear Layout which is inside a scroll view and contains two TextViews inside?","body":"The main layout is a Linear layout inside that a scroll view is there which contain sublayouts. Here is my layout [omitted everything except the specific layout (marked with red) as it will be very long] :
\n<ScrollView\n android:layout_width="match_parent"\n android:layout_height="match_parent">\n\n <LinearLayout\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:orientation="vertical">\n\n <androidx.cardview.widget.CardView\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:layout_gravity="center"\n android:layout_marginStart="10dp"\n android:layout_marginTop="8dp"\n android:layout_marginEnd="10dp"\n android:layout_marginBottom="8dp"\n android:foreground="?android:attr/selectableItemBackground"\n app:cardCornerRadius="8dp"\n app:cardElevation="10dp">\n\n <LinearLayout\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:orientation="vertical"\n android:padding="8dp">\n\n\n <LinearLayout\n android:id="@+id/layoutIncomeTax"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:orientation="horizontal">\n\n <TextView\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:gravity="start"\n android:text="Income Tax:"\n android:textColor="@color/black"\n android:textSize="16sp" />\n\n <TextView\n android:id="@+id/tvIncomeTax"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_weight="1"\n android:gravity="end"\n android:text="0"\n android:textColor="@color/black"\n android:textSize="16sp"\n android:textStyle="bold" />\n\n </LinearLayout>\n\n </LinearLayout>\n\n </androidx.cardview.widget.CardView>\n\n </LinearLayout>\n\n</ScrollView>\n
\n\nHere is my code (removed unnecessary codes) :
\npublic class ViewSalary extends AppCompatActivity {
\nprivate Spinner selectShift, selectYear, selectMonth;\nprivate EditText edtEmployeeCode;\nprivate Button viewSalaryBtn;\nprivate String shift, year, month;\n\n\nDatabaseReference rootDatabaseRef;\n\nprivate LinearLayout layoutIncomeTax;\n\nprivate TextView tvIncomeTax;\n\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_view_salary);\n\n\n viewSalaryBtn = findViewById(R.id.viewSalaryBtn);\n\n layoutIncomeTax = findViewById(R.id.layoutIncomeTax);\n\n tvIncomeTax = findViewById(R.id.tvIncomeTax);\n\n rootDatabaseRef = FirebaseDatabase.getInstance().getReference().child("Salary");\n\n viewSalaryBtn.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n\n viewSalary();\n\n String checkIncomeTax = tvIncomeTax.getText().toString();\n if (checkIncomeTax.equals("0.0")) {\n layoutIncomeTax.setVisibility(layoutIncomeTax.GONE);\n }\n\n }\n });\n\n\n}\n\nprivate void viewSalary() {\n\n final String empCode = edtEmployeeCode.getText().toString();\n\n DatabaseReference empRef = rootDatabaseRef.child(shift).child(year).child(month).child(empCode);\n\n empRef.addValueEventListener(new ValueEventListener() {\n @Override\n public void onDataChange(@NonNull DataSnapshot dataSnapshot) {\n if (dataSnapshot.exists()) {\n\n String incomeTax = dataSnapshot.child("IncomeTax").getValue(String.class);\n\n tvIncomeTax.setText(incomeTax);\n\n } else {\n Toast.makeText(ViewSalary.this, "Data does not exist!", Toast.LENGTH_SHORT).show();\n }\n }\n\n @Override\n public void onCancelled(@NonNull DatabaseError error) {\n Toast.makeText(ViewSalary.this, error.getMessage(), Toast.LENGTH_SHORT).show();\n }\n });\n\n}\n
\n}
\nI want to hide all linear layouts on button click after getting the data loaded and if TextView value is "0.0" (like the one marked with red in screenshot)
\n\n"},{"tags":["python","flask","range","flask-sqlalchemy"],"owner":{"reputation":13,"user_id":13541951,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/fa18bf723514cb20c3c9766a4899ce2b?s=128&d=identicon&r=PG&f=1","display_name":"programmeurNED","link":"https://stackoverflow.com/users/13541951/programmeurned"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623259305,"creation_date":1623259305,"question_id":67908940,"share_link":"https://stackoverflow.com/q/67908940","body_markdown":"For a school project, I am building a mastermind game with Python 3.8 and Flask webapp. Firstly, I created a program just using functions, and now I am trying to implement classes.\r\n\r\nWhen: 'objMastermind.secret_list(objMastermind)' is executed in Flask.py it return []. However, the variable iMaxPos, iMaxColor = 4? Thus, the for-loop isn't doing his job.\r\n\r\nCan someone help me out? \r\nThanks in advance!\r\n\r\n*main = webflask.py*\r\n\r\n**mastermind.py**\r\n\r\n```\r\n# Built-in library\r\nimport random\r\n\r\nMAX_COLORS = 4\r\nMAX_POSITIONS = 4\r\ncorrectGuesses = 0\r\ncurrentTries = 0\r\n\r\nclass Mastermind(): \r\n\r\n @property\r\n def userInputs(self, iMaxColors, iMaxPositions, iGuessesList, qSecretList):\r\n self.iMaxColors = iMaxColors\r\n self.iMaxPositons = iMaxPositions\r\n self.iGuessesList = iGuessesList\r\n self.qSecretList = qSecretList\r\n return self.iMaxColors, self.iMaxPositons, self.iMaxPositons\r\n\r\n @userInputs.setter\r\n def userInputs(self, iMaxColors, iMaxPositions, iGuessesList, qSecretList):\r\n self.iMaxColors = iMaxColors\r\n self.iMaxPositons = iMaxPositions\r\n self.iGuessesList = iGuessesList\r\n self.qSecretList = qSecretList\r\n\r\n def __init__(self):\r\n self.iMaxColors = 0\r\n self.iMaxPositons = 0\r\n self.iGuessesList = []\r\n self.qSecretList = []\r\n\r\n #generates a list of random numbers\r\n def secret_list(self, objMastermind):\r\n objMastermind.qSecretList = []\r\n print("iMaxPos =", objMastermind.iMaxPositions)\r\n print("iMaxColor =", objMastermind.iMaxColors)\r\n\r\n #loop max_positions amount of times\r\n for i in range(int(objMastermind.iMaxPositons)): \r\n objMastermind.qSecretList.append(random.randint(1, int(objMastermind.iMaxColors)))\r\n print(i)\r\n #print the secret_list ** don't tell anyone **\r\n print(objMastermind.qSecretList)\r\n print("Done")\r\n print(objMastermind.iMaxColors)\r\n return objMastermind.qSecretList\r\n\r\n def guesses(objMastermind):\r\n guess_list = []\r\n for i in range(objMastermind.iMaxPositons):\r\n guess_list.append(int(input("Please, guess the number: ")))\r\n\r\n #print the inserted \r\n print("\\n", guess_list)\r\n return guess_list\r\n\r\n def checkResult(mastermind_list, guesses_list):\r\n correctGuesses = 0\r\n closeGuesses = 0\r\n for i in range(len(guesses_list)):\r\n if(guesses_list[i] == mastermind_list[i]):\r\n correctGuesses += 1\r\n \r\n print("correctGuesses: ", correctGuesses)\r\n\r\n closeGuesses = len(set(guesses_list).intersection(mastermind_list))\r\n closeGuesses -= correctGuesses\r\n \r\n print("closeGuesses: ", closeGuesses)\r\n\r\n return correctGuesses \r\n\r\nif __name__ == "__main__":\r\n\r\n #mastermind_list = Mastermind.secret_list(MAX_COLORS, MAX_POSITIONS)\r\n #print(mastermind_list)\r\n\r\n #print("Welcome to the Mastermind game")\r\n #print("Try to guess the 4 secret numbers.\\n")\r\n\r\n while(correctGuesses < MAX_POSITIONS):\r\n #guesses_list = Mastermind.guesses(MAX_POSITIONS)\r\n\r\n #correctGuesses = Mastermind.checkResult(mastermind_list, guesses_list)\r\n \r\n currentTries += 1\r\n if(correctGuesses < MAX_POSITIONS):\r\n print("\\nYou guessed " + str(correctGuesses) + " number(s) corretly.\\n")\r\n correctGuesses = 0\r\n continue\r\n else:\r\n if (currentTries == 1):\r\n print("Congratulation, you guessed all 4 numers!! It took you " + str(currentTries) + " try.\\n")\r\n else:\r\n print("Congratulation, you guessed all 4 numers!! It took you " + str(currentTries) + " tries.\\n")\r\n```\r\n\r\n**webflask.py**\r\n```\r\nfrom mastermind import Mastermind\r\nfrom flask import Flask, render_template, request, url_for, redirect\r\nfrom werkzeug.utils import redirect\r\n\r\napp = Flask(__name__, template_folder='template')\r\n\r\n#init\r\nobjMastermind = Mastermind()\r\n\r\n@app.route('/', methods=["POST", "GET"])\r\ndef mastermind_home():\r\n \r\n if(request.method == "POST"):\r\n player_name= request.form["fullName"]\r\n objMastermind.iMaxColors = int(request.form["maxColors"])\r\n objMastermind.iMaxPositions = int(request.form["maxPositions"])\r\n objMastermind.secret_list(objMastermind)\r\n return redirect(url_for("startGame", usr=player_name))\r\n else:\r\n return render_template('mastermind_html.html')\r\n\r\n@app.route("/the-game-<usr>")\r\ndef startGame(usr):\r\n guessList = []\r\n mastermind_list = []\r\n if(request.method == "POST"):\r\n guessListPos1= request.form["guessListPos1"]\r\n guessListPos2= request.form["guessListPos2"]\r\n guessListPos3= request.form["guessListPos3"]\r\n guessListPos4= request.form["guessListPos4"]\r\n\r\n guessList.append(guessListPos1, guessListPos2, guessListPos3, guessListPos4)\r\n Mastermind.Mastermind.checkResult(mastermind_list, guessList)\r\n return render_template('mastermind_game.html', fullname = usr)\r\n else:\r\n return render_template('mastermind_game.html', fullname = usr)\r\n #return f"<h1>{usr}</h1>"\r\n\r\n\r\n\r\n#@app.route('/')\r\n#def home():\r\n #return 'Hello WorldTom!'\r\n \r\nif __name__ == '__main__':\r\n app.run(debug=True)\r\n app.logger()\r\n\r\n\r\n```\r\n\r\n**Output:**\r\n```\r\n* Serving Flask app 'webflask' (lazy loading)\r\n * Environment: production\r\n WARNING: This is a development server. Do not use it in a production deployment.\r\n Use a production WSGI server instead.\r\n * Debug mode: on\r\n * Restarting with stat\r\n * Debugger is active!\r\n * Debugger PIN: 492-502-031\r\n * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\r\n127.0.0.1 - - [09/Jun/2021 19:15:09] "GET / HTTP/1.1" 200 -\r\niMaxPos = 4\r\niMaxColor = 4\r\nDone\r\n4\r\n127.0.0.1 - - [09/Jun/2021 19:15:12] "POST / HTTP/1.1" 302 -\r\n127.0.0.1 - - [09/Jun/2021 19:15:12] "GET /the-game-Tim%20Boekhorst HTTP/1.1" 200 -\r\n```","link":"https://stackoverflow.com/questions/67908940/python-class-integration-for-loop-not-working","title":"Python class integration for-loop not working","body":"For a school project, I am building a mastermind game with Python 3.8 and Flask webapp. Firstly, I created a program just using functions, and now I am trying to implement classes.
\nWhen: 'objMastermind.secret_list(objMastermind)' is executed in Flask.py it return []. However, the variable iMaxPos, iMaxColor = 4? Thus, the for-loop isn't doing his job.
\nCan someone help me out?\nThanks in advance!
\nmain = webflask.py
\nmastermind.py
\n# Built-in library\nimport random\n\nMAX_COLORS = 4\nMAX_POSITIONS = 4\ncorrectGuesses = 0\ncurrentTries = 0\n\nclass Mastermind(): \n\n @property\n def userInputs(self, iMaxColors, iMaxPositions, iGuessesList, qSecretList):\n self.iMaxColors = iMaxColors\n self.iMaxPositons = iMaxPositions\n self.iGuessesList = iGuessesList\n self.qSecretList = qSecretList\n return self.iMaxColors, self.iMaxPositons, self.iMaxPositons\n\n @userInputs.setter\n def userInputs(self, iMaxColors, iMaxPositions, iGuessesList, qSecretList):\n self.iMaxColors = iMaxColors\n self.iMaxPositons = iMaxPositions\n self.iGuessesList = iGuessesList\n self.qSecretList = qSecretList\n\n def __init__(self):\n self.iMaxColors = 0\n self.iMaxPositons = 0\n self.iGuessesList = []\n self.qSecretList = []\n\n #generates a list of random numbers\n def secret_list(self, objMastermind):\n objMastermind.qSecretList = []\n print("iMaxPos =", objMastermind.iMaxPositions)\n print("iMaxColor =", objMastermind.iMaxColors)\n\n #loop max_positions amount of times\n for i in range(int(objMastermind.iMaxPositons)): \n objMastermind.qSecretList.append(random.randint(1, int(objMastermind.iMaxColors)))\n print(i)\n #print the secret_list ** don't tell anyone **\n print(objMastermind.qSecretList)\n print("Done")\n print(objMastermind.iMaxColors)\n return objMastermind.qSecretList\n\n def guesses(objMastermind):\n guess_list = []\n for i in range(objMastermind.iMaxPositons):\n guess_list.append(int(input("Please, guess the number: ")))\n\n #print the inserted \n print("\\n", guess_list)\n return guess_list\n\n def checkResult(mastermind_list, guesses_list):\n correctGuesses = 0\n closeGuesses = 0\n for i in range(len(guesses_list)):\n if(guesses_list[i] == mastermind_list[i]):\n correctGuesses += 1\n \n print("correctGuesses: ", correctGuesses)\n\n closeGuesses = len(set(guesses_list).intersection(mastermind_list))\n closeGuesses -= correctGuesses\n \n print("closeGuesses: ", closeGuesses)\n\n return correctGuesses \n\nif __name__ == "__main__":\n\n #mastermind_list = Mastermind.secret_list(MAX_COLORS, MAX_POSITIONS)\n #print(mastermind_list)\n\n #print("Welcome to the Mastermind game")\n #print("Try to guess the 4 secret numbers.\\n")\n\n while(correctGuesses < MAX_POSITIONS):\n #guesses_list = Mastermind.guesses(MAX_POSITIONS)\n\n #correctGuesses = Mastermind.checkResult(mastermind_list, guesses_list)\n \n currentTries += 1\n if(correctGuesses < MAX_POSITIONS):\n print("\\nYou guessed " + str(correctGuesses) + " number(s) corretly.\\n")\n correctGuesses = 0\n continue\n else:\n if (currentTries == 1):\n print("Congratulation, you guessed all 4 numers!! It took you " + str(currentTries) + " try.\\n")\n else:\n print("Congratulation, you guessed all 4 numers!! It took you " + str(currentTries) + " tries.\\n")\n
\nwebflask.py
\nfrom mastermind import Mastermind\nfrom flask import Flask, render_template, request, url_for, redirect\nfrom werkzeug.utils import redirect\n\napp = Flask(__name__, template_folder='template')\n\n#init\nobjMastermind = Mastermind()\n\n@app.route('/', methods=["POST", "GET"])\ndef mastermind_home():\n \n if(request.method == "POST"):\n player_name= request.form["fullName"]\n objMastermind.iMaxColors = int(request.form["maxColors"])\n objMastermind.iMaxPositions = int(request.form["maxPositions"])\n objMastermind.secret_list(objMastermind)\n return redirect(url_for("startGame", usr=player_name))\n else:\n return render_template('mastermind_html.html')\n\n@app.route("/the-game-<usr>")\ndef startGame(usr):\n guessList = []\n mastermind_list = []\n if(request.method == "POST"):\n guessListPos1= request.form["guessListPos1"]\n guessListPos2= request.form["guessListPos2"]\n guessListPos3= request.form["guessListPos3"]\n guessListPos4= request.form["guessListPos4"]\n\n guessList.append(guessListPos1, guessListPos2, guessListPos3, guessListPos4)\n Mastermind.Mastermind.checkResult(mastermind_list, guessList)\n return render_template('mastermind_game.html', fullname = usr)\n else:\n return render_template('mastermind_game.html', fullname = usr)\n #return f"<h1>{usr}</h1>"\n\n\n\n#@app.route('/')\n#def home():\n #return 'Hello WorldTom!'\n \nif __name__ == '__main__':\n app.run(debug=True)\n app.logger()\n\n\n
\nOutput:
\n* Serving Flask app 'webflask' (lazy loading)\n * Environment: production\n WARNING: This is a development server. Do not use it in a production deployment.\n Use a production WSGI server instead.\n * Debug mode: on\n * Restarting with stat\n * Debugger is active!\n * Debugger PIN: 492-502-031\n * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n127.0.0.1 - - [09/Jun/2021 19:15:09] "GET / HTTP/1.1" 200 -\niMaxPos = 4\niMaxColor = 4\nDone\n4\n127.0.0.1 - - [09/Jun/2021 19:15:12] "POST / HTTP/1.1" 302 -\n127.0.0.1 - - [09/Jun/2021 19:15:12] "GET /the-game-Tim%20Boekhorst HTTP/1.1" 200 -\n
\n"},{"tags":["c#",".net","datagridview"],"owner":{"reputation":1,"user_id":6951001,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/90574f53e532d5af85038dc7ffd8b379?s=128&d=identicon&r=PG&f=1","display_name":"DBAStarter","link":"https://stackoverflow.com/users/6951001/dbastarter"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259302,"creation_date":1623259302,"question_id":67908939,"share_link":"https://stackoverflow.com/q/67908939","body_markdown":"I have a bound DataGridView in which I've set a DateTimePicker control to become accessible when I click in the first column of a row. This works well.\r\n\r\nMy problem is when I exit the DateTimePicker cell and the DataGridView is repopulated the active cell always becomes the top left in the grid. To remedy this, I store the current Column and Row indexes then set the CurrentCell:\r\n```\r\nint iColumn = e.ColumnIndex;\r\nint iRow = e.RowIndex;\r\ndgvDataGrid.CurrentCell = dgvDataGrid[iColumn + 1, iRow];\r\n```\r\nI tried including\r\n```\r\ndgvDataGrid.CurrentCell.Selected = true;\r\n```\r\nAnd\r\n```\r\ndgvDataGrid.BeginEdit(true);\r\n```\r\nBut it seems no matter what I try I cannot begin entering data into the Selected cell unless I actually click in that cell first. I have checked, the iColumn and iRow values are what I expect/want them to be.\r\n\r\nMy goal is to set the CurrentCell then be able to enter data into it with out having to click the cell first.\r\nAny help is appreciated. \r\n","link":"https://stackoverflow.com/questions/67908939/cannot-type-in-cell-after-setting-datagridview-currentcell","title":"Cannot type in cell after setting DataGridView.CurrentCell","body":"I have a bound DataGridView in which I've set a DateTimePicker control to become accessible when I click in the first column of a row. This works well.
\nMy problem is when I exit the DateTimePicker cell and the DataGridView is repopulated the active cell always becomes the top left in the grid. To remedy this, I store the current Column and Row indexes then set the CurrentCell:
\nint iColumn = e.ColumnIndex;\nint iRow = e.RowIndex;\ndgvDataGrid.CurrentCell = dgvDataGrid[iColumn + 1, iRow];\n
\nI tried including
\ndgvDataGrid.CurrentCell.Selected = true;\n
\nAnd
\ndgvDataGrid.BeginEdit(true);\n
\nBut it seems no matter what I try I cannot begin entering data into the Selected cell unless I actually click in that cell first. I have checked, the iColumn and iRow values are what I expect/want them to be.
\nMy goal is to set the CurrentCell then be able to enter data into it with out having to click the cell first.\nAny help is appreciated.
\n"},{"tags":["javascript","date","timezone","timezone-offset"],"comments":[{"owner":{"reputation":448,"user_id":5091166,"user_type":"registered","profile_image":"https://i.stack.imgur.com/CNSWr.png?s=128&g=1","display_name":"JavaScript","link":"https://stackoverflow.com/users/5091166/javascript"},"edited":false,"score":1,"creation_date":1623228389,"post_id":67900555,"comment_id":120016390,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":124839,"user_id":257182,"user_type":"registered","accept_rate":43,"profile_image":"https://www.gravatar.com/avatar/f2c683e7dc0c4d4bcc790f87eaa67301?s=128&d=identicon&r=PG","display_name":"RobG","link":"https://stackoverflow.com/users/257182/robg"},"edited":false,"score":0,"creation_date":1623230357,"post_id":67900555,"comment_id":120017228,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":19,"user_id":11825348,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/39d634f30787726eb74a501ce3ba5911?s=128&d=identicon&r=PG&f=1","display_name":"parsa","link":"https://stackoverflow.com/users/11825348/parsa"},"is_accepted":false,"score":-1,"last_activity_date":1623229079,"creation_date":1623229079,"answer_id":67900811,"question_id":67900555,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":198020,"user_id":634824,"user_type":"registered","accept_rate":87,"profile_image":"https://www.gravatar.com/avatar/889cf720c96957e615463b5c903a5e18?s=128&d=identicon&r=PG","display_name":"Matt Johnson-Pint","link":"https://stackoverflow.com/users/634824/matt-johnson-pint"},"is_accepted":false,"score":0,"last_activity_date":1623259301,"creation_date":1623259301,"answer_id":67908938,"question_id":67900555,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":19,"user_id":11825348,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/39d634f30787726eb74a501ce3ba5911?s=128&d=identicon&r=PG&f=1","display_name":"parsa","link":"https://stackoverflow.com/users/11825348/parsa"},"is_answered":false,"view_count":35,"answer_count":2,"score":1,"last_activity_date":1623259301,"creation_date":1623227996,"question_id":67900555,"share_link":"https://stackoverflow.com/q/67900555","body_markdown":"I recently noticed that the values of these two are different on some dates.\r\n\r\nFor example, the output of both is the same for `04/01/2020` but different for `03/01/2020`.\r\n\r\n```javascript\r\nconsole.log(\r\n new Date("2020/03/01").getTimezoneOffset(), //-210\r\n new Date().getTimezoneOffset(), //-270\r\n);\r\n\r\nconsole.log(\r\n new Date("2020/04/01").getTimezoneOffset(), //-270\r\n new Date().getTimezoneOffset(), //-270\r\n);\r\n\r\n```\r\n\r\nI did this test for all the months of this year and the result was:\r\n\r\n- `2020/01/01` -> different ``` ```\r\n- `2020/02/01` -> different \r\n- `2020/03/01` -> different \r\n- `2020/04/01` -> same\r\n- `2020/05/01` -> same\r\n- `2020/06/01` -> same\r\n- `2020/07/01` -> same\r\n- `2020/08/01` -> same\r\n- `2020/09/01` -> same\r\n- `2020/10/01` -> different \r\n- `2020/11/01` -> different \r\n- `2020/12/01` -> different ","link":"https://stackoverflow.com/questions/67900555/what-is-the-difference-between-new-date-gettimezoneoffset-and-new-datestrin","title":"What is the difference between new Date().getTimezoneOffset() and new Date(string).getTimezoneOffset()?","body":"I recently noticed that the values of these two are different on some dates.
\nFor example, the output of both is the same for 04/01/2020
but different for 03/01/2020
.
console.log(\n new Date("2020/03/01").getTimezoneOffset(), //-210\n new Date().getTimezoneOffset(), //-270\n);\n\nconsole.log(\n new Date("2020/04/01").getTimezoneOffset(), //-270\n new Date().getTimezoneOffset(), //-270\n);\n\n
\nI did this test for all the months of this year and the result was:
\n2020/01/01
-> different
2020/02/01
-> different2020/03/01
-> different2020/04/01
-> same2020/05/01
-> same2020/06/01
-> same2020/07/01
-> same2020/08/01
-> same2020/09/01
-> same2020/10/01
-> different2020/11/01
-> different2020/12/01
-> differentcontroller node js
\n const vacation = new vacationModel(req.body);\n console.log(req.files);\n\n if (req.files === undefined) {\n console.log("missing image");\n return res.status(400).send("missing image");\n }\n const image = req.files.vacationImageName;\n console.log(image);\n\n const addedVacation = await vacationLogic.addNewVacationAsync(\n vacation,\n image\n );\n res.json(addedVacation);\n } catch (err) {\n console.log(err);\n res.status(400).send(err.message);\n }\n});\n
\nreact app
\n async function send(vacation: vacationModel) {\n try {\n const res = await axios.post<vacationModel>(\n globals.addNewVacationUrl,\n vacationModel.convertToFormData(vacation)\n );\n console.log(vacationModel.convertToFormData(vacation));\n
\nthe result was that the image was send as a req.body\nbut not as a req.files so i cant accsses the image from node cause its undefined
\n"},{"tags":["mysql","sql","oracle","oracle12c"],"comments":[{"owner":{"reputation":21611,"user_id":10138734,"user_type":"registered","profile_image":"https://i.stack.imgur.com/sf6Zj.jpg?s=128&g=1","display_name":"Akina","link":"https://stackoverflow.com/users/10138734/akina"},"edited":false,"score":0,"creation_date":1623243408,"post_id":67903994,"comment_id":120023095,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":21611,"user_id":10138734,"user_type":"registered","profile_image":"https://i.stack.imgur.com/sf6Zj.jpg?s=128&g=1","display_name":"Akina","link":"https://stackoverflow.com/users/10138734/akina"},"is_accepted":false,"score":0,"last_activity_date":1623243606,"creation_date":1623243606,"answer_id":67904671,"question_id":67903994,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":2119,"user_id":2527458,"user_type":"registered","accept_rate":36,"profile_image":"https://i.stack.imgur.com/fYtXY.jpg?s=128&g=1","display_name":"majid hajibaba","link":"https://stackoverflow.com/users/2527458/majid-hajibaba"},"is_accepted":false,"score":0,"last_activity_date":1623245330,"creation_date":1623245330,"answer_id":67905131,"question_id":67903994,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":712,"user_id":9010859,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/524fca838730d14d33ed041b3f42ca0b?s=128&d=identicon&r=PG&f=1","display_name":"JagaSrik","link":"https://stackoverflow.com/users/9010859/jagasrik"},"is_answered":false,"view_count":22,"answer_count":2,"score":0,"last_activity_date":1623259299,"creation_date":1623241055,"last_edit_date":1623259299,"question_id":67903994,"share_link":"https://stackoverflow.com/q/67903994","body_markdown":"Consider my source table as given below i.e customer.\r\n\r\nHow can i get the required output as shown using sql (oracle or mysql)\r\n\r\ncustomer :\r\n\r\n customer id Purchase_id cashback \r\n 123\t\tabc111\t\t\t5\r\n 123\t\tabc112\t\t\t5\r\n 123\t\tabc113\t\t\t2\r\n 345\t\tabc311\t\t\t0\r\n 345\t\tabc312\t\t\t2\t\r\n 678\t\tabc611\t\t\t4\t\r\n 678\t\tabc612\t\t\t3\t\r\n 678\t\tabc613\t\t\t5\t\r\n\r\nOutput Needed:\r\n\r\n ID \tpurchare_id_1 purchare_id_2 purchare_id_3 cashback_1 cashback_2 cashback_3 \r\n 123 \tabc111\t\t\tabc112\t\tabc113\t\t\t5\t\t\t5\t\t\t2\r\n 345\tabc311\t\t\tabc312\t\t\t\t\t\t0\t\t\t2\t\t\t\r\n 678\tabc611\t\t\tabc612\t\tabc613\t\t\t4\t\t\t3\t\t\t5\t\r\n\r\n\r\nDML and DDL:\r\n\r\n create table cust_table (\r\n customer_id int, Purchase_id varchar(100), cashback int\r\n );\r\n \r\n insert into cust_table values\r\n (123 , 'abc111' , 5),\r\n (123 , 'abc112' , 5),\r\n (123 , 'abc113' , 2),\r\n ( 345 , 'abc311' , 0),\r\n (345 , 'abc312' , 2),\r\n (678 , 'abc611' , 4),\r\n (678 , 'abc612' , 3),\r\n (678 , 'abc613' , 5);\r\n \r\n commit;\r\n\r\nPS:\r\nData might be not static, it can change.","link":"https://stackoverflow.com/questions/67903994/how-can-i-get-this-pivot-kind-of-output-in-sql","title":"How can I get this pivot kind of output in sql","body":"Consider my source table as given below i.e customer.
\nHow can i get the required output as shown using sql (oracle or mysql)
\ncustomer :
\n customer id Purchase_id cashback \n 123 abc111 5\n 123 abc112 5\n 123 abc113 2\n 345 abc311 0\n 345 abc312 2 \n 678 abc611 4 \n 678 abc612 3 \n 678 abc613 5 \n
\nOutput Needed:
\n ID purchare_id_1 purchare_id_2 purchare_id_3 cashback_1 cashback_2 cashback_3 \n 123 abc111 abc112 abc113 5 5 2\n 345 abc311 abc312 0 2 \n 678 abc611 abc612 abc613 4 3 5 \n
\nDML and DDL:
\ncreate table cust_table (\ncustomer_id int, Purchase_id varchar(100), cashback int\n);\n\ninsert into cust_table values\n (123 , 'abc111' , 5),\n (123 , 'abc112' , 5),\n (123 , 'abc113' , 2),\n ( 345 , 'abc311' , 0),\n (345 , 'abc312' , 2),\n (678 , 'abc611' , 4),\n (678 , 'abc612' , 3),\n (678 , 'abc613' , 5);\n \n commit;\n
\nPS:\nData might be not static, it can change.
\n"},{"tags":["java","arrays","char"],"comments":[{"owner":{"reputation":430,"user_id":2587373,"user_type":"registered","accept_rate":75,"profile_image":"https://i.stack.imgur.com/J1TaD.jpg?s=128&g=1","display_name":"T. Sar","link":"https://stackoverflow.com/users/2587373/t-sar"},"edited":false,"score":0,"creation_date":1623259204,"post_id":67908687,"comment_id":120030624,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":691,"user_id":9901515,"user_type":"registered","profile_image":"https://i.stack.imgur.com/sASPI.png?s=128&g=1","display_name":"csalmhof","link":"https://stackoverflow.com/users/9901515/csalmhof"},"is_accepted":false,"score":2,"last_activity_date":1623259292,"last_edit_date":1623259292,"creation_date":1623258600,"answer_id":67908772,"question_id":67908687,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":111,"user_id":11057391,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/06497cd1e589611aa9863dc56786060c?s=128&d=identicon&r=PG&f=1","display_name":"Saravanan","link":"https://stackoverflow.com/users/11057391/saravanan"},"is_accepted":false,"score":1,"last_activity_date":1623258759,"creation_date":1623258759,"answer_id":67908819,"question_id":67908687,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":80,"user_id":15156924,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/99f9cac5ba5ba23f9da2125bb308b70a?s=128&d=identicon&r=PG&f=1","display_name":"Denes Garda","link":"https://stackoverflow.com/users/15156924/denes-garda"},"is_accepted":true,"score":1,"last_activity_date":1623259132,"last_edit_date":1623259132,"creation_date":1623258773,"answer_id":67908824,"question_id":67908687,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":49,"user_id":15393275,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5bb1dc9724fcc8822a160be3fd44d773?s=128&d=identicon&r=PG&f=1","display_name":"Ciro Mertens","link":"https://stackoverflow.com/users/15393275/ciro-mertens"},"is_answered":true,"view_count":20,"accepted_answer_id":67908824,"answer_count":3,"score":0,"last_activity_date":1623259292,"creation_date":1623258207,"last_edit_date":1623259071,"question_id":67908687,"share_link":"https://stackoverflow.com/q/67908687","body_markdown":"I have a char array called data. \r\n\r\nI should write a method that makes it possible to return the array but with a starting point that is an integer variable called beginIndex.\r\n\r\nExample: array contains 'A', 'B', 'C', 'D' and beginIndex = 2. Then it should return 'B', 'C', 'D' (yes the index himself in this case the 2nd letter should be included as well!)\r\n\r\nHow do I do this? Or is it wiser to change it into a String and later change it back into a char array?\r\n","link":"https://stackoverflow.com/questions/67908687/start-a-char-array-from-a-certain-index","title":"start a char array from a certain index","body":"I have a char array called data.
\nI should write a method that makes it possible to return the array but with a starting point that is an integer variable called beginIndex.
\nExample: array contains 'A', 'B', 'C', 'D' and beginIndex = 2. Then it should return 'B', 'C', 'D' (yes the index himself in this case the 2nd letter should be included as well!)
\nHow do I do this? Or is it wiser to change it into a String and later change it back into a char array?
\n"},{"tags":["c#","asp.net-core","signalr","unity-container"],"owner":{"reputation":1,"user_id":16178248,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJw7D1-n5lwZJ9LuOjMOj0uuNo91hdXWJkpGd-aK=k-s128","display_name":"Dhiren Bhatia","link":"https://stackoverflow.com/users/16178248/dhiren-bhatia"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623259290,"creation_date":1623259290,"question_id":67908936,"share_link":"https://stackoverflow.com/q/67908936","body_markdown":"I am migrating my current code which is in .NET framework 4.8 to new .NET Core 5.0.\r\nFollowing is my original Startup.cs and additional file which I use to self host.\r\n\r\n \r\n namespace NHSHub.Core\r\n {\r\n using Owin;\r\n using Microsoft.Owin.Cors;\r\n using Microsoft.Owin.Host.HttpListener;\r\n using Microsoft.AspNet.SignalR;\r\n \r\n using Microsoft.AspNet.SignalR.Transports;\r\n using Unity;\r\n using NHSHub.CMS;\r\n \r\n using System.Net;\r\n \r\n public class Startup\r\n {\r\n public void Configuration(IAppBuilder app)\r\n {\r\n var container = new UnityContainer();\r\n var unityConfiguration = new UnityConfiguration();\r\n unityConfiguration.RegisterTypes(container);\r\n \r\n GlobalHost.DependencyResolver = new UnityDependencyResolver(container);\r\n \r\n GlobalHost.HubPipeline.AddModule(new SessionIdCheckModule());\r\n \r\n app.UseCors(new CorsOptions\r\n {\r\n PolicyProvider = new WildcardCorsPolicyProvider()\r\n });\r\n \r\n var listener = (HttpListener)app.Properties[typeof(HttpListener).FullName];\r\n listener.AuthenticationSchemes = AuthenticationSchemes.Ntlm | AuthenticationSchemes.Negotiate;\r\n \r\n //Throttling of http.sys to prevent too many requests being accepted at once.\r\n var maxAccepts = 25;\r\n var maxRequests = 25;\r\n var queueLimit = 25;\r\n var owinListener = (OwinHttpListener)app.Properties[typeof(OwinHttpListener).FullName];\r\n owinListener.SetRequestProcessingLimits(maxAccepts, maxRequests);\r\n owinListener.SetRequestQueueLimit(queueLimit);\r\n \r\n TurnOffWebSocket(GlobalHost.DependencyResolver);\r\n \r\n app.MapSignalR();\r\n }\r\n \r\n //Have to use Ajax long polling as the transport, to get around mixed content blocking in browsers.\r\n public void TurnOffWebSocket(IDependencyResolver resolver)\r\n {\r\n var transportManager = resolver.Resolve<ITransportManager>() as TransportManager;\r\n transportManager.Remove("webSockets");\r\n transportManager.Remove("serverSentEvents");\r\n transportManager.Remove("foreverFrame");\r\n }\r\n }}\r\n\r\nand Other file\r\n\r\n public class ServerStarter : IServerStarter\r\n {\r\n private static readonly Logger Logger = LogManager.GetCurrentClassLogger();\r\n private IDisposable _signalR;\r\n private readonly object _lockObject = new object();\r\n private bool _started = false;\r\n private string UrlAclPrefix = "http://127.0.0.1:";\r\n private ServerSettings _settings = null;\r\n\r\n public void StartServer()\r\n {\r\n Logger.Debug("StartServer()");\r\n\r\n try\r\n {\r\n lock (_lockObject) //Necessary check in case 2 threadpool threads call this method in immediate succession.\r\n {\r\n if (_started == false) //Necessary check to see if webapp is already started. (Can't check if _signalR is null here - doesn't work in locking / unlocking scenarios.)\r\n {\r\n\r\n Logger.Info("Initializing Hub Core.");\r\n\r\n //Needed to find hubs in separate projects...\r\n AppDomain.CurrentDomain.Load(typeof(TicketApiHub).Assembly.FullName);\r\n AppDomain.CurrentDomain.Load(typeof(CmsHub).Assembly.FullName);\r\n\r\n ListenToPort();\r\n\r\n Logger.Info($"Started listening for connections on '{UrlAclPrefix + _settings?.PortNo + "/"}'.");\r\n _started = true;\r\n }\r\n }\r\n }\r\n catch (Exception ex)\r\n {\r\n Logger.Info($"WebApp.Start failed. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\r\n MessageBox.Show("Application failed to start. Please see system administrator.", "NHS Credential Management", MessageBoxButtons.OK, MessageBoxIcon.Error);\r\n Application.Exit();\r\n }\r\n }\r\n\r\n //This method can be called by multiple threadpool threads at the same time.\r\n public void StopServer()\r\n {\r\n Logger.Debug("StopServer()");\r\n\r\n lock (_lockObject)\r\n {\r\n if (_signalR != null)\r\n {\r\n Logger.Debug("Stop listening on the port()");\r\n ReleasePortNumber();\r\n _signalR.Dispose();\r\n _signalR = null;\r\n _started = false;\r\n }\r\n }\r\n }\r\n\r\n // Request to release the port number from the NHS Port Service using the client proxy.\r\n private void ReleasePortNumber()\r\n {\r\n Logger.Debug("ReleasePortNumber()");\r\n\r\n try\r\n {\r\n Logger.Info("Releasing port number from NHS Port Service");\r\n var proxy = new ProxyClient();\r\n proxy.DeAllocatePortNumber();\r\n }\r\n catch (FaultException ex)\r\n {\r\n Logger.Info($"Port number release failed from NHS Port Service. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\r\n }\r\n catch (Exception ex)\r\n {\r\n Logger.Info($"Port number release failed from NHS Port Service. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\r\n }\r\n }\r\n\r\n //This should always work first time unless there's a very unusual circumstance where PRS assigns a port number and then it is taken \r\n //by something else before NHS Credential Management gets chance to start.\r\n //In that circumstance, loop and get another port from PRS.\r\n //Keep looping until successfully started. (In theory, if it gets through the entire range of ports in PRS and none work, \r\n //then you'll get a NoPortNumberAvailable exception and then put up a message saying NHS Credential Management failed to start. This should never happen though.)\r\n private void ListenToPort()\r\n {\r\n var response = false;\r\n\r\n while (!response)\r\n {\r\n try\r\n {\r\n var portNumber = GetPortNumber();\r\n var url = UrlAclPrefix + portNumber + "/";\r\n _signalR = WebApp.Start<Startup>(url);\r\n response = true;\r\n }\r\n catch (FaultException ex)\r\n {\r\n if (ex.Code == PRSExceptions.ServiceNotAvailable || ex.Code == PRSExceptions.NoPortNumberAvailable)\r\n {\r\n //Nothing we can do if PRS is down - just throw exception and put up message saying failed to start NHS Credential Management.\r\n throw;\r\n }\r\n }\r\n catch (Exception ex)\r\n {\r\n //If it is a TargetInvocationException - keep looping and trying again.\r\n //Should only get a TargetInvocationException if the port is in use by something else.\r\n //If PRS is working properly, this would only happen if the port has started being used by something else in the very short period\r\n //of time since PRS assigned this port to this session.\r\n //In that rare circumstance, loop and get a different port number from PRS, and try again to start NHS Credential Management.\r\n\r\n //If it is any other exception, throw it and put up a message saying failed to start NHS Credential Management.\r\n if (!CatchTargetInvocationException(ex))\r\n {\r\n throw;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Request the port number from the NHS Port Service using a client proxy. Client proxy returns the port number which is available from the configured range.\r\n // Once the port number is received, the NHSHub will start listening on that port.\r\n public int GetPortNumber()\r\n {\r\n Logger.Debug("GetPortNumber()");\r\n\r\n try\r\n {\r\n Logger.Info("Getting the port number from the NHS Port Service");\r\n var proxy = new ProxyClient();\r\n var portNo = proxy.GetPortNumber();\r\n Logger.Info($"Port no. received from the NHS Port Service {portNo}");\r\n _settings = new ServerSettings();\r\n _settings.PortNo = Convert.ToString(portNo);\r\n\r\n return portNo;\r\n }\r\n catch (FaultException ex)\r\n {\r\n Logger.Info($"Getting Port Number from NHS Port Service failed. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\r\n throw;\r\n }\r\n catch (Exception ex)\r\n {\r\n Logger.Info($"Getting Port Number from NHS Port Service failed. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\r\n throw;\r\n }\r\n }\r\n\r\n private bool CatchTargetInvocationException(Exception ex)\r\n {\r\n return (ex is TargetInvocationException && ex.InnerException.Message.Contains("Failed to listen on prefix") &&\r\n ex.InnerException.Message.Contains("because it conflicts with an existing registration on the machine"));\r\n }\r\n}}\r\n\r\n\r\n\r\n\r\n\r\n\r\nCan anyone suggest on following.\r\n 1. What is the replacement of Globalhost.Dependency resolver?\r\n 2. I want to keep using Unity for DI and not in build DI of asp.net core. How can I achieve that ?\r\n \r\n\r\n","link":"https://stackoverflow.com/questions/67908936/replace-globalhost-dependency-resolver-in-the-new-asp-net-core-signalr","title":"Replace Globalhost.Dependency resolver in the new Asp.net Core SignalR","body":"I am migrating my current code which is in .NET framework 4.8 to new .NET Core 5.0.\nFollowing is my original Startup.cs and additional file which I use to self host.
\nnamespace NHSHub.Core\n{\n using Owin;\n using Microsoft.Owin.Cors;\n using Microsoft.Owin.Host.HttpListener;\n using Microsoft.AspNet.SignalR;\n\n using Microsoft.AspNet.SignalR.Transports;\n using Unity;\n using NHSHub.CMS;\n\n using System.Net;\n\n public class Startup\n {\n public void Configuration(IAppBuilder app)\n {\n var container = new UnityContainer();\n var unityConfiguration = new UnityConfiguration();\n unityConfiguration.RegisterTypes(container);\n\n GlobalHost.DependencyResolver = new UnityDependencyResolver(container);\n\n GlobalHost.HubPipeline.AddModule(new SessionIdCheckModule());\n\n app.UseCors(new CorsOptions\n {\n PolicyProvider = new WildcardCorsPolicyProvider()\n });\n\n var listener = (HttpListener)app.Properties[typeof(HttpListener).FullName];\n listener.AuthenticationSchemes = AuthenticationSchemes.Ntlm | AuthenticationSchemes.Negotiate;\n\n //Throttling of http.sys to prevent too many requests being accepted at once.\n var maxAccepts = 25;\n var maxRequests = 25;\n var queueLimit = 25;\n var owinListener = (OwinHttpListener)app.Properties[typeof(OwinHttpListener).FullName];\n owinListener.SetRequestProcessingLimits(maxAccepts, maxRequests);\n owinListener.SetRequestQueueLimit(queueLimit);\n\n TurnOffWebSocket(GlobalHost.DependencyResolver);\n\n app.MapSignalR();\n }\n\n //Have to use Ajax long polling as the transport, to get around mixed content blocking in browsers.\n public void TurnOffWebSocket(IDependencyResolver resolver)\n {\n var transportManager = resolver.Resolve<ITransportManager>() as TransportManager;\n transportManager.Remove("webSockets");\n transportManager.Remove("serverSentEvents");\n transportManager.Remove("foreverFrame");\n }\n }}\n
\nand Other file
\npublic class ServerStarter : IServerStarter\n{\n private static readonly Logger Logger = LogManager.GetCurrentClassLogger();\n private IDisposable _signalR;\n private readonly object _lockObject = new object();\n private bool _started = false;\n private string UrlAclPrefix = "http://127.0.0.1:";\n private ServerSettings _settings = null;\n\npublic void StartServer()\n{\n Logger.Debug("StartServer()");\n\n try\n {\n lock (_lockObject) //Necessary check in case 2 threadpool threads call this method in immediate succession.\n {\n if (_started == false) //Necessary check to see if webapp is already started. (Can't check if _signalR is null here - doesn't work in locking / unlocking scenarios.)\n {\n\n Logger.Info("Initializing Hub Core.");\n\n //Needed to find hubs in separate projects...\n AppDomain.CurrentDomain.Load(typeof(TicketApiHub).Assembly.FullName);\n AppDomain.CurrentDomain.Load(typeof(CmsHub).Assembly.FullName);\n\n ListenToPort();\n\n Logger.Info($"Started listening for connections on '{UrlAclPrefix + _settings?.PortNo + "/"}'.");\n _started = true;\n }\n }\n }\n catch (Exception ex)\n {\n Logger.Info($"WebApp.Start failed. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\n MessageBox.Show("Application failed to start. Please see system administrator.", "NHS Credential Management", MessageBoxButtons.OK, MessageBoxIcon.Error);\n Application.Exit();\n }\n}\n\n//This method can be called by multiple threadpool threads at the same time.\npublic void StopServer()\n{\n Logger.Debug("StopServer()");\n\n lock (_lockObject)\n {\n if (_signalR != null)\n {\n Logger.Debug("Stop listening on the port()");\n ReleasePortNumber();\n _signalR.Dispose();\n _signalR = null;\n _started = false;\n }\n }\n}\n\n// Request to release the port number from the NHS Port Service using the client proxy.\nprivate void ReleasePortNumber()\n{\n Logger.Debug("ReleasePortNumber()");\n\n try\n {\n Logger.Info("Releasing port number from NHS Port Service");\n var proxy = new ProxyClient();\n proxy.DeAllocatePortNumber();\n }\n catch (FaultException ex)\n {\n Logger.Info($"Port number release failed from NHS Port Service. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\n }\n catch (Exception ex)\n {\n Logger.Info($"Port number release failed from NHS Port Service. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\n }\n}\n\n//This should always work first time unless there's a very unusual circumstance where PRS assigns a port number and then it is taken \n//by something else before NHS Credential Management gets chance to start.\n//In that circumstance, loop and get another port from PRS.\n//Keep looping until successfully started. (In theory, if it gets through the entire range of ports in PRS and none work, \n//then you'll get a NoPortNumberAvailable exception and then put up a message saying NHS Credential Management failed to start. This should never happen though.)\nprivate void ListenToPort()\n{\n var response = false;\n\n while (!response)\n {\n try\n {\n var portNumber = GetPortNumber();\n var url = UrlAclPrefix + portNumber + "/";\n _signalR = WebApp.Start<Startup>(url);\n response = true;\n }\n catch (FaultException ex)\n {\n if (ex.Code == PRSExceptions.ServiceNotAvailable || ex.Code == PRSExceptions.NoPortNumberAvailable)\n {\n //Nothing we can do if PRS is down - just throw exception and put up message saying failed to start NHS Credential Management.\n throw;\n }\n }\n catch (Exception ex)\n {\n //If it is a TargetInvocationException - keep looping and trying again.\n //Should only get a TargetInvocationException if the port is in use by something else.\n //If PRS is working properly, this would only happen if the port has started being used by something else in the very short period\n //of time since PRS assigned this port to this session.\n //In that rare circumstance, loop and get a different port number from PRS, and try again to start NHS Credential Management.\n\n //If it is any other exception, throw it and put up a message saying failed to start NHS Credential Management.\n if (!CatchTargetInvocationException(ex))\n {\n throw;\n }\n }\n }\n}\n\n// Request the port number from the NHS Port Service using a client proxy. Client proxy returns the port number which is available from the configured range.\n// Once the port number is received, the NHSHub will start listening on that port.\npublic int GetPortNumber()\n{\n Logger.Debug("GetPortNumber()");\n\n try\n {\n Logger.Info("Getting the port number from the NHS Port Service");\n var proxy = new ProxyClient();\n var portNo = proxy.GetPortNumber();\n Logger.Info($"Port no. received from the NHS Port Service {portNo}");\n _settings = new ServerSettings();\n _settings.PortNo = Convert.ToString(portNo);\n\n return portNo;\n }\n catch (FaultException ex)\n {\n Logger.Info($"Getting Port Number from NHS Port Service failed. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\n throw;\n }\n catch (Exception ex)\n {\n Logger.Info($"Getting Port Number from NHS Port Service failed. Error description is: {ex?.Message}. InnerException Message is: {ex?.InnerException?.Message}");\n throw;\n }\n}\n\nprivate bool CatchTargetInvocationException(Exception ex)\n{\n return (ex is TargetInvocationException && ex.InnerException.Message.Contains("Failed to listen on prefix") &&\n ex.InnerException.Message.Contains("because it conflicts with an existing registration on the machine"));\n}\n
\n}}
\nCan anyone suggest on following.
\nIn my SQLite database, I have a query that selects records where a string is present in one of several columns - i.e with the following
\nColumn1 | \nColumn2 | \n
---|---|
String | \nStringString | \n
I have the following query:
\nWHERE Column1 LIKE 'String' OR Column2 LIKE '%String%'\n
\nHow can I make it so that the results are ordered based on which column they matched with? I.e. put items that matched from Column1 before items that were matched with Column2, or vice versa?
\n"},{"tags":["odoo","odoo-13"],"comments":[{"owner":{"reputation":11147,"user_id":3146213,"user_type":"registered","profile_image":"https://i.stack.imgur.com/IbhfG.jpg?s=128&g=1","display_name":"CZoellner","link":"https://stackoverflow.com/users/3146213/czoellner"},"edited":false,"score":0,"creation_date":1623175758,"post_id":67892116,"comment_id":120002256,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":309,"user_id":14012215,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1d23d92690c36b86e57f1f829bff0f8f?s=128&d=identicon&r=PG&f=1","display_name":"hedgethenight","link":"https://stackoverflow.com/users/14012215/hedgethenight"},"reply_to_user":{"reputation":11147,"user_id":3146213,"user_type":"registered","profile_image":"https://i.stack.imgur.com/IbhfG.jpg?s=128&g=1","display_name":"CZoellner","link":"https://stackoverflow.com/users/3146213/czoellner"},"edited":false,"score":0,"creation_date":1623176411,"post_id":67892116,"comment_id":120002529,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":11147,"user_id":3146213,"user_type":"registered","profile_image":"https://i.stack.imgur.com/IbhfG.jpg?s=128&g=1","display_name":"CZoellner","link":"https://stackoverflow.com/users/3146213/czoellner"},"edited":false,"score":0,"creation_date":1623223537,"post_id":67892116,"comment_id":120014229,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":309,"user_id":14012215,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1d23d92690c36b86e57f1f829bff0f8f?s=128&d=identicon&r=PG&f=1","display_name":"hedgethenight","link":"https://stackoverflow.com/users/14012215/hedgethenight"},"is_accepted":false,"score":0,"last_activity_date":1623259287,"creation_date":1623259287,"answer_id":67908934,"question_id":67892116,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":309,"user_id":14012215,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1d23d92690c36b86e57f1f829bff0f8f?s=128&d=identicon&r=PG&f=1","display_name":"hedgethenight","link":"https://stackoverflow.com/users/14012215/hedgethenight"},"is_answered":false,"view_count":16,"answer_count":1,"score":0,"last_activity_date":1623259287,"creation_date":1623174339,"question_id":67892116,"share_link":"https://stackoverflow.com/q/67892116","body_markdown":"I am having some issues with the Odoo scheduler. I am running Odoo 13. \r\n\r\n\r\n actions = models.execute_kw(db, uid, password, 'ir.cron', 'search', [[['name', '=', 'Procurement: run scheduler']]])\r\n print(actions)\r\n \r\n schedule = models.execute_kw(db, uid, password, 'ir.cron', 'method_direct_trigger', [actions])\r\n print(schedule )\r\n\r\nI have attempted to change my config multiple times, increasing the time-outs. But the issue still keeps happening. \r\n\r\nThe error is \r\n\r\n xmlrpc.client.ProtocolError: <ProtocolError for ip.adress/xmlrpc/2/object: 504 Gateway Time-out>","link":"https://stackoverflow.com/questions/67892116/how-to-prevent-odoo-scheduler-from-timing-out","title":"How to prevent Odoo scheduler from timing out?","body":"I am having some issues with the Odoo scheduler. I am running Odoo 13.
\nactions = models.execute_kw(db, uid, password, 'ir.cron', 'search', [[['name', '=', 'Procurement: run scheduler']]])\nprint(actions)\n\nschedule = models.execute_kw(db, uid, password, 'ir.cron', 'method_direct_trigger', [actions])\nprint(schedule )\n
\nI have attempted to change my config multiple times, increasing the time-outs. But the issue still keeps happening.
\nThe error is
\nxmlrpc.client.ProtocolError: <ProtocolError for ip.adress/xmlrpc/2/object: 504 Gateway Time-out>\n
\n"},{"tags":["swift","uitableview","dynamic","uicollectionviewcell","collectionview"],"owner":{"reputation":11,"user_id":2365952,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ec5faf624a22319099a8acfd794d4e96?s=128&d=identicon&r=PG","display_name":"Aparna","link":"https://stackoverflow.com/users/2365952/aparna"},"is_answered":false,"view_count":16,"answer_count":0,"score":0,"last_activity_date":1623259280,"creation_date":1623057193,"last_edit_date":1623259280,"question_id":67868933,"share_link":"https://stackoverflow.com/q/67868933","body_markdown":"I have a collection view inside the table view cell, both are dynamic and collection view cells size are also dynamically based on label text size. When I land on that screen the collection view cell frame is not proper. And it becomes correct only after reload. I am using a custom layout for the collection view cell frames. ","link":"https://stackoverflow.com/questions/67868933/collectionview-dynamic-cell-size-proper-only-after-reload","title":"Collectionview dynamic cell size proper only after reload","body":"I have a collection view inside the table view cell, both are dynamic and collection view cells size are also dynamically based on label text size. When I land on that screen the collection view cell frame is not proper. And it becomes correct only after reload. I am using a custom layout for the collection view cell frames.
\n"},{"tags":["c#","image","unity3d"],"comments":[{"owner":{"reputation":54,"user_id":11131159,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-_i-WsOTCCvQ/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3reu5zJqQeeEVeVRz5C33Ksjur1WPw/mo/photo.jpg?sz=128","display_name":"Jahan","link":"https://stackoverflow.com/users/11131159/jahan"},"edited":false,"score":0,"creation_date":1623256341,"post_id":67908196,"comment_id":120029454,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":54,"user_id":11131159,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-_i-WsOTCCvQ/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3reu5zJqQeeEVeVRz5C33Ksjur1WPw/mo/photo.jpg?sz=128","display_name":"Jahan","link":"https://stackoverflow.com/users/11131159/jahan"},"edited":false,"score":0,"creation_date":1623256489,"post_id":67908196,"comment_id":120029534,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":731,"user_id":1679220,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/8c48d48053758cff69118a29655c3675?s=128&d=identicon&r=PG","display_name":"hijinxbassist","link":"https://stackoverflow.com/users/1679220/hijinxbassist"},"edited":false,"score":1,"creation_date":1623256679,"post_id":67908196,"comment_id":120029629,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":54,"user_id":11131159,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-_i-WsOTCCvQ/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3reu5zJqQeeEVeVRz5C33Ksjur1WPw/mo/photo.jpg?sz=128","display_name":"Jahan","link":"https://stackoverflow.com/users/11131159/jahan"},"edited":false,"score":0,"creation_date":1623256777,"post_id":67908196,"comment_id":120029674,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":731,"user_id":1679220,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/8c48d48053758cff69118a29655c3675?s=128&d=identicon&r=PG","display_name":"hijinxbassist","link":"https://stackoverflow.com/users/1679220/hijinxbassist"},"edited":false,"score":0,"creation_date":1623256781,"post_id":67908196,"comment_id":120029678,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16177838,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Gho0yBawmPfIte9U6-A4YybtrStO8yWDcgZ7uetBg=k-s128","display_name":"Jorara99","link":"https://stackoverflow.com/users/16177838/jorara99"},"is_answered":false,"view_count":11,"answer_count":0,"score":-1,"last_activity_date":1623259280,"creation_date":1623256169,"last_edit_date":1623259280,"question_id":67908196,"share_link":"https://stackoverflow.com/q/67908196","body_markdown":"i am building a quiz program and i want to adding the image in the options\r\n\r\nhere is my code\r\n \r\n public class QuizManager : MonoBehaviour{\r\n public List<QuestionAndAnswer> QnA;\r\n public GameObject[] options;\r\n public int currentQuestion;\r\n public Text QuestionTxt;\r\n public Image QuestionImg;}\r\n\r\n\r\n\r\n void SetAnswers()\r\n {\r\n for (int i = 0; i < options.Length; i++)\r\n {\r\n options[i].GetComponent<Answer>().isCorrect = false;\r\n options[i].transform.GetChild(0).GetComponent<Image>().Image = QnA[currentQuestion].Answers[i];\r\n\r\n if(QnA[currentQuestion].CorrectAnswer == i+1)\r\n {\r\n options[i].GetComponent<Answer>().isCorrect = true;\r\n }\r\n\r\n }\r\n }\r\n\r\n\r\nAnd i got this error\r\n\r\nImage' does not contain a definition for 'Image' and no accessible extension method 'Image' accepting a first argument of type 'Image' could be found (are you missing a using directive or an assembly reference?)\r\n\r\nplease help me :D","link":"https://stackoverflow.com/questions/67908196/how-do-i-add-image-in-unity","title":"How do i add image in unity","body":"i am building a quiz program and i want to adding the image in the options
\nhere is my code
\n public class QuizManager : MonoBehaviour{\n public List<QuestionAndAnswer> QnA;\n public GameObject[] options;\n public int currentQuestion;\n public Text QuestionTxt;\n public Image QuestionImg;}\n\n\n\nvoid SetAnswers()\n {\n for (int i = 0; i < options.Length; i++)\n {\n options[i].GetComponent<Answer>().isCorrect = false;\n options[i].transform.GetChild(0).GetComponent<Image>().Image = QnA[currentQuestion].Answers[i];\n\n if(QnA[currentQuestion].CorrectAnswer == i+1)\n {\n options[i].GetComponent<Answer>().isCorrect = true;\n }\n\n }\n }\n
\nAnd i got this error
\nImage' does not contain a definition for 'Image' and no accessible extension method 'Image' accepting a first argument of type 'Image' could be found (are you missing a using directive or an assembly reference?)
\nplease help me :D
\n"},{"tags":["assembly","x86"],"owner":{"reputation":1,"user_id":15886177,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a576a4dfa1cd04f74c5afd0f8e223dbf?s=128&d=identicon&r=PG&f=1","display_name":"Amit Lior ","link":"https://stackoverflow.com/users/15886177/amit-lior"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623259279,"creation_date":1623258653,"last_edit_date":1623259279,"question_id":67908785,"share_link":"https://stackoverflow.com/q/67908785","body_markdown":"In the proc section, before the start but in the code segment I wrote 2 procs, 'proc CheckYInput' and proc 'CheckXInput', which are supposed to find out which button I pressed, compare it to the numbered cell and if it is one of the 8 random cell, print over it. \r\nIt's basically a very bad 'mine sweeper'\r\n\r\n IDEAL\r\n MODEL small\r\n STACK 100h\r\n DATASEG\r\n \r\n \r\n ; random \r\n Clock equ es:6Ch\r\n \r\n \r\n ; after change \r\n \r\n \r\n \r\n ;for opening screen\r\n HTS DB "mine sweeper"\r\n PAKTC DB "[Press space to continue]"\r\n \r\n \r\n empty DB " "\r\n \r\n \txStart dw 1 ; x coordinate of line start\r\n \r\n yStart dw 0 ; y coordinate of line start\r\n \r\n length1 dw 1278 ; length1 of line1\r\n \r\n \tyStart2 dw 25 ; y coordinate of line2 start\r\n \t\r\n \tyStart3 dw 50 ; y coordinate of line3 start\r\n \r\n \tyStart4 dw 75 ; y coordinate of line4 start\r\n \r\n \tyStart5 dw 100 ; y coordinate of line5 start\r\n \r\n \tyStart6 dw 125 ; y coordinate of line6 start\r\n \r\n \tyStart7 dw 150 ; y coordinate of line7 start\r\n \r\n \tyStart8 dw 175 ; y coordinate of line8 start\r\n \t\r\n \t;for random\r\n \r\n Random1X db (?)\r\n Random2X db (?)\r\n Random3X db (?)\r\n Random4X db (?)\r\n Random5X db (?)\r\n Random6X db (?)\r\n Random7X db (?)\r\n Random8X db (?)\r\n Random1Y db (?)\r\n Random2Y db (?)\r\n Random3Y db (?)\r\n Random4Y db (?)\r\n Random5Y db (?)\r\n Random6Y db (?)\t\r\n Random7Y db (?)\r\n Random8Y db (?) \r\n \r\n CODESEG\r\n \r\n ;======================================\r\n ;=============cursor mode==============\r\n ;======================================\r\n \r\n \r\n \r\n proc ScreenClear \r\n \tmov ax,0600h \r\n mov bh,99h ;color of backround \r\n mov cx,0000h ;start position\r\n mov dx,184fh ;end position \r\n int 10h ;screenprint \r\n \t\r\n \t\r\n \tret\r\n endp ScreenClear\t\r\n \r\n \r\n proc modulo\r\n \r\n \r\n \tmov ax, 40h\r\n mov es, ax\r\n mov cx, 1\r\n mov bx, 0\r\n \r\n mov ax, [Clock] ;read timer counter\r\n mov ah, [byte cs:bx] ;read one byte from memory\r\n xor al, ah ;xor memory and counter\r\n and al, 00000101b ;leave result between 0-7\r\n \t\r\n ret \r\n endp modulo \r\n \r\n proc modulo2\r\n \r\n \tmov ax, 40h\r\n mov es, ax\r\n mov cx, 1\r\n mov bx, 0\r\n \r\n mov ax, [Clock] ;read timer counter\r\n mov ah, [byte cs:bx] ;read one byte from memory\r\n xor al, ah ;xor memory and counter\r\n and al, 00000100b ;leave result between 0-4\r\n ret\t\r\n endp modulo2\r\n \r\n proc CheckXInput\r\n IdkLOOP:\r\n \tmov ah, 1h\r\n \tint 21h\r\n \tcmp al,31h\r\n \tje RandomLoopX\r\n \tcmp al,32h\r\n \tje RandomLoopX\r\n \tcmp al,33h \r\n \tje RandomLoopX\r\n \tcmp al,34h \r\n \tje RandomLoopX\r\n \tcmp al,35h\r\n \tje RandomLoopX\r\n \tcmp al,36h\r\n \tje RandomLoopX\r\n \tcmp al,37h\r\n \tje RandomLoopX\r\n \tcmp al,38h\r\n \tje RandomLoopX\r\n \tjmp IdkLOOP; loops untill i hit left click \r\n \t\r\n \t\r\n RandomLoopX: ; starts a loop that checks each Y cordinate \r\n \tsub al,31h\r\n \tcmp al,[Random1X]\r\n \tje RandomLOOPX2\r\n \t\r\n \tcmp al,[Random2X]\r\n \tje RandomLoopX2\r\n \t\r\n \tcmp al,[Random3X]\r\n \tje RandomLoopX2\r\n \t\r\n \tcmp al,[Random4X]\r\n \tje RandomLoopX2\r\n \t\r\n \tcmp al,[Random5X]\r\n \tje RandomLoopX2\r\n \t\r\n \tcmp al,[Random6X]\r\n \tje RandomLoopX2\r\n \t\r\n \tcmp al,[Random7X]\r\n \tje RandomLoopX2\r\n \t\r\n \tcmp al,[Random8X]\r\n \tje RandomLoopX2\r\n \t\r\n \tjmp IdkLOOP\r\n \t\r\n RandomLoopX2:\r\n \tinc al\r\n \tdec al\r\n \tmov bl, 64\r\n \tmul bl ; mul 64 by the number of the cell and stores the answer in bx\r\n \tmov ax,bx ; moves the number of the cell in pixels to ax\r\n \tadd bx,64 ; the end of the cell in pixels \r\n \r\n \tjmp RandomLoopX3\r\n RandomLoopX3:\r\n \tmov bh,55h ;color of backround \r\n mov dx,ax\r\n \tdec bx\r\n int 10h ;screenprint\r\n \tcmp bx,ax\r\n \tja RandomLoopX3\r\n \t\r\n ret \r\n \tendp CheckXInput\r\n \t\r\n \t\r\n \t\r\n \tproc CheckYInput \r\n IdkLOOP2:\r\n \tmov ah, 1h\r\n \tint 21h\r\n \tcmp al,31h\r\n \tje RandomLoopY\r\n \tcmp al,32h\r\n \tje RandomLoopY\r\n \tcmp al,33h \r\n \tje RandomLoopY\r\n \tcmp al,34h \r\n \tje RandomLoopY\r\n \tcmp al,35h\r\n \tje RandomLoopY\r\n \tjmp IdkLOOP2\r\n \t\r\n \tRandomLoopY: ; starts a loop that checks each Y cordinate \r\n \tsub al,31h\r\n \tcmp al,[Random1Y]\r\n \tje RandomLOOPY2\r\n \t\r\n \tcmp al,[Random2Y]\r\n \tje RandomLoopY2\r\n \t\r\n \tcmp al,[Random3Y]\r\n \tje RandomLoopY2\r\n \t\r\n \tcmp al,[Random4Y]\r\n \tje RandomLoopY2\r\n \t\r\n \tcmp al,[Random5Y]\r\n \tje RandomLoopY2\r\n \t\r\n \tcmp al,[Random6Y]\r\n \tje RandomLoopY2\r\n \t\r\n \tcmp al,[Random7Y]\r\n \tje RandomLoopY2\r\n \t\r\n \tcmp al,[Random8Y]\r\n \tje RandomLoopY2\r\n \t\r\n \tjmp IdkLOOP2\r\n \t\r\n \t\r\n RandomLoopY2: ; starts a loop that checks each x cordinate\r\n \tmov cl,al \r\n \tmov bl, 25\r\n \tmul bl\r\n \tmov ax,bx\r\n \tadd bx,25\r\n \tjmp RamdomLoopY3\r\n RamdomLoopY3:\r\n \tmov bh,55h ;color of backround \r\n mov dx,ax ; start \r\n \tdec bx\r\n int 10h ;screenprint\r\n \tcmp bx,ax ;checks if reached end, if not it will keep printing \r\n \tja RamdomLoopY3\r\n ret \r\n \tendp CheckYInput\r\n \t\r\n proc callmodulo \r\n \tcall modulo \r\n mov [Random1X],al\r\n call modulo\r\n mov [Random2X],al\r\n call modulo\r\n mov [Random3X],al\r\n call modulo\r\n mov [Random4X],al\r\n call modulo\r\n mov [Random5X],al\r\n call modulo\r\n mov [Random6X],al\r\n call modulo\r\n mov [Random7X],al\r\n call modulo\r\n mov [Random8X],al\r\n \r\n ret\r\n endp callmodulo\r\n \r\n proc callmodulo2\r\n call modulo2\r\n mov [Random1Y],al\r\n call modulo2\r\n mov [Random2Y],al\r\n call modulo2\r\n mov [Random3Y],al\r\n call modulo2\r\n mov [Random4Y],al\r\n call modulo2\r\n mov [Random5Y],al\r\n call modulo2\r\n mov [Random6Y],al\r\n call modulo2\r\n mov [Random7Y],al\r\n call modulo2\r\n mov [Random8Y],al\r\n \r\n \r\n ret\r\n \r\n endp callmodulo2\r\n \t\r\n \t\r\n ;===================================\r\n ;============start=================\r\n ;===================================\r\n \r\n \r\n start:\r\n \tmov ax, @data\r\n \tmov ds, ax\r\n \t\r\n \t; Graphic mode\r\n \tmov ax, 13h\r\n \tint 10h\r\n \t\r\n \r\n \t\r\n \t\r\n \t;first text for first screen \r\n \tmov al, 1 ;color \r\n \tmov bh, 0 \r\n \tmov bl, 15 ;brightness \r\n \tmov cx, 12 ;PAKTC1end - offset PAKTC ; calculate message number of letters plus spaces, ect... \r\n \tmov dl, 11 ;position start X\r\n \tmov dh, 10 ;position start Y \r\n \tpush ds \r\n \tpop es\r\n \tmov bp, offset HTS\r\n \tmov ah, 13h ;graphic font \r\n \tint 10h ; print\r\n \r\n \t\r\n \t;second text for first screen\r\n \tmov al, 1 ; color \r\n \tmov bh, 27 \r\n \tmov bl, 15 ; brightness \r\n \tmov cx, 26 ;PAKTC1end - offset PAKTC ; calculate message number of letters plus spaces, ect... \r\n \tmov dl, 7 ; position start X\r\n \tmov dh, 15 ; position start Y \r\n \tpush ds\r\n \tpop es\r\n \tmov bp, offset PAKTC\r\n \tmov ah, 13h\r\n \tint 10h\r\n \t\r\n \t\r\n ;space press\r\n checkTitleSpace: \r\n \tmov ah, 1h\r\n \tint 21h\r\n \tcmp al, 20h ;space ascii\r\n \tjne checkTitleSpace\r\n \t\r\n \tcall ScreenClear ; calls the proc ScreenClear\r\n \r\n \t\r\n \r\n \r\n ;========================================\r\n ;=============after opening==============\r\n ;========================================\r\n \r\n \r\n \t;useless title \r\n \t;space press\r\n \tDraw2:\r\n \tmov ah, 1h\r\n \tint 21h \r\n \tcmp al, 20h ;space ascii \r\n \tjne Draw2 \r\n \t;first draw\r\n \r\n \tmov ah,0h\r\n \tmov al,13h\r\n \tint 10h\r\n \r\n ;The above three lines just switch to 320x200 256-color VGA.\r\n \tmov ax, 0a000h\r\n \tmov es, ax\t\r\n \tmov bx, 0 \r\n loopClear:\r\n \tmov [byte ptr es:bx], 11h\r\n \tinc bx\r\n \tcmp bx, 320 * 200\r\n \tjb loopClear\r\n \t\r\n ;=============================================\t\r\n ;==============lines start here===============\r\n ;============================================= \t\r\n \r\n \tmov cx, [xStart]\r\n add cx, [length1]\r\n \r\n \r\n ; loop from (xStart+length1) to xStart to draw a horizontal line\r\n \r\n LoopStart: \r\n \r\n ; draw a pixel\r\n mov al, 50 ; color\r\n mov dx, [yStart] \r\n mov ah, 0ch ; set sub function value in ah to draw a pixel \r\n int 10h ; and invoke the interrupt \t\t\t\t\t\t \r\n dec cx ; decrement the x coord \r\n cmp cx, [xStart] ; test to see if x coord has reached start value \r\n jae LoopStart ; continue loop if cx >= xStart\r\n \r\n mov dx, [ystart]\r\n add dx, [length1]\r\n \r\n ; loop from (ystart+length1) to ystart and add length1\r\n \r\n LoopStart2:\r\n ; draw a pixel\r\n ; set color in al, x in cx, y in dx\r\n mov al,50 ;color\r\n mov cx, [xStart] \r\n mov ah, 0ch \r\n int 10h\r\n dec dx ; decrement the y coord\r\n cmp dx, [yStart] ; test to see if y coord has reached start value\r\n \r\n jne LoopStart2 ; continue loop if dx >= yStart\t\r\n \r\n \tmov cx, [xStart]\r\n \tadd cx, [length1]\r\n \tLoopStart3:\r\n mov al, 50 ;color \r\n \t\tmov dx, [yStart2] \t\r\n mov ah, 0ch \r\n int 10h \r\n dec cx ; decrement the y coord\r\n cmp cx, [xStart] ; test to see if y coord has reached start value\t\t\r\n \tjne LoopStart3\r\n \r\n \tmov cx, [xStart]\r\n \tadd cx, [length1]\r\n \tLoopStart4:\r\n mov al, 50 ;color \r\n \t\tmov dx, [yStart3]\t\r\n mov ah, 0ch \r\n int 10h \r\n dec cx ; decrement the y coord\r\n cmp cx, [xStart] ; test to see if y coord has reached start value\t\t\r\n \tjne LoopStart4\r\n \r\n \t\r\n \r\n \tmov cx, [xStart]\r\n \tadd cx, [length1]\r\n \tLoopStart5:\r\n mov al, 50 ;color \r\n \t\tmov dx, [yStart4]\t\r\n mov ah, 0ch \r\n int 10h \r\n dec cx ; decrement the y coord\r\n cmp cx, [xStart] ; test to see if y coord has reached start value\t\t\r\n \tjne LoopStart5\r\n \r\n \r\n \tmov cx, [xStart]\r\n \tadd cx, [length1]\r\n \tLoopStart6:\r\n mov al, 50 ;color \r\n \t\tmov dx, [yStart5]\t\r\n mov ah, 0ch \r\n int 10h \r\n dec cx ; decrement the y coord\r\n cmp cx, [xStart] ; test to see if y coord has reached start value\t\t\r\n \tjne LoopStart6\r\n \r\n \r\n \r\n \tmov cx, [xStart]\r\n \tadd cx, [length1]\r\n \tLoopStart7:\r\n mov al, 50 ;color \r\n \t\tmov dx, [yStart6]\t\r\n mov ah, 0ch \r\n int 10h \r\n dec cx ; decrement the y coord\r\n cmp cx, [xStart] ; test to see if y coord has reached start value\t\t\r\n \tjne LoopStart7\r\n \r\n \r\n \tmov cx, [xStart]\r\n \tadd cx, [length1]\r\n \tLoopStart8:\r\n mov al, 50 ;color \r\n \t\tmov dx, [yStart7]\t\r\n mov ah, 0ch \r\n int 10h \r\n dec cx ; decrement the y coord\r\n cmp cx, [xStart] ; test to see if y coord has reached start value\t\t\r\n \tjne LoopStart8\r\n \r\n \r\n \r\n \r\n \tmov cx, [xStart]\r\n \tadd cx, [length1]\r\n \tLoopStart9:\r\n mov al, 50 ;color \r\n \t\tmov dx, [yStart8]\t\r\n mov ah, 0ch \r\n int 10h \r\n dec cx ; decrement the y coord\r\n cmp cx, [xStart] ; test to see if y coord has reached start value\t\t\r\n \tjne LoopStart9\r\n \r\n \r\n \r\n ;===================================================\r\n ;========lines end here (thank god)=================\r\n ;===================================================\r\n \r\n ;==============================\r\n ;=========for random===========\r\n ;==============================\r\n \r\n \r\n \r\n call callmodulo\r\n call callmodulo2\r\n call CheckXInput\r\n call CheckYInput\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \t\r\n \r\n exit:\r\n \tmov ax, 4c00h\r\n \tint 21h\r\n END start \r\n\r\n\r\n\r\nThis is the code, I know I know it's bad. But please help me figure out the problem. \r\n\r\nThank you. \r\n","link":"https://stackoverflow.com/questions/67908785/i-am-trying-to-code-a-game-but-i-ran-into-an-issue-my-print-commands-do-not-wor","title":"I am trying to code a game but I ran into an issue. My print commands do not work, I am sure I wrote it wrong, but I cant find the problem","body":"In the proc section, before the start but in the code segment I wrote 2 procs, 'proc CheckYInput' and proc 'CheckXInput', which are supposed to find out which button I pressed, compare it to the numbered cell and if it is one of the 8 random cell, print over it.\nIt's basically a very bad 'mine sweeper'
\n IDEAL\nMODEL small\nSTACK 100h\nDATASEG\n\n\n; random \nClock equ es:6Ch\n\n\n; after change \n\n\n\n;for opening screen\nHTS DB "mine sweeper"\nPAKTC DB "[Press space to continue]"\n\n\nempty DB " "\n\n xStart dw 1 ; x coordinate of line start\n\n yStart dw 0 ; y coordinate of line start\n\n length1 dw 1278 ; length1 of line1\n \n yStart2 dw 25 ; y coordinate of line2 start\n \n yStart3 dw 50 ; y coordinate of line3 start\n \n yStart4 dw 75 ; y coordinate of line4 start\n\n yStart5 dw 100 ; y coordinate of line5 start\n\n yStart6 dw 125 ; y coordinate of line6 start\n\n yStart7 dw 150 ; y coordinate of line7 start\n\n yStart8 dw 175 ; y coordinate of line8 start\n \n ;for random\n\nRandom1X db (?)\nRandom2X db (?)\nRandom3X db (?)\nRandom4X db (?)\nRandom5X db (?)\nRandom6X db (?)\nRandom7X db (?)\nRandom8X db (?)\nRandom1Y db (?)\nRandom2Y db (?)\nRandom3Y db (?)\nRandom4Y db (?)\nRandom5Y db (?)\nRandom6Y db (?) \nRandom7Y db (?)\nRandom8Y db (?) \n\nCODESEG\n\n;======================================\n;=============cursor mode==============\n;======================================\n\n\n\nproc ScreenClear \n mov ax,0600h \n mov bh,99h ;color of backround \n mov cx,0000h ;start position\n mov dx,184fh ;end position \n int 10h ;screenprint \n \n \n ret\nendp ScreenClear \n\n\nproc modulo\n\n\n mov ax, 40h\n mov es, ax\n mov cx, 1\n mov bx, 0\n\n mov ax, [Clock] ;read timer counter\n mov ah, [byte cs:bx] ;read one byte from memory\n xor al, ah ;xor memory and counter\n and al, 00000101b ;leave result between 0-7\n \nret \nendp modulo \n\nproc modulo2\n\n mov ax, 40h\n mov es, ax\n mov cx, 1\n mov bx, 0\n\n mov ax, [Clock] ;read timer counter\n mov ah, [byte cs:bx] ;read one byte from memory\n xor al, ah ;xor memory and counter\n and al, 00000100b ;leave result between 0-4\nret \nendp modulo2\n\nproc CheckXInput\nIdkLOOP:\n mov ah, 1h\n int 21h\n cmp al,31h\n je RandomLoopX\n cmp al,32h\n je RandomLoopX\n cmp al,33h \n je RandomLoopX\n cmp al,34h \n je RandomLoopX\n cmp al,35h\n je RandomLoopX\n cmp al,36h\n je RandomLoopX\n cmp al,37h\n je RandomLoopX\n cmp al,38h\n je RandomLoopX\n jmp IdkLOOP; loops untill i hit left click \n \n \nRandomLoopX: ; starts a loop that checks each Y cordinate \n sub al,31h\n cmp al,[Random1X]\n je RandomLOOPX2\n \n cmp al,[Random2X]\n je RandomLoopX2\n \n cmp al,[Random3X]\n je RandomLoopX2\n \n cmp al,[Random4X]\n je RandomLoopX2\n \n cmp al,[Random5X]\n je RandomLoopX2\n \n cmp al,[Random6X]\n je RandomLoopX2\n \n cmp al,[Random7X]\n je RandomLoopX2\n \n cmp al,[Random8X]\n je RandomLoopX2\n \n jmp IdkLOOP\n \nRandomLoopX2:\n inc al\n dec al\n mov bl, 64\n mul bl ; mul 64 by the number of the cell and stores the answer in bx\n mov ax,bx ; moves the number of the cell in pixels to ax\n add bx,64 ; the end of the cell in pixels \n \n jmp RandomLoopX3\nRandomLoopX3:\n mov bh,55h ;color of backround \n mov dx,ax\n dec bx\n int 10h ;screenprint\n cmp bx,ax\n ja RandomLoopX3\n \nret \n endp CheckXInput\n \n \n \n proc CheckYInput \nIdkLOOP2:\n mov ah, 1h\n int 21h\n cmp al,31h\n je RandomLoopY\n cmp al,32h\n je RandomLoopY\n cmp al,33h \n je RandomLoopY\n cmp al,34h \n je RandomLoopY\n cmp al,35h\n je RandomLoopY\n jmp IdkLOOP2\n \n RandomLoopY: ; starts a loop that checks each Y cordinate \n sub al,31h\n cmp al,[Random1Y]\n je RandomLOOPY2\n \n cmp al,[Random2Y]\n je RandomLoopY2\n \n cmp al,[Random3Y]\n je RandomLoopY2\n \n cmp al,[Random4Y]\n je RandomLoopY2\n \n cmp al,[Random5Y]\n je RandomLoopY2\n \n cmp al,[Random6Y]\n je RandomLoopY2\n \n cmp al,[Random7Y]\n je RandomLoopY2\n \n cmp al,[Random8Y]\n je RandomLoopY2\n \n jmp IdkLOOP2\n \n \nRandomLoopY2: ; starts a loop that checks each x cordinate\n mov cl,al \n mov bl, 25\n mul bl\n mov ax,bx\n add bx,25\n jmp RamdomLoopY3\nRamdomLoopY3:\n mov bh,55h ;color of backround \n mov dx,ax ; start \n dec bx\n int 10h ;screenprint\n cmp bx,ax ;checks if reached end, if not it will keep printing \n ja RamdomLoopY3\nret \n endp CheckYInput\n \nproc callmodulo \n call modulo \nmov [Random1X],al\ncall modulo\nmov [Random2X],al\ncall modulo\nmov [Random3X],al\ncall modulo\nmov [Random4X],al\ncall modulo\nmov [Random5X],al\ncall modulo\nmov [Random6X],al\ncall modulo\nmov [Random7X],al\ncall modulo\nmov [Random8X],al\n\nret\nendp callmodulo\n\nproc callmodulo2\ncall modulo2\nmov [Random1Y],al\ncall modulo2\nmov [Random2Y],al\ncall modulo2\nmov [Random3Y],al\ncall modulo2\nmov [Random4Y],al\ncall modulo2\nmov [Random5Y],al\ncall modulo2\nmov [Random6Y],al\ncall modulo2\nmov [Random7Y],al\ncall modulo2\nmov [Random8Y],al\n\n\nret\n\nendp callmodulo2\n \n \n;===================================\n;============start=================\n;===================================\n\n\nstart:\n mov ax, @data\n mov ds, ax\n \n ; Graphic mode\n mov ax, 13h\n int 10h\n \n\n \n \n ;first text for first screen \n mov al, 1 ;color \n mov bh, 0 \n mov bl, 15 ;brightness \n mov cx, 12 ;PAKTC1end - offset PAKTC ; calculate message number of letters plus spaces, ect... \n mov dl, 11 ;position start X\n mov dh, 10 ;position start Y \n push ds \n pop es\n mov bp, offset HTS\n mov ah, 13h ;graphic font \n int 10h ; print\n\n \n ;second text for first screen\n mov al, 1 ; color \n mov bh, 27 \n mov bl, 15 ; brightness \n mov cx, 26 ;PAKTC1end - offset PAKTC ; calculate message number of letters plus spaces, ect... \n mov dl, 7 ; position start X\n mov dh, 15 ; position start Y \n push ds\n pop es\n mov bp, offset PAKTC\n mov ah, 13h\n int 10h\n \n \n;space press\ncheckTitleSpace: \n mov ah, 1h\n int 21h\n cmp al, 20h ;space ascii\n jne checkTitleSpace\n \n call ScreenClear ; calls the proc ScreenClear\n\n \n\n\n;========================================\n;=============after opening==============\n;========================================\n\n\n ;useless title \n ;space press\n Draw2:\n mov ah, 1h\n int 21h \n cmp al, 20h ;space ascii \n jne Draw2 \n ;first draw\n\n mov ah,0h\n mov al,13h\n int 10h\n\n;The above three lines just switch to 320x200 256-color VGA.\n mov ax, 0a000h\n mov es, ax \n mov bx, 0 \nloopClear:\n mov [byte ptr es:bx], 11h\n inc bx\n cmp bx, 320 * 200\n jb loopClear\n \n;============================================= \n;==============lines start here===============\n;============================================= \n\n mov cx, [xStart]\n add cx, [length1]\n\n\n ; loop from (xStart+length1) to xStart to draw a horizontal line\n\n LoopStart: \n\n ; draw a pixel\n mov al, 50 ; color\n mov dx, [yStart] \n mov ah, 0ch ; set sub function value in ah to draw a pixel \n int 10h ; and invoke the interrupt \n dec cx ; decrement the x coord \n cmp cx, [xStart] ; test to see if x coord has reached start value \n jae LoopStart ; continue loop if cx >= xStart\n \n mov dx, [ystart]\n add dx, [length1]\n\n ; loop from (ystart+length1) to ystart and add length1\n\n LoopStart2:\n ; draw a pixel\n ; set color in al, x in cx, y in dx\n mov al,50 ;color\n mov cx, [xStart] \n mov ah, 0ch \n int 10h\n dec dx ; decrement the y coord\n cmp dx, [yStart] ; test to see if y coord has reached start value\n \n jne LoopStart2 ; continue loop if dx >= yStart \n\n mov cx, [xStart]\n add cx, [length1]\n LoopStart3:\n mov al, 50 ;color \n mov dx, [yStart2] \n mov ah, 0ch \n int 10h \n dec cx ; decrement the y coord\n cmp cx, [xStart] ; test to see if y coord has reached start value \n jne LoopStart3\n \n mov cx, [xStart]\n add cx, [length1]\n LoopStart4:\n mov al, 50 ;color \n mov dx, [yStart3] \n mov ah, 0ch \n int 10h \n dec cx ; decrement the y coord\n cmp cx, [xStart] ; test to see if y coord has reached start value \n jne LoopStart4\n \n \n\n mov cx, [xStart]\n add cx, [length1]\n LoopStart5:\n mov al, 50 ;color \n mov dx, [yStart4] \n mov ah, 0ch \n int 10h \n dec cx ; decrement the y coord\n cmp cx, [xStart] ; test to see if y coord has reached start value \n jne LoopStart5\n \n\n mov cx, [xStart]\n add cx, [length1]\n LoopStart6:\n mov al, 50 ;color \n mov dx, [yStart5] \n mov ah, 0ch \n int 10h \n dec cx ; decrement the y coord\n cmp cx, [xStart] ; test to see if y coord has reached start value \n jne LoopStart6\n \n\n\n mov cx, [xStart]\n add cx, [length1]\n LoopStart7:\n mov al, 50 ;color \n mov dx, [yStart6] \n mov ah, 0ch \n int 10h \n dec cx ; decrement the y coord\n cmp cx, [xStart] ; test to see if y coord has reached start value \n jne LoopStart7\n \n\n mov cx, [xStart]\n add cx, [length1]\n LoopStart8:\n mov al, 50 ;color \n mov dx, [yStart7] \n mov ah, 0ch \n int 10h \n dec cx ; decrement the y coord\n cmp cx, [xStart] ; test to see if y coord has reached start value \n jne LoopStart8\n \n\n\n\n mov cx, [xStart]\n add cx, [length1]\n LoopStart9:\n mov al, 50 ;color \n mov dx, [yStart8] \n mov ah, 0ch \n int 10h \n dec cx ; decrement the y coord\n cmp cx, [xStart] ; test to see if y coord has reached start value \n jne LoopStart9\n \n\n\n;===================================================\n;========lines end here (thank god)=================\n;===================================================\n\n;==============================\n;=========for random===========\n;==============================\n\n\n\ncall callmodulo\ncall callmodulo2\ncall CheckXInput\ncall CheckYInput\n\n\n\n\n\n\n\n \n\nexit:\n mov ax, 4c00h\n int 21h\nEND start \n
\nThis is the code, I know I know it's bad. But please help me figure out the problem.
\nThank you.
\n"},{"tags":["imagej","fiji","imagej-macro"],"owner":{"reputation":1905,"user_id":8713450,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ed61e21ec072346277da9569f1c9f966?s=128&d=identicon&r=PG&f=1","display_name":"ceno980","link":"https://stackoverflow.com/users/8713450/ceno980"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259277,"creation_date":1623259277,"question_id":67908933,"share_link":"https://stackoverflow.com/q/67908933","body_markdown":"I am new to ImageJ macros and I want to use a macro in Fiji. The code for the macro is from this [source][1]. I have downloaded the code and saved it as a text file. I have then run the macro through going to Plugins > Macros > Run. The version of ImageJ I am using is 1.53j.\r\n\r\nHowever, when I run the macro, I am getting the following error:\r\n\r\n[![enter image description here][2]][2]\r\n\r\n\r\n [1]: https://gist.github.com/mutterer/7901a5444920e4da568adeafb58338f1/revisions\r\n [2]: https://i.stack.imgur.com/ozMz5.png\r\n\r\nI have seen online that this macro works for other people. But I am not sure why I am getting this error or how to resolve it. Any help is appreciated.","link":"https://stackoverflow.com/questions/67908933/undefined-variable-error-when-running-macro-in-imagej","title":"Undefined variable error when running macro in ImageJ","body":"I am new to ImageJ macros and I want to use a macro in Fiji. The code for the macro is from this source. I have downloaded the code and saved it as a text file. I have then run the macro through going to Plugins > Macros > Run. The version of ImageJ I am using is 1.53j.
\nHowever, when I run the macro, I am getting the following error:
\n\nI have seen online that this macro works for other people. But I am not sure why I am getting this error or how to resolve it. Any help is appreciated.
\n"},{"tags":["google-apps-script","google-sheets"],"owner":{"reputation":376,"user_id":6394306,"user_type":"registered","profile_image":"https://lh4.googleusercontent.com/-UBKCbm7LRbk/AAAAAAAAAAI/AAAAAAAAAGM/2Bh2xU_ZZVo/photo.jpg?sz=128","display_name":"arul selvan","link":"https://stackoverflow.com/users/6394306/arul-selvan"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259273,"creation_date":1623259273,"question_id":67908932,"share_link":"https://stackoverflow.com/q/67908932","body_markdown":"I have the minimum order qty in H1\r\nI have the multiplier in H2 (multiplier means in multiples of)\r\n\r\nIf minimum order qty is 10 and multiplier is 2, in cell H5 to H100, the user can type anything equal to or more than 10 and in multiples of 2, which means he can type 10,12,14,16,18,....\r\n\r\nI don't want a drop down.\r\n\r\nIs it possible to achieve by data validation? Or "onEdit(e)" will be better? Will "onEdit(e)" work on mobile device? ","link":"https://stackoverflow.com/questions/67908932/minimum-order-and-multiples-in-data-validation","title":"Minimum order and multiples in data validation","body":"I have the minimum order qty in H1\nI have the multiplier in H2 (multiplier means in multiples of)
\nIf minimum order qty is 10 and multiplier is 2, in cell H5 to H100, the user can type anything equal to or more than 10 and in multiples of 2, which means he can type 10,12,14,16,18,....
\nI don't want a drop down.
\nIs it possible to achieve by data validation? Or "onEdit(e)" will be better? Will "onEdit(e)" work on mobile device?
\n"},{"tags":["python"],"comments":[{"owner":{"reputation":20860,"user_id":5193536,"user_type":"registered","profile_image":"https://i.stack.imgur.com/ZGlox.png?s=128&g=1","display_name":"nbk","link":"https://stackoverflow.com/users/5193536/nbk"},"edited":false,"score":0,"creation_date":1623257667,"post_id":67908542,"comment_id":120030060,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":16178054,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/fde7dcbe9d2b1e5d56e8fafaafc9a971?s=128&d=identicon&r=PG&f=1","display_name":"JCVar","link":"https://stackoverflow.com/users/16178054/jcvar"},"reply_to_user":{"reputation":20860,"user_id":5193536,"user_type":"registered","profile_image":"https://i.stack.imgur.com/ZGlox.png?s=128&g=1","display_name":"nbk","link":"https://stackoverflow.com/users/5193536/nbk"},"edited":false,"score":0,"creation_date":1623258846,"post_id":67908542,"comment_id":120030485,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16178054,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/fde7dcbe9d2b1e5d56e8fafaafc9a971?s=128&d=identicon&r=PG&f=1","display_name":"JCVar","link":"https://stackoverflow.com/users/16178054/jcvar"},"is_answered":false,"view_count":18,"answer_count":0,"score":0,"last_activity_date":1623259272,"creation_date":1623257524,"last_edit_date":1623259272,"question_id":67908542,"share_link":"https://stackoverflow.com/q/67908542","body_markdown":"I'm was pre-processing some HDF files using the Semi-Automatic Classif Plugin in Qgis. Usual procedure.\r\n\r\nThis time, the process stopped and an error popped up. SCP freezes and does not record the log file, nor process the images. This is what the error says:\r\n\r\nCode:\r\n\r\n**An error has occurred while executing Python code:** \r\n\r\n>**TypeError: unsupported operand type(s) for /: 'float' and 'str'** \r\nTraceback (most recent call last):\r\n File "C:/Users/miner/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\SemiAutomaticClassificationPlugin\\maininterface\\asterTab.py", line 428, in performASTERCorrection\r\n self.ASTER(cfg.ui.label_143.text(), o)\r\n File "C:/Users/miner/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\SemiAutomaticClassificationPlugin\\maininterface\\asterTab.py", line 230, in ASTER\r\n tPMDN = cfg.utls.createTempVirtualRaster(inputList, bandList, 'Yes', 'Yes', 0, self.rSr, 'No', xyResList = [pSize, pSize, float(uLX), float(uLY), float(lRX), float(lRY)], aster = 'Yes')\r\n File "C:/Users/miner/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\SemiAutomaticClassificationPlugin\\core\\utils.py", line 2253, in createTempVirtualRaster\r\n output = cfg.utls.createVirtualRaster(inputRasterList, tPMD1, bandNumberList, quiet, NoDataVal, relativeToVRT, projection, intersection, boxCoordList, xyResList, aster)\r\n File "C:/Users/miner/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\SemiAutomaticClassificationPlugin\\core\\utils.py", line 2380, in createVirtualRaster\r\n rX = abs(int(round((iRight - iLeft) / pXSize)))\r\n***TypeError: unsupported operand type(s) for /: 'float' and 'str'***\r\n\r\n\r\nI have tried old HDF files and reinstall SCP, etc. Same error message.\r\nCould anyone guide me to fix this please?\r\nThanks.\r\n","link":"https://stackoverflow.com/questions/67908542/did-anyone-have-this-typeerror-on-python-using-the-spc-in-qgis","title":"Did anyone have this TypeError on Python using the SPC in QGIS?","body":"I'm was pre-processing some HDF files using the Semi-Automatic Classif Plugin in Qgis. Usual procedure.
\nThis time, the process stopped and an error popped up. SCP freezes and does not record the log file, nor process the images. This is what the error says:
\nCode:
\nAn error has occurred while executing Python code:
\n\n\nTypeError: unsupported operand type(s) for /: 'float' and 'str'\nTraceback (most recent call last):\nFile "C:/Users/miner/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\SemiAutomaticClassificationPlugin\\maininterface\\asterTab.py", line 428, in performASTERCorrection\nself.ASTER(cfg.ui.label_143.text(), o)\nFile "C:/Users/miner/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\SemiAutomaticClassificationPlugin\\maininterface\\asterTab.py", line 230, in ASTER\ntPMDN = cfg.utls.createTempVirtualRaster(inputList, bandList, 'Yes', 'Yes', 0, self.rSr, 'No', xyResList = [pSize, pSize, float(uLX), float(uLY), float(lRX), float(lRY)], aster = 'Yes')\nFile "C:/Users/miner/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\SemiAutomaticClassificationPlugin\\core\\utils.py", line 2253, in createTempVirtualRaster\noutput = cfg.utls.createVirtualRaster(inputRasterList, tPMD1, bandNumberList, quiet, NoDataVal, relativeToVRT, projection, intersection, boxCoordList, xyResList, aster)\nFile "C:/Users/miner/AppData/Roaming/QGIS/QGIS3\\profiles\\default/python/plugins\\SemiAutomaticClassificationPlugin\\core\\utils.py", line 2380, in createVirtualRaster\nrX = abs(int(round((iRight - iLeft) / pXSize)))\nTypeError: unsupported operand type(s) for /: 'float' and 'str'
\n
I have tried old HDF files and reinstall SCP, etc. Same error message.\nCould anyone guide me to fix this please?\nThanks.
\n"},{"tags":["rust","ownership","reference-counting","refcell"],"comments":[{"owner":{"reputation":419,"user_id":8511998,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75ba0bfcb6db605366849e45c3d41ffd?s=128&d=identicon&r=PG&f=1","display_name":"L. Riemer","link":"https://stackoverflow.com/users/8511998/l-riemer"},"edited":false,"score":0,"creation_date":1623251319,"post_id":67899965,"comment_id":120027092,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":118,"user_id":8562400,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Rr3tS.jpg?s=128&g=1","display_name":"Román Cárdenas","link":"https://stackoverflow.com/users/8562400/rom%c3%a1n-c%c3%a1rdenas"},"reply_to_user":{"reputation":419,"user_id":8511998,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75ba0bfcb6db605366849e45c3d41ffd?s=128&d=identicon&r=PG&f=1","display_name":"L. Riemer","link":"https://stackoverflow.com/users/8511998/l-riemer"},"edited":false,"score":0,"creation_date":1623251710,"post_id":67899965,"comment_id":120027275,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":419,"user_id":8511998,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75ba0bfcb6db605366849e45c3d41ffd?s=128&d=identicon&r=PG&f=1","display_name":"L. Riemer","link":"https://stackoverflow.com/users/8511998/l-riemer"},"edited":false,"score":0,"creation_date":1623251965,"post_id":67899965,"comment_id":120027416,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":419,"user_id":8511998,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/75ba0bfcb6db605366849e45c3d41ffd?s=128&d=identicon&r=PG&f=1","display_name":"L. Riemer","link":"https://stackoverflow.com/users/8511998/l-riemer"},"is_accepted":false,"score":0,"last_activity_date":1623259271,"last_edit_date":1623259271,"creation_date":1623253712,"answer_id":67907571,"question_id":67899965,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":118,"user_id":8562400,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Rr3tS.jpg?s=128&g=1","display_name":"Román Cárdenas","link":"https://stackoverflow.com/users/8562400/rom%c3%a1n-c%c3%a1rdenas"},"is_answered":false,"view_count":36,"answer_count":1,"score":1,"last_activity_date":1623259271,"creation_date":1623225594,"last_edit_date":1623254297,"question_id":67899965,"share_link":"https://stackoverflow.com/q/67899965","body_markdown":"I'm trying to understand how to work with interior mutability. This question is strongly related to [my previous question](https://stackoverflow.com/questions/67870844/rust-implementing-an-iterator-from-a-vector-of-stdrc-smart-pointers).\r\n\r\nI have a generic struct `Port<T>` that owns a `Vec<T>`. We can "chain" port B to port A so, when reading the content of port A, we are able to read the content of port B. However, this chaining is hidden to port A's reader. That is why I implemented the `iter(&self)` method:\r\n\r\n```rust\r\nuse std::rc::Rc;\r\n\r\npub struct Port<T> {\r\n values: Vec<T>,\r\n ports: Vec<Rc<Port<T>>>,\r\n}\r\n\r\nimpl <T> Port<T> {\r\n pub fn new() -> Self {\r\n Self { values: vec![], ports: vec![] }\r\n }\r\n\r\n pub fn add_value(&mut self, value: T) {\r\n self.values.push(value);\r\n }\r\n\r\n pub fn is_empty(&self) -> bool {\r\n self.values.is_empty() && self.ports.is_empty()\r\n }\r\n\r\n pub fn chain_port(&mut self, port: Rc<Port<T>>) {\r\n if !port.is_empty() {\r\n self.ports.push(port)\r\n }\r\n }\r\n\r\n pub fn iter(&self) -> impl Iterator<Item = &T> {\r\n self.values.iter().chain(\r\n self.ports.iter()\r\n .flat_map(|p| Box::new(p.iter()) as Box<dyn Iterator<Item = &T>>)\r\n )\r\n }\r\n\r\n pub fn clear(&mut self) {\r\n self.values.clear();\r\n self.ports.clear();\r\n }\r\n}\r\n```\r\n\r\nThe application has the following pseudo-code behavior:\r\n\r\n* create ports\r\n* loop:\r\n * fill ports with values\r\n * chain ports\r\n * iterate over ports' values\r\n * clear ports\r\n\r\nThe `main` function should look like this:\r\n\r\n```rust\r\nfn main() {\r\n let mut port_a = Rc::new(Port::new());\r\n let mut port_b = Rc::new(Port::new());\r\n\r\n loop {\r\n port_a.add_value(1);\r\n port_b.add_value(2);\r\n\r\n port_a.chain_port(port_b.clone());\r\n\r\n for val in port_a.iter() {\r\n // read data\r\n };\r\n\r\n port_a.clear();\r\n port_b.clear();\r\n }\r\n}\r\n```\r\n\r\nHowever, the compiler complains:\r\n\r\n```none\r\nerror[E0596]: cannot borrow data in an `Rc` as mutable\r\n --> src/modeling/port.rs:46:9\r\n |\r\n46 | port_a.add_value(1);\r\n | ^^^^^^ cannot borrow as mutable\r\n |\r\n = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Port<i32>>`\r\n```\r\n\r\nI've been reading several posts etc., and it seems that I need to work with `Rc<RefCell<Port<T>>>` to be able to mutate the ports. I changed the implementation of `Port<T>`:\r\n\r\n```rust\r\nuse std::cell::RefCell;\r\nuse std::rc::Rc;\r\n\r\npub struct Port<T> {\r\n values: Vec<T>,\r\n ports: Vec<Rc<RefCell<Port<T>>>>,\r\n}\r\n\r\nimpl<T> Port<T> {\r\n\r\n // snip\r\n\r\n pub fn chain_port(&mut self, port: Rc<RefCell<Port<T>>>) {\r\n if !port.borrow().is_empty() {\r\n self.ports.push(port)\r\n }\r\n }\r\n\r\n pub fn iter(&self) -> impl Iterator<Item = &T> {\r\n self.values.iter().chain(\r\n self.ports\r\n .iter()\r\n .flat_map(|p| Box::new(p.borrow().iter()) as Box<dyn Iterator<Item = &T>>),\r\n )\r\n }\r\n\r\n // snip\r\n}\r\n```\r\n\r\nThis does not compile either:\r\n\r\n```none\r\nerror[E0515]: cannot return value referencing temporary value\r\n --> src/modeling/port.rs:35:31\r\n |\r\n35 | .flat_map(|p| Box::new(p.borrow().iter()) as Box<dyn Iterator<Item = &T>>),\r\n | ^^^^^^^^^----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n | | |\r\n | | temporary value created here\r\n | returns a value referencing data owned by the current function\r\n```\r\n\r\nI think I know what the problem is: `p.borrow()` returns a reference to the port being chained. We use that reference to create the iterator, but as soon as the function is done, the reference goes out of scope and the iterator is no longer valid.\r\n\r\nI have no clue on how to deal with this. I managed to implement the following unsafe method:\r\n\r\n```rust\r\n pub fn iter(&self) -> impl Iterator<Item = &T> {\r\n self.values.iter().chain(self.ports.iter().flat_map(|p| {\r\n Box::new(unsafe { (&*p.as_ref().as_ptr()).iter() }) as Box<dyn Iterator<Item = &T>>\r\n }))\r\n }\r\n```\r\n\r\nWhile this works, it uses unsafe code, and there must be a safe workaround.\r\n\r\nI set a [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0323b4f4f8d3411c1be5f9a0feb23687) for more details of my application. The application compiles and outputs the expected result (but uses unsafe code).","link":"https://stackoverflow.com/questions/67899965/how-do-i-implement-an-iterator-from-a-vector-of-stdrcstdrefcellt-smart-p","title":"How do I implement an iterator from a vector of std::Rc<std::RefCell<T>> smart pointers?","body":"I'm trying to understand how to work with interior mutability. This question is strongly related to my previous question.
\nI have a generic struct Port<T>
that owns a Vec<T>
. We can "chain" port B to port A so, when reading the content of port A, we are able to read the content of port B. However, this chaining is hidden to port A's reader. That is why I implemented the iter(&self)
method:
use std::rc::Rc;\n\npub struct Port<T> {\n values: Vec<T>,\n ports: Vec<Rc<Port<T>>>,\n}\n\nimpl <T> Port<T> {\n pub fn new() -> Self {\n Self { values: vec![], ports: vec![] }\n }\n\n pub fn add_value(&mut self, value: T) {\n self.values.push(value);\n }\n\n pub fn is_empty(&self) -> bool {\n self.values.is_empty() && self.ports.is_empty()\n }\n\n pub fn chain_port(&mut self, port: Rc<Port<T>>) {\n if !port.is_empty() {\n self.ports.push(port)\n }\n }\n\n pub fn iter(&self) -> impl Iterator<Item = &T> {\n self.values.iter().chain(\n self.ports.iter()\n .flat_map(|p| Box::new(p.iter()) as Box<dyn Iterator<Item = &T>>)\n )\n }\n\n pub fn clear(&mut self) {\n self.values.clear();\n self.ports.clear();\n }\n}\n
\nThe application has the following pseudo-code behavior:
\nThe main
function should look like this:
fn main() {\n let mut port_a = Rc::new(Port::new());\n let mut port_b = Rc::new(Port::new());\n\n loop {\n port_a.add_value(1);\n port_b.add_value(2);\n\n port_a.chain_port(port_b.clone());\n\n for val in port_a.iter() {\n // read data\n };\n\n port_a.clear();\n port_b.clear();\n }\n}\n
\nHowever, the compiler complains:
\nerror[E0596]: cannot borrow data in an `Rc` as mutable\n --> src/modeling/port.rs:46:9\n |\n46 | port_a.add_value(1);\n | ^^^^^^ cannot borrow as mutable\n |\n = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Port<i32>>`\n
\nI've been reading several posts etc., and it seems that I need to work with Rc<RefCell<Port<T>>>
to be able to mutate the ports. I changed the implementation of Port<T>
:
use std::cell::RefCell;\nuse std::rc::Rc;\n\npub struct Port<T> {\n values: Vec<T>,\n ports: Vec<Rc<RefCell<Port<T>>>>,\n}\n\nimpl<T> Port<T> {\n\n // snip\n\n pub fn chain_port(&mut self, port: Rc<RefCell<Port<T>>>) {\n if !port.borrow().is_empty() {\n self.ports.push(port)\n }\n }\n\n pub fn iter(&self) -> impl Iterator<Item = &T> {\n self.values.iter().chain(\n self.ports\n .iter()\n .flat_map(|p| Box::new(p.borrow().iter()) as Box<dyn Iterator<Item = &T>>),\n )\n }\n\n // snip\n}\n
\nThis does not compile either:
\nerror[E0515]: cannot return value referencing temporary value\n --> src/modeling/port.rs:35:31\n |\n35 | .flat_map(|p| Box::new(p.borrow().iter()) as Box<dyn Iterator<Item = &T>>),\n | ^^^^^^^^^----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n | | |\n | | temporary value created here\n | returns a value referencing data owned by the current function\n
\nI think I know what the problem is: p.borrow()
returns a reference to the port being chained. We use that reference to create the iterator, but as soon as the function is done, the reference goes out of scope and the iterator is no longer valid.
I have no clue on how to deal with this. I managed to implement the following unsafe method:
\n pub fn iter(&self) -> impl Iterator<Item = &T> {\n self.values.iter().chain(self.ports.iter().flat_map(|p| {\n Box::new(unsafe { (&*p.as_ref().as_ptr()).iter() }) as Box<dyn Iterator<Item = &T>>\n }))\n }\n
\nWhile this works, it uses unsafe code, and there must be a safe workaround.
\nI set a playground for more details of my application. The application compiles and outputs the expected result (but uses unsafe code).
\n"},{"tags":["ios","swift","xcode","macos","react-native"],"owner":{"reputation":1799,"user_id":9050437,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/82812bec265f3bf589beb39a5a76f47a?s=128&d=identicon&r=PG&f=1","display_name":"Syed","link":"https://stackoverflow.com/users/9050437/syed"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623259265,"creation_date":1623259265,"question_id":67908931,"share_link":"https://stackoverflow.com/q/67908931","body_markdown":"I'm developing an react-native application on M1 Mac.\r\n\r\nI recently updated my mac os to beta version Monterey(version 12.0 beta)\r\n\r\nAfter installing the beta version of the mac os i also installed the Xcode(13.0 beta)\r\n\r\nNow my app is installed to the iPad simulator but when i open the app, i get the following error.\r\n\r\n[![error log][1]][1]\r\n\r\n\r\nCan someone help me.\r\n\r\nThanks in advance!\r\n\r\n [1]: https://i.stack.imgur.com/r9vPt.png","link":"https://stackoverflow.com/questions/67908931/macos-update-raised-exc-bad-access-sigsegv","title":"MacOS update raised EXC_BAD_ACCESS (SIGSEGV)","body":"I'm developing an react-native application on M1 Mac.
\nI recently updated my mac os to beta version Monterey(version 12.0 beta)
\nAfter installing the beta version of the mac os i also installed the Xcode(13.0 beta)
\nNow my app is installed to the iPad simulator but when i open the app, i get the following error.
\n\nCan someone help me.
\nThanks in advance!
\n"},{"tags":["ios","swift","facebook","facebook-events"],"owner":{"reputation":613,"user_id":7970235,"user_type":"registered","profile_image":"https://i.stack.imgur.com/5rOpA.jpg?s=128&g=1","display_name":"M. Mansueli","link":"https://stackoverflow.com/users/7970235/m-mansueli"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259260,"creation_date":1623259260,"question_id":67908930,"share_link":"https://stackoverflow.com/q/67908930","body_markdown":"I have updated the **FBSDKAppEvents** to **11.0.0 version**, and the function AppEvents.activateApp() in AppDelegate is now deprecated. I have searched in the Facebook documentation, and unfortunately I didn't found any information about that, and I don't understand what's method I want to use to replace the deprecated:\r\n\r\n[![Deprecated function][1]][1]\r\n\r\nThe message is: \r\n"'activateApp()' is deprecated: The class method `activateApp` is deprecated. It is replaced by an instance method of the same name."\r\n\r\nDid anyone know what code I have to put to replace the deprecated one?\r\n\r\n [1]: https://i.stack.imgur.com/Rp6pO.png\r\n","link":"https://stackoverflow.com/questions/67908930/how-to-use-appevents-activateapp-in-11-0-0-version","title":"How to use AppEvents.activateApp() in 11.0.0 version","body":"I have updated the FBSDKAppEvents to 11.0.0 version, and the function AppEvents.activateApp() in AppDelegate is now deprecated. I have searched in the Facebook documentation, and unfortunately I didn't found any information about that, and I don't understand what's method I want to use to replace the deprecated:
\n\nThe message is:\n"'activateApp()' is deprecated: The class method activateApp
is deprecated. It is replaced by an instance method of the same name."
Did anyone know what code I have to put to replace the deprecated one?
\n"},{"tags":["c++","zlib"],"comments":[{"owner":{"reputation":22810,"user_id":5494370,"user_type":"registered","profile_image":"https://graph.facebook.com/10152989584621642/picture?type=large","display_name":"Alan Birtles","link":"https://stackoverflow.com/users/5494370/alan-birtles"},"edited":false,"score":1,"creation_date":1623140027,"post_id":67883805,"comment_id":119987125,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":41,"user_id":5426329,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/758853f857d0e2dc097a533981a9db9d?s=128&d=identicon&r=PG&f=1","display_name":"valeriot90","link":"https://stackoverflow.com/users/5426329/valeriot90"},"reply_to_user":{"reputation":22810,"user_id":5494370,"user_type":"registered","profile_image":"https://graph.facebook.com/10152989584621642/picture?type=large","display_name":"Alan Birtles","link":"https://stackoverflow.com/users/5494370/alan-birtles"},"edited":false,"score":0,"creation_date":1623140724,"post_id":67883805,"comment_id":119987365,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":22810,"user_id":5494370,"user_type":"registered","profile_image":"https://graph.facebook.com/10152989584621642/picture?type=large","display_name":"Alan Birtles","link":"https://stackoverflow.com/users/5494370/alan-birtles"},"edited":false,"score":0,"creation_date":1623141643,"post_id":67883805,"comment_id":119987722,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":41,"user_id":5426329,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/758853f857d0e2dc097a533981a9db9d?s=128&d=identicon&r=PG&f=1","display_name":"valeriot90","link":"https://stackoverflow.com/users/5426329/valeriot90"},"reply_to_user":{"reputation":22810,"user_id":5494370,"user_type":"registered","profile_image":"https://graph.facebook.com/10152989584621642/picture?type=large","display_name":"Alan Birtles","link":"https://stackoverflow.com/users/5494370/alan-birtles"},"edited":false,"score":0,"creation_date":1623250136,"post_id":67883805,"comment_id":120026545,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":22810,"user_id":5494370,"user_type":"registered","profile_image":"https://graph.facebook.com/10152989584621642/picture?type=large","display_name":"Alan Birtles","link":"https://stackoverflow.com/users/5494370/alan-birtles"},"is_accepted":false,"score":1,"last_activity_date":1623259258,"last_edit_date":1623259258,"creation_date":1623254249,"answer_id":67907715,"question_id":67883805,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":41,"user_id":5426329,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/758853f857d0e2dc097a533981a9db9d?s=128&d=identicon&r=PG&f=1","display_name":"valeriot90","link":"https://stackoverflow.com/users/5426329/valeriot90"},"is_answered":true,"view_count":26,"answer_count":1,"score":0,"last_activity_date":1623259258,"creation_date":1623139793,"last_edit_date":1623233135,"question_id":67883805,"share_link":"https://stackoverflow.com/q/67883805","body_markdown":"The zlib uncompress() return -3 (z_data_error) when I decompress data.\r\nFrom doc: returns Z_DATA_ERROR if the input data was corrupted or incomplete,\r\n\r\n uncompress((Bytef*)uncompressbuffer, &uncompressbuffersize, (const Bytef*)compressbuffer, &compressbuffersize)\r\n\r\nIn another application, where I use deflate/inflate I get the same error.\r\n\r\n strm.zalloc = Z_NULL;\r\n strm.zfree = Z_NULL;\r\n strm.opaque = Z_NULL;\r\n strm.avail_in = inputLength;\r\n strm.next_in = (unsigned char*) inputBuffer;\r\n\r\n ret = inflateInit(&strm);\r\n if (ret != Z_OK)\r\n {\r\n \tdelete[] uncompressedData;\r\n \treturn ERROR;\r\n }\r\n /******************************************************/\r\n \r\n \r\n strm.avail_out = unusedData; \r\n strm.next_out = (uncompressedData + MIN_CHUNK) - unusedData;\r\n \r\n /* run inflate() on input until output buffer not full */\r\n do {\r\n \tret = inflate(&strm, Z_NO_FLUSH);\r\n \tassert(ret != Z_STREAM_ERROR); /* state not clobbered */\r\n \r\n \tswitch (ret)\r\n \t{\r\n \tcase Z_NEED_DICT:\r\n\t \tret = Z_DATA_ERROR; /* and fall through */\r\n \tcase Z_DATA_ERROR:\r\n \tcase Z_MEM_ERROR:\r\n \t\t(void)inflateEnd(&strm);\r\n \t\treturn ret;\r\n \t}\r\n\r\n } while (strm.avail_out != 0 && ret == Z_OK);\r\n\r\nbut\r\n\r\nthis error happens only with x64 version of my software. A x86 working properly. The unzipped data is intact. The buffer size of compressed and uncompressed data are correct.\r\nZlib is correctly compiled to x64.\r\nWhat else could be causing this problem? Any hint?\r\n\r\nSample code with "uncompress":\r\n\r\n #include <iostream>\r\n #include <fstream>\r\n #include <cstdio>\r\n #include <vector>\r\n #include <zlib.h>\r\n #include <assert.h>\r\n #include <cstdlib>\r\n \r\n #define CHUNK 16384\r\n \r\n const int BUFFERSIZE = 4096;\r\n \r\n using namespace std;\r\n \r\n void compress(FILE* fin, FILE* fout) {\r\n \r\n \tchar buffer[BUFFERSIZE];\r\n \t\r\n \tint byte_read = fread(buffer, sizeof(char), BUFFERSIZE, fin);\r\n \r\n \t\r\n \tz_stream strm;\r\n \tint ret;\r\n \tunsigned have;\r\n \tunsigned char* tmp = new unsigned char[CHUNK];\r\n \r\n \tstrm.zalloc = Z_NULL;\r\n \tstrm.zfree = Z_NULL;\r\n \tstrm.opaque = Z_NULL;\r\n \tstrm.next_in = (unsigned char*)buffer;\r\n \tstrm.avail_in = byte_read;\r\n \tstrm.next_out = tmp;\r\n \tstrm.avail_out = CHUNK;\r\n \r\n \tret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);\r\n \r\n \t//first loop: compress input data stream and write on RTDB file\r\n \tdo\r\n \t{\r\n \r\n \t\tret = deflate(&strm, Z_NO_FLUSH);\r\n \t\tassert(ret != Z_STREAM_ERROR);\r\n \r\n \t\thave = BUFFERSIZE - strm.avail_out;\r\n \t\tfwrite(tmp, sizeof(char), BUFFERSIZE, fout);\r\n \r\n \t} while (strm.avail_out == 0);\r\n \t//assert(strm.avail_in == 0);\r\n \r\n \t//second loop: all input data consumed. Flush everything...\r\n \tdo\r\n \t{\r\n \t\tstrm.next_out = tmp;\r\n \t\tstrm.avail_out = BUFFERSIZE;\r\n \r\n \t\tret = deflate(&strm, Z_FINISH);\r\n \t\tassert(ret != Z_STREAM_ERROR);\r\n \r\n \t\thave = BUFFERSIZE - strm.avail_out;\r\n \t\tfwrite(tmp, sizeof(char), BUFFERSIZE, fout);\r\n \r\n \t} while (ret != Z_STREAM_END);\r\n \r\n \t(void)deflateEnd(&strm);\r\n \tdelete tmp;\r\n }\r\n \r\n void decompress(FILE* fin, FILE* fout) {\r\n \r\n \tint status;\r\n \r\n \tchar buffer[BUFFERSIZE];\r\n \r\n \tint byte_read = fread(buffer, sizeof(char), BUFFERSIZE, fin);\r\n \r\n \tvoid* compressedBuffer;\r\n \tvoid* uncompressedBuffer;\r\n \tuLongf\tcompressedBufferSize = BUFFERSIZE;\r\n \tuLongf\tuncompressedBufferSize = BUFFERSIZE;\r\n \r\n \tcompressedBuffer = malloc(compressedBufferSize);\r\n \tuncompressedBuffer = malloc(uncompressedBufferSize);\r\n \r\n \tstatus = uncompress((Bytef*)uncompressedBuffer, &uncompressedBufferSize, (const Bytef*)buffer, compressedBufferSize);\r\n \r\n \tfwrite(uncompressedBuffer, sizeof(char), BUFFERSIZE, fout);\r\n \r\n \tcout << "Status " << status << endl;\r\n }\r\n \r\n int main(int argc, char *argv[]) {\r\n \t\r\n \t//if (argc == 2)\r\n \t//{\r\n \t//\tif (strcmp(argv[1], "/?") == 0 || strcmp(argv[1], "--help") == 0)\r\n \t//\t{\r\n \t//\t\tcout << "Please give me 1 argument" << endl;\r\n \t//\t\t//getchar();\r\n \t//\t\treturn -1;\r\n \t//\t}\r\n \t//}\r\n \t//else\r\n \t//{\r\n \t//\tcout << "Please give me 1 argument" << endl;\r\n \t//\t//getchar();\r\n \t//\treturn -1;\r\n \t//}\r\n \t//char *inputdata = argv[1];\r\n \t\r\n \t//const char *inputdata = "C:\\\\Users\\\\Francesco\\\\source\\\\repos\\\\zlibtest\\\\P0000P0000_no_com-alt.rtdb";\r\n \tconst char *inputdata = "C:\\\\Users\\\\Francesco\\\\source\\\\repos\\\\zlibtest\\\\AAA.txt";\r\n \t//const char *inputdata = "C:\\\\Users\\\\Francesco\\\\source\\\\repos\\\\zlibtest\\\\P0000P0000_no_com-alt.rtdb";\r\n \t\r\n \tcout << inputdata << endl;\r\n \tFILE *fin, *fout, *fdec;\r\n \tfopen_s(&fin, inputdata, "r+");\r\n \r\n \tfopen_s(&fout, "output.txt", "w+");\r\n \r\n \tcompress(fin, fout);\r\n \r\n \tfclose(fin);\r\n \tfclose(fout);\r\n \r\n \tfopen_s(&fout, "output.txt", "r");\r\n \r\n \tfopen_s(&fdec, "dec.txt", "w");\r\n \r\n \tdecompress(fout, fdec);\r\n \t\r\n \tfclose(fout);\r\n \tfclose(fdec);\r\n }","link":"https://stackoverflow.com/questions/67883805/zlib-decompression-return-3-z-data-error","title":"zlib decompression return -3 (z_data_error)","body":"The zlib uncompress() return -3 (z_data_error) when I decompress data.\nFrom doc: returns Z_DATA_ERROR if the input data was corrupted or incomplete,
\nuncompress((Bytef*)uncompressbuffer, &uncompressbuffersize, (const Bytef*)compressbuffer, &compressbuffersize)\n
\nIn another application, where I use deflate/inflate I get the same error.
\nstrm.zalloc = Z_NULL;\nstrm.zfree = Z_NULL;\nstrm.opaque = Z_NULL;\nstrm.avail_in = inputLength;\nstrm.next_in = (unsigned char*) inputBuffer;\n\nret = inflateInit(&strm);\nif (ret != Z_OK)\n{\n delete[] uncompressedData;\n return ERROR;\n}\n/******************************************************/\n\n\nstrm.avail_out = unusedData; \nstrm.next_out = (uncompressedData + MIN_CHUNK) - unusedData;\n\n/* run inflate() on input until output buffer not full */\ndo {\n ret = inflate(&strm, Z_NO_FLUSH);\n assert(ret != Z_STREAM_ERROR); /* state not clobbered */\n\n switch (ret)\n {\n case Z_NEED_DICT:\n ret = Z_DATA_ERROR; /* and fall through */\n case Z_DATA_ERROR:\n case Z_MEM_ERROR:\n (void)inflateEnd(&strm);\n return ret;\n }\n\n} while (strm.avail_out != 0 && ret == Z_OK);\n
\nbut
\nthis error happens only with x64 version of my software. A x86 working properly. The unzipped data is intact. The buffer size of compressed and uncompressed data are correct.\nZlib is correctly compiled to x64.\nWhat else could be causing this problem? Any hint?
\nSample code with "uncompress":
\n#include <iostream>\n#include <fstream>\n#include <cstdio>\n#include <vector>\n#include <zlib.h>\n#include <assert.h>\n#include <cstdlib>\n\n#define CHUNK 16384\n\nconst int BUFFERSIZE = 4096;\n\nusing namespace std;\n\nvoid compress(FILE* fin, FILE* fout) {\n\n char buffer[BUFFERSIZE];\n \n int byte_read = fread(buffer, sizeof(char), BUFFERSIZE, fin);\n\n \n z_stream strm;\n int ret;\n unsigned have;\n unsigned char* tmp = new unsigned char[CHUNK];\n\n strm.zalloc = Z_NULL;\n strm.zfree = Z_NULL;\n strm.opaque = Z_NULL;\n strm.next_in = (unsigned char*)buffer;\n strm.avail_in = byte_read;\n strm.next_out = tmp;\n strm.avail_out = CHUNK;\n\n ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);\n\n //first loop: compress input data stream and write on RTDB file\n do\n {\n\n ret = deflate(&strm, Z_NO_FLUSH);\n assert(ret != Z_STREAM_ERROR);\n\n have = BUFFERSIZE - strm.avail_out;\n fwrite(tmp, sizeof(char), BUFFERSIZE, fout);\n\n } while (strm.avail_out == 0);\n //assert(strm.avail_in == 0);\n\n //second loop: all input data consumed. Flush everything...\n do\n {\n strm.next_out = tmp;\n strm.avail_out = BUFFERSIZE;\n\n ret = deflate(&strm, Z_FINISH);\n assert(ret != Z_STREAM_ERROR);\n\n have = BUFFERSIZE - strm.avail_out;\n fwrite(tmp, sizeof(char), BUFFERSIZE, fout);\n\n } while (ret != Z_STREAM_END);\n\n (void)deflateEnd(&strm);\n delete tmp;\n}\n\nvoid decompress(FILE* fin, FILE* fout) {\n\n int status;\n\n char buffer[BUFFERSIZE];\n\n int byte_read = fread(buffer, sizeof(char), BUFFERSIZE, fin);\n\n void* compressedBuffer;\n void* uncompressedBuffer;\n uLongf compressedBufferSize = BUFFERSIZE;\n uLongf uncompressedBufferSize = BUFFERSIZE;\n\n compressedBuffer = malloc(compressedBufferSize);\n uncompressedBuffer = malloc(uncompressedBufferSize);\n\n status = uncompress((Bytef*)uncompressedBuffer, &uncompressedBufferSize, (const Bytef*)buffer, compressedBufferSize);\n\n fwrite(uncompressedBuffer, sizeof(char), BUFFERSIZE, fout);\n\n cout << "Status " << status << endl;\n}\n\nint main(int argc, char *argv[]) {\n \n //if (argc == 2)\n //{\n // if (strcmp(argv[1], "/?") == 0 || strcmp(argv[1], "--help") == 0)\n // {\n // cout << "Please give me 1 argument" << endl;\n // //getchar();\n // return -1;\n // }\n //}\n //else\n //{\n // cout << "Please give me 1 argument" << endl;\n // //getchar();\n // return -1;\n //}\n //char *inputdata = argv[1];\n \n //const char *inputdata = "C:\\\\Users\\\\Francesco\\\\source\\\\repos\\\\zlibtest\\\\P0000P0000_no_com-alt.rtdb";\n const char *inputdata = "C:\\\\Users\\\\Francesco\\\\source\\\\repos\\\\zlibtest\\\\AAA.txt";\n //const char *inputdata = "C:\\\\Users\\\\Francesco\\\\source\\\\repos\\\\zlibtest\\\\P0000P0000_no_com-alt.rtdb";\n \n cout << inputdata << endl;\n FILE *fin, *fout, *fdec;\n fopen_s(&fin, inputdata, "r+");\n\n fopen_s(&fout, "output.txt", "w+");\n\n compress(fin, fout);\n\n fclose(fin);\n fclose(fout);\n\n fopen_s(&fout, "output.txt", "r");\n\n fopen_s(&fdec, "dec.txt", "w");\n\n decompress(fout, fdec);\n \n fclose(fout);\n fclose(fdec);\n}\n
\n"},{"tags":["angular"],"owner":{"reputation":103,"user_id":11941232,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ec01acf4c3656d74fab3c4d3060a1eb2?s=128&d=identicon&r=PG&f=1","display_name":"Gamoxion","link":"https://stackoverflow.com/users/11941232/gamoxion"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623259249,"creation_date":1623259249,"question_id":67908929,"share_link":"https://stackoverflow.com/q/67908929","body_markdown":"I have an Angular application in which I used to ask the user through a prompt to update the app whenever a new version was published. However, now I need to force the update without the user input. For updating I've been using Angular Service Worker and the SwUpdate class.\r\n\r\nMy problem is that when I publish a new version with code that supposedly forces auto-updates, users with the old version of the app keep seeing the prompt that asks them to update. If they do update the app works fine, but if they don't the old version is no longer compatible with the new implemented functionalities.\r\n\r\nThis is the code of auto-updating on my new version:\r\n\r\n public checkForUpdates() {\r\n // console.log("checkForUpdates");\r\n // console.log(this.updates.isEnabled);\r\n if (this.updates.isEnabled) {\r\n this.updates.available.subscribe((event) => {\r\n console.log("current version is", event.current);\r\n console.log("available version is", event.available);\r\n \r\n this.updates.activateUpdate().then(() => document.location.reload());\r\n \r\n //document.location.reload();\r\n //this.promptUser(event);\r\n });\r\n this.updates.activated.subscribe((event) => {\r\n console.log("old version was", event.previous);\r\n console.log("new version is", event.current);\r\n });\r\n }\r\n }\r\n\r\nHow could I make the existing old version users to update without their input? It seems that if they don't refresh or manually update the app, they won't get the new version.","link":"https://stackoverflow.com/questions/67908929/how-to-update-old-versions-service-worker-in-angular-without-refreshing-the-page","title":"How to update old versions Service Worker in Angular without refreshing the page?","body":"I have an Angular application in which I used to ask the user through a prompt to update the app whenever a new version was published. However, now I need to force the update without the user input. For updating I've been using Angular Service Worker and the SwUpdate class.
\nMy problem is that when I publish a new version with code that supposedly forces auto-updates, users with the old version of the app keep seeing the prompt that asks them to update. If they do update the app works fine, but if they don't the old version is no longer compatible with the new implemented functionalities.
\nThis is the code of auto-updating on my new version:
\n public checkForUpdates() {\n // console.log("checkForUpdates");\n // console.log(this.updates.isEnabled);\n if (this.updates.isEnabled) {\n this.updates.available.subscribe((event) => {\n console.log("current version is", event.current);\n console.log("available version is", event.available);\n\n this.updates.activateUpdate().then(() => document.location.reload());\n\n //document.location.reload();\n //this.promptUser(event);\n });\n this.updates.activated.subscribe((event) => {\n console.log("old version was", event.previous);\n console.log("new version is", event.current);\n });\n }\n }\n
\nHow could I make the existing old version users to update without their input? It seems that if they don't refresh or manually update the app, they won't get the new version.
\n"},{"tags":[".net","asp.net-core"],"owner":{"reputation":3,"user_id":9551458,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ff0ad13b2d83752d5b3532c760aebd58?s=128&d=identicon&r=PG&f=1","display_name":"beiduoan","link":"https://stackoverflow.com/users/9551458/beiduoan"},"is_answered":false,"view_count":11,"answer_count":0,"score":0,"last_activity_date":1623259249,"creation_date":1623258145,"question_id":67908676,"share_link":"https://stackoverflow.com/q/67908676","body_markdown":"I hope get week datetime list by datetime range,I tried the following code get number of weeks per month.\r\n\r\n var start = new DateTime(2021, 6, 09);\r\n var end = new DateTime(2021, 7, 01);\r\n\r\n end = new DateTime(end.Year, end.Month, DateTime.DaysInMonth(end.Year, end.Month));\r\n\r\n var diff = Enumerable.Range(0, Int32.MaxValue)\r\n .Select(e => start.AddMonths(e))\r\n .TakeWhile(e => e <= end)\r\n .Select(e => Convert.ToDateTime(e.ToString("yyyy-MM")));\r\n\r\n foreach (var item in diff)\r\n {\r\n\r\n DateTime dateTime = item;\r\n Calendar calendar = CultureInfo.CurrentCulture.Calendar;\r\n IEnumerable<int> daysInMonth = Enumerable.Range(1, calendar.GetDaysInMonth(dateTime.Year, dateTime.Month));\r\n List<Tuple<DateTime, DateTime>> weeks = daysInMonth.Select(day => new DateTime(dateTime.Year, dateTime.Month, day))\r\n .GroupBy(d => calendar.GetWeekOfYear(d, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday))\r\n .Select(g => new Tuple<DateTime, DateTime>(g.First(), g.Last()))\r\n .ToList();\r\n }\r\nBut,I hope get DateTime(2021, 6, 09) between Week starting on the 9th and DateTime(2021, 7, 01) Week ending on the 1th of weeks time, like this.\r\n\r\n 2021-06-09 2021-06-13\r\n .....\r\n 2021-06-28 2021-07-01\r\nhow to changed my code","link":"https://stackoverflow.com/questions/67908676/net-core-how-to-get-week-datetime-list-by-datetime-range","title":".net core how to get week datetime list by datetime range","body":"I hope get week datetime list by datetime range,I tried the following code get number of weeks per month.
\nvar start = new DateTime(2021, 6, 09);\n var end = new DateTime(2021, 7, 01);\n\n end = new DateTime(end.Year, end.Month, DateTime.DaysInMonth(end.Year, end.Month));\n\n var diff = Enumerable.Range(0, Int32.MaxValue)\n .Select(e => start.AddMonths(e))\n .TakeWhile(e => e <= end)\n .Select(e => Convert.ToDateTime(e.ToString("yyyy-MM")));\n\n foreach (var item in diff)\n {\n\n DateTime dateTime = item;\n Calendar calendar = CultureInfo.CurrentCulture.Calendar;\n IEnumerable<int> daysInMonth = Enumerable.Range(1, calendar.GetDaysInMonth(dateTime.Year, dateTime.Month));\n List<Tuple<DateTime, DateTime>> weeks = daysInMonth.Select(day => new DateTime(dateTime.Year, dateTime.Month, day))\n .GroupBy(d => calendar.GetWeekOfYear(d, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday))\n .Select(g => new Tuple<DateTime, DateTime>(g.First(), g.Last()))\n .ToList();\n }\n
\nBut,I hope get DateTime(2021, 6, 09) between Week starting on the 9th and DateTime(2021, 7, 01) Week ending on the 1th of weeks time, like this.
\n2021-06-09 2021-06-13\n.....\n2021-06-28 2021-07-01\n
\nhow to changed my code
\n"},{"tags":["r","shiny","r-markdown","flexdashboard","bootswatch"],"owner":{"reputation":37,"user_id":7885168,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/7ecb244d8a9605d9d6a61412d9ad7234?s=128&d=identicon&r=PG&f=1","display_name":"Wolkuz","link":"https://stackoverflow.com/users/7885168/wolkuz"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623259247,"creation_date":1623259247,"question_id":67908927,"share_link":"https://stackoverflow.com/q/67908927","body_markdown":"Maybe it's something very easy to solve, but I haven't found the problem yet.\r\n\r\nI started to develop a Dashboard in ```Rmarkdown```, ```Flexdashboard``` and ```Shiny```. At some point I tried the **dark theme** and it seems that the navigation bar is in **dark mode** always, and everything else is in **"light" mode**, since I see it in purple color, and it seems to me that it should be orange.\r\n\r\nI attach a reference image.\r\n\r\n[![Flexdashboard][1]][1]\r\n\r\nI am using the **"United"** theme: https://bootswatch.com/united/\r\n\r\nHere is the YAML header:\r\n\r\n[![YAML][2]][2]\r\n\r\nDoes anyone know how to fix it? I don't see where the problem is.\r\n\r\n\r\nI remain attentive, best regards.\r\n\r\n\r\n [1]: https://i.stack.imgur.com/kwXJH.png\r\n [2]: https://i.stack.imgur.com/RR637.png","link":"https://stackoverflow.com/questions/67908927/a-part-of-a-flexdashboard-is-permanently-in-dark-mode-while-the-entire-dashboa","title":"A part of a flexdashboard is permanently in "Dark Mode" while the entire dashboard is in "Light Mode". How can I change it?","body":"Maybe it's something very easy to solve, but I haven't found the problem yet.
\nI started to develop a Dashboard in Rmarkdown
, Flexdashboard
and Shiny
. At some point I tried the dark theme and it seems that the navigation bar is in dark mode always, and everything else is in "light" mode, since I see it in purple color, and it seems to me that it should be orange.
I attach a reference image.
\n\nI am using the "United" theme: https://bootswatch.com/united/
\nHere is the YAML header:
\n\nDoes anyone know how to fix it? I don't see where the problem is.
\nI remain attentive, best regards.
\n"},{"tags":["javascript","html","css"],"owner":{"reputation":1,"user_id":16178312,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9041a8090d7aaca35694e6d18699a9a8?s=128&d=identicon&r=PG&f=1","display_name":"jb12","link":"https://stackoverflow.com/users/16178312/jb12"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623259246,"creation_date":1623259246,"question_id":67908926,"share_link":"https://stackoverflow.com/q/67908926","body_markdown":"the last tab titled contact me does not display any of its content when I click it. \r\n \r\n <body>\r\n <ul class="tabs">\r\n <li data-tab-target="#home" class="active tab">Home</li>\r\n <li data-tab-target="#pricing" class="tab">Pricing</li>\r\n <li data-tab-target="#about" class="tab">About</li>\r\n <li data-tab-target="#Contact Me" class="tab">Contact Me</li>\r\n </ul>\r\n \r\n <div class="tab-content">\r\n <div id="home" data-tab-content class="active">\r\n <h1>Home</h1>\r\n <p>This is the home</p>\r\n </div>\r\n <div id="pricing" data-tab-content>\r\n <h1>Pricing</h1>\r\n <p>Some information on pricing</p>\r\n </div>\r\n <div id="about" data-tab-content>\r\n <h1>About</h1>\r\n <p>Let me tell you about me</p>\r\n </div>\r\n <div id="Contact Me" data-tab-content>\r\n <h1>Contact</h1>\r\n <p>hello let me tell</p>\r\n </div>\r\n </div>\r\n \r\n </body>\r\n </html>\r\n \r\n \r\n JS: This is where the error(Uncaught TypeError: Cannot read property 'classList' of null) is and I am not sure what I am doing wrong. \r\n \r\n const tabs = document.querySelectorAll('[data-tab-target]')\r\n const tabContents = document.querySelectorAll('[data-tab-content]')\r\n \r\n tabs.forEach(tab => {\r\n tab.addEventListener('click', () => {\r\n const target = document.querySelector(tab.dataset.tabTarget)\r\n tabContents.forEach(tabContent => {\r\n tabContent.classList.remove('active')\r\n })\r\n tabs.forEach(tab => {\r\n tab.classList.remove('active')\r\n })\r\n tab.classList.add('active')\r\n target.classList.add('active')\r\n \r\n })\r\n })\r\n","link":"https://stackoverflow.com/questions/67908926/why-do-i-keep-getting-this-error-uncaught-typeerror-cannot-read-property-clas","title":"Why do I keep getting this error? Uncaught TypeError: Cannot read property 'classList' of null","body":"the last tab titled contact me does not display any of its content when I click it.
\n<body>\n <ul class="tabs">\n <li data-tab-target="#home" class="active tab">Home</li>\n <li data-tab-target="#pricing" class="tab">Pricing</li>\n <li data-tab-target="#about" class="tab">About</li>\n <li data-tab-target="#Contact Me" class="tab">Contact Me</li>\n </ul>\n \n <div class="tab-content">\n <div id="home" data-tab-content class="active">\n <h1>Home</h1>\n <p>This is the home</p>\n </div>\n <div id="pricing" data-tab-content>\n <h1>Pricing</h1>\n <p>Some information on pricing</p>\n </div>\n <div id="about" data-tab-content>\n <h1>About</h1>\n <p>Let me tell you about me</p>\n </div>\n <div id="Contact Me" data-tab-content>\n <h1>Contact</h1>\n <p>hello let me tell</p>\n </div>\n </div>\n\n</body>\n</html>\n
\nJS: This is where the error(Uncaught TypeError: Cannot read property 'classList' of null) is and I am not sure what I am doing wrong.
\nconst tabs = document.querySelectorAll('[data-tab-target]')\nconst tabContents = document.querySelectorAll('[data-tab-content]')\n\ntabs.forEach(tab => {\n tab.addEventListener('click', () => {\n const target = document.querySelector(tab.dataset.tabTarget)\n tabContents.forEach(tabContent => {\n tabContent.classList.remove('active')\n })\n tabs.forEach(tab => {\n tab.classList.remove('active')\n })\n tab.classList.add('active')\n target.classList.add('active')\n \n })\n})\n
\n"},{"tags":["javascript","jquery","ajax"],"owner":{"reputation":123,"user_id":11420295,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/28b47334053d432b7db43f2fcb94170f?s=128&d=identicon&r=PG&f=1","display_name":"master_j02","link":"https://stackoverflow.com/users/11420295/master-j02"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623259244,"creation_date":1623259244,"question_id":67908925,"share_link":"https://stackoverflow.com/q/67908925","body_markdown":"I am using Ajax to populate a global list of employees, which are able to be selected to use in a form. Now Everything works fine, but the only thing I would like to do is access a variable inside the Ajax request, to use in another function. The variable is a JavaScript object, which I would like to use to pre-populate the fields of the form with the employees data. I will shorten the HTML for better readability, and show the only field that I'm concerned about. \r\n\r\nThe `<input>` tag in the Ajax function calls the `addEmployee` function to add the employee in the backend. \r\n\r\n\r\n $("#email, #phone").change(function () {\r\n let phone = $('#phone').val();\r\n let email = $('#email').val();\r\n \r\n \r\n $.ajax({\r\n url: '/employee/add/',\r\n data: {\r\n 'phone': phone,\r\n 'email': email,\r\n },\r\n dataType: 'json',\r\n success: function (data) {\r\n if (data) {\r\n $('#employee_list').html("");\r\n let res = data.emp_list;\r\n if (res.length > 0) {\r\n for (let i = 0; i < res.length; i++) {\r\n let html_string = '';\r\n let data = res[i];\r\n //I would like to access this ^^ data variable in the addEmployee function\r\n \r\n html_string += '<input onchange="addEmployee(this)" type="checkbox" id="' + data.id + '" name="remember_me" value="' + data.id + '"' + (data.selected ? 'checked' : '') + '>'\r\n\r\n // There are a bunch of other html strings that just populate the list with the \r\n //data variable, and access that object properties, such as data.first_name, data.last_name etc.\r\n\r\n \r\n\r\n html = $.parseHTML(html_string);\r\n $('#employee_list').append(html);\r\n }\r\n \r\n } else {\r\n $("#emp-list-head").hide();\r\n \r\n }\r\n }\r\n }\r\n \r\n });\r\n \r\n });\r\n \r\n \r\n function addEmployee(checkbox) {\r\n if ($(checkbox).is(':checked')) {\r\n $("<input>").attr({\r\n name: "hidden_id",\r\n id: "hidden_id",\r\n type: "hidden",\r\n value: checkbox.value\r\n }).appendTo($('#add_employee_form'));\r\n // Down here I would like to access the data variable from the ajax function to prepopulate my form\r\n $('#emp_first_name').val(where I would like to access data.first_name);\r\n }\r\n } \r\n\r\n\r\nis this something that is possible, or would complete extra functionality be needed to access the `data` variable from the ajax function to use in the `addEmployee` function?\r\n\r\nI even tried adding the `data` object itself in a custom html `data-value` attribute like so, \r\n\r\n html_string += '<input onchange="addEmployee(this)" type="checkbox" id="' + data.id + '" name="remember_me" data-value="' + data + '"' + value="' + data.id + '"' + (data.selected ? 'checked' : '') + '>'\r\n\r\nthis returned the `data-value` as an [object Object] like so, \r\n\r\n <input onchange="addEmployee(this)" type="checkbox" id=3 name="remember_me" data-value="[object Object]" value=3>\r\n\r\nAny help is greatly appreciated!\r\n\r\n\r\n","link":"https://stackoverflow.com/questions/67908925/access-a-javascript-variable-in-an-ajax-request-to-use-inside-another-function","title":"Access a JavaScript variable in an Ajax request, to use inside another function?","body":"I am using Ajax to populate a global list of employees, which are able to be selected to use in a form. Now Everything works fine, but the only thing I would like to do is access a variable inside the Ajax request, to use in another function. The variable is a JavaScript object, which I would like to use to pre-populate the fields of the form with the employees data. I will shorten the HTML for better readability, and show the only field that I'm concerned about.
\nThe <input>
tag in the Ajax function calls the addEmployee
function to add the employee in the backend.
$("#email, #phone").change(function () {\n let phone = $('#phone').val();\n let email = $('#email').val();\n\n\n $.ajax({\n url: '/employee/add/',\n data: {\n 'phone': phone,\n 'email': email,\n },\n dataType: 'json',\n success: function (data) {\n if (data) {\n $('#employee_list').html("");\n let res = data.emp_list;\n if (res.length > 0) {\n for (let i = 0; i < res.length; i++) {\n let html_string = '';\n let data = res[i];\n //I would like to access this ^^ data variable in the addEmployee function\n\n html_string += '<input onchange="addEmployee(this)" type="checkbox" id="' + data.id + '" name="remember_me" value="' + data.id + '"' + (data.selected ? 'checked' : '') + '>'\n\n // There are a bunch of other html strings that just populate the list with the \n //data variable, and access that object properties, such as data.first_name, data.last_name etc.\n\n \n\n html = $.parseHTML(html_string);\n $('#employee_list').append(html);\n }\n\n } else {\n $("#emp-list-head").hide();\n\n }\n }\n }\n\n });\n\n});\n\n\nfunction addEmployee(checkbox) {\n if ($(checkbox).is(':checked')) {\n $("<input>").attr({\n name: "hidden_id",\n id: "hidden_id",\n type: "hidden",\n value: checkbox.value\n }).appendTo($('#add_employee_form'));\n // Down here I would like to access the data variable from the ajax function to prepopulate my form\n $('#emp_first_name').val(where I would like to access data.first_name);\n }\n} \n
\nis this something that is possible, or would complete extra functionality be needed to access the data
variable from the ajax function to use in the addEmployee
function?
I even tried adding the data
object itself in a custom html data-value
attribute like so,
html_string += '<input onchange="addEmployee(this)" type="checkbox" id="' + data.id + '" name="remember_me" data-value="' + data + '"' + value="' + data.id + '"' + (data.selected ? 'checked' : '') + '>'\n
\nthis returned the data-value
as an [object Object] like so,
<input onchange="addEmployee(this)" type="checkbox" id=3 name="remember_me" data-value="[object Object]" value=3>\n
\nAny help is greatly appreciated!
\n"},{"tags":["c","command-line-arguments"],"comments":[{"owner":{"reputation":10409,"user_id":1216776,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/504692de390dabd9ca22fd716e178993?s=128&d=identicon&r=PG","display_name":"stark","link":"https://stackoverflow.com/users/1216776/stark"},"edited":false,"score":1,"creation_date":1623258095,"post_id":67908589,"comment_id":120030217,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":298,"user_id":7242485,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8f1e2b806fd878ae104d6435ffe001ad?s=128&d=identicon&r=PG&f=1","display_name":"zBeeble","link":"https://stackoverflow.com/users/7242485/zbeeble"},"is_accepted":false,"score":0,"last_activity_date":1623258221,"creation_date":1623258221,"answer_id":67908690,"question_id":67908589,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":70259,"user_id":3422102,"user_type":"registered","accept_rate":100,"profile_image":"https://i.stack.imgur.com/Tg0Gt.png?s=128&g=1","display_name":"David C. Rankin","link":"https://stackoverflow.com/users/3422102/david-c-rankin"},"is_accepted":false,"score":0,"last_activity_date":1623259237,"creation_date":1623259237,"answer_id":67908924,"question_id":67908589,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16178169,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyGO2dy6KfymSm1J9AnFDkqcRib7NgpRr8YPxMM=k-s128","display_name":"Rakesh Sharma chemist","link":"https://stackoverflow.com/users/16178169/rakesh-sharma-chemist"},"is_answered":false,"view_count":23,"answer_count":2,"score":0,"last_activity_date":1623259237,"creation_date":1623257778,"question_id":67908589,"share_link":"https://stackoverflow.com/q/67908589","body_markdown":"i have been searched for this issue but didn't found any solution.\r\nActually i want to create a Compiled in C, and if i enter ant argument to that file then it forwards the argument to another command via system()\r\nLet me explain,\r\nsuppose, growkl is my C compiled file.\r\nand in terminal, i wrote this :\r\n\r\n growkl TRYNEW /etc/cron.d ./grill/mk\r\n\r\nand then, the growkl file will forward all these arguments ( TRYNEW /etc/cron.d ./grill/mk ) to the command **/usr/bin/gkbroot**\r\nIn this way :\r\n\r\n /usr/bin/gkbroot TRYNEW /etc/cron.d ./grill/mk\r\n\r\n\r\nI'm a newbie with these things, so I'm not getting how to do this.\r\nCan anyone tell me","link":"https://stackoverflow.com/questions/67908589/how-to-get-list-of-all-command-line-argument-and-forward-all-of-those-arguments","title":"How to get list of all command line argument and forward all of those arguments to another command in C","body":"i have been searched for this issue but didn't found any solution.\nActually i want to create a Compiled in C, and if i enter ant argument to that file then it forwards the argument to another command via system()\nLet me explain,\nsuppose, growkl is my C compiled file.\nand in terminal, i wrote this :
\ngrowkl TRYNEW /etc/cron.d ./grill/mk\n
\nand then, the growkl file will forward all these arguments ( TRYNEW /etc/cron.d ./grill/mk ) to the command /usr/bin/gkbroot\nIn this way :
\n/usr/bin/gkbroot TRYNEW /etc/cron.d ./grill/mk\n
\nI'm a newbie with these things, so I'm not getting how to do this.\nCan anyone tell me
\n"},{"tags":["google-apps-script","mathematical-optimization","or-tools"],"comments":[{"owner":{"reputation":2021,"user_id":7810777,"user_type":"registered","profile_image":"https://i.stack.imgur.com/EadKV.jpg?s=128&g=1","display_name":"Stradivari","link":"https://stackoverflow.com/users/7810777/stradivari"},"edited":false,"score":0,"creation_date":1623250719,"post_id":67904711,"comment_id":120026805,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":10974726,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Xpeou.jpg?s=128&g=1","display_name":"A. Albinus","link":"https://stackoverflow.com/users/10974726/a-albinus"},"is_answered":false,"view_count":23,"answer_count":0,"score":0,"last_activity_date":1623259237,"creation_date":1623243748,"last_edit_date":1623259237,"question_id":67904711,"share_link":"https://stackoverflow.com/q/67904711","body_markdown":"I need to solve an assignment problem with Google Apps Script. The [LinearOptimizationService][1] seemed to be promising so what I tried is to port a corresponding [example from the google or-tools][2] .\r\n\r\nUnfortunately, I couldn't find out a way how I set up the constraint that each worker is assigned to exactly one task.\r\n\r\n\r\nThe working code (without the constraint) is as follows:\r\n\r\n```\r\nfunction myFunction() {\r\n // Create the variables\r\n var engine = LinearOptimizationService.createEngine();\r\n \r\n const costMatrix = [[7,5,3,8,3]\r\n ,[2,5,6,7,1]\r\n ,[1,8,9,5,9]]\r\n\r\n const capacities = [1,1,1,1,1]\r\n\r\n // initialize the decision variables\r\n x = new Array(costMatrix.length);\r\n for (let i=0; i<costMatrix.length; i++){\r\n x[i] = new Array(costMatrix[0].length);\r\n for (let j=0; j<costMatrix[0].length; j++){\r\n x[i][j] = engine.addVariable(`x${i}${j}`, 0, 1, LinearOptimizationService.VariableType.INTEGER, costMatrix[i][j]);\r\n }\r\n }\r\n\r\n // Each worker is assigned to at most one task.\r\n for (let i = 0; i < costMatrix.length; ++i) {\r\n constraint = engine.addConstraint(1, 1);\r\n for (let j = 0; j < costMatrix[0].length; ++j) {\r\n let contraintVar = engine.addVariable(x[i][j],0,1)\r\n constraint.setCoefficient(contraintVar, 1);\r\n }\r\n }\r\n\r\n // Each task is assigned to exactly one worker.\r\n for (let j = 0; j < costMatrix[0].length; ++j) {\r\n constraint = engine.addConstraint(1, 1);\r\n for (let i = 0; i < costMatrix.length; ++i) {\r\n let contraintVar = engine.addVariable(x[i][j],0,1)\r\n Logger.log(contraintVar)\r\n constraint.setCoefficient(contraintVar, 1);\r\n }\r\n }\r\n\r\n for (let i = 0; i < costMatrix.length; ++i) {\r\n for (let j = 0; j < costMatrix[0].length; ++j) {\r\n engine.setObjectiveCoefficient(x[i][j], costMatrix[i][j]);\r\n }\r\n }\r\n\r\n engine.setMinimization()\r\n\r\n // Solve the linear program\r\n var solution = engine.solve();\r\n if (!solution.isValid()) {\r\n throw 'No solution ' + solution.getStatus();\r\n }\r\n Logger.log('ObjectiveValue: ' + solution.getObjectiveValue());\r\n for (let i=0; i<costMatrix.length; i++){\r\n for (let j=0; j<costMatrix[0].length; j++){\r\n Logger.log(`Value of: x${i}${j} ` + solution.getVariableValue(`x${i}${j}`));\r\n }\r\n }\r\n}\r\n```\r\nAny help is appreciated.\r\n\r\nThanks\r\n\r\n\r\n [1]: https://developers.google.com/apps-script/reference/optimization\r\n [2]: https://developers.google.com/optimization/assignment/assignment_example","link":"https://stackoverflow.com/questions/67904711/adding-constraints-in-google-apps-script-linear-optimization-service","title":"Adding Constraints in Google Apps Script Linear Optimization Service","body":"I need to solve an assignment problem with Google Apps Script. The LinearOptimizationService seemed to be promising so what I tried is to port a corresponding example from the google or-tools .
\nUnfortunately, I couldn't find out a way how I set up the constraint that each worker is assigned to exactly one task.
\nThe working code (without the constraint) is as follows:
\nfunction myFunction() {\n // Create the variables\n var engine = LinearOptimizationService.createEngine();\n \n const costMatrix = [[7,5,3,8,3]\n ,[2,5,6,7,1]\n ,[1,8,9,5,9]]\n\n const capacities = [1,1,1,1,1]\n\n // initialize the decision variables\n x = new Array(costMatrix.length);\n for (let i=0; i<costMatrix.length; i++){\n x[i] = new Array(costMatrix[0].length);\n for (let j=0; j<costMatrix[0].length; j++){\n x[i][j] = engine.addVariable(`x${i}${j}`, 0, 1, LinearOptimizationService.VariableType.INTEGER, costMatrix[i][j]);\n }\n }\n\n // Each worker is assigned to at most one task.\n for (let i = 0; i < costMatrix.length; ++i) {\n constraint = engine.addConstraint(1, 1);\n for (let j = 0; j < costMatrix[0].length; ++j) {\n let contraintVar = engine.addVariable(x[i][j],0,1)\n constraint.setCoefficient(contraintVar, 1);\n }\n }\n\n // Each task is assigned to exactly one worker.\n for (let j = 0; j < costMatrix[0].length; ++j) {\n constraint = engine.addConstraint(1, 1);\n for (let i = 0; i < costMatrix.length; ++i) {\n let contraintVar = engine.addVariable(x[i][j],0,1)\n Logger.log(contraintVar)\n constraint.setCoefficient(contraintVar, 1);\n }\n }\n\n for (let i = 0; i < costMatrix.length; ++i) {\n for (let j = 0; j < costMatrix[0].length; ++j) {\n engine.setObjectiveCoefficient(x[i][j], costMatrix[i][j]);\n }\n }\n\n engine.setMinimization()\n\n // Solve the linear program\n var solution = engine.solve();\n if (!solution.isValid()) {\n throw 'No solution ' + solution.getStatus();\n }\n Logger.log('ObjectiveValue: ' + solution.getObjectiveValue());\n for (let i=0; i<costMatrix.length; i++){\n for (let j=0; j<costMatrix[0].length; j++){\n Logger.log(`Value of: x${i}${j} ` + solution.getVariableValue(`x${i}${j}`));\n }\n }\n}\n
\nAny help is appreciated.
\nThanks
\n"},{"tags":["amazon-dynamodb","amazon-cloudformation","aws-cli"],"comments":[{"owner":{"reputation":16555,"user_id":2933177,"user_type":"registered","accept_rate":50,"profile_image":"https://i.stack.imgur.com/LRuRW.jpg?s=128&g=1","display_name":"Charles","link":"https://stackoverflow.com/users/2933177/charles"},"edited":false,"score":0,"creation_date":1623259224,"post_id":67908480,"comment_id":120030634,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":16555,"user_id":2933177,"user_type":"registered","accept_rate":50,"profile_image":"https://i.stack.imgur.com/LRuRW.jpg?s=128&g=1","display_name":"Charles","link":"https://stackoverflow.com/users/2933177/charles"},"is_accepted":false,"score":0,"last_activity_date":1623259237,"creation_date":1623259237,"answer_id":67908923,"question_id":67908480,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":80,"user_id":1671640,"user_type":"registered","accept_rate":88,"profile_image":"https://www.gravatar.com/avatar/31ab2686bf849ad0e31bbea0f78aa421?s=128&d=identicon&r=PG","display_name":"Patrick Taylor","link":"https://stackoverflow.com/users/1671640/patrick-taylor"},"is_answered":false,"view_count":8,"answer_count":1,"score":0,"last_activity_date":1623259237,"creation_date":1623257278,"question_id":67908480,"share_link":"https://stackoverflow.com/q/67908480","body_markdown":"I'm trying to implement a DynamoDB `get_item` call using <https://github.com/aws/aws-sdk-ruby/blob/0465bfacbf87e6bc78c38191961ed860413d85cd/gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb#L697> via our Ruby on Rails app, [dr-recommends](https://github.com/lampo/dr-recommends).\r\n\r\nFrom reviewing this DynamoDB CloudFormation stack that I wrote, I expect the following `get_item` call to work, so I'm a little lost as to how to proceed.\r\n\r\n```yml\r\nType: 'AWS::DynamoDB::Table'\r\nProperties:\r\n AttributeDefinitions:\r\n - AttributeName: 'pk'\r\n AttributeType: 'S'\r\n - AttributeName: 'sk'\r\n AttributeType: 'S'\r\n KeySchema:\r\n - KeyType: 'HASH'\r\n AttributeName: 'pk'\r\n - KeyType: 'RANGE'\r\n AttributeName: 'sk'\r\n BillingMode: 'PAY_PER_REQUEST'\r\n```\r\n\r\nDo you see anything here that would explain why the following call might not work?\r\n\r\n```bash\r\naws dynamodb get-item --table-name actual-table-name --key "{\\"pk\\":{\\"S\\":\\"77119f89-d5bc-4662-91bb-f3e81e1d9b21\\"}}" --projection-expression sk\r\n# An error occurred (ValidationException) when calling the GetItem operation: The provided key element does not match the schema\r\n```","link":"https://stackoverflow.com/questions/67908480/dynamodb-get-item-the-provided-key-element-does-not-match-the-schema","title":"DynamoDB get_item "The provided key element does not match the schema"","body":"I'm trying to implement a DynamoDB get_item
call using https://github.com/aws/aws-sdk-ruby/blob/0465bfacbf87e6bc78c38191961ed860413d85cd/gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/table.rb#L697 via our Ruby on Rails app, dr-recommends.
From reviewing this DynamoDB CloudFormation stack that I wrote, I expect the following get_item
call to work, so I'm a little lost as to how to proceed.
Type: 'AWS::DynamoDB::Table'\nProperties:\n AttributeDefinitions:\n - AttributeName: 'pk'\n AttributeType: 'S'\n - AttributeName: 'sk'\n AttributeType: 'S'\n KeySchema:\n - KeyType: 'HASH'\n AttributeName: 'pk'\n - KeyType: 'RANGE'\n AttributeName: 'sk'\n BillingMode: 'PAY_PER_REQUEST'\n
\nDo you see anything here that would explain why the following call might not work?
\naws dynamodb get-item --table-name actual-table-name --key "{\\"pk\\":{\\"S\\":\\"77119f89-d5bc-4662-91bb-f3e81e1d9b21\\"}}" --projection-expression sk\n# An error occurred (ValidationException) when calling the GetItem operation: The provided key element does not match the schema\n
\n"},{"tags":["c#","html","regex","string","replace"],"comments":[{"owner":{"reputation":2839,"user_id":470096,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/c88080fb2ed07fc23209593063e224ed?s=128&d=identicon&r=PG","display_name":"Mark PM","link":"https://stackoverflow.com/users/470096/mark-pm"},"edited":false,"score":1,"creation_date":1623251940,"post_id":67906850,"comment_id":120027404,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":503,"user_id":12107765,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/6dd4d1f63f1845902b761281f462226e?s=128&d=identicon&r=PG&f=1","display_name":"Klamsi","link":"https://stackoverflow.com/users/12107765/klamsi"},"edited":false,"score":0,"creation_date":1623252739,"post_id":67906850,"comment_id":120027814,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":86677,"user_id":880990,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/123d02be3a4fb6074b72b7e28bc05bad?s=128&d=identicon&r=PG","display_name":"Olivier Jacot-Descombes","link":"https://stackoverflow.com/users/880990/olivier-jacot-descombes"},"edited":false,"score":0,"creation_date":1623256716,"post_id":67906850,"comment_id":120029648,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":16176386,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/045e7356a66ea114e0bef422764b8358?s=128&d=identicon&r=PG&f=1","display_name":"Buckweed","link":"https://stackoverflow.com/users/16176386/buckweed"},"edited":false,"score":0,"creation_date":1623258297,"post_id":67906850,"comment_id":120030286,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":1,"user_id":16176386,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/045e7356a66ea114e0bef422764b8358?s=128&d=identicon&r=PG&f=1","display_name":"Buckweed","link":"https://stackoverflow.com/users/16176386/buckweed"},"is_accepted":false,"score":0,"last_activity_date":1623259237,"creation_date":1623259237,"answer_id":67908922,"question_id":67906850,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16176386,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/045e7356a66ea114e0bef422764b8358?s=128&d=identicon&r=PG&f=1","display_name":"Buckweed","link":"https://stackoverflow.com/users/16176386/buckweed"},"is_answered":false,"view_count":26,"answer_count":1,"score":-1,"last_activity_date":1623259237,"creation_date":1623251027,"last_edit_date":1623256251,"question_id":67906850,"share_link":"https://stackoverflow.com/q/67906850","body_markdown":"I would like to replace words in a html string with another word, but it must only replace the exact word and not if it is part of the spelling of part of a word. The problem that I am having is that the html open or closing tags or other html elements are affecting what words are matched in the regex or it is replacing parts of words.\r\n```\r\nPostTxt = “<div>The <b>cat</b> sat on the mat, what a catastrophe.\r\n The <span>cat</span> is not allowed on the mat. This makes things complicated; the cat  must go! \r\n</div><p>cat cat cat</p>”; \r\n\r\n\tstring pattern = "cat";\r\n\r\n\t//replacement string to use\r\n\tstring replacement = "******";\r\n\r\n\t//Replace words\r\n\tPostTxt = Regex.Replace(PostTxt, pattern, replacement, RegexOptions.IgnoreCase);\r\n}\r\n```\r\nI would like it to return.\r\n\r\n```<div>The <b>***</b> sat on the mat, what a catastrophe. The <span>***</span> is not allowed on the mat. This makes things complicated; the ***  must go! </div><p>*** *** ***</p>```\r\n\r\nAny suggestions and help will be greatly appreciated.\r\n\r\n","link":"https://stackoverflow.com/questions/67906850/using-regex-replace-to-replace-words-in-html-string-without-affecting-html-tags","title":"Using regex.replace to replace words in html string without affecting html tags and parts of words","body":"I would like to replace words in a html string with another word, but it must only replace the exact word and not if it is part of the spelling of part of a word. The problem that I am having is that the html open or closing tags or other html elements are affecting what words are matched in the regex or it is replacing parts of words.
\nPostTxt = “<div>The <b>cat</b> sat on the mat, what a catastrophe.\n The <span>cat</span> is not allowed on the mat. This makes things complicated; the cat  must go! \n</div><p>cat cat cat</p>”; \n\n string pattern = "cat";\n\n //replacement string to use\n string replacement = "******";\n\n //Replace words\n PostTxt = Regex.Replace(PostTxt, pattern, replacement, RegexOptions.IgnoreCase);\n}\n
\nI would like it to return.
\n<div>The <b>***</b> sat on the mat, what a catastrophe. The <span>***</span> is not allowed on the mat. This makes things complicated; the ***  must go! </div><p>*** *** ***</p>
Any suggestions and help will be greatly appreciated.
\n"},{"tags":["python","pygame"],"owner":{"reputation":1,"user_id":15963877,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJxIc502NFoQSWNOy5jJfL3qKmiIxqPRbDs5x5e1=k-s128","display_name":"Purple Purple","link":"https://stackoverflow.com/users/15963877/purple-purple"},"is_answered":false,"view_count":8,"answer_count":0,"score":0,"last_activity_date":1623259229,"creation_date":1623259229,"question_id":67908921,"share_link":"https://stackoverflow.com/q/67908921","body_markdown":"I was wondering how I could end the game or stop the game from running after the player sprite touches the other sprite or the variable platform12. The following is what I have done so far:\r\n\r\n``` \r\n platform12 = gameSprites.GameObject(pygame.Vector2(2600, 500), pygame.Vector2(150, 50), "diamond_ore.png")\r\n\r\n self.platforms.add(self.ground, platform1, platform2, platform3, platform4, platform5, platform6, platform7, platform8, platform9, platform10, platform11, platform12)\r\n\r\n #PLAYER\r\n self.player = gameSprites.Player(pygame.Vector2(0, 450), pygame.Vector2(30, 40), pygame.Vector2(0, 0), "steve.png")\r\n self.player_objects.add(self.player)","link":"https://stackoverflow.com/questions/67908921/how-to-end-the-game-once-it-has-touched-an-image-in-pygame","title":"How to end the game once it has touched an image in pygame","body":"I was wondering how I could end the game or stop the game from running after the player sprite touches the other sprite or the variable platform12. The following is what I have done so far:
\n platform12 = gameSprites.GameObject(pygame.Vector2(2600, 500), pygame.Vector2(150, 50), "diamond_ore.png")\n\n self.platforms.add(self.ground, platform1, platform2, platform3, platform4, platform5, platform6, platform7, platform8, platform9, platform10, platform11, platform12)\n\n #PLAYER\n self.player = gameSprites.Player(pygame.Vector2(0, 450), pygame.Vector2(30, 40), pygame.Vector2(0, 0), "steve.png")\n self.player_objects.add(self.player)\n
\n"},{"tags":["reactjs","svg"],"comments":[{"owner":{"reputation":46038,"user_id":1264804,"user_type":"registered","accept_rate":61,"profile_image":"https://i.stack.imgur.com/oYX71.png?s=128&g=1","display_name":"isherwood","link":"https://stackoverflow.com/users/1264804/isherwood"},"edited":false,"score":0,"creation_date":1623255994,"post_id":67908128,"comment_id":120029295,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":7110,"user_id":2520800,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/60edc4072807728bf0f69a8af73f716c?s=128&d=identicon&r=PG","display_name":"Danny '365CSI' Engelman","link":"https://stackoverflow.com/users/2520800/danny-365csi-engelman"},"is_accepted":false,"score":0,"last_activity_date":1623259228,"creation_date":1623259228,"answer_id":67908920,"question_id":67908128,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":179,"user_id":14838495,"user_type":"registered","profile_image":"https://graph.facebook.com/10160508779911982/picture?type=large","display_name":"Jon","link":"https://stackoverflow.com/users/14838495/jon"},"is_answered":false,"view_count":16,"answer_count":1,"score":0,"last_activity_date":1623259228,"creation_date":1623255899,"question_id":67908128,"share_link":"https://stackoverflow.com/q/67908128","body_markdown":"I am using a git repository to display a chessboard:\r\n\r\nhttps://github.com/shaack/cm-chessboard\r\n\r\nAn example of the displayed chessboard can be found here:\r\n\r\nhttps://shaack.com/projekte/cm-chessboard/\r\n\r\nMy goal is to display some text over a square of my choice, which would display over the piece if it is present. So I presume that involves some kind of z-index on the svg.\r\n\r\nI've done inspect on the chessboard to see what the source code looks like, but I am at a loss for how to add a function that works like this:\r\n\r\n`function(coordinate,text)`, where coordinate could be something like c2.\r\n\r\nHow would you go about creating this function? \r\n\r\nI am at a loss of where to start. I've been looking at the source code in the git file and commenting the code to get a better understanding. Ideally I would like a function that doesn't alter the git repository, because then if they do an update, my code won't break. Maybe I need to add a function that modifies the instance of the board object.\r\n\r\nAny help is greatly appreciated.","link":"https://stackoverflow.com/questions/67908128/placing-text-over-svg-image","title":"Placing text over svg image","body":"I am using a git repository to display a chessboard:
\nhttps://github.com/shaack/cm-chessboard
\nAn example of the displayed chessboard can be found here:
\nhttps://shaack.com/projekte/cm-chessboard/
\nMy goal is to display some text over a square of my choice, which would display over the piece if it is present. So I presume that involves some kind of z-index on the svg.
\nI've done inspect on the chessboard to see what the source code looks like, but I am at a loss for how to add a function that works like this:
\nfunction(coordinate,text)
, where coordinate could be something like c2.
How would you go about creating this function?
\nI am at a loss of where to start. I've been looking at the source code in the git file and commenting the code to get a better understanding. Ideally I would like a function that doesn't alter the git repository, because then if they do an update, my code won't break. Maybe I need to add a function that modifies the instance of the board object.
\nAny help is greatly appreciated.
\n"},{"tags":["c"],"comments":[{"owner":{"reputation":97663,"user_id":189205,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/c60305494593d556e57a3cf8e4a8c163?s=128&d=identicon&r=PG","display_name":"interjay","link":"https://stackoverflow.com/users/189205/interjay"},"edited":false,"score":2,"creation_date":1623259036,"post_id":67908856,"comment_id":120030560,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":359,"user_id":5921662,"user_type":"registered","profile_image":"https://i.stack.imgur.com/tE9oj.jpg?s=128&g=1","display_name":"Sudipto","link":"https://stackoverflow.com/users/5921662/sudipto"},"edited":false,"score":1,"creation_date":1623259057,"post_id":67908856,"comment_id":120030568,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":108926,"user_id":364696,"user_type":"registered","profile_image":"https://i.stack.imgur.com/7eBCp.jpg?s=128&g=1","display_name":"ShadowRanger","link":"https://stackoverflow.com/users/364696/shadowranger"},"edited":false,"score":1,"creation_date":1623259060,"post_id":67908856,"comment_id":120030569,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":2133,"user_id":14215102,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ab57304b45cb91a383bcca55e5a23d77?s=128&d=identicon&r=PG&f=1","display_name":"dratenik","link":"https://stackoverflow.com/users/14215102/dratenik"},"edited":false,"score":0,"creation_date":1623259142,"post_id":67908856,"comment_id":120030596,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":15387772,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Gi-5nN1YGyxyaKYJqKwvLHjIZNmsqUO5ApR2LjTnA=k-s128","display_name":"CodeBeginner","link":"https://stackoverflow.com/users/15387772/codebeginner"},"edited":false,"score":0,"creation_date":1623259160,"post_id":67908856,"comment_id":120030608,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":108926,"user_id":364696,"user_type":"registered","profile_image":"https://i.stack.imgur.com/7eBCp.jpg?s=128&g=1","display_name":"ShadowRanger","link":"https://stackoverflow.com/users/364696/shadowranger"},"edited":false,"score":2,"creation_date":1623259247,"post_id":67908856,"comment_id":120030642,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":598476,"user_id":1491895,"user_type":"registered","accept_rate":69,"profile_image":"https://www.gravatar.com/avatar/82f9e178a16364bf561d0ed4da09a35d?s=128&d=identicon&r=PG","display_name":"Barmar","link":"https://stackoverflow.com/users/1491895/barmar"},"edited":false,"score":1,"creation_date":1623259252,"post_id":67908856,"comment_id":120030645,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":49503,"user_id":13422,"user_type":"registered","accept_rate":50,"profile_image":"https://www.gravatar.com/avatar/94b309d78a1253a334e9b82643a8dc97?s=128&d=identicon&r=PG","display_name":"Zan Lynx","link":"https://stackoverflow.com/users/13422/zan-lynx"},"edited":false,"score":0,"creation_date":1623259407,"post_id":67908856,"comment_id":120030707,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":2879,"user_id":9829403,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-RvgmsYSS48c/AAAAAAAAAAI/AAAAAAAAAAw/pUPnPAhmDec/photo.jpg?sz=128","display_name":"Tim Randall","link":"https://stackoverflow.com/users/9829403/tim-randall"},"is_accepted":false,"score":1,"last_activity_date":1623259213,"creation_date":1623259213,"answer_id":67908915,"question_id":67908856,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":15387772,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Gi-5nN1YGyxyaKYJqKwvLHjIZNmsqUO5ApR2LjTnA=k-s128","display_name":"CodeBeginner","link":"https://stackoverflow.com/users/15387772/codebeginner"},"is_answered":true,"view_count":27,"closed_date":1623259223,"answer_count":1,"score":0,"last_activity_date":1623259226,"creation_date":1623258902,"last_edit_date":1623259226,"question_id":67908856,"share_link":"https://stackoverflow.com/q/67908856","body_markdown":"Why does C doesn't accept 08 and 09 as an integer? Are there ways that I could still validate the 08 and 09 as an integer?\r\n\r\n```\r\nint main(){\r\nint a;\r\nscanf("%i", &a);\r\n\r\nif (a== 8 || a==08){\r\n printf("Octagon");\r\n}\r\nelse if (a== 9 || a==09){\r\n printf("Nonagon");\r\n}\r\n\r\nreturn 0;\r\n}","link":"https://stackoverflow.com/questions/67908856/invalid-integer-in-c","closed_reason":"Duplicate","title":"Invalid integer in C","body":"Why does C doesn't accept 08 and 09 as an integer? Are there ways that I could still validate the 08 and 09 as an integer?
\nint main(){\nint a;\nscanf("%i", &a);\n\nif (a== 8 || a==08){\n printf("Octagon");\n}\nelse if (a== 9 || a==09){\n printf("Nonagon");\n}\n\nreturn 0;\n}\n
\n"},{"tags":["python","regex","pandas"],"answers":[{"owner":{"reputation":970,"user_id":2271478,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1e6d2741f690d245b2786ac0f6e8dde8?s=128&d=identicon&r=PG","display_name":"xyzjayne","link":"https://stackoverflow.com/users/2271478/xyzjayne"},"is_accepted":false,"score":0,"last_activity_date":1623259017,"creation_date":1623259017,"answer_id":67908876,"question_id":67908812,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":486914,"user_id":3832970,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/64323e6cf08401474da3bf770ea13b58?s=128&d=identicon&r=PG&f=1","display_name":"Wiktor Stribiżew","link":"https://stackoverflow.com/users/3832970/wiktor-stribi%c5%bcew"},"is_accepted":false,"score":0,"last_activity_date":1623259225,"creation_date":1623259225,"answer_id":67908919,"question_id":67908812,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16177905,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyWv8uOc571fGG9CVREGPBIHMYemsc9IdqhsfI=k-s128","display_name":"MountainFish","link":"https://stackoverflow.com/users/16177905/mountainfish"},"is_answered":false,"view_count":17,"answer_count":2,"score":0,"last_activity_date":1623259225,"creation_date":1623258727,"last_edit_date":1623258888,"question_id":67908812,"share_link":"https://stackoverflow.com/q/67908812","body_markdown":"The following string is a typical example of the format of strings that I need to convert to a PD DataFrame. My attempted work flow is to:\r\n\r\n1. Split String into List (see string below, note this represents an individual row)\r\n2. Convert each list to a dictionary\r\n3. Convert dictionary to a PD DataFrame\r\n4. Merge DataFrames together\r\n\r\n**String:** (Representing one row of Data)\r\n```\r\n"PN_#":9999,"Item":"Pear, Large","Vendor":["Farm"],"Class":["Food","Fruit"],"Sales Group":"59","Vendor ID (from Vendor)":[78]\r\n```\r\n**Desired Output:**\r\n```\r\n{'PN_#':9999,\r\n'Item':"Pear, Large",\r\n'Vendor':"Farm",\r\n'Class':"Food,Fruit",\r\n'Sales Group':59,\r\n'```\r\nVendor ID (from Vendor)':78}\r\n```\r\n\r\n**Attempt:**\r\nI have been using re.split to attempt this. For most cases this is not an issue, however the items such as *"Class":["Food","Fruit"]* and `"Item":"Pear, Large"` are proving to be challenging to account for.\r\n\r\nThis regex solves the issues of the later case, however it obviously does not work for the former:\r\n\r\n```\r\nre.split("(?=[\\S]),(?=[\\S])",data)\r\n```\r\n\r\nI have tried a multitude of expressions to completely satisfy my requirements. The following expression is generally representative of what I have attempted unsuccessfully:\r\n\r\n```\r\nregex.split("(?!\\[.+?\\s),(?=[\\S])(?!.+?\\])", data)\r\n```\r\n\r\nAny suggestion or solutions for how to accomplish this, or suggestion if I am going about this the wrong way?\r\n\r\nRegards\r\n\r\n\r\n","link":"https://stackoverflow.com/questions/67908812/regex-match-for-variable-string-issue-regarding-look-ahead-and-quantifiers","title":"Regex Match for Variable String - Issue Regarding Look Ahead and Quantifiers","body":"The following string is a typical example of the format of strings that I need to convert to a PD DataFrame. My attempted work flow is to:
\nString: (Representing one row of Data)
\n"PN_#":9999,"Item":"Pear, Large","Vendor":["Farm"],"Class":["Food","Fruit"],"Sales Group":"59","Vendor ID (from Vendor)":[78]\n
\nDesired Output:
\n{'PN_#':9999,\n'Item':"Pear, Large",\n'Vendor':"Farm",\n'Class':"Food,Fruit",\n'Sales Group':59,\n'```\nVendor ID (from Vendor)':78}\n
\nAttempt:\nI have been using re.split to attempt this. For most cases this is not an issue, however the items such as "Class":["Food","Fruit"] and "Item":"Pear, Large"
are proving to be challenging to account for.
This regex solves the issues of the later case, however it obviously does not work for the former:
\nre.split("(?=[\\S]),(?=[\\S])",data)\n
\nI have tried a multitude of expressions to completely satisfy my requirements. The following expression is generally representative of what I have attempted unsuccessfully:
\nregex.split("(?!\\[.+?\\s),(?=[\\S])(?!.+?\\])", data)\n
\nAny suggestion or solutions for how to accomplish this, or suggestion if I am going about this the wrong way?
\nRegards
\n"},{"tags":["microsoft-graph-api","sharepoint-online"],"owner":{"reputation":115,"user_id":8706053,"user_type":"registered","profile_image":"https://i.stack.imgur.com/nCWrM.jpg?s=128&g=1","display_name":"Dave Guenther","link":"https://stackoverflow.com/users/8706053/dave-guenther"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259224,"creation_date":1623259224,"question_id":67908918,"share_link":"https://stackoverflow.com/q/67908918","body_markdown":"After watching the Microsoft video on [this page][1], I decided that I should start testing for server-side pagination by looking for @odata.nextLink fields in all my Graph API (v1.0) query responses, particularly on SharePoint resources. [In the video at about 1:38s][2], one of the presenters says that the nextLink is "typically" placed next to the collection in the response. So far, this is what I have encountered when I analyze the json response of the queries: the collection field is placed immediately after the @odata.nextLink field in the json object. However, I am a little concerned about the presenters choice of words ("typically"). <b>Can I expect this to always be the case though with Graph API?</b>\r\n\r\nI would like to know if I can build my query algorithm such that whenever I encounter a nextLink, I look to the next field to be the collection that I'll perform concatenation on when visiting the nextLink fields, or if there are cases that will break the algorithm.\r\n\r\nThank you.\r\n\r\n\r\n [1]: https://docs.microsoft.com/en-us/graph/paging\r\n [2]: https://youtu.be/DB_NoC9a1JI?t=98","link":"https://stackoverflow.com/questions/67908918/can-i-expect-when-handling-pagination-in-ms-graph-that-a-nextlink-will-always","title":"Can I expect when handling pagination in MS Graph, that a 'nextLink' will always be directly before the collection in a json object response?","body":"After watching the Microsoft video on this page, I decided that I should start testing for server-side pagination by looking for @odata.nextLink fields in all my Graph API (v1.0) query responses, particularly on SharePoint resources. In the video at about 1:38s, one of the presenters says that the nextLink is "typically" placed next to the collection in the response. So far, this is what I have encountered when I analyze the json response of the queries: the collection field is placed immediately after the @odata.nextLink field in the json object. However, I am a little concerned about the presenters choice of words ("typically"). Can I expect this to always be the case though with Graph API?
\nI would like to know if I can build my query algorithm such that whenever I encounter a nextLink, I look to the next field to be the collection that I'll perform concatenation on when visiting the nextLink fields, or if there are cases that will break the algorithm.
\nThank you.
\n"},{"tags":["python"],"comments":[{"owner":{"reputation":98575,"user_id":2296458,"user_type":"registered","accept_rate":90,"profile_image":"https://i.stack.imgur.com/wbG2s.png?s=128&g=1","display_name":"Cory Kramer","link":"https://stackoverflow.com/users/2296458/cory-kramer"},"edited":false,"score":3,"creation_date":1623249071,"post_id":67906180,"comment_id":120026022,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":3,"user_id":16176693,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyqKSiBG8oTXM3MUAUA1Wzcrt6hB2zaUXMy1tle=k-s128","display_name":"Mike Little","link":"https://stackoverflow.com/users/16176693/mike-little"},"reply_to_user":{"reputation":98575,"user_id":2296458,"user_type":"registered","accept_rate":90,"profile_image":"https://i.stack.imgur.com/wbG2s.png?s=128&g=1","display_name":"Cory Kramer","link":"https://stackoverflow.com/users/2296458/cory-kramer"},"edited":false,"score":0,"creation_date":1623256535,"post_id":67906180,"comment_id":120029555,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":98575,"user_id":2296458,"user_type":"registered","accept_rate":90,"profile_image":"https://i.stack.imgur.com/wbG2s.png?s=128&g=1","display_name":"Cory Kramer","link":"https://stackoverflow.com/users/2296458/cory-kramer"},"is_accepted":true,"score":3,"last_activity_date":1623249469,"last_edit_date":1623249469,"creation_date":1623249001,"answer_id":67906239,"question_id":67906180,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":55,"user_id":16131339,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GjMn92qyd_7sDPFAMqkgAHEvRlcsk9trV6xYqmm=k-s128","display_name":"Danish Khan","link":"https://stackoverflow.com/users/16131339/danish-khan"},"is_accepted":false,"score":-2,"last_activity_date":1623259224,"last_edit_date":1623259224,"creation_date":1623249251,"answer_id":67906310,"question_id":67906180,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":24,"user_id":13748961,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/7ef91c6837324a72ac72953e6ce23c4b?s=128&d=identicon&r=PG&f=1","display_name":"Mayank","link":"https://stackoverflow.com/users/13748961/mayank"},"is_accepted":false,"score":-1,"last_activity_date":1623249417,"creation_date":1623249417,"answer_id":67906354,"question_id":67906180,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":3,"user_id":16176693,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyqKSiBG8oTXM3MUAUA1Wzcrt6hB2zaUXMy1tle=k-s128","display_name":"Mike Little","link":"https://stackoverflow.com/users/16176693/mike-little"},"is_answered":true,"view_count":44,"accepted_answer_id":67906239,"answer_count":3,"score":0,"last_activity_date":1623259224,"creation_date":1623248828,"last_edit_date":1623248935,"question_id":67906180,"share_link":"https://stackoverflow.com/q/67906180","body_markdown":"How can I convert a date into a numeric date?\r\n\r\nFor example, I want to convert `'06-Jun-2021'` to `'20210609'` and then turn it into a string i can use in a webpage eg. `baseball.theater/games/20210609` so that i can automate the process daily.\r\n\r\nusing datetime i've managed to do :\r\n\r\n print (todays_date.year,todays_date.month,todays_date.day,sep="")\r\n\r\nwhich can print the output i need (without the trailing 0's) but i cannot make this into a string which i can use.\r\n\r\nobviously i am a COMPLETE newcomer to python, so be gentle please.","link":"https://stackoverflow.com/questions/67906180/convert-a-date-into-numeric-string","title":"convert a date into numeric string","body":"How can I convert a date into a numeric date?
\nFor example, I want to convert '06-Jun-2021'
to '20210609'
and then turn it into a string i can use in a webpage eg. baseball.theater/games/20210609
so that i can automate the process daily.
using datetime i've managed to do :
\nprint (todays_date.year,todays_date.month,todays_date.day,sep="")\n
\nwhich can print the output i need (without the trailing 0's) but i cannot make this into a string which i can use.
\nobviously i am a COMPLETE newcomer to python, so be gentle please.
\n"},{"tags":["mqtt","mosquitto"],"comments":[{"owner":{"reputation":41290,"user_id":504554,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/006ffde9ed3fac6396222405fc5e9bf0?s=128&d=identicon&r=PG","display_name":"hardillb","link":"https://stackoverflow.com/users/504554/hardillb"},"edited":false,"score":1,"creation_date":1623181382,"post_id":67891825,"comment_id":120004496,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":41290,"user_id":504554,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/006ffde9ed3fac6396222405fc5e9bf0?s=128&d=identicon&r=PG","display_name":"hardillb","link":"https://stackoverflow.com/users/504554/hardillb"},"edited":false,"score":1,"creation_date":1623181481,"post_id":67891825,"comment_id":120004531,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":16009708,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/039a40b7aaea93d5a3da1a23e0402eee?s=128&d=identicon&r=PG&f=1","display_name":"KevinAle21","link":"https://stackoverflow.com/users/16009708/kevinale21"},"reply_to_user":{"reputation":41290,"user_id":504554,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/006ffde9ed3fac6396222405fc5e9bf0?s=128&d=identicon&r=PG","display_name":"hardillb","link":"https://stackoverflow.com/users/504554/hardillb"},"edited":false,"score":0,"creation_date":1623254775,"post_id":67891825,"comment_id":120028757,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":1,"user_id":16009708,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/039a40b7aaea93d5a3da1a23e0402eee?s=128&d=identicon&r=PG&f=1","display_name":"KevinAle21","link":"https://stackoverflow.com/users/16009708/kevinale21"},"reply_to_user":{"reputation":41290,"user_id":504554,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/006ffde9ed3fac6396222405fc5e9bf0?s=128&d=identicon&r=PG","display_name":"hardillb","link":"https://stackoverflow.com/users/504554/hardillb"},"edited":false,"score":0,"creation_date":1623255196,"post_id":67891825,"comment_id":120028935,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":41290,"user_id":504554,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/006ffde9ed3fac6396222405fc5e9bf0?s=128&d=identicon&r=PG","display_name":"hardillb","link":"https://stackoverflow.com/users/504554/hardillb"},"edited":false,"score":0,"creation_date":1623258142,"post_id":67891825,"comment_id":120030235,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16009708,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/039a40b7aaea93d5a3da1a23e0402eee?s=128&d=identicon&r=PG&f=1","display_name":"KevinAle21","link":"https://stackoverflow.com/users/16009708/kevinale21"},"is_answered":false,"view_count":21,"answer_count":0,"score":0,"last_activity_date":1623259219,"creation_date":1623173164,"last_edit_date":1623259219,"question_id":67891825,"share_link":"https://stackoverflow.com/q/67891825","body_markdown":"I am struggling with a weird issue on my Mosquitto Broker that occurs after I enable logging using the configuration below.\r\nI'm using MQTT explorer to monitor my broker; after changing the configuration I started experiencing problems, monitor constantly said this: \r\n\r\n![enter image description here][1]\r\n\r\n\r\n [1]: https://i.stack.imgur.com/KTaVI.png\r\n\r\n\r\nIf I delete the line `log_dest file C:\\Archivos de programa\\mosquitto\\mosquitto.log` it seems to be fixed. \r\n\r\nI was adding the `log_dest` because I can not find the log file, please help me locate it.\r\n\r\nConfiguration File:\r\n```\r\n# Note that if the broker is running as a Windows service it will default to\r\n# "log_dest none" and neither stdout nor stderr logging is available.\r\n# Use "log_dest none" if you wish to disable logging.\r\n#log_dest none \r\nlog_dest topic \r\nlog_dest syslog \r\nlog_dest file C:\\Archivos de programa\\mosquitto\\mosquitto.log \r\n```\r\n\r\n","link":"https://stackoverflow.com/questions/67891825/mosquitto-configuration-log-issues","title":"Mosquitto configuration log issues","body":"I am struggling with a weird issue on my Mosquitto Broker that occurs after I enable logging using the configuration below.\nI'm using MQTT explorer to monitor my broker; after changing the configuration I started experiencing problems, monitor constantly said this:
\n\nIf I delete the line log_dest file C:\\Archivos de programa\\mosquitto\\mosquitto.log
it seems to be fixed.
I was adding the log_dest
because I can not find the log file, please help me locate it.
Configuration File:
\n# Note that if the broker is running as a Windows service it will default to\n# "log_dest none" and neither stdout nor stderr logging is available.\n# Use "log_dest none" if you wish to disable logging.\n#log_dest none \nlog_dest topic \nlog_dest syslog \nlog_dest file C:\\Archivos de programa\\mosquitto\\mosquitto.log \n
\n"},{"tags":["autodesk-forge","autodesk-viewer"],"owner":{"reputation":1,"user_id":5257876,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/22d0eba133c308f160f7d3dbf908840d?s=128&d=identicon&r=PG","display_name":"M.A.T","link":"https://stackoverflow.com/users/5257876/m-a-t"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623259218,"creation_date":1623259218,"question_id":67908916,"share_link":"https://stackoverflow.com/q/67908916","body_markdown":"Is there any way to disable the Thumbnails tab of `Autodesk.DocumentBrowser` extension?","link":"https://stackoverflow.com/questions/67908916/disabling-thumbnails-tab-of-document-browser-in-autodesk-forge","title":"Disabling Thumbnails tab of Document Browser in Autodesk Forge","body":"Is there any way to disable the Thumbnails tab of Autodesk.DocumentBrowser
extension?
I am working in Java and I want to make a deep copy of a MoleculeDTO object. I tried to make a copy constructor too, but it is not working and it is refering to the initial object.
\npublic class MoleculeDTO {\n private int ID;\n private String name;\n private List<AtomDTO> atoms = new ArrayList<>();\n private int nrAtoms =0;\n\n public MoleculeDTO(String name, List<AtomDTO> atoms, int nrAtoms) {\n this.name = name;\n this.atoms = atoms;\n this.nrAtoms = nrAtoms;\n }\n\n public MoleculeDTO(MoleculeDTO molecule) {\n this(molecule.getName(), molecule.getAtoms(), molecule.getNrAtoms());\n }\n...getter, setter\n}\n
\nHere is class AtomDTO.
\npublic class AtomDTO{\n private int ID;\n private String name;\n private String symbol;\n private int nrOfBonds;\n private List<BondDTO> bonds = new ArrayList<>();\n private int type;\n private AnchorNode anchorNode;\n\n\n public AtomDTO(String name, String symbol, int nrOfBonds, List<BondDTO> bonds, int type) {\n this.name = name;\n this.nrOfBonds = nrOfBonds;\n this.bonds = bonds;\n this.type = type;\n }\n\n public AtomDTO(AtomDTO copyAtom) {\n this(copyAtom.getName(),copyAtom.getSymbol(), copyAtom.getNrOfBonds(), copyAtom.getBonds(), copyAtom.getType());\n }\n...getter, setter\n}\n
\nHere is class BondDTO.
\npublic class BondDTO {\n private int ID;\n private int otherAtomID;\n private int otherAtomType;\n private int bondType;\n\n public BondDTO(int otherAtomID, int otherAtomType, int bondType) {\n this.otherAtomID = otherAtomID;\n this.otherAtomType = otherAtomType;\n this.bondType = bondType;\n }\n\n public BondDTO(BondDTO copyBond) {\n this(copyBond.getOtherAtomID(), copyBond.otherAtomType, copyBond.bondType);\n }\n...getter, setter\n}\n
\n"},{"tags":["java","split","awt"],"comments":[{"owner":{"reputation":46721,"user_id":3890632,"user_type":"registered","profile_image":"https://i.stack.imgur.com/hNkgF.png?s=128&g=1","display_name":"khelwood","link":"https://stackoverflow.com/users/3890632/khelwood"},"edited":false,"score":1,"creation_date":1623257048,"post_id":67908388,"comment_id":120029792,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":676524,"user_id":335858,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/4af3541c00d591e9a518b9c0b3b1190a?s=128&d=identicon&r=PG","display_name":"Sergey Kalinichenko","link":"https://stackoverflow.com/users/335858/sergey-kalinichenko"},"edited":false,"score":0,"creation_date":1623257359,"post_id":67908388,"comment_id":120029916,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":609,"user_id":12764490,"user_type":"registered","profile_image":"https://i.stack.imgur.com/nATZu.jpg?s=128&g=1","display_name":"Tim Hunter","link":"https://stackoverflow.com/users/12764490/tim-hunter"},"edited":false,"score":0,"creation_date":1623257780,"post_id":67908388,"comment_id":120030109,"content_license":"CC BY-SA 4.0"},{"owner":{"reputation":11,"user_id":14603352,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-DDu8Hn64Gf0/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuck79kly9Wf0I6tmJuo2ncRJdrglnA/s96-c/photo.jpg?sz=128","display_name":"Aishwarya Roy","link":"https://stackoverflow.com/users/14603352/aishwarya-roy"},"reply_to_user":{"reputation":609,"user_id":12764490,"user_type":"registered","profile_image":"https://i.stack.imgur.com/nATZu.jpg?s=128&g=1","display_name":"Tim Hunter","link":"https://stackoverflow.com/users/12764490/tim-hunter"},"edited":false,"score":0,"creation_date":1623258619,"post_id":67908388,"comment_id":120030402,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":609,"user_id":12764490,"user_type":"registered","profile_image":"https://i.stack.imgur.com/nATZu.jpg?s=128&g=1","display_name":"Tim Hunter","link":"https://stackoverflow.com/users/12764490/tim-hunter"},"is_accepted":false,"score":0,"last_activity_date":1623259209,"creation_date":1623259209,"answer_id":67908914,"question_id":67908388,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":11,"user_id":14603352,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-DDu8Hn64Gf0/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuck79kly9Wf0I6tmJuo2ncRJdrglnA/s96-c/photo.jpg?sz=128","display_name":"Aishwarya Roy","link":"https://stackoverflow.com/users/14603352/aishwarya-roy"},"is_answered":false,"view_count":13,"answer_count":1,"score":0,"last_activity_date":1623259209,"creation_date":1623256908,"last_edit_date":1623258857,"question_id":67908388,"share_link":"https://stackoverflow.com/q/67908388","body_markdown":"Whenever I write \\\\\\S (caps S) , then I get output 13, \r\nCan anyone tell me how this count 13, I mean why it just remove the last word?\r\n\r\n \r\n\r\n public void actionPerformed(ActionEvent e){\r\n String Text = area.getText();\r\n String words[]=Text.split("\\\\S");\r\n l1.setText("Words : "+words.length);\r\n l2.setText("Character : "+Text.length());\r\n }\r\n\r\n\r\nI use ActionListener for a AWT program,\r\n\r\nThis code has the counting for words and characters, \r\nBut I just want to know why it shows 13 words, I mean, \\\\\\\\S split the words, but why it do not count the last word, and just count the all character without the last word?","link":"https://stackoverflow.com/questions/67908388/counting-mechanism-of-capital-s-in-split-function-in-java","title":"Counting mechanism of Capital S in split function in Java","body":"Whenever I write \\\\S (caps S) , then I get output 13,\nCan anyone tell me how this count 13, I mean why it just remove the last word?
\npublic void actionPerformed(ActionEvent e){\n String Text = area.getText();\n String words[]=Text.split("\\\\S");\n l1.setText("Words : "+words.length);\n l2.setText("Character : "+Text.length());\n}\n
\nI use ActionListener for a AWT program,
\nThis code has the counting for words and characters,\nBut I just want to know why it shows 13 words, I mean, \\\\S split the words, but why it do not count the last word, and just count the all character without the last word?
\n"},{"tags":["docker","dockerfile"],"owner":{"reputation":1,"user_id":16178284,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/94db5172a27f96bc548a4ed14928c84f?s=128&d=identicon&r=PG&f=1","display_name":"usamawaqar","link":"https://stackoverflow.com/users/16178284/usamawaqar"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623259204,"creation_date":1623259204,"question_id":67908912,"share_link":"https://stackoverflow.com/q/67908912","body_markdown":"Whenever i try to build a simple container of c++ hello world file through remote container following error show up which is in the link below.\r\n[1]: https://i.stack.imgur.com/8wzXJ.png\r\n\r\nIt does not allow to build a simple c++ hello world file as a container. I am ubuntu 20.04.2.0 and vscode as a development tool.\r\nThanks for your help.\r\n\r\n\r\n","link":"https://stackoverflow.com/questions/67908912/remote-container-failed-to-build","title":"Remote Container failed to build","body":"Whenever i try to build a simple container of c++ hello world file through remote container following error show up which is in the link below.\n[1]: https://i.stack.imgur.com/8wzXJ.png
\nIt does not allow to build a simple c++ hello world file as a container. I am ubuntu 20.04.2.0 and vscode as a development tool.\nThanks for your help.
\n"},{"tags":["java","anylogic"],"answers":[{"owner":{"reputation":581,"user_id":13755144,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Zcx5k.jpg?s=128&g=1","display_name":"Emile Zankoul","link":"https://stackoverflow.com/users/13755144/emile-zankoul"},"is_accepted":false,"score":0,"last_activity_date":1623241340,"creation_date":1623241340,"answer_id":67904057,"question_id":67903692,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16175331,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/00ee132e91d16dfd59f62038bb190039?s=128&d=identicon&r=PG&f=1","display_name":"Msterup","link":"https://stackoverflow.com/users/16175331/msterup"},"is_answered":false,"view_count":22,"answer_count":1,"score":0,"last_activity_date":1623259202,"creation_date":1623239874,"last_edit_date":1623259202,"question_id":67903692,"share_link":"https://stackoverflow.com/q/67903692","body_markdown":"I am working on an model where a plane must move to a gate.\r\nThe plane has its destination gate set as its parameter.\r\n\r\nWhen I try to programmatically assign the gate to the `moveTo`'s `self.DEST_NODE`, I get what I think is a type error. \r\n\r\nI'm quite new to Java, and think the problem might be in the code.\r\n\r\nAdditional information: when I add no program but simply fill the node field with `p_Gate1` then the program works.\r\n\r\nI am very interested in converting the `PointNode` type to a `moveTo.Destination` type or something similar.\r\n\r\nPs. Thanks to Benjamin Schumann, I can now select between two options, but I would like all five gates enabled. (`agent.gate==1 ? p_Gate1 : p_Gate2`)\r\n\r\nPlease see attached screenshot. Thanks in advance.\r\n\r\n![Screenshot with errors][1]\r\n\r\n\r\n [1]: https://i.stack.imgur.com/nGoFw.png","link":"https://stackoverflow.com/questions/67903692/programatically-selection-destination-nodes-for-moveto-block","title":"Programatically selection destination nodes for moveTo block","body":"I am working on an model where a plane must move to a gate.\nThe plane has its destination gate set as its parameter.
\nWhen I try to programmatically assign the gate to the moveTo
's self.DEST_NODE
, I get what I think is a type error.
I'm quite new to Java, and think the problem might be in the code.
\nAdditional information: when I add no program but simply fill the node field with p_Gate1
then the program works.
I am very interested in converting the PointNode
type to a moveTo.Destination
type or something similar.
Ps. Thanks to Benjamin Schumann, I can now select between two options, but I would like all five gates enabled. (agent.gate==1 ? p_Gate1 : p_Gate2
)
Please see attached screenshot. Thanks in advance.
\n\n"},{"tags":["google-cloud-platform","mqtt","esp32","google-cloud-iot","root-certificate"],"owner":{"reputation":1,"user_id":14903154,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b8f6f3e6107e38a53fa73a6150eb425f?s=128&d=identicon&r=PG&f=1","display_name":"Aaryaa Padhyegurjar","link":"https://stackoverflow.com/users/14903154/aaryaa-padhyegurjar"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623259202,"creation_date":1623259202,"question_id":67908911,"share_link":"https://stackoverflow.com/q/67908911","body_markdown":"I'm trying to connect ESP32 to Google Cloud IoT Core using the **google-cloud-iot-arduino** and the **arduino-mqtt (lwmqtt)** libraries. \r\n\r\n1. I followed all necessary steps as given in this blog: [https://www.survivingwithandroid.com/cloud-iot-core-esp32/?unapproved=16731&moderation-hash=eeb8406949900a6f926ac15fdb54c7b6#comment-16731] --My code is the same as given here, just the WiFi SSID and other details are different.\r\nI also referred to these blogs:\r\n2. [https://ludovic-emo.medium.com/how-to-send-esp32-telemetry-to-google-cloud-iot-core-caf1a952020d]\r\n3. [https://medium.com/@gguuss/accessing-cloud-iot-core-from-arduino-838c2138cf2b]\r\n4. I also started a course on LinkedIn learning called "Learning Cloud IoT Core" by Lee Assam.\r\n\r\nBut I kept getting this message on the serial monitor:\r\n```\r\nSettings incorrect or missing a cyper for SSL\r\nConnect with mqtt.2030.ltsapis.goog:8883\r\n```\r\n\r\nI'm certain that the device ID and every other detail is correct. I suppose the root certificate is wrong. I tried several methods to generate the root certificate, the most common one being the last certificate we get from after executing this command:\r\n```openssl s_client -showcerts -connect mqtt.2030.ltsapis.goog:8883```\r\n\r\nI also tried using any of the root certificate bytes for the certificates with Google Trust Services (GTS) as the certificate authority (CA). Using this command:\r\n```curl pki.goog/roots.pem``` But that document has so many root certificates! Which one do I choose?\r\n\r\nI'm also not able to specify a binary root cert static as given here: https://github.com/Nilhcem/esp32-cloud-iot-core-k8s/blob/master/02-esp32_bme280_ciotc_arduino/ciotc_config.h\r\n\r\nHowever, they all give the same message on the serial monitor. So my questions are:\r\n1. Where am I going wrong?\r\n2. How to generate root certificate?\r\n3. How to specify a binary root cert static ?\r\n4. The example universal-lwmqtt form Google Cloud IoT Core JWT library specifies 2 root certificates, primary and backup. How to obtain those? [https://github.com/GoogleCloudPlatform/google-cloud-iot-arduino/blob/master/examples/universal-lwmqtt/ciotc_config.h]\r\n\r\nI have noticed that there were many others who had faced the exact same problem, however it was never resolved. I'm posting the links to those queries as well.\r\n1. https://stackoverflow.com/questions/62417204/esp32-connection-to-google-cloud-error-settings-incorrect-or-missing-a-cyper\r\n2. https://stackoverflow.com/questions/66799859/esp32-not-connecting-to-google-cloud-iot-core\r\n3. https://stackoverflow.com/questions/61608318/google-cloud-mqtt-with-esp32-reusing-jwt-error ","link":"https://stackoverflow.com/questions/67908911/esp32-and-google-cloud-iot-core-connection-settings-incorrect-or-missing-a-cype","title":"ESP32 and Google Cloud IoT Core connection: Settings incorrect or missing a cyper for SSL","body":"I'm trying to connect ESP32 to Google Cloud IoT Core using the google-cloud-iot-arduino and the arduino-mqtt (lwmqtt) libraries.
\nBut I kept getting this message on the serial monitor:
\nSettings incorrect or missing a cyper for SSL\nConnect with mqtt.2030.ltsapis.goog:8883\n
\nI'm certain that the device ID and every other detail is correct. I suppose the root certificate is wrong. I tried several methods to generate the root certificate, the most common one being the last certificate we get from after executing this command:\nopenssl s_client -showcerts -connect mqtt.2030.ltsapis.goog:8883
I also tried using any of the root certificate bytes for the certificates with Google Trust Services (GTS) as the certificate authority (CA). Using this command:\ncurl pki.goog/roots.pem
But that document has so many root certificates! Which one do I choose?
I'm also not able to specify a binary root cert static as given here: https://github.com/Nilhcem/esp32-cloud-iot-core-k8s/blob/master/02-esp32_bme280_ciotc_arduino/ciotc_config.h
\nHowever, they all give the same message on the serial monitor. So my questions are:
\nI have noticed that there were many others who had faced the exact same problem, however it was never resolved. I'm posting the links to those queries as well.
\nI am trying to create a program that would change the ip header of packets sent to a specific host. To do this, I intercept packets using libtins.
\nHere is my capture.hpp
file
#pragma once\n\n#include <tins/tins.h>\nusing namespace Tins;\n\nnamespace capturing {\n\n bool capture (PDU &pdu);\n\n}\n
\nthis is my capture.cpp
#include <iostream>\n#include "headers/capturing.hpp"\n#include <tins/tins.h>\n\nusing namespace Tins;\nusing namespace std;\n\nnamespace capturing {\n\n bool capture (PDU &pdu) {\n\n IP &ip = pdu.rfind_pdu<IP>();\n // ip.src_addr("127.0.0.1");\n\n cout << ip.src_addr() << endl;\n cout << ip.dst_addr() << endl;\n cout << ip.id() << endl;\n\n return false;\n\n }\n\n}\n
\nI tried working with pointers to pdu and IP, but it didn’t work, the packet sent didn’t change. Just no ideas about it.
\n"},{"tags":["cuda","reduction"],"answers":[{"owner":{"reputation":121094,"user_id":1695960,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/7f9f557c03db19232aa410540af2f966?s=128&d=identicon&r=PG","display_name":"Robert Crovella","link":"https://stackoverflow.com/users/1695960/robert-crovella"},"is_accepted":false,"score":0,"last_activity_date":1623259195,"creation_date":1623259195,"answer_id":67908908,"question_id":67907772,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":366,"user_id":741646,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/5acffcfc1c672d0a7901ede6d19f45f0?s=128&d=identicon&r=PG","display_name":"Kai","link":"https://stackoverflow.com/users/741646/kai"},"is_answered":false,"view_count":11,"answer_count":1,"score":0,"last_activity_date":1623259195,"creation_date":1623254457,"last_edit_date":1623254776,"question_id":67907772,"share_link":"https://stackoverflow.com/q/67907772","body_markdown":"I am somewhat confused, I have used the warp reduction as outlined by the online tutorial for quite a while now and it never caused problems. These are the snippets:\r\n\r\n while (r < total_rotations){\r\n \t\trot_index(d_refinements, h_num_refinements, abg,&rot_linear_index, r,s);\r\n \t\tconcat[threadIdx.x] = min(concat[threadIdx.x],score_offset[rot_linear_index]);\r\n \t\tr += blockDim.x;\r\n \t}\r\n \t__syncthreads();\r\n \tif (BLOCKSIZE >= 1024){if (tid < 512) { concat[tid] = min(concat[tid],concat[tid + 512]);} __syncthreads();}\r\n \tif (BLOCKSIZE >= 512){if (tid < 256) { concat[tid] = min(concat[tid],concat[tid + 256]);} __syncthreads();}\r\n \tif (BLOCKSIZE >= 256){if (tid < 128) { concat[tid] = min(concat[tid],concat[tid + 128]);} __syncthreads();}\r\n \tif (BLOCKSIZE >= 128){if (tid < 64) { concat[tid] = min(concat[tid],concat[tid + 64]);} __syncthreads();}\r\n \tif (tid < 32) min_warp_reduce<float,BLOCKSIZE>(concat,tid); __syncthreads();\r\n \tif (tid==0){\r\n \t\tmin_offset[0] = concat[0];\r\n \t}\r\n\r\nAnd the `__device__` code.\r\n\r\n template <class T, unsigned int blockSize>\r\n\r\n __device__\r\n void min_warp_reduce(volatile T * sdata, int tid){\r\n \tif (blockSize >= 64) sdata[tid] = min(sdata[tid],sdata[tid + 32]);\r\n \tif (blockSize >= 32) sdata[tid] = min(sdata[tid],sdata[tid + 16]);\r\n \tif (blockSize >= 16) sdata[tid] = min(sdata[tid],sdata[tid + 8]);\r\n \tif (blockSize >= 8) sdata[tid] = min(sdata[tid],sdata[tid + 4]);\r\n \tif (blockSize >= 4) sdata[tid] = min(sdata[tid],sdata[tid + 2]);\r\n \tif (blockSize >= 2) sdata[tid] = min(sdata[tid],sdata[tid + 1]);\r\n }\r\n\r\nTo me I have copied the tutorial code faithfully, yet a race condition check tells me that there are several conflicts. What am I missing?","link":"https://stackoverflow.com/questions/67907772/cuda-min-warp-reduction-produces-race-condition","title":"Cuda min warp reduction produces race condition","body":"I am somewhat confused, I have used the warp reduction as outlined by the online tutorial for quite a while now and it never caused problems. These are the snippets:
\nwhile (r < total_rotations){\n rot_index(d_refinements, h_num_refinements, abg,&rot_linear_index, r,s);\n concat[threadIdx.x] = min(concat[threadIdx.x],score_offset[rot_linear_index]);\n r += blockDim.x;\n }\n __syncthreads();\n if (BLOCKSIZE >= 1024){if (tid < 512) { concat[tid] = min(concat[tid],concat[tid + 512]);} __syncthreads();}\n if (BLOCKSIZE >= 512){if (tid < 256) { concat[tid] = min(concat[tid],concat[tid + 256]);} __syncthreads();}\n if (BLOCKSIZE >= 256){if (tid < 128) { concat[tid] = min(concat[tid],concat[tid + 128]);} __syncthreads();}\n if (BLOCKSIZE >= 128){if (tid < 64) { concat[tid] = min(concat[tid],concat[tid + 64]);} __syncthreads();}\n if (tid < 32) min_warp_reduce<float,BLOCKSIZE>(concat,tid); __syncthreads();\n if (tid==0){\n min_offset[0] = concat[0];\n }\n
\nAnd the __device__
code.
template <class T, unsigned int blockSize>\n\n__device__\nvoid min_warp_reduce(volatile T * sdata, int tid){\n if (blockSize >= 64) sdata[tid] = min(sdata[tid],sdata[tid + 32]);\n if (blockSize >= 32) sdata[tid] = min(sdata[tid],sdata[tid + 16]);\n if (blockSize >= 16) sdata[tid] = min(sdata[tid],sdata[tid + 8]);\n if (blockSize >= 8) sdata[tid] = min(sdata[tid],sdata[tid + 4]);\n if (blockSize >= 4) sdata[tid] = min(sdata[tid],sdata[tid + 2]);\n if (blockSize >= 2) sdata[tid] = min(sdata[tid],sdata[tid + 1]);\n}\n
\nTo me I have copied the tutorial code faithfully, yet a race condition check tells me that there are several conflicts. What am I missing?
\n"},{"tags":["r","auc"],"comments":[{"owner":{"reputation":1083,"user_id":9093302,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0821de7ead2f25daaf27accb90524b98?s=128&d=identicon&r=PG&f=1","display_name":"Brian Fisher","link":"https://stackoverflow.com/users/9093302/brian-fisher"},"edited":false,"score":0,"creation_date":1623258433,"post_id":67908515,"comment_id":120030333,"content_license":"CC BY-SA 4.0"}],"answers":[{"owner":{"reputation":19765,"user_id":13095326,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8c21c17926c0d5674359e99f6aab7735?s=128&d=identicon&r=PG&f=1","display_name":"Ian Campbell","link":"https://stackoverflow.com/users/13095326/ian-campbell"},"is_accepted":false,"score":0,"last_activity_date":1623259195,"last_edit_date":1623259195,"creation_date":1623258557,"answer_id":67908764,"question_id":67908515,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16176963,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgGy4Hd4T8V96BsIBYyYlU3dw2jshxzwaQeLTpOBSA=k-s128","display_name":"shinyhill","link":"https://stackoverflow.com/users/16176963/shinyhill"},"is_answered":false,"view_count":17,"answer_count":1,"score":-2,"last_activity_date":1623259195,"creation_date":1623257430,"last_edit_date":1623258153,"question_id":67908515,"share_link":"https://stackoverflow.com/q/67908515","body_markdown":"I'm a beginner who just started using R.\r\n\r\nI am trying to obtain the AUC for each time section using the trapezoid method with the results measured at 0,10,20,30,40, 50, 60 minutes for each ID.\r\nWhat should I do?\r\n\r\n```\r\n CASET0\tT10\tT20\tT30\tT40\tT50\tT60\r\n1\t 88\t89\t91\t105\t107\t139\t159\r\n2 \t 92\tNA\t102\tNA\tNA\t189\t144\r\n3\t 79\tNA\t82\t98\t106\t140\t118\r\n5\t 81\t81\t82\t92\t86\t101\t124\r\n8\t 90\t89\t89\t106\t115\t134\t101\r\n9\t 91\t77\t87\t82\t95\t133\t156\r\n```","link":"https://stackoverflow.com/questions/67908515/auc-by-trapezoid-method-in-r","title":"AUC by trapezoid method in R","body":"I'm a beginner who just started using R.
\nI am trying to obtain the AUC for each time section using the trapezoid method with the results measured at 0,10,20,30,40, 50, 60 minutes for each ID.\nWhat should I do?
\n CASET0 T10 T20 T30 T40 T50 T60\n1 88 89 91 105 107 139 159\n2 92 NA 102 NA NA 189 144\n3 79 NA 82 98 106 140 118\n5 81 81 82 92 86 101 124\n8 90 89 89 106 115 134 101\n9 91 77 87 82 95 133 156\n
\n"},{"tags":["ios","swift","ibeacon","beacon"],"answers":[{"owner":{"reputation":59229,"user_id":1461050,"user_type":"registered","accept_rate":89,"profile_image":"https://i.stack.imgur.com/c8IhJ.jpg?s=128&g=1","display_name":"davidgyoung","link":"https://stackoverflow.com/users/1461050/davidgyoung"},"is_accepted":false,"score":0,"last_activity_date":1623259191,"creation_date":1623259191,"answer_id":67908907,"question_id":67907906,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1112,"user_id":2811242,"user_type":"registered","accept_rate":92,"profile_image":"https://i.stack.imgur.com/XtrQv.png?s=128&g=1","display_name":"Luciano","link":"https://stackoverflow.com/users/2811242/luciano"},"is_answered":false,"view_count":12,"answer_count":1,"score":1,"last_activity_date":1623259191,"creation_date":1623255045,"question_id":67907906,"share_link":"https://stackoverflow.com/q/67907906","body_markdown":"I'm trying to monitoring region and detecting beacons when the app is killed (in foreground everything works fine). I've read that it should be sufficient to set `allowsBackgroundLocationUpdates=true` and `pausesLocationUpdatesAutomatically=false` to wake up the app, but only if an enter/exit event is detected.\r\n\r\nNow, my problem is that when I turn off the beacon, `didDetermineState` and `didExitRegion` are never called. And if I request the state explicitly, it return that it is still inside the region. What am I missing?\r\n\r\nThis is my code, entirely in the AppDelegate.\r\n\r\n func requestLocationPermissions() {\r\n locationManager = CLLocationManager()\r\n locationManager.delegate = self\r\n locationManager.requestAlwaysAuthorization()\r\n locationManager.allowsBackgroundLocationUpdates = true\r\n locationManager.pausesLocationUpdatesAutomatically = false\r\n \r\n startMonitoring()\r\n }\r\n \r\n func startMonitoring() {\r\n let constraint = CLBeaconIdentityConstraint(uuid: Config.Beacons.uuid, major: Config.Beacons.major, minor: Config.Beacons.minor)\r\n let beaconRegion = CLBeaconRegion(beaconIdentityConstraint: constraint, identifier: Config.Beacons.beaconID)\r\n beaconRegion.notifyEntryStateOnDisplay = true\r\n \r\n locationManager.startMonitoring(for: beaconRegion) \r\n locationManager.startRangingBeacons(satisfying: constraint)\r\n }\r\n \r\n func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) {\r\n if state == .inside {\r\n print("AppDelegate: inside beacon region")\r\n } else {\r\n print("AppDelegate: outside beacon region")\r\n }\r\n }\r\n \r\n func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {\r\n print("AppDelegate: entered region")\r\n }\r\n \r\n func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {\r\n print("AppDelegate: exited region")\r\n }\r\n \r\n func locationManager(_ manager: CLLocationManager, didRange beacons: [CLBeacon], satisfying beaconConstraint: CLBeaconIdentityConstraint) {\r\n guard beacons.count > 0 else {\r\n let constraint = CLBeaconIdentityConstraint(uuid: Config.Beacons.uuid, major: Config.Beacons.major, minor: Config.Beacons.minor)\r\n locationManager.requestState(for: CLBeaconRegion(beaconIdentityConstraint: constraint, identifier: Config.Beacons.beaconID))\r\n return\r\n }\r\n \r\n // Other stuff\r\n }","link":"https://stackoverflow.com/questions/67907906/ibeacon-diddeterminestate-never-called-when-exiting-a-region","title":"iBeacon: didDetermineState never called when exiting a region","body":"I'm trying to monitoring region and detecting beacons when the app is killed (in foreground everything works fine). I've read that it should be sufficient to set allowsBackgroundLocationUpdates=true
and pausesLocationUpdatesAutomatically=false
to wake up the app, but only if an enter/exit event is detected.
Now, my problem is that when I turn off the beacon, didDetermineState
and didExitRegion
are never called. And if I request the state explicitly, it return that it is still inside the region. What am I missing?
This is my code, entirely in the AppDelegate.
\nfunc requestLocationPermissions() {\n locationManager = CLLocationManager()\n locationManager.delegate = self\n locationManager.requestAlwaysAuthorization()\n locationManager.allowsBackgroundLocationUpdates = true\n locationManager.pausesLocationUpdatesAutomatically = false\n \n startMonitoring()\n}\n\nfunc startMonitoring() {\n let constraint = CLBeaconIdentityConstraint(uuid: Config.Beacons.uuid, major: Config.Beacons.major, minor: Config.Beacons.minor)\n let beaconRegion = CLBeaconRegion(beaconIdentityConstraint: constraint, identifier: Config.Beacons.beaconID)\n beaconRegion.notifyEntryStateOnDisplay = true\n\n locationManager.startMonitoring(for: beaconRegion) \n locationManager.startRangingBeacons(satisfying: constraint)\n}\n\nfunc locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) {\n if state == .inside {\n print("AppDelegate: inside beacon region")\n } else {\n print("AppDelegate: outside beacon region")\n }\n}\n \nfunc locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {\n print("AppDelegate: entered region")\n}\n \nfunc locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {\n print("AppDelegate: exited region")\n}\n \nfunc locationManager(_ manager: CLLocationManager, didRange beacons: [CLBeacon], satisfying beaconConstraint: CLBeaconIdentityConstraint) {\n guard beacons.count > 0 else {\n let constraint = CLBeaconIdentityConstraint(uuid: Config.Beacons.uuid, major: Config.Beacons.major, minor: Config.Beacons.minor)\n locationManager.requestState(for: CLBeaconRegion(beaconIdentityConstraint: constraint, identifier: Config.Beacons.beaconID))\n return\n }\n \n // Other stuff\n }\n
\n"},{"tags":["python","time-complexity","space-complexity"],"owner":{"reputation":1516,"user_id":6630012,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-Anrtu1035o8/AAAAAAAAAAI/AAAAAAAAAQQ/-dlTGZC7fxA/photo.jpg?sz=128","display_name":"gsb22","link":"https://stackoverflow.com/users/6630012/gsb22"},"is_answered":false,"view_count":28,"bounty_amount":50,"bounty_closes_date":1623863989,"answer_count":0,"score":0,"last_activity_date":1623259189,"creation_date":1623063782,"last_edit_date":1623077142,"question_id":67870431,"share_link":"https://stackoverflow.com/q/67870431","body_markdown":"So I was solving this LeetCode question - https://leetcode.com/problems/palindrome-partitioning-ii/ and have come up with the following most naive brute force recursive solution. Now, I know how to memoize this solution and work my way up to best possible with Dynamic Programming. But in order to find the time/space complexities of further solutions, I want to see how much worse this solution was and I have looked up in multiple places but haven't been able to find a concrete T/S complexity answer. \r\n\r\n\r\n```\r\ndef minCut(s: str) -> int:\r\n def is_palindrome(start, end):\r\n while start < end:\r\n if not s[start] == s[end]:\r\n return False\r\n start += 1\r\n end -= 1\r\n return True\r\n\r\n def dfs_helper(start, end):\r\n if start >= end:\r\n return 0\r\n\r\n if is_palindrome(start, end):\r\n return 0\r\n curr_min = inf\r\n \r\n # this is the meat of the solution and what is the time complexity of this\r\n for x in range(start, end):\r\n curr_min = min(curr_min, 1 + dfs_helper(start, x) + dfs_helper(x + 1, end))\r\n return curr_min\r\n\r\n return dfs_helper(0, len(s) - 1)\r\n```","link":"https://stackoverflow.com/questions/67870431/time-and-space-complexity-of-palindrome-partitioning-ii","title":"Time and Space complexity of Palindrome Partitioning II","body":"So I was solving this LeetCode question - https://leetcode.com/problems/palindrome-partitioning-ii/ and have come up with the following most naive brute force recursive solution. Now, I know how to memoize this solution and work my way up to best possible with Dynamic Programming. But in order to find the time/space complexities of further solutions, I want to see how much worse this solution was and I have looked up in multiple places but haven't been able to find a concrete T/S complexity answer.
\ndef minCut(s: str) -> int:\n def is_palindrome(start, end):\n while start < end:\n if not s[start] == s[end]:\n return False\n start += 1\n end -= 1\n return True\n\n def dfs_helper(start, end):\n if start >= end:\n return 0\n\n if is_palindrome(start, end):\n return 0\n curr_min = inf\n \n # this is the meat of the solution and what is the time complexity of this\n for x in range(start, end):\n curr_min = min(curr_min, 1 + dfs_helper(start, x) + dfs_helper(x + 1, end))\n return curr_min\n\n return dfs_helper(0, len(s) - 1)\n
\n"},{"tags":["python","cluster-computing","dask"],"comments":[{"owner":{"reputation":21408,"user_id":3821154,"user_type":"registered","accept_rate":40,"profile_image":"https://i.stack.imgur.com/RYr9X.jpg?s=128&g=1","display_name":"mdurant","link":"https://stackoverflow.com/users/3821154/mdurant"},"edited":false,"score":0,"creation_date":1623259250,"post_id":67907882,"comment_id":120030643,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":16138604,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyJsJWcYp6gvqn4vsmGIu6IxJnc4hlBJMkWdsOQ=k-s128","display_name":"iti1801","link":"https://stackoverflow.com/users/16138604/iti1801"},"is_answered":false,"view_count":8,"answer_count":0,"score":0,"last_activity_date":1623259185,"creation_date":1623254970,"last_edit_date":1623259185,"question_id":67907882,"share_link":"https://stackoverflow.com/q/67907882","body_markdown":"I tried the following code:\r\n\r\n```\r\nimport numpy as np \r\nfrom dask.distributed import Client \r\nfrom dask.jobqueue import PBSCluster \r\nimport dask.array as da\r\n\r\ncluster = PBSCluster(processes=1, cores=8, memory="40GB", \r\n local directory='$TMPDIR', \r\n walltime='1:00:00', interface='ib0') \r\n\r\ntask = client.submit(lambda: np.random.uniform(size=(623000, 73, 41)))\r\narr = da.from_delayed(task, shape=(623000, 73, 41), dtype=np.float32)\r\nres = client.compute(arr)\r\n\r\nres.result()\r\n```\r\n\r\nThe process is not finished. It is always restarted and is only performed by one worker. \r\n\r\nWhat is wrong with the code?\r\nIs it possible to distribute it to all the cores? ","link":"https://stackoverflow.com/questions/67907882/dask-computation-never-ending","title":"Dask computation never ending","body":"I tried the following code:
\nimport numpy as np \nfrom dask.distributed import Client \nfrom dask.jobqueue import PBSCluster \nimport dask.array as da\n\ncluster = PBSCluster(processes=1, cores=8, memory="40GB", \n local directory='$TMPDIR', \n walltime='1:00:00', interface='ib0') \n\ntask = client.submit(lambda: np.random.uniform(size=(623000, 73, 41)))\narr = da.from_delayed(task, shape=(623000, 73, 41), dtype=np.float32)\nres = client.compute(arr)\n\nres.result()\n
\nThe process is not finished. It is always restarted and is only performed by one worker.
\nWhat is wrong with the code?\nIs it possible to distribute it to all the cores?
\n"},{"tags":["eigen","openblas"],"owner":{"reputation":1,"user_id":16178379,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/dfd11e3f9244cdf6e8218fdf42c36207?s=128&d=identicon&r=PG&f=1","display_name":"tstjohn","link":"https://stackoverflow.com/users/16178379/tstjohn"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623259172,"creation_date":1623259172,"question_id":67908906,"share_link":"https://stackoverflow.com/q/67908906","body_markdown":"I'm trying to run Eigen's benchmark using OpenBLAS. However, it doesn't appear that OpenBLAS is actually being used.\r\n\r\nThe script that I'm running is based on the example provided on the Eigen website (https://eigen.tuxfamily.org/index.php?title=How_to_run_the_benchmark_suite).\r\n\r\nIs there anything else that needs to be done to properly use OpenBLAS?\r\n\r\nHere is a copy of the script that I'm running.\r\n\r\n```export OPENBLASDIR=/root/OpenBLAS\r\nOPENBLAS_LIBRARIES=$OPENBLASDIR/build/lib/libopenblas.so\r\nOPENBLAS_INCLUDES=$OPENBLASDIR/build/include\r\n\r\nexport EIGEN3DIR=/root/eigen-3.3.9\r\nexport BUILDDIR=/root/eigen-tests\r\n\r\nmkdir $BUILDDIR\r\ncd $BUILDDIR\r\n\r\ncmake $EIGEN3DIR -DEIGEN_BUILD_BTL=ON -DEIGEN3_INCLUDE_DIR=$EIGEN3DIR -DCMAKE_B\\\r\nUILD_TYPE=Release -DOPENBLAS_LIBRARIES=$OPENBLAS_LIBRARIES -DOPENBLAS_INCLUDES=\\\r\n$OPENBLAS_INCLUDES\r\ncd bench/btl\r\nmake -j8\r\nOMP_NUM_THREADS=1 ctest -V```","link":"https://stackoverflow.com/questions/67908906/attempting-to-run-eigen-benchmark-with-openblas-backend","title":"Attempting to Run Eigen Benchmark with OpenBLAS Backend","body":"I'm trying to run Eigen's benchmark using OpenBLAS. However, it doesn't appear that OpenBLAS is actually being used.
\nThe script that I'm running is based on the example provided on the Eigen website (https://eigen.tuxfamily.org/index.php?title=How_to_run_the_benchmark_suite).
\nIs there anything else that needs to be done to properly use OpenBLAS?
\nHere is a copy of the script that I'm running.
\nOPENBLAS_LIBRARIES=$OPENBLASDIR/build/lib/libopenblas.so\nOPENBLAS_INCLUDES=$OPENBLASDIR/build/include\n\nexport EIGEN3DIR=/root/eigen-3.3.9\nexport BUILDDIR=/root/eigen-tests\n\nmkdir $BUILDDIR\ncd $BUILDDIR\n\ncmake $EIGEN3DIR -DEIGEN_BUILD_BTL=ON -DEIGEN3_INCLUDE_DIR=$EIGEN3DIR -DCMAKE_B\\\nUILD_TYPE=Release -DOPENBLAS_LIBRARIES=$OPENBLAS_LIBRARIES -DOPENBLAS_INCLUDES=\\\n$OPENBLAS_INCLUDES\ncd bench/btl\nmake -j8\nOMP_NUM_THREADS=1 ctest -V```\n
\n"},{"tags":["kubernetes","cron","kubernetes-cronjob"],"owner":{"reputation":51,"user_id":12874621,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e9737ad85d83fda9bffa2aa987790ce0?s=128&d=identicon&r=PG&f=1","display_name":"girlcoder1","link":"https://stackoverflow.com/users/12874621/girlcoder1"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623259172,"creation_date":1623258394,"last_edit_date":1623259172,"question_id":67908726,"share_link":"https://stackoverflow.com/q/67908726","body_markdown":"I have this cron job set up to run every 2 hours. Sometimes the job runs and sometimes it doesn't run consistently. Any ideas as to what I can add/change to make it consistently run every 2 hours even if it fails?\r\n\r\n apiVersion: batch/v1beta1\r\n kind: CronJob\r\n metadata:\r\n name: {{ .Values.metadata.name }}\r\n namespace: {{ .Values.metadata.namespace }}\r\n spec:\r\n schedule: "0 11,23 * * *"\r\n schedule: "0 11,13,15,17,19,21,23 * * *"\r\n jobTemplate:\r\n spec:\r\n template:\r\n spec:\r\n containers:\r\n - name: {{ .Values.metadata.name }}\r\n image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"\r\n imagePullPolicy: Always\r\n env:\r\n {{ range .Values.envVars }}\r\n - name: "{{ .name }}"\r\n valueFrom:\r\n secretKeyRef:\r\n name: job\r\n key: {{ .name }}\r\n optional: {{ .optional }}\r\n {{ end }}\r\n resources:\r\n limits:\r\n cpu: 512m\r\n memory: 1024Mi\r\n requests:\r\n cpu: 200m\r\n memory: 256Mi\r\n restartPolicy: Never\r\n restartPolicy: OnFailure\r\n backoffLimit: 4","link":"https://stackoverflow.com/questions/67908726/cronjob-is-not-running-consistently","title":"CronJob Is not running consistently","body":"I have this cron job set up to run every 2 hours. Sometimes the job runs and sometimes it doesn't run consistently. Any ideas as to what I can add/change to make it consistently run every 2 hours even if it fails?
\napiVersion: batch/v1beta1\nkind: CronJob\nmetadata:\n name: {{ .Values.metadata.name }}\n namespace: {{ .Values.metadata.namespace }}\nspec:\n schedule: "0 11,23 * * *"\n schedule: "0 11,13,15,17,19,21,23 * * *"\n jobTemplate:\n spec:\n template:\n spec:\n containers:\n - name: {{ .Values.metadata.name }}\n image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"\n imagePullPolicy: Always\n env:\n {{ range .Values.envVars }}\n - name: "{{ .name }}"\n valueFrom:\n secretKeyRef:\n name: job\n key: {{ .name }}\n optional: {{ .optional }}\n {{ end }}\n resources:\n limits:\n cpu: 512m\n memory: 1024Mi\n requests:\n cpu: 200m\n memory: 256Mi\n restartPolicy: Never\n restartPolicy: OnFailure\n backoffLimit: 4\n
\n"},{"tags":["python","pdf","flask","web","pythonanywhere"],"owner":{"reputation":1,"user_id":16178277,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/a2b8008af86a0c27f62ffb4b394e7a17?s=128&d=identicon&r=PG&f=1","display_name":"JW30","link":"https://stackoverflow.com/users/16178277/jw30"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623259167,"creation_date":1623259167,"question_id":67908905,"share_link":"https://stackoverflow.com/q/67908905","body_markdown":"I am trying to host a website via Pythonanywhere that allows me to extract 8 digit product numbers from pdf files. The extracting is done by the textract module. \r\n\r\nWhen I try to extract certain pdf files I get a UnicodeDecodeError like you can see here: https://codeshare.io/WdNz6E. The problem is, if I run the website locally via the development server, the same pdf files are no problem for textract and the program runs without errors. The versions of Python, Flask and Textract are the same.\r\n\r\nThis is the function used to extract the pdf files:\r\n\r\n def get_numbers(file_path):\r\n output = ''\r\n pdf_string = str(textract.process(file_path))\r\n numbers_list = re.sub('\\D', ' ', pdf_string).split()\r\n for x in numbers_list:\r\n if len(x) == 8 and x not in output:\r\n output += f'{x} '\r\n return output.rstrip()","link":"https://stackoverflow.com/questions/67908905/pythonanywhere-textract-unicodedecodeerror-only-on-website","title":"Pythonanywhere Textract UnicodeDecodeError ONLY on website","body":"I am trying to host a website via Pythonanywhere that allows me to extract 8 digit product numbers from pdf files. The extracting is done by the textract module.
\nWhen I try to extract certain pdf files I get a UnicodeDecodeError like you can see here: https://codeshare.io/WdNz6E. The problem is, if I run the website locally via the development server, the same pdf files are no problem for textract and the program runs without errors. The versions of Python, Flask and Textract are the same.
\nThis is the function used to extract the pdf files:
\ndef get_numbers(file_path):\n output = ''\n pdf_string = str(textract.process(file_path))\n numbers_list = re.sub('\\D', ' ', pdf_string).split()\n for x in numbers_list:\n if len(x) == 8 and x not in output:\n output += f'{x} '\n return output.rstrip()\n
\n"},{"tags":["node.js","heroku","npm"],"comments":[{"owner":{"reputation":40163,"user_id":740553,"user_type":"registered","accept_rate":46,"profile_image":"https://i.stack.imgur.com/s5cOX.jpg?s=128&g=1","display_name":"Mike 'Pomax' Kamermans","link":"https://stackoverflow.com/users/740553/mike-pomax-kamermans"},"edited":false,"score":0,"creation_date":1623259310,"post_id":67908635,"comment_id":120030669,"content_license":"CC BY-SA 4.0"}],"owner":{"reputation":1,"user_id":10585293,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/fbff431b23df962bd4ea668ee946afe7?s=128&d=identicon&r=PG&f=1","display_name":"Dominik","link":"https://stackoverflow.com/users/10585293/dominik"},"is_answered":false,"view_count":10,"answer_count":0,"score":0,"last_activity_date":1623259160,"creation_date":1623258017,"last_edit_date":1623259160,"question_id":67908635,"share_link":"https://stackoverflow.com/q/67908635","body_markdown":"I try to deploy my app from github but I get these errors:\r\n...........................................................\r\n...........................................................\r\n...........................................................\r\n```\r\napp[web.1]: > node app.js\r\napp[web.1]:\r\nheroku[web.1]: State changed from starting to up\r\napp[web.1]: Serving on port 14885\r\napp[web.1]: Database connected\r\napp[web.1]: /app/node_modules/mongodb/lib/utils.js:698\r\napp[web.1]: throw error;\r\napp[web.1]: ^\r\napp[web.1]:\r\napp[web.1]: MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017\r\napp[web.1]: at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/topology.js:438:30)\r\napp[web.1]: at listOnTimeout (internal/timers.js:555:17)\r\napp[web.1]: at processTimers (internal/timers.js:498:7) {\r\napp[web.1]: reason: TopologyDescription {\r\napp[web.1]: type: 'Single',\r\n app[web.1]: setName: null,\r\napp[web.1]: maxSetVersion: null,\r\napp[web.1]: maxElectionId: null,\r\napp[web.1]: servers: Map(1) {\r\napp[web.1]: 'localhost:27017' => ServerDescription {\r\napp[web.1]: address: 'localhost:27017',\r\napp[web.1]: error: Error: connect ECONNREFUSED 127.0.0.1:27017\r\napp[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {\r\napp[web.1]: name: 'MongoNetworkError'\r\napp[web.1]: },\r\napp[web.1]: roundTripTime: -1,\r\napp[web.1]: lastUpdateTime: 81704897,\r\napp[web.1]: lastWriteDate: null,\r\napp[web.1]: opTime: null,\r\napp[web.1]: type: 'Unknown',\r\napp[web.1]: topologyVersion: undefined,\r\napp[web.1]: minWireVersion: 0,\r\napp[web.1]: maxWireVersion: 0,\r\napp[web.1]: hosts: [],\r\napp[web.1]: passives: [],\r\napp[web.1]: arbiters: [],\r\napp[web.1]: tags: []\r\napp[web.1]: }\r\napp[web.1]: },\r\napp[web.1]: stale: false,\r\napp[web.1]: compatible: true,\r\napp[web.1]: compatibilityError: null,\r\napp[web.1]: logicalSessionTimeoutMinutes: null,\r\napp[web.1]: heartbeatFrequencyMS: 10000,\r\napp[web.1]: localThresholdMS: 15,\r\napp[web.1]: commonWireVersion: null\r\napp[web.1]: }\r\napp[web.1]: }\r\napp[web.1]: npm ERR! code ELIFECYCLE\r\napp[web.1]: npm ERR! errno 1\r\napp[web.1]: npm ERR! serwis-ogloszeniowy@ start: `node app.js`\r\napp[web.1]: npm ERR! Exit status 1\r\napp[web.1]: npm ERR!\r\napp[web.1]: npm ERR! Failed at the serwis-ogloszeniowy@ start script.\r\napp[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.\r\napp[web.1]:\r\napp[web.1]: npm ERR! A complete log of this run can be found in:\r\napp[web.1]: npm ERR! /app/.npm/_logs/2021-06-09T17_07_14_026Z-debug.log\r\nheroku[web.1]: Process exited with status 1\r\nheroku[web.1]: State changed from up to crashed\r\n```\r\n...................................................................\r\nI have no idea what's going wrong. \r\nPlease help.","link":"https://stackoverflow.com/questions/67908635/heroku-errors-when-trying-to-deploy","title":"Heroku errors when trying to deploy","body":"I try to deploy my app from github but I get these errors:\n...........................................................\n...........................................................\n...........................................................
\napp[web.1]: > node app.js\napp[web.1]:\nheroku[web.1]: State changed from starting to up\napp[web.1]: Serving on port 14885\napp[web.1]: Database connected\napp[web.1]: /app/node_modules/mongodb/lib/utils.js:698\napp[web.1]: throw error;\napp[web.1]: ^\napp[web.1]:\napp[web.1]: MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017\napp[web.1]: at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/topology.js:438:30)\napp[web.1]: at listOnTimeout (internal/timers.js:555:17)\napp[web.1]: at processTimers (internal/timers.js:498:7) {\napp[web.1]: reason: TopologyDescription {\napp[web.1]: type: 'Single',\n app[web.1]: setName: null,\napp[web.1]: maxSetVersion: null,\napp[web.1]: maxElectionId: null,\napp[web.1]: servers: Map(1) {\napp[web.1]: 'localhost:27017' => ServerDescription {\napp[web.1]: address: 'localhost:27017',\napp[web.1]: error: Error: connect ECONNREFUSED 127.0.0.1:27017\napp[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {\napp[web.1]: name: 'MongoNetworkError'\napp[web.1]: },\napp[web.1]: roundTripTime: -1,\napp[web.1]: lastUpdateTime: 81704897,\napp[web.1]: lastWriteDate: null,\napp[web.1]: opTime: null,\napp[web.1]: type: 'Unknown',\napp[web.1]: topologyVersion: undefined,\napp[web.1]: minWireVersion: 0,\napp[web.1]: maxWireVersion: 0,\napp[web.1]: hosts: [],\napp[web.1]: passives: [],\napp[web.1]: arbiters: [],\napp[web.1]: tags: []\napp[web.1]: }\napp[web.1]: },\napp[web.1]: stale: false,\napp[web.1]: compatible: true,\napp[web.1]: compatibilityError: null,\napp[web.1]: logicalSessionTimeoutMinutes: null,\napp[web.1]: heartbeatFrequencyMS: 10000,\napp[web.1]: localThresholdMS: 15,\napp[web.1]: commonWireVersion: null\napp[web.1]: }\napp[web.1]: }\napp[web.1]: npm ERR! code ELIFECYCLE\napp[web.1]: npm ERR! errno 1\napp[web.1]: npm ERR! serwis-ogloszeniowy@ start: `node app.js`\napp[web.1]: npm ERR! Exit status 1\napp[web.1]: npm ERR!\napp[web.1]: npm ERR! Failed at the serwis-ogloszeniowy@ start script.\napp[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.\napp[web.1]:\napp[web.1]: npm ERR! A complete log of this run can be found in:\napp[web.1]: npm ERR! /app/.npm/_logs/2021-06-09T17_07_14_026Z-debug.log\nheroku[web.1]: Process exited with status 1\nheroku[web.1]: State changed from up to crashed\n
\n...................................................................\nI have no idea what's going wrong.
\nPlease help.
I installed Pycharm in Windows. I also have WSL2 Ubuntu. My projects are in WSL2 Ubuntu. I have 2 users in WSL2 Ubuntu. One user, user1
, I have been using for a while, including projects that I have edited with Pycharm. Recently, I created a 2nd user,user2
, to run Kafka separately. My Kafka-related project is stored in user2
.
I also execute files in user2
project in user2
terminals (after switching from user1
with su -ls user2
).
Now, I want to edit Python files in project under user2
in Pycharm. But I got this error:
Cannot save \\\\wsl\\Ubuntu\\home\\user2\\xxx\\xxx.py\nUnable to create a backup file (xxx.py~)\nThe file left unchanged.\n
\nAlso, at the bottom right of Pycharm IDE, there is an Event Log
notice
Failed to save settings. Please restart Pycharm.\n
\nRestarting Pycharm leads me to the same situation over.
\nWhat should I do to deal with Python projects sitting on and 2nd user? Note that, if I edit files under user1
, everything works fine (I can save files without any error notifications).
I am switching between java 8 and java 11 for some reason recently after updating the JAVA_HOME , I see a problem in IntelliJ IDEA for my Gradle project. so I am trying from scratch to setup java in Mac. but stuck with this inconsistent issue.
\n\n\n"},{"tags":["java","java-11","javacompiler"],"owner":{"reputation":1,"user_id":16175596,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJwNpfZ0IpWyOuHI_HzCUiLsfRQy09t3NTgeZ2ZC=k-s128","display_name":"RASHIKA SACHAN","link":"https://stackoverflow.com/users/16175596/rashika-sachan"},"is_answered":false,"view_count":20,"answer_count":0,"score":-1,"last_activity_date":1623258353,"creation_date":1623241696,"last_edit_date":1623258353,"question_id":67904137,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67904137/different-date-format-result-on-jdk8-vs-jdk11","title":"Different date format result on jdk8 vs jdk11","body":"Process 'command '/Applications/IntelliJ IDEA CE.app/Contents/jbr/Contents/Home/bin/java'' finished with non-zero exit value 1
\n
I have written this piece of code. When I am running on JDK 8, output is mm-dd-yyyy
. When running JDK 11, the output is yyyy-dd-mm
. How can I output mm-dd-yyyy
regardless of JDK version?
public static void main(String args[]){\n \n SimpleDateFormat sdfMedium =(SimpleDateFormat)DateFormat.getDateInstance(DateFormat.MEDIUM,newLocale(“en-US”)));\n \n System.out.println("Medium Format: "sdfMedium.toPattern());\n
\nI worked quite a while with Apache Storm in a distributed setting. But currently, I faced a strange situation.
\nI ran a Storm Cluster with the Nimbus node on the host nodes1
.\nMy storm.yaml
is quite simple:
storm.zookeeper.servers: \n - "nodes1"\nstorm.local.dir: /tmp/storm\nnimbus.seeds: ["nodes1"]\nui.port: 8081\nsupervisor.slots.ports: \n - 6700\n
\nI doublechecked that the Storm nimbus is running, I can run storm list
for example. Looking on my syslog gives the same information, so Storm Nimbus is active and running.
But my problem is, that my nimbus.log
stays empty and is not written!
So, why logging does not work and how to repair this?\nI have not modified any log4j-Files.
\n"},{"tags":["python","sql","postgresql"],"owner":{"reputation":27,"user_id":14110251,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9a26ef883bc2858767675b3f7296f02a?s=128&d=identicon&r=PG&f=1","display_name":"Bcat13","link":"https://stackoverflow.com/users/14110251/bcat13"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258348,"creation_date":1623258348,"question_id":67908713,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908713/postgresql-unable-to-add-record-to-table","title":"PostgreSQL- Unable to add record to table","body":"I'm very new to SQL, and am trying to add a record to a table. I debugged my code and have already successfully made a database with a table called "weather." However, when I try to insert a record into the table and then print the table, no data prints in Terminal. I was wondering what I am doing wrong. Thank you.
\nconn = psycopg2.connect(database="postgres", user='postgres',password='password', host='127.0.0.1', port= '5432' )\nconn.autocommit = True\ncursor = conn.cursor()\ncursor.execute('''INSERT INTO WEATHER (HUMIDITY, CITY, FEELSLIKE, HIGHLOW, TEMPERATURE) VALUES ('{%s}', '{%s}', '{%s}', '{%s}', '{%s}')'''), (humidityVal, cityVal, feelslikeVal, highlowVal, tempVal)\ncursor.execute('''SELECT * from WEATHER''')\nresult = cursor.fetchall()\nprint(result) \nconn.close()\n
\n"},{"tags":["python","scripting"],"owner":{"reputation":1,"user_id":16178272,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJxjSDhNZRoyhnVDnqPgRd7S7GxYTLWD401Yy3ih=k-s128","display_name":"Kirsten B.","link":"https://stackoverflow.com/users/16178272/kirsten-b"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258345,"creation_date":1623258345,"question_id":67908711,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908711/i-cant-figure-out-the-date-time-python-doesnt-work","title":"I cant figure out the date time... python, doesnt work","body":"import datetime \n\ndef convert_to_mysql_date(input_date):\n
\nif not input_date:\nreturn "NULL"\nreturn (\ndatetime.dateime.strptime(input_date, "%m/%d/%Y").date().strftime("%Y/%m/%d")\n)
\nfor purchase in processed_response:\npurchase_date = datetime.datetime(2019, 1, 1)
\nMy brain has been working on it for days now.... if some guy can help me!!! :(
\n"},{"tags":["javascript","css","google-chrome","pdf"],"owner":{"reputation":77,"user_id":10624531,"user_type":"registered","profile_image":"https://graph.facebook.com/2232219823478884/picture?type=large","display_name":"Felipe Augusto Gonalves Basili","link":"https://stackoverflow.com/users/10624531/felipe-augusto-gonalves-basili"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258343,"creation_date":1623258343,"question_id":67908710,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908710/bug-on-google-chrome-when-showing-pdf","title":"Bug on google Chrome when showing PDF","body":"Recently a have been faced with a problem on Google Chrome I don't know if this error is in the google or in my code;
\nIf set the div as display: none; and show it again the PDF-view show only grey background; if I do a zoom in or out, it appears again;
\nTo illustrate the error a took theses screenshots;
\nMy Google Chrome version is 91.0.4472.77 64 bits
\n\nAfter display:none
\n\n"},{"tags":["javascript","google-sheets-api"],"owner":{"reputation":11,"user_id":15790364,"user_type":"registered","profile_image":"https://lh6.googleusercontent.com/-Wl25wDidqNY/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuclne4ErijuCUDv6MilqD0L9JrTI8Q/s96-c/photo.jpg?sz=128","display_name":"light1","link":"https://stackoverflow.com/users/15790364/light1"},"is_answered":false,"view_count":12,"answer_count":1,"score":0,"last_activity_date":1623258341,"creation_date":1623255411,"question_id":67908008,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908008/how-to-delete-row-in-google-sheets-using-api-v4-in-javascript","title":"how to delete row in google sheets using api v4 in Javascript?","body":" var params1 = {\n spreadsheetId: 'Id', \n range: "sheet 1!A2",\n };\n \n var clearValuesRequestBody = {\n };\n \n var request = await gapi.client.sheets.spreadsheets.values.clear(params1, clearValuesRequestBody);\n
\nI am trying to delete a row in google sheets using google sheets API in javascript. But I am able to delete only the first cell of the row. I believe there has to be something in clear values request body but I don't know what. Also if you can suggest me how to remove that blank row that has been created by deleting this row, that would be great.
\n"},{"tags":["c#","date-formatting","c#-5.0","c#-8.0"],"owner":{"reputation":1,"user_id":15571409,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e35a5532bc78f79f0a446c7338c74408?s=128&d=identicon&r=PG&f=1","display_name":"kumar","link":"https://stackoverflow.com/users/15571409/kumar"},"is_answered":false,"view_count":46,"closed_date":1623243697,"answer_count":2,"score":-3,"last_activity_date":1623258337,"creation_date":1623243138,"last_edit_date":1623258337,"question_id":67904537,"link":"https://stackoverflow.com/questions/67904537/how-to-convert-different-dates-with-string-format-to-specific-format-like-yyyymm","closed_reason":"Duplicate","title":"How to convert different dates with string format to specific format like YYYYMMDD","body":"I am trying to convert different string date formats to a specific format i.e., YYYYMMDD and all the incoming dates are valid. How can I return a new list of strings representing this format
\n"},{"tags":["r","ggplot2","rstudio","data-visualization","bar-chart"],"owner":{"reputation":1,"user_id":15197952,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgejEfm71-nDZK6wiJlcsyQK7OQ0Uu86aE40yR95g=k-s128","display_name":"Spanias Charalampos","link":"https://stackoverflow.com/users/15197952/spanias-charalampos"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258334,"creation_date":1623258334,"question_id":67908708,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908708/ggplot2-r-percent-stacked-barchart-with-multiple-variables","title":"ggplot2 R : Percent stacked barchart with multiple variables","body":"R version 4.0.5 (2021-03-31)\nPlatform: x86_64-w64-mingw32/x64 (64-bit)\nRunning under: Windows 10 x64 (build 19042)
\nI want to create a percent stacked barchart including 2 groups (regional, international) and the means of 4 different numerical variables (ground low-intensity, ground high-intensity, standing low-intensity, standing high-intensity). The latter variables are representing the duration of each time period in seconds.
\nMy data are:\ndataset
\nThe image below represents an example of what I kind want to make:\nTime-motion analysis description relative to total fight time, considering modalities and positions of actions Coswig, V. S., Gentil, P., Bueno, J. C., Follmer, B., Marques, V. A., & Del Vecchio, F. B. (2018). Physical fitness predicts technical-tactical and time-motion profile in simulated Judo and Brazilian Jiu-Jitsu matches. PeerJ, 6, e4851.
\nI have read a lot of guides and watched many YT tutorials, but most of them are using 2 categorical and 1 numerical variable, thus, it does not work in my case.
\nAny help or guidance would be highly appreciated.
\nThank you in advance.
\n"},{"tags":["javascript","html","function","dropdown","html-select"],"owner":{"reputation":69,"user_id":10215791,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5fac0f428cbf0b557252f469f82981cd?s=128&d=identicon&r=PG&f=1","display_name":"QuestionsAndAnswers","link":"https://stackoverflow.com/users/10215791/questionsandanswers"},"is_answered":false,"view_count":17,"answer_count":0,"score":0,"last_activity_date":1623258330,"creation_date":1623257859,"last_edit_date":1623258330,"question_id":67908604,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908604/search-function-not-working-and-not-showing-results-in-html-element","title":"Search function not working and not showing results in html element","body":"I am creating a web page, on which by clicking the dropdown options and then clicking the Display-button the user can search and load search results of external library web page url into my web page. By clicking the search-button, my web page should fire/call setSearchParameters() -function (which calls other functions related to those specific dropdown options) and load the search results on my webpage.
\nI have checked answers on Stackoverflow from different threads (also those automatically suggested as writing this question), but nothing seems to work. Here is my code so far. Onclick-event by clicking the Display-button should call setSearchParameters() -function and load the results for example on form element.
\nThe problem with my code right now is that when I choose options from the dropdown list and click the Display-button, it does not load the search results at all. It does not show/display any results. I tried Axios for creating search functions for certain dropdown option combinations.
\n<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n <title>Page for library search</title>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css\">\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js\"></script>\n <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js\"></script>\n\n <!--JQuery-libraries: -->\n <link rel=\"stylesheet\" href=\"//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css\">\n <link rel=\"stylesheet\" href=\"/resources/demos/style.css\">\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js\"></script>\n <!-- Axios -->\n <script src=\"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js\"></script>\n\n <script>\n function getFinnishBooks() {\n axios.get('https://finna.fi/Search/Results?limit=0&filter%5B%5D=%7Eformat%3A%220%2FBook%2F%22&filter%5B%5D=%7Elanguage%3A%22fin%22&type=AllFields')\n .then(res => {\n console.log(res.data.login);\n });\n\n .catch(err => {\n console.log(err);\n });\n }\n </script>\n\n <script>\n function getEnglishBooks() {\n axios.get('https://finna.fi/Search/Results?limit=0&filter%5B%5D=%7Eformat%3A%220%2FBook%2F%22&filter%5B%5D=%7Elanguage%3A%22fin%22&filter%5B%5D=%7Elanguage%3A%22eng%22&type=AllFields')\n .then(res => {\n console.log(res.data.login);\n });\n\n .catch(err => {\n console.log(err);\n });\n }\n </script>\n\n <script>\n function getFinnishRecordings() {\n axios.get('https://finna.fi/Search/Results?sort=relevance&bool0%5B%5D=AND&lookfor0%5B%5D=&type0%5B%5D=AllFields&lookfor0%5B%5D=&type0%5B%5D=AllFields&join=AND&filter%5B%5D=%7Elanguage%3A%22fin%22&filter%5B%5D=%7Eformat%3A%220%2FSound%2F%22&limit=20')\n .then(res => {\n console.log(res.data.login);\n });\n\n .catch(err => {\n console.log(err);\n });\n }\n </script>\n\n <script>\n function getEnglishRecordings() {\n axios.get('https://finna.fi/Search/Results?sort=relevance&bool0%5B%5D=AND&lookfor0%5B%5D=&type0%5B%5D=AllFields&lookfor0%5B%5D=&type0%5B%5D=AllFields&join=AND&filter%5B%5D=%7Elanguage%3A%22eng%22&filter%5B%5D=%7Eformat%3A%220%2FSound%2F%22&limit=20');\n console.log(res.data.login);\n });\n\n .catch(err => {\n console.log(err);\n });\n }\n </script>\n\n <script>\n function setSearchParameters() {\n const choice = select.value;\n\n if (choice == 'books' && choice == 'finnish') {\n getFinnishBooks();\n\n } else if (choice == 'books' && choice == 'english') {\n getEnglishBooks();\n } else if (choice == 'books' && choice == 'swedish') {\n getEnglishBooks();\n } else if (choice == 'recordings' && choice == 'finnish') {\n getFinnishRecordings();\n } else if (choice == 'recordings' && choice == 'english') {\n getFinnishRecordings();\n\n else if (choice == 'recordings' && choice == 'swedish') {\n getFinnishRecordings();\n }\n }\n </script>\n\n</head>\n\n<body>\n <!-- /*Style begins*/ -->\n <style>\n .navbar-custom .navbar-brand,\n .navbar-custom .navbar-text {\n color: #FFFFFF;\n }\n /* Modify the background color */\n \n .navbar-custom {\n /*background-color: #AB47BC;*/\n background-color: #4A148C;\n }\n \n .navbar-collapse .collapse {\n color: #FFFFFF;\n }\n \n .dropdown {\n background-color: #FFEBEE;\n }\n \n iframe {\n width: 400px;\n height: 200px;\n border: 1px solid black;\n border-radius: 5px;\n }\n </style>\n <!-- /* Style ends */ -->\n <div class=\"jumbotron text-center\">\n <h1>Search library books and other stuff!</h1>\n <p>Search library books, recordings and other products from the library selection</p>\n </div>\n <!-- /*\n\n*/ -->\n <div class=\"container\">\n <div class=\"example\">\n <script type=\"text/javascript\">\n $(document).ready(function() {\n $('#option-droup-demo').multiselect({\n enableClickableOptGroups: true\n });\n });\n </script>\n <select id=\"option-droup-demo\" multiple=\"multiple\">\n <optgroup label=\"Material\">\n <option value=\"books\">Books</option>\n <option value=\"recordings\">Recordings</option>\n <optgroup label=\"Languages\">\n <option value=\"finnish\">Finnish</option>\n <option value=\"english\">English</option>\n <option value=\"swedish\">Swedish</option>\n </optgroup>\n </select>\n </div>\n </div>\n </div>\n <form>\n <!-- <button type=\"submit\" onclick=\"return setSearchParameters();\">Submit</button> -->\n <input type=\"button\" onclick=\"setSearchParameters()\" value=\"Display\">\n </form>\n</body>\n<footer class=\"bg-light text-center text-lg-start\">\n <div class=\"text-center p-3\" style=\"background-color: rgba(0, 0, 0, 0.2); margin-top: 1%; background-color: #4A148C; color: #FFFFFF; margin-bottom:0%\">\n\n <a class=\"text-white\" href=\"https://finna.fi/\">Original page</a>\n </div>\n</footer>\n\n</html>
\r\nSo typically, on a basic level, you often see firestore collection triggered functions written like:
\nexports.myFunction = functions.firestore\n .document('my-collection/{docId}')\n .onWrite((change, context) => { /* ... */ });\n
\nThat being said, I am running my deployments a bit different, although structurally identical.
\nI deploy the functions via Terraform where I define:
\nSo as you can see, while the way I do it is certainly requires more configuration, it's very much identical, it's just configured in a more GCP-able fashion (if you will)
\nSo, with that context:
\nI am a newbie in python and stackoverflow. I am trying to change my way of thinking about loops.\nI have a series of values which type is <class 'pandas.core.series.Series'>.
\nGoal: Giving a depth n, I would like to compute for each value (except the first 2*n-2) :
\nresult(i) = sum[j=0 to n-1](distance(i,j)*value[i-j])/sum[j=0 to n-1](distance[j])\n\nwith distance(i,j) = sum[k=1 to n-1]((value[i-j]-value[i-j-k])^2)\n
\nI want to avoid loops, so is there a better way to achieve my goal using numpy?
\n"},{"tags":["mysql","node.js","docker","docker-compose","sequelize.js"],"owner":{"reputation":1,"user_id":15919166,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/15419b912a5c2d50aaf5035a516bc290?s=128&d=identicon&r=PG&f=1","display_name":"Lagoss","link":"https://stackoverflow.com/users/15919166/lagoss"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258322,"creation_date":1623258322,"question_id":67908706,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908706/throw-new-sequelizeerrors-connectionerrorerr","title":"throw new SequelizeErrors.ConnectionError(err);","body":"I'm creating a project with docker-compose sequelize nodejs and mysql, where mysql is running in docker-compose, but when I go to do an insert it tells me:
\n/usr/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:116\napp_1 | throw new SequelizeErrors.ConnectionRefusedError(err);\napp_1 | ^\napp_1 | \napp_1 | ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 127.0.0.1:3308\napp_1 | at ConnectionManager.connect (/usr/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:116:17)\napp_1 | at processTicksAndRejections (node:internal/process/task_queues:96:5)\napp_1 | at async ConnectionManager._connect (/usr/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:24)\napp_1 | at async /usr/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32\napp_1 | at async ConnectionManager.getConnection (/usr/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:280:7)\napp_1 | at async /usr/app/node_modules/sequelize/lib/sequelize.js:613:26\napp_1 | at async MySQLQueryInterface.insert (/usr/app/node_modules/sequelize/lib/dialects/abstract/query-interface.js:749:21)\napp_1 | at async User.save (/usr/app/node_modules/sequelize/lib/model.js:3954:35)\napp_1 | at async Function.create (/usr/app/node_modules/sequelize/lib/model.js:2207:12)\napp_1 | at async createUser (/usr/app/src/controllers/UserController.js:11:18) {\napp_1 | parent: Error: connect ECONNREFUSED 127.0.0.1:3308\napp_1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1133:16) {\napp_1 | errno: -111,\napp_1 | code: 'ECONNREFUSED',\napp_1 | syscall: 'connect',\napp_1 | address: '127.0.0.1',\napp_1 | port: 3308,\napp_1 | fatal: true\napp_1 | },\napp_1 | original: Error: connect ECONNREFUSED 127.0.0.1:3308\napp_1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1133:16) {\napp_1 | errno: -111,\napp_1 | code: 'ECONNREFUSED',\napp_1 | syscall: 'connect',\napp_1 | address: '127.0.0.1',\napp_1 | port: 3308,\napp_1 | fatal: true\napp_1 | }\napp_1 | }\napp_1 | [nodemon] app crashed - waiting for file changes before starting...\n\n
\nI'm going to put the file in which I connect to the database and my docker-compose file
\nconnect to database:
\nrequire("dotenv").config();\n\nmodule.exports = {\n dialect: 'mysql',\n host: process.env.HOST,\n port: 3308,\n username: process.env.USER,\n password: process.env.PASSWORD,\n database: process.env.DATABASE,\n define: {\n timestamps: true,\n underscored: true,\n }\n };\n
\nthe HOST is = localhost,
\nI tested the connection in dbeaver and it connected normally, I also managed to create my migrations, only when inserting data using postman, it doesn't work,
\nthis is my docker-compose:
\nversion: '3.7'\nservices: \n db:\n container_name: 'database-node'\n image: mysql:8.0.25\n command: --default-authentication-plugin=mysql_native_password\n restart: always\n ports: \n - '3308:3306'\n environment: \n - MYSQL_ROOT_PASSWORD=root\n - TZ=America/Sao_Paulo \n \n app: \n build: .\n command: npm start\n ports: \n - '3090:3090'\n volumes: \n - .:/usr/app\n
\n"},{"tags":["firebase","firebase-security","firebase-app-check"],"owner":{"reputation":63,"user_id":16164526,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyzeHn9qZzhpeZmzhTrZRfOgyqUOqLwtCcLmhof=k-s128","display_name":"Pooja","link":"https://stackoverflow.com/users/16164526/pooja"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258319,"creation_date":1623258319,"question_id":67908705,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908705/which-data-should-i-hide-to-prevent-unwanted-access-to-my-firebase-database","title":"Which data should I hide to prevent unwanted access to my firebase database?","body":"Firebase provides strong security rules and recently they have introduced Firebase App Check at I/O 2021. All these are good security measures. But even if I do not enforce App Check and write the rules as:
\n".read": true\n".write": true\n
\nWhich information is used by others to access my database and how can I hide those informations?
\n"},{"tags":["php","mysql","amazon-web-services"],"owner":{"reputation":1,"user_id":16177988,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ggl42f5-jHqDBg4IxFVIiRLvuLEPpP4l4XeSO-o=k-s128","display_name":"Codest BD","link":"https://stackoverflow.com/users/16177988/codest-bd"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258310,"creation_date":1623258310,"question_id":67908704,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908704/why-not-write-data-mariadb-database-in-aws-server","title":"Why not write data mariadb database in aws server","body":"I have installed aapanel in AWS server. I transfered my website to aws from namecheap shared hosting. when I transfered my website in aws website work normally without withdraw page. Then I tried in xampp server its work fine. All time not work in AWS server. [Problem: Not write data in database]
\n<?php \n include('config.php');\n session_start();\n $uid=$_SESSION['user']['user_id'];\n date_default_timezone_set('Asia/Dhaka');\n $date=date("Y-m-d h:i");\n $status=1;\n\n $statement290 = $pdo->prepare("SELECT * FROM tbl_member WHERE user_id=?");\n $statement290->execute(array($uid));\n $result290 = $statement290->fetchAll(PDO::FETCH_ASSOC);\n foreach ($result290 as $row290){\n $wcredit=$row290['credit'];\n }\n $amount=$_POST['withdraw_amount']+10;\n \n if \n ($amount >= $wcredit)\n {\n $status=0;\n echo json_encode(array("wstatues"=>"<div role='alert' class='alert alert-danger'>\n <strong>Your withdraw amount is more than your balance!</strong>\n </div>"));\n }\n else if \n ($amount < 500)\n {\n $status=0;\n echo json_encode(array("wstatues"=>"<div role='alert' class='alert alert-danger'>\n <strong>Minimum withdraw 500tk !</strong>\n </div>"));\n }\n if ($status==1){\n\n $state = $pdo->prepare("SELECT * FROM tbl_member WHERE user_id=?");\n $state->execute(array($uid));\n $results = $state->fetchAll(PDO::FETCH_ASSOC);\n foreach ($results as $row) {\n $credit = $row['credit'];\n }\n $final_amount = $credit-$_POST['withdraw_amount'];\n $statement = $pdo->prepare("UPDATE tbl_member SET credit=? WHERE user_id=?");\n $statement->execute(array($final_amount,$uid));\n $a="0";\n $statement = $pdo->prepare("INSERT INTO tbl_withdraw (request_by, amount, method, send_to, account_type, date, withdraw_status) VALUES (?,?,?,?,?,?,?)");\n $statement->execute(array($uid,$_POST['withdraw_amount'],$_POST['withdraw_method'],$_POST['withdraw_to'],$_POST['account_type'],$date,$a));\n\n echo json_encode(array("wstatues"=>"<div role='alert' class='alert alert-success'>\n <strong>Your withdraw has been successfully requested!</strong>\n </div>"));\n $id = $pdo->lastInsertId();\n $detail="Withdraw Request By You";\n $date=date("Y-m-d h:i");\n $type="Withdraw-R";\n $statement2 = $pdo->prepare("INSERT INTO tbl_transaction \n (detail_id, type, description,transaction_date,user_balance)\n VALUES (?,?,?,?,?)");\n $statement2->execute(array($id,$type,$detail,$date,$final_amount));\n }\n?>\n
\n"},{"tags":["java","spring-boot","spring-security","oauth-2.0","spring-security-oauth2"],"owner":{"reputation":576,"user_id":7773888,"user_type":"registered","accept_rate":40,"profile_image":"https://i.stack.imgur.com/iVXmp.jpg?s=128&g=1","display_name":"raviraja","link":"https://stackoverflow.com/users/7773888/raviraja"},"is_answered":false,"view_count":19,"bounty_amount":150,"bounty_closes_date":1623862135,"answer_count":0,"score":0,"last_activity_date":1623258304,"creation_date":1623084471,"last_edit_date":1623258304,"question_id":67875673,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67875673/spring-security-with-oauth2-0-and-form-login","title":"Spring Security with oAuth2.0 and form login","body":"In my Spring Boot application, i am having form based login and oAuth2.0 based login with Google, my security configuration is defined as
\n http\n .cors()\n .and()\n .sessionManagement()\n .sessionCreationPolicy(SessionCreationPolicy.STATELESS)\n .and()\n .csrf()\n .disable()\n .authorizeRequests()\n .antMatchers("/oauth2/**")\n .permitAll()\n .anyRequest()\n .authenticated()\n .and()\n .addFilter(new JWTAuthenticationFilter(authenticationManager()))\n .addFilter(jwtAuthorizationFilter)\n .formLogin()\n .and()\n .oauth2Login()\n .authorizationEndpoint()\n .authorizationRequestRepository(httpCookieOAuth2AuthorizationRequestRepository)\n .and()\n .userInfoEndpoint()\n .userService(customOAuth2UserService)\n .and()\n .successHandler(oAuth2AuthenticationSuccessHandler)\n .failureHandler(oAuth2AuthenticationFailureHandler);\n
\nI am doing stateless authentication with JWT, for form based login JWTAuthenticationFilter
handles the authentication as below.
JWTAuthenticationFilter
\npublic class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {\n//code to authenticate user and generate JWT\n}\n
\nand JWTAuthorizationFilter
validates the JWT for subsequent requests as below.
JWTAuthorizationFilter
\npublic class JWTAuthorizationFilter extends BasicAuthenticationFilter {\n// code to perform authorization\n}\n
\nNow coming to oAuth2.0 customOAuth2UserService
does register the new users and update the existing user information.\nOAuth2AuthenticationSuccessHandler
generates JWT on successful oAuth2.0 authentication.\nNow functionality wise both form login and oAuth2.0 works fine, but there are few tiny issues i am trying to solve which i need help for.
Issues
\nhttp://localhost:8080/login
with wrong form login credentials i am getting a Sign In HTML form with Google login as response body and 200 as status code, ideally I want 400 bad request or something.What configurations i am missing and what can i change to fix these issues, TIA.
\n"},{"tags":["python","plotly","data-visualization","treemap","plotly-python"],"owner":{"reputation":732,"user_id":9524160,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=128","display_name":"callmeanythingyouwant","link":"https://stackoverflow.com/users/9524160/callmeanythingyouwant"},"is_answered":false,"view_count":13,"answer_count":1,"score":0,"last_activity_date":1623258304,"creation_date":1623245252,"question_id":67905114,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67905114/plotly-show-hoverinfo-in-treemap-only-for-child-nodes","title":"Plotly: Show hoverinfo in treemap only for child nodes","body":"import pandas as pd\nimport plotly.express as px\n\ndf = pd.DataFrame({'world':['world']*4,\n 'continent':['SA','SA','NA','NA'],\n 'country':['Brazil','Uruguay','USA','Canada'],\n 'total_cases_per_100':[6,1,12,8]})\n\nfig = px.treemap(df, path=['world','continent','country'],values='total_cases_per_100')\nfig.update_traces(hovertemplate=None, hoverinfo='value')\n
\nThe code above gives the following output-
\n\nAs visible, it displays correctly the value of total_cases_per_100
for USA
and all the other child nodes. But for parent nodes, it sums it up, which is wrong as total_cases_per_100
is a ratio and not a total.
Is there anyway I can hide the value
hoverinfo for all nodes except the children?
In case this is not possible, the actual value for the parent nodes is also available with me but I am not sure how I could replace the generated value with it.
\n"},{"tags":["java","python","backend"],"owner":{"reputation":1,"user_id":16178177,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GiEJYZ5-Aay0sMH5xBPk3zvUqfy_t3FWpyqQVEw2w=k-s128","display_name":"ridhvikaa vasudevan","link":"https://stackoverflow.com/users/16178177/ridhvikaa-vasudevan"},"is_answered":false,"view_count":4,"answer_count":0,"score":-1,"last_activity_date":1623258297,"creation_date":1623258297,"question_id":67908702,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908702/how-am-i-suppose-to-add-a-folder-in-macintosh-hd","title":"How am i suppose to add a folder in Macintosh HD","body":"I am trying to download MongoDB in my Macbook Air. The only problem is I currently have the version 10.15.5 which is why I am not able to add my folder in macintosh HD. How do I fix this problem
\n"},{"tags":["python","pandas","machine-learning","scikit-learn"],"owner":{"reputation":1,"user_id":16006685,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgzYt46_FJu6mEsZRfD8n64v7D-kmMEA7lXIxvO=k-s128","display_name":"Md Masud Rana","link":"https://stackoverflow.com/users/16006685/md-masud-rana"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258293,"creation_date":1623258293,"question_id":67908701,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908701/ml-classification-model-selection-based-on-the-following-data","title":"ML Classification model selection based on the following data?","body":"What kind of ML Classification model suits the best when I want to predict if the person had a good day or bad day based on the everyday data entry shown in the table. Note: DayAnswer target variable, and all other columns are independent.
\n\n"},{"tags":["json","elasticsearch","logstash","kibana","elk"],"owner":{"reputation":1,"user_id":15646025,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/7bce4c3f1d60410498482f967df9cfb5?s=128&d=identicon&r=PG&f=1","display_name":"ES-G","link":"https://stackoverflow.com/users/15646025/es-g"},"is_answered":false,"view_count":7,"answer_count":1,"score":0,"last_activity_date":1623258289,"creation_date":1623253480,"question_id":67907508,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907508/logstash-configuration-to-globally-mutate-sub-index-patterns","title":"Logstash configuration to globally mutate sub index patterns","body":"I have an ELK stack, with some configured index patterns. As part of internal requirements, I need to edit a json object (which is part of that index pattern), globally to "string".\nAs of now, such json object is randomly populated by numerous sub-fields, like "date", "temps", and many more others.\nAll of these are automatically managed by ELK, but I need all of them to be processed and converted (casted) as "strings".
\nSo, the basic configuration is as follows:
\ntype A: "long"\ntype B: "int"\ntype C: "string"\ntype D: "json object"\n
\nwhere type D is a nested json object which includes (as sub fields) numerous other index patterns and fields, like (for example) "typeD.date", "typeD.temps", "typeD.extrastuff", and so on.
\nI need all of the "typeD*
" objects to be casted and converted as strings.\nSo far, I tried to use a .conf with logstash, but it did not work. I will paste my configuration after (numerous) attempts. I tried all these configuration in my own local docker environment.
The log which I tested logstash from was called log_file.json and it contains numerous sample lines, including also the index patterns I want to edit globally with this mutate operation.
\ninput {\n file{\n type => "json"\n path => "/home/container/logstash/log_file.json"\n start_position => "beginning"\n sincedb_path => "/dev/null"\n codec => json\n }\n}\n\nfilter {\n if [message] =~ /\\A\\{.+\\}\\z/ {\n json {\n source => "message"\n }\n\n json {\n source => "[message][typeD]"\n}\n\n mutate {\n convert => ["typeD.*","string"]\n}\n }\n}\n\noutput {\n elasticsearch {\n hosts => "http://localhost:9200"\n index => "logstash-test-%{+yyyy.MM.dd}"\n }\n stdout{}\n}\n
\nAlso, after logging in via Kibana, I can see that the (conf) file has been correctly created and loaded by logstash, but still it fails to convert the index patterns as strings.
\nI would need to know which edits are necessary for the configuration to work. Does the logstash config file need some edit? Is there anything wrong in the setup?
\nThanks
\n"},{"tags":["angular","typescript","drag-and-drop","angular8"],"owner":{"reputation":1227,"user_id":4659026,"user_type":"registered","accept_rate":68,"profile_image":"https://www.gravatar.com/avatar/8f979c90540bc9b5b766ad8f55475c59?s=128&d=identicon&r=PG&f=1","display_name":"Mr.M","link":"https://stackoverflow.com/users/4659026/mr-m"},"is_answered":false,"view_count":52,"answer_count":0,"score":0,"last_activity_date":1623258284,"creation_date":1623221393,"last_edit_date":1623258284,"question_id":67898936,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67898936/drag-and-drop-dynamic-fields-using-ng-drag-drop-using-angular-not-working-as-exp","title":"drag and drop dynamic fields using ng drag drop using angular not working as expected","body":"Team,
\ni am using ng drag and drop to move my dynamic fields from field area to panel area.
\nin my cunrrent code Drag is working but droppable not working.
\nHere is the reference screen.
\ni want to drag no of fields into personal details form.
\n\nHere is my code for drag.
\n <div class="fieldexplorer">\n <div class="sectionHeader_field">\n Field Explorer\n </div>\n <div draggable [dragData]="label" *ngFor="let label of labels;">\n <div class="hoverselect" style="padding: 8px;border: 1px solid black;">\n <span [ngClass]="(label.fieldType=='Number'?'numberbefore':(label.fieldType=='List'?'listbefore':'radiobefore'))">\n </span> {{label.labelName}}\n </div>\n </div>\n
\nHere is the sample droppable
\n <div class="row" [droppable] [dragHintClass]="'drag-hint'" (onDrop)="onAnyDrop($event, 'personalDetails')">\n <div class="col-md-12">\n <div class="form">\n <div class="bgwhite">\n <form [formGroup]="personalDetails">\n <div class="container-fluid">\n <div class="row">\n <div class="col-md-3">\n <mat-form-field class="example-full-width">\n <mat-label>Date of Birth</mat-label>\n <input matInput formControlName="dob" [matDatepicker]="picker" [min]="minDate" [max]="maxDate" />\n <mat-datepicker-toggle [for]="picker"> </mat-datepicker-toggle>\n <mat-datepicker #picker> </mat-datepicker>\n <span *ngIf="personalFieldsLocks['dateOfBirth']" class="fa fa-lock lock_field"></span>\n </mat-form-field>\n </div>\n </div> \n </div>\n </form>\n </div>\n </div>\n </div>\n <div class="row" [droppable] [dragHintClass]="'drag-hint'" (onDrop)="onAnyDrop($event, 'contactDetails')">\n <div class="col-md-12">\n <div class="form_cont">\n <div class="bgwhite_cont">\n <form [formGroup]="contactDetails">\n <div class="container-fluid">\n <div class="row">\n <div class="col-md-3 form-group">\n <mat-form-field>\n <mat-label>Address 1</mat-label>\n <input matInput formControlName="address1" class="form-control" placeholder="Address 1" />\n <span class="fa fa-lock lock_field"></span>\n </mat-form-field>\n </div>\n </div>\n </div>\n </form>\n </div>\n </div>\n
\n \nTS code
\nonAnyDrop(e: any, formGroupName: string) {\n console.log(e, formGroupName);\n if (formGroupName === 'personalDetails') {\n this.addInput(this.personalDetails, e.fieldType, 'ABCED', false);\n } else if (formGroupName === 'contactDetails') {\n this.addInput(this.contactDetails, e.fieldType, 'XYZABC', false);\n }\n }\n
\n"},{"tags":["rust","channels"],"owner":{"reputation":33,"user_id":12114471,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/500568ec03a17b67adf36abc159152a1?s=128&d=identicon&r=PG&f=1","display_name":"JNP","link":"https://stackoverflow.com/users/12114471/jnp"},"is_answered":false,"view_count":9,"answer_count":0,"score":-1,"last_activity_date":1623258282,"creation_date":1623257269,"last_edit_date":1623258282,"question_id":67908477,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908477/receive-message-from-channel-between-modules","title":"Receive message from channel between modules","body":"I have four modules. The client is sending messages and the server is receiving messages. Once the server receives the message, it tries to send the message to the MPSC channel. I put the receiver in the other .rs file where I intend to receive the message.
\nI am not getting any message on the receiver side.
\nMaybe an infinite loop on the server side creates a problem, but is there a way to make this channel communication working?
\nclient.rs
\nuse std::io::prelude::*;\nuse std::os::unix::net::UnixDatagram;\nuse std::path::Path;\nuse std::sync::mpsc;\n\npub fn tcp_datagram_client() {\n pub static FILE_PATH: &'static str = "/tmp/datagram.sock";\n let socket = UnixDatagram::unbound().unwrap();\n match socket.connect(FILE_PATH) {\n Ok(socket) => socket,\n Err(e) => {\n println!("Couldn't connect: {:?}", e);\n return;\n }\n };\n println!("TCP client Connected to TCP Server {:?}", socket);\n loop {\n socket\n .send(b"Hello from client to server")\n .expect("recv function failed");\n }\n}\n\nfn main() {\n tcp_datagram_client();\n}\n
\nserver.rs
\nuse std::os::unix::net::UnixDatagram;\nuse std::path::Path;\nuse std::str::from_utf8;\nuse std::sync::mpsc::Sender;\n\nfn unlink_socket(path: impl AsRef<Path>) {\n let path = path.as_ref();\n if path.exists() {\n if let Err(e) = std::fs::remove_file(path) {\n eprintln!("Couldn't remove the file: {:?}", e);\n }\n }\n}\n\nstatic FILE_PATH: &'static str = "/tmp/datagram.sock";\npub fn tcp_datagram_server(tx: Sender<String>) {\n unlink_socket(FILE_PATH);\n let socket = match UnixDatagram::bind(FILE_PATH) {\n Ok(socket) => socket,\n Err(e) => {\n eprintln!("Couldn't bind: {:?}", e);\n return;\n }\n };\n let mut buf = vec![0; 1024];\n println!("Waiting for client to connect...");\n loop {\n let received_bytes = socket.recv(&mut buf).expect("recv function failed");\n println!("Received {:?}", received_bytes);\n let received_message = from_utf8(&buf).expect("utf-8 convert failed");\n tx.send(received_message.to_string());\n }\n}\n
\nmessage_receiver.rs
\nuse crate::unix_datagram_server;\nuse std::sync::mpsc;\n\npub fn handle_messages() {\n let (tx, rx) = mpsc::channel();\n unix_datagram_server::tcp_datagram_server(tx);\n let message_from_tcp_server = rx.recv().unwrap();\n println!("{:?}", message_from_tcp_server);\n}\n
\nmain.rs
\nmod unix_datagram_server;\nmod message_receiver;\n\nfn main() {\n message_receiver::handle_messages();\n}\n
\nOnce the TCP client is connected:
\nTCP client Connected to TCP Server UnixDatagram { fd: 3, local: (unnamed), peer: "/tmp/datagram.sock" (pathname) }\n
\nI receive no messages on the channel receiver end:
\nWaiting for client to connect...\n
\n"},{"tags":["python","arrays","numpy","multidimensional-array","sub-array"],"owner":{"reputation":1,"user_id":16177879,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b61b9b920195f67176a972e50ed35cc2?s=128&d=identicon&r=PG&f=1","display_name":"Wilfred","link":"https://stackoverflow.com/users/16177879/wilfred"},"is_answered":false,"view_count":9,"answer_count":1,"score":0,"last_activity_date":1623258277,"creation_date":1623256889,"question_id":67908381,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908381/finding-the-indices-of-the-minimum-in-each-2d-array-from-a-3d-array","title":"Finding the indices of the minimum in each 2D array from a 3D array","body":"I'm new to numpy and python in general and I am looking to find the minimum of each 2D subarray, given a 3D array. For example:
\n# construct an example 3D array\na = np.array([[5,4,1,5], [0,1,2,3], [3,2,8,1]]).astype(np.float32)\nb = np.array([[3,2,9,3], [8,6,5,3], [6,7,2,8]]).astype(np.float32)\nc = np.array([[9,7,6,5], [4,7,6,3], [1,2,3,4]]).astype(np.float32)\nd = np.array([[5,4,9,2], [4,2,6,1], [7,5,9,1]]).astype(np.float32)\ne = np.array([[4,5,2,9], [7,1,5,8], [0,2,6,4]]).astype(np.float32)\n\na = np.insert(a, 0, [np.inf]*len(a), axis=1)\nb = np.insert(b, 1, [np.inf]*len(b), axis=1)\nc = np.insert(c, 2, [np.inf]*len(c), axis=1)\nd = np.insert(d, 3, [np.inf]*len(d), axis=1)\ne = np.insert(e, 4, [np.inf]*len(e), axis=1)\n\narr = np.swapaxes(np.dstack((a,b,c,d,e)), 1, 2)\nprint(arr) \n
\ngives this result:\n3D Matrix
\nThe result I'm looking for are the indices of the minimum element from each of the 2D arrays, something like:
\n[[0, 0, 3], # corresponding to the coordinates of element with value 1 in the first 2D array\n [1, 0, 1], # corresponding to the coordinates of element with value 0 in the second 2D array\n [2, 4, 0]] # corresponding to the coordinates of element with value 0 in the third 2D array\n
\nor something similar along those lines. I plan on using the indices to get that value, then replace the column and row in that 2D subarray with infinite values to find a next minimum that isn't in the same row/column.
\nAny help is appreciated, thank you!
\n"},{"tags":["ios","swift","api","alamofire"],"owner":{"reputation":150,"user_id":4975287,"user_type":"registered","profile_image":"https://i.stack.imgur.com/yoZWB.png?s=128&g=1","display_name":"Asbis","link":"https://stackoverflow.com/users/4975287/asbis"},"is_answered":false,"view_count":6,"answer_count":1,"score":0,"last_activity_date":1623258276,"creation_date":1623257978,"question_id":67908629,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908629/error-to-parse-from-alomofire-post-request","title":"Error to parse from alomofire post request","body":"I have an issue with parsing using alamofire. I get an error to try to decode the json file that i get in return from the request.\nI have tried to parse JSON file that looks like this:
\nsuccess({\ndata = {\n id = "eb259a9e-1b71-4df3-9d2a-6aa797a147f6";\n nickname = joeDoe;\n options = {\n avatar = avatar1;\n };\n rooms = "<null>";\n};\n
\n})
\nIt Gives me an error that looks like this:
\nkeyNotFound(CodingKeys(stringValue: "id", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \\"id\\", intValue: nil) (\\"id\\").", underlyingError: nil))\n
\nThe user model looks like this:
\nimport Foundation\n\nstruct userModel: Codable {\n let id: String\n let nickname: String\n let options: options\n let rooms: String\n\nenum CodingKeys: String, CodingKey {\n case id = "id"\n case nickname = "nickname"\n case options = "options"\n case rooms = "rooms"\n }\n}\n\nstruct options: Codable {\n var avatar: String?\nenum CodingKeys: String, CodingKey {\n case avatar = "avatar"\n }\n }\n
\nAnd the function looks like this:
\n func postUser(){\n AF.request("http://test.com/", method: .post, parameters: user).responseJSON {response in\n guard let itemsData = response.data else {\n print("test1")\n return\n }\n do {\n print("hallo!")\n let decoder = JSONDecoder()\n print("")\n print(itemsData)\n print("")\n print(response.description)\n let items = try decoder.decode(userModel.self, from: itemsData)\n print(items)\n DispatchQueue.main.async {\n print("test2")\n }\n } catch {\n print(error)\n print("test3")\n }\n}\n
\nHow do i fix the issue?
\n"},{"tags":["bash","slurm"],"owner":{"reputation":121,"user_id":9654966,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0e16ec0f5c28f1bb42cccdb2f65292b7?s=128&d=identicon&r=PG&f=1","display_name":"Rodrigo Duarte","link":"https://stackoverflow.com/users/9654966/rodrigo-duarte"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258274,"creation_date":1623258274,"question_id":67908698,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908698/submitting-slurm-array-job-with-a-limit-above-maxarraysize","title":"Submitting slurm array job with a limit above MaxArraySize?","body":"I need to submit a slurm array that will run the same script 18000 times (for independent genes), and I wanted to do this in a way that won't cause problems for my Uni's cluster.
\nCurrently, the MaxArraySize
set by the admins is 2048
. I was going to manually set my options like:
First array script:
\n#SBATCH --array=1-2000%300 \n
\nNext script:
\n#SBATCH --array=2001-4000%300\n
\nand so on...
\nBut slurm does not like values above 2048 in the array.
\nWhat's the easiest way of doing this?
\n(All I can think are for loops, but then I'd lose the constraint option from slurm [%300
], to avoid clogging the scheduler.)
Essentially I am making a list of invoices as a bill, it will look like this (in word through powershell, note that the word file doesn't pre-emptively exists, i create a new one and start adding to it):\n
\nThe problem is that I only know how to do the following:
\n$word = New-Object -comobject word.application\n$word.Visible = $false\n$doc = $word.Documents.Add()\n$Selection = $word.Selection\n$Selection.Style="Title"\n$Selection.Font.Bold = 1\n$Selection.ParagraphFormat.Alignment = 2\n$Selection.TypeText("Expected Billing")\n$Selection.TypeParagraph()\n$Selection.Style="No Spacing"\n$Selection.Font.Bold = 0\n$Selection.TypeParagraph()\n
\nAdding text is easy but when it comes to adding tables, I cant get it right.\nAs you can see:
\nActually the numbered tables aren't supposed to have borders either but I left them so you visually see.\nThen of course the total calculated amount which I can do. But notice it comes after the tables so I want tables appending and want to know how to append after them.\nCan someone help me out? I don't know the coding for this.
\n"},{"tags":["javascript","powerpoint"],"owner":{"reputation":93,"user_id":5700239,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/96ada05bb04da1523fb1074399a6a0a4?s=128&d=identicon&r=PG&f=1","display_name":"Avneesh Srivastava","link":"https://stackoverflow.com/users/5700239/avneesh-srivastava"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258265,"creation_date":1623258265,"question_id":67908697,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908697/office-js-powerpoint-reading-custom-properties-from-add-in","title":"office.js, Powerpoint: Reading custom properties from add-in","body":"I am trying to deploy a new powerpoint add-in using the Javascript APIs that microsoft has created.
\nI have looked at both
\nOffice.context.document.settings
Powerpoint.run((ctx) => ctx.presentation)
But I cannot find the custom properties anywhere, Is there any workaround to fetch the same? I thought of parsing OOXML but that seems too tedious for a large document.
\n"},{"tags":["javascript","arrays"],"owner":{"reputation":563,"user_id":15212955,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/25246ba7477630430cb2e58af462e504?s=128&d=identicon&r=PG&f=1","display_name":"Siva Pradhan","link":"https://stackoverflow.com/users/15212955/siva-pradhan"},"is_answered":true,"view_count":48,"answer_count":3,"score":0,"last_activity_date":1623258265,"creation_date":1623168377,"last_edit_date":1623173582,"question_id":67890653,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67890653/two-dimentional-array-problem-statement-in-javascript","title":"Two dimentional array problem statement in javascript","body":"Below is a 2D array that represents movement of an entity over a 2 second period:
\n[[10, 200, 0], [70, 170, 600], [110, 150, 1000], [155, 120, 1600], [155, 120, 2000]]\n
\nEach array elements contains x-coordinate, y-coordinate, and timestamp in such order.
\nI need to transform this data which shows location at sporadic moments in time to an array showing the location at a fixed rate of every 200ms. I need to interpolate the missing values.
\nI know the correct output is:
\n10 200 0\n30 190 200\n50 180 400 \n70 170 600\n90 160 800\n110 150 1000\n125 140 1200\n140 130 1400\n155 120 1600\n155 120 1800\n155 120 2000\n
\nHow can I achieve this?
\n"},{"tags":["azure","form-recognizer"],"owner":{"reputation":244,"user_id":1729816,"user_type":"registered","accept_rate":80,"profile_image":"https://www.gravatar.com/avatar/cba5aa80773b7edde6d445cd4c1abb26?s=128&d=identicon&r=PG","display_name":"Johnnygizmo","link":"https://stackoverflow.com/users/1729816/johnnygizmo"},"is_answered":false,"view_count":12,"answer_count":1,"score":0,"last_activity_date":1623258261,"creation_date":1623247490,"last_edit_date":1623249446,"question_id":67905749,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67905749/unable-to-load-asset-for-pdfs-in-form-recognizer-labeling-tool","title":""Unable to Load Asset" for PDF's in Form Recognizer Labeling Tool","body":"Form Recognizer shows 'unable to load asset' on PDFs. I have tried multiple PDF's from various sources and they all return this error. JPGs work as expected.
\nAn additional error popped up
\n\n\n\n"},{"tags":["java","split"],"owner":{"reputation":11,"user_id":14603352,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-DDu8Hn64Gf0/AAAAAAAAAAI/AAAAAAAAAAA/AMZuuck79kly9Wf0I6tmJuo2ncRJdrglnA/s96-c/photo.jpg?sz=128","display_name":"Aishwarya Roy","link":"https://stackoverflow.com/users/14603352/aishwarya-roy"},"is_answered":false,"view_count":9,"answer_count":0,"score":0,"last_activity_date":1623258261,"creation_date":1623256908,"last_edit_date":1623258261,"question_id":67908388,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908388/counting-mechanism-of-capital-s-in-split-function-in-java","title":"Counting mechanism of Capital S in split function in Java","body":"Uncaught NetworkError: Failed to execute 'importScripts' on\n'WorkerGlobalScope': The script at\n'http://fotts.azureedge.net/npm/pdfjs-dist/2.3.200/pdf.worker.js'\nfailed to load
\n
Whenever I write \\\\S (caps S) , then I get output 13,\nCan anyone tell me how this count 13, I mean why it just remove the last word?
\nTextAreaCount() {\n\n l1=new Label();\n l1.setBounds(150,50,100,30);\n add(l1);\n\n l2=new Label();\n l2.setBounds(250,50,100,30);\n add(l2);\n\n\n area = new TextArea();\n area.setBounds(20, 100, 450, 300);\n add(area);\n\n b = new Button("Count");\n b.setBounds(200, 450, 100, 30);\n b.addActionListener(this);\n add(b);\n\n setSize(500, 500);\n setLayout(null);\n setVisible(true);\n}\n\npublic void actionPerformed(ActionEvent e){\n String Text = area.getText();\n String words[]=Text.split("\\\\S");\n l1.setText("Words : "+words.length);\n l2.setText("Character : "+Text.length());\n}\n\n\n\n\n\npublic static void main(String[] args) {\n new TextAreaCount();\n}\n
\nThis code has the counting for words and characters,\nBut I just want to know why it shows 13 words, I mean, \\\\S split the words, but why it do not count the last word, and just count the all character without the last word?
\n"},{"tags":["html","css","drop-down-menu"],"owner":{"reputation":1,"user_id":16178157,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/396406f920f044469dc74449adccfa9e?s=128&d=identicon&r=PG&f=1","display_name":"Titir","link":"https://stackoverflow.com/users/16178157/titir"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258254,"creation_date":1623258254,"question_id":67908695,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908695/drop-down-menu-link-change-colour","title":"drop-down menu link change colour","body":"I have created a drop-down menu with links.\nWhen i hover on the names, the drop-down menu appears.\nBefore adding the links, I could change colors of the name when the drop-down menu appears.\nI made all names golden and the name over which I hover, turns black and gives drop-down menu and the name remains black while I go through drop-down menu.\nBut ever since I added links and changed all the names to golden, it refuses to turn black when drop-down menu appears
\n"},{"tags":["latex","pdflatex","lyx"],"owner":{"reputation":1,"user_id":16178202,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/06fa2069e28905743a2c7b2a7e5ab752?s=128&d=identicon&r=PG&f=1","display_name":"ska96","link":"https://stackoverflow.com/users/16178202/ska96"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258244,"creation_date":1623258244,"question_id":67908693,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908693/latex-error-missing-begindocument-using-lyx","title":"LaTeX Error: Missing \\begin{document} using LyX","body":"I just switched from MikTeX to TeXLive and I tried to preview a LyX file and I got 3 errors of "LaTeX Error: Missing \\begin{document}". I tried to add it to the preamble, but that did not work. I can use show output anyway and the document runs fine (correctly showing the content) except for the first page which are 4 lines that are just the path to these different filenames:
\nI checked the TeX path and it is correctly TeXLive being used. Can anyone help me?
\n"},{"tags":["python","python-3.x","bash","docker","dockerfile"],"owner":{"reputation":91,"user_id":15864414,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/f2833ab9521869de79e0beffc626d7ca?s=128&d=identicon&r=PG&f=1","display_name":"Opps_0","link":"https://stackoverflow.com/users/15864414/opps-0"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258235,"creation_date":1623258235,"question_id":67908692,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908692/how-to-run-a-bash-script-from-dockerfile","title":"How to run a bash script from dockerfile","body":"I am using a bash script (run.sh
) to run a python file (calculate_ssp.py
). The code is working fine. The folder structure is given below
├── dataset\n └── dataset_1.csv\n├── Dockerfile\n├── __init__.py\n├── output\n├── run.sh\n├── scripts\n│ ├── calculate_ssp.py\n│ ├── __init__.py\n
\nThe bash script is
\n#!/bin/bash\n\npython3 -m scripts.calculate_ssp 0.5\n
\nNow, I am trying to run the bash script (run.sh
) from the Dockerfile
. The content of the Dockerfile is
#Download base image ubuntu 20.04\nFROM ubuntu:20.04\n\n#Download python\nFROM python:3.8.5\n\nADD run.sh .\n\nRUN pip install pandas\nRUN pip install rdkit-pypi\n\nCMD ["bash", "run.sh"]\n
\nBut, I am getting an error /usr/local/bin/python3: Error while finding module specification for 'scripts.calculate_ssp' (ModuleNotFoundError: No module named 'scripts')
Could you tell me why I am getting the error (as the code is working fine from the bash script)?
\n"},{"tags":["python"],"owner":{"reputation":1,"user_id":16178154,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e6235fcea91fe80bb2f588f3611c8694?s=128&d=identicon&r=PG&f=1","display_name":"whited_evil_hack3r","link":"https://stackoverflow.com/users/16178154/whited-evil-hack3r"},"is_answered":false,"view_count":15,"closed_date":1623257722,"answer_count":0,"score":-6,"last_activity_date":1623258234,"creation_date":1623257645,"last_edit_date":1623258234,"question_id":67908564,"link":"https://stackoverflow.com/questions/67908564/write-a-function-that-takes-two-equal-length-strings-and-produces-there-xor-comb","closed_reason":"Needs details or clarity","title":"Write a function that takes two equal length strings and produces there xor combination","body":"My mentor has asked me to study on this question. I'm a complete beginner so please help. This is not a Homework. I wanted to be a ethical hacker, so my father contacted a Person who wanted to check my thinking skills. He said this "you have to write the logic of this code". I'm a complete beginner so please just let me know what I have to do basically. And I don't know anything about xor and etc.
\n"},{"tags":["java","oop","copy-constructor","deep-copy"],"owner":{"reputation":25,"user_id":14979447,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/34c21cf9285487947fa462425695309d?s=128&d=identicon&r=PG&f=1","display_name":"eeelll","link":"https://stackoverflow.com/users/14979447/eeelll"},"is_answered":true,"view_count":16,"answer_count":1,"score":1,"last_activity_date":1623258227,"creation_date":1623257191,"question_id":67908455,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908455/how-to-make-a-deep-copy-of-an-object-with-a-list-variable-in-java","title":"How to make a deep copy of an object with a List variable in Java?","body":"I am working in Java and I want to make a deep copy of a MoleculeDTO object. I tried to make a copy constructor too, but it is not working and it is refering to the initial object.
\npublic class MoleculeDTO {\n private int ID;\n private String name;\n private List<AtomDTO> atoms = new ArrayList<>();\n private int nrAtoms =0;\n\n public MoleculeDTO(String name, List<AtomDTO> atoms, int nrAtoms) {\n this.name = name;\n this.atoms = atoms;\n this.nrAtoms = nrAtoms;\n }\n\n public MoleculeDTO(MoleculeDTO molecule) {\n this(molecule.getName(), molecule.getAtoms(), molecule.getNrAtoms());\n }\n...getter, setter\n}\n
\nHere is class AtomDTO.
\npublic class AtomDTO{\n private int ID;\n private String name;\n private String symbol;\n private int nrOfBonds;\n private List<BondDTO> bonds = new ArrayList<>();\n private int type;\n private AnchorNode anchorNode;\n\n\n public AtomDTO(String name, String symbol, int nrOfBonds, List<BondDTO> bonds, int type) {\n this.name = name;\n this.nrOfBonds = nrOfBonds;\n this.bonds = bonds;\n this.type = type;\n }\n\n public AtomDTO(AtomDTO copyAtom) {\n this(copyAtom.getName(),copyAtom.getSymbol(), copyAtom.getNrOfBonds(), copyAtom.getBonds(), copyAtom.getType());\n }\n...getter, setter\n}\n
\nHere is class BondDTO.
\npublic class BondDTO {\n private int ID;\n private int otherAtomID;\n private int otherAtomType;\n private int bondType;\n\n public BondDTO(int otherAtomID, int otherAtomType, int bondType) {\n this.otherAtomID = otherAtomID;\n this.otherAtomType = otherAtomType;\n this.bondType = bondType;\n }\n\n public BondDTO(BondDTO copyBond) {\n this(copyBond.getOtherAtomID(), copyBond.otherAtomType, copyBond.bondType);\n }\n...getter, setter\n}\n
\n"},{"tags":["sql","hiveql"],"owner":{"reputation":9,"user_id":14655684,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0a3f5f074c1785727ae76a71c32f50ae?s=128&d=identicon&r=PG&f=1","display_name":"Matias021","link":"https://stackoverflow.com/users/14655684/matias021"},"is_answered":false,"view_count":20,"answer_count":0,"score":-1,"last_activity_date":1623258223,"creation_date":1623251729,"last_edit_date":1623258223,"question_id":67907054,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907054/complex-case-with-3-ways","title":"complex case with 3 ways","body":"I have a complex case that I would appreciate to have your advice on it.
\nwhen Order_id exist and if there are 2 rows with the same order_id :\nthen select the row that have no null on seller and comment\nelse select the row with seller and null on the comment and change the null to comment not provided
\n(change the null to not provided)
when order_id does not exist - put not found in both seller and comment
\nPlease see the date example and the Desired result on the photo
\n\nWITH cte1 as (\nSELECT \n a.order_id, \n ,a.cat_id,\n ,COALESCE(b.seller, 'No reason found') as seller\n ,COALESCE(b.comment, 'No comment found') as comment\n FROM table2 AS a\nLEFT JOIN table1 AS b\nON a.order_id = b.order_id\nand a.cat_id = b.cat_id\nGROUP BY \na.order_id\n ,a.cat_id\n ,COALESCE(b.seller, 'No reason found') \n ,COALESCE(b.comment, 'No comment found') \n)\n,\ncte2 as (\nselect \norder_id, \ncat_id,\nname,\nbrand,\nyear,\n\nfrom table2 \n\n\n) \n\nselect\ncb.order_id, \ncb.cat_id,\ncb.name,\ncb.brand,\ncb.year,\nca.seller,\nca.comment\nfrom cte1 as ca left join mca as cte2 as cb on \nca.order_id=cb.order_id\nand ca.cat_id=cb.cat_id\nGROUP BY\ncb.order_id, \ncb.cat_id,\ncb.name,\ncb.brand,\ncb.year,\nca.seller,\nca.comment\n
\n"},{"tags":["c","command-line-arguments"],"owner":{"reputation":1,"user_id":16178169,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyGO2dy6KfymSm1J9AnFDkqcRib7NgpRr8YPxMM=k-s128","display_name":"Rakesh Sharma chemist","link":"https://stackoverflow.com/users/16178169/rakesh-sharma-chemist"},"is_answered":false,"view_count":14,"answer_count":1,"score":0,"last_activity_date":1623258221,"creation_date":1623257778,"question_id":67908589,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908589/how-to-get-list-of-all-command-line-argument-and-forward-all-of-those-arguments","title":"How to get list of all command line argument and forward all of those arguments to another command in C","body":"i have been searched for this issue but didn't found any solution.\nActually i want to create a Compiled in C, and if i enter ant argument to that file then it forwards the argument to another command via system()\nLet me explain,\nsuppose, growkl is my C compiled file.\nand in terminal, i wrote this :
\ngrowkl TRYNEW /etc/cron.d ./grill/mk\n
\nand then, the growkl file will forward all these arguments ( TRYNEW /etc/cron.d ./grill/mk ) to the command /usr/bin/gkbroot\nIn this way :
\n/usr/bin/gkbroot TRYNEW /etc/cron.d ./grill/mk\n
\nI'm a newbie with these things, so I'm not getting how to do this.\nCan anyone tell me
\n"},{"tags":["r","dplyr"],"owner":{"reputation":321,"user_id":13734451,"user_type":"registered","profile_image":"https://i.stack.imgur.com/phKcJ.jpg?s=128&g=1","display_name":"Moses","link":"https://stackoverflow.com/users/13734451/moses"},"is_answered":true,"view_count":20,"accepted_answer_id":67904850,"answer_count":3,"score":2,"last_activity_date":1623258219,"creation_date":1623244008,"last_edit_date":1623258219,"question_id":67904783,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67904783/is-there-a-way-to-collapse-related-variables-into-a-single-based-on-a-condition","title":"Is there a way to collapse related variables into a single based on a condition?","body":"Lets say I have multiple variables that measure substance abuse i.e a1 is on alcohal usage,\na2 is on bhang and a3 is on cocaine. I would like to generate variable afin that indicates engaged in substance abuse if any of the the three is yes.
\nIs there a way to shorten the code so I don't specify use multiple ifelse
statements as below? Trying to find the best way to do it because I have more than 10 variables to collapse into one and writing ifelse
may not be ideal.
# Anymatch\nlibrary(tidyverse)\n\nset.seed(2021)\n\nmydata <- tibble(\n a1 = factor(round(runif(20, 1, 3)),\n labels = c("Yes", "No", "N/A")),\n a2 = factor(round(runif(20, 1, 3)),\n labels = c("Yes", "No", "N/A")),\n a3 = factor(round(runif(20, 1, 3)),\n labels = c("Yes", "No", "N/A")),\n b1 = round(rnorm(20, 10, 2)))\nmydata\n\nmydata <- mydata %>%\n mutate(afin = ifelse(a1 == "Yes"|a2=="Yes"|a3=="Yes", "Yes", "No"))\n\n
\n"},{"tags":["java","tomcat","classloader","classnotfoundexception","jcs"],"owner":{"reputation":1429,"user_id":9341540,"user_type":"registered","accept_rate":100,"profile_image":"https://www.gravatar.com/avatar/7dde858ecafcaa645e231e3c64dd79ea?s=128&d=identicon&r=PG&f=1","display_name":"Klaus","link":"https://stackoverflow.com/users/9341540/klaus"},"is_answered":false,"view_count":2,"answer_count":0,"score":0,"last_activity_date":1623258218,"creation_date":1623258218,"question_id":67908689,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908689/classnotfoundexception-while-reading-object-from-file-in-jcs-cache","title":"ClassNotFoundException while reading object from file in JCS Cache","body":"I am using JCS caching in my web application and time to time the JCS get
method throws ClassNotFoundException
upon trying to read object from the IndexedDiskCache
. Usually after server startup and then continues..
Sample code:
\nGenericResult cachedResult = jcs.get( "myKey" );\n
\nCache configurations.
\njcs.region.generic_result_store='DC'\njcs.region.generic_result_store.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache\njcs.region.generic_result_store.cacheattributes.MaxMemoryIdleTimeSeconds=3600\njcs.region.generic_result_store.elementattributes.IdleTime=3600\njcs.region.generic_result_store.cacheattributes.MaxObjects=400\njcs.region.generic_result_store.cacheattributes.MaxSpoolPerRun=500\njcs.region.generic_result_store.elementattributes.MaxLifeSeconds=7200\njcs.region.generic_result_store.elementattributes.IsLateral=false\njcs.region.generic_result_store.elementattributes.IsRemote=false\njcs.region.generic_result_store.cacheattributes.UseMemoryShrinker=true\njcs.region.generic_result_store.elementattributes.IsEternal=true\njcs.region.generic_result_store.elementattributes.IsSpool=true\njcs.region.generic_result_store.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes\njcs.region.generic_result_store.elementattributes=org.apache.jcs.engine.ElementAttributes\njcs.region.generic_result_store.cacheattributes.ShrinkerIntervalSeconds=300\n
\nException:
\nRegion [generic_result_store] Exception, Problem reading object from file java.lang.ClassNotFoundException: com.example.result.GenericResult\nat java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435) ~[?:?]\nat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[?:?]\nat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]\nat java.base/java.lang.Class.forName0(Native Method) ~[?:?]\nat java.base/java.lang.Class.forName(Class.java:468) ~[?:?]\nat java.base/java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:782) ~[?:?]\nat java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2028) ~[?:?]\nat java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1895) ~[?:?]\nat java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2202) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1712) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:519) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:477) ~[?:?]\nat java.base/java.util.ArrayList.readObject(ArrayList.java:899) ~[?:?]\nat java.base/jdk.internal.reflect.GeneratedMethodAccessor1272.invoke(Unknown Source) ~[?:?]\nat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]\nat java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]\nat java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1226) ~[?:?]\nat java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2401) ~[?:?]\nat java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2235) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1712) ~[?:?]\nat java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2540) ~[?:?]\nat java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2434) ~[?:?]\nat java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2235) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1712) ~[?:?]\nat java.base/java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2540) ~[?:?]\nat java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2434) ~[?:?]\nat java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2235) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1712) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:519) ~[?:?]\nat java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:477) ~[?:?]\nat org.apache.jcs.utils.serialization.StandardSerializer.deSerialize(StandardSerializer.java:73) ~[jcs-1.3.jar:1.3]\n
\nThe class GenericResult
is bundled with my web application and the dependency JCS
library is provided in the Apache Tomcat's lib folder.JCS version 1.3
My webapps POM :
\n<dependency>\n <groupId>org.apache.jcs</groupId>\n <artifactId>jcs</artifactId>\n <version>1.3</version>\n <scope>provided</scope>\n</dependency>\n
\nThis only happens time to time and when this happens, restarting the tomcat fixes this issue for a period of time. Is there anything I am missing here or can someone explain to me why this is happening.
\nIf possible kindly let me know how the class loading happens behind the scenes, As per Tomcat Docs from the perspective of a web application, class or resource loading looks in Bootstrap classes of your JVM -> /WEB-INF/classes of your web application -> /WEB-INF/lib/*.jar of your web application -> System class loader classes -> Common class loader classes. In my scenario, the class com.example.result.GenericResult
should be found in the /WEB-INF/classes
but that is not happening ( or am I wrong here?? )
Following is my code to update view height inside tableview cell
\n override func layoutSubviews() {\n super.layoutSubviews()\n layout()\n}\n\nfileprivate func layout() {\n rootFlexContainer.frame.size.width = frame.width - 20\n rootFlexContainer.flex.layout(mode: .adjustHeight)\n if(rootFlexContainer.frame.height != 0) {\n tagsHeight.constant = rootFlexContainer.frame.height\n \n }\n \n \n}\n
\nalthough this is not reflected till I scroll i.e is cell is recreated. How to update constraint inside TableViewCell of a view?
\nhere is entire tableviewcell code
\nimport UIKit\nimport FlexLayout\nimport SDWebImage\n\n\n\nclass StoreListTableViewCell: UITableViewCell {\n\n\n@IBOutlet weak var menuLbl: UILabel!\n\n\n@IBOutlet weak var menuView: UIView!\n\n@IBOutlet weak var cellBgview: UIView!\n@IBOutlet weak var storeImg: UIImageView!\n@IBOutlet weak var storeLocation: UILabel!\n@IBOutlet weak var storeTitle: UILabel!\n\n@IBOutlet weak var cellContainer: UIView!\n\n\n@IBOutlet weak var stackView: UIStackView!\n\n\n@IBOutlet weak var tagsHeight: NSLayoutConstraint!\nvar storeImgStr = ""\nvar storeTitleStr = ""\nvar storeLocationStr = ""\nvar score : Double = 0.0\nvar tagsStr = ""\nvar isMenuAvailble = 0\nvar retailerTags: [String]?\nvar cashbackString = ""\nfileprivate let rootFlexContainer = UIView()\n\n\n\n@IBOutlet weak var tagsView: UIView!\n\n\n@IBOutlet weak var ratingBtn: UIButton!\noverride func awakeFromNib() {\n super.awakeFromNib()\n self.layoutIfNeeded()\n cellBgview.clipsToBounds = true\n cellBgview.layer.cornerRadius = 5\n cellContainer.layer.shadowColor = UIColor.lightGray.cgColor\n cellContainer.layer.shadowOpacity = 0.5\n cellContainer.layer.shadowRadius = 5.0\n cellContainer.layer.shadowOffset = CGSize(width: 0, height: 2)\n cellContainer.backgroundColor = UIColor.clear\n cellContainer.layer.cornerRadius = 5.0\n cellContainer.layer.borderColor = UIColor.white.cgColor\n cellContainer.layer.borderWidth = 0.5\n ratingBtn.layer.borderWidth = 1\n ratingBtn.layer.cornerRadius = 5\n tagsView.addSubview(rootFlexContainer)\n \n //cellContainer.layer.shadowPath = UIBezierPath(rect: cellBgview.bounds).cgPath\n }\n\nfunc setSetupStoreUI() {\n \n if isMenuAvailble == 1 {\n menuView.isHidden = false\n menuView.layer.cornerRadius = 10\n } else {\n menuView.isHidden = true\n }\n \n storeTitle.text = storeTitleStr\n // storeTitle.sizeToFit()\n storeLocation.text = storeLocationStr\n //storeLocation.sizeToFit()\n \n\n //.filter{ $0.name != " " }\n //storeImg.sd_imageIndicator = SDWebImageActivityIndicator.gray\n storeImg.backgroundColor = UIColor.hexStringToUIColor(hex: AppStrings.placeHolderColor)\n if let url = URL(string: storeImgStr.encoded), !(storeImgStr.isEmpty) {\n self.storeImg.sd_setImage(with: url)\n \n }\n \n \n menuLbl.text = AppLocalString.PREORDER_TEXT.localized()\n menuLbl.font = FontStyle.ProximaNovaBold(size: 12)\n\n storeTitle.font = FontStyle.ProximaNovaSemibold(size: 14)\n storeLocation.font = FontStyle.ProximaNovaRegular(size: 12)\n storeLocation.textColor = .gray\n // ratingBtn.isHidden = (score == 0)\n ratingBtn.setTitle(score == 0 ? "-" : String(format: "%.1f", score), for: .normal)\n ratingBtn.backgroundColor = UIColor.hexStringToUIColor(hex: Utility.getRatingColor(rating: score))\n ratingBtn.layer.borderColor = UIColor.hexStringToUIColor(hex: Utility.getRatingColor(rating: score)).cgColor\n \n rootFlexContainer.subviews.forEach({ $0.removeFromSuperview() })\n //tagsView.willRemoveSubview(rootFlexContainer)\n //rootFlexContainer.frame = tagsView.frame\n //tagsView.addSubview(rootFlexContainer)\n rootFlexContainer.flex.direction(.row).wrap(.wrap).alignSelf(.auto).justifyContent(.start).paddingRight(2).define { (flex) in\n for i in 0..<((retailerTags?.count ?? 0) > 3 ? 3 : (retailerTags?.count ?? 0)) {\n let nameLabel = UIButton()\n nameLabel.isUserInteractionEnabled = false\n nameLabel.setTitle((retailerTags?[i] ?? "").trim(), for: .normal)\n nameLabel.setTitleColor(.black, for: .normal)\n nameLabel.titleLabel?.font = FontStyle.ProximaNovaRegular(size: 11)\n nameLabel.contentEdgeInsets = UIEdgeInsets(top: 1.5, left: 4, bottom: 1.5, right:4)\n nameLabel.layer.borderColor = UIColor.hexStringToUIColor(hex: AppStrings.grayBorderColor).cgColor\n nameLabel.layer.cornerRadius = 8\n nameLabel.layer.borderWidth = 1.0\n nameLabel.sizeToFit()\n flex.addItem(nameLabel).margin(2)\n \n }\n if cashbackString != "" {\n let cashbackLabel = UIButton()\n \n cashbackLabel.backgroundColor = UIColor.hexStringToUIColor(hex: AppStrings.orangeCashbackColor)\n cashbackLabel.isUserInteractionEnabled = false\n cashbackLabel.setTitle(cashbackString, for: .normal)\n cashbackLabel.setTitleColor(.black, for: .normal)\n cashbackLabel.titleLabel?.font = FontStyle.ProximaNovaRegular(size: 10)\n cashbackLabel.contentEdgeInsets = UIEdgeInsets(top: 1.5, left: 5, bottom: 1.5, right: 5)\n cashbackLabel.layer.cornerRadius = 5\n cashbackLabel.layer.borderWidth = 0\n cashbackLabel.sizeToFit()\n flex.addItem(cashbackLabel).margin(2)\n }\n \n }\n rootFlexContainer.flex.layout()\n if retailerTags?.count ?? 0 == 0 {\n tagsView.isHidden = true\n } else {\n tagsView.isHidden = false\n }\n \n \n \n}\n\n\noverride func layoutSubviews() {\n super.layoutSubviews()\n layout()\n}\n\nfileprivate func layout() {\n rootFlexContainer.frame.size.width = frame.width - 20\n rootFlexContainer.flex.layout(mode: .adjustHeight)\n if(rootFlexContainer.frame.height != 0) {\n tagsHeight.constant = rootFlexContainer.frame.height\n \n }\n \n \n}\n\n\n\noverride func setSelected(_ selected: Bool, animated: Bool) {\n super.setSelected(selected, animated: animated)\n \n // Configure the view for the selected state\n}\n\n}\n
\nFollowing is view hierarchy from stroryboard
\n\n"},{"tags":["swift","firebase","firebase-realtime-database"],"owner":{"reputation":13,"user_id":16069696,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/566941fd877c1da2c346cd5a899a5732?s=128&d=identicon&r=PG&f=1","display_name":"bdriii","link":"https://stackoverflow.com/users/16069696/bdriii"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258215,"creation_date":1623258215,"question_id":67908688,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908688/the-problem-is-that-selecting-the-image-is-mandatory-in-firebase-swift","title":"The problem is that selecting the image is mandatory in firebase swift","body":"I have a button to send and save the data in firebase
\ndata is : TextFiled and TextView and Color and Image
\nThe problem is in the picture
\nI can not perform the transmission without selecting the image
\nI want to make it optional
\nThis Button Code :
\n@IBAction func SendBtn(_ sender: Any) {\n\n if let profileImage = SelecSubStorge , let profileIMG = profileImage.jpegData(compressionQuality: 0.1) {\n \n let udidImage = NSUUID().uuidString\n let storeg = Storage.storage().reference(withPath: "gs://myproduct-744cb.appspot.com").child(udidImage)\n \n storeg.putData(profileIMG, metadata: nil) { metaDate, error in\n if error != nil {\n print(error?.localizedDescription)\n return\n } else {\n storeg.downloadURL { url, error in\n let imgSub = url?.absoluteString\n \n let cgColor = self.ColorIsColor!.cgColor\n self.labelColor = CIColor(cgColor: cgColor).stringRepresentation\n \n let ref = Database.database().reference()\n let sub = ref.child("Sub")\n let udid = sub.childByAutoId().key\n let setRef = sub.child(udid!)\n let value = ["sub": self.subjectLB.text , "detiles" : self.detilesTextview.text , "ImgSub" : imgSub , "SubID" : udid , "Color" : self.labelColor , "Alignment" : self.data0 , "sizeFont" : self.SliderSize ] as [String : Any]\n setRef.setValue(value) { error, ref in\n if error != nil {\n print(error?.localizedDescription)\n } else {\n \n let alert = UIAlertController(title: "Done", message: "Done Send", preferredStyle: UIAlertController.Style.alert)\n\n alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))\n\n self.present(alert, animated: true, completion: nil)\n \n \n }\n }\n }\n }\n }\n }\n}\n
\nWhere is the problem and how can I make it optional?
\n"},{"tags":["java","arrays","char"],"owner":{"reputation":47,"user_id":15393275,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5bb1dc9724fcc8822a160be3fd44d773?s=128&d=identicon&r=PG&f=1","display_name":"Ciro Mertens","link":"https://stackoverflow.com/users/15393275/ciro-mertens"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623258207,"creation_date":1623258207,"question_id":67908687,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908687/start-a-char-array-from-a-certain-index","title":"start a char array from a certain index","body":"I already have a char array called data. I should write a method that makes it possible to return the array but with a starting point that is an integer variable called beginIndex.\nExample: array is A, B, C, D and beginIndex = 2. Then it should return B, C, D (yes the index himself in this case the 2nd letter should be included as well!)
\nHow do I do this? Or is it wiser to change it into a String and later change it back into a char array?
\n"},{"tags":["excel","vba"],"owner":{"reputation":1,"user_id":10615000,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/812f8844227e4a73152395be36d136bb?s=128&d=identicon&r=PG&f=1","display_name":"kekehere","link":"https://stackoverflow.com/users/10615000/kekehere"},"is_answered":false,"view_count":3,"closed_date":1623258256,"answer_count":0,"score":0,"last_activity_date":1623258207,"creation_date":1623258207,"question_id":67908686,"link":"https://stackoverflow.com/questions/67908686/why-my-data-is-not-place-in-a-specific-row","closed_reason":"Duplicate","title":"Why my data is not place in a specific row?","body":"i tried to place the data at column 5 row B but the data place at bottom of the excel table
\nPrivate Sub CommandButton20_Click() \n\nDim sh As Worksheet\nDim le As Long\nDim lastrow As Double\nSet sh = ThisWorkbook.Sheets("SUM-REBAR (C)")\nlastrow = ActiveSheet.Cells(Rows.Count, 5).End(xlUp).Row \nWith sh\n.Cells(lastrow + 1, "B") = TextBox33.Value \n.Cells(lastrow + 1, "C") = TextBox35.Value\n.Cells(lastrow + 1, "D") = TextBox34.Value\n.Cells(lastrow + 1, "E") = TextBox36.Value\nEnd With\nEnd Sub\n
\n"},{"tags":["validation","blazor","data-annotations","blazor-editform"],"owner":{"reputation":21,"user_id":8919663,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/9f7e2b8dea3104c58a3da4ebab209796?s=128&d=identicon&r=PG&f=1","display_name":"Antonito","link":"https://stackoverflow.com/users/8919663/antonito"},"is_answered":false,"view_count":22,"answer_count":1,"score":0,"last_activity_date":1623258202,"creation_date":1623171883,"last_edit_date":1623175690,"question_id":67891540,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67891540/in-blazor-execute-a-method-after-validating-an-inputtext-by-dataannotation","title":"In Blazor, execute a method after validating an InputText by DataAnnotation","body":"I need to check if data typed in a inputtext is valid, and if it is, then execute a method.\n(Validation by a DataAnnotation
).
I tried in the OnFieldChanged
event of EditForm
but this one executes before validation.
How could I do this?
\n"},{"tags":["android","flutter","app-actions"],"owner":{"reputation":1,"user_id":16172032,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJw30eLoGC5_UVtDwY7j_5jlpBABbH7SsiKQiy0Z=k-s128","display_name":"Prashant Nath","link":"https://stackoverflow.com/users/16172032/prashant-nath"},"is_answered":false,"view_count":13,"answer_count":0,"score":-1,"last_activity_date":1623258200,"creation_date":1623219527,"last_edit_date":1623258200,"question_id":67898585,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67898585/how-to-use-google-assistant-app-actions-from-my-flutter-app","title":"How to use Google Assistant app actions from my Flutter app?","body":"I am facing this issue for a long time and I want to know if someone can help me to solve this problem. I want to use app actions feature powered by google assistant to control the custom app actions using flutter app,but I am unable to find something till know as google developers shown this feature with koatlin language and I have not any clue that how same can be done on flutter app.
\n"},{"tags":["swift","augmented-reality","arkit","realitykit"],"owner":{"reputation":1,"user_id":16178188,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GivGf0rLDumlJzao7aftaW0M_U54FVrHwn6XO57Yw=k-s128","display_name":"Jonathan Lessiohadi","link":"https://stackoverflow.com/users/16178188/jonathan-lessiohadi"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258196,"creation_date":1623258196,"question_id":67908684,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908684/arkit-realitykit-shows-coloring-based-on-distance","title":"ARKit/RealityKit shows coloring based on distance","body":"I have been trying to find an answer to this for hours to no avail. Currently the mesh that shows scene reconstruction shows different colors based on how far the object is from the camera. I have tried all kinds of variations of the code below from many different sources (including from the Swift documentation), but no matter what I do, I cannot get the colors to be uniform or be colored based on classification. If anyone has any ideas on how to fix this, that would be greatly appreciated. Alternatively, I have heard that there is something similar to this in SceneKit, so if no one can figure this out, then I will also take suggestions on how to do it with SceneKit. Thanks in advance.
\nimport UIKit\nimport RealityKit\nimport ARKit\n\nextension ARMeshClassification {\n var description: String {\n switch self {\n case .ceiling: return "Ceiling"\n case .door: return "Door"\n case .floor: return "Floor"\n case .seat: return "Seat"\n case .table: return "Table"\n case .wall: return "Wall"\n case .window: return "Window"\n case .none: return "None"\n @unknown default: return "Unknown"\n }\n }\n var color: UIColor {\n switch self {\n case .ceiling: return .red\n case .door: return .green\n case .floor: return .blue\n case .seat: return .cyan\n case .table: return .magenta\n case .wall: return .yellow\n case .window: return .black\n case .none: return .systemOrange\n @unknown default: return .white\n }\n }\n}\n\nclass ViewController: UIViewController {\n \n @IBOutlet var arView: ARView!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n arView.automaticallyConfigureSession = false\n let config = ARWorldTrackingConfiguration()\n config.sceneReconstruction = .meshWithClassification\n arView.debugOptions.insert(.showSceneUnderstanding)\n }\n}\n
\n"},{"tags":["c","math","numbers","keypad","codevisionavr"],"owner":{"reputation":58,"user_id":15899360,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ghh109vjCXAI5UBujH35PSQajbJOVVncuG0A8w6zg=k-s128","display_name":"Zavosh Ghorbanpour","link":"https://stackoverflow.com/users/15899360/zavosh-ghorbanpour"},"is_answered":false,"view_count":48,"answer_count":0,"score":1,"last_activity_date":1623258193,"creation_date":1623152938,"last_edit_date":1623258193,"question_id":67886300,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67886300/keypad-function-return-wrong-number","title":"keypad function return wrong number","body":"in ScanKey function which is for keypad 3*4 its work well until numbers length under 4\nit works like this number = (number * 10)
but for a number like this 123456 which have more than 4 number it gives me other numbers what should I do? my program works with an int that's I use integer.\nwhen I enter a number like 555555 it changes to 31267.\nIDE CodeVisionAVR\nC language for ATmega16a
struct User\n{\n unsigned long int username;\n unsigned long int password;\n bool role;\n};\n\nunsigned long int username;\nunsigned long int password;\n\n
\n do\n {\n lcd_clear();\n lcd_putsf("Enter Username:");\n lcd_gotoxy(0, 1);\n sprintf(show, "%d", username);\n lcd_puts(show);\n lcd_gotoxy(0, 2);\n lcd_putsf("Enter Password:");\n lcd_gotoxy(0, 3);\n password = ScanKey();\n if (!password)\n {\n break;\n }\n else if (password / 10 < 10)\n {\n PORTC .1 = 1;\n lcd_clear();\n lcd_putsf("At least 3 numbers !");\n delay_ms(150);\n PORTC .1 = 0;\n }\n } while (password / 10 < 10);\n\n if (username && password)\n {\n user[UL].role = false;\n lcd_clear();\n if (currentUser < 0 && !currentUser)\n {\n lcd_putsf("Promote to admin ? ");\n lcd_gotoxy(0, 1);\n lcd_putsf("Yes press 1");\n lcd_gotoxy(0, 2);\n lcd_putsf("No press 2");\n if (ScanKey() == 1)\n {\n user[UL].role = true;\n }\n lcd_gotoxy(0, 3);\n }\n user[UL].username = username;\n user[UL].password = password;\n UL++;\n PORTC .0 = 1;\n lcd_putsf("User added !!");\n delay_ms(150);\n PORTC .0 = 0;\n }\n
\nunsigned long int ScanKey(void)\n{\n unsigned long int num = 0;\n _lcd_write_data(0x0F);\n PORTC .2 = 1;\n while (1)\n {\n PORTD .0 = 0;\n PORTD .1 = 1;\n PORTD .2 = 1;\n delay_ms(5);\n if (PIND .3 == 0)\n {\n while (PIND .3 == 0)\n ;\n lcd_putchar('1');\n num = (num * 10) + 1;\n }\n else if (PIND .4 == 0)\n {\n while (PIND .4 == 0)\n ;\n lcd_putchar('4');\n num = (num * 10) + 4;\n }\n else if (PIND .5 == 0)\n {\n while (PIND .5 == 0)\n ;\n lcd_putchar('7');\n num = (num * 10) + 7;\n }\n else if (PIND .6 == 0)\n {\n while (PIND .6 == 0)\n ;\n _lcd_write_data(0x10);\n lcd_putchar(' ');\n _lcd_write_data(0x10);\n num /= 10;\n }\n\n PORTD .0 = 1;\n PORTD .1 = 0;\n PORTD .2 = 1;\n delay_ms(5);\n if (PIND .3 == 0)\n {\n while (PIND .3 == 0)\n ;\n lcd_putchar('2');\n num = (num * 10) + 2;\n }\n else if (PIND .4 == 0)\n {\n while (PIND .4 == 0)\n ;\n lcd_putchar('5');\n num = (num * 10) + 5;\n }\n else if (PIND .5 == 0)\n {\n while (PIND .5 == 0)\n ;\n lcd_putchar('8');\n num = (num * 10) + 8;\n }\n else if (PIND .6 == 0)\n {\n while (PIND .6 == 0)\n ;\n lcd_putchar('0');\n num = (num * 10) + 0;\n }\n\n PORTD .0 = 1;\n PORTD .1 = 1;\n PORTD .2 = 0;\n delay_ms(5);\n if (PIND .3 == 0)\n {\n while (PIND .3 == 0)\n ;\n lcd_putchar('3');\n num = (num * 10) + 3;\n }\n else if (PIND .4 == 0)\n {\n while (PIND .4 == 0)\n ;\n lcd_putchar('6');\n num = (num * 10) + 6;\n }\n else if (PIND .5 == 0)\n {\n while (PIND .5 == 0)\n ;\n lcd_putchar('9');\n num = (num * 10) + 9;\n }\n else if (PIND .6 == 0)\n {\n while (PIND .6 == 0)\n ;\n break;\n }\n }\n PORTC .2 = 0;\n _lcd_write_data(0x0C);\n return num;\n}```\n
\n"},{"tags":["java","sorting","oop","arraylist"],"owner":{"reputation":109,"user_id":9269308,"user_type":"registered","profile_image":"https://graph.facebook.com/199011024012083/picture?type=large","display_name":"Jonathan Baxevanidis","link":"https://stackoverflow.com/users/9269308/jonathan-baxevanidis"},"is_answered":false,"view_count":8,"answer_count":0,"score":0,"last_activity_date":1623258185,"creation_date":1623256794,"last_edit_date":1623258185,"question_id":67908351,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908351/how-to-sort-file-using-arraylist-according-to-specific-token","title":"How to sort file using Arraylist according to specific token?","body":"I have a file that has some info about ticket issuance which looks like that.
\nTest Passenger Aegean Business 06:00 Athens-London 650.92 E1 T9759 09/06/2021 12:45:22\nTest Passenger RyanAir Economy 10:30 Athens-London 200.65 E2 T9946 09/06/2021 12:45:30\nTest Passenger Lufthansa Business 12:30 Athens-London 700.50 E3 T8189 09/06/2021 12:45:37\n
\nThe attributes are passengerName
, Company
, ticketClass
, departureTime
, itenerary
, ticketCost
, gate
, ticketId
, issueDate
which are seperated using "\\t" as the delimiter
.\nEvery input in the file is a String
. The file gets loaded in an Arraylist
from where I try to sort it according to the price of the ticket. What I do is I split the arraylist in tokens in order to get the correct thing to compare from each arraylist, but it doesn’t seem to work. Also I have tried to implement all the Collections.sort()
examples that I found but still nothing works. The desired result to get the file sorted so I can display it in a JTextArea
.Every field of the file is a String which is an attribute of the Ticket class
and the ArrayList is of type Ticket (ArrayList<Ticket> = new ArrayList();
). Here is what I have till now.
private void loadFromFile(String fileName) {\n \n ArrayList<Ticket> ticketsList = new ArrayList();\n\n try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {\n \n String line = "";\n String[] tokens;\n Ticket ticket = new Ticket();\n \n float totalTicketCost = (float) 0.00;\n int numberOfLines = 0;\n\n while(reader.ready()){\n line = reader.readLine();\n\n tokens = line.split("\\t");\n\n if (tokens.length == 9) {\n\n ticket = new Ticket(tokens[0], tokens[1], tokens[2], tokens[3], tokens[4], tokens[5],tokens[6], tokens[7], tokens[8]);\n ticketsList.add(ticket);\n }\n\n area.append(ticket.toString());\n\n totalTicketCost += Float.parseFloat(tokens[5]);\n \n // format dacimals for total cost\n DecimalFormat df = new DecimalFormat();\n df.setMaximumFractionDigits(2);\n\n numberOfTickets.setText(String.valueOf(numberOfLines));\n totalCost.setText(String.valueOf(df.format(totalTicketCost)));\n\n numberOfLines++; //Total number of tickets\n \n }\n \n // Since nothing works let's try the C way of finding the the biggest ticketCost\n float tmp = Float.valueOf(ticketsList.get(0).getTicketPrice());\n float max = Float.valueOf(ticketsList.get(0).getTicketPrice());\n \n for( int i = 0; i < ticketsList.size(); i++){\n \n tmp = Float.valueOf(ticketsList.get(i).getTicketPrice());\n \n if( max < tmp ){\n max = tmp;\n // currentBig = Float.valueOf(ticketsList.get(i+1).getTicketPrice());\n } \n System.out.println(tmp + "\\n");\n }\n \n } catch (Exception e) {\n }\n} \n
\n"},{"tags":["r","ggplot2"],"owner":{"reputation":393,"user_id":3337399,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2014e9655c30e9b504c841fdfb9fb8f5?s=128&d=identicon&r=PG&f=1","display_name":"moooh","link":"https://stackoverflow.com/users/3337399/moooh"},"is_answered":false,"view_count":39,"answer_count":2,"score":0,"last_activity_date":1623258180,"creation_date":1623232179,"last_edit_date":1623237422,"question_id":67901691,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67901691/ggplot-create-a-facet-grid-with-free-scales","title":"ggplot: create a facet grid with free scales","body":"In ggplot I want to create a facet grid where the y axes are free. This scales
option is available in facet_wrap()
but I want to keep the grid layout. I have attached a drawn example of what I want.
EDIT:\nI added some code for calrity
\n# Create data\nnX <- 3\nnY <- 3\nnVal <- 2\ndf <- data.frame(M = sort(rep(paste0("M",1:nX), nVal * nY)),\n n = rep(sort(paste0("n",rep((1:nY)-1, nVal))),nX),\n G = rep(1:2,nX * nY),\n val = c(100,300,20,10,1,2,10,25,NA,NA,0.1,0.2,25,27,2,5,0.5,0.6))\n\n# Delete observations to resemble my data\ndf <- subset(df, !is.na(val))\n\n# scales does not work in facet_grid(), thus obscuring trends for low values\nggplot(df, aes(x = G,\n y = val)) +\n geom_line()+\n ylim(0,NA)+\n facet_grid(n ~ M,scales = "free_y")\n
\n\nNote that no trends are visible for low values because in the grid they are obscured by the high values.
\n# the grid is lost in facet_wrap()\nggplot(df, aes(x = G,\n y = val)) +\n geom_line()+\n ylim(0,NA)+\n facet_wrap(n+M~.,scales = "free_y")\n
\n\nNote that the grid layout is lost.
\n"},{"tags":["dialogflow-es","actions-on-google"],"owner":{"reputation":1,"user_id":16172188,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1a81be67c92b879c514fca408a0855fe?s=128&d=identicon&r=PG","display_name":"Karan Sheth","link":"https://stackoverflow.com/users/16172188/karan-sheth"},"is_answered":false,"view_count":14,"answer_count":1,"score":0,"last_activity_date":1623258169,"creation_date":1623218212,"last_edit_date":1623221405,"question_id":67898367,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67898367/google-actions-re-certification-requirements","title":"Google Actions Re-certification requirements","body":"Do we need to re-certify a deployed skill if we edit Entities (eg: add synonyms) to Dialogflow or edit Types in case of using Actions Builder?
\nEssentially is there an "Update Live Skill" option similar to Alexa Skills Kit, where any published skill can be updated immediately when changes are limited to sample utterances within an intent or slot/entity values.
\n"},{"tags":["c++","debugging","gdb"],"owner":{"reputation":36,"user_id":5640590,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/938d2a44aaaeedfb07144ba3686acc9f?s=128&d=identicon&r=PG&f=1","display_name":"nkgt_","link":"https://stackoverflow.com/users/5640590/nkgt"},"is_answered":false,"view_count":26,"answer_count":1,"score":0,"last_activity_date":1623258168,"creation_date":1623228865,"question_id":67900767,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67900767/debugging-multiprocess-project-with-gdb","title":"Debugging multiprocess project with GDB","body":"I'd like to to debug a multiprocess C++ project with GDB, specifically I'd like to know if there is a way to achieve the following
\nThe ideal solution would be something similar to what is offered by the Visual Studio debugger as described here.\nAt the moment I'm able to attach multiple processes to a GDB instance but then only the current selected inferior is executed while the others are stopped and waiting for a continue command.
\n"},{"tags":["redis","lua","bloom-filter"],"owner":{"reputation":11,"user_id":16152972,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/3525f704f6188322de0eecb431056e79?s=128&d=identicon&r=PG&f=1","display_name":"tom","link":"https://stackoverflow.com/users/16152972/tom"},"is_answered":false,"view_count":42,"answer_count":1,"score":1,"last_activity_date":1623258165,"creation_date":1623063429,"last_edit_date":1623080618,"question_id":67870349,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67870349/springboot-use-lua-to-create-redis-bloom-filter-user-script1-err-bad-error","title":"springboot use lua to create redis bloom filter : @user_script:1: ERR bad error rate","body":"I use the SpringBoot provided redistemplate to execute the Lua script:
\nreturn redis.call('bf.reserve', KEYS[1],ARGV[1],ARGV[2])\n
\nbut it keeps getting wrong:
\n\n\nERR Error running script (call to f_264cca3824c7a277f5d3cf63f1b2642a0750e989): @user_script:1: ERR bad error rate.
\n
this is my docker image:\nredislabs/rebloom:2.2.5
\ni try to run this script in linux command,it works:
\n[root@daice ~]# redis-cli --eval a.lua city , 0.001 100000\nOK\n[root@daice ~]# redis-cli\n127.0.0.1:6379> keys *\n1) "city"\n
\n"},{"tags":["python","pandas"],"owner":{"reputation":21,"user_id":9091034,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/d986002a55ba762358207f7f60b05516?s=128&d=identicon&r=PG&f=1","display_name":"Stgauss","link":"https://stackoverflow.com/users/9091034/stgauss"},"is_answered":false,"view_count":23,"answer_count":1,"score":0,"last_activity_date":1623258161,"creation_date":1623257486,"question_id":67908527,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908527/pandas-get-column-based-on-another-column-which-contains-column-names","title":"Pandas: get column, based on another column which contains column names","body":"I'm working on a script to do some pricing. Have a dataframe which contains a quantity list:
\nName | \nVolume | \nArea | \n
---|---|---|
Wood | \n133 | \n256 | \n
Steel | \n55 | \n330 | \n
(and 1800 more lines like those)
\nWhat I need to do is create a third column in the df that contains the "true" quantity.\nPretty much, on some materials it's the volume, on others it's the area.
\nName | \nVolume | \nArea | \nQty | \n
---|---|---|---|
Wood | \n133 | \n256 | \n133 | \n
Steel | \n55 | \n330 | \n330 | \n
So far I've thought to create a dictionary:
\nmy_dict = {'Wood':'Volume', 'Steel':'Area'}
\nUsing map (or replace) I put that into a column in the df:
\nName | \nVolume | \nArea | \nDatafield | \n
---|---|---|---|
Wood | \n133 | \n256 | \nVolume | \n
Steel | \n55 | \n330 | \nArea | \n
Now, how would I go about putting the quantity into the Quantity column, based on what Datafield says?
\nI tried
\ndf['Quantity'] = df[df['Datafield']]
\nBut, it crashed and I'm stuck.
\n"},{"tags":["python-3.x","string","amazon-web-services","amazon-s3","boto3"],"owner":{"reputation":339,"user_id":8942319,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/b7aad150d47f39c523e91c65834b44bf?s=128&d=identicon&r=PG&f=1","display_name":"sam","link":"https://stackoverflow.com/users/8942319/sam"},"is_answered":false,"view_count":15,"answer_count":0,"score":0,"last_activity_date":1623258157,"creation_date":1623183261,"last_edit_date":1623258157,"question_id":67894019,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67894019/aws-boto3-s3-i-accidentally-renamed-a-set-of-files-as-empty-string-theyre-gon","title":"AWS Boto3 S3: I accidentally renamed a set of files as empty string. They're gone right?","body":"To "rename" some files I copied them with a new name and then deleted the originals. In creating the new name I meant to do this:
\nnew_key_path = '.'.join(key_path.split('.')[0:3])\n
\nBut I did this
\nnew_key_path = '.'.join(str.split('.')[0:3])\n
\nkey_path
vs str
. The former is a valid variable (path to file), the latter was apparently not None
, but an empty string. So it didn't error out. The result of this was that all iterations set new_key_path
to .
. The rest of the logic was such that I was essentially copying to the "root" of the s3 bucket...
Anyway, I can get the data back elsewhere but just want to validate that I indeed messed up in this specific way. I don't see it anywhere else in the bucket. Thanks
\nEDIT: adding the example renaming code. This is out of the box with Boto3.
\nself.s3_resource.Object(self._bucket_name, new_key_path).copy_from(CopySource=copy_src)\nself.s3_resource.Object(self._bucket_name, key_path).delete()\n
\n"},{"tags":["r","auc"],"owner":{"reputation":1,"user_id":16176963,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgGy4Hd4T8V96BsIBYyYlU3dw2jshxzwaQeLTpOBSA=k-s128","display_name":"shinyhill","link":"https://stackoverflow.com/users/16176963/shinyhill"},"is_answered":false,"view_count":13,"answer_count":0,"score":-2,"last_activity_date":1623258153,"creation_date":1623257430,"last_edit_date":1623258153,"question_id":67908515,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908515/auc-by-trapezoid-method-in-r","title":"AUC by trapezoid method in R","body":"I'm a beginner who just started using R.
\nI am trying to obtain the AUC for each time section using the trapezoid method with the results measured at 0,10,20,30,40, 50, 60 minutes for each ID.\nWhat should I do?
\n CASET0 T10 T20 T30 T40 T50 T60\n1 88 89 91 105 107 139 159\n2 92 NA 102 NA NA 189 144\n3 79 NA 82 98 106 140 118\n5 81 81 82 92 86 101 124\n8 90 89 89 106 115 134 101\n9 91 77 87 82 95 133 156\n
\n"},{"tags":["javascript","regex","string"],"owner":{"reputation":3,"user_id":13567734,"user_type":"registered","profile_image":"https://lh5.googleusercontent.com/-MuWuOfcASF0/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rf82T7_IDLxKMcN1ay9h41RNF25DA/mo/photo.jpg?sz=128","display_name":"Vlad","link":"https://stackoverflow.com/users/13567734/vlad"},"is_answered":true,"view_count":15,"accepted_answer_id":67908679,"answer_count":1,"score":0,"last_activity_date":1623258153,"creation_date":1623257029,"last_edit_date":1623257653,"question_id":67908425,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908425/regex-do-not-capture-group-in-javascript","title":"Regex do not capture group in JavaScript","body":"I wrote regular expression
\n/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g\n
\nFor given string
\ntranslateX(381px) translateY(-94px)\n
\nTo capture translateX
and translateY
values. Tested it by regex101.com service, it works well there. But, when I try it in JavaScript it capture translateX
value which is 381
but not capture translateY
which is -94
. Do you have any ideas why is this happening?
regex101
https://i.stack.imgur.com/Nuj5X.png
\nJavaScript exec
console.log(/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g.exec(\"translateX(381px) translateY(-94px)\"));
\r\nUsing matchAll
gives the same result.
JavaScript matchAll
console.log(\"translateX(381px) translateY(-94px)\".matchAll(/translateX\\((?<X>-{0,1}\\d+)px\\)|translateY\\((?<Y>-{0,1}\\d+)px\\)/g).next().value.groups);
\r\nI'm attempting to use Entity Framework Core with Npgsql to perform a raw SQL query where the WHERE clause part is pulled in from the database, with the actual 'value' supplied by a user. As a concrete example:
\nThis part of the SQL is static
\nSELECT TITLE as TitleField,\n GEOM as GeomField,\n GEOM_X as XField,\n GEOM_Y as YField\nFROM fdw_public."MY_TABLE"\n
\nThen an administrator can set a WHERE clause up in the database, for example:
\nCOLUMNNAME LIKE '%{search}%'\n
\nor
\nOTHER_COLUMNNAME = '{search}' AND COLUMNNAME = 'Something Static';\n
\nThis isn't known at compile time and could be any valid WHERE clause.
\nThe {search} part is a placeholder. I trust the clause coming from the database, this is only controlled by the application owner and if they want to break their own table, that's fine.
\nThe end result is this SQL
\nSELECT TITLE as TitleField,\n GEOM as GeomField,\n GEOM_X as XField,\n GEOM_Y as YField\nFROM fdw_public."MY_TABLE"\nWHERE COLUMNNAME LIKE '%{search}%'\n
\nThe {search} part however is the user input (from a web application), so this needs parameterizing.
\nThe following works, but is obviously very open to SQL Injection
\nvar sql = $@"SELECT TITLE as TitleField,\n GEOM as GeomField,\n XFIELD as XField,\n YFIELD as YField\n FROM fdw_public."MY_TABLE"\n WHERE {searchDefinition.WhereClause.Replace("{search}", searchTerm)}";\n \nvar dbResults = _context.DatabaseSearchResults.FromSqlRaw(sql).ToList();\n
\nSo I attempted to use a parameter for the whole where clause
\nvar sql = $@"SELECT TITLE as TitleField,\n GEOM as GeomField,\n XFIELD as XField,\n YFIELD as YField\n FROM fdw_public."MY_TABLE"\n WHERE @whereClause";\n\n var whereClauseParam = new Npgsql.NpgsqlParameter("@whereClause", searchDefinition.WhereClause.Replace("{search}", searchTerm));\n var dbResults = _context.DatabaseSearchResults.FromSqlRaw(sql,whereClauseParam).ToList();\n
\nBut this throws the following exception from Npgsql
\n\n\n42804: argument of WHERE must be type boolean, not type text
\n
This does makes sense to me, as it feels wrong paramterizing ann entire clause, but I can't figure out a better way round it.
\nIdeally I need to parametrize just the search term, like this
\nvar sql = $@"SELECT TITLE as TitleField,\n GEOM as GeomField,\n XFIELD as XField,\n YFIELD as YField\n FROM fdw_public."MY_TABLE"\n WHERE {searchDefinition.WhereClause.Replace("{search}","@p0")}";\n\n var searchTermParam = new Npgsql.NpgsqlParameter("p0", searchTerm);\n var dbResults = _context.DatabaseSearchResults.FromSqlRaw(sql, searchTermParam).ToList();\n
\nBut again, this doesn't work, understandably, as it is being interpreted literally.
\nI feel this may involve a change in how I'm doing this completely, or at worse, falling back to sanitizing the search string using some well known sanitization, but I don't want to do this, I want to use parameters.
\nEither way, to sum up, the requirement is this
\nI just started a intro college C programming class and have the following assignment:
\nUse a loop to load random integer values into a 1 dimensional array.
\nUse a loop to load random integer values into a multidimensional array.
\nCreate a function to search (Linear) for numbers in both.
\na. The search should find all numbers divisible by 3 and return the number back to the user , as well as print the number to the screen.
\nWrite functions to print the contents of each array.
\nYour function should accept an array as the parameter.
\nWrite a function that increments all the values by an integer that is passed as a parameter. This parameter should be passed by reference.
\nPrint the byte sizes of each array to the screen
\nOur professor has yet to teach anything. She just kind of handed us a textbook and said get to it. after watching a couple of youtube videos and reading other threads, I've been able to do #1 successfully but am just lost when it comes to the rest. Any help would be greatly appreciated.
\nHere's what I have so far.
\n#include <stdlib.h>\n#include <time.h>\n\nconst int r = 5;\nconst int c = 5;\n\nint main(void)\n{\n srand(time(NULL)); //generator for random numbers\n int rndmNum[25]; //random number array for 25 ints\n int i;\n\nprintf("One-Dimensional Array\\n"); //objective 1\n for (i = 0; i < 25; i++) //loop 25 times\n {\n rndmNum[i] = i + 1;\n printf("%d\\n", (rand() % 50) + 1);} //print random ints from 1-100 objective 4\n\nprintf("\\nMulti-Dimensional Array\\n"); //objective 2\n int mltdim[r][c]; //multidim array for 25 nuumbers\n \n\n\n\n return 0;\n\n\n}\n
\n"},{"tags":["amazon-web-services","amazon-cloudfront"],"owner":{"reputation":14078,"user_id":160245,"user_type":"registered","accept_rate":80,"profile_image":"https://www.gravatar.com/avatar/ad3772721158c9ed78c4fccbc1d1b9f9?s=128&d=identicon&r=PG","display_name":"NealWalters","link":"https://stackoverflow.com/users/160245/nealwalters"},"is_answered":false,"view_count":6,"answer_count":1,"score":0,"last_activity_date":1623258148,"creation_date":1623256932,"question_id":67908392,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908392/does-cloudfront-disable-enable-effectively-invalidate-all-files","title":"Does Cloudfront Disable/Enable effectively "invalidate" all files?","body":"I know it takes longer and more resources, but does doing a full disable/enable in Cloudfront invalidate all the files? Sometimes it seems safer to just do everything than rely on the developers sending us an exactly list of files. (We have a static HTML site with javascript code hosted in S3 and exposed via Cloudfront.)
\nI tried the disable/enable yesterday, but today, people were saying it looks their code changes were not being used on the website.
\nGreat feature in the future would be to invalidate all files changed since the last validation. That should be easy for them to do.
\n"},{"tags":[".net","asp.net-core"],"owner":{"reputation":3,"user_id":9551458,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/ff0ad13b2d83752d5b3532c760aebd58?s=128&d=identicon&r=PG&f=1","display_name":"beiduoan","link":"https://stackoverflow.com/users/9551458/beiduoan"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258145,"creation_date":1623258145,"question_id":67908676,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908676/net-core-how-to-get-week-datetime-list-by-datetime-range","title":".net core how to get week datetime list by datetime range","body":"I hope get week datetime list by datetime range,I tried the following code get number of weeks per month.
\nvar start = new DateTime(2021, 6, 09);\n var end = new DateTime(2021, 7, 01);\n\n end = new DateTime(end.Year, end.Month, DateTime.DaysInMonth(end.Year, end.Month));\n\n var diff = Enumerable.Range(0, Int32.MaxValue)\n .Select(e => start.AddMonths(e))\n .TakeWhile(e => e <= end)\n .Select(e => Convert.ToDateTime(e.ToString("yyyy-MM")));\n\n foreach (var item in diff)\n {\n\n DateTime dateTime = item;\n Calendar calendar = CultureInfo.CurrentCulture.Calendar;\n IEnumerable<int> daysInMonth = Enumerable.Range(1, calendar.GetDaysInMonth(dateTime.Year, dateTime.Month));\n List<Tuple<DateTime, DateTime>> weeks = daysInMonth.Select(day => new DateTime(dateTime.Year, dateTime.Month, day))\n .GroupBy(d => calendar.GetWeekOfYear(d, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday))\n .Select(g => new Tuple<DateTime, DateTime>(g.First(), g.Last()))\n .ToList();\n }\n
\nBut,I hope get DateTime(2021, 6, 09) between Week starting on the 9th and DateTime(2021, 7, 01) Week ending on the 1th of weeks time, like this.
\n2021-06-09 2021-06-13\n.....\n2021-06-28 2021-07-01\n
\nhow to changed my code
\n"},{"tags":["r","ggplot2","legend","sf"],"owner":{"reputation":2193,"user_id":4224718,"user_type":"registered","accept_rate":91,"profile_image":"https://i.stack.imgur.com/0zvNV.jpg?s=128&g=1","display_name":"M. Beausoleil","link":"https://stackoverflow.com/users/4224718/m-beausoleil"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258141,"creation_date":1623258141,"question_id":67908675,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908675/mix-colour-fill-and-linetype-in-r-ggplot-legend","title":"Mix colour, fill and linetype in R ggplot legend","body":"I have a map where I'm trying to add to a legend with 2 filled polygons and 1 polygon but with only the contour that is outlined (which would be represented only by a dotted line).
\nlibrary(sf);library(ggplot)\n# point\np <- rbind(c(1,2), c(2,1), c(3,2), c(3.5,3.5), c(3.4,3.6), c(3.9,1.4))\n(mp <- st_multipoint(p))\n\np1 <- rbind(c(0,0), c(1,0), c(3,2), c(2,4), c(1,4), c(0,0))\np2 <- rbind(c(1,1), c(1,2), c(2,2), c(1,1))\npol <-st_polygon(list(p1,p2))\n\np3 <- rbind(c(3,0), c(4,0), c(4,1), c(3,1), c(3,0))\np4 <- rbind(c(3.3,0.3), c(3.8,0.3), c(3.8,0.8), c(3.3,0.8), c(3.3,0.3))[5:1,]\np5 <- rbind(c(3,3), c(4,2), c(4,3), c(3,3))\n(mpol1 <- st_multipolygon(list(list(p3))))\n(mpol2 <- st_multipolygon(list(list(p4))))\n(mpol3 <- st_multipolygon(list(list(p5))))\n\nggplot(mp, aes(geometry = geometry)) + \n geom_sf(data = pol, aes(geometry = geometry), inherit.aes = FALSE) +\n # Add the points \n geom_sf(data = mpol1, alpha = 0.5, aes(geometry = geometry, colour = "grey90", fill = "grey90"), size = 0.05) + \n geom_sf(data = mpol2, alpha = 0.5, aes(geometry = geometry, colour = "grey20", fill = "grey20"), size = 0.05) +\n geom_sf(data = mpol3, alpha = 0.5, aes(geometry = geometry,colour = "grey30", fill=NA), size = 0.8, linetype = "dotted") +\n scale_color_manual(values = c(alpha("grey90",.5),alpha("grey20",.5),alpha("grey30",.5)), labels = c("item1", "item2","item3"), name="My Leg. hurts") +\n scale_fill_manual( values = c(alpha("grey90",.5),alpha("grey20",.5),NA), labels = c("item1", "item2","item3"), name="My Leg. hurts") + \n theme_bw()+\n theme(legend.key = element_rect(fill = NA), \n legend.background = element_rect(fill = NA),\n legend.text = element_text(size = 12), \n legend.title = element_text(size = 12,face='bold'))\n
\nGives
\n\nBut I want this:
\n\nHow can this be achieved?
\n"},{"tags":["sql","plsql","oracle11g","rdbms"],"owner":{"reputation":11,"user_id":15908800,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/863c6dd0e26ce7cb2f06c2660d45f37d?s=128&d=identicon&r=PG&f=1","display_name":"water_drinker","link":"https://stackoverflow.com/users/15908800/water-drinker"},"is_answered":false,"view_count":8,"answer_count":1,"score":0,"last_activity_date":1623258137,"creation_date":1623257837,"question_id":67908600,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908600/how-to-stop-a-running-command-in-oracle-11g-dbms","title":"How to stop a running command in oracle 11g DBMS","body":"I used to write PL/SQL procedures in oracle dbms. Few times I would end up in situations like Infinite loop and the query continuously running I want to stop it. If I press ctrl + C whole command line gets closed.
\n"},{"tags":["javascript","regex"],"owner":{"reputation":55,"user_id":11361543,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-aAWlAXnzPyw/AAAAAAAAAAI/AAAAAAAAAwY/o-PtlTaNlwE/photo.jpg?sz=128","display_name":"Shantanu Kaushik","link":"https://stackoverflow.com/users/11361543/shantanu-kaushik"},"is_answered":true,"view_count":24,"answer_count":1,"score":0,"last_activity_date":1623258136,"creation_date":1623239917,"question_id":67903700,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67903700/capturing-variable-names-using-regex-javascript","title":"Capturing variable names using RegEX JavaScript?","body":"I am trying to capture variable names from the variable declaration. The variables are declared and initialized in the following manner:
\nlet URL="https://www.lipsum.com/", error, pass=true;\n
\nI have this above code in the form of a string and I want to obtain the name of the variables using RegEX.
\nI am using this regex expression: /let\\s+([\\w_$]+)(?:=.*),?/;
However, I am only getting URL
in the output
const str = `let URL=\"https://www.lipsum.com/\", error, pass=true;`;\nconst regex = /let\\s+([\\w_$]+)(?:=.*),?/;\n\nconsole.log(str.match(regex));
\r\nHow do I obtain the variable names URL
, error
, and pass
from the given string?
I have a pandas dataframe with around 20-30 columns. I would like to obtain the column names in a list when one cell value equals to the string "Fail".
\nThe dataframe would look like this:
\n Column_1 Column_2 ... Column_30\n0 Pass Pass Fail\n1 Pass Pass Pass\n2 Fail Pass Pass\n3 Pass Pass Pass\n4 Pass Pass Pass\n..\n
\nThe expected result looks like such [Column_1, Column 30]
we have two GitHub Enterprise Appliance we installed as "New Install" however; we would want to configure the second GitHub Enterprise Appliance as a "Configure as Replica" although it is currently installed as a "New Install". How do we go about this?
\n"},{"tags":["reactjs"],"owner":{"reputation":41,"user_id":12378060,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/7b5af6dbec6c53af1f1def286bbf7c5f?s=128&d=identicon&r=PG&f=1","display_name":"LosProgramer","link":"https://stackoverflow.com/users/12378060/losprogramer"},"is_answered":false,"view_count":21,"answer_count":1,"score":0,"last_activity_date":1623258130,"creation_date":1623257343,"question_id":67908492,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908492/componentdidupdate-infinite-loop","title":"componentDidUpdate() infinite loop","body":"I get an error message for componentDidUpdate when I try to set state and I'm not sure why.
\ncomponentDidUpdate() {\n if(this.props.isLoadingDept===false && this.props.isLoadingEmpStatus===false\n && this.props.isLoadingGroup===false && this.props.isLoadingEmpDesig===false){\n this.setState({\n button:false\n })\n console.log('UPDATE')\n}\n}\n
\nconsole log value gets logged only once, when the statement is true, so I'm not sure how and why is it looping..
\n"},{"tags":["javascript"],"owner":{"reputation":1133,"user_id":10796680,"user_type":"registered","profile_image":"https://i.stack.imgur.com/rgfvm.jpg?s=128&g=1","display_name":"David Alford","link":"https://stackoverflow.com/users/10796680/david-alford"},"is_answered":false,"view_count":18,"answer_count":0,"score":0,"last_activity_date":1623258127,"creation_date":1623257818,"last_edit_date":1623258127,"question_id":67908597,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908597/how-to-add-event-listener-for-file-upload","title":"How to add event listener for file upload","body":"I have a video upload form which needs a progress bar. I am using an xhr.upload.addEventListener
function to monitor the progress of the upload. Problem is that the only way I can get the progress bar to display the upload progress is by only uploading the video field as such:
let formData = new FormData(e.target[4]); // 4th element in the form is the video\n
\nBut the only way I can get it to send the whole form (but it will not update the progress bar) is as such:
\nlet formData = new FormData(e.target.form);\n
\nThe whole AJAX function is here:
\n<script>\n function saveVideo(e) {\n e.preventDefault();\n let formData = new FormData(e.target[4]);\n\n $.ajax({\n async : true,\n type : 'POST',\n url : videoFormURL,\n headers : {"X-CSRFToken": token},\n enctype : 'multipart/form-data',\n processData : false,\n contentType : false,\n data : formData,\n xhr : function () {\n let xhr = new XMLHttpRequest();\n xhr.upload.addEventListener('progress', function (e) {\n if (e.lengthComputable) {\n let percent = Math.round(e.loaded / e.total * 100);\n $('#progress-bar').attr('aria-valuenow', percent).css('width', percent + '%');\n }\n });\n return xhr;\n },\n });\n }\n</script>\n
\nHow can I monitor the progress but also upload the whole form?
\nAll help is very much appreciated.
\n"},{"tags":["parallel-processing","hardware","cpu-architecture","sse"],"owner":{"reputation":1,"user_id":16177793,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/8ca0f4c5c752b4a7433447f7780d3dc2?s=128&d=identicon&r=PG&f=1","display_name":"akmopp","link":"https://stackoverflow.com/users/16177793/akmopp"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623258125,"creation_date":1623258125,"question_id":67908669,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908669/why-isnt-everything-sse-or-simd-by-default","title":"Why isn't everything SSE (or "SIMD") by default?","body":"I don't know much about the internal working of the CPU, and my understanding of SSE is equally basic; it works in the form of additional long registers that pack some number of data types you want a perform a single operation on (in parallel) using a single instruction.
\nGreat, but why isn't every register and every operation like that by default? If I want to add two integers, why would I need to place each in two separate registers and do the operation through multiple instructions when I could just do it through SSE? does it interfere with concurrency somehow? is it a hardware limitation?
\nThanks! If there are somewhat easy to follow sources as well, I would gladly appreciate it
\n"},{"tags":["python","keras","tensorflow2.0","reinforcement-learning","keras-rl"],"owner":{"reputation":33,"user_id":15915226,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/5b0af37108f3b739f3f5f52bf96a758c?s=128&d=identicon&r=PG&f=1","display_name":"KnownUnknown","link":"https://stackoverflow.com/users/15915226/knownunknown"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258120,"creation_date":1623258120,"question_id":67908668,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908668/failedpreconditionerror-while-using-ddpg-rl-algorithm-in-python-with-keras-ke","title":"FailedPreconditionError while using DDPG RL algorithm, in python, with keras, keras-rl2","body":"I am training a DDPG agent on my custom environment that I wrote using openai gym. I am getting error during training the model.
\nWhen I search for a solution on web, I found that some people who faced similar issue were able to resolve it by initializing the variable.
\nFor example by using:\ntf.global_variable_initialzer()\n
\nBut I am using tensorflow version 2.5.0 which does not have this method. Which means there should be some other way to solve this error. But I am unable to find the solution.
\nHere are the libraries that I used with there versions
\ntensorflow: 2.5.0\ngym: 0.18.3\nnumpy: 1.19.5\nkeras: 2.4.3\nkeras-rl2: 1.0.5 DDPG agent comes from this library\n
\nError/Stacktrace:
\nTraining for 1000 steps ...\nInterval 1 (0 steps performed)\n 17/10000 [..............................] - ETA: 1:04 - reward: 256251545.0121\nC:\\Users\\vchou\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\keras\\engine\\training.py:2401: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically.\n warnings.warn('`Model.state_updates` will be removed in a future version. '\n 100/10000 [..............................] - ETA: 1:03 - reward: 272267266.5754\nC:\\Users\\vchou\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:2426: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically.\n warnings.warn('`Model.state_updates` will be removed in a future version. '\n---------------------------------------------------------------------------\nFailedPreconditionError Traceback (most recent call last)\n<ipython-input-17-0938aa6056e8> in <module>\n 1 # Training\n----> 2 ddpgAgent.fit(env, 1000, verbose=1, nb_max_episode_steps = 100)\n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\rl\\core.py in fit(self, env, nb_steps, action_repetition, callbacks, verbose, visualize, nb_max_start_steps, start_step_policy, log_interval, nb_max_episode_steps)\n 191 # Force a terminal state.\n 192 done = True\n--> 193 metrics = self.backward(reward, terminal=done)\n 194 episode_reward += reward\n 195 \n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\rl\\agents\\ddpg.py in backward(self, reward, terminal)\n 279 state0_batch_with_action = [state0_batch]\n 280 state0_batch_with_action.insert(self.critic_action_input_idx, action_batch)\n--> 281 metrics = self.critic.train_on_batch(state0_batch_with_action, targets)\n 282 if self.processor is not None:\n 283 metrics += self.processor.metrics\n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\keras\\engine\\training_v1.py in train_on_batch(self, x, y, sample_weight, class_weight, reset_metrics)\n 1075 self._update_sample_weight_modes(sample_weights=sample_weights)\n 1076 self._make_train_function()\n-> 1077 outputs = self.train_function(ins) # pylint: disable=not-callable\n 1078 \n 1079 if reset_metrics:\n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\keras\\backend.py in __call__(self, inputs)\n 4017 self._make_callable(feed_arrays, feed_symbols, symbol_vals, session)\n 4018 \n-> 4019 fetched = self._callable_fn(*array_vals,\n 4020 run_metadata=self.run_metadata)\n 4021 self._call_fetch_callbacks(fetched[-len(self._fetches):])\n\n~\\anaconda3\\envs\\AdSpendProblem\\lib\\site-packages\\tensorflow\\python\\client\\session.py in __call__(self, *args, **kwargs)\n 1478 try:\n 1479 run_metadata_ptr = tf_session.TF_NewBuffer() if run_metadata else None\n-> 1480 ret = tf_session.TF_SessionRunCallable(self._session._session,\n 1481 self._handle, args,\n 1482 run_metadata_ptr)\n\nFailedPreconditionError: Could not find variable dense_5_1/kernel. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status=Not found: Resource localhost/dense_5_1/kernel/class tensorflow::Var does not exist.\n [[{{node ReadVariableOp_21}}]]\n
\nThe actor and critic networks are as follows:
\nACTOR NETWORK\nModel: "sequential"\n_________________________________________________________________\nLayer (type) Output Shape Param # \n=================================================================\nflatten (Flatten) (None, 10) 0 \n_________________________________________________________________\ndense (Dense) (None, 32) 352 \n_________________________________________________________________\nactivation (Activation) (None, 32) 0 \n_________________________________________________________________\ndense_1 (Dense) (None, 32) 1056 \n_________________________________________________________________\nactivation_1 (Activation) (None, 32) 0 \n_________________________________________________________________\ndense_2 (Dense) (None, 32) 1056 \n_________________________________________________________________\nactivation_2 (Activation) (None, 32) 0 \n_________________________________________________________________\ndense_3 (Dense) (None, 10) 330 \n_________________________________________________________________\nactivation_3 (Activation) (None, 10) 0 \n=================================================================\nTotal params: 2,794\nTrainable params: 2,794\nNon-trainable params: 0\n_________________________________________________________________\nNone\n
\nCRITIC NETWORK\nModel: "model"\n__________________________________________________________________________________________________\nLayer (type) Output Shape Param # Connected to \n==================================================================================================\nobservation_input (InputLayer) [(None, 1, 10)] 0 \n__________________________________________________________________________________________________\naction_input (InputLayer) [(None, 10)] 0 \n__________________________________________________________________________________________________\nflatten_1 (Flatten) (None, 10) 0 observation_input[0][0] \n__________________________________________________________________________________________________\nconcatenate (Concatenate) (None, 20) 0 action_input[0][0] \n flatten_1[0][0] \n__________________________________________________________________________________________________\ndense_4 (Dense) (None, 32) 672 concatenate[0][0] \n__________________________________________________________________________________________________\nactivation_4 (Activation) (None, 32) 0 dense_4[0][0] \n__________________________________________________________________________________________________\ndense_5 (Dense) (None, 32) 1056 activation_4[0][0] \n__________________________________________________________________________________________________\nactivation_5 (Activation) (None, 32) 0 dense_5[0][0] \n__________________________________________________________________________________________________\ndense_6 (Dense) (None, 32) 1056 activation_5[0][0] \n__________________________________________________________________________________________________\nactivation_6 (Activation) (None, 32) 0 dense_6[0][0] \n__________________________________________________________________________________________________\ndense_7 (Dense) (None, 1) 33 activation_6[0][0] \n__________________________________________________________________________________________________\nactivation_7 (Activation) (None, 1) 0 dense_7[0][0] \n==================================================================================================\nTotal params: 2,817\nTrainable params: 2,817\nNon-trainable params: 0\n__________________________________________________________________________________________________\nNone\n
\nHere is the code for DDPG agent
\n# Create DDPG agent\nddpgAgent = DDPGAgent(\n nb_actions = nb_actions,\n actor = actor,\n critic = critic,\n critic_action_input = action_input,\n memory = memory,\n nb_steps_warmup_critic = 100,\n nb_steps_warmup_actor = 100,\n random_process = random_process,\n gamma = 0.99,\n target_model_update = 1e-3\n)\n\nddpgAgent.compile(Adam(learning_rate=0.001, clipnorm=1.0), metrics=['mae'])\n
\n"},{"tags":["angular","typescript","stripe-payments"],"owner":{"reputation":13,"user_id":14744187,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/bf5bb3bc0c3d87c7b17b5f02f1d5f8c5?s=128&d=identicon&r=PG&f=1","display_name":"wildpopones","link":"https://stackoverflow.com/users/14744187/wildpopones"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623258118,"creation_date":1623258118,"question_id":67908667,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908667/integration-stripe-angular-cannot-find-name-stripe-did-you-mean-stripe","title":"Integration Stripe Angular, Cannot find name 'Stripe'. Did you mean 'stripe'?","body":"I am trying to integrate Stripe with redirection to my app, I am using Angular-typescript.
\nHere is the code I have so far in my component:
\nvar head = document.getElementsByTagName('head')[0];\nvar script = document.createElement('script');\nscript.onload = function() {\n console.log('Script loaded');\n var stripe = Stripe(MY_PUBLICK_KEY);\n return stripe.redirectToCheckout({ sessionId: SESSION_I_RETURNED_FROM_MY_BACKEND});\n}\nscript.src = 'https://js.stripe.com/v3/';\nhead.appendChild(script);\n
\nBut I have the following error running the above code:
\nCannot find name 'Stripe'. Did you mean 'stripe'?
I have installed package with the command npm install --save stripe
following the next guide https://stripe.com/docs/checkout/integration-builder
Is there anyone that faced the same problem when integrating Stripe?
\nThanks!
\n"},{"tags":["reactjs"],"owner":{"reputation":49,"user_id":13398497,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GguMV_amD6S8ZcMIa9irT7jG05Z7RK6qwXUTROJ2A=k-s128","display_name":"Enyak Stew","link":"https://stackoverflow.com/users/13398497/enyak-stew"},"is_answered":false,"view_count":19,"answer_count":2,"score":0,"last_activity_date":1623258117,"creation_date":1623254918,"question_id":67907872,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907872/set-image-source-dinamically-in-react-js","title":"set image source dinamically in React.js","body":"I am importing these images :
\nimport Image1 from './assets/image1.png';\nimport Image2 from './assets/image2.png';\n
\nI am then using them in JSX :
\n<img src={Image1} alt="image1"/>\n<img src={Image2} alt="image2"/>\n
\nThe problem is that I would like to be able to set the source dinamically, like this, for example :
\n<img src={`Image${1}`} alt="image1"/>\n
\nbut of course a string won't work.
\nIs there any way to do this ?
\nThanks
\n"},{"tags":["python","amazon-s3","pyspark","apache-spark-sql","awswrangler"],"owner":{"reputation":377,"user_id":13254554,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GhUqdXhtIy0MJhnwup3cuy2MU-vxp7Mm0MQ8oT78zQ=k-s128","display_name":"brenda","link":"https://stackoverflow.com/users/13254554/brenda"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258114,"creation_date":1623258114,"question_id":67908664,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908664/store-parquet-files-in-aws-s3-into-a-spark-dataframe-using-pyspark","title":"store parquet files (in aws s3) into a spark dataframe using pyspark","body":"I'm trying to read data from a specific folder in my s3 bucket. This data is in parquet format. To do that I'm using awswrangler:
\nimport awswrangler as wr\n\n# read data\ndata = wr.s3.read_parquet("s3://bucket-name/folder/with/parquet/files/", dataset = True)\n
\nThis returns a pandas dataframe:
\nclient_id center client_lat client_lng inserted_at matrix_updated\n0700292081 BFDR -23.6077 -46.6617 2021-04-19 2021-04-19 \n7100067781 BFDR -23.6077 -46.6617 2021-04-19 2021-04-19 \n7100067787 BFDR -23.6077 -46.6617 2021-04-19 2021-04-19 \n
\nHowever, instead of a pandas dataframe I would like to store this data retrieved from my s3 bucket in a spark dataframe. I've tried doing this(which is my own question), but seems not to be working correctly.
\nI was wondering if there is any way I could store this data into a spark dataframe using awswrangler. Or if you have an alternative I would like to read about it.
\n"},{"tags":["javascript","api","vue.js","axios","web-frontend"],"owner":{"reputation":13,"user_id":8278279,"user_type":"registered","profile_image":"https://i.stack.imgur.com/Xddr2.png?s=128&g=1","display_name":"Kamal Kunwar","link":"https://stackoverflow.com/users/8278279/kamal-kunwar"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258114,"creation_date":1623258114,"question_id":67908663,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908663/fetch-the-data-from-multiple-api-axios-and-get-it-in-the-page-on-load-vue-js-3","title":"fetch the data from multiple api - axios and get it in the page on load vue.js 3","body":"I want to fetch the data from multiple API
with axios
in Vue.js 3. The backend is Laravel API.
I am able to get data on response1.data and response2.data on console but how can I assign this data to the object defined on data() function of Vue.js.
\nI need this data to load on page on loaded. The Vue.js code is -
\n<script>\nexport default {\n name:'Followup',\n data() {\n return {\n patient:{},\n labGroup:{},\n }\n },\n created() { \n this.$axios.get('/sanctum/csrf-cookie').then(response => {\n this.$axios.all([\n this.$axios.get(`/api/patients/showSomeDetails/${this.$route.params.id}`),\n this.$axios.get('/api/labitems/getGroup')\n ])\n .then(this.$axios.spread(function (response1, response2) {\n console.log(response1.data) // this has given result on console. \n this.patient = response1.data // It is giving error on console. => TypeError: Cannot set property 'patient' of null\n this.labGroup = response2.data // same\n console.log(response2.data)\n\n }))\n .catch(function (error) {\n console.error(error);\n });\n\n })\n },\ncomputed() {\n},\nmethods: {\n}\n} \n</script>\n
\nI got error on console - this- app.js:20666 TypeError: Cannot set property 'patient' of null
How can I assign data to the patient and labGroup, so it will applied to my webpage via v-model
\nThis is my patient followup up form, where I need to get the patient details from patient table, and labitems to fill lab reports from labitems table.
\nI hope, someone will give me a solution for this.
\n"},{"tags":["java","hibernate","jpa","join","fetch"],"owner":{"reputation":1,"user_id":16178077,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GhgLLCnlqcqr4yeIX9EtDXJLeLYZIS30nlEX_dNRg=k-s128","display_name":"Bruno Trindade","link":"https://stackoverflow.com/users/16178077/bruno-trindade"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623258111,"creation_date":1623258111,"question_id":67908661,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908661/solution-to-n1-issue-in-jpa-and-hibernate-with-multiples-many-to-one","title":"Solution to N+1 issue in JPA and Hibernate with multiples Many-To-One","body":"I found some solutions to avoid N+1 problem but this solutions works only for single Many-To-One relationship.
\nFor example, the following question: What is the solution for the N+1 issue in JPA and Hibernate?
\nThe problem that I'm trying to solve is this:
\n@Entity \npublic class Book implements Serializable { \n \n @Id \n private Long id; \n\n private String title; \n \n @ManyToOne(fetch = FetchType.LAZY) \n private Author author; \n\n @ManyToOne(fetch = FetchType.LAZY) \n private Brand brand;\n}\n
\nSolutions like try to fetch through JPQL doesn't work and fetch just one relationship, for example:
\nSELECT b FROM Book b \nINNER JOIN FETCH b.author \nINNER JOIN FETCH b.brand\n
\nIn this case, only 'author' relationship would be fetched and N+1 problem will happen with 'brand' relationship.
\nDo you know any solution to solve this specific problem?
\nThank you!
\n"},{"tags":["sql","if-statement","group-by","count","case"],"owner":{"reputation":1,"user_id":11429634,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/1011ee3ccdb18fe311626b06ec50ab81?s=128&d=identicon&r=PG&f=1","display_name":"user11429634","link":"https://stackoverflow.com/users/11429634/user11429634"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623258111,"creation_date":1623258111,"question_id":67908660,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908660/use-a-count-function-in-a-case-statment","title":"Use a count function in a case statment","body":"I have the below code for which I need to enter a count function in one condition of the case statement and then group by the case statement like below. But it is not letting me group the case statement. I essentially want to create a third bucket called "Both" with the condition below
\nselect \nCASE\n WHEN i.CLASSIFICATION in ('CUSTOMER','PARTNER') THEN 'API'\n WHEN i.CLASSIFICATION in ('MOBILE','NDSE') THEN 'APP' \n WHEN (i.CLASSIFICATION in ('MOBILE','NDSE','CUSTOMER','PARTNER') OR count(distinct UPPER(p.ACCOUNTID)) >=2) THEN 'BOTH' \n ELSE 'Other' END AS "Bucket", \ncount(distinct ACCOUNTID) as No_Accounts,count(distinct envelopeid_hash) as numenvelopes\nfrom ENVELOPE_TABLE e \nJOIN DIMDATE_TABLE b on to_date(e.sentinitial)=b.standarddate\njoin PAYING_TABLE p\non UPPER(e.ACCOUNTID)=UPPER(p.ACCOUNTID) \nLEFT JOIN IK_TABLE i ON i.IntegratorKeyId = e.InitiatingIntegratorKeyId AND i.SourceKey = e.SourceKey\ngroup by 1\n
\n"},{"tags":["spring-webflux","project-reactor","webflux","spring-data-mongodb-reactive","reactive-mongo-java"],"owner":{"reputation":317,"user_id":7681696,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/0c2d9b34b00d577f21472cdca00de3c0?s=128&d=identicon&r=PG&f=1","display_name":"PaulDev","link":"https://stackoverflow.com/users/7681696/pauldev"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623258107,"creation_date":1623254858,"last_edit_date":1623258107,"question_id":67907864,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907864/in-spring-webflux-how-to-chaining-methods-from-multiple-services-repo-in-order","title":"In Spring WebFlux, How to chaining methods from multiple services/repo, in order to 'delete' elements in multiples DB-Collections'?","body":"I am trying 'delete' items in 03 different DB-Collections(Reactive MongoDB), using 03 different services/repo (userService + postService + userRepo);
\nMy Goal is DELETE an object (in each collection) simultaneously, using the same chaining-code;
\nBelow is the code for the above situation:
\nCurrent working status: not working;
\nCurrent behaviour: not executes any delete, weither delete-userService, delete-postService, or delete-userRepo.
\n@Slf4j\n@Service\n@AllArgsConstructor\npublic class UserService implements UserServiceInt {\n\n private final UserRepo userRepo;\n\n private final PostServiceInt postServ;\n\n private final CommentServiceInt comServ;\n\n private final CustomExceptions customExceptions;\n\n @Override\n public Mono<Void> deleteInTwoCollections(String id) {\n return userRepo\n .findById(id)\n .switchIfEmpty(customExceptions.userNotFoundException())\n \n .map(user -> {\n userRepo.delete(user); // First deletion - delete-method from userRepo\n return user;\n })\n\n .flatMapMany(user -> postServ.findPostsByAuthorId(user.getId()))\n .map(post -> {\n postServ.delete(post); // Second deletion - delete-method from postService\n return post;\n })\n\n .flatMap(post -> comServ.findCommentsByPostId(post.getPostId()))\n .map(comServ::delete) // Third deletion - delete-method from commentService\n .then()\n ;\n }\n}\n
\nThanks a lot for any help
\n"},{"tags":["tomcat","jakarta-ee"],"owner":{"reputation":1,"user_id":16177221,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a/AATXAJyGWCT6kx-FXdD22qu_eF8IjtJpbaNQz1H3mUxA=k-s128","display_name":"Pyrockx","link":"https://stackoverflow.com/users/16177221/pyrockx"},"is_answered":false,"view_count":7,"answer_count":0,"score":0,"last_activity_date":1623258104,"creation_date":1623255937,"last_edit_date":1623258104,"question_id":67908137,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908137/how-to-login-successfully-using-a-java-ee-jakarta-ee-web-application-jaas-or-h","title":"How to login successfully using a Java EE/Jakarta EE web application (JAAS) or how to configure correctly a realm using Tomcat 10?","body":"I'm using Tomcat 10 and eclipse to develop a J2E (or Jakarta EE) web application. I followed this tutorial (http://objis.com/tutoriel-securite-declarative-jee-avec-jaas/#partie2) which seems old (it's a french document, because i'm french, sorry if my english isn't perfect), but I also read the Tomcat 10 documentation.
\nThe dataSource works, I followed instructions on this page (https://tomcat.apache.org/tomcat-10.0-doc/jndi-datasource-examples-howto.html#Oracle_8i,_9i_&_10g) and tested it, but it seems that the realm doesn't work, because I can't login successfully. I always have an authentification error, even if I use the right login and password.
\nI tried a lot of "solutions" to correct this, but no one works. And I still don't know if I have to put the realm tag inside context.xml, server.xml or both. I tried context.xml and both, but i don't see any difference.
\nMy web.xml :
<?xml version="1.0" encoding="UTF-8"?>\n<web-app \n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \n xmlns="http://Java.sun.com/xml/ns/javaee" \n xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" \n version="3.0">\n \n <!-- Servlet -->\n \n <servlet>\n <servlet-name>Accueil</servlet-name>\n <servlet-class>servlet.Accueil</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Accueil</servlet-name>\n <url-pattern></url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Bar</servlet-name>\n <servlet-class>servlet.Bar</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Bar</servlet-name>\n <url-pattern>/bar</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Galerie</servlet-name>\n <servlet-class>servlet.Galerie</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Galerie</servlet-name>\n <url-pattern>/galerie</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Cave</servlet-name>\n <servlet-class>servlet.Cave</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Cave</servlet-name>\n <url-pattern>/cave</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Mentions</servlet-name>\n <servlet-class>servlet.Mentions</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Mentions</servlet-name>\n <url-pattern>/mentions-legales</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Plan</servlet-name>\n <servlet-class>servlet.Plan</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Plan</servlet-name>\n <url-pattern>/plan-acces</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Restaurant</servlet-name>\n <servlet-class>servlet.Restaurant</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Restaurant</servlet-name>\n <url-pattern>/restaurant</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>Catalogue</servlet-name>\n <servlet-class>servlet.catalogue</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>Catalogue</servlet-name>\n <url-pattern>/catalogue</url-pattern>\n </servlet-mapping>\n \n <servlet>\n <servlet-name>AdminCatalogue</servlet-name>\n <servlet-class>servlet.AdminCatalogue</servlet-class>\n </servlet>\n \n <servlet-mapping>\n <servlet-name>AdminCatalogue</servlet-name>\n <url-pattern>/admin/administration-catalogue</url-pattern>\n </servlet-mapping>\n \n <security-constraint>\n <display-name>Test authentification Tomcat</display-name>\n <!-- Liste des pages protégées -->\n <web-resource-collection>\n <web-resource-name>Page sécurisée</web-resource-name>\n <url-pattern>/admin/*</url-pattern>\n </web-resource-collection>\n <!-- Rôles des utilisateurs ayant le droit d'y accéder -->\n <auth-constraint>\n <role-name>admin</role-name>\n </auth-constraint>\n <!-- Connection sécurisée -->\n <!-- <user-data-constraint>\n <transport-guarantee>CONFIDENTIAL</transport-guarantee>\n </user-data-constraint> -->\n </security-constraint>\n \n <!-- Configuration de l'authentification -->\n <login-config>\n <auth-method>FORM</auth-method>\n <realm-name>Espace administration</realm-name>\n <form-login-config>\n <form-login-page>/WEB-INF/login.jsp</form-login-page>\n <form-error-page>/WEB-INF/erreur-authentification.jsp</form-error-page>\n </form-login-config>\n </login-config>\n \n <!-- Rôles utilisés dans l'application -->\n <security-role>\n <description>Administrateur</description>\n <role-name>admin</role-name>\n </security-role>\n \n <!-- Ajoute taglibs.jsp au début de chaque jsp -->\n <jsp-config>\n <jsp-property-group>\n <url-pattern>*.jsp</url-pattern>\n <include-prelude>/WEB-INF/taglibs.jsp</include-prelude>\n </jsp-property-group>\n </jsp-config>\n \n <!-- Déclaration de référence à une source de données JNDI -->\n <resource-ref>\n <description>DB Connection</description>\n <res-ref-name>jdbc/caradoc</res-ref-name>\n <res-type>javax.sql.DataSource</res-type>\n <res-auth>Container</res-auth>\n </resource-ref>\n \n</web-app>\n
\ncontext.xml :
\n<?xml version="1.0" encoding="UTF-8"?>\n<!--\n Licensed to the Apache Software Foundation (ASF) under one or more\n contributor license agreements. See the NOTICE file distributed with\n this work for additional information regarding copyright ownership.\n The ASF licenses this file to You under the Apache License, Version 2.0\n (the "License"); you may not use this file except in compliance with\n the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an "AS IS" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n-->\n<!-- The contents of this file will be loaded for each web application -->\n<Context>\n\n <!-- Default set of monitored resources. If one of these changes, the -->\n <!-- web application will be reloaded. -->\n <WatchedResource>WEB-INF/web.xml</WatchedResource>\n <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>\n <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>\n\n <!-- Uncomment this to enable session persistence across Tomcat restarts -->\n <!--\n <Manager pathname="SESSIONS.ser" />\n -->\n <Resource name="jdbc/caradoc" auth="Container" type="javax.sql.DataSource"\n maxTotal="100" maxIdle="30" maxWaitMillis="10000"\n username="root" password="Caradoc22600!" driverClassName="com.mysql.jdbc.Driver"\n url="jdbc:mysql://localhost:3307/caradoc"/>\n \n <Realm className="org.apache.catalina.realm.DataSourceRealm" \n daraSourceName="jdbc/caradoc" localDataSource="true" userTable="utilisateurs"\n userRoleTable="roles" userNameCol="login" userCredCol="mdp"\n roleNameCol="role">\n <CredentialHandler className="org.apache.catalina.realm.SecretKeyCredentialHandler"\n algorithm="PBKDF2WithHmacSHA512"\n iterations="100000"\n keyLength="256"\n saltLength="16"\n />\n </Realm>\n</Context>\n
\nserver.xml :
\n<!--\n Licensed to the Apache Software Foundation (ASF) under one or more\n contributor license agreements. See the NOTICE file distributed with\n this work for additional information regarding copyright ownership.\n The ASF licenses this file to You under the Apache License, Version 2.0\n (the "License"); you may not use this file except in compliance with\n the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an "AS IS" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n-->\n<!-- Note: A "Server" is not itself a "Container", so you may not\n define subcomponents such as "Valves" at this level.\n Documentation at /docs/config/server.html\n -->\n<Server port="9000" shutdown="SHUTDOWN">\n <Listener className="org.apache.catalina.startup.VersionLoggerListener" />\n <!-- Security listener. Documentation at /docs/config/listeners.html\n <Listener className="org.apache.catalina.security.SecurityListener" />\n -->\n <!--APR library loader. Documentation at /docs/apr.html -->\n <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />\n <!-- Prevent memory leaks due to use of particular java/javax APIs-->\n <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />\n <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />\n <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />\n\n <!-- Global JNDI resources\n Documentation at /docs/jndi-resources-howto.html\n -->\n <GlobalNamingResources>\n <!-- Editable user database that can also be used by\n UserDatabaseRealm to authenticate users\n -->\n <Resource name="UserDatabase" auth="Container"\n type="org.apache.catalina.UserDatabase"\n description="User database that can be updated and saved"\n factory="org.apache.catalina.users.MemoryUserDatabaseFactory"\n pathname="conf/tomcat-users.xml" />\n </GlobalNamingResources>\n\n <!-- A "Service" is a collection of one or more "Connectors" that share\n a single "Container" Note: A "Service" is not itself a "Container",\n so you may not define subcomponents such as "Valves" at this level.\n Documentation at /docs/config/service.html\n -->\n <Service name="Catalina">\n\n <!--The connectors can use a shared executor, you can define one or more named thread pools-->\n <!--\n <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"\n maxThreads="150" minSpareThreads="4"/>\n -->\n\n\n <!-- A "Connector" represents an endpoint by which requests are received\n and responses are returned. Documentation at :\n HTTP Connector: /docs/config/http.html\n AJP Connector: /docs/config/ajp.html\n Define a non-SSL/TLS HTTP/1.1 Connector on port 8080\n -->\n <Connector port="8080" protocol="HTTP/1.1"\n connectionTimeout="20000"\n redirectPort="8443"\n URIEncoding = "UTF-8" />\n\n <!-- <Connector port="8443"\n protocol="org.apache.coyote.http11.Http11NioProtocol"\n maxThreads="150"\n SSLEnabled="true"\n scheme="https"\n secure="true"\n clientAuth="false"\n sslProtocol="TLS"\n keystoreFile="autosigned-cert.keystore"\n keyAlias="tomcat"\n keystorePass="azertyuiop" /> -->\n <!-- A "Connector" using the shared thread pool-->\n <!--\n <Connector executor="tomcatThreadPool"\n port="8080" protocol="HTTP/1.1"\n connectionTimeout="20000"\n redirectPort="8443" />\n -->\n <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443\n This connector uses the NIO implementation. The default\n SSLImplementation will depend on the presence of the APR/native\n library and the useOpenSSL attribute of the\n AprLifecycleListener.\n Either JSSE or OpenSSL style configuration may be used regardless of\n the SSLImplementation selected. JSSE style configuration is used below.\n -->\n <!--\n <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"\n maxThreads="150" SSLEnabled="true">\n <SSLHostConfig>\n <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"\n type="RSA" />\n </SSLHostConfig>\n </Connector>\n -->\n\n <!-- Define an AJP 1.3 Connector on port 8009 -->\n <!--\n <Connector protocol="AJP/1.3"\n address="::1"\n port="8009"\n redirectPort="8443" />\n -->\n\n <!-- An Engine represents the entry point (within Catalina) that processes\n every request. The Engine implementation for Tomcat stand alone\n analyzes the HTTP headers included with the request, and passes them\n on to the appropriate Host (virtual host).\n Documentation at /docs/config/engine.html -->\n\n <!-- You should set jvmRoute to support load-balancing via AJP ie :\n <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">\n -->\n <Engine name="Catalina" defaultHost="localhost">\n\n <!--For clustering, please take a look at documentation at:\n /docs/cluster-howto.html (simple how to)\n /docs/config/cluster.html (reference documentation) -->\n <!--\n <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>\n -->\n\n <!-- Use the LockOutRealm to prevent attempts to guess user passwords\n via a brute-force attack -->\n <Realm className="org.apache.catalina.realm.LockOutRealm">\n <!-- This Realm uses the UserDatabase configured in the global JNDI\n resources under the key "UserDatabase". Any edits\n that are performed against this UserDatabase are immediately\n available for use by the Realm. -->\n <Realm className="org.apache.catalina.realm.UserDatabaseRealm"\n resourceName="UserDatabase"/>\n </Realm>\n\n <Realm className="org.apache.catalina.realm.LockOutRealm">\n <Realm className="org.apache.catalina.realm.DataSourceRealm" \n daraSourceName="jdbc/caradoc" localDataSource="true" userTable="utilisateurs"\n userRoleTable="roles" userNameCol="login" userCredCol="mdp"\n roleNameCol="role">\n <CredentialHandler className="org.apache.catalina.realm.SecretKeyCredentialHandler"\n algorithm="PBKDF2WithHmacSHA512"\n iterations="100000"\n keyLength="256"\n saltLength="16"\n />\n </Realm>\n </Realm>\n\n <Host name="localhost" appBase="webapps"\n unpackWARs="true" autoDeploy="true">\n\n <!-- SingleSignOn valve, share authentication between web applications\n Documentation at: /docs/config/valve.html -->\n <!--\n <Valve className="org.apache.catalina.authenticator.SingleSignOn" />\n -->\n\n <!-- Access log processes all example.\n Documentation at: /docs/config/valve.html\n Note: The pattern used is equivalent to using pattern="common" -->\n <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"\n prefix="localhost_access_log" suffix=".txt"\n pattern="%h %l %u %t "%r" %s %b" />\n\n </Host>\n </Engine>\n </Service>\n</Server>\n
\nlogin.jsp :
\n<%@ page language="java" contentType="text/html; charset=UTF-8"\n pageEncoding="UTF-8"%>\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset="UTF-8">\n<title>Connexion Administrateur</title>\n</head>\n<body>\n <div align="center">\n <h2>Identification</h2>\n </div>\n <form action="j_security_check" method="post" accept-charset="utf-8">\n <table align="center">\n <tr>\n <td>Login : </td>\n <td><input type="text" name="j_username"/></td>\n </tr>\n <tr>\n <td>Mot de passe : </td>\n <td><input type="password" name="j_password"/></td>\n </tr>\n </table>\n <p align="center"><input type="submit" value="Connexion"/></p>\n </form>\n</body>\n</html>\n
\nerreur-authentifiction.jsp, has same content as login.jsp, but with an error message.
User table (password hash obtained with digest.bat) :\nUser table
\nRole table with foreign key on login referencing login column of user table :\nRole table
\nThis is my project arborescence, if it can help : arborescence
\nSo please, can someone tell me what I did wrong ?
\n"},{"tags":["java","android","android-linearlayout","visibility","show-hide"],"owner":{"reputation":1,"user_id":16177674,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14Ghq1-kEBr_o9EZvxjj3eU7RT2_uVgmCW6yGY5DXOQ=k-s128","display_name":"Suraj Verma","link":"https://stackoverflow.com/users/16177674/suraj-verma"},"is_answered":false,"view_count":10,"answer_count":0,"score":0,"last_activity_date":1623258101,"creation_date":1623257797,"last_edit_date":1623258101,"question_id":67908594,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908594/how-to-set-visibility-gone-of-a-linear-layout-which-is-inside-a-scroll-view-and","title":"How to set visibility GONE of a Linear Layout which is inside a scroll view and contains two TextViews inside?","body":"The main layout is a Linear layout inside that a scroll view is there which contain sublayouts. Here is my layout [omitted everything except the specific layout (marked with red) as it will be very long] :
\n<ScrollView\n android:layout_width="match_parent"\n android:layout_height="match_parent">\n\n <LinearLayout\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:orientation="vertical">\n\n <androidx.cardview.widget.CardView\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:layout_gravity="center"\n android:layout_marginStart="10dp"\n android:layout_marginTop="8dp"\n android:layout_marginEnd="10dp"\n android:layout_marginBottom="8dp"\n android:foreground="?android:attr/selectableItemBackground"\n app:cardCornerRadius="8dp"\n app:cardElevation="10dp">\n\n <LinearLayout\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:orientation="vertical"\n android:padding="8dp">\n\n\n <LinearLayout\n android:id="@+id/layoutIncomeTax"\n android:layout_width="match_parent"\n android:layout_height="wrap_content"\n android:orientation="horizontal">\n\n <TextView\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:gravity="start"\n android:text="Income Tax:"\n android:textColor="@color/black"\n android:textSize="16sp" />\n\n <TextView\n android:id="@+id/tvIncomeTax"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_weight="1"\n android:gravity="end"\n android:text="0"\n android:textColor="@color/black"\n android:textSize="16sp"\n android:textStyle="bold" />\n\n </LinearLayout>\n\n </LinearLayout>\n\n </androidx.cardview.widget.CardView>\n\n </LinearLayout>\n\n</ScrollView>\n
\n\nHere is my code (removed unnecessary codes) :
\npublic class ViewSalary extends AppCompatActivity {
\nprivate Spinner selectShift, selectYear, selectMonth;\nprivate EditText edtEmployeeCode;\nprivate Button viewSalaryBtn;\nprivate String shift, year, month;\n\n\nDatabaseReference rootDatabaseRef;\n\nprivate LinearLayout layoutIncomeTax;\n\nprivate TextView tvIncomeTax;\n\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_view_salary);\n\n\n viewSalaryBtn = findViewById(R.id.viewSalaryBtn);\n\n layoutIncomeTax = findViewById(R.id.layoutIncomeTax);\n\n tvIncomeTax = findViewById(R.id.tvIncomeTax);\n\n rootDatabaseRef = FirebaseDatabase.getInstance().getReference().child("Salary");\n\n viewSalaryBtn.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n\n viewSalary();\n\n String checkIncomeTax = tvIncomeTax.getText().toString();\n if (checkIncomeTax.equals("0.0")) {\n layoutIncomeTax.setVisibility(layoutIncomeTax.GONE);\n }\n\n }\n });\n\n\n}\n\nprivate void viewSalary() {\n\n final String empCode = edtEmployeeCode.getText().toString();\n\n DatabaseReference empRef = rootDatabaseRef.child(shift).child(year).child(month).child(empCode);\n\n empRef.addValueEventListener(new ValueEventListener() {\n @Override\n public void onDataChange(@NonNull DataSnapshot dataSnapshot) {\n if (dataSnapshot.exists()) {\n\n String incomeTax = dataSnapshot.child("IncomeTax").getValue(String.class);\n\n tvIncomeTax.setText(incomeTax);\n\n } else {\n Toast.makeText(ViewSalary.this, "Data does not exist!", Toast.LENGTH_SHORT).show();\n }\n }\n\n @Override\n public void onCancelled(@NonNull DatabaseError error) {\n Toast.makeText(ViewSalary.this, error.getMessage(), Toast.LENGTH_SHORT).show();\n }\n });\n\n}\n
\n}
\nI want to hide all linear layouts on button click after getting the data loaded and if TextView value is "0.0" (like the one marked with red in screenshot)
\n\n"},{"tags":["excel","vba","selenium","export-to-excel"],"owner":{"reputation":15,"user_id":13804833,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/e302eb75ecb95fb24f5eafc8ecfa7750?s=128&d=identicon&r=PG&f=1","display_name":"AAdi","link":"https://stackoverflow.com/users/13804833/aadi"},"is_answered":false,"view_count":36,"answer_count":1,"score":0,"last_activity_date":1623258097,"creation_date":1623231368,"question_id":67901448,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67901448/the-innertext-in-tbody-is-not-printing","title":"The innerText in tbody is not printing","body":"The "thead" is giving all the data in side by innerText, but "tbody" is blank. No "tr" and even "td" is helping.
\nSub ScrapeOddsUsingXMLHTTP11()\nDim XMLRequest As New MSXML2.XMLHTTP60\nDim HTMLDoc As New MSHTML.HTMLDocument\nDim HTMLDiv As MSHTML.IHTMLElement\nDim HTMLTable1, HTMLTable2 As MSHTML.IHTMLElement\n\nXMLRequest.Open "GET", "https://www.nseindia.com/get-quotes/equity?symbol=MCX", False\nXMLRequest.send\n\nIf XMLRequest.Status <> 200 Then\n MsgBox XMLRequest.Status & " - " & XMLRequest.statusText\n Exit Sub\nEnd If\n\nHTMLDoc.body.innerHTML = XMLRequest.responseText\n\nSet HTMLDiv = HTMLDoc.getElementById("priceInfoTable")\nSet HTMLTable1 = HTMLDiv.getElementsByTagName("thead")(0)\nSet HTMLTable2 = HTMLDiv.getElementsByTagName("tbody")(0)\n\nDebug.Print HTMLTable1.innerText\nDebug.Print HTMLTable2.innerText\n\nEnd Sub\n
\nPlease help me there the image is incerted.
\n"},{"tags":["java","angular","version"],"owner":{"reputation":85,"user_id":7551051,"user_type":"registered","profile_image":"https://lh4.googleusercontent.com/-weUfbjvkvV8/AAAAAAAAAAI/AAAAAAAAAvE/1vAomyTRBog/photo.jpg?sz=128","display_name":"Hatim Setti","link":"https://stackoverflow.com/users/7551051/hatim-setti"},"is_answered":false,"view_count":16,"closed_date":1623255968,"answer_count":0,"score":0,"last_activity_date":1623258084,"creation_date":1623255658,"last_edit_date":1623258084,"question_id":67908057,"link":"https://stackoverflow.com/questions/67908057/which-version-of-java-is-needed-for-angular","closed_reason":"Duplicate","title":"which version of java is needed for angular","body":"I have a question, we have an existing project with java 6 and GWT and we want to migrate to angular (we are using soap web services)
\nIs java 6 works with angular ?\n
If not, must I use java 8 ?
\nAngular works with soap web services or we must go for Rest ?
I am trying to check when loading arbitrary csv files if they have a header or not, and I have been using the built-in sniffer to do so.
\nI have two csv files, which look like so:
\nhours,cumulative\n0,0\n0.167,0\n1,0.844751725\n2,1.036681406\n4,3.574853513\n8,6.658784849\n24,17.99046989\n48,28.71241914\n120,45.19487011\n168,55.48073423\n240,63.42035593\n336,71.46442916\n
\nhours,cumulative\n0.00,0\n24.00,3001.516\n48.00,4183.836\n72.00,5090.53\n96.00,5869.408\n120.00,6588.484\n144.00,7251.586\n168.00,7882.792\n192.00,8457.52\n216.00,8986.762\n240.00,9482.2\n264.00,9945.37\n288.00,10388.204\n312.00,10800.012\n336.00,11219.976\n360.00,11620.11\n384.00,12006.216\n408.00,12371.944\n432.00,12724.996\n456.00,13066.336\n
\nAnd I am trying to run this code to detect if there are headers present in the file:
\nwith open(file,encoding='utf-8-sig') as f:\n has_header = csv.Sniffer().has_header(f.read(1024))\nheader = 0 if has_header == True else None\n
\nThis works beautifully for file2, but for file1 (and others) it just does not correctly read the data.
\nColumn one is a float for file1, but int for file2 (copied from notepad++ so not sure why the decimals are there). When I switch the data to be a float for file2 (e.g. 24 -> 24.000001), then has_header returns the incorrect value. I have tested this with numerous files, and for any file with an int type for column one, then has_header = True. Conversely, any column that is a float will return has_header = False even though there is one.
\nI'm really scratching my head over this one and I'm unsure why this would be so.
\nAny insight/help would be great, thanks!
\n"},{"tags":["c"],"owner":{"reputation":99,"user_id":11478529,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/29b4713b937df82a2612d28bd03b5564?s=128&d=identicon&r=PG&f=1","display_name":"Akil","link":"https://stackoverflow.com/users/11478529/akil"},"is_answered":false,"view_count":35,"answer_count":2,"score":-1,"last_activity_date":1623258083,"creation_date":1623256086,"last_edit_date":1623256545,"question_id":67908167,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908167/trying-to-remove-hyphens-from-a-string-in-c","title":"Trying to remove hyphens from a string in C","body":"I am solving a problem in which I have a date (YYYY-MM-DD) as user input and I need to find out the day(Sunday, Monday,.. ). I have tried to remove the hyphen so that I can proceed with Zellor's rule. To achieve that I used a loop. However, it doesn't seem to work.\nHere's is my code:
\n#include<stdio.h>\nint main(){\n char date[11], datenum[9]; \n int date_num;\n printf("Enter the date in yyyy-mm-dd format\\n");\n scanf("%s", &date);\n int j = 0;\n for (int i=0; i<10; i++){\n if (date[i]!='-' && j<8){\n datenum[j] = date[i];\n printf("%c", datenum[j]);\n j++;\n }\n } \n printf("%s\\n", datenum);\n return 0;\n}\n
\nI was expecting 20210609 as output when I gave 2021-06-09 as input but that doesn't seem to be the case. Instead, I got 2021060920210609█2021-06-09.
\n"},{"tags":["mysql","ef-code-first","razor-pages","asp.net-core-5.0","ef-core-5.0"],"owner":{"reputation":387,"user_id":1798229,"user_type":"registered","accept_rate":50,"profile_image":"https://www.gravatar.com/avatar/177fd0c20f226cc118b716438d0a803c?s=128&d=identicon&r=PG","display_name":"Chris","link":"https://stackoverflow.com/users/1798229/chris"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623258078,"creation_date":1623258078,"question_id":67908657,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908657/entityframeword-core-5-mysql-table-sharing","title":"EntityFrameword Core 5, MySQL, Table sharing","body":"The scenario:
\nI have an address table with what you'd kind of expect (street, town, postcode etc)
\nI have 2 other entities (Site and Client Details), both of these have an address property (another way of thinking of the structure is to think of it like ClientDetails.Address as a head office and Sites/Site.Address as office buildings around the country).
\nI'm trying to figure out getting the relationship sorted, currently it's complaining because when I add a ClientDetails.Address, its failing on the ClientDetails.Sites.Address FK constraint.
\nI'm thinking I might need to configure the relationships manually through the Fluent API, but figured I'd ask in case anyone has had similar (I'm sure I'm not the first one wanting to do this)!
\nI'm trying to do this using a CodeFirst approach, I have no additional config in my modelBuilder configuration.
\nThe project is using .NET 5 with EF Core 5
\nI'm starting to think that Table Splitting is how is resolve this but the examples I've seen thus far don't quite seem to make sense to me.
\nDB Schema:
\n\n\nClientDetails.cs
\npublic class ClientDetails\n{\n public Guid ClientDetailsId { get; set; }\n\n public string Name { get; set; }\n\n public virtual Address Address { get; set; }\n\n public Byte[] Image { get; set; }\n\n public List<ClientStaff> Staff { get; set; }\n\n public List<Site> Sites { get; set; }\n}\n
\nSite.cs
\npublic class Site\n{\n public Guid? SiteId { get; set; }\n\n public string AccessCode { get; set; }\n\n public PointOfContact PointOfContact { get; set; }\n\n public Guid ClientDetailsId { get; set; }\n\n public ClientDetails ClientDetails { get; set; }\n\n public virtual Address Address { get; set; } \n}\n
\nAddress.cs
\n public class Address\n{\n public Guid AddressId { get; set; }\n\n public string LineOne { get; set; }\n\n public string LineTwo { get; set; }\n\n public string LineThree { get; set; }\n\n public string PostalCode { get; set; }\n\n public Guid ClientDetailsId { get; set; }\n public virtual ClientDetails ClientDetails { get; set; }\n public Guid SiteId { get; set; }\n public virtual Site Site { get; set; }\n}\n
\n"},{"tags":["windows","powershell","firewall","silent-installer"],"owner":{"reputation":1,"user_id":16178083,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GgKHr8A1n93Ez_bhtpvJK_JA49kEtYSl0Yqb-XL-g=k-s128","display_name":"FutureHistory24","link":"https://stackoverflow.com/users/16178083/futurehistory24"},"is_answered":false,"view_count":6,"answer_count":0,"score":0,"last_activity_date":1623258078,"creation_date":1623258078,"question_id":67908658,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908658/powershell-silent-install-windows-defender-firewall-prompt","title":"PowerShell - Silent Install - Windows Defender Firewall Prompt","body":"I am trying to write a silent install for an application but during the install, a Windows Firewall Security Alert appears for allowing access to the domain/private/public network. I have already created an inbound rule to allow the application over the domain network, but the window asking for permission will still display, which is an issue since its suppose to be a silent install. I verified that the inbound rule was successful in Windows Defender Firewall with Advanced Security. What would be the best way to get this prompt closed?
\n\n netsh advfirewall firewall add rule name="javaw.exe" dir=in action=allow program= $fullPath enable=yes profile=domain\n
\n"},{"tags":["p4-lang"],"owner":{"reputation":119,"user_id":5712225,"user_type":"registered","profile_image":"https://graph.facebook.com/1521385268157472/picture?type=large","display_name":"Mahmoud Bahnasy","link":"https://stackoverflow.com/users/5712225/mahmoud-bahnasy"},"is_answered":false,"view_count":3,"answer_count":0,"score":0,"last_activity_date":1623258077,"creation_date":1623258077,"question_id":67908656,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908656/can-we-set-queue-depth-length-per-priority-in-p4","title":"Can we set queue depth/length per priority in P4?","body":"I'm trying to implement a priority Queue in P4 and I need to limit the number of packets that can be served in a low priority queue so I won't choke the high priority traffic.\nTherefore, I need to either:\n1- Set a fixed size per queue per priority.\n2- Drop a packet if the priority queue length exceeded certain threshold\nAny idea on how to accomplish either one of them.\nThanks
\n"},{"tags":["javascript","html"],"owner":{"reputation":5152,"user_id":4352930,"user_type":"registered","accept_rate":78,"profile_image":"https://i.stack.imgur.com/54DOb.png?s=128&g=1","display_name":"tfv","link":"https://stackoverflow.com/users/4352930/tfv"},"is_answered":true,"view_count":39,"accepted_answer_id":67903946,"answer_count":1,"score":0,"last_activity_date":1623258075,"creation_date":1623233729,"last_edit_date":1623258075,"question_id":67902098,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67902098/cannot-get-rid-of-page-reload-in-html-javascript-form","title":"Cannot get rid of page reload in html/javascript form","body":"I am trying to set up a form in which buttons fill input fields and in which those input fields can again be emptied by other "delete" buttons.
\nThis works quite well, but I cannot get rid of one problem in a special action sequence:
\nIf I press buttons "one" and "three", the corresponding input forms are filled properly, this is what I want.
\nNow if after that I press the "Delete A" button, one of two unwanted things happen:
\nIf the command event.preventDefault() exists in line 15, then (only) the first input field gets cleared correctly and the buttons are restored. But when I then again press button "one", the complete form gets cleared and the word "three" vanishes from form 2.
\nIf the command event.preventDefault() is deleted from line 15, then as soon as I press "Delete A", the complete form gets cleared and also the word "three" vanishes from form 2.
\nI do not want to clear the complete form to be reloaded at any stage.
\nEDIT: The problem is not a question of returning false
values from functions to prevent form submission as discussed in JavaScript code to stop form submission . in fact all my fucntions are returning false
values.
<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"ISO-8859-1\">\n\n</head>\n<script> \n\nfunction evt_r(){\nvar task = document.getElementById(\"task_\"+arguments[0]);\nvar tasklabel = arguments[0];\nvar texts = Array.from(arguments).slice(1)\nvar length = task.getElementsByTagName(\"button\").length - 1;\n\nevent.preventDefault()\n\n// remove existing buttons\nfor (let i =0; i < length; i++){\ntask.removeChild(task.getElementsByTagName(\"button\")[0]);\n}\n\n// recreate all buttons from scratch\nfor (let i =texts.length-1; i >=0 ; i--){\nbtn = document.createElement(\"button\");\nbtn.innerHTML = texts[i];\nbtn.onClick= \"evt_\"+String(tasklabel)+\"_\"+String(i)+\"()\";\nbtn.id=\"id_btn_\"+String(tasklabel)+\"_\"+String(i);\ntask.insertBefore(btn, task.firstChild);\ntask.children[0].style.marginRight =\"5px\";\n}\ndocument.getElementById(\"id_task_\"+String(tasklabel)).value=\"\";\n\nreturn false;\n}\n\nfunction evt_0_0(){\nvar elem = document.getElementById(\"id_btn_0_0\");\nevent.preventDefault()\nelem.parentNode.removeChild(elem);\ndocument.getElementById(\"id_task_0\").value=document.getElementById(\"id_task_0\").value +\"one \"\nreturn false;\n}\nfunction evt_0_1(){\nvar elem = document.getElementById(\"id_btn_0_1\");\nevent.preventDefault()\nelem.parentNode.removeChild(elem);\ndocument.getElementById(\"id_task_0\").value=document.getElementById(\"id_task_0\").value +\"two \"\nreturn false;\n}\n\nfunction evt_1_0(){\nvar elem = document.getElementById(\"id_btn_1_0\");\nevent.preventDefault()\nelem.parentNode.removeChild(elem);\ndocument.getElementById(\"id_task_1\").value=document.getElementById(\"id_task_1\").value +\"three \"\nreturn false;\n}\nfunction evt_1_1(){\nvar elem = document.getElementById(\"id_btn_1_1\");\nevent.preventDefault()\nelem.parentNode.removeChild(elem);\ndocument.getElementById(\"id_task_1\").value=document.getElementById(\"id_task_1\").value +\"four \"\nreturn false;\n}\n\n</script>\n\n<body>\n<ol>\n<li style=\"margin-bottom:8px\"><form id = \"task_0\" >\n<button id=\"id_btn_0_0\" onclick=\"evt_0_0()\">one</button>\n<button id=\"id_btn_0_1\" onclick=\"evt_0_1()\">two</button>\n\n<button id=\"id_btn_0_r\" onclick='evt_r(\"0\", \"one\", \"two\")' style=\"margin-left:50px\">Delete A</button>\n<br>\n<input id=\"id_task_0\" style=\"margin-top:10px\" ></input>\n</form>\n<li style=\"margin-bottom:8px\"><form id = \"task_1\" >\n<button id=\"id_btn_1_0\" onclick=\"evt_1_0()\">three</button>\n<button id=\"id_btn_1_1\" onclick=\"evt_1_1()\">four</button>\n<button id=\"id_btn_1_r\" onclick='evt_r(\"1\", \"three\", \"four\")' style=\"margin-left:50px\">Delete B</button>\n<br>\n<input id=\"id_task_1\" style=\"margin-top:10px\" ></input>\n</form>\n\n</body>\n</html>
\r\nI need to count how many times certain value occurs in a column
\nIt looks like this (select * from znajezyki order by klos
)
klos - is a serial number of a person (this value is repeated)
\nNow I need to create a query that will show me how many people knows 1,2,3 languages
\nIf the same "klos" value is repeated 2 times that means that this person knows 2 languages if it occurs 3 times that means that pearson knows 3 languages and so on
\nI'd like my result to look something like this:\n
\nI tried refering to this post here but i cannot understand it and can't get it to work
\nI hope y'all can understand what I am talking about :)
\n"},{"tags":["go"],"owner":{"reputation":387,"user_id":12293663,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/-YRO5C6xRN0g/AAAAAAAAAAI/AAAAAAAAARg/CWKAIE4BUxI/photo.jpg?sz=128","display_name":"cosmos multi","link":"https://stackoverflow.com/users/12293663/cosmos-multi"},"is_answered":false,"view_count":9,"answer_count":0,"score":0,"last_activity_date":1623258070,"creation_date":1623258070,"question_id":67908654,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908654/how-to-keep-the-value-of-a-cookie","title":"how to keep the value of a cookie","body":"I am in the process of user authentication in my application which is done through a cookie that the jwt saves, when I make the request the client obtains the cookie without problems, but when the client updates the page or only f5 the cookie is deleted , I was investigating if it was happening on localhost or there was a problem in my code, but I didn't find anything related to my problem.\nThis is my code in Go:
\nfunc Login(w http.ResponseWriter, r *http.Request) {\n w.Header().Set("Content-Type", "application/json")\n\n u := model.User{}\n if err := json.NewDecoder(r.Body).Decode(&u); err != nil {\n http.Error(w, "format incorrect", http.StatusBadRequest)\n return\n }\n\n user, equals, err := u.AccessControll(u.Email, u.Password)\n if err != nil {\n http.Error(w, err.Error(), http.StatusBadRequest)\n return\n }\n\n if !equals {\n http.Error(w, "ups", http.StatusBadRequest)\n return\n }\n\n token, err := jwt.CreateToken(user)\n if err != nil {\n http.Error(w, err.Error(), http.StatusBadRequest)\n return\n }\n\n cookie := http.Cookie{\n Name: "token",\n Value: token,\n Expires: time.Now().Add(5 * time.Minute),\n HttpOnly: true,\n }\n\n http.SetCookie(w, &cookie)\n}\n
\n"},{"tags":["python","pandas","if-statement","next"],"owner":{"reputation":1,"user_id":16158116,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/2a0dfcf8f95a93cf74074c48d85bf0a3?s=128&d=identicon&r=PG&f=1","display_name":"yosi","link":"https://stackoverflow.com/users/16158116/yosi"},"is_answered":false,"view_count":17,"answer_count":1,"score":0,"last_activity_date":1623258069,"creation_date":1623255218,"question_id":67907956,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907956/finding-the-first-row-which-stratifies-two-conditions-in-python-data-frame","title":"Finding the first row which stratifies two conditions in python data frame","body":"I have a data frame which looks like this:
\n\nI want to write a code which locates points that have distance less than 250 from the next point. When it finds the point searches for the first point that is more than 250 away with speed greater than 5.\nFor example in the sample data set, first find row 7 and then locate row 10 which is more than 250 away and has speed of 10.8 and return the index of row 10\nI have write this code so far:
\nfor i in (number+1 for number in range(data_gpd.index[-1]-1)):\nif (data_gpd['distance'][i+1]< 250):\n
\nI'm not sure what should I do after this condition. I had in mind to use "Next" statement with conditions but I was only able to find it for list comprehension with one condition.
\nI really appreciate your help as I'm new to python and not sure which syntax would work better
\n"},{"tags":["sqlite"],"owner":{"reputation":87,"user_id":11704346,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/44942af2f7847e6a6a0ba38e0a10ecbd?s=128&d=identicon&r=PG&f=1","display_name":"UncommentedCode","link":"https://stackoverflow.com/users/11704346/uncommentedcode"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258069,"creation_date":1623258069,"question_id":67908652,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908652/sqlite-sort-by-source-column","title":"SQLite Sort by Source Column","body":"In my SQLite database, I have a query that selects records where a string is present in one of several columns - i.e with the following
\nColumn1 | \nColumn2 | \n
---|---|
String | \nStringString | \n
I have the following query:
\nWHERE Column1 LIKE 'String' OR Column2 LIKE '%String%'\n
\nHow can I make it so that the results are ordered based on which column they matched with? I.e. put items that matched from Column1 before items that were matched with Column2, or vice versa?
\n"},{"tags":["typescript","webassembly","deno"],"owner":{"reputation":47,"user_id":11576753,"user_type":"registered","profile_image":"https://i.stack.imgur.com/KtOlW.png?s=128&g=1","display_name":"nabezokodaikon","link":"https://stackoverflow.com/users/11576753/nabezokodaikon"},"is_answered":false,"view_count":4,"answer_count":0,"score":0,"last_activity_date":1623258068,"creation_date":1623258068,"question_id":67908651,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908651/when-i-bundle-code-with-wasm-and-run-it-in-a-browser-using-deno-i-get-an-error","title":"When I bundle code with wasm and run it in a browser using deno, I get an error","body":"When I bundle code with wasm and run it in a browser using deno, I get an error.
\nRunning command.
\n$ cargo build --target=wasm32-unknown-unknown --release\n$ wasm-bindgen target/wasm32-unknown-unknown/release/wasm_deno.wasm --out-dir ./server/public/pkg --target web\n$ deno bundle server/public/ts/greet.ts server/public/js/greet.js\n
\nThen, the following error occurs.
\nUncaught TypeError: Cannot read property '__wbindgen_malloc' of undefined\n
\nIf you change the typescript code, you will get various other errors.
\n"},{"tags":["excel","vba"],"owner":{"reputation":45,"user_id":5555327,"user_type":"registered","accept_rate":67,"profile_image":"https://www.gravatar.com/avatar/b8c037c1dbe477fd741f5e23fa399dd0?s=128&d=identicon&r=PG&f=1","display_name":"SomeNewPythonGuy","link":"https://stackoverflow.com/users/5555327/somenewpythonguy"},"is_answered":false,"view_count":23,"answer_count":1,"score":0,"last_activity_date":1623258066,"creation_date":1623184013,"last_edit_date":1623184071,"question_id":67894153,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67894153/excel-vba-macro-to-hide-all-rows-except-top-5-rows-and-selected-row","title":"Excel VBA/Macro to hide all rows except top 5 rows and selected row?","body":"good afternoon, everyone. I have several worksheets in progress that have various rows of data in the field. I have one aspect of unhiding all of the rows through a macro, as well as creating VBA to select and hide all rows without colored squares from within the worksheet. My main dilemma is that in a section with let's say 200 rows, I want to have it so that only the row the user has selected through the cursor and the top 5 rows (Or maybe just the top row or so, depending on the table.)
\nAny help would be appreciated. I'll post an example of what I mean.\nlike so
\nTitle 1 Title 2 Title 3
Row 1 Something 1 SomethingElse 1
\nRow 2 Something 2 SomethingElse 2
\nRow 3 Something 3 SomethingElse 3
\nRow 4 Something 4 SomethingElse 4 <User is on Cell A, shown here as Bolded
\nRow 5 Something 5 SomethingElse 5
\nRow 6 Something 6 SomethingElse 6
\nRow 7 Something 7 SomethingElse 7
\nRow 8 Something 8 SomethingElse 8
\nRow 9 Something 9 SomethingElse 9
\nRow 10 Something 10 SomethingElse 10
\nThis is what I'd Like after the macro gets done. Just the top row and selected row.
\nTitle 1 Title 2 Title 3
\nRow 4 Something 4 SomethingElse 4
\nThank you again, everyone!
\n"},{"tags":["python","opencv","python-imaging-library","png","python-tesseract"],"owner":{"reputation":1,"user_id":16178153,"user_type":"registered","profile_image":"https://lh3.googleusercontent.com/a-/AOh14GiSQiolB1SiDc7FUJFU--MM4ooRbLTJK0gMeCqS=k-s128","display_name":"Eli Norris","link":"https://stackoverflow.com/users/16178153/eli-norris"},"is_answered":false,"view_count":5,"answer_count":0,"score":0,"last_activity_date":1623258065,"creation_date":1623258065,"question_id":67908648,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908648/running-into-weird-erros-when-coverting-a-png-screenshot-of-a-table-into-a-exce","title":"Running Into weird erros when coverting a .png screenshot of a table into a excel file","body":"I am currently trying to convert a .png screenshot of a table into an excel file with all the data. Creating the new images, vertical, inverted, horizontal, and img_vh are all working. The seems to be somewhere towards the end of the program. I found this skeleton code online and have made slight modifications but I do not have a complete understanding of what is happening.
\nHere is my error followed by the code, apologies if the question is not well written, this is my first post. Any advice/ideas are greatly appreciated
\nERROR:
\nTraceback (most recent call last):\n
\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 255, in run_tesseract\nproc = subprocess.Popen(cmd_args, **subprocess_args())\nFile "C:\\ProgramData\\Anaconda3\\lib\\subprocess.py", line 775, in init\nrestore_signals, start_new_session)\nFile "C:\\ProgramData\\Anaconda3\\lib\\subprocess.py", line 1178, in _execute_child\nstartupinfo)\nFileNotFoundError: [WinError 2] The system cannot find the file specified
\nDuring handling of the above exception, another exception occurred:
\nTraceback (most recent call last):\nFile "C:/Users/19038/PycharmProjects/1st Day/ExEqsENGR102_528eli.norris.py", line 187, in \nout = pytesseract.image_to_string(erosion)\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 413, in image_to_string\n}output_type\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 412, in \nOutput.STRING: lambda: run_and_get_output(*args),\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 287, in run_and_get_output\nrun_tesseract(**kwargs)\nFile "C:\\Users\\19038\\PycharmProjects\\1st Day\\venv\\lib\\site-packages\\pytesseract\\pytesseract.py", line 259, in run_tesseract\nraise TesseractNotFoundError()\npytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.
\nCODE:
\n import cv2\n import numpy as np\n import pandas as pd\n import matplotlib.pyplot as plt\n import csv\n \n try:\n from PIL import Image\n except ImportError:\n import Image\n import pytesseract\n \n \n #read your file\n #file=r'/Users\\19038\\Desktop/Picture.png'\n img = cv2.imread('C:/Users/19038/Desktop/Research Things/Test/Picture.png',0)\n #print(img)\n img.shape\n \n #thresholding the image to a binary image\n thresh,img_bin = cv2.threshold(img,128,255,cv2.THRESH_BINARY |cv2.THRESH_OTSU)\n \n #inverting the image\n img_bin = 255-img_bin\n cv2.imwrite('C:/Users/19038/Desktop/Research Things/Test/inverted_Picture.png', img_bin)\n \n #Plotting the image to see the output\n plotting = plt.imshow(img_bin,cmap='gray')\n plt.show()\n \n # countcol(width) of kernel as 100th of total width\n kernel_len = np.array(img).shape[1] // 100\n # Defining a vertical kernel to detect all vertical lines of image\n ver_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (1, kernel_len))\n # Defining a horizontal kernel to detect all horizontal lines of image\n hor_kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (kernel_len, 1))\n # A kernel of 2x2\n kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (2, 2))\n \n # Use vertical kernel to detect and save the vertical lines in a jpg\n image_1 = cv2.erode(img_bin, ver_kernel, iterations=3)\n vertical_lines = cv2.dilate(image_1, ver_kernel, iterations=3)\n cv2.imwrite("C:/Users/19038/Desktop/Research Things/Test/vertical.jpg", vertical_lines)\n # Plot the generated image\n plotting = plt.imshow(image_1, cmap='gray')\n plt.show()\n \n # Use horizontal kernel to detect and save the horizontal lines in a jpg\n image_2 = cv2.erode(img_bin, hor_kernel, iterations=3)\n horizontal_lines = cv2.dilate(image_2, hor_kernel, iterations=3)\n cv2.imwrite("C:/Users/19038/Desktop/Research Things/Test/horizontal.jpg", horizontal_lines)\n # Plot the generated image\n plotting = plt.imshow(image_2, cmap='gray')\n plt.show()\n \n # Combine horizontal and vertical lines in a new third image, with both having same weight.\n img_vh = cv2.addWeighted(vertical_lines, 0.5, horizontal_lines, 0.5, 0.0)\n # Eroding and thesholding the image\n img_vh = cv2.erode(~img_vh, kernel, iterations=2)\n thresh, img_vh = cv2.threshold(img_vh, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)\n cv2.imwrite("C:/Users/19038/Desktop/Research Things/Test/img_vh.jpg", img_vh)\n bitxor = cv2.bitwise_xor(img, img_vh)\n bitnot = cv2.bitwise_not(bitxor)\n # Plotting the generated image\n plotting = plt.imshow(bitnot, cmap='gray')\n plt.show()\n \n # Detect contours for following box detection\n contours, hierarchy = cv2.findContours(img_vh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)\n \n \n def sort_contours(cnts, method="left-to-right"):\n # initialize the reverse flag and sort index\n reverse = False\n i = 0\n # handle if we need to sort in reverse\n if method == "right-to-left" or method == "bottom-to-top":\n reverse = True\n # handle if we are sorting against the y-coordinate rather than\n # the x-coordinate of the bounding box\n if method == "top-to-bottom" or method == "bottom-to-top":\n i = 1\n # construct the list of bounding boxes and sort them from top to\n # bottom\n boundingBoxes = [cv2.boundingRect(c) for c in cnts]\n (cnts, boundingBoxes) = zip(*sorted(zip(cnts, boundingBoxes),\n key=lambda b: b[1][i], reverse=reverse))\n # return the list of sorted contours and bounding boxes\n return (cnts, boundingBoxes)\n \n \n # Sort all the contours by top to bottom.\n contours, boundingBoxes = sort_contours(contours, method="top-to-bottom")\n \n # Creating a list of heights for all detected boxes\n heights = [boundingBoxes[i][3] for i in range(len(boundingBoxes))]\n \n # Get mean of heights\n mean = np.mean(heights)\n \n # Create list box to store all boxes in\n box = []\n # Get position (x,y), width and height for every contour and show the contour on image\n for c in contours:\n x, y, w, h = cv2.boundingRect(c)\n if (w < 1000 and h < 500):\n image = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)\n box.append([x, y, w, h])\n \n plotting = plt.imshow(image, cmap='gray')\n plt.show()\n \n # Creating two lists to define row and column in which cell is located\n row = []\n column = []\n j = 0\n \n # Sorting the boxes to their respective row and column\n for i in range(len(box)):\n \n if (i == 0):\n column.append(box[i])\n previous = box[i]\n \n else:\n if (box[i][1] <= previous[1] + mean / 2):\n column.append(box[i])\n previous = box[i]\n \n if (i == len(box) - 1):\n row.append(column)\n \n else:\n row.append(column)\n column = []\n previous = box[i]\n column.append(box[i])\n \n print(column)\n print(row)\n \n # calculating maximum number of cells\n countcol = 0\n for i in range(len(row)):\n countcol = len(row[i])\n if countcol > countcol:\n countcol = countcol\n \n # Retrieving the center of each column\n center = [int(row[i][j][0] + row[i][j][2] / 2) for j in range(len(row[i])) if row[0]]\n \n center = np.array(center)\n center.sort()\n print(center)\n # Regarding the distance to the columns center, the boxes are arranged in respective order\n \n finalboxes = []\n for i in range(len(row)):\n lis = []\n for k in range(countcol):\n lis.append([])\n for j in range(len(row[i])):\n diff = abs(center - (row[i][j][0] + row[i][j][2] / 4))\n minimum = min(diff)\n indexing = list(diff).index(minimum)\n lis[indexing].append(row[i][j])\n finalboxes.append(lis)\n \n # from every single image-based cell/box the strings are extracted via pytesseract and stored in a list\n outer = []\n for i in range(len(finalboxes)):\n for j in range(len(finalboxes[i])):\n inner = ''\n if (len(finalboxes[i][j]) == 0):\n outer.append(' ')\n else:\n for k in range(len(finalboxes[i][j])):\n y, x, w, h = finalboxes[i][j][k][0], finalboxes[i][j][k][1], finalboxes[i][j][k][2], \\\n finalboxes[i][j][k][3]\n finalimg = bitnot[x:x + h, y:y + w]\n kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (2, 1))\n border = cv2.copyMakeBorder(finalimg, 2, 2, 2, 2, cv2.BORDER_CONSTANT, value=[255, 255])\n resizing = cv2.resize(border, None, fx=2, fy=2, interpolation=cv2.INTER_CUBIC)\n dilation = cv2.dilate(resizing, kernel, iterations=1)\n erosion = cv2.erode(dilation, kernel, iterations=2)\n \n out = pytesseract.image_to_string(erosion)\n if (len(out) == 0):\n out = pytesseract.image_to_string(erosion, config='--psm 3')\n inner = inner + " " + out\n outer.append(inner)\n \n # Creating a dataframe of the generated OCR list\n arr = np.array(outer)\n dataframe = pd.DataFrame(arr.reshape(len(row), countcol))\n print(dataframe)\n data = dataframe.style.set_properties(align="left")\n # Converting it in a excel-file\n data.to_excel("C:/Users/19038/Desktop/Research Things/Test/output.xlsx")\n
\n"},{"tags":["macos","docker","http"],"owner":{"reputation":335,"user_id":6521289,"user_type":"registered","profile_image":"https://www.gravatar.com/avatar/789067089fcc5fa817d0715240593ab0?s=128&d=identicon&r=PG&f=1","display_name":"lak","link":"https://stackoverflow.com/users/6521289/lak"},"is_answered":false,"view_count":16,"answer_count":1,"score":0,"last_activity_date":1623258062,"creation_date":1623101218,"question_id":67878890,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67878890/docker-engine-api-url-in-mac","title":"Docker Engine API URL in mac","body":"I'm trying to make HTTP requests to Docker Engine API but I'm getting a NotFound error
\nconst response = await axios({\n method: 'POST',\n url: "http://unix:///var/run/docker.sock:/v1.39/images/create?fromImage=my-image&tag=latest",\n headers: {\n 'Content-Type': 'application/json'\n }\n });\n
\nThis is the error I got.
\ncode: 'ENOTFOUND',\nsyscall: 'getaddrinfo',\nhostname: 'unix',\n
\nI have read some articles, apparently I have to edit a file called docker.service, but I'm not able to find it in MAC. Any idea
\n"},{"tags":["sql-server","tsql","sql-server-2016"],"owner":{"reputation":2817,"user_id":4191466,"user_type":"registered","accept_rate":50,"profile_image":"https://www.gravatar.com/avatar/5e8319491a3bf6019ad5ebaf8163be55?s=128&d=identicon&r=PG&f=1","display_name":"fdkgfosfskjdlsjdlkfsf","link":"https://stackoverflow.com/users/4191466/fdkgfosfskjdlsjdlkfsf"},"is_answered":false,"view_count":17,"answer_count":1,"score":0,"last_activity_date":1623258059,"creation_date":1623254844,"last_edit_date":1623255620,"question_id":67907856,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907856/tsql-issues-with-canceling-long-running-alter-table","title":"Tsql: Issues with canceling long-running alter table?","body":"Are there any negative issues with canceling a running alter table
statement that alters a column from nvarchar(100)
to nvarchar(25)
? The table has at least 35M rows.
I'm asking because it's been running for the last 1.5 hours. This is the statement:
\nALTER TABLE HourlyTable\nALTER COLUMN EmpId nvarchar(25);\n
\nWe're using Microsoft SQL Server 2016 (SP2-GDR)
I've created this struct, and a function that initializes all of the fields within that struct and returns a struct pointer. Within this struct I have one single dimensional array of integers, and a two dimensional array of pointers. However, somehow the value inside the cells of the single dimensional array are being stored inside the address of the two dimensional array. I have no idea how, but it's messing me up pretty badly.
\n#include <stdio.h>\n#include <stdlib.h>\n\ntypedef struct LonelyPartyArray\n{\n int **fragments; // the address of fragments[i] is being set as\n int *fragment_sizes; // the value inside fragment_sizes[i]\n} LonelyPartyArray;\n\nLonelyPartyArray *createParty(int num_fragments)\n{\n int i;\n\n // Allocating LonelyPartyArray struct pointer\n LonelyPartyArray *party = malloc(sizeof(LonelyPartyArray));\n\n // I am allocating these separately, is something going on with how my system is\n // allocating space for these arrays?\n\n // Allocating LonelyPartyArray\n party->fragments = malloc(sizeof(int *) * num_fragments);\n\n // Allocating LonelyPartyArray fragment size\n party->fragment_sizes = malloc(sizeof(int) * num_fragments);\n\n // Initializing party->fragments to NULL (not used) and fragment_sizes to zero\n for (i = 0; i < num_fragments; i++)\n party->fragments[i] = NULL;\n\n for (i = 0; i < num_fragments; i++)\n party->fragment_sizes[i] = 0;\n\n for (i = 0; i < num_fragments; i++)\n {\n if (party->fragments[i] != party->fragment_sizes[i])\n break;\n printf("Why is this happening???? [%d]\\n", i);\n return NULL;\n }\nreturn party;\n}\n\nint main(void)\n{\n LonelyPartyArray *party = createParty(3);\n\n return 0;\n}\n
\nI have no idea how party->fragments[] is being set as the address for party->fragment_sizes[], but I need them to be separate.
\n"},{"tags":["c++","template-meta-programming"],"owner":{"reputation":3901,"user_id":4224575,"user_type":"registered","accept_rate":82,"profile_image":"https://i.stack.imgur.com/Nvq43.gif?s=128&g=1","display_name":"Lorah Attkins","link":"https://stackoverflow.com/users/4224575/lorah-attkins"},"is_answered":true,"view_count":26,"accepted_answer_id":67908206,"answer_count":2,"score":1,"last_activity_date":1623258053,"creation_date":1623254490,"last_edit_date":1623255673,"question_id":67907777,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907777/trait-for-non-qualified-or-pointer-reference-types","title":"Trait for non qualified or pointer/reference types","body":"I'm implementing a check to see if a type is stripped of any qualifications:
\ntemplate <class T>\nstruct is_plain : std::integral_constant<\n bool, \n std::is_same_v<T, std::decay_t<T>> // *\n>;\n
\nIs the logic in std::is_same_v<T, std::decay_t<T>>
, i.e. check if a type is stripped of anything that decay
would remove,available as a standard trait?
If not, is my implementation missing something? I just want to make sure (in a static assertion) that one does not pass pointers or references to some class.
\nAs pointed out by @NathanOliver, decay
won't remove pointerness (if that's a word), so decay_t<int*>==int*
. I wasn't aware of that, so an addition to the desciprion would be that I want to remove pointers from the type as well.
I tried making few adjustments but still, it did not work. I've read that adding height to and would work. And why is adding height working.
\n* {\nmargin: 0;\npadding: 0;\n}\n\nbody {\nbackground-color: -webkit-linear-gradient(-45deg, #d93b32, #D932D1, #9232d9);\nbackground-color: -moz-linear-gradient(-45deg, #d93b32, #D932D1, #9232d9);\nfont-family: 'Raleway', sans-serif;\n}\n\nhtml,\nbody {\nheight: 100%;\n}\n
\n"},{"tags":["android","material-design"],"owner":{"reputation":904,"user_id":1060673,"user_type":"registered","accept_rate":42,"profile_image":"https://i.stack.imgur.com/VxuL9.png?s=128&g=1","display_name":"FTLRalph","link":"https://stackoverflow.com/users/1060673/ftlralph"},"is_answered":false,"view_count":11,"answer_count":1,"score":0,"last_activity_date":1623258049,"creation_date":1623253226,"question_id":67907453,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67907453/android-custom-theme-color-not-changing-for-toolbar","title":"Android custom theme, color not changing for Toolbar","body":"Excuse the short question, but this seems relatively simple but can't get the toolbar color to change:
\n\nChanging the textSize or even the parent of the ToolbarTitle
property does cause changes to the text, but I cannot get the color to change no matter what I try.
<style name="Theme.Custom" parent="Theme.MaterialComponents.DayNight.NoActionBar">\n <item name="toolbarStyle">@style/Toolbar</item>\n</style>\n\n<style name="Toolbar" parent="Widget.MaterialComponents.Toolbar">\n <item name="titleTextAppearance">@style/ToolbarTitle</item>\n <item name="android:textColor">#FFFFFF</item>\n</style>\n\n<style name="ToolbarTitle" parent="TextAppearance.MaterialComponents.Button">\n <item name="android:textSize">12sp</item>\n <item name="android:textColor">#FFFFFF</item>\n</style>\n
\n"},{"tags":["angular","checkbox"],"owner":{"reputation":1011,"user_id":8760028,"user_type":"registered","accept_rate":92,"profile_image":"https://www.gravatar.com/avatar/63b1af9245d3c42448c0a0b5efe04ce1?s=128&d=identicon&r=PG&f=1","display_name":"pranami","link":"https://stackoverflow.com/users/8760028/pranami"},"is_answered":false,"view_count":12,"answer_count":0,"score":0,"last_activity_date":1623258042,"creation_date":1623257527,"last_edit_date":1623258042,"question_id":67908545,"content_license":"CC BY-SA 4.0","link":"https://stackoverflow.com/questions/67908545/how-do-i-get-the-checked-and-unchecked-values-of-a-checkbox-in-angular","title":"How do I get the checked and unchecked values of a checkbox in angular","body":"I have a list of checkboxes as shown below:
\n <div class="col-md-4 md-padding" *ngFor="let node of nodeList; let j=index;">\n <md-checkbox-group>\n <md-checkbox\n class="md-h6 row md-padding--xs"\n name="{{node.FQDN}}"\n label="{{node.FQDN}}"\n value="{{node.FQDN}}"\n required="true"\n htmlId="filter_label_{{j}}"\n (click)="updatefilter(node.FQDN)"\n [formControlName]="servers"\n [(ngModel)]="node.selected">\n </md-checkbox>\n\n\n </md-checkbox-group>\n\n\n </div>\n
\nI have to check if the checbox is checked or unchecked. How do I proceed?
\n"}],"has_more":true,"backoff":10,"quota_max":300,"quota_remaining":273} \ No newline at end of file diff --git a/schema.xlsx b/schema.xlsx new file mode 100644 index 0000000..c0383b4 Binary files /dev/null and b/schema.xlsx differ