Sachin21112004 commited on
Commit
b41f8b9
·
verified ·
1 Parent(s): eef802b

Upload folder using huggingface_hub

Browse files
rag/rag_component_temp.jsonl CHANGED
@@ -1,7 +1,6 @@
1
- {"id": "88c0ca69-b13f-41d6-9bef-58e170c7342d", "text": "Q: &lt;img&gt; attribute in the first element is different than other elements, preventing me from scraping its URL A: <p>Simply select all of the images, iterate over the <code>ResultSet</code> and check if an attribute is available to extract its value and print it or append it do a <code>list</code> or <code>set</code> in case of avoiding duplicates.</p>\n<p>Example:</p>\n<pre class=\"lang-py prettyprint-override\"><code>from bs4 import BeautifulSoup\n\nhtml = '''\n&lt;img class=&quot;class_name&quot; src=&quot;https://website1.png&quot;/&gt;\n&lt;img class=&quot;class_name late&quot; data-src=&quot;https://website2.png&quot;/&gt;\n&lt;img class=&quot;class_name late&quot; data-src=&quot;https://website3.png&quot;/&gt;\n'''\nsoup = BeautifulSoup(html)\n\nfor link in soup.select('img.class_name'):\n if link.get('src'):\n print(link.get('src'))\n else:\n print(link.get('data-src'))\n</code></pre>\n<p>Output:</p>\n<pre><code>https://website1.png\nhttps://website2.png\nhttps://website3.png\n</code></pre>\n", "tags": ["python", "html", "web-scraping"]}
2
- {"id": "711daddb-4b19-4d46-bfb3-a3629d895807", "text": "Q: Problem displaying png file from web server to client web browser in C A: <ol>\n<li><p><code>send(new_socket, http_header, sizeof(http_header), 0);</code> should be <code>strlen(http_header)</code> instead of <code>sizeof</code>.</p>\n</li>\n<li><p><code>if (file &gt; 0) {</code> doesn't do anything, you already check if the fil exist after you open it, and as it's a pointer you only want to check if it's NULL or not.</p>\n</li>\n<li><p><code>fread()</code> returns a size_t not a long (they may be the same type of course).</p>\n</li>\n<li><p>You have use bytes_read instead of <code>sizeof(dbuffer)</code> in <code>send()</code> to a short read results in a short write (but see refinement for partial writes which are normal).</p>\n</li>\n<li><p>(not fixed) Browsers may request other files. Firefox, for instance, asks for a <code>/favicon.ico</code> so you want to reject that with a 403. With the above changes curl returns file as is.</p>\n</li>\n<li><p>As you run that send in a <code>while(1)</code> you probably want to move the <code>rewind(file)</code> into that <code>while</code>-loop and you may need to <code>clearerr(file)</code> too.</p>\n</li>\n</ol>\n<pre><code> size_t bytes_read;\n do {\n bytes_read = fread(dbuffer, 1, BUFFER_LEN, file);\n ssize_t bytes_sent;\n for(size_t n = 0; n &lt; bytes_read; n += bytes_sent) {\n bytes_sent = send(new_socket, dbuffer + n, bytes_read - n, 0);\n if(bytes_sent == -1) {\n perror(&quot;send failed&quot;);\n goto err;\n }\n }\n // if feof(file) then we just finished reading the file,\n // otherwise we may want to perror() something.\n } while(bytes_read == BUFFER_LEN);\nerr:\n close(new_socket);\n clearerr(file);\n rewind(file);\n</code></pre>\n", "tags": ["c", "http"]}
3
- {"id": "3a4a4940-95e8-485b-b5a3-6ff52bf29cec", "text": "Q: Can you use the this keyword outside of the non static function member? A: <p><code>this</code> can't be used outside member function. It is in fact an implicit (hidden) argument of member function.<br />\nSince C++23 there is new syntax to pass <code>this</code> explicitly to member function:</p>\n<p><a href=\"https://en.cppreference.com/cpp/language/member_functions#Explicit_object_member_functions\" rel=\"nofollow noreferrer\">Non-static member functions - explicit object parameter</a></p>\n<blockquote>\n<h4>Explicit object member functions</h4>\n<p>For a non-static non-virtual member function not declared with cv-qualifier or ref-qualifier, its first parameter, if not being a <a href=\"https://en.cppreference.com/cpp/language/parameter_pack\" rel=\"nofollow noreferrer\" title=\"cpp/language/parameter pack\">function parameter pack</a>, can be an <a href=\"https://en.cppreference.com/cpp/language/function#Explicit_object_parameter\" rel=\"nofollow noreferrer\" title=\"cpp/language/function\">explicit object parameter</a> (denoted with the prefixed keyword <code>this</code>):</p>\n<pre><code>struct X\n{\n void foo(this X const&amp; self, int i); // same as void foo(int i) const &amp;;\n// void foo(int i) const &amp;; // Error: already declared\n\n void bar(this X self, int i); // pass object by value: makes a copy of \u201c\\*this\u201d\n};\n</code></pre>\n</blockquote>\n<p>In old syntax first parameter is hidden under <code>this</code> keyword.</p>\n<p>If you see this new syntax for member functions, it becomes obvious why using <code>this</code> outside member function doesn't make sense.</p>\n<p>If you try use <a href=\"https://en.cppreference.com/cpp/utility/functional/bind\" rel=\"nofollow noreferrer\"><code>std::bind</code></a> with member functions this hidden <code>this</code> argument also becomes more obvious.</p>\n", "tags": ["c++", "class", "this", "memory-address", "this-pointer"]}
4
- {"id": "89c96e39-43c6-4682-8f6c-7dfee80f1e74", "text": "Q: Replicating the iOS 26 Tab Bar: Components, Animations, and Dimensions A: <p>You are my hero man! Thank you very much!</p>\n", "tags": ["ios", "swift", "swiftui", "tabs"]}
5
- {"id": "c1f2643a-a56b-4972-a4ae-73ac6f56d248", "text": "Q: string literals and constexpr string msg = format(...) with GCC C++23 A: <p>You can use <code>std::to_chars</code> which is <code>constexpr</code> since C++23 (<a href=\"https://en.cppreference.com/cpp/utility/to_chars\" rel=\"nofollow noreferrer\">https://en.cppreference.com/cpp/utility/to_chars</a>). But it won't be enough. Compile-time concatenation is not straightforward.</p>\n<p>It cannot be achieved from <code>std::string_view</code> for reasons explained there: <a href=\"https://stackoverflow.com/questions/73478427/concatenating-string-view-objects\">Concatenating string_view objects</a>.</p>\n<p>It does not always work with <code>std::string</code> because it dynamically allocates its data. Thus it can be only used if the string is destroyed at the end of the <code>constexpr</code> expression. It can accidentally work if Short String Optimization applies but it is implementation and data dependant.</p>\n<p>So the issue is a bit more complex than it seems.</p>\n<p>First of all, I will propose a user-defined compile-time string literal, with well defined concatenation.</p>\n<p>This can be done like this:</p>\n<pre class=\"lang-cpp prettyprint-override\"><code>#include &lt;string_view&gt;\n\n// LiteralString is a literal class type, usable as constant template parameter\n// N does not includes null final character\ntemplate &lt;std::size_t N&gt;\nstruct LiteralString {\n consteval LiteralString(const char* s) { std::copy(s, s + N, &amp;data[0]); }\n consteval operator std::string_view() const { return {data, N}; }\n\n static constexpr std::size_t size = N;\n char data[N]{};\n};\n\n// deduction guide for string literals\ntemplate &lt;std::size_t N&gt;\nLiteralString(const char (&amp;s)[N]) -&gt; LiteralString&lt;N - 1&gt;;\n\n// user-define string litteral\ntemplate &lt;LiteralString LS&gt;\nconstexpr auto operator&quot;&quot;_ls() {\n return LS;\n}\n\n// compile-time only concatenation\ntemplate &lt;std::size_t Ln, std::size_t Rn&gt;\nconsteval auto operator+(LiteralString&lt;Ln&gt; const&amp; lhs,\n LiteralString&lt;Rn&gt; const&amp; rhs) {\n constexpr std::size_t NewSize = Ln + Rn;\n char data[NewSize]{};\n auto ptr = std::copy(lhs.data, lhs.data + Ln, &amp;data[0]);\n std::copy(rhs.data, rhs.data + Rn, ptr);\n return LiteralString&lt;NewSize&gt;{data};\n}\n</code></pre>\n<p>Note that I will need to construct from <code>const char* s</code> later, which does not allow to deduce <code>N</code>. If I want to initialize from a simple string literal such as <code>&quot;Hello&quot;</code> I will have to deduce <code>N</code> from the string length and I achieve that through a deduction guide.</p>\n<p>Then lets work on the creation from a number, using <code>std::to_chars</code>:</p>\n<pre class=\"lang-cpp prettyprint-override\"><code>namespace Details {\n// number of digits of i in base 10\ntemplate &lt;unsigned int i&gt;\nconsteval std::size_t NbDigits() {\n if constexpr (i &lt;= 9) {\n return 1;\n } else {\n return NbDigits&lt;i / 10&gt;() + 1;\n }\n}\n} // namespace Details\n\n// compile-time creation of a string literal from an integer\ntemplate &lt;unsigned int i&gt;\nconsteval auto to_string() {\n // getting the needed size\n static constexpr std::size_t buf_size = Details::NbDigits&lt;i&gt;() + 1;\n char buf[buf_size]{};\n // using to_chars constexpr-ness\n *(std::to_chars(buf, buf + buf_size, i).ptr) = 0;\n return LiteralString&lt;buf_size&gt;(buf);\n}\n</code></pre>\n<p>It's quite straightforward. I just need to be &quot;smart&quot; about the buffer size. Note that a bit more work would be needed to handle other types than <code>unsigned int</code> (handling signedness, representation,...).</p>\n<p>Now we can play with it:</p>\n<pre class=\"lang-cpp prettyprint-override\"><code>int main() {\n static constexpr auto full_message =\n &quot;The number is &quot;_ls + to_string&lt;42&gt;() + &quot;.&quot;_ls;\n // casting to string_view for display, no need to overload operator &lt;&lt;\n std::cout &lt;&lt; std::string_view{full_message};\n}\n</code></pre>\n<p>Outputs:</p>\n<blockquote>\n<p>The number is 42.</p>\n</blockquote>\n<p><a href=\"https://godbolt.org/z/TEnKf1dYx\" rel=\"nofollow noreferrer\">LIVE</a></p>\n<p>Final note: as a bonus, a <code>LiteralString</code> can be used as a template parameter, if needed.</p>\n", "tags": ["c++", "gcc", "format", "string-literals", "c++23"]}
6
- {"id": "a7462e97-7a52-4434-b0a1-bcc677a522b8", "text": "Q: Document a Vue3 Generic Component such that typedoc can list, $emits, $props and $slots A: <p>Until now I was able to create the following vue3 type definition helper.</p>\n<ul>\n<li>It handles both exposing types to tools like typedoc resulting in human readable documentation, as well as keep the types usable during development.</li>\n</ul>\n<pre><code>import type { ComponentPublicInstance, SlotsType, EmitsOptions } from &quot;vue&quot;;\n\n/**\n * Converts a tuple-format emits type `{ eventName: [arg1: T1, ...] }` to\n * the function-value format `{ eventName: (arg1: T1, ...) =&gt; void }` required\n * by `EmitsOptions`. Use this when passing a tuple-format emits type to\n * `TGenericVue3Component` or `TGenericVue3ComponentConstructor`.\n * @group Types\n * @category Types\n */\nexport type TTupleEmitsToOptions&lt;T extends Record&lt;string, any[]&gt;&gt; = {\n [K in keyof T]: (...args: T[K]) =&gt; void;\n};\n\n/**\n * Helper type for defining the return type of a Generic Vue Component constructor.\n * Ensures TypeDoc picks up properties (via Readonly&lt;P&gt;) and Vue integration (via ComponentPublicInstance).\n * \n * Usage:\n * export default {} as unknown as new &lt;T&gt;(props: IProps&lt;T&gt;) =&gt; TGVue3GenericComponent&lt;IProps&lt;T&gt;, IEmits&lt;T&gt;, ISlots&lt;T&gt;, IExposed&gt;;\n * @group Types\n * @category Types\n */\nexport type TGenericVue3Component&lt;TProps, TEmits extends EmitsOptions = {}, TSlots extends Record&lt;string, any&gt; = {}, TExposed extends Record&lt;string, any&gt; = {}&gt;\n = ComponentPublicInstance&lt;TProps, {}, {}, {}, {}, TEmits, TProps, {}, false, any, {}, SlotsType&lt;TSlots&gt;&gt; &amp; TExposed &amp; Readonly&lt;TProps&gt; &amp; {\n $props: TProps;\n $slots: TSlots;\n $emits: TEmits;\n};\n\n/**\n * Helper type for defining the return type of a Generic Vue Component constructor.\n * Ensures TypeDoc picks up properties (via Readonly&lt;P&gt;) and Vue integration (via ComponentPublicInstance).\n * \n * Note: This definition does not work well will generics. In case your interfaces need generic use @see { @link TGenericVue3Component }\n * \n * Usage:\n * export default {} as unknown as TGVue3GenericComponentConstructor&lt;IProps, IEmits, ISlots, IExposed&gt;;\n * @group Types\n * @category Types\n */\nexport type TGenericVue3ComponentConstructor&lt;TProps, TEmits extends EmitsOptions = {}, TSlots extends Record&lt;string, any&gt; = {}, TExposed extends Record&lt;string, any&gt; = {}&gt;\n = new (props: TProps) =&gt; TGenericVue3Component&lt;typeof props, TEmits, TSlots, TExposed&gt;;\n\n</code></pre>\n<h2>Usage</h2>\n<p>You have to cast the <code>export default {}</code> to <code>unknown</code> first, then you cast it again to a constructor definition which outputs TGenericVue3Component with your props-, emits- and slots-types/interfaces. In my case:</p>\n<ul>\n<li><code>IGVue3DropdownProps&lt;TId, TData&gt;</code></li>\n<li><code>TGVue3DropdownEmits&lt;TId, TData&gt;</code></li>\n<li><code>IGVue3DropdownSlots&lt;TId, TData&gt;</code></li>\n<li><code>IGVue3DropdownExposed</code></li>\n</ul>\n<pre class=\"lang-ts prettyprint-override\"><code>&lt;script lang=&quot;ts&quot;&gt;\n/* We will use this script-block to export type definitions and documentation. */\nimport type { IDropdownItem, IGVue3DropdownExposed, IGVue3DropdownProps, IGVue3DropdownRefreshOptions, IGVue3DropdownSlots, TGVue3DropdownEmits } from &quot;./GVue3Dropdown.types&quot;;\n\n/**\n * ...\n * @class\n */\nexport default {} as unknown as new &lt;TId extends TListEntryPropertyName, TData&gt;(props: IGVue3DropdownProps&lt;TId, TData&gt;)\n=&gt; TGenericVue3Component&lt;\n typeof props,\n TTupleEmitsToOptions&lt;TGVue3DropdownEmits&lt;TId, TData&gt;&gt;, /* We need to wrap our emits type in `TTupleEmitsToOptions` for the vue compiler to be happy. */\n IGVue3DropdownSlots&lt;TId, TData&gt;,\n IGVue3DropdownExposed\n&gt;;\n\n&lt;/script&gt;\n\n\n&lt;script setup lang=&quot;ts&quot; generic=&quot;TId extends TListEntryPropertyName, TData&quot;&gt;\n/* And this script-setup-block to implement the actual component. */\n\n...\n\n/* Using `defineProps` with our props interface. */\nconst props = defineProps&lt;IGVue3DropdownProps&lt;TId, TData&gt;&gt;();\n\n/* When actually defining emits we use our type `TGVue3DropdownEmits` directly. */\nconst emit = defineEmits&lt;TGVue3DropdownEmits&lt;TId, TData&gt;&gt;();\n\n/* Slots can be simply defined without passing any types or interfaces. */\nconst slots = useSlots();\n\n/* API will be exposed in 2 steps. */\nconst exposedApi: IGVue3DropdownExposed = {\n refresh: refreshFromProps\n};\ndefineExpose(exposedApi);\n\n\n&lt;/script&gt;\n</code></pre>\n<h2>How it displays</h2>\n<p>This is nicely picked up by typedoc like:\n<a href=\"https://i.sstatic.net/IYrBAjoW.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.sstatic.net/IYrBAjoW.png\" alt=\"Typedoc nicely formatted properties etc.\" /></a></p>\n<p>and VS-Code typehints\n<img src=\"https://i.sstatic.net/5BbUIbHO.png\" alt=\"VS-Code typehints on hover\" /></p>\n<hr />\n<p>For reference these are the defined types:</p>\n<pre class=\"lang-ts prettyprint-override\"><code>import type { IListEntry, ListTextFilter, TListEntryPropertyName } from &quot;@gsag/listengine&quot;;\n\n/**\n * @category Comp / ListEngine / Dropdown\n * @module GVue3Dropdown.types\n */\n\n/**\n * The `v-model` payload for `GVue3Dropdown`.\n * Use a one-element array for single-select mode and an array of keys for multi-select mode.\n * Empty selection is represented by `[]`, `null`, or `undefined`.\n * @category Comp / ListEngine / Dropdown\n */\nexport type TGVue3DropdownModelValue&lt;TId extends TListEntryPropertyName&gt; = TId[] | null | undefined;\n\n/**\n * Dynamic fetch callback for `GVue3Dropdown`.\n * @category Comp / ListEngine / Dropdown\n */\nexport type TDropdownFetchCallback&lt;TId extends TListEntryPropertyName, TData&gt; = (listTextFilter: ListTextFilter&lt;TId, IDropdownItem&lt;TId, TData&gt;&gt;) =&gt; Promise&lt;Array&lt;IDropdownItem&lt;TId, TData&gt;&gt;&gt;;\n\n/**\n * Interface for dropdown items.\n * @category Comp / ListEngine / Dropdown\n */\nexport interface IDropdownItem&lt;TId extends TListEntryPropertyName, TData&gt;\n{\n /** Unique identifier for the item. Supports `string` and `number`. */\n key: TId;\n /** The actual value/payload of the item. */\n value: TData;\n}\n\n/**\n * Internationalization options for GVue3Dropdown.\n * @category Comp / ListEngine / Dropdown\n */\nexport interface I18nGVue3Dropdown\n{\n /** i18n: User call to action to search or chose options */\n searchOrSelectCallToAction?: string;\n /** i18n: There are no options at all. */\n noOptionsAvailable?: string;\n /** i18n: There are no options for the search. */\n noOptionsFound?: string;\n /** i18n: Search is currently running. */\n searching?: string;\n}\n\n/**\n * Options for the exposed `refresh()` method.\n * @category Comp / ListEngine / Dropdown\n */\nexport interface IGVue3DropdownRefreshOptions\n{\n /**\n * Resets transient UI state such as the open state and current search text before refreshing.\n * Default: `true`\n */\n resetUi?: boolean;\n\n /**\n * Clears the current filter before refreshing and rehydrates the selection from the current `modelValue`.\n * Default: `true`\n */\n resetFilter?: boolean;\n}\n\n/**\n * Public instance API exposed by `GVue3Dropdown`.\n * @category Comp / ListEngine / Dropdown\n */\nexport interface IGVue3DropdownExposed\n{\n /**\n * Refreshes the dropdown from the current props and `modelValue`.\n * Useful when the component stays mounted across sessions and needs to rehydrate its internal selection state.\n */\n refresh(options?: IGVue3DropdownRefreshOptions): Promise&lt;void&gt;;\n}\n\n/**\n * Slots definition for GVue3Dropdown\n * @category Comp / ListEngine / Dropdown\n */\nexport interface IGVue3DropdownSlots&lt;TId extends TListEntryPropertyName, TData&gt;\n{\n /**\n * Slot for rendering a single option in the dropdown list.\n * @param props The list entry containing the option item.\n */\n option?(props: { listEntry: IListEntry&lt;TId, IDropdownItem&lt;TId, TData&gt;&gt;; }): any;\n\n /**\n * Slot for rendering one selected multi-select entry.\n * Receives the selected list entry and a toggle callback for deselection.\n */\n &quot;option-selected&quot;?(props: { listEntry: IListEntry&lt;TId, IDropdownItem&lt;TId, TData&gt;&gt;; onToggleSelection: () =&gt; void; }): any;\n\n /**\n * Slot for rendering the create-action row shown as the last dropdown entry.\n * Receives the current typed search text and a trigger callback.\n */\n &quot;option-create&quot;?(props: { searchText: string; onCreate: () =&gt; void; }): any;\n}\n\n/**\n * Emits definition for GVue3Dropdown.\n * `update:modelValue` always emits an array-shaped selection payload.\n * @category Comp / ListEngine / Dropdown\n */\nexport type TGVue3DropdownEmits&lt;TId extends TListEntryPropertyName, TData&gt; = {\n &quot;update:modelValue&quot;: [value: TGVue3DropdownModelValue&lt;TId&gt;];\n &quot;add-selection&quot;: [item: IDropdownItem&lt;TId, TData&gt;];\n &quot;remove-selection&quot;: [item: IDropdownItem&lt;TId, TData&gt;];\n &quot;action-create&quot;: [searchText: string];\n};\n\n/**\n * @deprecated Use `TGVue3DropdownEmits` instead.\n * @category Comp / ListEngine / Dropdown\n */\nexport type IGVue3DropdownEmits&lt;TId extends TListEntryPropertyName, TData&gt; = TGVue3DropdownEmits&lt;TId, TData&gt;;\n\n/**\n * @category Comp / ListEngine / Dropdown\n */\nexport interface IGVue3DropdownProps&lt;TId extends TListEntryPropertyName, TData&gt;\n{\n /**\n * A list of options.\n * Cannot be used together with fetch.\n * When set it is recommended to also set @see { @link IGVue3DropdownProps.search }.\n */\n options?: Array&lt;IDropdownItem&lt;TId, TData&gt;&gt;;\n\n /**\n * Dynamic fetch callback.\n * Cannot be used together with `options`.\n * @returns A promise resolving to a list of dropdown items.\n */\n fetch?: TDropdownFetchCallback&lt;TId, TData&gt;;\n\n /**\n * When using an async fetch it is a good idea to defer the fetching process to prevent excessive API calls.\n * The minimum value will be `10` at all times. There is no upper limit.\n */\n deferFetchByMilliseconds?: number;\n\n /** Whether multiple items can be selected. Default: false */\n enableMultiSelect?: boolean;\n\n /** Enables the optional create-action row for the current search text. Default: false */\n enableCreateAction?: boolean;\n\n /**\n * Callback to convert a value to a string for display in the input (if single select) or bubbles.\n * Default: String(value)\n */\n display?: (value: IDropdownItem&lt;TId, TData&gt;) =&gt; string;\n\n /**\n * Callback used to convert a value to searchable text.\n */\n search?: (value: IDropdownItem&lt;TId, TData&gt;) =&gt; string;\n\n /**\n * `v-model` binding for the selected key or keys.\n * Use a one-element array for single-select mode and an array of keys for multi-select mode.\n * Empty selection is represented by `[]`, `null`, or `undefined`.\n */\n modelValue?: TGVue3DropdownModelValue&lt;TId&gt;;\n\n /**\n * Additional class for the dropdown container.\n */\n containerClass?: string | Record&lt;string, boolean&gt;;\n\n i18n?: I18nGVue3Dropdown;\n}\n\n</code></pre>\n<p>Disclaimer: I used all tools available to me:</p>\n<ul>\n<li>Official Typescript and Vue3 documentations</li>\n<li>Gemini 3 (Pro), ChatGPT as well as Claude Sonnet 4.6</li>\n</ul>\n<p>Tested in production.</p>\n", "tags": ["typescript", "vuejs3", "typedoc", "vue-tsc"]}
7
- {"id": "2d090f68-0b88-4b2c-807d-8e0e104f3be7", "text": "Q: How to remove the top (or navigation) toolbar background tint in iOS 27 A: <p>This problem is a bit difficult to reproduce, most arrangements do not show a material background behind the toolbar. However, I found that it did happen if <code>.scrollEdgeEffectStyle(.hard, for: .top)</code> is applied to the <code>ScrollView</code>.</p>\n<p>To fix,</p>\n<ul>\n<li><em>either</em> change the edge effect style from <code>.hard</code> to <code>.soft</code></li>\n<li><em>or</em>, if you don't want a fade effect either, apply <code>.scrollEdgeEffectHidden(for: .top)</code> instead.</li>\n</ul>\n<p>Here is a little example to show it working:</p>\n<pre class=\"lang-swift prettyprint-override\"><code>struct ContentView: View {\n let loremIpsum = &quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&quot;\n\n var body: some View {\n TabView {\n Tab(&quot;Recipies&quot;, systemImage: &quot;fork.knife&quot;) {\n NavigationStack {\n NavigationLink(&quot;Show a good recipie&quot;) {\n nestedContent\n }\n }\n }\n Tab(&quot;Settings&quot;, systemImage: &quot;gearshape&quot;) {\n Text(&quot;Settings&quot;)\n }\n }\n }\n\n private var nestedContent: some View {\n GeometryReader { geo in\n ScrollView {\n VStack {\n headerImage(topInset: geo.safeAreaInsets.top)\n Text(loremIpsum)\n .font(.title3)\n .padding()\n .frame(height: 1000, alignment: .top)\n }\n }\n .ignoresSafeArea()\n // .scrollEdgeEffectStyle(.automatic, for: .top) // \ud83d\udc48 causes background effect\n .scrollEdgeEffectHidden(for: .top) // \ud83d\udc48 prevents it\n .toolbar {\n ToolbarItem(placement: .topBarTrailing) {\n Button(&quot;Options&quot;, systemImage: &quot;ellipsis&quot;) {}\n }\n }\n }\n }\n\n private func headerImage(topInset: CGFloat) -&gt; some View {\n Image(systemName: &quot;fish.fill&quot;)\n .resizable()\n .scaledToFit()\n .padding(.top, topInset)\n .padding([.leading, .trailing, .bottom])\n .foregroundStyle(.orange.gradient)\n .background(.mint.opacity(0.3))\n }\n}\n</code></pre>\n<p><img src=\"https://i.sstatic.net/9QlqRdNK.gif\" alt=\"Animation\" /></p>\n", "tags": ["ios", "swiftui", "swiftui-toolbar"]}
 
