qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,315,292 | <p>I'm working on a fairly complex Access Database, trying to build forms with custom buttons for working with records. I'm using list boxes to display and navigate through records and all fields for existing records are disabled unless the user presses an edit button. The problem I'm having is that if I press the Edit or Add New button, enabling all of the fields, and then try to change the selection in a combo box, it does not update on the first try.</p>
<p>If I edit a text box first then the combo boxes work fine.
I've determined that the control's beforeUpdate and afterUpdate events are not firing on the first try but the action triggers the form_Dirty event and then it works as expected. I tried setting Me.Dirty = True with the Edit button and that solved the problem but it causes problems with some of my other code and it seems like an unnecessary workaround if only I understood the actual cause of the problem. It also works as expected if I leave the Combo Box unbound, but I am trying to build a template that doesn't require too much work to build new forms off of and I would rather not go that route.</p>
<p>It must have something to do with some bit of code I'm using because I can start a basic form and the combo boxes work fine.
I've started a basic test form and am adding code from my template form bit by bit until the problem arises, but it's a tedious process. Any help would be appreciated.</p>
<p>What am I missing? Is there some way of getting the Combo Box events to fire before the form is dirty?</p>
<p>UPDATE:
I have templates for a basic form, a form with a single subform, and a form with multiple subs in a tab control.</p>
<p>After some more testing I discovered that this problem does not apply to the basic form which has no subforms. This template uses similar code to the others for new, edit, cancel, save and delete buttons and for preventing accidental changes, preventing Form_unload during an edit and so on. The main difference I can think of off the top of my head is that the templates with subforms use class modules and collections to hold various data and pass it between the main form and subforms. Not sure if or how this might relate to combo box functionality.</p>
<p>I built most of this last winter then got too busy over the summer to work on it. Just now picking it up again and I'm having to re-learn a lot of the details of how my code works.</p>
| [
{
"answer_id": 74315620,
"author": "Tural Rzaxanov",
"author_id": 9922647,
"author_profile": "https://Stackoverflow.com/users/9922647",
"pm_score": -1,
"selected": false,
"text": "1';DROP table accounts where id!='123454321344321\n"
},
{
"answer_id": 74315621,
"author": "Ken Lee",
"author_id": 11854986,
"author_profile": "https://Stackoverflow.com/users/11854986",
"pm_score": 3,
"selected": true,
"text": "$query = mysqli_query($conn, \"select name from accounts where name = '{$name}'\");\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20415536/"
] |
74,315,298 | <p>I am trying to convert a large ~ 100mb csv file to xlsx using python.
I tried the solution below, but ran into memory issues</p>
<p><a href="https://stackoverflow.com/a/62750402/1266723">https://stackoverflow.com/a/62750402/1266723</a></p>
<p>Solution below solves the memory issue by writing in chunks, but over-writes the files. Can someone please recommend how to append to the same file instead of creating new files or overwriting the same file?</p>
<p><a href="https://stackoverflow.com/a/71237366/1266723">https://stackoverflow.com/a/71237366/1266723</a></p>
<pre><code>import pandas as pd
n = 1000 # number of rows per chunk
df = pd.read_csv("myFile.csv")
for i in range(0, df.shape[0], n):
df[i:i+n].to_excel(f"new_file.xlsx", index=False, header=False)
</code></pre>
| [
{
"answer_id": 74315390,
"author": "tturbo",
"author_id": 12284585,
"author_profile": "https://Stackoverflow.com/users/12284585",
"pm_score": 0,
"selected": false,
"text": "# ExcelWriter can also be used to append to an existing Excel file:\n\nwith pd.ExcelWriter('output.xlsx',\n mode='a') as writer: \n df.to_excel(writer, sheet_name='Sheet_name_3')\n"
},
{
"answer_id": 74315485,
"author": "rftr",
"author_id": 14533535,
"author_profile": "https://Stackoverflow.com/users/14533535",
"pm_score": 0,
"selected": false,
"text": "startrow"
},
{
"answer_id": 74316367,
"author": "Serge Ballesta",
"author_id": 3545273,
"author_profile": "https://Stackoverflow.com/users/3545273",
"pm_score": 1,
"selected": false,
"text": "n = 1000 # chunksize\nwith pd.read_csv(\"myFile.csv\", chunksize=n) as reader, \\\n pd.ExcelWriter('new_file.xlsx') as writer:\n for i, df in enumerate(reader):\n df.to_excel(writer, index=False, header=False, startrow=i * n)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1266723/"
] |
74,315,341 | <p>My goal is to extract salary from a string and if this salary comes from collective agreement. I have come up with a following regex:</p>
<pre><code>pattern = "([Kk]ollektivvertragliche[sn]|Kollektivvertrag|[Cc]ollective [Aa]greement|[Kk]ollektivvertr|KV) .* ([0-9]{1,4}[.,][0-9]{2,3}[,]*[0-9]*) .* ([0-9]{1,4}[.,][0-9]{2,3}[,]*[0-9]*)"
</code></pre>
<ul>
<li><code>([Kk]ollektivvertragliche[sn]|Kollektivvertrag|[Cc]ollective [Aa]greement|[Kk]ollektivvertr|KV)</code> - first group, that captures if salary is defined according to collective agreement.</li>
<li><code>([0-9]{1,4}[.,][0-9]{2,3}[,]*[0-9]*)</code> - is a salary of the form xx.yyy,zz/xx.yyy,zz/x.yyy/xxx (for example 21.950,13/1.859,20/1.700/700 $)</li>
<li><code>.+</code> between collective agreement and salary matches any character.</li>
</ul>
<p>I have tested and it looks like it works well if all groups are available:</p>
<pre><code>t = 'Entlohnung nach Caritas Kollektivvertrag : __ [lineBreak] Mindestgehalt in Gehaltsstufe 1 - Verwendungsgruppe VI , dzt. EUR 1.849,90 bis 1.900,32 '
r = re.search(pattern,t)
r.groups()
</code></pre>
<p>But if some of the groups(for example collective agreement or salary) is missed, it doesn't work.</p>
<pre><code>string examples:
#t = 'EUR 35.362,00 Jahresbrutto'
#t = '2.800 brutto/Monat'
#t = 'laut Kollektivvertrag beträgt € 1.597,72 brutto pro Monat auf Basis Vollzeitbeschäftigung.'
#t = 'KV-Mindestgehalt von monatlich € 1.671,00'
#t = 'kollektivvertragliches Mindestgehalt von € 2.026,88 brutto pro Monat'
#t = 'Bruttojahreseinkommen ab € 50.000,'
#t = 'ein KV-Mindestlohn von EUR 1.277,00 brutto pro Monat'
#t = 'beträgt jedoch mindestens € 25.480'
#t = 'Gehalt lt. BAGS-KV €\xa02.100,78 brutto'
#t = 'kollektivvertraglicher Mindestgehalt EUR 33.000 Brutto/Jahr'
#t = '\nLohn/Gehalt ab EUR 2500,00 brutto monatlich,'
#t = 'KV IT __EUR 2.302'
#t = '25 Wochenstunden EUR [lineBreak] 1.641,91 bis EUR 1.859,21 brutto'
#t = 'Entlohnung nach Caritas Kollektivvertrag: __ [lineBreak] Mindestgehalt in Gehaltsstufe 1 - Verwendungsgruppe VI , dzt. EUR 1.849,90'
#t = 'The position is remunerated according to the Kollektivvertrag for Austrian Universities, i.e., the salary amounts to at least 38.230EUR/year before taxes'
#t = 'Erfahrung bieten wir ein Bruttojahresgehalt ab EUR 36.400.'
</code></pre>
<p>I have tried to impleemnt optional groups with a help of <code>?</code> and <code>?:</code> (like in this post <a href="https://stackoverflow.com/questions/15474741/python-regex-optional-capture-group">python regex optional capture group</a>), but it didn't work either.</p>
<p><strong>Desired output:</strong> (group_1_result,group_2_result,group_3_result).</p>
<p>If some of the group is missed: instead of "group_n_result" I would like to have <code>None</code></p>
| [
{
"answer_id": 74316364,
"author": "Swifty",
"author_id": 20267366,
"author_profile": "https://Stackoverflow.com/users/20267366",
"pm_score": 1,
"selected": false,
"text": "import re\n\npattern1 = re.compile(\"([Kk]ollektivvertragliche[snr]|Kollektivvertrag|[Cc]ollective [Aa]greement|[Kk]ollektivvertr|KV)\")\npattern2 = re.compile(\"([0-9]{1,4}.[0-9]{2,3}[,[0-9]+]*)\")\n\n\nt = ''''Entlohnung nach Caritas Kollektivvertrag : __ [lineBreak] Mindestgehalt in Gehaltsstufe 1 - Verwendungsgruppe VI , dzt. EUR 1.849,90 bis 1.900,32 '\n#t = 'EUR 35.362,00 Jahresbrutto'\n#t = '2.800 brutto/Monat'\n#t = 'laut Kollektivvertrag beträgt € 1.597,72 brutto pro Monat auf Basis Vollzeitbeschäftigung.'\n#t = 'KV-Mindestgehalt von monatlich € 1.671,00'\n#t = 'kollektivvertragliches Mindestgehalt von € 2.026,88 brutto pro Monat'\n#t = 'Bruttojahreseinkommen ab € 50.000,'\n#t = 'ein KV-Mindestlohn von EUR 1.277,00 brutto pro Monat'\n#t = 'beträgt jedoch mindestens € 25.480'\n#t = 'Gehalt lt. BAGS-KV €\\xa02.100,78 brutto'\n#t = 'kollektivvertraglicher Mindestgehalt EUR 33.000 Brutto/Jahr'\n#t = '\\nLohn/Gehalt ab EUR 2500,00 brutto monatlich,'\n#t = 'KV IT __EUR 2.302'\n#t = '25 Wochenstunden EUR [lineBreak] 1.641,91 bis EUR 1.859,21 brutto'\n#t = 'Entlohnung nach Caritas Kollektivvertrag: __ [lineBreak] Mindestgehalt in Gehaltsstufe 1 - Verwendungsgruppe VI , dzt. EUR 1.849,90'\n#t = 'The position is remunerated according to the Kollektivvertrag for Austrian Universities, i.e., the salary amounts to at least 38.230EUR/year before taxes'\n#t = 'Erfahrung bieten wir ein Bruttojahresgehalt ab EUR 36.400.'\n'''\nfor line in t.splitlines():\n found = []\n r = re.search(pattern1,line)\n found.append(r[0] if r else r)\n \n for match in pattern2.finditer(line):\n found.append(match[0])\n\n print(found)\n\n# ['Kollektivvertrag', '1.849,90', '1.900,32']\n# [None, '35.362,00']\n# [None, '2.800']\n# ['Kollektivvertrag', '1.597,72']\n# ['KV', '1.671,00']\n# ['kollektivvertragliches', '2.026,88']\n# [None, '50.000,']\n# ['KV', '1.277,00']\n# [None, '25.480']\n# ['KV', '2.100,78']\n# ['kollektivvertraglicher', '33.000']\n# [None] (this one comes from \\n ; such empty lines can be filtered out)\n# [None, '2500,00']\n# ['KV', '2.302']\n# [None, '1.641,91', '1.859,21']\n# ['Kollektivvertrag', '1.849,90']\n# ['Kollektivvertrag', '38.230']\n# [None, '36.400']\n"
},
{
"answer_id": 74316827,
"author": "The fourth bird",
"author_id": 5424988,
"author_profile": "https://Stackoverflow.com/users/5424988",
"pm_score": 3,
"selected": true,
"text": "#t = '"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5094589/"
] |
74,315,382 | <p>can you do this in C++:</p>
<pre><code>vector<int> v1={1,2}, v2={3,4};
vector<int> v3={...v1, ...v2, 5};
//v3 = {1,2,3,4,5}
</code></pre>
<p>What is the simplest way to do this with C++ ?</p>
| [
{
"answer_id": 74315527,
"author": "Caleth",
"author_id": 2610810,
"author_profile": "https://Stackoverflow.com/users/2610810",
"pm_score": 3,
"selected": true,
"text": "insert"
},
{
"answer_id": 74315576,
"author": "Pepijn Kramer",
"author_id": 16649550,
"author_profile": "https://Stackoverflow.com/users/16649550",
"pm_score": 3,
"selected": false,
"text": "#include <iostream>\n#include <vector>\n\nnamespace details\n{\n template<typename type_t, typename arg_t, typename... args_t>\n auto make_spread_impl(std::vector<type_t>& values, const arg_t& arg, const args_t&... args)\n {\n // check if template argument is a value or a std::vector of values.\n if constexpr (std::is_same_v<arg_t, type_t>)\n {\n // single value\n values.push_back(arg);\n }\n else\n {\n // vector of values\n static_assert(std::is_same_v<std::vector<type_t>, arg_t>);\n\n // append values to end\n values.insert(values.end(), arg.begin(), arg.end());\n }\n\n // continue recursion\n if constexpr (sizeof...(args_t) > 0)\n {\n return make_spread_impl(values, args...);\n }\n\n // recursion end condition\n return values;\n }\n}\n\ntemplate<typename type_t, typename... args_t>\nauto make_spread(const args_t&... args)\n{\n\n // one argument return a vector of values.\n if constexpr (sizeof...(args) == 1ul)\n {\n return std::vector<type_t>{args...};\n }\n \n // otherwise recurse\n std::vector<type_t> values;\n details::make_spread_impl(values, args...);\n return values;\n}\n\n\n\nint main()\n{\n std::vector<int> v1{ 1,2,3 };\n std::vector<int> v2{ 5,6,7 };\n\n auto result = make_spread<int>(v1, 4, v2, 8);\n\n for (const auto& value : result)\n {\n std::cout << value << \" \";\n }\n\n\n return 0;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3046585/"
] |
74,315,420 | <p>I have a website with 100 posts of a custom post type. On the single pages of each post, I would like to have a “Previous” and “Next” link to quickly jump to, you guessed it, the previous or next post.</p>
<p>I thought that was going to be easy, and I made these links:</p>
<pre><code><?php $prev_post = get_previous_post();
if ($prev_post) {
echo '<a rel="prev" href="' . get_permalink($prev_post->ID) . '">Previous</a>';
} ?>
<?php $next_post = get_next_post();
if ($next_post) {
echo '<a rel="next" href="' . get_permalink($next_post->ID) . '">Next</a>';
} ?>
</code></pre>
<p>Except those does not work. Instead of a hundred posts I can navigate through, it only allows me to jump through 5 posts. And random ones too: it goes from #1 to #15, then #40, #58, #80. Or if I decide to start from #100 and click previous, it goes to #79, then #40, #39 and #1.</p>
<p>It’s all very random. I have no clue what order this is and why it does not have all the posts.</p>
<p>Ideally I would like to go through the posts in alphabetical order of their slug. Ignoring taxonomy.</p>
<p>Anyone know how to do this? Thanks!</p>
| [
{
"answer_id": 74315628,
"author": "zillionera_dev",
"author_id": 15306153,
"author_profile": "https://Stackoverflow.com/users/15306153",
"pm_score": 0,
"selected": false,
"text": "if( get_adjacent_post(false, '', false) ) { \n next_post_link('%link', '← Previous project');\n} else { \n $last = new WP_Query('post_type=project&posts_per_page=1&order=DESC'); $last->the_post();\n echo '<a href=\"' . get_permalink() . '\">← Previous project</a>';\n wp_reset_query();\n}; \n\n\nif( get_adjacent_post(false, '', true) ) { \n previous_post_link('%link', 'Next project →');\n} else { \n $first = new WP_Query('post_type=project&posts_per_page=1&order=ASC'); $first->the_post();\n echo '<a href=\"' . get_permalink() . '\">Next project →</a>';\n wp_reset_query();\n}; \n"
},
{
"answer_id": 74315630,
"author": "nicolas",
"author_id": 9636020,
"author_profile": "https://Stackoverflow.com/users/9636020",
"pm_score": 1,
"selected": false,
"text": "<?php\n$criteria = array( \n 'post_type' => 'data_type',\n 'orderby' => 'slug',\n 'order' => 'ASC',\n 'posts_per_page' => -1\n); \n$posts = get_posts($criteria);\n$ids = array();\nforeach ($posts as $thepost) {\n $ids[] = $thepost->ID;\n}\n$index = array_search($post->ID, $ids);\n$previd = $ids[$index - 1];\n$nextid = $ids[$index + 1];\nif ($previd) { ?>\n <a rel=\"prev\" href=\"<?php echo get_permalink($previd) ?>\">Previous</a>\n<?php }\nif ($nextid) { ?>\n <a rel=\"next\" href=\"<?php echo get_permalink($nextid) ?>\">Next</a>\n<?php } ?>\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9636020/"
] |
74,315,425 | <p>I have this case:</p>
<pre><code>a = "I run away without you"
if "with" in a:
print("s")
else:
print("n")
</code></pre>
<p>This expression is True. But, I want to print "n", because <code>a</code> has to have exactly "with" and not a substring.
How can I do this?</p>
| [
{
"answer_id": 74315482,
"author": "Coko",
"author_id": 9955893,
"author_profile": "https://Stackoverflow.com/users/9955893",
"pm_score": -1,
"selected": false,
"text": "=="
},
{
"answer_id": 74315508,
"author": "Zxd2009",
"author_id": 19109884,
"author_profile": "https://Stackoverflow.com/users/19109884",
"pm_score": 3,
"selected": true,
"text": "\"with\" - True\n\"without\" - False\n\"with xxx\" - True\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19947948/"
] |
74,315,428 | <p>I want to create a WordPress Plugin where I want to add some css, and upon activation, those css will be in effect and be viewing in the website. Upon deactivation, the css will also be out of effect.</p>
<p>Any how I can do that? Or any documentation I can take help from?</p>
| [
{
"answer_id": 74315482,
"author": "Coko",
"author_id": 9955893,
"author_profile": "https://Stackoverflow.com/users/9955893",
"pm_score": -1,
"selected": false,
"text": "=="
},
{
"answer_id": 74315508,
"author": "Zxd2009",
"author_id": 19109884,
"author_profile": "https://Stackoverflow.com/users/19109884",
"pm_score": 3,
"selected": true,
"text": "\"with\" - True\n\"without\" - False\n\"with xxx\" - True\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14427209/"
] |
74,315,453 | <p>I have the following dataframe containing scores for a competition as well as a column that counts what number entry for each person.</p>
<pre><code>import pandas as pd
df = pd.DataFrame({'Name': ['John', 'Jim', 'John','Jim', 'John','Jim','John','Jim','John','Jim','Jack','Jack','Jack','Jack'],'Score': [10,8,9,3,5,0, 1, 2,3, 4,5,6,8,9]})
df['Entry_No'] = df.groupby(['Name']).cumcount() + 1
df
</code></pre>
<p><a href="https://i.stack.imgur.com/JNAAB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JNAAB.png" alt="enter image description here" /></a></p>
<p>Then I have another table that stores data on the maximum number of entries that each person can have:</p>
<pre><code>df2 = pd.DataFrame({'Name': ['John', 'Jim', 'Jack'],'Limit': [2,3,1]})
df2
</code></pre>
<p><a href="https://i.stack.imgur.com/Mer5j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mer5j.png" alt="enter image description here" /></a></p>
<p>I am trying to drop rows from <code>df</code> where the entry number is greater than the <code>Limit</code> according to each person in <code>df2</code> so that my expected output is this:</p>
<p><a href="https://i.stack.imgur.com/jdJ7W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jdJ7W.png" alt="enter image description here" /></a></p>
<p>If there are any ideas on how to help me achieve this that would be fantastic! Thanks</p>
| [
{
"answer_id": 74315741,
"author": "rftr",
"author_id": 14533535,
"author_profile": "https://Stackoverflow.com/users/14533535",
"pm_score": 2,
"selected": true,
"text": "pandas.merge"
},
{
"answer_id": 74315758,
"author": "Mat.B",
"author_id": 14649447,
"author_profile": "https://Stackoverflow.com/users/14649447",
"pm_score": 0,
"selected": false,
"text": "join"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13194245/"
] |
74,315,474 | <p>I can't find how to change the cursor colour of an entry field on MAUI for Android.
I'm writing an app supporting dark theme and I don't want the entry box to have a light background. Unfortunately, the default cursor colour is dark purple, which has insufficient contrast and makes it very hard to see.
I'd be happy if it were the same colour as the text or if I could set it independently.
Any suggestions?</p>
| [
{
"answer_id": 74315741,
"author": "rftr",
"author_id": 14533535,
"author_profile": "https://Stackoverflow.com/users/14533535",
"pm_score": 2,
"selected": true,
"text": "pandas.merge"
},
{
"answer_id": 74315758,
"author": "Mat.B",
"author_id": 14649447,
"author_profile": "https://Stackoverflow.com/users/14649447",
"pm_score": 0,
"selected": false,
"text": "join"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5256279/"
] |
74,315,480 | <p>I want to write a function that returns the number of duplicate items in an array.</p>
<p>For example:</p>
<pre><code>arr = [2,4,6,3,2,2,4,6]
# this should return 3 since (2,4,6) are repeated in the list
</code></pre>
| [
{
"answer_id": 74315741,
"author": "rftr",
"author_id": 14533535,
"author_profile": "https://Stackoverflow.com/users/14533535",
"pm_score": 2,
"selected": true,
"text": "pandas.merge"
},
{
"answer_id": 74315758,
"author": "Mat.B",
"author_id": 14649447,
"author_profile": "https://Stackoverflow.com/users/14649447",
"pm_score": 0,
"selected": false,
"text": "join"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17321786/"
] |
74,315,490 | <p>I have the following code that tries to cover most cases of a dictionary walk, and output it as indented text (indent based on the items' nesting in the dictionary. There are two problems:</p>
<ol>
<li>I think the check at the start, which caters for "raw_list", is a bit of a hack, but I cannot think of a better way</li>
<li>I cannot get the level variable to properly reflect its position</li>
</ol>
<p>Thanks. I think the rest of the recursion is correct...</p>
<pre><code>a = {
"raw_list" : [1,2,3],
"a" : 1,
"b" : 2,
"mydict": {
"c":3,
"d":4
},
"mydict2": {
"c":5,
"d":6
},
"list1": [
{
"e1":7,
"e2":8
},
{
"e3":9,
"e4":10
}
],
"list2": [
{
"f1":11,
"f2":12
}
]
}
def process_data(data,level):
if not isinstance(data,list) and not isinstance(data,dict) :
print("\t"*level + str(data))
return
for element, val in data.items():
if isinstance(val, dict):
print("\t"*level + "DICT:" + element)
level+=1
process_data(val,level)
elif isinstance(val, list):
print("\t"*level + "LIST:" + element)
level += 1
for i, item in enumerate(val):
process_data(item,level)
else:
print("\t"*level+element + ":" + str(val))
level-=1
process_data(a,1)
</code></pre>
<p>Got this:</p>
<pre><code>LIST:test
1
2
3
a:1
b:2
DICT:mydict
c:3
d:4
DICT:mydict2
c:5
d:6
LIST:list1
e1:7
e2:8
e3:9
e4:10
LIST:list2
f1:11
f2:12
</code></pre>
<p>But want this:</p>
<pre><code>LIST:test
1
2
3
a:1
b:2
DICT:mydict
c:3
d:4
DICT:mydict2
c:5
d:6
LIST:list1
e1:7
e2:8
e3:9
e4:10
LIST:list2
f1:11
f2:12
</code></pre>
| [
{
"answer_id": 74315588,
"author": "Yevhen Kuzmovych",
"author_id": 4727702,
"author_profile": "https://Stackoverflow.com/users/4727702",
"pm_score": 2,
"selected": true,
"text": "level"
},
{
"answer_id": 74315844,
"author": "Krunal Jethva",
"author_id": 11836885,
"author_profile": "https://Stackoverflow.com/users/11836885",
"pm_score": 0,
"selected": false,
"text": "def process_data(data,level):\n if not isinstance(data,list) and not isinstance(data,dict) :\n print(\"\\t\"*level + str(data))\n return\n\n for element, val in data.items():\n if isinstance(val, dict):\n print(\"\\t\"*level + \"DICT:\" + element)\n process_data(val,level + 1)\n elif isinstance(val, list):\n print(\"\\t\"*level + \"LIST:\" + element)\n for i, item in enumerate(val):\n process_data(item,level + 1)\n else:\n print(\"\\t\"*level+element + \":\" + str(val))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12683974/"
] |
74,315,494 | <p>Using pyspark. I would have a data frame like this</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">col1</th>
<th style="text-align: center;">col2</th>
<th style="text-align: center;">col3</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">1</td>
<td style="text-align: center;">[3,7]</td>
<td style="text-align: center;">5</td>
</tr>
<tr>
<td style="text-align: center;">hello</td>
<td style="text-align: center;">4</td>
<td style="text-align: center;">666</td>
</tr>
<tr>
<td style="text-align: center;">4</td>
<td style="text-align: center;">world</td>
<td style="text-align: center;">4</td>
</tr>
</tbody>
</table>
</div>
<p>Now I want to get the column name where the number 666 is included.</p>
<p>So the result should be "col3".</p>
<p>Thanks</p>
<p><strong>Edits</strong></p>
<p>Added other values than int. The great answers are focussed on only int values. Sry.</p>
<p>deleted: while we are at it, I guess the index can also be retrieved easily.</p>
| [
{
"answer_id": 74315588,
"author": "Yevhen Kuzmovych",
"author_id": 4727702,
"author_profile": "https://Stackoverflow.com/users/4727702",
"pm_score": 2,
"selected": true,
"text": "level"
},
{
"answer_id": 74315844,
"author": "Krunal Jethva",
"author_id": 11836885,
"author_profile": "https://Stackoverflow.com/users/11836885",
"pm_score": 0,
"selected": false,
"text": "def process_data(data,level):\n if not isinstance(data,list) and not isinstance(data,dict) :\n print(\"\\t\"*level + str(data))\n return\n\n for element, val in data.items():\n if isinstance(val, dict):\n print(\"\\t\"*level + \"DICT:\" + element)\n process_data(val,level + 1)\n elif isinstance(val, list):\n print(\"\\t\"*level + \"LIST:\" + element)\n for i, item in enumerate(val):\n process_data(item,level + 1)\n else:\n print(\"\\t\"*level+element + \":\" + str(val))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6510273/"
] |
74,315,515 | <p>Here's the problem with iterating over the components as array elements, I guess. I tried many iteration methods for loop, .forEach() and .map(). The some result was came only from the first one. It was rendered only one component from the array, when famous methods .forEach() and .map() wasn't rendered nothing at all.</p>
<p>I logged to the console the value of iterator variable from the above for loop and it wasn't incremented at all, it was 0, when the max count is 10.</p>
<p>Here's the code:</p>
<pre><code>const renderState = () => {
if (loading) {
// When the users objects are loading from the server:
return <p>Loading...</p>;
} else if (hasErrors) {
// When some loading-error occured:
return <p>Can not load the page.</p>;
} else {
// And when loading was successfully finished, rendering all of them:
for (let i = 0; i < users.length; i++) {
return <ProfileCard key={users[i].id} user={users[i]} />
}
}
};
</code></pre>
| [
{
"answer_id": 74315588,
"author": "Yevhen Kuzmovych",
"author_id": 4727702,
"author_profile": "https://Stackoverflow.com/users/4727702",
"pm_score": 2,
"selected": true,
"text": "level"
},
{
"answer_id": 74315844,
"author": "Krunal Jethva",
"author_id": 11836885,
"author_profile": "https://Stackoverflow.com/users/11836885",
"pm_score": 0,
"selected": false,
"text": "def process_data(data,level):\n if not isinstance(data,list) and not isinstance(data,dict) :\n print(\"\\t\"*level + str(data))\n return\n\n for element, val in data.items():\n if isinstance(val, dict):\n print(\"\\t\"*level + \"DICT:\" + element)\n process_data(val,level + 1)\n elif isinstance(val, list):\n print(\"\\t\"*level + \"LIST:\" + element)\n for i, item in enumerate(val):\n process_data(item,level + 1)\n else:\n print(\"\\t\"*level+element + \":\" + str(val))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13416525/"
] |
74,315,520 | <p>I tried to build a dataframe from api request response, but I'm getting this error.</p>
<pre><code>url= 'https://www.reddit.com/r/Wallstreetbets/top.json?limit=10&t=year'
r= requests.get(url)
json= r.json()
message_df = pd.DataFrame(json['message'])
error_df = pd.DataFrame(json['error'])
message_df.head()
ValueError: DataFrame constructor not properly called!
</code></pre>
| [
{
"answer_id": 74315652,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "User-Agent"
},
{
"answer_id": 74315924,
"author": "Lindokuhle Moloi",
"author_id": 20416357,
"author_profile": "https://Stackoverflow.com/users/20416357",
"pm_score": 0,
"selected": false,
"text": "url='https://www.reddit.com/r/Wallstreetbets/top.json?limit=10&t=year'\n\nr= requests.get(url)\n\njson= r.json()\n\ndf = pd.DataFrame.from_dict(json, orient='index')\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18066567/"
] |
74,315,533 | <p>I have a use case where I want my script that runs multiple functions parallelly using multiprocessing to exit with non zero code and that should stop running the script immediately on seeing the return code 1 or errors from any of the functions.</p>
<p>Here is what I am trying to do, not sure if my approach is correct and what should I do further.</p>
<pre><code>def a(a1):
if a1==a2:
print("success")
return 0
else:
print("failure")
return 1 #or sys.exit(1) - not sure which 1 should I use here
def b(b1):
if b1==b2:
print("success")
return 0
else:
print("failure")
return 1 #or sys.exit(1) - not sure which 1 should I use here
def runall():
if __name__ =='__main__':
t1= multiprocess.Process(target=a, args=a1)
t1= multiprocess.Process(target=b, args=b1)
t1.start()
t1.join()
</code></pre>
| [
{
"answer_id": 74315571,
"author": "Will",
"author_id": 12829151,
"author_profile": "https://Stackoverflow.com/users/12829151",
"pm_score": 2,
"selected": true,
"text": "sys.exit()"
},
{
"answer_id": 74321105,
"author": "Booboo",
"author_id": 2823719,
"author_profile": "https://Stackoverflow.com/users/2823719",
"pm_score": 0,
"selected": false,
"text": "multiprocessing.Process"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12252991/"
] |
74,315,545 | <p>I have attempted to try in Python the same thing I achieve in a GIS Software.</p>
<p>I have 51 centroids to compare to 90,000+ parcels and find the overlap.</p>
<p>It seems that my script is working (which I am happy to have been able and write) but I was curious if there is a way to speed this up? it takes around 5mins. I appreciate any help I can get as the final scope would be to process way more centroids and way more parcels so I am concerned by the time it would take.</p>
<p>I added the code below as well as a few lines of how the csv and json files look.</p>
<pre><code>import json, csv, time
from shapely.geometry import Point, Polygon
start = time.time()
with open('M035TaxPar_CY20_FY20.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
for row in csv_reader:
if line_count == 0:
#print(f'Column names are {", ".join(row)}')
line_count += 1
else:
my_coord = tuple([float(row[10]), float(row[11])])
my_coord = Point(my_coord)
line_count += 1
with open('boston_parcels_all.json', 'r') as f:
array = json.load(f)
dict_size = len(array.get("features"))
for i in range(0, dict_size -1):
sub_dict = array.get("features")[i]
geometry_dict = sub_dict.get("geometry")
current_Pol = geometry_dict.get("coordinates")
attribute_data = sub_dict.get("properties")
parcel_id = attribute_data.get("MAP_PAR_ID")
try:
final_Pol = Polygon(current_Pol[0])
except AttributeError:
continue
except ValueError:
continue
if not my_coord.within(final_Pol):
continue
else:
if parcel_id == None:
continue
else:
print(f"My pol: {parcel_id}, my point: {row[0]}")
print(f'Processed {line_count} lines.')
end = time.time()
total_time = end - start
print("\n"+ str(total_time))```
CSV file:
MAP_PAR_ID,LOC_ID,POLY_TYPE,MAP_NO,SOURCE,PLAN_ID,LAST_EDIT,BND_CHK,NO_MATCH,TOWN_ID,X_coord,Y_coord
0301290001,F_772282_2959076,FEE,3,ASSESS,,20191107,,N,35,-71.07030535235137,42.36703589444949
0301286000,F_772818_2959719,FEE,3,ASSESS,,20191107,,N,35,-71.0682938996932,42.36876187375208
JSON file:
{
"type" : "FeatureCollection",
"name" : "M035TaxPar_CY20_FY20",
"features" : [
{
"type" : "Feature",
"geometry" : {
"type" : "Polygon",
"coordinates" : [
[
[ -71.074767681, 42.3489358757 ],
[ -71.0745071763, 42.3490067112 ],
[ -71.074852421, 42.3497214512 ],
[ -71.0757149372, 42.3494869825 ],
[ -71.0753495281, 42.3487373608 ],
[ -71.074767681, 42.3489358757 ]
]
]
},
"properties" : {
"SHAPE_Leng" : 324.191190544,
"SHAPE_Area" : 6483.24124923,
"MAP_PAR_ID" : "0401134000",
"LOC_ID" : "F_771022_2952578",
"POLY_TYPE" : "FEE",
"MAP_NO" : "4",
"SOURCE" : "ASSESS",
"LAST_EDIT" : 20191107,
"NO_MATCH" : "N",
"TOWN_ID" : 35
}
},
{
"type" : "Feature",
"geometry" : {
"type" : "Polygon",
"coordinates" : [
[
[ -71.0554563931, 42.3547109221 ],
[ -71.0550339868, 42.3548837812 ],
[ -71.0557334699, 42.3555313301 ],
[ -71.0564003565, 42.3554356917 ],
[ -71.0562325294, 42.3545663782 ],
[ -71.0554563931, 42.3547109221 ]
]
]
},
"properties" : {
"SHAPE_Leng" : 351.344209198,
"SHAPE_Area" : 7627.60108948,
"MAP_PAR_ID" : "0304410000",
"LOC_ID" : "F_776224_2954721",
"POLY_TYPE" : "FEE",
"MAP_NO" : "3",
"SOURCE" : "ASSESS",
"LAST_EDIT" : 20191107,
"NO_MATCH" : "N",
"TOWN_ID" : 35
}
}
]
}
</code></pre>
| [
{
"answer_id": 74315571,
"author": "Will",
"author_id": 12829151,
"author_profile": "https://Stackoverflow.com/users/12829151",
"pm_score": 2,
"selected": true,
"text": "sys.exit()"
},
{
"answer_id": 74321105,
"author": "Booboo",
"author_id": 2823719,
"author_profile": "https://Stackoverflow.com/users/2823719",
"pm_score": 0,
"selected": false,
"text": "multiprocessing.Process"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2377480/"
] |
74,315,548 | <p>The container has an image as a child. I need a line on top of that (diagonally from top right to bottom left).</p>
| [
{
"answer_id": 74315611,
"author": "MrShakila",
"author_id": 19292778,
"author_profile": "https://Stackoverflow.com/users/19292778",
"pm_score": 1,
"selected": false,
"text": "class CustomClipPath extends CustomClipper<Path> {\n var radius=10.0;\n @override\n Path getClip(Size size) {\n Path path = Path();\n path.lineTo(0, 200);\n path.lineTo(200,200);\n path.lineTo(260,0);\n path.lineTo(30, 0);\n return path;\n }\n @override\n bool shouldReclip(CustomClipper<Path> oldClipper) => false;\n}\n"
},
{
"answer_id": 74315703,
"author": "targiasld",
"author_id": 5812524,
"author_profile": "https://Stackoverflow.com/users/5812524",
"pm_score": 3,
"selected": true,
"text": "import 'package:flutter/material.dart';\n\n\nvoid main() {\n runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n home: Scaffold(\n body: Container(\n color: Colors.white,\n padding: EdgeInsets.symmetric(horizontal: 40, vertical: 80),\n child: Container(\n width: 300,\n height: 400,\n color: Colors.yellow,\n child: CustomPaint(painter: LinePainter()),\n ),\n ),\n ),\n );\n }\n}\n\nclass LinePainter extends CustomPainter {\n @override\n void paint(Canvas canvas, Size size) {\n\n final p1 = Offset(size.width, 0);\n final p2 = Offset(0, size.height);\n final paint = Paint()\n ..color = Colors.black\n ..strokeWidth = 4;\n canvas.drawLine(p1, p2, paint);\n }\n\n @override\n bool shouldRepaint(LinePainter oldDelegate) => false;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6204714/"
] |
74,315,557 | <pre><code>SELECT
REPORTDATE,ARCHIVEDATE, RATE,GRID48_DR,
REGEXP_REPLACE(SUBSTR(GRID48_DR, 1, MNTHS_BTWN - 1),
'\[\*a-zA-Z0-9\]', 'X') ||RATE||
SUBSTR(GRID48_DR, 1, LENGTH(GRID48_DR) - (MNTHS_BTWN)) GRID48_NEW
FROM
(SELECT
REPORTDATE, ARCHIVEDATE, RATE, GRID48_DR,
MONTHS_BETWEEN(to_date(ARCHIVEDATE, 'MMYYYY'), to_date(REPORTDATE, 'MMYYYY')) + 1 AS MNTHS_BTWN
FROM TRADE)
</code></pre>
<p>In the Months Between function I am trying to find the no. of months (+1) between a Timestamp data type date(archivedate) and String type date reportdate. How to do in BQ?</p>
<p>How do I replace the "SELECT REPORTDATE,ARCHIVEDATE,RATE,GRID48_DR,MONTHS_BETWEEN(to_date(ARCHIVEDATE,'MMYYYY'),to_date(REPORTDATE,'MMYYYY'))+1 AS MNTHS_BTWN" in BG ?</p>
| [
{
"answer_id": 74315611,
"author": "MrShakila",
"author_id": 19292778,
"author_profile": "https://Stackoverflow.com/users/19292778",
"pm_score": 1,
"selected": false,
"text": "class CustomClipPath extends CustomClipper<Path> {\n var radius=10.0;\n @override\n Path getClip(Size size) {\n Path path = Path();\n path.lineTo(0, 200);\n path.lineTo(200,200);\n path.lineTo(260,0);\n path.lineTo(30, 0);\n return path;\n }\n @override\n bool shouldReclip(CustomClipper<Path> oldClipper) => false;\n}\n"
},
{
"answer_id": 74315703,
"author": "targiasld",
"author_id": 5812524,
"author_profile": "https://Stackoverflow.com/users/5812524",
"pm_score": 3,
"selected": true,
"text": "import 'package:flutter/material.dart';\n\n\nvoid main() {\n runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n home: Scaffold(\n body: Container(\n color: Colors.white,\n padding: EdgeInsets.symmetric(horizontal: 40, vertical: 80),\n child: Container(\n width: 300,\n height: 400,\n color: Colors.yellow,\n child: CustomPaint(painter: LinePainter()),\n ),\n ),\n ),\n );\n }\n}\n\nclass LinePainter extends CustomPainter {\n @override\n void paint(Canvas canvas, Size size) {\n\n final p1 = Offset(size.width, 0);\n final p2 = Offset(0, size.height);\n final paint = Paint()\n ..color = Colors.black\n ..strokeWidth = 4;\n canvas.drawLine(p1, p2, paint);\n }\n\n @override\n bool shouldRepaint(LinePainter oldDelegate) => false;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20416382/"
] |
74,315,574 | <p>I am trying to use NGINX as an authenticated passthrough proxy (which intercepts a request, checks authentication, and redirects to the original destination (including HTTPS and HTTP URLs) ). However, when I try to achieve the same, I am getting the error as</p>
<pre><code>2022/11/04 15:42:58 [info] 6905#0: *7 no user/password was provided for basic authentication, client: 127.0.0.1, server: localhost, request: "GET http://www.google.com/ HTTP/1.1", host: "www.google.com"
2022/11/04 15:42:58 [info] 6905#0: *7 kevent() reported that client 127.0.0.1 closed keepalive connection
</code></pre>
<p>I am using the following curl:</p>
<pre><code>curl -x 127.0.0.1:80 -u username:password "https://www.google.com"
</code></pre>
<p>Here is my nginx.conf file</p>
<pre><code> index index.html index.htm index.php;
ssl_certificate /usr/local/etc/ssl/certs/self-signed.crt;
ssl_certificate_key /usr/local/etc/ssl/private/self-signed.key;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format custom1 '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$http_x_forwarded_for" $request_id '
'"$request_body"';
log_format custom '$request_body' ;
access_log logs/host.access.log custom ;
sendfile on;
spinous on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
server { # simple reverse-proxy
listen 8082;
proxy_connect;
auth_basic "Restricted Content";
auth_basic_user_file /etc/apache2/.htpasswd;
proxy_connect_allow 443 563;
proxy_connect_connect_timeout 1220s;
proxy_connect_read_timeout 1220s;
proxy_connect_send_timeout 1220s;
resolver 8.8.8.8;
server_name localhost;
access_log logs/host.access.log main;
listen 443 SSL;
listen [::]:443 SSL;
ssl_session_timeout 5m;
ssl_certificate /usr/local/etc/ssl/certs/self-signed.crt;
ssl_certificate_key /usr/local/etc/ssl/private/self-signed.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
location / {
proxy_pass $host:$server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
auth_basic "Administrator’s Area";
auth_basic_user_file /etc/apache2/.htpasswd;
}
}
}
</code></pre>
| [
{
"answer_id": 74315611,
"author": "MrShakila",
"author_id": 19292778,
"author_profile": "https://Stackoverflow.com/users/19292778",
"pm_score": 1,
"selected": false,
"text": "class CustomClipPath extends CustomClipper<Path> {\n var radius=10.0;\n @override\n Path getClip(Size size) {\n Path path = Path();\n path.lineTo(0, 200);\n path.lineTo(200,200);\n path.lineTo(260,0);\n path.lineTo(30, 0);\n return path;\n }\n @override\n bool shouldReclip(CustomClipper<Path> oldClipper) => false;\n}\n"
},
{
"answer_id": 74315703,
"author": "targiasld",
"author_id": 5812524,
"author_profile": "https://Stackoverflow.com/users/5812524",
"pm_score": 3,
"selected": true,
"text": "import 'package:flutter/material.dart';\n\n\nvoid main() {\n runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n home: Scaffold(\n body: Container(\n color: Colors.white,\n padding: EdgeInsets.symmetric(horizontal: 40, vertical: 80),\n child: Container(\n width: 300,\n height: 400,\n color: Colors.yellow,\n child: CustomPaint(painter: LinePainter()),\n ),\n ),\n ),\n );\n }\n}\n\nclass LinePainter extends CustomPainter {\n @override\n void paint(Canvas canvas, Size size) {\n\n final p1 = Offset(size.width, 0);\n final p2 = Offset(0, size.height);\n final paint = Paint()\n ..color = Colors.black\n ..strokeWidth = 4;\n canvas.drawLine(p1, p2, paint);\n }\n\n @override\n bool shouldRepaint(LinePainter oldDelegate) => false;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6933688/"
] |
74,315,585 | <p>I built a script that elaborate google sheets and extract them to a Drive folder. To create it script I followed the <a href="https://developers.google.com/apps-script/guides/support/best-practices" rel="nofollow noreferrer">Best Practices</a>.
What I'm noticing is that over time the execution slowed down and I don't understand why sometimes is faster than others.</p>
<p>I tried with smaller scripts --> just 1 getValues(), elaborate the array of arrays completely and only inside the code, and at the end 1 setValues() to plot the data into sheet --> and these type of scripts don't slow down over time. What I'm trying to understand is if other aspects rather than the quality of the code affect the speed of the GAS execution</p>
| [
{
"answer_id": 74316172,
"author": "Rubén",
"author_id": 1595451,
"author_profile": "https://Stackoverflow.com/users/1595451",
"pm_score": 2,
"selected": false,
"text": "now()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6729983/"
] |
74,315,605 | <p>I'm applying <code>filter</code> and <code>max</code> on a <code>List<Person></code>, trying to find out oldest person(people) among the suspected list if he's on the target list</p>
<pre><code>List<String> targetNames= new ArrayList<>();
targetPersonName.add("Jason");
targetPersonName.add("Mike");
List<Person> suspectedList = getSuspectedPeople();
List<Person> result = suspectedList.stream()
.filter((Person p) -> targetNames.contains(p.getName()))
.collect(Collectors.groupingBy(Person::getAge))
.entrySet().stream().max(Map.Entry.comparingByKey()).get().getValue();
</code></pre>
<p>The above code works fine when <code>result</code> is not <code>null</code> or not <code>empty</code>; however, it raise the <code>NoSuchElementException("No value present")</code> when <code>result</code> is empty. Looking for a way to use <code>ifPresent()</code> then <code>get().getValue()</code>.</p>
| [
{
"answer_id": 74315876,
"author": "Georglider",
"author_id": 12791811,
"author_profile": "https://Stackoverflow.com/users/12791811",
"pm_score": 0,
"selected": false,
"text": ".orElse(new AbstractMap.SimpleEntry<>(0, Collections.emptyList())).getValue()\n"
},
{
"answer_id": 74315884,
"author": "Chaosfire",
"author_id": 17795888,
"author_profile": "https://Stackoverflow.com/users/17795888",
"pm_score": 2,
"selected": false,
"text": "Optional"
},
{
"answer_id": 74315900,
"author": "frascu",
"author_id": 2526969,
"author_profile": "https://Stackoverflow.com/users/2526969",
"pm_score": 2,
"selected": true,
"text": "map"
},
{
"answer_id": 74336011,
"author": "Sobhan",
"author_id": 7189597,
"author_profile": "https://Stackoverflow.com/users/7189597",
"pm_score": 0,
"selected": false,
"text": "List<Person> sortedList = personList.stream()\n .sorted(Comparator.comparing(Person::getAge).reversed())\n .collect(Collectors.toList());\n\nPerson maxAgePerson = sortedList.get(0);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11019702/"
] |
74,315,648 | <p>This is a docker-compose.yml file.
When I am running the docker-compose-up command it will through an error.
looks like **services. volumes must be a mapping **
`</p>
<pre><code>version: '3.9'
services:
zookeeper:
container_name: zookeeper
image: wurstmeister/zookeeper
ports:
- '2181:2181'
kafka:
container_name: kafka
image: wurstmeister/kafka
ports:
- '9092:9092'
volumes:
- ./data/kafka: /var/run/docker.sock
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ZOOKEEPER_CONNECT=zookeeper: 2181
mongo:
container_name: mongo
image: mongo
ports:
- '27017:27017'
volumes:
- './data/mongo:/data/db'
app1:
container_name: app1
build: ./app1
ports:
- '8080:8080'
volumes:
- ./app1:/app
environment:
PORT: 8080
MONGO_URL: 'mongodb://mongo:27017/app1'
KAFKA_BOOTSTRAP_SERVERS: 'kafka:9092'
KAFKA_TOPIC: topic1
depends_on:
- mongo
- kafka
app2:
container_name: app2
build: ./app2
ports:
- '8081:8080'
volumes:
- ./app2:/app
environment:
PORT: 8081
MONGO_URL: 'mongodb://mongo:27017/app2'
KAFKA_BOOTSTRAP_SERVERS: 'kafka:9092'
KAFKA_TOPIC: topic1
depends_on:
- mongo
- kafka
</code></pre>
<p>`</p>
<p>basically The <code>docker compose up</code> command aggregates the output of each container.</p>
| [
{
"answer_id": 74315824,
"author": "Paul Rey",
"author_id": 3756843,
"author_profile": "https://Stackoverflow.com/users/3756843",
"pm_score": 0,
"selected": false,
"text": "volumes"
},
{
"answer_id": 74315827,
"author": "atish.s",
"author_id": 6200354,
"author_profile": "https://Stackoverflow.com/users/6200354",
"pm_score": 1,
"selected": false,
"text": "services:\n app2:\n container_name: app2\n build: ./app2\n ports:\n - '8081:8080'\n volumes:\n - app2:/app # ./app2 has been updated to app2, app2 is the volume name\n environment:\n PORT: 8081\n MONGO_URL: 'mongodb://mongo:27017/app2'\n KAFKA_BOOTSTRAP_SERVERS: 'kafka:9092'\n KAFKA_TOPIC: topic1\n depends_on:\n - mongo\n - kafka\n\nvolumes:\n myapp2:\n # add the other volumes mapped here\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20250062/"
] |
74,315,667 | <p>I am using angular and I have two children components and I wanna pass data to them. Here is how I wrote my code: This is the home template</p>
<pre><code><div class="myCard">
<mat-card style="width: 500px;">
<mat-card-title style="display: flex; align-items: center; justify-content:space-between">
<span>Employees</span>
<button mat-raised-button color="primary" routerLink="/home/add-employee">Add</button>
</mat-card-title>
<router-outlet ></router-outlet>
</mat-card>
</div>
</code></pre>
<p>Then on the <code><router-outlet></router-outlet></code> that's where the children components show. I know how to pass data to child if I included only one child component like <code><app-child [data]="data"></app-child></code> in place of <code><router-outlet></router-outlet></code> on the code above. So I wanna know how can I achieve this the way I want</p>
<p><strong>Update</strong>
Thanks guys, but I found the answer <a href="https://stackoverflow.com/questions/41451375/passing-data-into-router-outlet-child-components">here</a></p>
| [
{
"answer_id": 74315824,
"author": "Paul Rey",
"author_id": 3756843,
"author_profile": "https://Stackoverflow.com/users/3756843",
"pm_score": 0,
"selected": false,
"text": "volumes"
},
{
"answer_id": 74315827,
"author": "atish.s",
"author_id": 6200354,
"author_profile": "https://Stackoverflow.com/users/6200354",
"pm_score": 1,
"selected": false,
"text": "services:\n app2:\n container_name: app2\n build: ./app2\n ports:\n - '8081:8080'\n volumes:\n - app2:/app # ./app2 has been updated to app2, app2 is the volume name\n environment:\n PORT: 8081\n MONGO_URL: 'mongodb://mongo:27017/app2'\n KAFKA_BOOTSTRAP_SERVERS: 'kafka:9092'\n KAFKA_TOPIC: topic1\n depends_on:\n - mongo\n - kafka\n\nvolumes:\n myapp2:\n # add the other volumes mapped here\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10085435/"
] |
74,315,728 | <p>I have a load of survey data that I need to remove the length outliers from. It looks something like this (but not much like this, a dolphin is unlikely to be 52mm):</p>
<pre><code>Area Season Species Length (mm)
Christchurch Spring dolphin 52
Christchurch Spring dolphin 54
Christchurch Spring dolphin 46
Christchurch Spring dolphin 40
Christchurch Spring dolphin 38
Christchurch Autumn dolphin 52
Christchurch Autumn dolphin 54
Christchurch Autumn dolphin 46
Christchurch Autumn dolphin 40
Christchurch Autumn dolphin 38
Christchurch Spring ray 52
Christchurch Spring ray 54
Christchurch Spring ray 46
Christchurch Spring ray 40
Christchurch Spring ray 38
Christchurch Autumn ray 52
Christchurch Autumn ray 54
Christchurch Autumn ray 46
Christchurch Autumn ray 40
Christchurch Autumn ray 38
</code></pre>
<p>My problem is I have 6 areas, a range of species at each and about 2000 measurements and I need to remove the length outlier for each species at each season and location. I am very new to r and coding in general so any help is appreciated in making this process more efficient as I am fully aware I have probably not gone about this the most streamlined way.</p>
<p>I have used a loop to subset the original data by area giving me 6 new data frames, and then each of those by season and species which gives me something around 30 data frames.</p>
<p>I now have run out of steam and can't work out how to remove the outliers from each data frame without putting each one in individually in to the code below.</p>
<pre><code>Q<-quantile(au_ray_christ$TOTAL_LENGTH_MM, probs=c(.25,.75),na.rm=FALSE)
iqr<-IQR(au_ray_christ$TOTAL_LENGTH_MM)
au_ray_christ<-subset(au_ray_christ,au_ray_christ$TOTAL_LENGTH_MM >(Q[1]-1.5*iqr) & au_ray_christ$TOTAL_LENGTH_MM < (Q[2]+1.5*iqr))
</code></pre>
<p>Any help would be appreciated, I'm more than happy to go back a few steps if it stops me having to copy and paste my life away!</p>
<p>ps. I also eventually need the data to be back in one frame so if I can avoid splitting it all down in anyway that would be great too.</p>
| [
{
"answer_id": 74316048,
"author": "user2974951",
"author_id": 2974951,
"author_profile": "https://Stackoverflow.com/users/2974951",
"pm_score": 1,
"selected": true,
"text": "do.call(\n rbind,\n by(\n df,\n list(df$Area,df$Season,df$Species),\n function(x){\n Q<-quantile(x$Length_mm,probs=c(.25,.75),na.rm=FALSE)\n iqr<-IQR(x$Length_mm)\n cbind(\n x,\n \"out\"=x$Length_mm<(Q[1]-1.5*iqr) | x$Length_mm>(Q[2]+1.5*iqr)\n )\n }\n )\n)\n"
},
{
"answer_id": 74316653,
"author": "shghm",
"author_id": 12552884,
"author_profile": "https://Stackoverflow.com/users/12552884",
"pm_score": 1,
"selected": false,
"text": "outliers"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20416384/"
] |
74,315,750 | <p>There are dynamic libraries provided by others, which are out of my control. What I know is that most of the aforementioned libraries are compiled
by <code>g++4.9.4</code> & <code>g++4.8.4</code> with <code>C++11</code> support, and few libraries are
compiled by <code>g++11.1.0</code> with <code>C++14</code> support. And I have to use newer g++ which supports <code>C++17</code> to compile my project. I intend to use <code>g++11.3.0</code> on <code>Ubuntu20.4</code>.</p>
<p>Is there any potential problem I should be aware of when linking to dynamic libraries compiled by the said old version g++?</p>
| [
{
"answer_id": 74339164,
"author": "Dan Bonachea",
"author_id": 3528321,
"author_profile": "https://Stackoverflow.com/users/3528321",
"pm_score": 2,
"selected": false,
"text": "libstdc++.so.6.0.*"
},
{
"answer_id": 74343237,
"author": "n. m.",
"author_id": 775806,
"author_profile": "https://Stackoverflow.com/users/775806",
"pm_score": 2,
"selected": false,
"text": "std::string"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13611002/"
] |
74,315,759 | <p>If you evaluate</p>
<pre><code>(Math.PI).ToString("G51")
</code></pre>
<p>the result is</p>
<pre><code>"3,141592653589793115997963468544185161590576171875"
</code></pre>
<p><code>Math.Pi</code> is correct up to the 15th decimal which is in accordance with the precision of a <code>double</code>. "G17" is used for round tripping, so I expected the <code>ToString</code> to stop after "G17", but instead it continued to produce numbers up to "G51".</p>
<p><strong>Q</strong> Since the digits after 15th decimal are beyond the precision afforded by the 53 bits of mantissa, how are the remaining digits calculated?</p>
| [
{
"answer_id": 74324038,
"author": "Poul Bak",
"author_id": 5741643,
"author_profile": "https://Stackoverflow.com/users/5741643",
"pm_score": 0,
"selected": false,
"text": ".ToString(\"G51\")"
},
{
"answer_id": 74324040,
"author": "David Browne - Microsoft",
"author_id": 7297700,
"author_profile": "https://Stackoverflow.com/users/7297700",
"pm_score": 2,
"selected": true,
"text": "using System.Numerics;\n\nvar r = new BigRational(Math.PI);\nBigRational dem;\n\nBigRational.NumDen(r, out dem);\nvar num = r * dem;\n\nConsole.WriteLine(num);\nConsole.WriteLine(\"-----------------\");\nConsole.WriteLine(dem);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4090370/"
] |
74,315,783 | <p>Looking at the <a href="https://www.gnu.org/software/cflow/manual/html_node/Source-of-wc-command.html" rel="nofollow noreferrer">sample implementation of <code>wc.c</code></a> when counting number of lines, it loop through the file, one character at a time and accumulating the '\n' to count the number of newlines:</p>
<pre><code>#define COUNT(c) \
ccount++; \
if ((c) == '\n') \
lcount++;
</code></pre>
<ul>
<li><p>Is there a way to just seek the file for '\n' and keep jumping to the newline characters and do a count?</p>
</li>
<li><p>Would seeking for '\n' be the same as just reading characters one at a time until we see '\n' and count it?</p>
</li>
</ul>
| [
{
"answer_id": 74382402,
"author": "viraltaco_",
"author_id": 9282847,
"author_profile": "https://Stackoverflow.com/users/9282847",
"pm_score": 3,
"selected": false,
"text": "'\\n'"
},
{
"answer_id": 74444081,
"author": "Christian Severin",
"author_id": 158371,
"author_profile": "https://Stackoverflow.com/users/158371",
"pm_score": 2,
"selected": false,
"text": "'\\n'"
},
{
"answer_id": 74451680,
"author": "Konstantin Svintsov",
"author_id": 3386820,
"author_profile": "https://Stackoverflow.com/users/3386820",
"pm_score": -1,
"selected": false,
"text": "#include <string.h>\n\nunsigned int count_newlines(const char *str) {\n unsigned result = 0;\n const char s = str;\n while ((s = strchr(s, '\\n')) != NULL) {\n ++result; // found one '\\n'\n ++s; // and start searching again from the next character\n }\n return result;\n} \n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/610569/"
] |
74,315,793 | <p>I have multiple rows of string where the string is all wrong. Here is one row an an example of the geometry and output expected:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>geometry</th>
<th>output</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>POLYGON (( 106.812271, -6.361551, 106.812111, -6.361339, 106.81205, -6.361177, 106.81206, -6.360905, 106.812055, -6.360582, 106.812065, -6.360218, 106.812293, -6.359295, 106.812593, -6.358644, 106.812436, -6.358406, 106.8121515, -6.3582051, 106.8123, -6.357823, 106.81244, -6.357407, 106.812612, -6.356842, 106.812719, -6.356544, 106.81274, -6.356384, 106.812864, -6.356148, 106.813019, -6.356021, 106.813287, -6.355797, 106.813781, -6.355286, 106.814076, -6.354751, 106.814277, -6.354393, 106.814403, -6.354027, 106.814553, -6.353814, 106.814736, -6.353526, 106.814993, -6.353302, 106.81516, -6.353024, 106.815358, -6.35279, 106.815509, -6.352588, 106.815675, -6.352331, 106.8153007, -6.3521138, 106.8151398, -6.3520137, 106.8149789, -6.3518005, 106.8147643, -6.3516939, 106.8144639, -6.3516245, 106.8141527, -6.3515392, 106.8135734, -6.351342, 106.813171, -6.3512034, 106.8123284, -6.3509219, 106.8122418, -6.3511298, 106.8118164, -6.3521534, 106.8116597, -6.3525047, 106.8111849, -6.3535692, 106.8102245, -6.3554942, 106.8093545, -6.3568947, 106.8085097, -6.3580518, 106.80795, -6.358832, 106.8077793, -6.3590429, 106.807668, -6.359441, 106.807499, -6.360346, 106.8072531, -6.3616378, 106.8071476, -6.3622599, 106.8070637, -6.3626798, 106.8070823, -6.3629367, 106.8071207, -6.3634531, 106.8078269, -6.363831, 106.809448, -6.364124, 106.810574, -6.364198, 106.81066, -6.362993, 106.811175, -6.36277, 106.812087, -6.361703, 106.812271, -6.361551))</td>
<td>POLYGON (( 106.812271 -6.361551, 106.812111 -6.361339, 106.81205 -6.361177, 106.81206 -6.360905, 106.812055 -6.360582, 106.812065 -6.360218, 106.812293 -6.359295, 106.812593 -6.358644, 106.812436 -6.358406, 106.8121515 -6.3582051, 106.8123 -6.357823, 106.81244 -6.357407, 106.812612 -6.356842, 106.812719 -6.356544, 106.81274 -6.356384, 106.812864 -6.356148, 106.813019 -6.356021, 106.813287 -6.355797, 106.813781 -6.355286, 106.814076 -6.354751, 106.814277 -6.354393, 106.814403 -6.354027, 106.814553 -6.353814, 106.814736 -6.353526, 106.814993 -6.353302, 106.81516 -6.353024, 106.815358 -6.35279, 106.815509 -6.352588, 106.815675, -6.352331, 106.8153007, -6.3521138, 106.8151398 -6.3520137, 106.8149789 -6.3518005, 106.8147643 -6.3516939, 106.8144639 -6.3516245, 106.8141527 -6.3515392, 106.8135734 -6.351342, 106.813171 -6.3512034, 106.8123284 -6.3509219, 106.8122418 -6.3511298, 106.8118164 -6.3521534, 106.8116597 -6.3525047, 106.8111849 -6.3535692, 106.8102245 -6.3554942, 106.8093545 -6.3568947, 106.8085097 -6.3580518, 106.80795 -6.358832, 106.8077793 -6.3590429, 106.807668 -6.359441, 106.807499 -6.360346, 106.8072531 -6.3616378, 106.8071476 -6.3622599, 106.8070637 -6.3626798, 106.8070823 -6.3629367, 106.8071207 -6.3634531, 106.8078269 -6.363831, 106.809448 -6.364124, 106.810574 -6.364198, 106.81066 -6.362993, 106.811175 -6.36277, 106.812087 -6.361703, 106.812271 -6.361551))</td>
</tr>
</tbody>
</table>
</div>
<p>One example is as follows above. I need to get rid of all odd position commas and only keep the even position commas. So that the geometry can become output.</p>
<p>I tried doing a split(text.",") and concatenate however when the columns is blank it returns xxx,,,, which is not what I had in mind.
Since some have more than 200 commas means that I need to have more than 200 columns, is there a simpler way like using regex?Someone please help.</p>
| [
{
"answer_id": 74316222,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 2,
"selected": true,
"text": "=INDEX(REGEXREPLACE(QUERY(FLATTEN(SPLIT(A1, \",\")&IF(ISODD(\n SEQUENCE(1, COLUMNS(SPLIT(A1, \",\")))),, \",\")),,9^9), \",$\", ))\n"
},
{
"answer_id": 74316293,
"author": "TheMaster",
"author_id": 8404453,
"author_profile": "https://Stackoverflow.com/users/8404453",
"pm_score": 2,
"selected": false,
"text": ", -"
},
{
"answer_id": 74409283,
"author": "bobble bubble",
"author_id": 5527985,
"author_profile": "https://Stackoverflow.com/users/5527985",
"pm_score": 0,
"selected": false,
"text": ","
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20355243/"
] |
74,315,809 | <p>I have a table with prefixes (here in csv format):</p>
<pre><code>PREFIX,LABEL
A,Infectious diseases
B,Infectious diseases
C,Tumor
D1,Tumor
D2,Tumor
D31,Tumor
D32,Tumor
D33,Blood disorder
D4,Blood disorder
D5,Blood disorder
</code></pre>
<p>And I want to join it with this one:</p>
<pre><code>AGE,DEATH_CODE
67,A02
85,D318
75,C007+X
62,D338
</code></pre>
<p>To get obviously:</p>
<pre><code>AGE,LABEL
67,Infectious diseases
85,Tumor
75,Tumor
62,Blood disorder
</code></pre>
<p>I know how to do that with SQL and <code>LIKE</code> but not with tidyverse <code>left_join</code> or base R.</p>
<hr />
<h2>Dput of data</h2>
<h3>Table 1: CIM_CODES</h3>
<pre><code>structure(list(PREFIX = c("A", "B", "C", "D1", "D2", "D31", "D32",
"D33", "D4", "D5"), LABEL = c("Infectious diseases", "Infectious diseases",
"Tumor", "Tumor", "Tumor", "Tumor", "Tumor", "Blood disorder",
"Blood disorder", "Blood disorder")), row.names = c(NA, -10L), spec = structure(list(
cols = list(PREFIX = structure(list(), class = c("collector_character",
"collector")), LABEL = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = ","), class = "col_spec"), problems = <pointer: 0x000002527d306190>, class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
</code></pre>
<h3>Table 2: DEATH_CAUSES</h3>
<pre><code>structure(list(AGE = c(67, 85, 75, 62), DEATH_CODE = c("A02",
"D318", "C007+X", "D338")), row.names = c(NA, -4L), spec = structure(list(
cols = list(AGE = structure(list(), class = c("collector_double",
"collector")), DEATH_CODE = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = ","), class = "col_spec"), problems = <pointer: 0x0000025273898c60>, class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
</code></pre>
| [
{
"answer_id": 74315980,
"author": "hungtv",
"author_id": 19825967,
"author_profile": "https://Stackoverflow.com/users/19825967",
"pm_score": -1,
"selected": false,
"text": "select a.age, p.label \nfrom prefix p\nleft join age a on a.death_code like CONCAT(\"%\",p.prefix,\"%\"); \n"
},
{
"answer_id": 74316146,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 3,
"selected": true,
"text": "library(tidyverse)\n\nDEATH_CAUSES |>\n mutate(LABEL = map_chr(DEATH_CODE, \n ~CIM_CODES$LABEL[\n which.min(stringdist::stringdist(.x, CIM_CODES$PREFIX))\n ]))\n#> # A tibble: 4 x 3\n#> AGE DEATH_CODE LABEL \n#> <dbl> <chr> <chr> \n#> 1 67 A02 Infectious diseases\n#> 2 85 D318 Tumor \n#> 3 75 C007+X Tumor \n#> 4 62 D338 Blood disorder\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6537892/"
] |
74,315,811 | <p>I get this error after submitting the form. Here's the controller code.</p>
<p>The error appears to be in the validate() part.</p>
<pre><code>
public function store(Request $request) {
$video = new Video();
$request->validate([
'title' => 'required|max:68',
'description' => 'required|max:256',
'image' => 'image|mimes:jpeg,png,jpg,webp|max:2048',
'video' => 'video|mimes:m4v,avi,flv,mp4,mov',
]);
if($request->image) {
$title = uniqid().'.'.$request->image->extension();
$request->image->move(public_path('video/images'), $title);
$video->image = $title;
}
if($request->video) {
$title = uniqid().'.'.$request->video->extension();
$request->video->move(public_path('video/videos'), $title);
$video->video = $title;
}
$video->title = $request->title;
$video->description = $request->description;
$video->save();
return redirect()->route('videos.list')->with('Success','video created successfully!');
}
</code></pre>
<p>Thanks in advance</p>
<p>I tried different things but I still need figuring this out</p>
<pre><code></code></pre>
| [
{
"answer_id": 74315852,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 2,
"selected": true,
"text": "'video' => 'video|mimes:m4v,avi,flv,mp4,mov',\n"
},
{
"answer_id": 74315864,
"author": "Ramil Huseynov",
"author_id": 6711823,
"author_profile": "https://Stackoverflow.com/users/6711823",
"pm_score": 0,
"selected": false,
"text": "\n public function store(Request $request) {\n $video = new Video();\n $request->validate([\n 'title' => 'required|max:68',\n 'description' => 'required|max:256',\n 'image' => 'image|mimes:jpeg,png,jpg,webp|max:2048',\n 'video' => 'mimes:m4v,avi,flv,mp4,mov',\n ]);\n \n if($request->image) { \n $title = uniqid().'.'.$request->image->extension();\n $request->image->move(public_path('video/images'), $title);\n $video->image = $title; \n } \n \n if($request->video) { \n $title = uniqid().'.'.$request->video->extension();\n $request->video->move(public_path('video/videos'), $title);\n $video->video = $title; \n } \n \n $video->title = $request->title; \n $video->description = $request->description; \n $video->save();\n \n return redirect()->route('videos.list')->with('Success','video created successfully!');\n \n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18645628/"
] |
74,315,814 | <p>Am I assigning the app role permission below in azuread.tf incorrectly?</p>
<pre><code>resource "azuread_application" "resource_creation" {
display_name = local.azad_resource_creation_sp_name
app_role {
# ensuring app role definition can be assigned to other applications (the service principal)
allowed_member_types = ["Application"]
# enabling the app role
enabled = true
# app role description used when the role is being assigned
description = "Pre Requisite application role for service principal authentication"
# app role display name that shows during app role assignment
display_name = "Role assigned - Application.ReadWrite.All"
# unique identifier of the app role, sourced from https://learn.microsoft.com/en-us/graph/permissions-reference
id = "1bfefb4e-e0b5-418b-a88f-73c46d2cc8e9"
}
}
</code></pre>
<p>After applying the config I receive the following error:</p>
<pre><code> Error: Could not create application
with azuread_application.service_connection
on azuread.tf line 14, in resource "azuread_application" "service_connection":
resource "azuread_application" "service_connection" {
ApplicationsClient.BaseClient.Post(): unexpected status 403 with OData error: Authorization_RequestDenied: Insufficient privileges to complete the operation.
</code></pre>
<p>I have referenced other code examples and in this instance I am authencticating via a service principal. Hence the reason why I have assigned the: <code>Application.ReadWrite.All</code> role. Sourced here - <a href="https://learn.microsoft.com/en-us/graph/permissions-reference" rel="nofollow noreferrer">Microsoft Graph permissions reference</a></p>
<p>Do I need an <a href="https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/app_role_assignment" rel="nofollow noreferrer">app role assignment</a> ? Or are additional application roles required in addition to the <code>Application.ReadWrite.All</code> role?</p>
| [
{
"answer_id": 74315852,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 2,
"selected": true,
"text": "'video' => 'video|mimes:m4v,avi,flv,mp4,mov',\n"
},
{
"answer_id": 74315864,
"author": "Ramil Huseynov",
"author_id": 6711823,
"author_profile": "https://Stackoverflow.com/users/6711823",
"pm_score": 0,
"selected": false,
"text": "\n public function store(Request $request) {\n $video = new Video();\n $request->validate([\n 'title' => 'required|max:68',\n 'description' => 'required|max:256',\n 'image' => 'image|mimes:jpeg,png,jpg,webp|max:2048',\n 'video' => 'mimes:m4v,avi,flv,mp4,mov',\n ]);\n \n if($request->image) { \n $title = uniqid().'.'.$request->image->extension();\n $request->image->move(public_path('video/images'), $title);\n $video->image = $title; \n } \n \n if($request->video) { \n $title = uniqid().'.'.$request->video->extension();\n $request->video->move(public_path('video/videos'), $title);\n $video->video = $title; \n } \n \n $video->title = $request->title; \n $video->description = $request->description; \n $video->save();\n \n return redirect()->route('videos.list')->with('Success','video created successfully!');\n \n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338838/"
] |
74,315,849 | <p>I have a column of TIMESTAMP(6) datatype in oracle and have values like 2022-04-01 18:02:42 and i wanna fetch all the records that falls between two datetime. I tried like below but no luck,</p>
<pre><code>select * from table
where column BETWEEN '2022-04-01 18:02:42' and '2022-11-03 19:28:57' -- no records
</code></pre>
<p>tried this too,</p>
<pre><code>select *
from table
where column BETWEEN to_date('2022-04-01','yyyy-mm-dd')
and to_date('2022-11-03','yyyy-mm-dd') -- a non-numeric character was found where a numeric was expected
</code></pre>
<p>and,</p>
<pre><code>select *
from table
where column BETWEEN to_timestamp('2022-04-01','yyyy-mm-dd')
and to_timestamp('2022-11-03','yyyy-mm-dd') -- a non-numeric character was found where a numeric was expected.
</code></pre>
<p>I want to fetch records falls in this dates!</p>
<p>Thanks.</p>
| [
{
"answer_id": 74315852,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 2,
"selected": true,
"text": "'video' => 'video|mimes:m4v,avi,flv,mp4,mov',\n"
},
{
"answer_id": 74315864,
"author": "Ramil Huseynov",
"author_id": 6711823,
"author_profile": "https://Stackoverflow.com/users/6711823",
"pm_score": 0,
"selected": false,
"text": "\n public function store(Request $request) {\n $video = new Video();\n $request->validate([\n 'title' => 'required|max:68',\n 'description' => 'required|max:256',\n 'image' => 'image|mimes:jpeg,png,jpg,webp|max:2048',\n 'video' => 'mimes:m4v,avi,flv,mp4,mov',\n ]);\n \n if($request->image) { \n $title = uniqid().'.'.$request->image->extension();\n $request->image->move(public_path('video/images'), $title);\n $video->image = $title; \n } \n \n if($request->video) { \n $title = uniqid().'.'.$request->video->extension();\n $request->video->move(public_path('video/videos'), $title);\n $video->video = $title; \n } \n \n $video->title = $request->title; \n $video->description = $request->description; \n $video->save();\n \n return redirect()->route('videos.list')->with('Success','video created successfully!');\n \n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20038861/"
] |
74,315,879 | <p>I want to replace the missing value with the average of past years on the same date.</p>
<p>I think for this it is worth using the dplyr package from R's tidyverse to group the data by month and day. How can I conduct mean imputation on a subset of data?</p>
<pre><code>DATA <- read.csv('DateCaratNO2.csv')
DATA <- as.data.frame(DATA)
DATA$Full.Data <- as.POSIXct(DATA$date, format = "%m/%d/%Y")
DATA$day <- format(DATA$Full.Data, "%d")
DATA$month <- format(DATA$Full.Data, "%m")
DATA$year <- format(DATA$Full.Data, "%Y")
attach(DATA)
library(dplyr)
df <- DATA %>% mutate(day = lubridate::floor_date(Full.Data, "day"),
month = lubridate::floor_date(Full.Data, "month")) %>%
dplyr::group_by(day, month, ID) %>%
mutate(NO2 = replace_na(NO2, mean(NO2, na.rm=TRUE)))
</code></pre>
<p>I need to replace the missing value with the average value for the same day and month for a specific station. Any help is appreciated!</p>
<p>The <code>dput</code> from the data can be found here:</p>
<pre><code>structure(list(ID = c("IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A", "IT1940A",
"IT1940A", "IT1940A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A", "IT1938A",
"IT1938A", "IT1938A"), date = c("2/1/2015", "2/2/2015", "2/3/2015",
"2/4/2015", "2/5/2015", "2/6/2015", "2/7/2015", "2/8/2015", "2/9/2015",
"2/10/2015", "2/11/2015", "2/12/2015", "2/13/2015", "2/14/2015",
"2/15/2015", "2/16/2015", "2/17/2015", "2/18/2015", "2/19/2015",
"2/20/2015", "2/21/2015", "2/22/2015", "2/23/2015", "2/24/2015",
"2/25/2015", "2/26/2015", "2/27/2015", "2/28/2015", "2/1/2016",
"2/2/2016", "2/3/2016", "2/4/2016", "2/5/2016", "2/6/2016", "2/7/2016",
"2/8/2016", "2/9/2016", "2/10/2016", "2/11/2016", "2/12/2016",
"2/13/2016", "2/14/2016", "2/15/2016", "2/16/2016", "2/17/2016",
"2/18/2016", "2/19/2016", "2/20/2016", "2/21/2016", "2/22/2016",
"2/23/2016", "2/24/2016", "2/25/2016", "2/26/2016", "2/27/2016",
"2/28/2016", "2/29/2016", "1/1/2017", "1/2/2017", "1/3/2017",
"1/4/2017", "1/5/2017", "1/6/2017", "1/7/2017", "1/8/2017", "1/9/2017",
"1/10/2017", "1/11/2017", "1/12/2017", "1/13/2017", "1/14/2017",
"1/15/2017", "1/16/2017", "1/17/2017", "1/18/2017", "1/19/2017",
"1/20/2017", "1/21/2017", "1/22/2017", "1/23/2017", "1/24/2017",
"1/25/2017", "1/26/2017", "1/27/2017", "1/28/2017", "1/29/2017",
"1/30/2017", "1/31/2017", "2/1/2018", "2/2/2018", "2/3/2018",
"2/4/2018", "2/5/2018", "2/6/2018", "2/7/2018", "2/8/2018", "2/9/2018",
"2/10/2018", "2/11/2018", "2/12/2018", "2/13/2018", "2/14/2018",
"2/15/2018", "2/16/2018", "2/17/2018", "2/18/2018", "2/19/2018",
"2/20/2018", "2/21/2018", "2/22/2018", "2/23/2018", "2/24/2018",
"2/25/2018", "2/26/2018", "2/27/2018", "2/28/2018", "1/1/2019",
"1/2/2019", "1/3/2019", "1/4/2019", "1/5/2019", "1/6/2019", "1/7/2019",
"1/8/2019", "1/9/2019", "1/10/2019", "1/11/2019", "1/12/2019",
"1/13/2019", "1/14/2019", "1/15/2019", "1/16/2019", "1/17/2019",
"1/18/2019", "1/19/2019", "1/20/2019", "1/21/2019", "1/22/2019",
"1/23/2019", "1/24/2019", "1/25/2019", "1/26/2019", "1/27/2019",
"1/28/2019", "1/29/2019", "1/30/2019", "1/31/2019", "2/1/2019",
"2/2/2019", "2/3/2019", "2/4/2019", "2/5/2019", "2/6/2019", "2/7/2019",
"2/8/2019", "2/9/2019", "2/10/2019", "2/11/2019", "2/12/2019",
"2/13/2019", "2/14/2019", "2/15/2019", "2/16/2019", "2/17/2019",
"2/18/2019", "2/19/2019", "2/20/2019", "2/21/2019", "2/22/2019",
"2/23/2019", "2/24/2019", "2/25/2019", "2/26/2019", "2/27/2019",
"2/28/2019", "1/1/2020", "1/2/2020", "1/3/2020", "1/4/2020",
"1/5/2020", "1/6/2020", "1/7/2020", "1/8/2020", "1/9/2020", "1/10/2020",
"1/11/2020", "1/12/2020", "1/13/2020", "1/14/2020", "1/15/2020",
"1/16/2020", "1/17/2020", "1/18/2020", "1/19/2020", "1/20/2020",
"1/21/2020", "1/22/2020", "1/23/2020", "1/24/2020", "1/25/2020",
"1/26/2020", "1/27/2020", "1/28/2020", "1/29/2020", "1/30/2020",
"1/31/2020", "2/1/2021", "2/2/2021", "2/3/2021", "2/4/2021",
"2/5/2021", "2/6/2021", "2/7/2021", "2/8/2021", "2/9/2021", "2/10/2021",
"2/11/2021", "2/12/2021", "2/13/2021", "2/14/2021", "2/15/2021",
"2/16/2021", "2/17/2021", "2/18/2021", "2/19/2021", "2/20/2021",
"2/21/2021", "2/22/2021", "2/23/2021", "2/24/2021", "2/25/2021",
"2/26/2021", "2/27/2021", "2/28/2021", "2/1/2015", "2/2/2015",
"2/3/2015", "2/4/2015", "2/5/2015", "2/6/2015", "2/7/2015", "2/8/2015",
"2/9/2015", "2/10/2015", "2/11/2015", "2/12/2015", "2/13/2015",
"2/14/2015", "2/15/2015", "2/16/2015", "2/17/2015", "2/18/2015",
"2/19/2015", "2/20/2015", "2/21/2015", "2/22/2015", "2/23/2015",
"2/24/2015", "2/25/2015", "2/26/2015", "2/27/2015", "2/28/2015",
"2/1/2016", "2/2/2016", "2/3/2016", "2/4/2016", "2/5/2016", "2/6/2016",
"2/7/2016", "2/8/2016", "2/9/2016", "2/10/2016", "2/11/2016",
"2/12/2016", "2/13/2016", "2/14/2016", "2/15/2016", "2/16/2016",
"2/17/2016", "2/18/2016", "2/19/2016", "2/20/2016", "2/21/2016",
"2/22/2016", "2/23/2016", "2/24/2016", "2/25/2016", "2/26/2016",
"2/27/2016", "2/28/2016", "2/29/2016", "1/1/2017", "1/2/2017",
"1/3/2017", "1/4/2017", "1/5/2017", "1/6/2017", "1/7/2017", "1/8/2017",
"1/9/2017", "1/10/2017", "1/11/2017", "1/12/2017", "1/13/2017",
"1/14/2017", "1/15/2017", "1/16/2017", "1/17/2017", "1/18/2017",
"1/19/2017", "1/20/2017", "1/21/2017", "1/22/2017", "1/23/2017",
"1/24/2017", "1/25/2017", "1/26/2017", "1/27/2017", "1/28/2017",
"1/29/2017", "1/30/2017", "1/31/2017", "2/1/2018", "2/2/2018",
"2/3/2018", "2/4/2018", "2/5/2018", "2/6/2018", "2/7/2018", "2/8/2018",
"2/9/2018", "2/10/2018", "2/11/2018", "2/12/2018", "2/13/2018",
"2/14/2018", "2/15/2018", "2/16/2018", "2/17/2018", "2/18/2018",
"2/19/2018", "2/20/2018", "2/21/2018", "2/22/2018", "2/23/2018",
"2/24/2018", "2/25/2018", "2/26/2018", "2/27/2018", "2/28/2018",
"1/1/2019", "1/2/2019", "1/3/2019", "1/4/2019", "1/5/2019", "1/6/2019",
"1/7/2019", "1/8/2019", "1/9/2019", "1/10/2019", "1/11/2019",
"1/12/2019", "1/13/2019", "1/14/2019", "1/15/2019", "1/16/2019",
"1/17/2019", "1/18/2019", "1/19/2019", "1/20/2019", "1/21/2019",
"1/22/2019", "1/23/2019", "1/24/2019", "1/25/2019", "1/26/2019",
"1/27/2019", "1/28/2019", "1/29/2019", "1/30/2019", "1/31/2019",
"2/1/2019", "2/2/2019", "2/3/2019", "2/4/2019", "2/5/2019", "2/6/2019",
"2/7/2019", "2/8/2019", "2/9/2019", "2/10/2019", "2/11/2019",
"2/12/2019", "2/13/2019", "2/14/2019", "2/15/2019", "2/16/2019",
"2/17/2019", "2/18/2019", "2/19/2019", "2/20/2019", "2/21/2019",
"2/22/2019", "2/23/2019", "2/24/2019", "2/25/2019", "2/26/2019",
"2/27/2019", "2/28/2019", "1/1/2020", "1/2/2020", "1/3/2020",
"1/4/2020", "1/5/2020", "1/6/2020", "1/7/2020", "1/8/2020", "1/9/2020",
"1/10/2020", "1/11/2020", "1/12/2020", "1/13/2020", "1/14/2020",
"1/15/2020", "1/16/2020", "1/17/2020", "1/18/2020", "1/19/2020",
"1/20/2020", "1/21/2020", "1/22/2020", "1/23/2020", "1/24/2020",
"1/25/2020", "1/26/2020", "1/27/2020", "1/28/2020", "1/29/2020",
"1/30/2020", "1/31/2020", "2/1/2021", "2/2/2021", "2/3/2021",
"2/4/2021", "2/5/2021", "2/6/2021", "2/7/2021", "2/8/2021", "2/9/2021",
"2/10/2021", "2/11/2021", "2/12/2021", "2/13/2021", "2/14/2021",
"2/15/2021", "2/16/2021", "2/17/2021", "2/18/2021", "2/19/2021",
"2/20/2021", "2/21/2021", "2/22/2021", "2/23/2021", "2/24/2021",
"2/25/2021", "2/26/2021", "2/27/2021", "2/28/2021"), NO2 = c(8.494022,
10.270843, 20.854183, 26.973156, 17.957637, 14.908667, 16.15965,
11.995295, 8.860629, 10.035246, 20.141964, 22.327379, 21.02741,
24.465761, 16.538571, 16.556504, 4.783193, 7.59238, 19.161681,
22.677657, 15.586068, NA, NA, NA, 16.631454, 11.29906, 14.864193,
16.420849, 14.104021, 18.786681, 16.8078, 5.788044, 4.648989,
15.276459, 6.557777, 14.57682, 21.385529, 7.954627, 9.436122,
9.503997, 6.562462, 9.555659, 14.54271, 11.293801, 9.99976, 5.034411,
6.153122, 3.590124, 3.350876, 15.858318, 11.843004, 3.834344,
13.858539, 7.778169, 8.614458, 2.18815, 14.864767, 23.718167,
22.192393, 21.003893, 11.270417, 12.869576, 5.541511, 6.065571,
8.600884, 15.744785, 17.657224, 19.806599, 21.258571, 20.145979,
9.321535, 12.00277, 15.655933, 17.461837, 24.439565, 16.996054,
13.463386, 4.692335, 2.42172, 9.528777, 8.088544, 20.124756,
17.19798, 17.549501, 17.667262, 10.398431, 20.365667, 26.515232,
13.012708, 7.710178, 6.731884, 6.873468, 13.216107, 8.248941,
12.667134, 7.967476, 13.450384, 4.469243, 6.016051, 20.221312,
9.978077, 8.125063, 6.054654, 17.886531, 16.911314, 14.872607,
18.379769, 13.280178, 13.173737, 16.163359, 7.180439, 7.067153,
5.78097, 9.115078, 11.401236, 13.672157, 7.67733, 9.121578, 9.53306,
9.169626, 10.399597, 9.929665, 13.432182, 21.290884, 11.990955,
7.629396, 11.871206, 7.8844, 13.096837, 17.530286, 15.16868,
23.066559, 24.500176, 21.301399, 19.780404, 10.435753, 17.164999,
10.730105, 10.39671, 21.078079, 10.896736, 12.381213, 17.814773,
10.77259, 12.325191, 14.441106, 13.372432, 12.20334, 2.267116,
7.004822, 6.484815, 6.160732, 11.205868, 17.221174, 12.932672,
15.424868, 13.584568, 9.045232, 9.253143, 4.746712, 5.356391,
7.956635, 15.78769, 15.203057, 21.611717, 13.938919, 10.338719,
14.906831, 12.02256, 8.323146, 5.962648, 12.607288, 8.366664,
11.722606, 13.118021, 13.167657, 23.943211, 15.73205, NA, NA,
NA, 19.458806, 13.905096, 22.780715, 28.207544, 16.330735, 10.908304,
13.027756, 18.055168, 18.981838, 14.758766, 22.892374, 15.730101,
4.159135, 6.782227, 8.725889, 16.589754, 16.98659, 14.466077,
9.835424, 5.603747, 7.533586, 7.258124, 3.757233, 6.975397, 16.506639,
22.993903, 22.146121, 32.453523, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 8.874777, 5.274195, 8.771376, NA, 13.485412, 21.698904,
27.922464, 16.498973, 28.762024, 23.60364, 24.60113, 27.767211,
31.555646, 31.960224, 12.792771, 11.874074, 25.523096, 36.005253,
37.642116, 43.185004, 26.004919, 30.18264, 25.999374, NA, 32.056592,
37.521471, 38.501752, 43.199343, 47.116269, 39.203263, 45.309426,
26.376231, 25.090029, 35.950189, 33.532655, 28.406965, 24.936877,
32.878943, 26.889793, 24.207449, 31.056998, 29.679594, 36.303335,
28.31691, 35.54293, 18.791613, 17.165094, 31.426778, 26.191531,
33.661524, NA, 18.94205, 8.852177, 20.852655, 22.10272, 17.050833,
18.940024, NA, NA, NA, NA, 22.335409, 23.47458, 12.399243, 23.636525,
NA, 21.434094, 22.799834, 23.083384, 17.963889, 9.915422, 20.821297,
35.158618, 35.247528, 33.416598, 35.369512, 34.734347, 40.436504,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 36.207926, 33.685805, 30.957001,
37.630453, 42.27948, 46.808245, 31.737096, 53.81515, 18.27784,
33.830545, 50.393628, 42.016389, 36.003148, 36.643481, 47.376107,
36.050758, 26.756718, 19.165313, 8.837838, 18.859527, 32.150087,
24.903609, 16.42232, 28.227237, 32.079918, 27.3481, NA, 33.219278,
33.551203, 35.606984, 38.398312, 45.264114, 41.581028, 24.478762,
50.790748, 32.137279, 39.643216, 28.691853, 42.126903, 33.707412,
27.494751, 26.748115, 38.457202, 37.951861, 17.364936, 32.06137,
26.519822, 41.503974, 46.908624, 30.394106, 47.184144, 35.195138,
39.95927, 41.872991, 38.210744, 27.324773, 30.350131, 52.469295,
34.62326, 32.508014, 33.325587, 29.8272, 31.795985, NA, 51.978294,
38.143252, 29.89106, 42.116386, 36.054773, 32.849115, 18.242602,
18.520913, 29.982071, 26.920768, 27.383854, 21.16106, 9.234787,
NA, 36.617475, 12.935865, 18.385505, 25.670893, 26.499172, 23.917398,
18.786183, 8.155483, 13.224367, 4.103037, 22.595824, 28.268346,
26.41122, 17.739975, 26.06706, 24.139574, 28.397405, 30.879564,
24.112995, 10.538676, 9.012384, 14.210404, 24.614131, 33.060392,
24.914316, 33.322334, 27.921317, 35.113113, 26.507393, 14.22918,
7.30602, 37.749187, 43.352686, 34.664751, 33.116411, 40.646825,
32.890795, 30.315907, 37.905017, 43.562624, 40.983335, 28.682102,
34.585785, 26.711978, 33.635901, 32.167869, 39.401156, 41.840677,
46.413608, 31.613008, 28.768333, 27.468747, 19.921701, 16.148044,
23.349917, 19.946367, 22.412272, 27.136632, 17.069591, 21.201786,
35.533755, 35.117128, 25.738005, 20.21309, 12.068008, 10.685154,
24.855044, 18.835436, 12.114451, 6.274859, 9.588431, 18.601217,
27.243322, 27.039121, 28.688985, 27.590541, 15.86111, 28.251711,
27.363969, 22.524697, 34.540087, 32.924065, 14.335373, 15.010271
)), class = "data.frame", row.names = c(NA, -468L))
</code></pre>
| [
{
"answer_id": 74315852,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 2,
"selected": true,
"text": "'video' => 'video|mimes:m4v,avi,flv,mp4,mov',\n"
},
{
"answer_id": 74315864,
"author": "Ramil Huseynov",
"author_id": 6711823,
"author_profile": "https://Stackoverflow.com/users/6711823",
"pm_score": 0,
"selected": false,
"text": "\n public function store(Request $request) {\n $video = new Video();\n $request->validate([\n 'title' => 'required|max:68',\n 'description' => 'required|max:256',\n 'image' => 'image|mimes:jpeg,png,jpg,webp|max:2048',\n 'video' => 'mimes:m4v,avi,flv,mp4,mov',\n ]);\n \n if($request->image) { \n $title = uniqid().'.'.$request->image->extension();\n $request->image->move(public_path('video/images'), $title);\n $video->image = $title; \n } \n \n if($request->video) { \n $title = uniqid().'.'.$request->video->extension();\n $request->video->move(public_path('video/videos'), $title);\n $video->video = $title; \n } \n \n $video->title = $request->title; \n $video->description = $request->description; \n $video->save();\n \n return redirect()->route('videos.list')->with('Success','video created successfully!');\n \n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20356960/"
] |
74,315,881 | <p>I have created a fitted surface from x, y, z data points. How do I insert <code>data tips</code> for the min and max value in the chart?</p>
<pre><code>defDM_fit = fit([def_X, def_Y],def_Z,'cubicinterp');
clf;
figure(2)
plot(defDM_fit,[def_X, def_Y],def_Z);
</code></pre>
<p>using the following test code is raising an error "<em>Invalid argument. The object has been deleted or does not support data tips</em>":</p>
<pre><code>datatip(defDM_fit, def_X(1), def_Y(1), def_Z(1))
</code></pre>
<p>And I do not know how to manage that tips show up at min and max value in the chart by code.</p>
<p><a href="https://i.stack.imgur.com/kcL6t.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kcL6t.jpg" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74316580,
"author": "Ander Biguri",
"author_id": 1485872,
"author_profile": "https://Stackoverflow.com/users/1485872",
"pm_score": 2,
"selected": false,
"text": "datatip"
},
{
"answer_id": 74316997,
"author": "BillBokeey",
"author_id": 4383032,
"author_profile": "https://Stackoverflow.com/users/4383032",
"pm_score": 3,
"selected": true,
"text": "fit"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1867590/"
] |
74,315,935 | <p>I need to convert a vector of complex numbers into a JSON array using the <a href="https://github.com/nbsdx/SimpleJSON" rel="nofollow noreferrer">SimpleJSON</a> library.<br>
Next, I will be passing my complex vector over the socket in JSON format.<br>
But SimpleJSON doesn't know how to work with vectors.<br></p>
<p>SimpleJSON's code is quite complex for me.... there are a lot of variadic templates.<br>
How should I change the <a href="https://github.com/nbsdx/SimpleJSON/blob/master/json.hpp" rel="nofollow noreferrer">code in SimpleJSON</a> so that I can convert my complex vector to JSON format:<br></p>
<pre><code>#include "json.hpp"
#include <iostream>
#include <complex>
int main() {
struct {
std::vector<std::complex<double>> Data;
} MESSAGE;
MESSAGE.Data = {{-3.2, 0.24}, {0.94, -9.3}};
}
</code></pre>
<p>I expect this JSON format</p>
<pre><code>{
"Data" : [ {"re": x, "im": y}, {"re": x, "im": y} ]
}
</code></pre>
| [
{
"answer_id": 74316580,
"author": "Ander Biguri",
"author_id": 1485872,
"author_profile": "https://Stackoverflow.com/users/1485872",
"pm_score": 2,
"selected": false,
"text": "datatip"
},
{
"answer_id": 74316997,
"author": "BillBokeey",
"author_id": 4383032,
"author_profile": "https://Stackoverflow.com/users/4383032",
"pm_score": 3,
"selected": true,
"text": "fit"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20251832/"
] |
74,315,940 | <p>I am trying to send email from Excel, which send attachment using pivot table range saved in Data sheet from A2 and gets dynamic every day. but i am getting error as obejct does not support this method. getting error at "TO" field</p>
<pre><code>Sub emailtest()
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As String
Dim rngSubject As String
Dim rngBody As String
Dim LastRow As Long
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
Sheets("Data").Select
LastRow = Worksheets("Data").Range("A" & Rows.Count).End(xlUp).Row
With objMail
.To = Worksheets("Data").Range("A2: A" & LastRow - 1)
.Subject = "Sell Fail Trade"
.Body = "Please find today's sell report"
.Attachments.Add "C\Temp Folder"
.Display 'Instead of .Display, you can use .Send to send the email _
or .Save to save a copy in the drafts folder
End With
Set objOutlook = Nothing
Set objMail = Nothing
End Sub
</code></pre>
<p>Can someone please help me to fix the error.</p>
| [
{
"answer_id": 74316239,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 0,
"selected": false,
"text": "To"
},
{
"answer_id": 74316656,
"author": "FunThomas",
"author_id": 7599798,
"author_profile": "https://Stackoverflow.com/users/7599798",
"pm_score": 1,
"selected": false,
"text": "To"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11773981/"
] |
74,315,973 | <p>I would like to transform a dataframe into a feature matrix (actually, I'm not sure it is called a feature matrix).</p>
<pre><code>df = pd.DataFrame({'Car': ['Audi', 'Toyota', 'Chrysler', 'Toyota', 'Chrysler', 'Chrysler'],
'Color': ['red', 'red', 'blue', 'silver', 'blue', 'silver']})
</code></pre>
<pre><code> Car Color
0 Audi red
1 Toyota red
2 Chrysler blue
3 Toyota silver
4 Chrysler blue
5 Chrysler silver
</code></pre>
<p>I would like to create a matrix with cars and colors as index and columns where a <code>True</code>, or 1 shows a possible combination like follows:</p>
<pre><code> Color Audit Chrysler Toyota
0 blue 0 1 0
1 red 1 0 1
2 silver 0 1 1
</code></pre>
<p>I can create a matrix and then iterate over the rows and enter the values, but this takes quite long. Is there a better way to create this matrix?</p>
<p>Kind regards,
Stephan</p>
| [
{
"answer_id": 74316239,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 0,
"selected": false,
"text": "To"
},
{
"answer_id": 74316656,
"author": "FunThomas",
"author_id": 7599798,
"author_profile": "https://Stackoverflow.com/users/7599798",
"pm_score": 1,
"selected": false,
"text": "To"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20358971/"
] |
74,315,982 | <ul>
<li>Wordpress 4.0.6</li>
<li>XAMPP 1.8.2 [Apache 2.4.4, MySQL 5.5.32, PHP 5.4.25, phpMyAdmin 4.0.4] or AMPPS 2.7</li>
<li>Theme: Directory 4.18 By AitThemes</li>
</ul>
<p>I'm working on a backup of an old site from early 2015, however I'm getting the error below. Everything works fine except when I try to load/live view the site content.</p>
<p>The specific file changes depending on what content I try to view. post, category, image-page etc</p>
<p>How do I fix this?</p>
<p><strong>When trying to view home page:</strong></p>
<p><code>Fatal error: Class 'WpLatte' not found in E:\xampp\htdocs\xite\wp-content\themes\directory\page-dir-home.php on line 14</code></p>
<p>Line 14 to 19:</p>
<pre><code>$latteParams['post'] = WpLatte::createPostEntity(
$GLOBALS['wp_query']->post,
array(
'meta' => $GLOBALS['pageOptions'],
)
);
</code></pre>
<p><strong>- e.g. When trying to view a post.</strong> <code>Fatal error: Class 'WpLatte' not found in E:\xampp\htdocs\xite\wp-content\themes\directory\single.php on line 2</code></p>
<p>Entire code of single.php:</p>
<pre><code><?php
$latteParams['post'] = WpLatte::createPostEntity(
$GLOBALS['wp_query']->post,
array(
'meta' => $GLOBALS['pageOptions'],
)
);
ob_start();
comments_template('');
ob_get_clean();
/**
* Fire!
*/
WPLatte::createTemplate(basename(__FILE__, '.php'), $latteParams)->render();
</code></pre>
<p><strong>- e.g. When trying to view a category.</strong> <code>Fatal error: Class 'WpLatteCategoryEntity' not found in E:\xampp\htdocs\xite\wp-content\themes\directory\category.php on line 10</code></p>
<p>Entire code of category.php. Line 10 starts $latteParams['category'] = new</p>
<pre><code><?php
/**
* AIT WordPress Theme
*
* Copyright (c) 2012, Affinity Information Technology, s.r.o. (http://ait-themes.club)
*/
$latteParams['category'] = new WpLatteCategoryEntity($wp_query->queried_object);
$latteParams['posts'] = WpLatte::createPostEntity($wp_query->posts);
WPLatte::createTemplate(basename(__FILE__, '.php'), $latteParams)->render();
</code></pre>
| [
{
"answer_id": 74316239,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 0,
"selected": false,
"text": "To"
},
{
"answer_id": 74316656,
"author": "FunThomas",
"author_id": 7599798,
"author_profile": "https://Stackoverflow.com/users/7599798",
"pm_score": 1,
"selected": false,
"text": "To"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74315982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11678839/"
] |
74,316,021 | <p>I have a ZULU timestamp that I have to convert into Paris time zone.</p>
<pre class="lang-none prettyprint-override"><code>ZULU 2022-11-04T06:10:08.606+00:00 --> Paris 2022-11-04T07:10:08.606+01:00
</code></pre>
<p>And have to take care of DST for example:
Summer time Hour +2 hour
Winter time Hour +1 hour</p>
<p>I have written the below code which is working as expected on the local but when deploy on the server (Paris) not working as expected.</p>
<pre class="lang-java prettyprint-override"><code>import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Locale;
public class ParisTime {
public static void main(String[] args) throws ParseException {
// String date = "2022-05-31T23:30:12.209+00:00";
String date = "2022-11-04T06:10:08.606+00:00";
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.ENGLISH);
LocalDateTime dateTime = dateFormat.parse(date).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
ZonedDateTime of = ZonedDateTime.of(dateTime, ZoneId.of("Europe/Paris"));
String hourDiff = of.toString().substring(of.toString().indexOf('+') + 1, of.toString().indexOf('+') + 3);
String zonedDateTime = of.plusHours(Integer.valueOf(hourDiff)).toString();
String newDatetime = zonedDateTime.substring(0, of.toString().indexOf('['));
System.out.println(newDatetime);
System.out.println(dateFormat.parse(newDatetime));
}
}
</code></pre>
<p>Output</p>
<pre class="lang-none prettyprint-override"><code>2022-11-04T07:10:08.606+01:00
Fri Nov 04 07:10:08 IST 2022
</code></pre>
| [
{
"answer_id": 74316503,
"author": "deHaar",
"author_id": 1712135,
"author_profile": "https://Stackoverflow.com/users/1712135",
"pm_score": 4,
"selected": true,
"text": "java.time"
},
{
"answer_id": 74317219,
"author": "Abra",
"author_id": 2164365,
"author_profile": "https://Stackoverflow.com/users/2164365",
"pm_score": 2,
"selected": false,
"text": "parse"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5023024/"
] |
74,316,090 | <p>Hello in my laravel application i have a moment when the user is notified on mail when tha order is complete.</p>
<p>`
In my controller i have:</p>
<pre><code>Mail::to('test@mail')->send(new OrderSuccess($id));
// $id is a string
</code></pre>
<p>in mail.php</p>
<pre><code><?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class OrderSuccess extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $order_id;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($order_id)
{
$this->order_id = $order_id;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('mails.ordermail')
->with([
'order_id' => $this->order_id
]);
}
}
</code></pre>
<p>In mail blade template:</p>
<pre><code>Test order n. {{ $order_id }}
</code></pre>
<p>But i'm getting a failed job that shows this error</p>
<p>ErrorException: Undefined variable $order_id in C:\Users...</p>
<p>What am i doing wrong?</p>
<p>`</p>
| [
{
"answer_id": 74316503,
"author": "deHaar",
"author_id": 1712135,
"author_profile": "https://Stackoverflow.com/users/1712135",
"pm_score": 4,
"selected": true,
"text": "java.time"
},
{
"answer_id": 74317219,
"author": "Abra",
"author_id": 2164365,
"author_profile": "https://Stackoverflow.com/users/2164365",
"pm_score": 2,
"selected": false,
"text": "parse"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299680/"
] |
74,316,095 | <p>Is there a way to publish using ROS1 based ros version in one machine and subscribe to these same topics from another machine that only use ROS2 versions like humble.</p>
<p>Clarification
Machine 1
Version1: ROS1
Distro: Naotic
Publisher Node: Publisher1
Topic: /sampletopic</p>
<p>Machine 2
Version2: ROS2
Distro: Humble
Subscriber Node: Subscriber1
Subscribing to Topic: /sampletopic</p>
<p>It is common to export ros_core_master among ROS1 distros. Couldn't get a way to cross-communicate with ROS1 and ROS2 based publishers and subscribers? It is mainly due to difference in Architecture but there must be some possibility.
Thank you in advance for the insights.</p>
| [
{
"answer_id": 74338767,
"author": "Andyza",
"author_id": 13250503,
"author_profile": "https://Stackoverflow.com/users/13250503",
"pm_score": 1,
"selected": false,
"text": "sudo apt install ros-foxy-ros1-bridge"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5169765/"
] |
74,316,101 | <p>For some reason I have to install a perforce server and I've been trying to automate the installation but I have a stupid issue with the fact that I can't rerun the script a day after as the session expired.</p>
<p>For clarification pupose:</p>
<ul>
<li>I'm installing perforce server on linux, the server is running a debian and I'm following the linux installation (that works) and installing the <code>helix-p4d</code> package.</li>
<li>Following that I'm configuring the server using the /opt/perforce/sbin/configure-helix-p4d.sh script and passing the parameters as option to the script.</li>
<li>I then follow the security recommandation of perforce for the installation: <a href="https://www.perforce.com/manuals/p4sag/Content/P4SAG/chapter.security.html" rel="nofollow noreferrer">https://www.perforce.com/manuals/p4sag/Content/P4SAG/chapter.security.html</a></li>
</ul>
<p>All the command below are executed on the perforce server.</p>
<p>I've done some reading and some suggest to create a ticket with no expiration using this command:</p>
<pre><code>p4 login -a -p
</code></pre>
<p>I tried and got the tickets string to use for connection:</p>
<pre><code>p4 -P STRING login
</code></pre>
<p>And I got asked the password... I don't really understand what I'm doing wrong there and I don't know how to check the ticket expiration date.</p>
<p>I tried other simpler things like:</p>
<ul>
<li>setting the P4PASSWD variable using <code>p4 set P4PASSWD=PASSWORD</code> , that doesn't seem to be working anymore, the value is not visible when doing a <code>p4 set -s</code></li>
<li>setting the P4PASSWD variable directly in $HOME/p4enviro file... the value appears in <code>p4 set -s</code> but <code>p4 login</code> still asks for the password.</li>
</ul>
<p>I would really like to have the ticket thing working with no time of expiration but at this point I will take anything that prevents the password from being asked...</p>
<p>Does anyone knows how to set the password or tickets for it to work?</p>
<p>EDIT:</p>
<p>I also tried to change the security parameter of the perforce configuration to not require the ticket auth as in parameters 3/4 (default value) and tried the values for compatibility but I still can't set the P4PASSWD.</p>
| [
{
"answer_id": 74318582,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "p4 login"
},
{
"answer_id": 74319346,
"author": "Jase Lindgren",
"author_id": 11645951,
"author_profile": "https://Stackoverflow.com/users/11645951",
"pm_score": 2,
"selected": true,
"text": "p4 login -a -p"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6588456/"
] |
74,316,125 | <p>I have got two ggplots, of which I want the size of the grey area to be exactly equal.</p>
<p>Now by playing around I can get very close by setting first plot width to 12 and second plot width to 14.</p>
<pre><code>ggsave(filename="test1.png", myPlot, width = 12, height =12, dpi=300, units="cm", device='png')
ggsave(filename="test2.png", myPlot, width = 14, height =12, dpi=300, units="cm", device='png')
</code></pre>
<p><a href="https://i.stack.imgur.com/o7IV6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o7IV6.png" alt="enter image description here" /></a></p>
<p>My question is whether I can pull some variable(s) from the first plot, so that I can automatically compute the right width for the second plot (ie, the width that makes the grey areas identical in size).</p>
| [
{
"answer_id": 74318582,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "p4 login"
},
{
"answer_id": 74319346,
"author": "Jase Lindgren",
"author_id": 11645951,
"author_profile": "https://Stackoverflow.com/users/11645951",
"pm_score": 2,
"selected": true,
"text": "p4 login -a -p"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2071794/"
] |
74,316,131 | <p>sI have a livewire form with an address field that has google places autocomplete enabled on it. Every time I select an address from the autocomplete list and move to a new input in the form the address input gets reset to the value before clicking the address I wanted.</p>
<p>I added wire:ignore on my field and it still gets reset to the value typed in before the click event. This is my code for the input:</p>
<pre><code><div wire:ignore id="for-input-address" class="form-group col-lg-6{{ $errors->has('address') ? ' has-danger' : '' }}">
<label class="form-control-label" for="input-address">{{ __('Home address') }}</label>
<input wire:model="address" type="text" name="address" id="input-address" class="form-control form-control-alternative{{ $errors->has('address') ? ' is-invalid' : '' }}" placeholder="{{ __('Home address') }}" value="{{ old('address') }}" required autofocus>
@if ($errors->has('address'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('address') }}</strong>
</span>
@endif
</div>
</code></pre>
<p>So if I type 56 and select the address the moment I move to the next field the input gets reset to 56.</p>
<p>I want to say I have some select fields with wire:ignore that work just fine when livewire reloads the DOM.</p>
| [
{
"answer_id": 74318582,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "p4 login"
},
{
"answer_id": 74319346,
"author": "Jase Lindgren",
"author_id": 11645951,
"author_profile": "https://Stackoverflow.com/users/11645951",
"pm_score": 2,
"selected": true,
"text": "p4 login -a -p"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1326160/"
] |
74,316,176 | <p>I have following data:</p>
<pre><code>value = [["time1", "client1", None, "username1"], ["time2", "client1", "event1", "username1"], ["time3", "client1", None, "username2"], ["time4", "client2", None, "username3"], ["time5", "client2", "event2", "username4"], ["time6", "client3", None, "username5"]]
columns = ["timestamp", "clients", "events", "usernames"]
df = pd.DataFrame(value, columns=columns)
</code></pre>
<p>The DataFrame looks like:</p>
<pre><code>timestamp clients events usernames
0 time1 client1 None username1
1 time2 client1 event1 username1
2 time3 client1 None username2
3 time4 client2 None username3
4 time5 client2 event2 username4
5 time6 client3 None username5
</code></pre>
<p>I want to realize following calculation:</p>
<pre><code>df.groupby("clients").agg(**{
"total_records": ("timestamp", "size"),
"unique_users": ("usernames", "nunique"),
"without_events_records": ("events", lambda x: x.notnull().mean()),
# "without_events_users": add calculation without events per unique username
})
</code></pre>
<p>How can I do the aggregation in the comment row?</p>
| [
{
"answer_id": 74318582,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "p4 login"
},
{
"answer_id": 74319346,
"author": "Jase Lindgren",
"author_id": 11645951,
"author_profile": "https://Stackoverflow.com/users/11645951",
"pm_score": 2,
"selected": true,
"text": "p4 login -a -p"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15597400/"
] |
74,316,178 | <p>I want to run both react and node on single server because i don't want to start it together.
like when i run npm start both will be run because i want to run project using electronjs.</p>
<p>I tried to run command <code>npm start client.js server.js</code> but it didn't work</p>
| [
{
"answer_id": 74316247,
"author": "Moussa Bistami",
"author_id": 15628525,
"author_profile": "https://Stackoverflow.com/users/15628525",
"pm_score": -1,
"selected": false,
"text": "3000"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19380618/"
] |
74,316,179 | <p>Context:<br />
I'm building a app that can plot graph structures in electron with react. My backend is some Matlab code that can perform analysis on the graph struct. I'm using flask as the middle man communicating between them.</p>
<p>In the GUI i have a button that should be able to load the data that is provided in a excel file to the GUI. This should be done by a post request that uses a matlab script to load the data from the excel file and then returns this to javascript.</p>
<p>I have tried using something like this:</p>
<pre><code>
fetch('http://localhost:5000/getGriddata', {
method : 'POST',
headers : {
'Content-Type' : 'application/json'
},
body : JSON.stringify(fileObj.path)
}).then(response => response.json())
.then(data => setGriddata(data))
.catch(error => console.log(error));
</code></pre>
<p>The problem is that this code won't wait for the flask function to be finished. The flask function takes about 10 seconds depending on the graph size. Therefor i want to make this call in sync with my javascript code so that after the request, i can assure that the new griddata is defined.</p>
<p>Question:<br />
Is there some way to ensure this when using fetch?<br />
Do i need to find a different way of connecting to flask, if so what would that be?</p>
| [
{
"answer_id": 74316462,
"author": "Bhagya Mudgal",
"author_id": 18245194,
"author_profile": "https://Stackoverflow.com/users/18245194",
"pm_score": 1,
"selected": false,
"text": "const fetchGridData = async () => {\n try {\n const response = await fetch('http://localhost:5000/getGriddata', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(fileObj.path)\n });\n\n const result = await response.json();\n\n setGriddata(result)\n } catch(error) {\n console.error(\"fetchGridData =>\", error)\n }\n}\n"
},
{
"answer_id": 74319814,
"author": "1Pre",
"author_id": 20416697,
"author_profile": "https://Stackoverflow.com/users/20416697",
"pm_score": 3,
"selected": true,
"text": "var request = new XMLHttpRequest();\nrequest.open(\"POST\",'http://localhost:5000/getGriddata',false);\nrequest.setRequestHeader('content-type', 'application/json');\nrequest.send(JSON.stringify(fileObj.path));\nconsole.log(request.response)\nconsole.log(request.responseText)\nsetGriddata(JSON.parse(request.responseText))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20416697/"
] |
74,316,183 | <p>i have this input component:</p>
<p><a href="https://i.stack.imgur.com/NPv1s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NPv1s.png" alt="enter image description here" /></a></p>
<p>I want to change the style of input component if the value of input is less than the current year.
for example, if the user entered 2020 which is less than 2022, in this case i want to change the color of background for example.
Any help will be appreciated</p>
<p>A function will be called to check the entered value and whether we need to change the style or not:</p>
<pre><code>let changeStyle=false;
const checkExpireYear = (year: string) => {
// converting the entered year to number
let enteredYear: number = parseInt(year);
// getting the current year
const date = new Date();
let currentYear = date.getFullYear();
// checking if the entered year is less than the current year
// based on this condition the style will be changed
if (enteredYear > currentYear) {
console.log("valid year");
changeStyle = false;
} else {
console.log("unvalid year");
changeStyle = true;
}
};
</code></pre>
<p>and this is my input component :</p>
<pre><code><CardNumberInput
className={changeStyle ? "bg-red-400" : ""}
placeholder="2030"
onChange={(e) => {
if (e.currentTarget.value.length > 3) {
checkExpireYear(e.currentTarget.value);
}
}}
/>
</code></pre>
<p>it does not show any error, but the style is not changing<br />
Thanx in advance</p>
| [
{
"answer_id": 74316294,
"author": "Bhagya Mudgal",
"author_id": 18245194,
"author_profile": "https://Stackoverflow.com/users/18245194",
"pm_score": 2,
"selected": false,
"text": "useState"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18446878/"
] |
74,316,233 | <p>Just getting to learn C better and I'm playing with arrays.</p>
<p>I would like to enter my phone number into an array like this:</p>
<pre><code>#include <stdio.h>
int main()
{
int phoneNum[10];
for (int i = 0; i < sizeof(phoneNum); i++) {
printf("Insert digit %d of your phone number: \n", i + 1);
scanf("%d", &phoneNum[i]);
}
return 0;
}
</code></pre>
<p>This seems to fail as it keeps asking me for a new digit. So I tried to print the size of the array:</p>
<pre><code>int phoneNum[10];
printf("%lu", sizeof(phoneNum));
</code></pre>
<p>which incredibly gives me the result of 40 even though I initialized it to be 10 (?).
I have three questions:</p>
<ol>
<li>Why is the result 40 and not 10 in <code>sizeof(phoneNum)</code> ?</li>
<li>How can I add elements in an array successfully with <code>scanf</code> in the above manner?</li>
<li>If the above manner is silly, is there a better, more efficient way to do this? For example directly enter 10 digits into an array? I can of course use <code>scanf("%d%d%d...", digit1, digit2, digit3, ...)</code> but I would like a generalized way, using the size of the array (say I don't know it and it's passed from another function)</li>
</ol>
| [
{
"answer_id": 74316457,
"author": "embedded4ever",
"author_id": 8647388,
"author_profile": "https://Stackoverflow.com/users/8647388",
"pm_score": 2,
"selected": false,
"text": "sizeof(phoneNum)"
},
{
"answer_id": 74318687,
"author": "I NN_",
"author_id": 12658756,
"author_profile": "https://Stackoverflow.com/users/12658756",
"pm_score": 0,
"selected": false,
"text": "sizeof(phoneNum)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11770144/"
] |
74,316,241 | <p>this my laravel Task Controller</p>
<pre><code><?php
namespace App\Http\Controllers;
use App\Models\task;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
class TaskController extends Controller
{
public function getTask()
{
$userid= Auth::user()->id;
$response = task::where('id_karyawan',$userid)->get();
return response()->json($response,200);
}
}
</code></pre>
<p>but i get this error when i try it in postman. please help me to clear this error thanks</p>
<pre><code>ErrorException: Trying to get property 'id' of non-object in file C:\Users\Lenovo\BackendBSIMonitoring\app\Http\Controllers\TaskController.php on line 37
</code></pre>
| [
{
"answer_id": 74316457,
"author": "embedded4ever",
"author_id": 8647388,
"author_profile": "https://Stackoverflow.com/users/8647388",
"pm_score": 2,
"selected": false,
"text": "sizeof(phoneNum)"
},
{
"answer_id": 74318687,
"author": "I NN_",
"author_id": 12658756,
"author_profile": "https://Stackoverflow.com/users/12658756",
"pm_score": 0,
"selected": false,
"text": "sizeof(phoneNum)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20367393/"
] |
74,316,269 | <p>I would like to test some dash plotly UI functions with cypress but I have some problems with ids based on dash <a href="https://dash.plotly.com/pattern-matching-callbacks#simple-example-with-match" rel="nofollow noreferrer">Pattern Matching</a>, e.g.:</p>
<img src="https://i.stack.imgur.com/f1TmCm.png" width="800" />
<p>Trying to use the id, as found in the DOM, I get the following error:</p>
<p><a href="https://i.stack.imgur.com/qSzFom.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qSzFom.png" alt="enter image description here" /></a></p>
<p>I've tried the test with the following sytax:</p>
<pre class="lang-js prettyprint-override"><code>cy.get('[id="{"index":0,"type":"dynamic-dropdown"}"]').should('exist')
</code></pre>
<pre class="lang-js prettyprint-override"><code>cy.get('[id={"index":0,"type":"dynamic-dropdown"}]').should('exist')
</code></pre>
<p>EDIT:</p>
<p>I've also found this based on the browser developer mode, which will not throw a syntax error but the element can not be found:</p>
<pre class="lang-js prettyprint-override"><code>cy.get('[id="{&quot;index&quot;:0,&quot;type&quot;:&quot;dynamic-dropdown&quot;}"]').should('exist')
</code></pre>
| [
{
"answer_id": 74319362,
"author": "Rene",
"author_id": 9620269,
"author_profile": "https://Stackoverflow.com/users/9620269",
"pm_score": 0,
"selected": false,
"text": "cy.get(\"\")"
},
{
"answer_id": 74322278,
"author": "Fody",
"author_id": 16997707,
"author_profile": "https://Stackoverflow.com/users/16997707",
"pm_score": 1,
"selected": false,
"text": "cy.get('.dash-dropdown')\n .then($el => console.log('attributes', $el[0].attributes))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9620269/"
] |
74,316,302 | <p>So I created a sidebar wherein i have different links, such as <code>orders, users, products</code>. So, when I click fast at a different URL, I get an error. I also create a loading state so every time the URL changes, it reloads. But this most happened when I click on to <strong>order</strong> link. I also tried to put optional chaining inside the columns.</p>
<p>Should I also put a loading state in app.js? which is mostly consist of route?</p>
<p>The column came from the App.js</p>
<p>List.jsx</p>
<pre><code>const List = ({columns}) => {
const location = useLocation()
const id = location.pathname.split('/')[1]
const [loading,setLoading] = useState(true)
const [data,setData] = useState([])
useEffect(() =>{
const getData = async () =>{
try {
const res = await userRequest.get(`/${id}`)
setData(res.data)
setLoading(false)
} catch (error) {
}
}
getData()
},[id, data, columns])
return (
<>
{loading ? (
<BeatLoader
color="#36d7b7"
loading={loading}
size={50}
aria-label="Loading Spinner"
data-testid="loader"
/>
) : (
<div className="list">
<Sidebar/>
<div className="listContainer">
<Navbar/>
<Datatable columns={columns} data={data} setData={setData}/>
</div>
</div>
)}
</>
)
}
export default List
</code></pre>
<p>Datatable.jsx</p>
<pre><code>const Datatable = ({data,setData, columns}) => {
const [loading, setLoading] = useState(true)
//const [data, setData] = useState(userRows);
useEffect(() => {
setLoading(false)
},[data, setData, columns])
const handleDelete = (id) => {
setData(data.filter((item) => item.id !== id));
};
const actionColumn = [
{
field: "action",
headerName: "Action",
width: 200,
renderCell: (params) => {
return (
<div className="cellAction">
<Link to="/users/test" style={{ textDecoration: "none" }}>
<div className="viewButton">View</div>
</Link>
<div
className="deleteButton"
onClick={() => handleDelete(params.row._id)}
>
Delete
</div>
</div>
);
},
},
];
return (
<div className="datatable">
<div className="datatableTitle">
<div className="search">
<input type="text" placeholder="Search..." />
<SearchOutlinedIcon />
</div>
</div>
{loading ? (
<BeatLoader
color="#36d7b7"
loading={loading}
size={50}
aria-label="Loading Spinner"
data-testid="loader"
/>
): (
<DataGrid
className="datagrid"
rows={data}
getRowId={(row) => row._id}
columns={columns.concat(actionColumn)}
pageSize={9}
rowsPerPageOptions={[9]}
checkboxSelection
/>
)}
</div>
);
};
export default Datatable;
</code></pre>
<p>This is the error I'm receiving, it came from the products[0]</p>
<p><a href="https://i.stack.imgur.com/pNgW7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pNgW7.png" alt="enter image description here" /></a></p>
<p>column.js</p>
<pre><code>export const orderColumn = [
{field: "_id", headerName: "Transaction", width: 220},
{
field: "buyerId",
headerName: "Buyer ID" ,
width: 150,
renderCell: (params) => {
return (
<div className="cellWithImg">
{params.row?.userId?.studentId}
</div>
)
},
},
{
field: "amount",
headerName:"Price" ,
width: 150,
renderCell: (params) => {
return (
<div className="cellWithImg">
{params.row?.amount}
</div>
)
},
},
{
field: "products",
headerName: "Product",
width: 150,
renderCell: (params) =>{
return (
<div className="cellWithImg">
<img className="cellImg" src={params.row?.products[0]?.productId?.img} alt="avatar" />
{params.row?.products[0]?.productId?.title}
</div>
)
}
},
{
field: "seller",
headerName: "Seller",
width: 150,
renderCell: (params) =>{
return (
<div>
{params.row?.products[0]?.sellerId?.studentId}
</div>
)
}
},
{
field: "location and time",
headerName: "Location and Time",
width: 150,
renderCell: (params) =>{
return (
<div >
{params.row?.location} || {params.row?.time}
</div>
)
}
},
{
field: "status",
headerName: "Status",
width: 150,
renderCell: (params) =>{
return (
<div >
{params.row?.status}
</div>
)
}
}
]
</code></pre>
<p><strong>EDIT</strong></p>
<p>Additional Info, this is what I received when I call</p>
<pre><code> {
"_id": "636357777877c919bb2cfa45",
"userId": {
"_id": "636355527877c919bb2cdf22",
"studentId": "1234567891"
},
"products": [
{
"productId": {
"_id": "636355a07877c919bb2cdfdc",
"title": "Cabinet Update Shoe",
"img": "https://firebasestorage.googleapis.com/v0/b/tua-ecom.appspot.com/o/1667454433424%5Bobject%20File%5D?alt=media&token=fb6cd8f1-a204-4a63-bcc2-7de2c93fd544"
},
"quantity": 1,
"sellerId": {
"_id": "636355187877c919bb2cdf1f",
"studentId": "1234567890"
},
"_id": "636357777877c919bb2cfa46"
}
],
"amount": 100,
"location": "Guard House",
"time": "8:00",
"status": "pending",
"tax": 1,
"createdAt": "2022-11-03T05:53:59.997Z",
"updatedAt": "2022-11-03T05:53:59.997Z",
"__v": 0
},
</code></pre>
| [
{
"answer_id": 74316407,
"author": "Apostolos",
"author_id": 1121008,
"author_profile": "https://Stackoverflow.com/users/1121008",
"pm_score": 1,
"selected": false,
"text": "_SOME_PROPERTY[_SOME_INDEX]"
},
{
"answer_id": 74318288,
"author": "Stykgwar",
"author_id": 20088885,
"author_profile": "https://Stackoverflow.com/users/20088885",
"pm_score": 0,
"selected": false,
"text": "const ListOrder = ({columns}) => {\n const location = useLocation()\n const id = location.pathname.split('/')[1]\n const [loading,setLoading] = useState(true)\n const [data,setData] = useState([])\n \n useEffect(() =>{\n const getData = async () =>{\n try {\n const res = await userRequest.get(`/order`)\n setData(res.data)\n setLoading(false)\n } catch (error) {\n \n }\n }\n getData()\n },[id, data, columns])\n\n return (\n <>\n {loading ? (\n <BeatLoader \n color=\"#36d7b7\" \n loading={loading}\n size={50}\n aria-label=\"Loading Spinner\"\n data-testid=\"loader\"\n />\n\n ) : (\n <div className=\"list\">\n <Sidebar/>\n <div className=\"listContainer\">\n <Navbar/>\n <Datatable columns={columns} id={id} data={data} setData={setData}/>\n </div>\n </div>\n )}\n </>\n )\n}\n\nexport default ListOrder\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20088885/"
] |
74,316,322 | <p>The <a href="https://safe-stack.github.io/docs/quickstart/" rel="nofollow noreferrer">SAFE Stack Documentation</a> says to install <strong>npm</strong> (amongst other things) as a pre-requisite to build SAFE apps. But the link refers to <a href="https://www.npmjs.com" rel="nofollow noreferrer">https://www.npmjs.com</a> where you have to search for packages. <strong>But which ones? What to install?</strong> There are thousands of packages there.</p>
<p><strong>UPDATE:</strong>
I have just noticed that the npm documentation says that <em>npm comes bundled with node, & most third-party distributions, by default</em>. So why does the SAFE Stack documentation show the link to npm? Is there any sense in it?</p>
<p>I have tried to install the <strong>npm</strong> package via NuGet. But whatever I do, running the SAFE standard template in VS ends with a NullReferenceException:</p>
<p>File <em>helpers.fs</em></p>
<pre><code>let runOrDefault args =
try
match args with
| [| target |] -> Target.runOrDefault target
| _ -> Target.runOrDefault "Run" //NullReferenceException
0
with e ->
printfn "%A" e
1
</code></pre>
<p>Entering <em>dotnet run</em> through a command prompt opens a console window containing these messages:</p>
<pre><code>Starting target 'InstallClient'
.> "C:\Program Files\nodejs\npm.CMD" install (In: false, Out: false, Err: false)
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: undefined
npm ERR! notsup Not compatible with your version of node/npm: undefined
npm ERR! notsup Required: {"node":"~16","npm":"~8"}
npm ERR! notsup Actual: {"npm":"8.19.2","node":"v19.0.0"}
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Local\npm-cache\_logs\2022-11-04T11_38_04_408Z-debug-0.log
Finished (Failed) 'InstallClient' in 00:00:02.0540071
</code></pre>
<p><strong>UPDATE</strong>:
In line with Tomáš Petříček's recommendation, I installed this version of node.js: <em>Latest LTS Version: 18.12.0 (includes npm 8.19.2)</em></p>
<p>But again, <em>NullReferenceException</em> in VS, and the following error messages appear when using the command prompt:</p>
<pre><code>Starting target 'InstallClient'
.> "C:\Program Files\nodejs\npm.CMD" install (In: false, Out: false, Err: false)
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: undefined
npm ERR! notsup Not compatible with your version of node/npm: undefined
npm ERR! notsup Required: {"node":"~16","npm":"~8"}
npm ERR! notsup Actual: {"npm":"8.19.2","node":"v18.12.0"}
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Local\npm-cache\_logs\2022-11-04T13_19_03_959Z-debug-0.log
Finished (Failed) 'InstallClient' in 00:00:01.9942657
---------------------------------------------------------------------
Build Time Report
---------------------------------------------------------------------
Target Duration
------ --------
Clean 00:00:00.5118885
InstallClient 00:00:01.9937254 (Process exit code '1' <> 0. Command Line: C:\Program Files\nodejs\npm.CMD install)
Run 00:00:00 (skipped)
Total: 00:00:02.6111670
Status: Failure
---------------------------------------------------------------------
Fake.Core.BuildFailedException: Target 'InstallClient' failed.
</code></pre>
| [
{
"answer_id": 74323628,
"author": "Miroslav Husťák",
"author_id": 8910438,
"author_profile": "https://Stackoverflow.com/users/8910438",
"pm_score": 1,
"selected": true,
"text": "cmd"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8910438/"
] |
74,316,379 | <p>so I'm trying to iterate over a char array in c. The Array is defined in a header file like this.</p>
<p><code>char const SEQUENCE[] PROGMEM = "\MdTqZWYzVf5E661OAd4r7ylINBLNEAzO... </code>
the array is well over 1 thousand characters in length.</p>
<p>next I've been told to use the extern key word to bring the array into my main.c file.
this is how I've done that. Not sure if this is totally correct.</p>
<p><code>extern char const SEQUENCE[]; </code></p>
<p>I've tried to loop over the array and pring each individual value like this.</p>
<p><code>for (uint8_t I = 0; I < 64; I++) { printf("%c ", SEQUENCE[I]); } </code></p>
<p>but I got this as an output.</p>
<p>␏ ␀ ␀ ␀ ␀ ␀ ␀ ..</p>
<p>I expected something like.
M d T q ...</p>
<p>can anyone tell me what is going wrong here?</p>
| [
{
"answer_id": 74317267,
"author": "Tenobaal",
"author_id": 18861247,
"author_profile": "https://Stackoverflow.com/users/18861247",
"pm_score": -1,
"selected": false,
"text": "#ifndef INCLUDE_headername_H\n#define INCLUDE_headername_H\n...\nextern const char* SEQUENCE;\n...\n#endif\n"
},
{
"answer_id": 74317891,
"author": "ryyker",
"author_id": 645128,
"author_profile": "https://Stackoverflow.com/users/645128",
"pm_score": 1,
"selected": false,
"text": "uint8_t"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15557228/"
] |
74,316,401 | <p>In the first example, it is understood that <code>num2</code> gets the updated value of <code>num1</code> i.e., <code>4</code>.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let num1 = 2;
num1 = 4;
let num2 = num1;
console.log(num1); // result 4
console.log(num2); // result 4</code></pre>
</div>
</div>
</p>
<p>In the second example, why doesn't <code>lastName</code> get the updated value of ``firstName` i.e, "Henry".</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let firstName = "David";
let lastName = firstName;
firstName = "Henry";
console.log(firstName); // result Henry
console.log(lastName); // result David</code></pre>
</div>
</div>
</p>
<p>Is it due to the order of declaration?</p>
| [
{
"answer_id": 74316450,
"author": "T.J. Crowder",
"author_id": 157247,
"author_profile": "https://Stackoverflow.com/users/157247",
"pm_score": 2,
"selected": true,
"text": "num2 = num1;"
},
{
"answer_id": 74316451,
"author": "Jean-Baptiste Yunès",
"author_id": 719263,
"author_profile": "https://Stackoverflow.com/users/719263",
"pm_score": 0,
"selected": false,
"text": "let lastName = firstName"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19391190/"
] |
74,316,432 | <p>can someone please tell me why the 3rd div is looking that way instead of being right under the 1st div? And what would I need to write in my CSS file to make the 3rd div positioned right under the 1st one?
<a href="https://i.stack.imgur.com/uxW9V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uxW9V.png" alt="enter image description here" /></a></p>
<p>This is the HTML:</p>
<pre class="lang-html prettyprint-override"><code><div class="div-main">
<div class="div-1">
1
</div>
<div class="div-2">
2
</div>
<div class="div-3">
3
</div>
</div>
</code></pre>
<p>This is the CSS:</p>
<pre class="lang-css prettyprint-override"><code>.div-main {
border: 5px solid yellow;
padding: 15px;
}
.div-1 {
border: 1px solid black;
padding: 15px;
width: 30%;
height: 30vh;
display: inline-block;
}
.div-2 {
border: 1px solid black;
padding: 15px;
width: 69%;
height: 50vh;
display: inline-block;
}
.div-3 {
border: 1px solid black;
padding: 15px;
width: 30%;
height: 30vh;
display: inline-block;
}
</code></pre>
| [
{
"answer_id": 74316539,
"author": "SMAKSS",
"author_id": 11908502,
"author_profile": "https://Stackoverflow.com/users/11908502",
"pm_score": 3,
"selected": true,
"text": "block"
},
{
"answer_id": 74316638,
"author": "Adam",
"author_id": 12571484,
"author_profile": "https://Stackoverflow.com/users/12571484",
"pm_score": 1,
"selected": false,
"text": ".div-main {\n border: 5px solid yellow;\n padding: 15px;\n /* this makes a grid layout with 2 columns and as many rows as needed. */\n /* There's only 3 divs so that'll automatically give us 2 rows */\n /* The grid-template-columns property is the width of each column - though there are some qualifications with this */\n display: grid;\n grid-template-columns: 30% 69%;\n}\n\n.div-main>div {\n /* I've moved this to its own rule so you don't need to repeat yourself */\n border: 1px solid black;\n padding: 15px;\n}\n\n.div-1 {\n /* I've kept the height of your original divs */\n height: 30vh;\n}\n\n.div-2 {\n height: 50vh;\n /* setting grid-row: span 2 makes this div use two rows when it's being displayed */\n /* this allows the third div to appear to the left */\n /* in effect there's 4 cells in this grid but the last, bottom right cell is taken up by div-2 as we've told it to span 2 rows */\n grid-row: span 2;\n}\n\n.div-3 {\n height: 30vh;\n}"
},
{
"answer_id": 74317573,
"author": "Mark Schultheiss",
"author_id": 125981,
"author_profile": "https://Stackoverflow.com/users/125981",
"pm_score": 2,
"selected": false,
"text": "group-left"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10367451/"
] |
74,316,444 | <p>I'm creating an app for my company to add a user and group to AD.</p>
<p>I can add the user fine, but struggling to add the user to a group.</p>
<p>I get the following : Exception thrown: <code>'System.DirectoryServices.DirectoryServicesCOMException' in System.DirectoryServices.dll</code></p>
<p>Please help :-D</p>
<p>Here is the code snippet im using to add the user to a group.</p>
<p><code>AdAccountName</code> and <code>GroupStr</code> are variables already populated in prior code not shown below.</p>
<pre><code> try
{
string admin_userName = "administrator";
string admin_password = "password";
string LDAP = "LDAP://192.168.231.128/CN=Users,DC=home,DC=lab";
DirectoryEntry dirEntry = new DirectoryEntry(LDAP + GroupStr, admin_userName, admin_password);
dirEntry.Invoke("add", new object[] {ADAccountNameStr});
dirEntry.CommitChanges();
dirEntry.Close();
}
catch (System.DirectoryServices.DirectoryServicesCOMException E)
{
//doSomething with E.Message.ToString();
}
</code></pre>
| [
{
"answer_id": 74316539,
"author": "SMAKSS",
"author_id": 11908502,
"author_profile": "https://Stackoverflow.com/users/11908502",
"pm_score": 3,
"selected": true,
"text": "block"
},
{
"answer_id": 74316638,
"author": "Adam",
"author_id": 12571484,
"author_profile": "https://Stackoverflow.com/users/12571484",
"pm_score": 1,
"selected": false,
"text": ".div-main {\n border: 5px solid yellow;\n padding: 15px;\n /* this makes a grid layout with 2 columns and as many rows as needed. */\n /* There's only 3 divs so that'll automatically give us 2 rows */\n /* The grid-template-columns property is the width of each column - though there are some qualifications with this */\n display: grid;\n grid-template-columns: 30% 69%;\n}\n\n.div-main>div {\n /* I've moved this to its own rule so you don't need to repeat yourself */\n border: 1px solid black;\n padding: 15px;\n}\n\n.div-1 {\n /* I've kept the height of your original divs */\n height: 30vh;\n}\n\n.div-2 {\n height: 50vh;\n /* setting grid-row: span 2 makes this div use two rows when it's being displayed */\n /* this allows the third div to appear to the left */\n /* in effect there's 4 cells in this grid but the last, bottom right cell is taken up by div-2 as we've told it to span 2 rows */\n grid-row: span 2;\n}\n\n.div-3 {\n height: 30vh;\n}"
},
{
"answer_id": 74317573,
"author": "Mark Schultheiss",
"author_id": 125981,
"author_profile": "https://Stackoverflow.com/users/125981",
"pm_score": 2,
"selected": false,
"text": "group-left"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20416834/"
] |
74,316,461 | <p>so I have to make a function that does binning and counts the different breaks. So what I have for now is:</p>
<pre><code> binfunc <- function(numbers, breaks) {
.bincode(numbers, breaks, right = TRUE, include.lowest = FALSE)
}
</code></pre>
<p>The output for an example vector would be:</p>
<pre><code>numbers1 <- c(20, 70, 14, 30)
breaks1 <- c(youth = 18, adult = 40, elder = Inf)
binfunc(numbers1, breaks1)
[1] 1 2 NA 1
</code></pre>
<p>But what I want to have as an output is the different breaks counted in a vector like:</p>
<pre><code>c(youth = 1, adult = 2, elder = 1)
</code></pre>
<p>Thanks in Advance</p>
| [
{
"answer_id": 74316539,
"author": "SMAKSS",
"author_id": 11908502,
"author_profile": "https://Stackoverflow.com/users/11908502",
"pm_score": 3,
"selected": true,
"text": "block"
},
{
"answer_id": 74316638,
"author": "Adam",
"author_id": 12571484,
"author_profile": "https://Stackoverflow.com/users/12571484",
"pm_score": 1,
"selected": false,
"text": ".div-main {\n border: 5px solid yellow;\n padding: 15px;\n /* this makes a grid layout with 2 columns and as many rows as needed. */\n /* There's only 3 divs so that'll automatically give us 2 rows */\n /* The grid-template-columns property is the width of each column - though there are some qualifications with this */\n display: grid;\n grid-template-columns: 30% 69%;\n}\n\n.div-main>div {\n /* I've moved this to its own rule so you don't need to repeat yourself */\n border: 1px solid black;\n padding: 15px;\n}\n\n.div-1 {\n /* I've kept the height of your original divs */\n height: 30vh;\n}\n\n.div-2 {\n height: 50vh;\n /* setting grid-row: span 2 makes this div use two rows when it's being displayed */\n /* this allows the third div to appear to the left */\n /* in effect there's 4 cells in this grid but the last, bottom right cell is taken up by div-2 as we've told it to span 2 rows */\n grid-row: span 2;\n}\n\n.div-3 {\n height: 30vh;\n}"
},
{
"answer_id": 74317573,
"author": "Mark Schultheiss",
"author_id": 125981,
"author_profile": "https://Stackoverflow.com/users/125981",
"pm_score": 2,
"selected": false,
"text": "group-left"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18463607/"
] |
74,316,484 | <p>I am trying to make a contact form and I need to have a big text box for people to explain their inquiry in detail. Currently I am using:</p>
<pre><code><div class="formField">
<label for="contactType2"> Details about your inquiry </label>
<input type="text"
name="contactType2"
id="contactType"
required></input>
</div>
</code></pre>
<p>But this only shows up as a single line due to the text input being a small box. How do I fix this?</p>
<p>I have tried to look through the other inputs VSC offers but I don't see one that would fix this problem. I also have the pre-written code above</p>
| [
{
"answer_id": 74316539,
"author": "SMAKSS",
"author_id": 11908502,
"author_profile": "https://Stackoverflow.com/users/11908502",
"pm_score": 3,
"selected": true,
"text": "block"
},
{
"answer_id": 74316638,
"author": "Adam",
"author_id": 12571484,
"author_profile": "https://Stackoverflow.com/users/12571484",
"pm_score": 1,
"selected": false,
"text": ".div-main {\n border: 5px solid yellow;\n padding: 15px;\n /* this makes a grid layout with 2 columns and as many rows as needed. */\n /* There's only 3 divs so that'll automatically give us 2 rows */\n /* The grid-template-columns property is the width of each column - though there are some qualifications with this */\n display: grid;\n grid-template-columns: 30% 69%;\n}\n\n.div-main>div {\n /* I've moved this to its own rule so you don't need to repeat yourself */\n border: 1px solid black;\n padding: 15px;\n}\n\n.div-1 {\n /* I've kept the height of your original divs */\n height: 30vh;\n}\n\n.div-2 {\n height: 50vh;\n /* setting grid-row: span 2 makes this div use two rows when it's being displayed */\n /* this allows the third div to appear to the left */\n /* in effect there's 4 cells in this grid but the last, bottom right cell is taken up by div-2 as we've told it to span 2 rows */\n grid-row: span 2;\n}\n\n.div-3 {\n height: 30vh;\n}"
},
{
"answer_id": 74317573,
"author": "Mark Schultheiss",
"author_id": 125981,
"author_profile": "https://Stackoverflow.com/users/125981",
"pm_score": 2,
"selected": false,
"text": "group-left"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19985446/"
] |
74,316,487 | <p>I tried to make a button that displays the hidden content when revealed using bootstrap but it's not working. Any Suggestions</p>
<pre><code><button class="bc2 border-primary bg-primary rounded-2 mt-4 p-1 text-nowrap card-footer text-white" type="button" data-toggle="collapse" data-target="#ho2" aria-expanded="false" aria-controls="ho2">Get Started</button>
<div class="collapse" id="ho2">
<div class="card card-body">
Hello World!
</div>
</div>
</code></pre>
| [
{
"answer_id": 74316703,
"author": "Cervus camelopardalis",
"author_id": 10347145,
"author_profile": "https://Stackoverflow.com/users/10347145",
"pm_score": 2,
"selected": false,
"text": "data-toggle=\"collapse\""
},
{
"answer_id": 74316886,
"author": "Flewz",
"author_id": 20262622,
"author_profile": "https://Stackoverflow.com/users/20262622",
"pm_score": 1,
"selected": true,
"text": "data-bs-*"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20417015/"
] |
74,316,504 | <pre><code>
#include <stdio.h>
int main() {
int a,i,j;
FILE *fp,*fw;
fp=fopen("new.txt", "r");
fw=fopen("exam.txt", "w");
for (i=0; i<4; i++) {
int flag=0;
fscanf(fp,"%d",&a);
for(j=2;j<a;j++)
{
if(a%j==0){
flag=1;
}
}
}
if(flag==0){
fprintf(fw,"%d number is prime \n",a);
}
else
{
fprintf(fw, "%d number is not prime \n",a);
}
fclose(fp);
fclose(fw);
}
</code></pre>
<p>ı want to print to file exam.txt whether the numbers in file new.txt are prime or not but when ı run the code it always writing 'number is not prime' .</p>
| [
{
"answer_id": 74316742,
"author": "Eric Postpischil",
"author_id": 298225,
"author_profile": "https://Stackoverflow.com/users/298225",
"pm_score": 0,
"selected": false,
"text": "int flag=0;"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20416885/"
] |
74,316,519 | <p>I wondering if there is any way to get a time interval for an item in Flutter?</p>
<p>Example:</p>
<p>I have an item where I set a date when this item was last calibrated, and then I want the application to remind me (with either a push message or an email) after a set period of time for the next calibration and so on.</p>
<p>I use <code>Firestore</code> for my database.</p>
| [
{
"answer_id": 74316742,
"author": "Eric Postpischil",
"author_id": 298225,
"author_profile": "https://Stackoverflow.com/users/298225",
"pm_score": 0,
"selected": false,
"text": "int flag=0;"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15971353/"
] |
74,316,550 | <p>I am working on a project that makes heavy use of static polymorphism. A particular use-case that I am interested in would be made possible by static reflection, but we still don't have this in C++. The use case looks something like this: I have a functions that read/write a data structure to/from a binary file:</p>
<pre><code>template <typename data_t> void write_binary(const my_type_t<data_t>& obj)
{
//write a binary file...
}
template <typename data_t> void read_binary(my_type_t<data_t>& obj)
{
//read a binary file...
}
</code></pre>
<p>I would like to enforce that I can only read data from files that were output by the same type, e.g. <code>my_type_t<std::string></code> can only read from binary files output by <code>my_type_t<std::string></code>, etc. The way I want to do this is to add a small header to the binary file that identifies the specialization of <code>data_t</code>:</p>
<pre><code>template <typename data_t> void write_binary(const my_type_t<data_t>& obj)
{
//write header type_name(data_t)
//write a binary file...
}
template <typename data_t> void read_binary(my_type_t<data_t>& obj)
{
//read header
//assert header == type_name(data_t)
//read a binary file...
}
</code></pre>
<p>I am aware of the existence of <code>typeid(data_t).name()</code> and the various methods of demangling it, but I want something that is defined by the standard.</p>
<p>So my precise question is this: for any two types <code>type1_t</code> and <code>type2_t</code>, is there <em>any C++ standard-defined mapping "F" whatsoever</em> such that <code>F(type1_t) == F(type2_t)</code> always implies <code>type1_t == type2_t</code>, and <code>type1_t == type2_t</code> always implies <code>F(type1_t) == F(type2_t)</code>, independent of compiler? That is, is there any bijective mapping between types and some kind of serializable value defined by the c++ standard?</p>
<p><strong>EDIT</strong>
There is a subtlety in this question that I did not initially emphasize: I do not want to serialize arbitrary types. The function body that writes my objects to files is already implemented. What I want (as stated in the question above) is simply a <em>unique identifier for every type that is compiler independent</em>. The role of the template specialization <code>data_t</code> of <code>my_type_t<data_t></code> is not to affect <em>what</em> information is written/read, but rather <em>how it is interpreted</em>.</p>
<p>Just a couple of other thematic points:</p>
<ul>
<li>Due to the nature of my project, I cannot know ahead of type what type <code>data_t</code> will be, I must allow it to feasibly be anything.</li>
<li>It is very much undesirable for me to have to place requirements on what types can be used for the template specification, i.e. requiring people to implement some kind of "name" field for their types. This is because the final type <code>data_t</code> that ends up being used for the I/O is not tied to the interfaces that my users are exposed to.</li>
<li>While the details of how instances of types are stored in memory are indeed platform- and compiler-dependent, the names of the types themselves are ultimately properties only of the source code, not the compiler.</li>
</ul>
| [
{
"answer_id": 74319154,
"author": "Jakob Stark",
"author_id": 17862371,
"author_profile": "https://Stackoverflow.com/users/17862371",
"pm_score": 2,
"selected": false,
"text": "typeid(...).name()"
},
{
"answer_id": 74323390,
"author": "Jeff Garrett",
"author_id": 3242146,
"author_profile": "https://Stackoverflow.com/users/3242146",
"pm_score": 2,
"selected": true,
"text": "template <typename data_t> void write_binary(const my_type_t<data_t>& obj)\n{\n //write header type_name(data_t)\n //write a binary file...\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3112622/"
] |
74,316,576 | <p>I'm facing the following problem: I'm building a third-party integration into my Django app. Users that already use the third-party should be able to click on a button and be redirected to my app. In the redirect, the third-party will send a POST request with a JSON that contains some info (email, some IDs etc.).</p>
<p>I'll use this info to see if I have the user in my DB already.</p>
<p>If yes, I want to:</p>
<ul>
<li>return a response with a user ID and API Key for the third party to store</li>
<li>then redirect the user to a login screen</li>
</ul>
<p>If no, I want to:</p>
<ul>
<li>create a user and return a response with a user ID and API Key for the third party to store</li>
<li>then redirect the user to a confirmation screen.</li>
</ul>
<p>The question I have: How can I redirect the user AFTER returning the user ID & API key?</p>
<p>My current logic is this:</p>
<pre><code>class UserList(APIView):
....
def post(self, request):
if account_exists:
return Response(account_data)
# NOW I WANT TO REDIRECT
else:
create_account()
return Response(account_data)
# NOW I WANT TO REDIRECT
</code></pre>
<p>I'm currently using DRF to handle the POST requests, not sure whether that is the best way of doing it though?</p>
| [
{
"answer_id": 74319154,
"author": "Jakob Stark",
"author_id": 17862371,
"author_profile": "https://Stackoverflow.com/users/17862371",
"pm_score": 2,
"selected": false,
"text": "typeid(...).name()"
},
{
"answer_id": 74323390,
"author": "Jeff Garrett",
"author_id": 3242146,
"author_profile": "https://Stackoverflow.com/users/3242146",
"pm_score": 2,
"selected": true,
"text": "template <typename data_t> void write_binary(const my_type_t<data_t>& obj)\n{\n //write header type_name(data_t)\n //write a binary file...\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19481659/"
] |
74,316,579 | <p>I have two different arrays. One is like:</p>
<pre><code>const arrOne = [
[{sender: '0000', to: '1111'}],
[{sender: '2222', to: '1111'}]
];
</code></pre>
<p>And the other array is like:</p>
<pre><code>const arrTwo = [
{
firstName: 'John',
lastName: 'Doe',
num: '1111'
}
]
</code></pre>
<p>Now i want to match the key <code>to</code> from arrOne and <code>num</code> from array two and if they mathes, the first array should update with firstname and lastname. So, the expected output would be like this:</p>
<pre><code> const arrOne = [
[{sender: '0000', to: '1111', firstName: 'John', lastName: 'Doe'}],
[{sender: '2222', to: '1111', firstName: 'John', lastName: 'Doe'}]
];
</code></pre>
<p>Here's what i have tried:</p>
<pre><code>arrOne = arrOne.map(item => {
const item2 = arrTwo.find(i2 => i2.num == item.to);
return item2 ? { ...item, ...item2 } : item;
});
</code></pre>
<p>Thanks in advance. Also please suggest how to do that with types in TypeScript ?</p>
| [
{
"answer_id": 74319154,
"author": "Jakob Stark",
"author_id": 17862371,
"author_profile": "https://Stackoverflow.com/users/17862371",
"pm_score": 2,
"selected": false,
"text": "typeid(...).name()"
},
{
"answer_id": 74323390,
"author": "Jeff Garrett",
"author_id": 3242146,
"author_profile": "https://Stackoverflow.com/users/3242146",
"pm_score": 2,
"selected": true,
"text": "template <typename data_t> void write_binary(const my_type_t<data_t>& obj)\n{\n //write header type_name(data_t)\n //write a binary file...\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9343113/"
] |
74,316,670 | <p>from te first page of <a href="https://riverpod.dev/it/" rel="nofollow noreferrer">Rivepod</a> library I found this example.</p>
<pre><code>final counterProvider = StateNotifierProvider<Counter, int>((ref) {
return Counter();
});
class Counter extends StateNotifier<int> {
Counter() : super(0);
void increment() => state++;
}
</code></pre>
<p>Now, what I want to ask is: what is the right way to do something like this below?</p>
<pre><code>class Counter extends StateNotifier<int> {
Counter({int? value}) : super(value ?? 0);
void increment() => state++;
}
</code></pre>
<p>I want that my <code>counterProvider</code> can have optional parameters in input, my use case is a StateNotifier used to manage a edit/create page.</p>
| [
{
"answer_id": 74317060,
"author": "john",
"author_id": 16146701,
"author_profile": "https://Stackoverflow.com/users/16146701",
"pm_score": 0,
"selected": false,
"text": "class Counter extends StateNotifier<int> {\n Counter({int value = 0}) : super(value);\n void increment() => state++;\n}"
},
{
"answer_id": 74378358,
"author": "Ruble",
"author_id": 17991131,
"author_profile": "https://Stackoverflow.com/users/17991131",
"pm_score": 2,
"selected": true,
"text": "final valueProvider = StateProvider<Counter, int>((ref) => return 5);\n\nfinal counterProvider = StateNotifierProvider<Counter, int>((ref) {\n final value = ref.watch(valueProvider);\n\n return Counter(value);\n});\n\nclass Counter extends StateNotifier<int> {\n Counter(int value) : super(value ?? 0);\n void increment() => state++;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4016462/"
] |
74,316,671 | <p>This is an example of input.txt:<br />
<a href="https://i.stack.imgur.com/uDCVb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uDCVb.png" alt="enter image description here" /></a></p>
<p>I need to read the matrix from the input.txt file and output it to the output.txt file in the same format. The matrix can be stepped (not rectangular). The size of the array is determined as it will be entered by the user in input.txt. The input format should be shown in the screenshot.</p>
<p>I tried to read the matrix using rows, I can read a rectangular matrix and if we know its size in advance.</p>
<pre><code> void readMtx() throws IOException {
BufferedReader br = new BufferedReader(new FileReader("input.txt"));
List<String> lines = new ArrayList<>();
while (br.ready()) {
lines.add(br.readLine());
}
int matrixWidth = lines.get(0).split(" ").length;
int matrixHeight = lines.size();
Double[][] matrix = new Double[matrixHeight][matrixWidth];
for (int i = 0; i < matrixHeight; i++) {
for (int j = 0; j < matrixWidth; j++) {
String[] line = lines.get(i).split(" ");
matrix[i][j] = Double.parseDouble(line[j]);
}
}
for (int i = 0; i < matrixHeight; i++) {
System.out.println(Arrays.toString(matrix[i]));
}
}
</code></pre>
| [
{
"answer_id": 74317060,
"author": "john",
"author_id": 16146701,
"author_profile": "https://Stackoverflow.com/users/16146701",
"pm_score": 0,
"selected": false,
"text": "class Counter extends StateNotifier<int> {\n Counter({int value = 0}) : super(value);\n void increment() => state++;\n}"
},
{
"answer_id": 74378358,
"author": "Ruble",
"author_id": 17991131,
"author_profile": "https://Stackoverflow.com/users/17991131",
"pm_score": 2,
"selected": true,
"text": "final valueProvider = StateProvider<Counter, int>((ref) => return 5);\n\nfinal counterProvider = StateNotifierProvider<Counter, int>((ref) {\n final value = ref.watch(valueProvider);\n\n return Counter(value);\n});\n\nclass Counter extends StateNotifier<int> {\n Counter(int value) : super(value ?? 0);\n void increment() => state++;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17274825/"
] |
74,316,705 | <p>I'm currently working on a project where I need the data factory pipeline to copy based off the last run date.</p>
<p>The process breakdown....</p>
<ol>
<li>Data is ingested into a storage account</li>
<li>The data ingested is in the directory format topic/yyyy/mm/dd i.e., multiple files being brought in a single directory hence it's files are partitioned by date which looks like this <a href="https://i.stack.imgur.com/ThztY.png" rel="nofollow noreferrer">day format</a> and <a href="https://i.stack.imgur.com/USHNF.png" rel="nofollow noreferrer">month</a> and year etc</li>
<li>The process currently filters based on the last high water mark date which updates each time the pipeline is run and triggers daily at 4am, once the copy is successful, a set variable increases the high-water mark value by 1 (I.e., one day), though files are not brought over on the weekends (this is the problem)</li>
<li>The date value (HWM) will not increase if no files are brought over and will continue to loop through the same date.</li>
<li>How to I get the pipeline to increase or look for the next file in that directory given that I use the HWV as the directory to the file, copy and update the HWM value only when completed dynamically. <a href="https://i.stack.imgur.com/5Bl3o.png" rel="nofollow noreferrer">Current update logic</a></li>
<li>current lookup of HWV <a href="https://i.stack.imgur.com/wJtb0.png" rel="nofollow noreferrer">lookup and directory path to copy files</a></li>
</ol>
| [
{
"answer_id": 74317060,
"author": "john",
"author_id": 16146701,
"author_profile": "https://Stackoverflow.com/users/16146701",
"pm_score": 0,
"selected": false,
"text": "class Counter extends StateNotifier<int> {\n Counter({int value = 0}) : super(value);\n void increment() => state++;\n}"
},
{
"answer_id": 74378358,
"author": "Ruble",
"author_id": 17991131,
"author_profile": "https://Stackoverflow.com/users/17991131",
"pm_score": 2,
"selected": true,
"text": "final valueProvider = StateProvider<Counter, int>((ref) => return 5);\n\nfinal counterProvider = StateNotifierProvider<Counter, int>((ref) {\n final value = ref.watch(valueProvider);\n\n return Counter(value);\n});\n\nclass Counter extends StateNotifier<int> {\n Counter(int value) : super(value ?? 0);\n void increment() => state++;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18438858/"
] |
74,316,708 | <p>There are two tables. It is necessary to insert two fields from one to the other so that duplicates do not appear. I tried those methods that are described for</p>
<blockquote>
<pre><code> USING INSERT IGNORE
Using replace
USING INSERT ... on duplicate key update
</code></pre>
</blockquote>
<p>But I didn't succeed. For example, it ignore duplicate and write these:</p>
<pre><code>REPLACE INTO user_favorites
(user_id, partner_id)
SELECT id, partner_id FROM users
</code></pre>
<p>How to do it?</p>
<p>1 table</p>
<pre><code>create table local.users
(
id int auto_increment,
name varchar(255) null,
email varchar(255) null,
password varchar(255) null,
partner_id int null,
constraint users_email_unique
unique (email),
constraint users_id_uindex
unique (id)
)
alter table local.users
add primary key (id);
</code></pre>
<p>2 table</p>
<pre><code>create table local.user_favorites
(
id int auto_increment,
user_id int null,
partner_id int null,
constraint user_favorites_id_uindex
unique (id),
constraint user_favorites_partners_id_fk
foreign key (partner_id) references local.partners (id)
on update cascade on delete cascade,
constraint user_favorites_users_id_fk
foreign key (user_id) references local.users (id)
on update cascade on delete cascade
);
alter table local.user_favorites
add primary key (id);
</code></pre>
| [
{
"answer_id": 74317060,
"author": "john",
"author_id": 16146701,
"author_profile": "https://Stackoverflow.com/users/16146701",
"pm_score": 0,
"selected": false,
"text": "class Counter extends StateNotifier<int> {\n Counter({int value = 0}) : super(value);\n void increment() => state++;\n}"
},
{
"answer_id": 74378358,
"author": "Ruble",
"author_id": 17991131,
"author_profile": "https://Stackoverflow.com/users/17991131",
"pm_score": 2,
"selected": true,
"text": "final valueProvider = StateProvider<Counter, int>((ref) => return 5);\n\nfinal counterProvider = StateNotifierProvider<Counter, int>((ref) {\n final value = ref.watch(valueProvider);\n\n return Counter(value);\n});\n\nclass Counter extends StateNotifier<int> {\n Counter(int value) : super(value ?? 0);\n void increment() => state++;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12355439/"
] |
74,316,716 | <p>Let's say its the 15th and my function runs, if that function is called again on the 15th it will not run. But if the date is the 16th and the function is called, then it is allowed to run.
How could I achieve this?
P.S. Code below is in visual basic however C# is fine for an answer</p>
<pre><code>Private Sub CreateLogger()
Logger = New CustomLogger(Sub(value, Type)
Dim tempFileLogPath = IO.Path.Combine("C:\temp", $"FileAttributer_{Today:yyyyMMdd}.txt")
Dim consoleLogger = New ConsoleLogger()
Dim textFileLogger = New TextFileLogger(tempFileLogPath)
Dim compositeLogger = New CompositeLogger(consoleLogger, textFileLogger)
value = $"{DateTime.Now:dd/MM/yyyy HH:mm:ss} - {value}"
compositeLogger.Write(value, Type)
End Sub)
End Sub
</code></pre>
| [
{
"answer_id": 74316947,
"author": "Tolbxela",
"author_id": 2487565,
"author_profile": "https://Stackoverflow.com/users/2487565",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Threading;\n \npublic class Program\n{\n private static DateTime lastRunTime;\n \n public static void Main()\n {\n for(int i=0; i < 10; i++) {\n DoSomething();\n Thread.Sleep(1000);\n }\n }\n \n private static void DoSomething() \n {\n if (DateTime.Now.Day != lastRunTime.Day) {\n lastRunTime = DateTime.Now;\n Console.WriteLine($\"Run: {lastRunTime}\");\n } \n }\n}\n"
},
{
"answer_id": 74317808,
"author": "Dubbs777",
"author_id": 2393357,
"author_profile": "https://Stackoverflow.com/users/2393357",
"pm_score": 0,
"selected": false,
"text": "public abstract class ExecutionManager\n{\n protected string ActionKey { get; }\n\n public ExecutionManager(string actionKey)\n {\n ActionKey = actionKey;\n }\n\n protected abstract DateTime GetLastExecution();\n\n protected abstract void SetLastExecution(DateTime dateTime);\n\n\n public void OncePerDay(Action action)\n {\n if (GetLastExecution().Date != DateTime.Now.Date)\n {\n SetLastExecution(DateTime.Now);\n action();\n }\n }\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19719649/"
] |
74,316,723 | <p><a href="https://i.stack.imgur.com/HaJdb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HaJdb.png" alt="this is the error that has appeared" /></a></p>
<p>I tried to just add (assets/ ) but that didn't solve the problem</p>
| [
{
"answer_id": 74316947,
"author": "Tolbxela",
"author_id": 2487565,
"author_profile": "https://Stackoverflow.com/users/2487565",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Threading;\n \npublic class Program\n{\n private static DateTime lastRunTime;\n \n public static void Main()\n {\n for(int i=0; i < 10; i++) {\n DoSomething();\n Thread.Sleep(1000);\n }\n }\n \n private static void DoSomething() \n {\n if (DateTime.Now.Day != lastRunTime.Day) {\n lastRunTime = DateTime.Now;\n Console.WriteLine($\"Run: {lastRunTime}\");\n } \n }\n}\n"
},
{
"answer_id": 74317808,
"author": "Dubbs777",
"author_id": 2393357,
"author_profile": "https://Stackoverflow.com/users/2393357",
"pm_score": 0,
"selected": false,
"text": "public abstract class ExecutionManager\n{\n protected string ActionKey { get; }\n\n public ExecutionManager(string actionKey)\n {\n ActionKey = actionKey;\n }\n\n protected abstract DateTime GetLastExecution();\n\n protected abstract void SetLastExecution(DateTime dateTime);\n\n\n public void OncePerDay(Action action)\n {\n if (GetLastExecution().Date != DateTime.Now.Date)\n {\n SetLastExecution(DateTime.Now);\n action();\n }\n }\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13493586/"
] |
74,316,729 | <p>I have the following values</p>
<pre><code>values <- seq(1,3)
</code></pre>
<p>I would like to have the resulting dataframe</p>
<pre><code># A tibble: 6 x 2
facet values
<dbl> <dbl>
1 1 1
2 2 1
3 2 2
4 3 1
5 3 2
6 3 3
</code></pre>
<p>The <code>facet</code> is a column which is stating the iteration of the recursive append.</p>
<p>My current solution is</p>
<pre><code>facet1 <- values %>% head(1) %>% tibble(facet = 1, values = .)
facet2 <- values %>% head(2) %>% tibble(facet = 2, values = .)
facet3 <- values %>% head(3) %>% tibble(facet = 3, values = .)
bind_rows(facet1, facet2, facet3)
</code></pre>
<h1>A more general solution needed [Edit]</h1>
<p>The current solutions will not work for my use-case because they are exploiting the fact that in my previous example sequences of the facets equal the values.</p>
<p>Here is a more general reproducible example where the values are much different from the facets.</p>
<pre><code>set.seed(42)
values <- rnorm(3,0,.2)
df_recursive <- tribble(~facet, ~values,
1, 0.27,
2, 0.27,
2, -0.11,
3, 0.27,
3, -0.11,
3, 0.07)
</code></pre>
<pre><code># A tibble: 6 x 2
facet values
<dbl> <dbl>
1 1 0.27
2 2 0.27
3 2 -0.11
4 3 0.27
5 3 -0.11
6 3 0.07
</code></pre>
| [
{
"answer_id": 74316814,
"author": "B. Christian Kamgang",
"author_id": 10848898,
"author_profile": "https://Stackoverflow.com/users/10848898",
"pm_score": 2,
"selected": false,
"text": "library(dplyr)\n\ntibble(facet=1:3) %>%\n group_by(facet) %>%\n summarise(values = seq_len(facet)) %>% \n ungroup()\n\n# A tibble: 6 x 2\n facet values\n <int> <int>\n1 1 1\n2 2 1\n3 2 2\n4 3 1\n5 3 2\n6 3 3\n\nlibrary(data.table)\n\ndata.table(facet=1:3)[, .(values = seq_len(facet)), by=facet]\n\n facet values\n <int> <int>\n1: 1 1\n2: 2 1\n3: 2 2\n4: 3 1\n5: 3 2\n6: 3 3\n"
},
{
"answer_id": 74316857,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 4,
"selected": true,
"text": "library(tidyverse)\n\nvalues <- seq(1,3)\n\nmap_dfr(values, ~tibble(facet = .x, values = 1:.x))\n#> # A tibble: 6 x 2\n#> facet values\n#> <int> <int>\n#> 1 1 1\n#> 2 2 1\n#> 3 2 2\n#> 4 3 1\n#> 5 3 2\n#> 6 3 3\n"
},
{
"answer_id": 74317408,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "rep"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2444023/"
] |
74,316,730 | <p>I have the following code that gets called from a Controller.</p>
<pre><code>public async Task Execute()
{
var collections= await _repo.GetCollections(); // This gets 500+ items
List<Object1> coolCollections= new List<Object1>();
List<Object2> uncoolCollections= new List<Object2>();
foreach (var collection in collections)
{
if(collection == "Something")
{
var specialObject = TurnObjectIntoSpecialObject(collection);
uncoolCollections.Add(specialObject);
}
else
{
var anotherObject = TurnObjectIntoAnotherObject(object);
coolCollections.Add(anotherObject);
}
}
var list1Async = coolCollections.Select(async obj => await restService.PostObject1(obj)); //each call takes 200 -> 2000ms
var list2Async = uncoolCollections.Select(async obj => await restService.PostObject2(obj));//each call takes 300 -> 3000ms
var asyncTasks = list1Async.Concat<Task>(list2Async);
await Task.WhenAll(asyncTasks); //As 500+ 'tasks'
}
</code></pre>
<p>Unfortunately, I'm getting a 504 error after around 300 or so requests. I can't change the API the RestService calls so I'm stuck trying to make the above code more performant.</p>
<p>Changing <code>Task.WhenAll</code> to a <code>foreach</code> loop does work, and does resolve the time out but it's very slow.</p>
<p>My question is how can I make sure the above code does not timeout after x number of requests?</p>
| [
{
"answer_id": 74317068,
"author": "Panagiotis Kanavos",
"author_id": 134204,
"author_profile": "https://Stackoverflow.com/users/134204",
"pm_score": 3,
"selected": true,
"text": "ParallelOptions parallelOptions = new()\n{\n MaxDegreeOfParallelism = 30\n};\n \nawait Parallel.ForEachAsync(object1, parallelOptions, async obj =>\n{\n await restService.PostObject1(obj);\n});\nawait Parallel.ForEachAsync(object2, parallelOptions, async obj =>\n{\n await restService.PostObject2(obj);\n});\n"
},
{
"answer_id": 74318773,
"author": "Theodor Zoulias",
"author_id": 11178549,
"author_profile": "https://Stackoverflow.com/users/11178549",
"pm_score": 0,
"selected": false,
"text": "objects"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7716559/"
] |
74,316,754 | <p>I have a proxy to set it on my Visual Studio by this command line on the terminal : <code>export HTTP_PROXY=http://127.0.0.1:22548</code>. I can run my script without issues. But I can not put this config on GitHub Actions?
Somme one can help me?</p>
| [
{
"answer_id": 74333385,
"author": "tg0h",
"author_id": 11813885,
"author_profile": "https://Stackoverflow.com/users/11813885",
"pm_score": 2,
"selected": false,
"text": "jobs:\n cypress_test:\n runs-on: ubuntu-latest\n steps:\n - name: \"run cypress test\"\n run: echo $HTTP_PROXY\n env:\n HTTP_PROXY: http://127.0.0.1:22548\n"
},
{
"answer_id": 74391954,
"author": "FlutterLover",
"author_id": 12044397,
"author_profile": "https://Stackoverflow.com/users/12044397",
"pm_score": 1,
"selected": true,
"text": "jobs:\n cypress-ua-run:\n name: Cypress UA test\n runs-on: [ self-hosted, Companyname ]\n timeout-minutes: 20\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12044397/"
] |
74,316,851 | <p>I encountered a strange problem, but to make it clear see the code first:</p>
<pre><code>#include <stdio.h>
#include <stdint.h>
int main() {
uint8_t a = 0b1000'0000; // -> one leftmost bit
uint8_t b = 0b1000'0000;
a = (a << 1) >> 1; // -> Both shifts in one line
b = b << 1; // -> Shifts separated into two individual lines
b = b >> 1;
printf("%i != %i", a, b);
return 0;
}
</code></pre>
<p>(using C++ 17 on a x86 machine)</p>
<p>If you compile the code, <code>b</code> is <code>0</code> while <code>a</code> is <code>128</code>.
On a general level, this expressions should not be tied to the processors architecture or its bit width, I would expect both to be <code>0</code> after the operation</p>
<p>The bitshift right operator is defined to fill up the left bits with zero, as the example with <code>b</code> proves.</p>
<p>If I look at the assembler code, I can see that for <code>b</code>, the value is loaded from RAM into a register, shifted left, written back into RAM, read again from RAM into a register and then shifted write. On every write back into RAM, the truncation to 8 bit integer is done, removing the leftmost <code>1</code> from the byte, as it is out of range for an 8-bit integer.</p>
<p>For <code>a</code> on the other hand, the value is loaded in a register (based on the x86 architecture, 32-bit wide), shifted left, then shifted right again, shifting the 1 just back where it was, caused by the 32-bit register.</p>
<p>My question is now, is this one-line optimization for <code>a</code> a correct behavior and should be taken in account while writing code, or is it a compiler bug to be reported to the compiler developers?</p>
| [
{
"answer_id": 74316971,
"author": "dbush",
"author_id": 1687119,
"author_profile": "https://Stackoverflow.com/users/1687119",
"pm_score": 5,
"selected": true,
"text": "int"
},
{
"answer_id": 74317001,
"author": "Lundin",
"author_id": 584518,
"author_profile": "https://Stackoverflow.com/users/584518",
"pm_score": 2,
"selected": false,
"text": "(a << 1) >> 1;"
},
{
"answer_id": 74317142,
"author": "amirhm",
"author_id": 4529589,
"author_profile": "https://Stackoverflow.com/users/4529589",
"pm_score": 1,
"selected": false,
"text": "a = ((uint8_t)(a << 1)) >> 1\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10581770/"
] |
74,316,883 | <p>This code only deletes a string which I provide it in removed_str variable but I want to delete all the string which start from "|" and ends with "|". How should i do it?</p>
<pre><code>int main()
{
std::ifstream in_file("Test-1.txt");
std::ofstream out_file("output.txt");
std::string str;
const std::string removed_str = "|start|";
while (std::getline(in_file, str)) {
std::size_t ind = str.find(removed_str);
std::cout << str << std::endl;
if (ind != std::string::npos)
{
str.erase(ind, removed_str.length());
}
std::cout << str << std::endl;
out_file << str << std::endl;
}
}
</code></pre>
| [
{
"answer_id": 74316971,
"author": "dbush",
"author_id": 1687119,
"author_profile": "https://Stackoverflow.com/users/1687119",
"pm_score": 5,
"selected": true,
"text": "int"
},
{
"answer_id": 74317001,
"author": "Lundin",
"author_id": 584518,
"author_profile": "https://Stackoverflow.com/users/584518",
"pm_score": 2,
"selected": false,
"text": "(a << 1) >> 1;"
},
{
"answer_id": 74317142,
"author": "amirhm",
"author_id": 4529589,
"author_profile": "https://Stackoverflow.com/users/4529589",
"pm_score": 1,
"selected": false,
"text": "a = ((uint8_t)(a << 1)) >> 1\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12422272/"
] |
74,316,890 | <p>How do I extract/view the csv files created by this block of code? What the code does is pull data from a table and extract the json elements. I am running this code on Jupyter notebook but I can't figure out how to view the csv file.</p>
<pre><code>print('Conducting ETL for all events data')
class CsvBuilder:
def __init__(self, fileName: str):
self._fileName = fileName
self._headers = []
self._rows = []
def hasHeaders(self) -> bool:
return len(self._headers) > 0
def setHeaders(self, headers):
self._headers = headers
def addRow(self, row):
self._rows.append(row)
def write(self):
file_existed = os.path.isfile(self._fileName)
with open(self._fileName, 'a') as outputFile:
writer = csv.writer(outputFile)
if not file_existed:
writer.writerow(self._headers)
writer.writerows(self._rows)
class NullBuilder(CsvBuilder):
def __init__(self):
super().__init__(None)
def hasHeaders(self) -> bool:
pass
def setHeaders(self, headers):
pass
def addRow(self, row):
pass
def write(self):
pass
class CsvBuilderProvider:
def __init__(self):
self._builders = {}
self._defaultBuilder = NullBuilder()
def registerBuilder(self, event: str, builder: CsvBuilder) -> 'CsvBuilderProvider':
self._builders[event] = builder
return self
def getBuilderForEvent(self, event: str):
if event in self._builders.keys():
return self._builders[event]
return self._defaultBuilder
def isJson(value) :
return str(value)[0] == '{'
for start_date in weeks:
end_date = start_date + dt.timedelta(days=7)
print('Querying for date range: {} to {}'.format(start_date, end_date))
query_data = """
SELECT events
FROM webschema.data
WHERE created_at >= DATE('{start_date}')
AND created_at < DATE('{end_date}')
;
""".format(start_date=start_date, end_date=end_date)
cursor.execute(query_data)
rows = cursor.fetchall()
print('Query completed')
csvBuilderProvider = CsvBuilderProvider()
csvBuilderProvider.registerBuilder('open', CsvBuilder('open.csv')) \
.registerBuilder('send', CsvBuilder('send.csv')) \
.registerBuilder('click', CsvBuilder('click.csv')) \
.registerBuilder('soft_bounce', CsvBuilder('soft_bounce.csv')) \
.registerBuilder('hard_bounce', CsvBuilder('hard_bounce.csv'))
print('Processing data')
csvBuilders = {}
processed = 0
errored = 0
for row in rows:
try:
jsonData = json.loads(row[0])
for event in jsonData:
eventName = event["event"]
csvBuilder = csvBuilders.setdefault(eventName, csvBuilderProvider.getBuilderForEvent(eventName))
if not csvBuilder.hasHeaders():
csvBuilder.setHeaders(event.keys())
newData = []
for value in event.values():
quotedValue = json.dumps(value) if isJson(value) else value
newData.append(quotedValue)
csvBuilder.addRow(newData)
processed += 1
except Exception as e:
errored += 1
print('Appending processed data to CSV')
for builder in csvBuilders.values():
builder.write()
</code></pre>
<p>I don't have a clue how to extract the csv files. It says file not found when I try to run</p>
<pre><code>pd.read_csv('open.csv')
</code></pre>
| [
{
"answer_id": 74317520,
"author": "svfat",
"author_id": 2419628,
"author_profile": "https://Stackoverflow.com/users/2419628",
"pm_score": 0,
"selected": false,
"text": "import pathlib\nCWD = pathlib.Path().resolve()\n...\nCsvBuilder(CWD / 'open.csv')\n...\npd.read_csv(CWD / 'open.csv')\n\n"
},
{
"answer_id": 74318309,
"author": "Anthony B.",
"author_id": 19408037,
"author_profile": "https://Stackoverflow.com/users/19408037",
"pm_score": -1,
"selected": false,
"text": "import os\nos.chdir('/tmp')\npd.read_csv('open.csv')\n"
},
{
"answer_id": 74318496,
"author": "suvayu",
"author_id": 289784,
"author_profile": "https://Stackoverflow.com/users/289784",
"pm_score": 0,
"selected": false,
"text": "pd.read_csv(csvBuilderProvider.getBuilderForEvent(\"open\")._fileName)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20417204/"
] |
74,316,893 | <p>I'm trying to develop a flutter app. The idea of the app is to get the location of some users and show it in a container (not in a map).</p>
<p>However, here we have some conditions, for example, my location is the main location of the list of locations and the most important, I can get the distance of the different locations, but I don't know how to show that position and that relations in my device without a map.</p>
<p>I know that with "position library" I can put any element where I want, so, I can tell to Flutter that if my location is the main location, to show a container (positioned a container) in the middle of the screen trying to simulate that I am that container for example. However, if I have another location on the left (around 10 meters of the left of the main location) how I can show it in my device?</p>
| [
{
"answer_id": 74317520,
"author": "svfat",
"author_id": 2419628,
"author_profile": "https://Stackoverflow.com/users/2419628",
"pm_score": 0,
"selected": false,
"text": "import pathlib\nCWD = pathlib.Path().resolve()\n...\nCsvBuilder(CWD / 'open.csv')\n...\npd.read_csv(CWD / 'open.csv')\n\n"
},
{
"answer_id": 74318309,
"author": "Anthony B.",
"author_id": 19408037,
"author_profile": "https://Stackoverflow.com/users/19408037",
"pm_score": -1,
"selected": false,
"text": "import os\nos.chdir('/tmp')\npd.read_csv('open.csv')\n"
},
{
"answer_id": 74318496,
"author": "suvayu",
"author_id": 289784,
"author_profile": "https://Stackoverflow.com/users/289784",
"pm_score": 0,
"selected": false,
"text": "pd.read_csv(csvBuilderProvider.getBuilderForEvent(\"open\")._fileName)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16077730/"
] |
74,316,939 | <p>I have a list with some dicts inside. The list looks like this:</p>
<pre><code>files = [
{'name': "text.txt", 'size': 10, 'location': "cloud", 'info': "Nothing"},
{'name': "img.jpg", 'size': 200, 'location': "local", 'info': "private"},
{'name': "cars.txt", 'size': 109, 'location': "cloud", 'info': "private"}
]
</code></pre>
<p>I also have a folder where "text.txt", "img.jpg" and "cars.txt" are located. Somehow I have to get all elements where "location" is "cloud" AND "info" is "Nothing".</p>
<p>The only way to sort the data is by using the "next" function</p>
<pre><code>next((item for item in files if item["location"] == "cloud"), None)
</code></pre>
<p>What is the fastest way to achieve this? And also to sort by "location" and "info"?</p>
| [
{
"answer_id": 74316994,
"author": "Equinox",
"author_id": 5660284,
"author_profile": "https://Stackoverflow.com/users/5660284",
"pm_score": 1,
"selected": false,
"text": "files = [dic['name'] for dic in files if dic['location'] == 'cloud' and dic['info'] == \"Nothing\"])\nprint(files)\n"
},
{
"answer_id": 74317015,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
"author_profile": "https://Stackoverflow.com/users/11622508",
"pm_score": 3,
"selected": true,
"text": "list(filter(lambda x: x[\"location\"]==\"cloud\" and x[\"info\"]==\"Nothing\",files))\n# [{'name': 'text.txt', 'size': 10, 'location': 'cloud', 'info': 'Nothing'}]\n"
},
{
"answer_id": 74319150,
"author": "The Lazy Graybeard",
"author_id": 9608497,
"author_profile": "https://Stackoverflow.com/users/9608497",
"pm_score": 1,
"selected": false,
"text": "jmespath"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12493291/"
] |
74,316,955 | <p>Given the following python pandas dataframe:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>province</th>
<th>district</th>
</tr>
</thead>
<tbody>
<tr>
<td>Total</td>
<td>example</td>
</tr>
<tr>
<td>NaN</td>
<td>other</td>
</tr>
<tr>
<td>Other</td>
<td>NaN</td>
</tr>
<tr>
<td>NaN</td>
<td>example</td>
</tr>
<tr>
<td>Result</td>
<td>example</td>
</tr>
<tr>
<td>NaN</td>
<td>example</td>
</tr>
</tbody>
</table>
</div>
<p>If the province column is NaN and the value for that row is 'example', I want to fill the province gap with 'example'. The rest of the rows stay as they are.</p>
<p>DataFrame result:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>province</th>
<th>district</th>
</tr>
</thead>
<tbody>
<tr>
<td>Total</td>
<td>example</td>
</tr>
<tr>
<td>NaN</td>
<td>other</td>
</tr>
<tr>
<td>Other</td>
<td>NaN</td>
</tr>
<tr>
<td>example</td>
<td>example</td>
</tr>
<tr>
<td>Result</td>
<td>example</td>
</tr>
<tr>
<td>example</td>
<td>example</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74317056,
"author": "sophocles",
"author_id": 9167382,
"author_profile": "https://Stackoverflow.com/users/9167382",
"pm_score": 0,
"selected": false,
"text": "loc"
},
{
"answer_id": 74317093,
"author": "ozacha",
"author_id": 5726768,
"author_profile": "https://Stackoverflow.com/users/5726768",
"pm_score": 2,
"selected": true,
"text": ".fillna()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18396935/"
] |
74,316,965 | <p>I have been trying (unsuccessfully) to use the solutions from several threads, especially:
<a href="https://stackoverflow.com/q/68803148">Get column name based on row values matching in DF in R (more than 3 column names)</a>
<a href="https://stackoverflow.com/q/46456265">Populate a new column if a value is found in any column</a>
But when I adapt them to my specific needs, I fail...
Other posts deal with matching to a specific value, or a maximum value etc., but that doesn't work for me.</p>
<p>So I have a variable (a date) and I need to know where that date comes from, based on other date variables. I have a very large dataset, so I need to keep the rest of that in place, and avoid using references to column numbers (e.g., df[2:3]) because my data source may change in the future, so best to stick to variable names (e.g., "date1"). Best to explain with an example:</p>
<pre><code>df<-data.frame(id=as.character(c(1,2,3,4,5)),
date1=c("01/10/2022",NA,"1/10/2022","2/10/2022",NA),
date2=c("02/10/2022",NA,"3/10/2022","4/10/2022","02/10/2022"),
date3=c("05/10/2022","3/10/2022", "5/10/2022","6/10/2022","04/10/2022"),
keydate=c("01/10/2022","3/10/2022", "1/10/2022","4/10/2022","05/10/2022"))
df$date1 <- as.Date(df$date1, format="%d/%m/%y")
df$date2 <- as.Date(df$date2, format="%d/%m/%y")
df$date3 <- as.Date(df$date3, format="%d/%m/%y")
df$keydate <- as.Date(df$keydate, format="%d/%m/%y")
</code></pre>
<p>Then I need a new variable "datesource" defining where "keydate" comes from, in my previous example this would be:</p>
<pre><code>datesource=c("date1","date3","date1","date2","none")
cbind(df,datesource)
</code></pre>
<p>Some of my failed attempts include:</p>
<pre><code>df$datesource = ifelse(df$keydate %in% df[c(date1,date2,date3),], colnames(df), "none") #get all "none"
#OR
df %>% mutate(datesource = ifelse(df$keydate %in% df, colnames(df), "none")) #get all "none"
#OR
df$datesource <- apply(df, colnames(df[c(date1,date2,date3),]),
function(x) ifelse(any(x = df$keydate), colnames(df), 'none'))
#Error in apply(df, colnames(df[c(date1, date2, date3), ]), function(x) ifelse(any(x = df$keydate), : 'X' must have named dimnames
</code></pre>
<p>Thank you for help!</p>
| [
{
"answer_id": 74317056,
"author": "sophocles",
"author_id": 9167382,
"author_profile": "https://Stackoverflow.com/users/9167382",
"pm_score": 0,
"selected": false,
"text": "loc"
},
{
"answer_id": 74317093,
"author": "ozacha",
"author_id": 5726768,
"author_profile": "https://Stackoverflow.com/users/5726768",
"pm_score": 2,
"selected": true,
"text": ".fillna()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20398697/"
] |
74,316,986 | <p>I start working with Vue3 and created some basic app with adding items to list.</p>
<p>I have two componetnts: <strong>ItemList</strong> and <strong>ItemForm</strong>. Both are added to main <strong>App.vue</strong> component like that:</p>
<p><strong>App.vue - simplified</strong></p>
<pre class="lang-html prettyprint-override"><code><template>
<ItemsList/>
<ItemForm/>
</template>
</code></pre>
<p>In <strong>ItemsList</strong> I have prop called 'items'. And function addItem() for adding new items to list.</p>
<p>In <strong>ItemForm</strong> have form and on submit I want send this data from form to <strong>ItemsList</strong> component to update list view.</p>
<p>I checked few things and nothing works for me (I read that in Vue2 was EventBus which was used for such a situation). I don't wanna also learn some bad way to solve that problems so I ask you for help.</p>
<p>#EDIT</p>
<p><strong>App.vue</strong></p>
<pre class="lang-html prettyprint-override"><code><template>
<div>
<ItemsList/>
</div>
<div>
<ItemForm/>
</div>
</template>
<script setup>
import ItemForm from "@/components/ItemForm";
import ItemsList from "@/components/ItemsList";
</script>
</code></pre>
<p><strong>ItemForm.vue</strong></p>
<pre class="lang-html prettyprint-override"><code><template>
<form v-on:submit="addItem">
<input type="text" v-model="title"/>
<textarea v-model="description"></textarea>
<button>Add item</button>
</form>
</template>
<script>
export default {
data() {
return {
title: '',
description: ''
}
},
methods: {
addItem(e) {
e.preventDefault();
}
}
}
</script>
</code></pre>
<p><strong>ItemsList.vue</strong></p>
<pre class="lang-html prettyprint-override"><code><template>
<ul>
<li v-for="item in items">
<p><b>{{ item.title }}</b></p>
</li>
</ul>
</template>
<script>
export default {
data() {
return {
items: []
}
},
methods: {
addItem: function(item) {
this.items.push(item);
}
},
}
</script>
</code></pre>
| [
{
"answer_id": 74317057,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 1,
"selected": false,
"text": "<template>\n<Comp @send-data=\"callback\" />\n\n<input v-model=\"myInput\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport Comp from './Comp.vue'\n\nconst myInput = ref('')\n\nconst callback = data => myInput.value = data\n</script>\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74316986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1977199/"
] |
74,317,026 | <p>I have two views one is parent view (Ics view) in which I have added child view (side View).
In IcsView I have written code for buttons add file and add folder now I want to bind that data in child view i.e. side view.</p>
<p>Model:</p>
<pre><code> public partial class Data:ObservableObject
{
public string filePath { get; set; }
public String FilePath
{
get { return filePath; }
set { filePath = value; }
}
}
</code></pre>
<p>Ics xaml:</p>
<pre><code><ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ICSViewer.MVVM.View.IcsView"
xmlns:v="clr-namespace:ICSViewer.MVVM.View"
xmlns:model="clr-namespace:ICSViewer.MVVM.ViewModel"
>
<ContentPage.BindingContext>
<model:IcsViewModel/>
</ContentPage.BindingContext>
<ContentPage.MenuBarItems>
</code></pre>
<p>
<v:SideView Grid.Column="0" Grid.RowSpan="3" />
</p>
<p>IcsView Code Behind:</p>
<pre><code> private readonly IFolderPicker _folderPicker;
public static List<Data> Items = new List<Data>();
public IcsView(IFolderPicker folderPicker)
{
InitializeComponent();
_folderPicker = folderPicker;
}
private async void Add_File(object sender, EventArgs e)
{
var CustomFileType = new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<String>>
{
{ DevicePlatform.WinUI, new[]{"ics"} },
});
var results = await FilePicker.PickMultipleAsync(new PickOptions
{
FileTypes = CustomFileType,
});
foreach (var result in results)
{
FileInfo fileInfo = new FileInfo(result.FullPath);
double size = fileSize(fileInfo);
bool fileExist = false;
foreach (Data item in Items)
{
if (item.FilePath.Equals(result.FullPath))
{
fileExist = true;
break;
}
}
if (!fileExist)
{
Items.Add(new Data
{
FilePath = result.FullPath,
});
}
else
{
await DisplayAlert("Alert", "File already exist!", "Ok");
}
}
}
public void getFiles(FileInfo path)
{
double size = fileSize(path);
bool fileExist = false;
foreach (Data item in Items)
{
if (item.FilePath.Equals(path.FullName))
{
fileExist = true;
break;
}
}
if (!fileExist)
{
Items.Add(new Data
{
FilePath = path.FullName,
});
}
}
public double fileSize(FileInfo file)
{
double fileSize = file.Length;
double sizeMb = fileSize * 0.000001;
return Math.Round(sizeMb, 2);
}
</code></pre>
<p>SideView</p>
<pre><code> <StackLayout>
<Label Text="{Binding SideModel.HeaderText}" FontSize="18" FontAttributes="Bold" Padding="5" />
<CollectionView ItemsSource="{Binding Source={x:Reference childView }, Path=icsViewModel.Items}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Label Text="{Binding FilePath}"/>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</code></pre>
<p>This is Code behind of sideView</p>
<pre><code>public string FilePath
{
get
{
string value = (String)GetValue(FilePathProperty);
return value;
}
set
{
SetValue(FilePathProperty, value);
}
}
static void OnFileNameChanged(BindableObject bindable, object oldValue, object newValue)
{
Console.WriteLine("-----------------> " + newValue);
}
public static readonly BindableProperty MyViewModelProperty =
BindableProperty.Create(
nameof(IcsViewModel),
typeof(IcsViewModel),
typeof(SideView),
null);
public static readonly BindableProperty FilePathProperty = BindableProperty.Create(nameof(File)
, typeof(Data)
, typeof(SideView), defaultBindingMode: BindingMode.TwoWay, propertyChanged: OnFileNameChanged);
public IcsViewModel icsViewModel
{
set { SetValue(MyViewModelProperty, value); }
get { return (IcsViewModel)GetValue(MyViewModelProperty); }
}
public SideView()
{
InitializeComponent();
}
</code></pre>
<p>Updated view Model:
I haven't added set method in here. and I m not getting how I should add that property in here. so can you please go through it once.</p>
<p>namespace DataBinding.MVVM.ViewModel
{
internal partial class ParentViewModel : INotifyPropertyChanged
{</p>
<pre><code> public ObservableCollection<Data> Item { get; set; }
public ParentViewModel()
{
Item = new ObservableCollection<Data>();
}
[RelayCommand]
public async void Add_File()
{
var CustomFileType = new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<String>>
{
{ DevicePlatform.WinUI, new[]{"ics"} },
});
var results = await FilePicker.PickMultipleAsync(new PickOptions
{
FileTypes = CustomFileType,
});
foreach (var result in results)
{
FileInfo fileInfo = new FileInfo(result.FullPath);
double size = fileSize(fileInfo);
bool fileExist = false;
foreach (Data item in Item)
{
if (item.name.Equals(result.FullPath))
{
fileExist = true;
break;
}
}
if (!fileExist)
{
Item.Add(new Data
{
name = result.FullPath,
});
}
else
{
Item = Item;
}
}
}
public void getFiles(FileInfo path)
{
double size = fileSize(path);
bool fileExist = false;
foreach (Data item in Item)
{
if (item.name.Equals(path.FullName))
{
fileExist = true;
break;
}
}
if (!fileExist)
{
Item.Add(new Data
{
name = path.FullName,
});
}
}
public double fileSize(FileInfo file)
{
double fileSize = file.Length;
double sizeMb = fileSize * 0.000001;
return Math.Round(sizeMb, 2);
}
bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (Object.Equals(storage, value))
return false;
storage = value;
OnPropertyChanged(propertyName);
return true;
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
}
</code></pre>
<p>}</p>
<p>If I select particular file then I want that file or folder to be populated in my side view.
And I am not able to bind data from IcsView.xaml.cs to sideview.xaml.cs</p>
| [
{
"answer_id": 74317057,
"author": "ericmp",
"author_id": 14569750,
"author_profile": "https://Stackoverflow.com/users/14569750",
"pm_score": 1,
"selected": false,
"text": "<template>\n<Comp @send-data=\"callback\" />\n\n<input v-model=\"myInput\" />\n</template>\n\n<script setup>\nimport { ref } from 'vue'\nimport Comp from './Comp.vue'\n\nconst myInput = ref('')\n\nconst callback = data => myInput.value = data\n</script>\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19836184/"
] |
74,317,037 | <p>Created an indeterminate progress-bar. I have added padding but that does not seem to apply on the right side.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.progress-bar {
height: 5px;
background-color: red;
width: 10rem;
overflow: hidden;
padding: 1rem;
}
.progress-bar-value {
width: 100%;
height: 100%;
background-color: pink;
animation: indeterminateAnimation 1s infinite linear;
transform-origin: 0% 100%;
}
@keyframes indeterminateAnimation {
0% { transform: translateX(0) scaleX(0); }
40% { transform: translateX(0) scaleX(0.4); }
100% { transform: translateX(100%) scaleX(0.5); }
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="progress-bar">
<div class="progress-bar-value"></div>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74317161,
"author": "CBroe",
"author_id": 1427878,
"author_profile": "https://Stackoverflow.com/users/1427878",
"pm_score": 2,
"selected": true,
"text": ".progress-bar {\n height: 5px;\n background-color: red;\n width: 10rem;\n overflow: hidden;\n padding: 1rem 0 1rem 1rem;\n border-right: 1rem solid red;\n}\n\n.progress-bar-value {\n width: 100%;\n height: 100%;\n background-color: pink;\n animation: indeterminateAnimation 1s infinite linear;\n transform-origin: 0% 100%;\n}\n\n@keyframes indeterminateAnimation {\n 0% { transform: translateX(0) scaleX(0); }\n 40% { transform: translateX(0) scaleX(0.4); }\n 100% { transform: translateX(100%) scaleX(0.5); }\n}"
},
{
"answer_id": 74317177,
"author": "Matthias",
"author_id": 3530084,
"author_profile": "https://Stackoverflow.com/users/3530084",
"pm_score": 0,
"selected": false,
"text": "@keyframes indeterminateAnimation {\n 0% { transform: translateX(0) scaleX(0); }\n 40% { transform: translateX(0) scaleX(0.4); }\n 100% { transform: translateX(45%) scaleX(0.5); }\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20330384/"
] |
74,317,065 | <p>I have a dataset which has two variables, one character and one numeric :</p>
<pre><code>structure(list(ID = c("A", "B", "C", "D", "E", "A", "B", "C",
"D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E"),
value = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20)), class = "data.frame", row.names = c(NA,
-20L))
</code></pre>
<p>What I would like to do is to switch the values of the "value" variable between each group of "A" and "E" for every sequence of "A" and "E".</p>
<p>Thus, my final output should look like this:</p>
<pre><code>ID value
A 5
B 2
C 3
D 4
E 1
A 10
B 7
C 8
D 9
E 6
A 15
B 12
C 13
D 14
E 11
A 20
B 17
C 18
D 19
E 16
</code></pre>
<p>I used a sequence of numbers here just to make the example easy but my real values are not a sequence of 1 to 20. So, a solution that has a pattern of number would not work in my data.</p>
<p>Thanks!</p>
| [
{
"answer_id": 74317097,
"author": "Tom Hoel",
"author_id": 17213355,
"author_profile": "https://Stackoverflow.com/users/17213355",
"pm_score": 0,
"selected": false,
"text": "library(tidyverse)\n\ndf %>% \n pivot_wider(names_from = ID, \n values_from = value) %>% \n unnest(everything()) %>% \n transform(A = E, \n E = A) %>% \n pivot_longer(cols = everything())\n\n# A tibble: 20 x 2\n name value\n <chr> <dbl>\n 1 A 5\n 2 B 2\n 3 C 3\n 4 D 4\n 5 E 1\n 6 A 10\n 7 B 7\n 8 C 8\n 9 D 9\n10 E 6\n11 A 15\n12 B 12\n13 C 13\n14 D 14\n15 E 11\n16 A 20\n17 B 17\n18 C 18\n19 D 19\n20 E 16\n"
},
{
"answer_id": 74317175,
"author": "Robert Hacken",
"author_id": 2094893,
"author_profile": "https://Stackoverflow.com/users/2094893",
"pm_score": 1,
"selected": false,
"text": "# matrix with indices of A's and E's in its two rows\nae <- matrix(which(df$ID %in% c('A', 'E')), nrow=2)\n# switch A and E\ndf$value[ae] <- df$value[ae[2:1, ]]\n\ndf\n# ID value\n# 1 A 5\n# 2 B 2\n# 3 C 3\n# 4 D 4\n# 5 E 1\n# 6 A 10\n# 7 B 7\n# 8 C 8\n# 9 D 9\n# 10 E 6\n# 11 A 15\n# 12 B 12\n# 13 C 13\n# 14 D 14\n# 15 E 11\n# 16 A 20\n# 17 B 17\n# 18 C 18\n# 19 D 19\n# 20 E 16\n"
},
{
"answer_id": 74317341,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 1,
"selected": false,
"text": "dplyr"
},
{
"answer_id": 74317481,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 0,
"selected": false,
"text": "vA <- df$value[df$ID == \"A\"]\nvE <- df$value[df$ID == \"E\"]\n\ndf$value[df$ID == \"A\"] <- vE\ndf$value[df$ID == \"E\"] <- vA\n\ndf\n#> ID value\n#> 1 A 5\n#> 2 B 2\n#> 3 C 3\n#> 4 D 4\n#> 5 E 1\n#> 6 A 10\n#> 7 B 7\n#> 8 C 8\n#> 9 D 9\n#> 10 E 6\n#> 11 A 15\n#> 12 B 12\n#> 13 C 13\n#> 14 D 14\n#> 15 E 11\n#> 16 A 20\n#> 17 B 17\n#> 18 C 18\n#> 19 D 19\n#> 20 E 16\n"
},
{
"answer_id": 74317528,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 1,
"selected": false,
"text": "df$ID <- ifelse(df$ID == \"A\", \"E\", ifelse(df$ID == \"E\", \"A\", df$ID))\n"
},
{
"answer_id": 74317816,
"author": "jblood94",
"author_id": 9463489,
"author_profile": "https://Stackoverflow.com/users/9463489",
"pm_score": 1,
"selected": false,
"text": "value"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13069688/"
] |
74,317,090 | <p>I have question about showing popup and hiding on mouseenter and mouseleave events.
HTML part of question:</p>
<pre><code><div id=\"social-wrapper\">
<input type=\"checkbox\" class=\"checkbox\" id=\"share\" />
<label for=\"share\" class=\"label entypo-export\"><span>share</span></label>
<div class=\"social\">
<ul>
<li>
<img id=\"linkdln\" src=\"{$linkdln}\" />
</li>
<li>
<img id=\"facebook\" src=\"{$facebook}\" />
</li>
<li>
<img id=\"twitter\" src=\"{$twitter}\" />
</li>
<li>
<img id=\"copy\" src=\"{$copy}\" />
</li>
</ul>
</div>
</div>
</code></pre>
<p>Frontend</p>
<p><a href="https://i.stack.imgur.com/PWNVP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PWNVP.png" alt="enter image description here" /></a></p>
<p>Jquery Part</p>
<pre><code>var CHECKBOX = jQuery('input#share');
var mouse_is_inside = false
jQuery('.label').on({
mouseenter: function () {
mouse_is_inside = true;
//$(CHECKBOX).prop("checked", true).trigger("change");
// console.log('entering!');
},
mouseleave: function () {
// $(CHECKBOX).prop("checked", false).trigger("change");
// console.log('outside now!');
mouse_is_inside = false;
}
});
</code></pre>
<p>I want when user hover the Share button to open popup, that's easy and I achieved that. But problem it's not hiding it.
Should be on mouseleave, but if user leaves share button will hive and user will no have opportunity to select social media, so i need to set good condition for hiding it.</p>
<p>if someone can help will be thankful!</p>
| [
{
"answer_id": 74317235,
"author": "zillionera_dev",
"author_id": 15306153,
"author_profile": "https://Stackoverflow.com/users/15306153",
"pm_score": 3,
"selected": true,
"text": "#social-wrapper:hover .social {\n visibility: visible;\n opacity: 1;\n position: relative;\n}\n#social-wrapper .social {\n visibility: hidden;\n opacity: 0;\n position: absolute;\n bottom: -30px;\n} \n"
},
{
"answer_id": 74323189,
"author": "Twisty",
"author_id": 463319,
"author_profile": "https://Stackoverflow.com/users/463319",
"pm_score": 0,
"selected": false,
"text": ".hover()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14283036/"
] |
74,317,095 | <p>Apologies in advance for such a long and basic question!</p>
<p>Given the following three <code>html</code> snippets which are part of a bigger part as follows:</p>
<pre><code><html>
<body>
<span _ngcontent-ont-c199="" class="font-weight-bold">
<span _ngcontent-ont-c199="" class="ng-star-inserted">
<span _ngcontent-ont-c199="" translate="">
nro
</span>
4 A.
</span>
<!-- -->
<span _ngcontent-ont-c199="" class="ng-star-inserted">
6.12.1939
</span>
<!-- -->
</span>
<span _ngcontent-ont-c199="" class="ng-star-inserted">
, JR 10
</span>
<!-- -->
<!-- -->
<span _ngcontent-ont-c199="" class="ng-star-inserted">
:
<span _ngcontent-ont-c199="" translate="">
sivu
</span>
1
</span>
</body>
</html>
</code></pre>
<p>and</p>
<pre><code><html>
<body>
<span _ngcontent-evu-c199="" class="font-weight-bold">
<!-- -->
<span _ngcontent-evu-c199="" class="ng-star-inserted">
1905
</span>
<!-- -->
</span>
<span _ngcontent-evu-c199="" class="ng-star-inserted">
, Aksel Paul
</span>
<!-- -->
<span _ngcontent-evu-c199="" class="ng-star-inserted">
, Helsinki
</span>
<!-- -->
<span _ngcontent-evu-c199="" class="ng-star-inserted">
:
<span _ngcontent-evu-c199="" translate="">
page
</span>
63
</span>
</body>
</html>
</code></pre>
<p>and</p>
<pre><code><html>
<body>
<span _ngcontent-ejj-c199="" class="badge badge-secondary ng-star-inserted">
22
</span>
<span _ngcontent-dna-c199="" class="font-weight-bold">
<span _ngcontent-dna-c199="" class="ng-star-inserted">
<span _ngcontent-dna-c199="" translate="">
nro
</span>
12 ZZ
</span>
<span _ngcontent-dna-c199="" class="ng-star-inserted">
10.2016
</span>
</span>
<span _ngcontent-ejj-c199="" class="ng-star-inserted">
, Arbetarförlaget Ab
</span>
<!-- -->
<span _ngcontent-ejj-c199="" class="ng-star-inserted">
, Stockholm
</span>
<!-- -->
<span _ngcontent-ejj-c199="" class="ng-star-inserted">
:
<span _ngcontent-ejj-c199="" translate="">
sida
</span>
20
</span>
</body>
</html>
</code></pre>
<p>I would like to extract 6 different information (if available otherwise <code>None</code>) using a desired list which looks as follows:</p>
<pre><code>desired_list = ["badge", "issue", "date", "publisher", "city", "page"]
</code></pre>
<p>So I have the following code (very inefficient using for loop):</p>
<pre><code>desired_list = [None]*6 # initialize with [None, None, None, None, None, None]
soup = BeautifulSoup(html, "lxml") # html_1, html_2, html_3
fwb = soup.find("span", class_="font-weight-bold")
issue_date = fwb.select("span.ng-star-inserted") # always a list of 2 elements: ['nro XX extension', 'DD.MM.YYYY']
for el in issue_date:
element = el.text.split()
if "nro" in element:
desired_list[1] = " ".join(element) # handling issue: nro XX extension
desired_list[2] = " ".join(element) # handling date: DD.MM.YYYY
badge = soup.find("span", class_="badge badge-secondary ng-star-inserted")
if badge: desired_list[0] = " ".join(badge.text.split()) # handling badge
</code></pre>
<p>Currently, I can only extract info for first three components in my <code>desired_list</code>, namely, <code>badge</code>, <code>issue</code>, <code>date</code>.</p>
<pre><code>[None, 'nro 4 A.', '6.12.1939', None, None, None] # html_1
[None, None, '1905', None, None, None] # html_2
['22', 'nro 12 ZZ', '10.2016', None, None, None] # html_3
</code></pre>
<p>Whereas, my desired list for each <code>html</code> should looks like this:</p>
<pre><code>[None, 'nro 4 A.', '6.12.1939', 'JR 10', None, 'sivu 1'] # html_1
[None, None, '1905', 'Aksel Paul', 'Helsinki', 'page 63'] # html_2
['22', 'nro 12 ZZ', '10.2016', 'Arbetarförlaget Ab', 'Stockholm', 'sida 20'] # html_3
</code></pre>
<p>And I don't know how to manipulate my code to retrieve all 6 fields given the aforementioned <code>html</code> snippets since their occurrences are very stochastic meaning that it can happen some information is missing. I really appreciate if someone can recommend me smarter and more efficient way of handling this.</p>
<p>I am aware of <code>soup.find_all("span", class_="ng-star-inserted")</code>. However, the problem is that <code>find_all</code> does not always return a list with length of 6 to enumerate!</p>
<p>Cheers,</p>
| [
{
"answer_id": 74317283,
"author": "svfat",
"author_id": 2419628,
"author_profile": "https://Stackoverflow.com/users/2419628",
"pm_score": 0,
"selected": false,
"text": " result = soup.find_all(\"span\", \"ng-star-inserted\")\n for position, element in enumerate(result):\n print(el)\n"
},
{
"answer_id": 74331712,
"author": "Driftr95",
"author_id": 6146136,
"author_profile": "https://Stackoverflow.com/users/6146136",
"pm_score": 2,
"selected": true,
"text": "desired_list"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5437090/"
] |
74,317,098 | <p>How to center a HR tag vertically in a div, i tried this but its not centered perfectly</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
position: relative;
width: 80vw;
height: 40vh;
border: solid 4px #333;
}
hr {
height: 5px;
background-color: cadetblue;
position: absolute;
right: 0;
top: 50%;
left: 0;
transform: translateY(-100%);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
<hr>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74317170,
"author": "Johannes",
"author_id": 5641669,
"author_profile": "https://Stackoverflow.com/users/5641669",
"pm_score": 3,
"selected": true,
"text": "transform"
},
{
"answer_id": 74317255,
"author": "PA.",
"author_id": 30447,
"author_profile": "https://Stackoverflow.com/users/30447",
"pm_score": 2,
"selected": false,
"text": "hr"
},
{
"answer_id": 74317410,
"author": "Amit Kumar",
"author_id": 20379294,
"author_profile": "https://Stackoverflow.com/users/20379294",
"pm_score": 0,
"selected": false,
"text": "transform"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18461576/"
] |
74,317,103 | <p>The project required is to make the uppercase letters to be lowercased and vice versa. I don't understand why my code isn't working as expected.</p>
<p>The code is below:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let start4 = 0;
let swappedName = "elZerO";
for (let i = 0; i < swappedName.length; i++) {
if (swappedName[i] === swappedName[i].toLowerCase()) {
swappedName[i].toUpperCase();
} else {
swappedName[i].toLowerCase();
}
console.log(swappedName);
}</code></pre>
</div>
</div>
</p>
<p>The result of the code was nothing changed in the text.</p>
| [
{
"answer_id": 74317170,
"author": "Johannes",
"author_id": 5641669,
"author_profile": "https://Stackoverflow.com/users/5641669",
"pm_score": 3,
"selected": true,
"text": "transform"
},
{
"answer_id": 74317255,
"author": "PA.",
"author_id": 30447,
"author_profile": "https://Stackoverflow.com/users/30447",
"pm_score": 2,
"selected": false,
"text": "hr"
},
{
"answer_id": 74317410,
"author": "Amit Kumar",
"author_id": 20379294,
"author_profile": "https://Stackoverflow.com/users/20379294",
"pm_score": 0,
"selected": false,
"text": "transform"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16385537/"
] |
74,317,133 | <p>I am trying to do a complex order by or possibly a group by and then order by. The table name is curtomer_updates. What I want it to do is first of all sort by descending order on the last_updated_date and then have a unique cust_id together sorted by last_updated_date. Below is an example of what it is right now and the expected result. Thank you for any help.</p>
<p><strong>Table normally sorted</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: right;">Update_ID</th>
<th style="text-align: right;">Cust_Id</th>
<th style="text-align: left;">Field_updated</th>
<th style="text-align: left;">Last_updated_date</th>
<th style="text-align: left;">Updated_by</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1223</td>
<td style="text-align: left;">Name</td>
<td style="text-align: left;">2021-11-01 12:23</td>
<td style="text-align: left;">Frodo Baggins</td>
</tr>
<tr>
<td style="text-align: right;">2</td>
<td style="text-align: right;">9999</td>
<td style="text-align: left;">address</td>
<td style="text-align: left;">2021-12-02 19:23</td>
<td style="text-align: left;">Legolas</td>
</tr>
<tr>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2200</td>
<td style="text-align: left;">phone</td>
<td style="text-align: left;">2021-12-03 23:00</td>
<td style="text-align: left;">Bilbo Baggins</td>
</tr>
<tr>
<td style="text-align: right;">4</td>
<td style="text-align: right;">2200</td>
<td style="text-align: left;">Name</td>
<td style="text-align: left;">2022-01-04 02:23</td>
<td style="text-align: left;">Bilbo Baggins</td>
</tr>
<tr>
<td style="text-align: right;">5</td>
<td style="text-align: right;">9999</td>
<td style="text-align: left;">phone</td>
<td style="text-align: left;">2022-02-05 12:23</td>
<td style="text-align: left;">Golum</td>
</tr>
<tr>
<td style="text-align: right;">6</td>
<td style="text-align: right;">9999</td>
<td style="text-align: left;">address</td>
<td style="text-align: left;">2022-03-06 20:00</td>
<td style="text-align: left;">Sauron</td>
</tr>
<tr>
<td style="text-align: right;">7</td>
<td style="text-align: right;">1223</td>
<td style="text-align: left;">address</td>
<td style="text-align: left;">2022-04-07 01:24</td>
<td style="text-align: left;">Gandalf</td>
</tr>
<tr>
<td style="text-align: right;">8</td>
<td style="text-align: right;">2200</td>
<td style="text-align: left;">email</td>
<td style="text-align: left;">2022-05-08 12:50</td>
<td style="text-align: left;">Some Urkai</td>
</tr>
<tr>
<td style="text-align: right;">9</td>
<td style="text-align: right;">3412</td>
<td style="text-align: left;">email, phone</td>
<td style="text-align: left;">2022-06-08 08:45</td>
<td style="text-align: left;">Golum</td>
</tr>
<tr>
<td style="text-align: right;">10</td>
<td style="text-align: right;">1223</td>
<td style="text-align: left;">address</td>
<td style="text-align: left;">2022-07-10 00:23</td>
<td style="text-align: left;">Pippin</td>
</tr>
<tr>
<td style="text-align: right;">11</td>
<td style="text-align: right;">3412</td>
<td style="text-align: left;">email, address</td>
<td style="text-align: left;">2022-09-22 16:48</td>
<td style="text-align: left;">Gandalf</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Expected result</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: right;">Update_ID</th>
<th style="text-align: right;">Cust_Id</th>
<th style="text-align: left;">Field_updated</th>
<th style="text-align: left;">Last_updated_date</th>
<th style="text-align: left;">Updated_by</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">11</td>
<td style="text-align: right;">3412</td>
<td style="text-align: left;">email, address</td>
<td style="text-align: left;">2022-09-22 16:48</td>
<td style="text-align: left;">Gandalf</td>
</tr>
<tr>
<td style="text-align: right;">9</td>
<td style="text-align: right;">3412</td>
<td style="text-align: left;">email, phone</td>
<td style="text-align: left;">2022-06-08 08:45</td>
<td style="text-align: left;">Golum</td>
</tr>
<tr>
<td style="text-align: right;">10</td>
<td style="text-align: right;">1223</td>
<td style="text-align: left;">address</td>
<td style="text-align: left;">2022-07-10 00:23</td>
<td style="text-align: left;">Pippin</td>
</tr>
<tr>
<td style="text-align: right;">7</td>
<td style="text-align: right;">1223</td>
<td style="text-align: left;">address</td>
<td style="text-align: left;">2022-04-07 01:24</td>
<td style="text-align: left;">Gandalf</td>
</tr>
<tr>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1223</td>
<td style="text-align: left;">Name</td>
<td style="text-align: left;">2021-11-01 12:23</td>
<td style="text-align: left;">Frodo Baggins</td>
</tr>
<tr>
<td style="text-align: right;">8</td>
<td style="text-align: right;">2200</td>
<td style="text-align: left;">email</td>
<td style="text-align: left;">2022-05-08 12:50</td>
<td style="text-align: left;">Some Urkai</td>
</tr>
<tr>
<td style="text-align: right;">4</td>
<td style="text-align: right;">2200</td>
<td style="text-align: left;">Name</td>
<td style="text-align: left;">2022-01-04 02:23</td>
<td style="text-align: left;">Bilbo Baggins</td>
</tr>
<tr>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2200</td>
<td style="text-align: left;">phone</td>
<td style="text-align: left;">2021-12-03 23:00</td>
<td style="text-align: left;">Bilbo Baggins</td>
</tr>
<tr>
<td style="text-align: right;">6</td>
<td style="text-align: right;">9999</td>
<td style="text-align: left;">address</td>
<td style="text-align: left;">2022-03-06 20:00</td>
<td style="text-align: left;">Sauron</td>
</tr>
<tr>
<td style="text-align: right;">5</td>
<td style="text-align: right;">9999</td>
<td style="text-align: left;">phone</td>
<td style="text-align: left;">2022-02-05 12:23</td>
<td style="text-align: left;">Golum</td>
</tr>
<tr>
<td style="text-align: right;">2</td>
<td style="text-align: right;">9999</td>
<td style="text-align: left;">address</td>
<td style="text-align: left;">2021-12-02 19:23</td>
<td style="text-align: left;">Legolas</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74317637,
"author": "The Impaler",
"author_id": 6436191,
"author_profile": "https://Stackoverflow.com/users/6436191",
"pm_score": 2,
"selected": false,
"text": "select t.*\nfrom customer_updates t\njoin (\n select cust_id, dense_rank() over(order by max(last_updated_date)) as rk\n from customer_updates\n group by cust_id\n) x on x.cust_id = t.cust_id\norder by x.rk desc, t.last_updated_date desc\n"
},
{
"answer_id": 74318230,
"author": "wnutt",
"author_id": 1665437,
"author_profile": "https://Stackoverflow.com/users/1665437",
"pm_score": 2,
"selected": false,
"text": "SELECT *\nFROM curtomer_updates\nORDER BY \n MAX(Last_updated_date) OVER (PARTITION BY cust_id) DESC\n ,Last_updated_date DESC\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8594588/"
] |
74,317,135 | <p>edit: i cant edit the original code, since the button and its function is provided by a plugin. If could find the initial JS for the function of the button, i would hide the first one and recreate / modify it myself if thats somehow possible..</p>
<p>I have a button which is already styled and running a javascript function (cant find the code for it).</p>
<p>Is it possible to create a popup for that existing button?</p>
<p>Found this tutorial on how to create a popup on W3</p>
<pre><code><div class="popup w3-text-blue" onclick="myFunction()">Click me to toggle the popup!
<span class="popuptext" id="myPopup">A Simple Popup!</span>
</div>
<style>
.popup {
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.popup .popuptext {
visibility: hidden;
width: 160px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
}
.popup .popuptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent; }
span#myPopup.popuptext.show {
visibility: visible;
}
</style>
<script>
// When the user clicks the div, open the popup
function myFunction() {
var popup = document.getElementById('myPopup');
popup.classList.toggle('show');
}
</script>
</code></pre>
<p>but cant make it work for an existing button.</p>
<p>All info i have for that button:</p>
<pre><code><button type="button" class="class class2 class3" data-overwrite-fields="1"><i class="fas fa-check fa-fw"></i> Submit</button>
</code></pre>
<p>(the i class is an svg image)</p>
<p>Is it possible to create a popup for that button or should i move on?</p>
| [
{
"answer_id": 74317637,
"author": "The Impaler",
"author_id": 6436191,
"author_profile": "https://Stackoverflow.com/users/6436191",
"pm_score": 2,
"selected": false,
"text": "select t.*\nfrom customer_updates t\njoin (\n select cust_id, dense_rank() over(order by max(last_updated_date)) as rk\n from customer_updates\n group by cust_id\n) x on x.cust_id = t.cust_id\norder by x.rk desc, t.last_updated_date desc\n"
},
{
"answer_id": 74318230,
"author": "wnutt",
"author_id": 1665437,
"author_profile": "https://Stackoverflow.com/users/1665437",
"pm_score": 2,
"selected": false,
"text": "SELECT *\nFROM curtomer_updates\nORDER BY \n MAX(Last_updated_date) OVER (PARTITION BY cust_id) DESC\n ,Last_updated_date DESC\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19957060/"
] |
74,317,164 | <p>I am currently working on a plugin for grandMA2 lighting control using Lua. I need the current time. The only way to get the current time is the following function:</p>
<pre><code>gma.show.getvar('TIME')
</code></pre>
<p>which always returns the current system time, which I then store in a variable. An example return value is <code>"12h54m47.517s"</code>.</p>
<p>How can I separate the hours, minutes and seconds into 3 variables?</p>
| [
{
"answer_id": 74317534,
"author": "LMD",
"author_id": 7185318,
"author_profile": "https://Stackoverflow.com/users/7185318",
"pm_score": 2,
"selected": false,
"text": "os.date"
},
{
"answer_id": 74323875,
"author": "koyaanisqatsi",
"author_id": 11740758,
"author_profile": "https://Stackoverflow.com/users/11740758",
"pm_score": 0,
"selected": false,
"text": "gsub()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19980635/"
] |
74,317,214 | <p>What I am trying to achieve is to archive the app and still have a working consent form on the app.</p>
<p>Although this piece of code is deprecated and says to use ORKInstructionStep I haven't found anywhere how to use ORKInstructionStep instead of ORKVisualConsentStep.
<a href="https://i.stack.imgur.com/j6zJO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j6zJO.png" alt="" /></a>
Whenever I try to Archive the app I keep getting this problem. Still, I also can't remove the ORKVisualConsentStep because I haven't been able to find anywhere how to add the consentDocument otherwise.
<a href="https://i.stack.imgur.com/AAsbR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AAsbR.png" alt="" /></a></p>
<p>I've looked at so many other tutorials and all of them use the ORKVisualConsentStep and haven't seen anyone that has had this problem show how to still keep the consent form working. I can get the app running on a phone but I can't get it to archive so not entirely sure what is going on.</p>
<p>Any insight would be beneficial thank you</p>
| [
{
"answer_id": 74657364,
"author": "Zohaib Suhail",
"author_id": 20417397,
"author_profile": "https://Stackoverflow.com/users/20417397",
"pm_score": 1,
"selected": true,
"text": "instructionStep.imageContentMode = .scaleAspectFit"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20417397/"
] |
74,317,262 | <p>This is my first time submitting here, so please bear with me on formatting.</p>
<p>So, I have a normal list of strings like:</p>
<pre class="lang-py prettyprint-override"><code>name = ["Michael", "Helen", "Mike", "Joe", "Michael"]
</code></pre>
<p>I need to append these to another list if they don't repeat, and then later print out that list. So the next list would be like</p>
<pre class="lang-py prettyprint-override"><code>norepeat_list = ["Michael", "Helen", "Mike", "Joe"]
</code></pre>
<p>Which I've already done and didn't have issues with. The problem is I'm not just appending those names, each name has another value associated with it in another list of times (also strings), and I need that too. So I've been appending both the name and the times at the same time in a list like</p>
<pre><code>norepeat_list.append(name[i], time[i])
</code></pre>
<p>Which then makes the result a 2d list. So I don't know how to make it so that the program checks each list in the list for the original name value, and the only solution I've found is 'any' or some import stuff, and I can't do that.</p>
<p>So far I have:</p>
<pre><code>name = ["Michael", "Helen", "Mike", "Joe", "Michael"]
time = ["08:42:39", "08:39:56", "08:58:43", "09:04:03", "05:32:54"]
norepeat_list = []
for i in range(len(name[i])):
if name[i] not in norepeat_list:
norepeat_list.append(name[i])
for i in norepeat_list:
print(i)
</code></pre>
<p>I've tried appending the timestamp at the same time and adding another layer of <code>for j in ...</code>, but I can't get anything to work.</p>
| [
{
"answer_id": 74317336,
"author": "Minibumphead",
"author_id": 13852386,
"author_profile": "https://Stackoverflow.com/users/13852386",
"pm_score": -1,
"selected": false,
"text": "for n,t in zip(name,time):\n print(n,t)\n\nthis will zip the two lists together and you have access to the values of both lists.\n"
},
{
"answer_id": 74317342,
"author": "svfat",
"author_id": 2419628,
"author_profile": "https://Stackoverflow.com/users/2419628",
"pm_score": -1,
"selected": false,
"text": "name"
},
{
"answer_id": 74319652,
"author": "Sam Mason",
"author_id": 1358308,
"author_profile": "https://Stackoverflow.com/users/1358308",
"pm_score": 2,
"selected": false,
"text": "name = [\"Michael\", \"Helen\", \"Mike\", \"Joe\", \"Michael\"]\ntime = [\"08:42:39\", \"08:39:56\", \"08:58:43\", \"09:04:03\", \"05:32:54\"]\n\nseen_names = []\nnorepeat_list = []\nfor i in range(len(name)):\n if name[i] not in seen_names:\n seen_names.append(name[i])\n norepeat_list.append((name[i], time[i]))\n\nfor name_time in norepeat_list:\n print(name_time)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20417420/"
] |
74,317,276 | <p>I am working on a guitar application written in Objective-C. It has a feature like Tuning from Guitar. The tuning screen requires microphone permission. When we give permission to the app, suddenly the app starts producing a screeching noise which sounds very weird.</p>
<p>The same code is working on iOS 15 and lower versions. Only in iOS 16 and higher it is having this noise issue.</p>
<p>I have used audiokit and the version of audiokit is 2.2 and the latest version is 5.5.7</p>
<p><code>pod 'AudioKit'</code></p>
| [
{
"answer_id": 74317336,
"author": "Minibumphead",
"author_id": 13852386,
"author_profile": "https://Stackoverflow.com/users/13852386",
"pm_score": -1,
"selected": false,
"text": "for n,t in zip(name,time):\n print(n,t)\n\nthis will zip the two lists together and you have access to the values of both lists.\n"
},
{
"answer_id": 74317342,
"author": "svfat",
"author_id": 2419628,
"author_profile": "https://Stackoverflow.com/users/2419628",
"pm_score": -1,
"selected": false,
"text": "name"
},
{
"answer_id": 74319652,
"author": "Sam Mason",
"author_id": 1358308,
"author_profile": "https://Stackoverflow.com/users/1358308",
"pm_score": 2,
"selected": false,
"text": "name = [\"Michael\", \"Helen\", \"Mike\", \"Joe\", \"Michael\"]\ntime = [\"08:42:39\", \"08:39:56\", \"08:58:43\", \"09:04:03\", \"05:32:54\"]\n\nseen_names = []\nnorepeat_list = []\nfor i in range(len(name)):\n if name[i] not in seen_names:\n seen_names.append(name[i])\n norepeat_list.append((name[i], time[i]))\n\nfor name_time in norepeat_list:\n print(name_time)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12775090/"
] |
74,317,298 | <p>There is a playlist that consists of tracks and jingles:</p>
<pre><code>var arr = [
{'title': 'jingle fixed'},
{'title': track 0},
{'title': track 1},
{'title': 'jingle fixed'},
{'title': track 2},
{'title': 'jingle fixed'},
{'title': track 3},
{'title': track 4},
{'title': track 5}
];
function shuffle(playList) {
let currentIndex = playList.length, randomIndex;
while (currentIndex != 0) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
// How to except by playList.title?
[playList[currentIndex], playList[randomIndex]] = [playList[randomIndex], playList[currentIndex]];
}
return playList;
}
</code></pre>
<p>I need to randomize (shuffle) only the tracks, and leave the jingles in their position.</p>
<p>What is expected:</p>
<pre><code>[
{'title': 'jingle fixed'},
{'title': track 4},
{'title': track 1},
{'title': 'jingle fixed'},
{'title': track 5},
{'title': 'jingle fixed'},
{'title': track 3},
{'title': track 0},
{'title': track 1}
];
</code></pre>
| [
{
"answer_id": 74317655,
"author": "Peterrabbit",
"author_id": 18242865,
"author_profile": "https://Stackoverflow.com/users/18242865",
"pm_score": 2,
"selected": false,
"text": "const tracks = [{\n title: 'jingle fixed'\n },\n {\n title: \"track 4\"\n },\n {\n title: \"track 1\"\n },\n {\n title: 'jingle fixed'\n },\n {\n title: \"track 5\"\n },\n {\n title: 'jingle fixed'\n },\n {\n title: \" track 3\"\n },\n {\n title: \"track 0\"\n },\n {\n title: \"track 1\"\n }\n];\n\nconst shuff_tracks = tracks.filter(t => t.title !== \"jingle fixed\");\nshuff_tracks.sort(() => Math.floor(Math.random() * 10) % 2 === 0 ? 1 : -1);\n\nlet tr_i = -1;\n\nconst out = tracks.map(t => {\n if (t.title === \"jingle fixed\") return t;\n return shuff_tracks[++tr_i];\n});\n\nconsole.log(out)"
},
{
"answer_id": 74317804,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 2,
"selected": true,
"text": "let t = [ {'title': 'jingle fixed'}, {'title': 'track 0'}, {'title': 'track 1'}, {'title': 'jingle fixed'}, {'title': 'track 2'}, {'title': 'jingle fixed'}, {'title': 'track 3'}, {'title': 'track 4'}, {'title': 'track 5'}];\nlet m=i=>i.title!=='jingle fixed', f=t.filter(m);\nt = t.map(i=>m(i)?f.splice(~~(Math.random()*f.length),1)[0]:i);\nconsole.log(t);"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9968097/"
] |
74,317,301 | <p>i got an array like this</p>
<pre><code>$ratings =
[
[ 'text' => 'bla',
'author' => 'Ute U.',
'stars' => 2
],
[ 'text' => 'bla2',
'author' => 'Ute a.',
'stars' => 4
]
]
</code></pre>
<p>Its obvious that the value behind 'stars' is an integer.
But how do I compare that value with any number?
What i tried, and doesn't work is</p>
<pre><code>foreach ($ratings as $rating)
{
if ($rating['stars'] == 5)
{
$showRatings[] = $rating;
}
}
</code></pre>
<p>The assigning line isnt the problem, i am sure of that since all other code not regarding the comparism works with this line.</p>
<p>I ofc also tried 12 other solution from various sites.. it never ever works..</p>
<p>Please help a brother out here.</p>
| [
{
"answer_id": 74317655,
"author": "Peterrabbit",
"author_id": 18242865,
"author_profile": "https://Stackoverflow.com/users/18242865",
"pm_score": 2,
"selected": false,
"text": "const tracks = [{\n title: 'jingle fixed'\n },\n {\n title: \"track 4\"\n },\n {\n title: \"track 1\"\n },\n {\n title: 'jingle fixed'\n },\n {\n title: \"track 5\"\n },\n {\n title: 'jingle fixed'\n },\n {\n title: \" track 3\"\n },\n {\n title: \"track 0\"\n },\n {\n title: \"track 1\"\n }\n];\n\nconst shuff_tracks = tracks.filter(t => t.title !== \"jingle fixed\");\nshuff_tracks.sort(() => Math.floor(Math.random() * 10) % 2 === 0 ? 1 : -1);\n\nlet tr_i = -1;\n\nconst out = tracks.map(t => {\n if (t.title === \"jingle fixed\") return t;\n return shuff_tracks[++tr_i];\n});\n\nconsole.log(out)"
},
{
"answer_id": 74317804,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 2,
"selected": true,
"text": "let t = [ {'title': 'jingle fixed'}, {'title': 'track 0'}, {'title': 'track 1'}, {'title': 'jingle fixed'}, {'title': 'track 2'}, {'title': 'jingle fixed'}, {'title': 'track 3'}, {'title': 'track 4'}, {'title': 'track 5'}];\nlet m=i=>i.title!=='jingle fixed', f=t.filter(m);\nt = t.map(i=>m(i)?f.splice(~~(Math.random()*f.length),1)[0]:i);\nconsole.log(t);"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11730571/"
] |
74,317,309 | <p>I have a variable url, which has the following value: 'https://xxx?yyy?zzz'</p>
<p>Through a for loop, I am trying to split the url into :
- https://xxx
- yyy
- zzz</p>
<p>I do that division thanks to the .split(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split</a>) method.</p>
<p>So, what I have is the following:</p>
<p>let url = https://xxx?yyy?zzz;</p>
<pre><code>if(url.includes("?")) {
for(var i = 0; i <= url.split("?").length; i++) {
urlTotal = url.split("?")[i] + '?'
}
}
</code></pre>
<p>What I would like to do is to join the first two parts of the url, like this: https://xxx?yyy.</p>
<p>But I also have to keep in mind that if the url has, for example, 5 '?', I have to take the first four parts.</p>
<p>For example:
let url = https://xxx?yyy?zzz?jjj?hhh</p>
<p>The result, should be the following: https://xxx?yyy?zzz?jjj</p>
<p>Thank you.</p>
| [
{
"answer_id": 74317397,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 2,
"selected": false,
"text": "let url = 'https://xxx?yyy?zzz?jjj?hhh';\nconsole.log(url.includes('?')?url.split('?').slice(0,-1).join('?'):url);"
},
{
"answer_id": 74317405,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 2,
"selected": true,
"text": "let str1 = `https://xxx?yyy?zzz`\nlet str2 = `https://xxx?yyy?zzz?jjj?hhh`\nlet str3 = `https://stackoverflow.com/`\n\nconst parse = (url) => {\n if(url.indexOf('?') == -1){\n return url\n }\n let strs = url.split('?')\n strs = strs.slice(0,strs.length-1)\n return strs.join('?')\n}\n\nconsole.log(parse(str1))\nconsole.log(parse(str2))\nconsole.log(parse(str3))"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19672488/"
] |
74,317,322 | <p>I am currently having hard time creating a formula for my sheet to record values when the following conditions will be met:
I want to give 15% discount from the original price if a Person purchased their ticket online (<code>Online = TRUE</code>), and only applicable for customers who is atleast 50 years old, kindly list the new calculated discounted price in the <code>Discounted Price</code> Column</p>
<p>I have tried creating a formula but I got <code>formula parse error</code>.
Formula used : <code>=IF((B2=TRUE AND D2>50),(E2*0.85),E2)</code></p>
<p>This is my sample data in the sheet and the expected output on Discounted Price column. Any help will be appreciated.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Person</th>
<th>Online</th>
<th>Physical Store</th>
<th>Age</th>
<th>Original Price</th>
<th>Discounted Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>TRUE</td>
<td>FALSE</td>
<td>67</td>
<td>1000</td>
<td>850</td>
</tr>
<tr>
<td>B</td>
<td>TRUE</td>
<td>FALSE</td>
<td>16</td>
<td>1000</td>
<td>1000</td>
</tr>
<tr>
<td>C</td>
<td>FALSE</td>
<td>TRUE</td>
<td>24</td>
<td>1000</td>
<td>1000</td>
</tr>
<tr>
<td>D</td>
<td>TRUE</td>
<td>FALSE</td>
<td>52</td>
<td>1000</td>
<td>850</td>
</tr>
<tr>
<td>E</td>
<td>FALSE</td>
<td>TRUE</td>
<td>60</td>
<td>1000</td>
<td>1000</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74317385,
"author": "George",
"author_id": 20345563,
"author_profile": "https://Stackoverflow.com/users/20345563",
"pm_score": 3,
"selected": true,
"text": "AND"
},
{
"answer_id": 74321541,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 0,
"selected": false,
"text": "=INDEX(IF(B2:B=\"\",,IF((B2:B=TRUE)*(D2:D>50), (E2:E*0.85), E2:E))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20415984/"
] |
74,317,344 | <p>I have a list of numbers. Each index has <code>3</code> values.</p>
<p><code>[{24, 17, 22}, {16, 4, 38}, {25, 13, 38}, {32, 18, 15}, {8, 10, 18}]</code></p>
<p>I am trying to convert them into <code>39 bit</code> string and turning on bits according to <code>integer</code> values.</p>
<p>For example, <code>{24, 17, 22}</code> means that I should turn on bits <code>24, 17, 22</code> among <code>39 bits</code>.</p>
<p><strong>Sample Code:</strong></p>
<pre><code>p1='000000000000000000000000000001011000000' #39 bit just to get length (39)
for x in range(0, len(mylist), 1):
a = mylist[x]
a = ''.join('1' if i in a else '0' for i in range(len(p1)))
print (len(a))
print (a)
</code></pre>
<p><strong>Output:</strong></p>
<pre><code>39
000000000000000001000010100000000000000
39
000010000000000010000000000000000000001
39
000000000000010000000000010000000000001
39
000000000000000100100000000000001000000
39
000000001010000000100000000000000000000
</code></pre>
<p>if we look at numbers <code>{16, 4, 38}, {25, 13, 38}</code> in the list, the last two numbers are <code>38</code>. Their <code>39 bit</code> ouput string are <code>000010000000000010000000000000000000001</code> and <code>000000000000010000000000010000000000001</code>. However, the on bits should be at index <code>38</code> not <code>39</code>.</p>
<p><strong>Am I making a mistake?</strong></p>
| [
{
"answer_id": 74317385,
"author": "George",
"author_id": 20345563,
"author_profile": "https://Stackoverflow.com/users/20345563",
"pm_score": 3,
"selected": true,
"text": "AND"
},
{
"answer_id": 74321541,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 0,
"selected": false,
"text": "=INDEX(IF(B2:B=\"\",,IF((B2:B=TRUE)*(D2:D>50), (E2:E*0.85), E2:E))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74317344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13373167/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.