1
+ {"id": "795b96d9-8da4-4b9c-8a19-20c0ff13c511", "text": "Q: Why Rust is taking a ton of my disk space and how to make it use less A: <p>As long as your Cargo.toml has all the correct dependancies details you just need the cargo.toml file and the actual code in the src folder. It speeds up the compiling having the compiler have easy local access to those build files but you dont need it.</p>\n", "tags": ["rust", "rust-cargo"]}
2
+ {"id": "aea5d1c8-f58a-4bf4-be0d-4419d3a018d9", "text": "Q: Why does Python asyncio performance decrease when creating too many small tasks? A: <p>There is no &quot;performance decrease&quot;- there is an overhead time to create and execute the single line of code for each of these tasks.</p>\n<p>Scaling from 100_000 to 1_000_000 tasks with your snippet actually show a better than linear time -\nSince these tasks actually perform no asynchronous wait, just a yielding to the loop - the CPU is expected to be 100% busy running this code - and due to asyncio nature, it does that in a single thread - and therefore, in a single processor core.</p>\n", "tags": ["python", "performance", "concurrency", "python-asyncio", "event-loop"]}
3
+ {"id": "548d3ad8-6010-420a-ab5e-baf0ba80e858", "text": "Q: Why is my program throwing an illegal instruction error? A: <p>Your compiler has literally inserted a &quot;generate undefined instruction exception&quot; instruction at the end of your <code>int travelling(int bal)</code> function because although it was declared to return an <code>int</code>, there is no <code>return &lt;some int value&gt;;</code> at all in it. That's &quot;undefined behavior&quot; (UB) and the compiler can do anything it wants, like deleting your computer's hard drive. It was being nice in this case though.</p>\n<p>You can see the generated processor instructions for your C++ function in e.g. Godbold (<a href=\"https://godbolt.org/z/9GMKnjsT8\" rel=\"nofollow noreferrer\">https://godbolt.org/z/9GMKnjsT8</a>), then you see that</p>\n<ol>\n<li><p>It generates the <code>ud2</code> instruction (generate undefined instruction exception, see (<a href=\"https://mudongliang.github.io/x86/html/file_module_x86_id_318.html\" rel=\"nofollow noreferrer\">https://mudongliang.github.io/x86/html/file_module_x86_id_318.html</a>)</p>\n</li>\n<li><p>It gives you a <strong>warning</strong> telling you what's wrong</p>\n</li>\n</ol>\n<p><a href=\"https://i.sstatic.net/3hAiPilD.png\" rel=\"nofollow noreferrer\"><img src=\"https://i.sstatic.net/3hAiPilD.png\" alt=\"enter image description here\" /></a></p>\n<p>Hence you should:</p>\n<ul>\n<li><p>change your <code>travelling()</code> function to return <code>void</code>. It's just a print function and doesn't need to return anyhting.</p>\n</li>\n<li><p>check compiler warnings more throughly or compile with <code>-pedantic</code> to make the compiler refuse compilation when a warning occurs. Enable (most) of the warnings with <code>-Wall -Wextra</code>.</p>\n</li>\n</ul>\n", "tags": ["c++"]}
4
+ {"id": "3aa0d454-e95d-48d7-9727-77b5712abe7c", "text": "Q: How to specify an anchor target in Bootstrap 5 Dropdown? A: <p>As dropdown item is showing tab (with <code>data-bs-toggle=&quot;tab&quot;</code>), anchor behavior is lost (even if you used <code>a</code> tags, instead of <code>button</code>).\nSo, you need to manually scroll to anchor with JavaScript.</p>\n<p>However, you need to wait for Bootstrap to actually show tab, so you could use tab <code>show.bs.tab </code> event listener, and also store anchor target on dropdown item, and then scroll to it:</p>\n<p>store anchor target:</p>\n<pre class=\"lang-html prettyprint-override\"><code>&lt;li&gt;&lt;button class=&quot;dropdown-item&quot; data-bs-toggle=&quot;tab&quot; data-bs-target=&quot;#tabB-pane-1&quot; type=&quot;button&quot; role=&quot;tab&quot; aria-controls=&quot;tabB-pane-1&quot; aria-selected=&quot;false&quot; data-anchor=&quot;#first-part&quot;&gt;Part 1&lt;/button&gt;&lt;/li&gt;\n</code></pre>\n<p>add tab events listener to scroll to anchor of triggering item:</p>\n<pre class=\"lang-javascript prettyprint-override\"><code>document.querySelectorAll('.parts-menu .dropdown-item[data-bs-toggle=&quot;tab&quot;]').forEach(item =&gt; {\n\n item.addEventListener('shown.bs.tab', function() {\n\n const anchor = this.dataset.anchor;\n\n document.querySelector(anchor).scrollIntoView({\n behavior: 'smooth'\n });\n\n });\n\n});\n</code></pre>\n<p>demo:</p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\" data-babel-preset-react=\"false\" data-babel-preset-ts=\"false\">\n<div class=\"snippet-code\">\n<pre class=\"snippet-code-html lang-html prettyprint-override\"><code>&lt;!doctype html&gt;\n&lt;html lang=\"en\"&gt;\n\n&lt;head&gt;\n &lt;meta charset=\"utf-8\"&gt;\n &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;\n &lt;link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css\" rel=\"stylesheet\"&gt;\n &lt;title&gt;Bootstrap Example&lt;/title&gt;\n &lt;script defer src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js\"&gt;&lt;/script&gt;\n &lt;style&gt;\n .parts div {\n height: 300px;\n }\n &lt;/style&gt;\n &lt;script&gt;\n addEventListener(\"DOMContentLoaded\", ()=&gt;{\n\n document.querySelectorAll('.parts-menu .dropdown-item[data-bs-toggle=\"tab\"]').forEach(item =&gt; {\n\n item.addEventListener('shown.bs.tab', function() {\n\n const anchor = this.dataset.anchor;\n\n document.querySelector(anchor).scrollIntoView({\n behavior: 'smooth'\n });\n\n });\n\n });\n\n });\n &lt;/script&gt;\n&lt;/head&gt;\n\n&lt;body&gt;\n\n\n &lt;ul class=\"nav nav-tabs\" role=\"tablist\"&gt;\n &lt;li class=\"nav-item\" role=\"presentation\"&gt;\n &lt;button class=\"nav-link active\" id=\"tabB-0\" data-bs-toggle=\"tab\" data-bs-target=\"#tabB-pane-0\" type=\"button\" role=\"tab\" aria-controls=\"tabB-pane-0\" aria-selected=\"true\"&gt;TabB 0&lt;/button&gt;\n &lt;/li&gt;\n\n &lt;li class=\"nav-item dropdown\" role=\"presentation\"&gt;\n &lt;button class=\"nav-link dropdown-toggle\" id=\"tabB-1\" type=\"button\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\"&gt;TabB 1&lt;/button&gt;\n &lt;ul class=\"dropdown-menu parts-menu\"&gt;\n &lt;li&gt;&lt;button class=\"dropdown-item\" data-bs-toggle=\"tab\" data-bs-target=\"#tabB-pane-1\" type=\"button\" role=\"tab\" aria-controls=\"tabB-pane-1\" aria-selected=\"false\" data-anchor=\"#first-part\"&gt;Part 1&lt;/button&gt;&lt;/li&gt;\n &lt;li&gt;&lt;button class=\"dropdown-item\" data-bs-toggle=\"tab\" data-bs-target=\"#tabB-pane-1\" type=\"button\" role=\"tab\" aria-controls=\"tabB-pane-1\" aria-selected=\"false\" data-anchor=\"#second-part\"&gt;Part 2&lt;/button&gt;&lt;/li&gt;\n &lt;li&gt;&lt;button class=\"dropdown-item\" data-bs-toggle=\"tab\" data-bs-target=\"#tabB-pane-1\" type=\"button\" role=\"tab\" aria-controls=\"tabB-pane-1\" aria-selected=\"false\" data-anchor=\"#third-part\"&gt;part 3&lt;/button&gt;\n &lt;/li&gt;\n &lt;/ul&gt;\n &lt;/li&gt;\n\n &lt;li class=\"nav-item\" role=\"presentation\"&gt;\n &lt;button class=\"nav-link\" id=\"tabB-2\" data-bs-toggle=\"tab\" data-bs-target=\"#tabB-pane-2\" type=\"button\" role=\"tab\" aria-controls=\"tabB-pane-2\" aria-selected=\"true\"&gt;TabB 2&lt;/button&gt;\n &lt;/li&gt;\n &lt;/ul&gt;\n &lt;div class=\"tab-content\"&gt;\n &lt;div class=\"tab-pane fade show active\" id=\"tabB-pane-0\" role=\"tabpanel\" aria-labelledby=\"tabB-0\" tabindex=\"0\"&gt;\n This is tabB pane 0.\n &lt;/div&gt;\n &lt;div class=\"tab-pane fade parts\" id=\"tabB-pane-1\" role=\"tabpanel\" aria-labelledby=\"tabB-1\" tabindex=\"0\"&gt;\n &lt;div id=\"first-part\"&gt;\n This is tabB pane 1 - first part.\n &lt;/div&gt;\n &lt;div id=\"second-part\"&gt;\n This is tabB pane 1 - second part.\n &lt;/div&gt;\n &lt;div id=\"third-part\"&gt;\n This is tabB pane 1 - third part.\n &lt;/div&gt;\n &lt;/div&gt;\n &lt;div class=\"tab-pane fade\" id=\"tabB-pane-2\" role=\"tabpanel\" aria-labelledby=\"tabB-2\" tabindex=\"0\"&gt;\n This is tabB pane 2.\n &lt;/div&gt;\n &lt;/div&gt;\n\n\n\n&lt;/body&gt;\n\n&lt;/html&gt;</code></pre>\n</div>\n</div>\n</p>\n", "tags": ["html", "bootstrap-5", "dropdown"]}
5
+ {"id": "d5190bbc-cf78-4c7d-96fc-3105bf3dd5fd", "text": "Q: How to redirect stderr and stdout to /dev/null? A: <p>There are two problems here:</p>\n<pre><code>ls -a $PWD/*/bin/activate 2&gt;&amp;1 /dev/null\n</code></pre>\n<p>The order of redirection is not the right (you redirect the errors in the std output) and <code>/dev/null</code> is not prefixed with a stream redirection.</p>\n<p>You should first redirect the std output into <code>/dev/null</code> and then redirect the std error into the same stream than the std output (that is <code>/dev/null</code>) :</p>\n<pre><code>ls -a $PWD/*/bin/activate &gt; /dev/null 2&gt;&amp;1\n</code></pre>\n", "tags": ["zsh"]}
6
+ {"id": "da337a4a-c6d6-4a8b-bdaa-e6134d9d3031", "text": "Q: join_by() where key in x can match two keys in y A: <p>With <code>sqldf</code>:</p>\n<pre class=\"lang-r prettyprint-override\"><code>sqldf::sqldf(\n &quot;SELECT a.*, b.*\n FROM a \n LEFT JOIN b \n ON a.key = b.key1 OR a.key = b.key2&quot;\n)\n\n#&gt; key else1 key1 key2 else2 else3\n#&gt; 1 1 cup 1 5 banana blues\n#&gt; 2 2 plate 2 banana jazz\n#&gt; 3 3 bowl 3 banana reggae\n#&gt; 4 4 jug 4 pear ska\n</code></pre>\n<p>Or with <code>powerjoin</code>:</p>\n<pre><code>powerjoin::power_left_join(\n a, b, \n by = ~ dplyr::if_else(.x$key == .y$key1 | \n .x$key == .y$key2, \n TRUE, FALSE, FALSE)\n )\n</code></pre>\n<p>Or <code>fuzzyjoin</code>:</p>\n<pre><code>fuzzyjoin::fuzzy_join(\n a, b,\n multi_by = c(&quot;key&quot; = &quot;key1&quot;, &quot;key&quot; = &quot;key2&quot;),\n multi_match_fun = \\(x, y) {\n x[, 1] == y[, 1] | x[, 2] == y[, 2]\n },\n mode = &quot;left&quot;\n)\n</code></pre>\n", "tags": ["r", "dplyr"]}
 
rag/rag_version_1.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:de016725dede067da84c7efe260db60799bb7fb0ed40f38ba4c8ad3ce6bec4c9
3
- size 7451802
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:810c803d55ca8c80e05886e2ce5221d970077d14a659a6818d6e9fe11c502369
3
+ size 7462054