problem
stringlengths
26
131k
labels
class label
2 classes
folowing "What's a Creel?"s tutorial: Can't create a IWICBitmapDecoder, in visual studio 2015 : I've been following "what's a Creel?"'s tutorial for direct 2d. i got to tutorial 8: 'Loading an image'. I didn't have the `spritesheet` object save the pointer to the `Graphics` object as this caused problems with this version of visual studio, so it's passed every time something needing it is called. main point: when i try creating a `IWICBitmapDecoder` with the `wicfactory->CreateDecoderFromFile()` method, i get the following error: Exception thrown at 0x008C70A7 in Project8.exe: 0xC0000005: Access violation reading location 0x00000000. and in the Autos i get: `hr | E_NOINTERFACE No such interface supported. this | 0x00c1a5c8 {bmp=0x00000000 <NULL> } spritesheet * wicfactory | 0x00000000<NULL> wicdecoder | 0xcccccccc{...}` the code being this: #pragma once #include <wincodec.h> //include windowscodecs.lib in the linker input #include "Graphics.h" #include <d2d1.h> #include<string> class spritesheet { public: ID2D1Bitmap* bmp; spritesheet() {} spritesheet(LPCWSTR file, graphics* gfx) { //this->gfx = gfx; //bmp = NULL; HRESULT hr; //create an image factory IWICImagingFactory *wicFactory; hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, CLSID_WICImagingFactory, (LPVOID*)&wicFactory ); //create a decoder IWICBitmapDecoder *wicdecoder; hr = wicFactory->CreateDecoderFromFilename( file, NULL, GENERIC_READ, WICDecodeMetadataCacheOnLoad, &wicdecoder ); IWICBitmapFrameDecode* wicframe = NULL; hr = wicdecoder->GetFrame(0, &wicframe); IWICFormatConverter *wicconverter = NULL; hr = wicFactory->CreateFormatConverter(&wicconverter); hr = wicconverter->Initialize( wicframe, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0.0, WICBitmapPaletteTypeCustom ); gfx->gettarget()->CreateBitmapFromWicBitmap( wicconverter, NULL, &bmp ); if (wicdecoder) wicdecoder->Release(); if (wicFactory) wicFactory->Release(); if (wicconverter) wicconverter->Release(); if (wicframe) wicframe->Release(); } void init(wchar_t * file, graphics * gfx) { //this->gfx = gfx; //bmp = NULL; HRESULT hr; //create an image factory IWICImagingFactory* wicFactory; hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, CLSID_WICImagingFactory, (LPVOID*)&wicFactory ); //create a decoder IWICBitmapDecoder* wicdecoder; hr = wicFactory->CreateDecoderFromFilename( file, NULL, GENERIC_READ, WICDecodeMetadataCacheOnLoad, &wicdecoder ); IWICBitmapFrameDecode* wicframe = NULL; hr = wicdecoder->GetFrame(0, &wicframe); IWICFormatConverter *wicconverter = NULL; hr = wicFactory->CreateFormatConverter(&wicconverter); hr = wicconverter->Initialize( wicframe, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0.0, WICBitmapPaletteTypeCustom ); gfx->rendertarget->CreateBitmapFromWicBitmap( wicconverter, NULL, &bmp ); if (wicdecoder) wicdecoder->Release(); if (wicFactory) wicFactory->Release(); if (wicconverter) wicconverter->Release(); if (wicframe) wicframe->Release(); gfx->rendertarget->DrawBitmap( bmp, D2D1::RectF(0.0f, 0.0f, 10, 10), //dest rect 1.0f, D2D1_BITMAP_INTERPOLATION_MODE::D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, //effect for scaling D2D1::RectF(0, 0, 10, 10)); //scource rect } void draw(graphics *gfx) { gfx->rendertarget->DrawBitmap( bmp, D2D1::RectF(0.0f, 0.0f, 10, 10), //dest rect 1.0f, D2D1_BITMAP_INTERPOLATION_MODE::D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, //effect for scaling D2D1::RectF(0, 0, 10, 10)); //scource rect } }; now, just to test things, i did put a `ID2D1Bitmap* bmp;` at the start of each method just to see where things got, but the `wicdecoder` error message just changed to a random place in memory. if anyone has ether done this, or followed some other tutorial, or done it on their own, and has been successful, please help.
0debug
static int filter_frame(AVFilterLink *inlink, AVFrame *ref) { FrameStepContext *framestep = inlink->dst->priv; if (!(framestep->frame_count++ % framestep->frame_step)) { framestep->frame_selected = 1; return ff_filter_frame(inlink->dst->outputs[0], ref); } else { framestep->frame_selected = 0; av_frame_free(&ref); return 0; } }
1threat
how to know if a .txt extension cotains a plain text or a CSV structure? : A client sends a csv structure in a .txt file and at other times sends a flat structure with paragraphs and sentences. How can I identify through a program in C # if the file sent by the client is a CSV or a plain text? **CSV Example:** 1,33838,20181217,GTR,5,1587,S,"STT PPP USA, SA.",N,2,58.00,3,58.00 2,1,0,0,LHG,1000000007,,6,0,1000000006, 2,2,0,0,LHG,1000000007,,6,0,1000000003, **Text Plane Example:** ASCII Converter enables you to easily convert ASCII characters to their hex, decimal, and binary representations. In addition, base64 encode/decode binary data. As you type in one of the text boxes above, the other boxes are converted on the fly. The ASCII converter doesn't automatically add spaces between the converted values. You can use the add spaces button to separate the ASCII characters so that the converted values will also be separated from one another.
0debug
What is a virtualenv, and why should I use one? : <p>I am trying to install a Python package with this command</p> <pre><code>pip install &lt;name of package&gt; </code></pre> <p>I'm getting permission errors and I'm not sure why. I could run it with <code>sudo</code>, but someone told me that was a bad idea, and I should use a virtualenv instead.</p> <p>What is a virtualenv? What does it do for me?</p>
0debug
static void gen_dozi(DisasContext *ctx) { target_long simm = SIMM(ctx->opcode); int l1 = gen_new_label(); int l2 = gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_LT, cpu_gpr[rA(ctx->opcode)], simm, l1); tcg_gen_subfi_tl(cpu_gpr[rD(ctx->opcode)], simm, cpu_gpr[rA(ctx->opcode)]); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0); gen_set_label(l2); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); }
1threat
error: the following arguments are required: --port : this is my code : [in the image, the selected portion is my code][1] I am facing the error: usage: second.py [-h] --port PORT second.py: error: `the following arguments are required: --port` [1]: https://i.stack.imgur.com/RJKkT.png
0debug
List Append using for loop PYTHON : I am trying to get a list of elements using a for loop to index my previous list. Here's the code: `for index in range(1,810): list.extend(t[index]) list.extend(t[index+1]) list.extend(t[index])` I already a list named "list" and t is an older list. To be more specific i want to make my list like this. t1,t2,t1,t2,t3,t2,t3,t4 etc. I get this error TypeError: 'float' object is not iterable Any help? Thanks!
0debug
static void free_note_info(struct elf_note_info *info) { struct elf_thread_status *ets; while (!TAILQ_EMPTY(&info->thread_list)) { ets = TAILQ_FIRST(&info->thread_list); TAILQ_REMOVE(&info->thread_list, ets, ets_link); qemu_free(ets); } qemu_free(info->prstatus); qemu_free(info->psinfo); qemu_free(info->notes); }
1threat
In MVP is onClick responsibility of View or Presenter? : <p>In the MVP pattern who is responsible to handle clicks on the UI?<br> E.g. the non-MVP approach would be something like: </p> <pre><code>counterButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { totalClicks++; counterTextView.setText("Total clicks so far: "+totalClicks); } }); </code></pre> <p>Using MVP is the <code>onClick</code> the responsibility of the <code>Presenter</code>? Or the <code>View</code> can handle that?<br> Can someone please clarify this?</p>
0debug
How does C treat trailing spaces in scanf? : <p>If a <em>scanf</em> statement has any white space in the format string, like as follows, </p> <pre><code>scanf(" %c",&amp;abc); </code></pre> <p>then it just skips over an unlimited number of white spaces until it hits a character.<br> So <strong>\n p</strong> as input would store <em>p</em> in <strong>abc</strong>. </p> <p>Using this concept I am not able to predict the output of the following program that I typed.</p> <pre><code>char echo ; do { scanf ("%c ", &amp;echo); printf ("%c\n",echo); } while (echo != '\n') ; </code></pre> <p>Note that there is a <em>trailing space</em> in the scanf statement. </p> <p>Upon execution of the code I get the following behaviour.<br> It asks for a character. <em>I enter C</em><br> It asks for a character. <em>I enter I</em><br> It prints C.<br> It asks for a character. <em>I enter R</em><br> It prints I.<br> It asks for a character. <em>I enter C</em><br> It prints R. </p> <p>This goes on forever. If I press newline, then it just skips it.<br> Why does it ask for two characters in the beginning? Shouldn't it execute the <em>printf</em> statement?<br> Why is the character of the previous input get printed in the next one?</p>
0debug
int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *id = qdict_get_str(qdict, "id"); BlockDriverState *bs; bs = bdrv_find(id); if (!bs) { qerror_report(QERR_DEVICE_NOT_FOUND, id); return -1; } if (bdrv_in_use(bs)) { qerror_report(QERR_DEVICE_IN_USE, id); return -1; } qemu_aio_flush(); bdrv_flush(bs); bdrv_close(bs); if (bdrv_get_attached_dev(bs)) { bdrv_make_anon(bs); } else { drive_uninit(drive_get_by_blockdev(bs)); } return 0; }
1threat
How to disable the "did you mean ..." suggestions in gcc? : Besides forced colors by default (which could be turned with `GCC_COLORS=`), newer gccs come with another irritating misfeature: they try to second-guess me, and drown warnings about real problems with "did you mean?" google / artificial stupidity -like spam garbage. Example: ``` $ gcc -Wall -c -o /dev/null -xc - <<'EOT' #include <stdlib.h> void foo(char *b, size_t z){ readlink("/foo", b, z); } EOT <stdin>: In function ‘foo’: <stdin>:3:30: warning: implicit declaration of function ‘readlink’; did you mean ‘realloc’? [-Wimplicit-function-declaration] ``` No baby, I did not mean `realloc`; I just forgot to include the `unistd.h` header. Is there any way to turn this OFF? eg have it print just `implicit declaration of function ‘readlink’ [-Wimplicit-function-declaration]`, without the helpful suggestion?
0debug
Pyhton selenium drop down menu click : i want to select option from a drop down menu, for this i use that : `br.find_element_by_xpath("//*[@id='adyen-encrypted-form']/fieldset/div[3]/div[2]/div/div/div/div/div[2]/div/ul/li[5]/span").click()` To select option month 4 but when i do that pyhton return error message : `selenium.common.exceptions.ElementNotVisibleException: Message: element not visible (Session info: chrome=51.0.2704.103) (Driver info: chromedriver=2.22.397929 (fb72fb249a903a0b1041ea71eb4c8b3fa0d9be5a),platform=Mac OS X 10.11.5 x86_64) ` That is the HTML code: </div> <div class="form-row exp-date clearfix fancyform"> <div class="formfield expired-label monthcaption"> <label>Date d'expiration <span>*</span></label> </div> <div class="formfield month"> <div class="value value-select"> <select class="selectbox required" id="dwfrm_adyenencrypted_expiryMonth" data-missing-error="Veuillez sélectionner le mois d'expiration" data-parse-error="Ce contenu est invalide" data-range-error="Ce contenu est trop long ou trop court" data-value-error="Cette date d'expiration est invalide" pattern="^(:?0[1-9]|1[0-2])$" required="required" > <option class="selectoption" label="Mois" value="">Mois</option> <option class="selectoption" label="01" value="01">01</option> <option class="selectoption" label="02" value="02">02</option> <option class="selectoption" label="03" value="03">03</option> <option class="selectoption" label="04" value="04">04</option> <option class="selectoption" label="05" value="05">05</option> <option class="selectoption" label="06" value="06">06</option> <option class="selectoption" label="07" value="07">07</option> <option class="selectoption" label="08" value="08">08</option> <option class="selectoption" label="09" value="09">09</option> <option class="selectoption" label="10" value="10">10</option> <option class="selectoption" label="11" value="11">11</option> <option class="selectoption" label="12" value="12">12</option> </select> What is wrong ? I know selenium cant find the element but i dont know why , xpath wrong ? i need to use other method to find element ? thanks for anwsers
0debug
Region of interest extraction in Matlab : I am writing a Matlab code to implement a specific filter on a selected (from auto ROI) grayscale region of a forearm image which consists of veins. I also uploaded the forearm of a subject(after foreground has extracted). I have not been able to find or write a code to do so. Basically, I have NIR camera images of the forearm of different subjects with different orientations. I wrote the code that has extracted the foreground grayscale image of the arm, that gave me the white background with the forearm. I used Sobel edge to find edges. I also found the nonzero indices using 'find' function. I got the row and col indices. I need an idea on how to extract image inside (almost 10 pixels) of the edges detected on both sides of the forearm (black and white edged image-also uploaded). [sobel-edge][1] [Foreground image][2] [1]: https://i.stack.imgur.com/2jpZ8.jpg [2]: https://i.stack.imgur.com/iUPXA.jpg
0debug
Node.JS: Getting error : [nodemon] Internal watch failed: watch ENOSPC : <p>I just installed <code>Node.js</code> on my <code>Ubuntu 14.04</code> operating system for the first time. I also installed <code>npm</code>. The next step in my installation process was installing <code>nodemon</code>. This all worked out fine. </p> <hr> <p><strong><em>But, when I run <code>nodemon</code> by typing <code>nodemon app.js</code> in my command line, I get the following error...</em></strong> </p> <p><code>[nodemon] 1.8.1 [nodemon] to restart at any time, enter</code>rs<code> [nodemon] watching: *.* [nodemon] starting</code>node app.js<code> [nodemon] Internal watch failed: watch ENOSPC </code></p> <p><strong><em>In the command line below the error...</em></strong></p> <pre><code>alopex@Alopex:~/Desktop/coding_dojo/week-9/javascript/node/testing_node$ Hello World </code></pre> <p>Why is this happening? Is this normal behavior for nodemon? If not, how can I fix it? </p> <hr> <p><strong><em>Side notes...</em></strong></p> <p>1) <code>app.js</code> is a <code>Javascript</code> file with <code>console.log(111)</code> inside of it.<br> 2) <code>node</code> version is <code>v0.10.25</code><br> 3) <code>npm</code> version is <code>1.3.10</code><br> 4) <code>nodemon</code> version is <code>1.8.1</code><br> 5) <code>ubuntu</code> version is...<br></p> <pre><code>Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS Release: 14.04 Codename: trusty </code></pre>
0debug
How to set fetchPolicy globally on apollo-client queries? : <p>I have a few mutations that should trigger some refetchQueries, but I need those queries to have a fetchPolicy other than the default. </p> <p>Is there a way to set <a href="http://dev.apollodata.com/core/apollo-client-api.html#ApolloClient.query" rel="noreferrer">fetchPolicy</a> globally instead of per query? So to avoid setting fetchPolicy on each query.</p>
0debug
void qemu_clock_unregister_reset_notifier(QEMUClockType type, Notifier *notifier) { notifier_remove(notifier); }
1threat
BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int error) { BlockdevOnError on_err = is_read ? bs->on_read_error : bs->on_write_error; switch (on_err) { case BLOCKDEV_ON_ERROR_ENOSPC: return (error == ENOSPC) ? BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT; case BLOCKDEV_ON_ERROR_STOP: return BLOCK_ERROR_ACTION_STOP; case BLOCKDEV_ON_ERROR_REPORT: return BLOCK_ERROR_ACTION_REPORT; case BLOCKDEV_ON_ERROR_IGNORE: return BLOCK_ERROR_ACTION_IGNORE; default: abort(); } }
1threat
static int parse_iplconvkernel(IplConvKernel **kernel, char *buf, void *log_ctx) { char shape_filename[128] = "", shape_str[32] = "rect"; int cols = 0, rows = 0, anchor_x = 0, anchor_y = 0, shape = CV_SHAPE_RECT; int *values = NULL, ret; sscanf(buf, "%dx%d+%dx%d/%32[^=]=%127s", &cols, &rows, &anchor_x, &anchor_y, shape_str, shape_filename); if (!strcmp(shape_str, "rect" )) shape = CV_SHAPE_RECT; else if (!strcmp(shape_str, "cross" )) shape = CV_SHAPE_CROSS; else if (!strcmp(shape_str, "ellipse")) shape = CV_SHAPE_ELLIPSE; else if (!strcmp(shape_str, "custom" )) { shape = CV_SHAPE_CUSTOM; if ((ret = read_shape_from_file(&cols, &rows, &values, shape_filename, log_ctx)) < 0) return ret; } else { av_log(log_ctx, AV_LOG_ERROR, "Shape unspecified or type '%s' unknown.\n", shape_str); return AVERROR(EINVAL); } if (rows <= 0 || cols <= 0) { av_log(log_ctx, AV_LOG_ERROR, "Invalid non-positive values for shape size %dx%d\n", cols, rows); return AVERROR(EINVAL); } if (anchor_x < 0 || anchor_y < 0 || anchor_x >= cols || anchor_y >= rows) { av_log(log_ctx, AV_LOG_ERROR, "Shape anchor %dx%d is not inside the rectangle with size %dx%d.\n", anchor_x, anchor_y, cols, rows); return AVERROR(EINVAL); } *kernel = cvCreateStructuringElementEx(cols, rows, anchor_x, anchor_y, shape, values); av_freep(&values); if (!*kernel) return AVERROR(ENOMEM); av_log(log_ctx, AV_LOG_VERBOSE, "Structuring element: w:%d h:%d x:%d y:%d shape:%s\n", rows, cols, anchor_x, anchor_y, shape_str); return 0; }
1threat
static void imx_fec_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { IMXFECState *s = IMX_FEC(opaque); FEC_PRINTF("writing 0x%08x @ 0x%" HWADDR_PRIx "\n", (int)value, addr); switch (addr & 0x3ff) { case 0x004: s->eir &= ~value; break; case 0x008: s->eimr = value; break; case 0x010: if ((s->ecr & FEC_EN) && !s->rx_enabled) { imx_fec_enable_rx(s); } break; case 0x014: if (s->ecr & FEC_EN) { imx_fec_do_tx(s); } break; case 0x024: s->ecr = value; if (value & FEC_RESET) { imx_fec_reset(DEVICE(s)); } if ((s->ecr & FEC_EN) == 0) { s->rx_enabled = 0; } break; case 0x040: s->mmfr = value; if (extract32(value, 28, 1)) { do_phy_write(s, extract32(value, 18, 9), extract32(value, 0, 16)); } else { s->mmfr = do_phy_read(s, extract32(value, 18, 9)); } s->eir |= FEC_INT_MII; break; case 0x044: s->mscr = value & 0xfe; break; case 0x064: s->mibc = (value & 0x80000000) ? 0xc0000000 : 0; break; case 0x084: s->rcr = value & 0x07ff003f; break; case 0x0c4: s->tcr = value; if (value & 1) { s->eir |= FEC_INT_GRA; } break; case 0x0e4: s->conf.macaddr.a[0] = value >> 24; s->conf.macaddr.a[1] = value >> 16; s->conf.macaddr.a[2] = value >> 8; s->conf.macaddr.a[3] = value; break; case 0x0e8: s->conf.macaddr.a[4] = value >> 24; s->conf.macaddr.a[5] = value >> 16; break; case 0x0ec: break; case 0x118: case 0x11c: case 0x120: case 0x124: break; case 0x144: s->tfwr = value & 3; break; case 0x14c: break; case 0x150: s->frsr = (value & 0x3fc) | 0x400; break; case 0x180: s->erdsr = value & ~3; s->rx_descriptor = s->erdsr; break; case 0x184: s->etdsr = value & ~3; s->tx_descriptor = s->etdsr; break; case 0x188: s->emrbr = value & 0x7f0; break; case 0x300: s->miigsk_cfgr = value & 0x53; break; case 0x308: s->miigsk_enr = (value & 0x2) ? 0x6 : 0; break; default: qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%" HWADDR_PRIx "\n", TYPE_IMX_FEC, __func__, addr); break; } imx_fec_update(s); }
1threat
Binding `len = length xs` and then calculating `len` causes GHC to consume lots of RAM : <p>I found a strange thing about GHCi and lists.</p> <p>This command takes some time to execute and just returns the right answer.</p> <pre><code>ghci&gt; length [1..10^8] 100000000 </code></pre> <p>However, binding this to a variable and executing causes GHC to consume about 5 GiB of RAM without releasing until the GHCi session is over. Typing <code>:quit</code> after it consumes 3 GiB more before actually exiting.</p> <pre><code>ghci&gt; len = length [1..10^8] ghci&gt; len -- Consumes 5 GiB 100000000 ghci&gt; :quit -- Consumes 3 GiB -- Exits </code></pre> <p>Is this normal? What is the difference between the commands?</p> <p>GHC version is 8.2.2.</p>
0debug
How to detect when keyboard is opened or closed in React Native : <p>How to detect if user close the keyboard in react native, I want to call a function when user closed the keyboard.</p> <p>and if you can answer to detect keyboard is open too it will be appreciated, thanks. </p> <p>I'm on the react native latest <code>version 0.56</code></p>
0debug
'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS : <p>I'm using Visual Studio 2015 and attempting to compile code that has worked before I updated from VS 2013.</p> <p><strong><em>'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS</em></strong></p> <pre><code>partner.sin_addr.s_addr = inet_addr(ip.c_str()); </code></pre> <p>I attempted to use the functions mentioned but they were undefined. I attempted to define the macro in many different spots but nothing happened. Another thread said that I should include Ws2tcpip.h instead of WinSock2 &amp; add Ws2_32.lib. I already have the library added, and when I used the include nothing happened. What is going on?!</p>
0debug
How do min-content and max-content work? : <p>How are the <code>min-content</code> and <code>max-content</code> values calculated in CSS? </p> <p>And what does intrinsic dimension mean?</p>
0debug
format pythonic superscript in html way : From a file, I have got strings like: 4f^145d^66s^2 I have to format that in a html compatible way as: 4f<sup>14</sup>5d<sup>6</sup>6s<sup>2</sup> So that it looks like: 4f<sup>14</sup>5d<sup>6</sup>6s<sup>2</sup> This is an example and I have to format hundreds of them, so, doing it manually is not possible. What I have to do is replace `^` with `<sup>`(which is not problem); **find the next `[a-z]`, and insert `</sup>` one letter before that**(this is the problematic part), or at the end of the string. How I can do that?
0debug
Trailing where clause for extension of non-generic type : <p>I have the following code:</p> <pre><code>func registerNotification(name:String, selector:Selector) { NSNotificationCenter.defaultCenter().addObserver(self, selector: selector, name: name, object: nil) } func registerKeyboardNotifications() { let isInPopover = navigationController?.popoverPresentationController != nil let ignore = isInPopover &amp;&amp; DEVICE_IS_IPAD if !ignore { registerNotification(UIKeyboardWillShowNotification, selector: Selector("keyboardWillShow:")) registerNotification(UIKeyboardWillHideNotification, selector: Selector("keyboardWillHide:")) } } </code></pre> <p>in an extension to <code>UIViewController</code>. This code is reused by many viewcontroller to register for keyboard notifications. However with Swift 2.2 it produces a warning. I like the new <code>#selector</code> syntax but not sure how to implement it in this case. </p> <p>I think the correct solution is to make a protocol and extend <code>UIViewController</code> only for instances that conform to that protocol. My code so far:</p> <pre><code>@objc protocol KeyboardNotificationDelegate { func keyboardWillShow(notification: NSNotification) func keyboardWillHide(notification: NSNotification) } extension UIViewController where Self: KeyboardNotificationDelegate { func registerKeyboardNotifications() { let isInPopover = navigationController?.popoverPresentationController != nil let ignore = isInPopover &amp;&amp; DEVICE_IS_IPAD if !ignore { registerNotification(UIKeyboardWillShowNotification, selector: #selector(KeyboardNotificationDelegate.keyboardWillShow(_:))) registerNotification(UIKeyboardWillHideNotification, selector: #selector(KeyboardNotificationDelegate.keyboardWillHide(_:))) } } } </code></pre> <p>However this get me the error </p> <pre><code>trailing where clause for extension of non-generic type </code></pre> <p>on the extension row. Any ideas?</p>
0debug
static void rtas_int_on(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { struct ics_state *ics = spapr->icp->ics; uint32_t nr; if ((nargs != 1) || (nret != 1)) { rtas_st(rets, 0, -3); return; } nr = rtas_ld(args, 0); if (!ics_valid_irq(ics, nr)) { rtas_st(rets, 0, -3); return; } ics_write_xive(ics, nr, ics->irqs[nr - ics->offset].server, ics->irqs[nr - ics->offset].saved_priority, ics->irqs[nr - ics->offset].saved_priority); rtas_st(rets, 0, 0); }
1threat
How to get the current url in the browser in Angular 2 using TypeScript? : <p>I need to get the current URL present in the browser in my Angular 2 application. </p> <p>In JavaScript normally we do it using the window object.</p> <p>How can I do this in Angular 2 using TypeScript?</p> <p>Thanks.</p>
0debug
GIT pull failed: 'unable to unlink file: invalid argument' : <p>New GIT user here, managing a Moodle course web site system on a Windows server. Trying to do my first Pull update of the core code (using TortoiseGit) and it's not working. Git is unable to unlink old versions of any the 200+ files to be updated because of an "invalid argument". I have no idea what that means.</p> <p>Here's what it looks like after I dismiss 210 error dialogs: <a href="https://i.stack.imgur.com/iHmIM.png" rel="noreferrer">tortoisegit</a></p> <p>I've rebooted the server and scoured the web for ideas, but I'm at a loss for what to try next.</p> <p>Any ideas would be <em>greatly</em> appreciated!</p>
0debug
static void gif_copy_img_rect(const uint32_t *src, uint32_t *dst, int linesize, int l, int t, int w, int h) { const int y_start = t * linesize; const uint32_t *src_px, *src_pr, *src_py = src + y_start, *dst_py = dst + y_start; const uint32_t *src_pb = src_py + (t + h) * linesize; uint32_t *dst_px; for (; src_py < src_pb; src_py += linesize, dst_py += linesize) { src_px = src_py + l; dst_px = (uint32_t *)dst_py + l; src_pr = src_px + w; for (; src_px < src_pr; src_px++, dst_px++) *dst_px = *src_px; } }
1threat
visual studio 2015 debug command : <p>I have some problems with the debug command in visual studio 2015 professional. I have a limited access to debugger command. For example, commands like dc, db, ~ are working while lm, ld are not and also the extended commands like .dump, .ecxr. My visual studio is running on Windows 7. I am using the command window when the debugger has reach a breakpoint. I don't see what could go wrong. Any help appreciate ...</p>
0debug
How to activate a function after a given time? : <p>I would like to activate a function after a sound is played and complete. I assume that NSTimer needs to be included, but I am not sure of how to implement in order to make it. It is helpful if you could give me some code that works. </p>
0debug
static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv) { TPMInfo *res = g_new0(TPMInfo, 1); TPMPassthroughOptions *tpo; res->id = g_strdup(drv->id); res->model = drv->fe_model; res->options = g_new0(TpmTypeOptions, 1); switch (drv->ops->type) { case TPM_TYPE_PASSTHROUGH: res->options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH; tpo = g_new0(TPMPassthroughOptions, 1); res->options->u.passthrough = tpo; if (drv->path) { tpo->path = g_strdup(drv->path); tpo->has_path = true; } if (drv->cancel_path) { tpo->cancel_path = g_strdup(drv->cancel_path); tpo->has_cancel_path = true; } break; case TPM_TYPE__MAX: break; } return res; }
1threat
void xen_init_display(int domid) { struct XenDevice *xfb, *xin; struct XenFB *fb; struct XenInput *in; int i = 0; wait_more: i++; main_loop_wait(true); xfb = xen_be_find_xendev("vfb", domid, 0); xin = xen_be_find_xendev("vkbd", domid, 0); if (!xfb || !xin) { if (i < 256) { usleep(10000); goto wait_more; } xen_be_printf(NULL, 1, "displaystate setup failed\n"); return; } fb = container_of(xfb, struct XenFB, c.xendev); fb->c.con = graphic_console_init(xenfb_update, xenfb_invalidate, NULL, NULL, fb); fb->have_console = 1; in = container_of(xin, struct XenInput, c.xendev); in->c.con = fb->c.con; xen_be_check_state(xin); xen_be_check_state(xfb); }
1threat
eroor in my android code in main activity : enter code here import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java .lang.String; import static android.support.v7.appcompat.R.id.text; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView text = (TextView) findViewById(R.id.tv); Button btn = (Button) findViewById(R.id.btn_hit); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new Jsontask().execute("https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/moviesDemoItem.txt"); } }); } public class Jsontask extends AsyncTask<String,String,String>{ @Override protected String doInBackground(String... params) { HttpURLConnection http=null; BufferedReader reader = null; try { URL url=new URL(params[0]); http=(HttpURLConnection)url.openConnection(); http.connect(); InputStream inp=http.getInputStream(); reader=new BufferedReader(new InputStreamReader(inp)); String line=" "; StringBuffer read=new StringBuffer(); while((line=reader.readLine())!=null) read.append(line); return reader.toString(); } catch(MalformedURLException e1){ e1.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (http != null) http.disconnect(); try { if(reader!=null) reader.close(); } catch (IOException e) { e.printStackTrace(); } } return null; } @Override protected void onPostExecute(String result){ super.onPostExecute(result); text.setText(result); } } }
0debug
Library to calculate date in Javascript : <p>I have a question about a method to calculate total days by javascript. Example: - startDate = 20170916 and closeDate = 20171224 => 99 days</p> <p>What libs can I use to write this method? Note that can't use moment.js libs and I'm a newbie of js</p>
0debug
Setting conditional onClick behaviour in React Component : <p>I'm working on a component where a button (input field of type 'submit') will submitting data once clicked. However, I'd like to introduce a safeguard to show an alert on screen if the input field is blank.</p> <p>Thinking this would work the same way as it would for component attributes, I've tried variations on the following without much luck:</p> <pre><code>onClick={props.inputText === '' ? alert("Text cannot be blank.") : (e =&gt; props.onSubmit(props.inputText))}/&gt; </code></pre> <p>I'd rather not run the check inside the <em>onSubmit</em> function in order to isolate updates to the store as far as possible (I'm following a React-Redux structure).</p> <p>Any idea if and how JSX handles a situation like this?</p>
0debug
void virtqueue_map_sg(struct iovec *sg, hwaddr *addr, size_t num_sg, int is_write) { unsigned int i; hwaddr len; if (num_sg >= VIRTQUEUE_MAX_SIZE) { error_report("virtio: map attempt out of bounds: %zd > %d", num_sg, VIRTQUEUE_MAX_SIZE); exit(1); } for (i = 0; i < num_sg; i++) { len = sg[i].iov_len; sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write); if (sg[i].iov_base == NULL || len != sg[i].iov_len) { error_report("virtio: trying to map MMIO memory"); exit(1); } } }
1threat
void tcg_target_qemu_prologue (TCGContext *s) { int i, frame_size; frame_size = 0 + 8 + 8 + 8 + 8 + 8 + 8 + TCG_STATIC_CALL_ARGS_SIZE + ARRAY_SIZE (tcg_target_callee_save_regs) * 8 ; frame_size = (frame_size + 15) & ~15; tcg_out32 (s, MFSPR | RT (0) | LR); tcg_out32 (s, STDU | RS (1) | RA (1) | (-frame_size & 0xffff)); for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) tcg_out32 (s, (STD | RS (tcg_target_callee_save_regs[i]) | RA (1) | (i * 8 + 48 + TCG_STATIC_CALL_ARGS_SIZE) ) ); tcg_out32 (s, STD | RS (0) | RA (1) | (frame_size + 20)); tcg_out32 (s, STD | RS (2) | RA (1) | (frame_size + 40)); tcg_out32 (s, MTSPR | RS (3) | CTR); tcg_out32 (s, BCCTR | BO_ALWAYS); tb_ret_addr = s->code_ptr; for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) tcg_out32 (s, (LD | RT (tcg_target_callee_save_regs[i]) | RA (1) | (i * 8 + 48 + TCG_STATIC_CALL_ARGS_SIZE) ) ); tcg_out32 (s, LD | RT (0) | RA (1) | (frame_size + 20)); tcg_out32 (s, LD | RT (2) | RA (1) | (frame_size + 40)); tcg_out32 (s, MTSPR | RS (0) | LR); tcg_out32 (s, ADDI | RT (1) | RA (1) | frame_size); tcg_out32 (s, BCLR | BO_ALWAYS); }
1threat
static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat) { memset(stbuf, 0, sizeof(*stbuf)); stbuf->st_dev = prstat->st_dev; stbuf->st_ino = prstat->st_ino; stbuf->st_nlink = prstat->st_nlink; stbuf->st_mode = prstat->st_mode; stbuf->st_uid = prstat->st_uid; stbuf->st_gid = prstat->st_gid; stbuf->st_rdev = prstat->st_rdev; stbuf->st_size = prstat->st_size; stbuf->st_blksize = prstat->st_blksize; stbuf->st_blocks = prstat->st_blocks; stbuf->st_atim.tv_sec = prstat->st_atim_sec; stbuf->st_atim.tv_nsec = prstat->st_atim_nsec; stbuf->st_mtime = prstat->st_mtim_sec; stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec; stbuf->st_ctime = prstat->st_ctim_sec; stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec; }
1threat
the object does not have the specified attribute error in python : <p>I am new to python. The following is the code.</p> <pre><code>class simple: def __init__(self, str): print("inside the simple constructor") self.s = str # two methods: def show(self): print(self.s) def showMsg(self, msg): print(msg + ":", self.show()) if __name__ == "__main__": # create an object: x = simple("constructor argument") x.show() x.showMsg("A message") </code></pre> <p>After I run it, I got the </p> <pre><code>AttributeError: 'simple' object has no attribute 'show' </code></pre> <p>So, does anyone know what's going on here? 'show' is not an attribute, right? For my understanding, it should be a method. Does anyone understand what's going on here? Many thanks for your time and attention.</p>
0debug
How to generate automatic numbering that sent to email : <p>First of all I'm going to tell a bit about myself. I have an adequate knowledge about HTML, CSS. For PHP, I just started to learn.</p> <p>I'm building a website using Wordpress, and using Elementor. So in this Elementor plugin, there's a function to build form, capture it and sent to our chosen email.</p> <p>Currently I want to build a registration page that contain a form. The form will contain basic requirement such as name, age, address etc. So when a person fills the form, it will automatically be captured by the system and sent to our chosen email.</p> <p>The problem is, I want to put numbering to each registration made on the form sent to the email. Example: After a user has fill the form, I got an email stating that there was a new registration. I want in the headline or subject to have a registration number such as 'Registration No 221' , then the next user who gonna fill the form and the system sent it to us, will receive an email at his side stating that 'Your registration No is 222. Please wait for us to call you'. Meanwhile in our email, I want an email stating that 'New Registration Available: Registration No 222'. This is an automated email sent by the system.</p> <p>I want to have fully control on how the registration number start. So I can change it to start at number 500, then reset it to another number such as 356 or something else.</p> <p>I know a bit PHP but not too much. Is there any guide here how can I create this features? Thanks in advance.</p>
0debug
Accessing pointer member of the structure using structure pointer : <p>I have defined integer pointer inside the structure.And i want to use that member pointer using the structure pointer.My code is as shown below:</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; struct abc { int *x; }; int main() { struct abc *p = (struct abc*)malloc(sizeof(struct abc)); p-&gt;x = (int*)malloc(sizeof(int)); p-&gt;x = 10; printf("The value is %d\n",p-&gt;x); free(p); } </code></pre> <p>Now i am getting output as per my expectation.But i have got warning message while compiling.The warning messages are:</p> <pre><code>temp.c:14:7: warning: assignment makes pointer from integer without a cast [enabled by default] temp.c:15:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat] </code></pre> <p>I have also tried,</p> <pre><code>*p-&gt;x = 10 printf("The value is %d\n",*p-&gt;x); </code></pre> <p>but it is not working.</p> <p>How to solve this warning?</p>
0debug
How can unexpected '{' error in if condition be fixed in PHP? : <p>my php code is</p> <pre><code>&lt;?php session_start(); if(!isset($_SESSION["userId"]){ header('Location: index.php'); exit; } ?&gt; </code></pre> <p>and i got an error</p> <pre><code>Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\page\login.php on line 3 </code></pre> <p>can anyone help me to solve this problem</p>
0debug
What is the Operator Precedence of Await? : <p>In Javascript certain operators are processed before others:</p> <pre><code>1 + 2 * 3 // 1 + (2 * 3) // 7 because * has higher precedence than + 1 === 0 + 1 // 1 === (0 + 1) // true because + has a higher precedence than === </code></pre> <p>The MDN has a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence" rel="noreferrer">full breakdown of all operators</a> and their precedence ... except <code>await</code>.</p> <pre><code>await getFoo() * 2; // await (getFoo() * 2) or (await getFoo()) * 2? await getFoo() === 5; // await (getFoo() === 5) or (await getFoo()) === 5? </code></pre> <p>Can anyone explain which operators are processed before/after await?</p> <p>Right now I feel like I have to add a bunch of parenthesis that are probably unnecessary because I'm not sure what will get handled before/after <code>await</code>. And while I know I should just be able to look this up, even MDN (the gold standard of documentation IMHO) doesn't have the answer.</p>
0debug
static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset, const int16_t *block, ptrdiff_t stride) { int i; for(i=0; i<4; i++) FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); }
1threat
Cannot resolve symbol 'Theme' in styles.xml (Android Studio) : <p><a href="https://i.stack.imgur.com/dMjYm.png"><img src="https://i.stack.imgur.com/dMjYm.png" alt="Screenshot"></a></p> <p>Since today, Android Studio can't find the AppCompat themes in styles.xml, but for example AppCompatActivity in code does get recognized. My Android Studio version is 2.2.2, Build #AI-145.3360264</p> <p>I already tried upgrading to the latest build tools, compile sdk (25) version etc. but it didn't fix the problem.</p> <p>At the moment I have installed the following (from sdk manager):</p> <ul> <li>android api: 19 and 23</li> <li>sdk platform tools: 25.0.1</li> <li>sdk tools: 25.2.3</li> <li>build-tools: 23.0.2 and 25.0.1</li> <li>support repository: 40</li> <li>google repository: 39</li> </ul> <p>and a few others, that shouldn't be necessary to list here.</p> <p>build.gradle of app:</p> <pre><code>apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion '25.0.1' defaultConfig { applicationId "xxx.xxxxxxxx.xxxxxxxxx" //not the real applicationId minSdkVersion 14 targetSdkVersion 19 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile files('libs/RootTools.jar') compile 'com.android.support:support-v4:23.+' compile 'com.android.support:support-v13:23.+' compile 'com.android.support:appcompat-v7:23.+' compile 'com.android.support:design:23.+' compile 'com.android.support:cardview-v7:23.+' compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' compile 'de.hdodenhof:circleimageview:2.1.0' } </code></pre>
0debug
Linux where does zip place the newly created zip file? : <p>Looking to zip up a folder on my linux box ie <code>zip -r9 test /var/www/html/</code> where does that resulting test.zip file end up? in my pwd? I still want to leave the contents of /var/www/html intact.</p>
0debug
How to run a task every n minutes in C# : I wrote a code to update ddns which works fine, I wanted to know that if it is possible to run it every n minuted defined by a user. I searched stackoverflow but none of the solution seems to work. I tried using while(true) { this.DoMyMethod(); Thread.Sleep(TimeSpan.FromMinutes(1)); } and I am still having some trouble. What is the best way to run this task every n minutes. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.IO; using System.Net; using System.Net.Http; using System.Windows.Forms; using System.Timers; namespace GoogleDDNS { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { if (username.Text == "") { System.Windows.MessageBox.Show("Please enter the username"); username.Focus(); return; } if (password.Text == "") { System.Windows.MessageBox.Show("Please enter the password"); password.Focus(); return; } if (subdomain.Text == "") { System.Windows.MessageBox.Show("Please enter the subdomain"); subdomain.Focus(); return; } var client = new WebClient { Credentials = new NetworkCredential(username.Text, password.Text) }; var response = client.DownloadString("https://domains.google.com/nic/update?hostname=" + subdomain.Text); //MessageBox.Show(response); responseddns.Content = response; Properties.Settings.Default.usernamesave = username.Text; Properties.Settings.Default.passwordsave = password.Text; Properties.Settings.Default.subdomainsave = subdomain.Text; //Properties.Settings.Default.intervalsave = interval.Text; Properties.Settings.Default.Save(); } private void Window_Loaded(object sender, RoutedEventArgs e) { username.Text = Properties.Settings.Default.usernamesave; password.Text = Properties.Settings.Default.passwordsave; subdomain.Text = Properties.Settings.Default.subdomainsave; //interval.Text = Properties.Settings.Default.intervalsave; } } }
0debug
python code for compiling sequence : please i have a problem in my code it doesn't give me the desired output import re f = open("cub.txt") cub = f.read() f.close() r = re.compile("([A-A]{1})\s([A-A,'A'])\s([-+]?[0-9]*\.?[0-9]*)") matches = re.findall(r, cub) print (matches) desired output: {'A': {'GCA': '0.26', 'GCC': '0.32', 'GCU': '0.29', 'GCG': '0.13'}, 'C': {'UGC': '0.60', 'UGU': '0.40'}, 'E': {'GAG': '0.57', 'GAA': '0.43'}, 'D': {'GAU': '0.50', 'GAC': '0.50'}, 'G': {'GGU': '0.18', 'GGG': '0.25', 'GGA': '0.27', 'GGC': '0.31'}, 'F': {'UUU': '0.45', 'UUC': '0.55'}, 'I': {'AUA': '0.18', 'AUC': '0.46', 'AUU': '0.35'}, 'H': {'CAC': '0.60', 'CAU': '0.40'}, 'K': {'AAG': '0.56', 'AAA': '0.44'}, '*': {'UAA': '0.41', 'UGA': '0.59'}, 'M': {'AUG': '1.00'}, 'L': {'CUU': '0.13', 'CUG': '0.41', 'CUC': '0.18', 'CUA': '0.06', 'UUG': '0.13', 'UUA': '0.08'}, 'N': {'AAU': '0.43', 'AAC': '0.57'}, 'Q': {'CAA': '0.27', 'CAG': '0.72', 'UAG': '0.01'}, 'P': {'CCU': '0.27', 'CCG': '0.14', 'CCA': '0.28', 'CCC': '0.30'}, 'S': {'UCU': '0.18', 'AGC': '0.26', 'UCG': '0.07', 'UCC': '0.20', 'UCA': '0.15', 'AGU': '0.14'}, 'R': {'CGA': '0.10', 'CGC': '0.19', 'AGA': '0.22', 'AGG': '0.21', 'CGG': '0.18', 'CGU': '0.10'}, 'T': {'ACC': '0.31', 'ACA': '0.30', 'ACG': '0.14', 'ACU': '0.25'}, 'W': {'UGG': '1.00'}, 'V': {'GUC': '0.22', 'GUA': '0.12', 'GUG': '0.45', 'GUU': '0.21'}, 'Y': {'UAC': '0.60', 'UAU': '0.40'}}
0debug
Variable is not declared error : <p>I'm trying to get visual basic to work through Visual Studio 2013. I began the course a week ago so I'm pretty clueless. All I know is how to create a new project, in general select Form and in declarations select Activated. In the end I end up with the following code : </p> <pre><code>Public Class Form1 Private Sub Form1_Activated(sender As Object, e As EventArgs) Handles Me.Activated a = 3 b = 2 c = a + b Print(c) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub End Class </code></pre> <p>Pretty sure something needs to be deleted. I tried declaring a,b and c with Int but that didn't help and I'm still getting the same error. I tried deleting everything except </p> <pre><code>Private Sub Form1_Activated(sender As Object, e As EventArgs) Handles Me.Activated a = 3 b = 2 c = a + b Print(c) End Sub </code></pre> <p>but then I get the error Statement is not valid in a namespace.</p>
0debug
static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) { CPUS390XState *env = &cpu->env; const uint8_t r1 = ipa1 >> 4; const uint8_t r3 = ipa1 & 0x0f; int ret; uint8_t order; uint64_t *status_reg; uint64_t param; S390CPU *dst_cpu = NULL; cpu_synchronize_state(CPU(cpu)); order = decode_basedisp_rs(env, run->s390_sieic.ipb, NULL) & SIGP_ORDER_MASK; status_reg = &env->regs[r1]; param = (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1]; if (qemu_mutex_trylock(&qemu_sigp_mutex)) { ret = SIGP_CC_BUSY; goto out; } switch (order) { case SIGP_SET_ARCH: ret = sigp_set_architecture(cpu, param, status_reg); break; default: dst_cpu = s390_cpu_addr2state(env->regs[r3]); ret = handle_sigp_single_dst(dst_cpu, order, param, status_reg); } trace_kvm_sigp_finished(order, CPU(cpu)->cpu_index, dst_cpu ? CPU(dst_cpu)->cpu_index : -1, ret); if (ret >= 0) { setcc(cpu, ret); return 0; } return ret; }
1threat
static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_checksum) { int64_t start, size; size= get_v(bc); init_checksum(bc, calculate_checksum ? av_crc04C11DB7_update : NULL, 1); return size; }
1threat
Collect Specific Rows from txt file : <p><a href="https://i.stack.imgur.com/6rmL2.png" rel="nofollow noreferrer">sample of the txt file</a> </p> <p>I want to extract the whole lines from a txt file which has <strong><em>NVSS</em></strong> keyword and export it as a new txt file but I have no idea how to do this. Thank you</p>
0debug
int opt_opencl_bench(void *optctx, const char *opt, const char *arg) { int i, j, nb_devices = 0, count = 0; int64_t score = 0; AVOpenCLDeviceList *device_list; AVOpenCLDeviceNode *device_node = NULL; OpenCLDeviceBenchmark *devices = NULL; cl_platform_id platform; av_opencl_get_device_list(&device_list); for (i = 0; i < device_list->platform_num; i++) nb_devices += device_list->platform_node[i]->device_num; if (!nb_devices) { av_log(NULL, AV_LOG_ERROR, "No OpenCL device detected!\n"); return AVERROR(EINVAL); } if (!(devices = av_malloc_array(nb_devices, sizeof(OpenCLDeviceBenchmark)))) { av_log(NULL, AV_LOG_ERROR, "Could not allocate buffer\n"); return AVERROR(ENOMEM); } for (i = 0; i < device_list->platform_num; i++) { for (j = 0; j < device_list->platform_node[i]->device_num; j++) { device_node = device_list->platform_node[i]->device_node[j]; platform = device_list->platform_node[i]->platform_id; score = av_opencl_benchmark(device_node, platform, run_opencl_bench); if (score > 0) { devices[count].platform_idx = i; devices[count].device_idx = j; devices[count].runtime = score; av_strlcpy(devices[count].device_name, device_node->device_name, sizeof(devices[count].device_name)); count++; } } } qsort(devices, count, sizeof(OpenCLDeviceBenchmark), compare_ocl_device_desc); fprintf(stderr, "platform_idx\tdevice_idx\tdevice_name\truntime\n"); for (i = 0; i < count; i++) fprintf(stdout, "%d\t%d\t%s\t%"PRId64"\n", devices[i].platform_idx, devices[i].device_idx, devices[i].device_name, devices[i].runtime); av_opencl_free_device_list(&device_list); av_free(devices); return 0; }
1threat
static void intel_hda_parse_bdl(IntelHDAState *d, IntelHDAStream *st) { target_phys_addr_t addr; uint8_t buf[16]; uint32_t i; addr = intel_hda_addr(st->bdlp_lbase, st->bdlp_ubase); st->bentries = st->lvi +1; g_free(st->bpl); st->bpl = g_malloc(sizeof(bpl) * st->bentries); for (i = 0; i < st->bentries; i++, addr += 16) { pci_dma_read(&d->pci, addr, buf, 16); st->bpl[i].addr = le64_to_cpu(*(uint64_t *)buf); st->bpl[i].len = le32_to_cpu(*(uint32_t *)(buf + 8)); st->bpl[i].flags = le32_to_cpu(*(uint32_t *)(buf + 12)); dprint(d, 1, "bdl/%d: 0x%" PRIx64 " +0x%x, 0x%x\n", i, st->bpl[i].addr, st->bpl[i].len, st->bpl[i].flags); } st->bsize = st->cbl; st->lpib = 0; st->be = 0; st->bp = 0; }
1threat
trouble with inputs using a while loop : int towerh; do{ printf ("give me an integer between 1 and 23 and I will make a tower"); int towerh = GetInt(); }while (towerh < 1 || towerh > 23); I'm trying to make this code block loop as long as towerh is not between 1 and 23. I keep getting errors saying that the variable needs to be initialized. I'm sure this is a small thing but I have no clue how to assess or correct it in c.
0debug
How do you find your GitLab host name (to test your SSH key)? : <p>I just created a personal GitLab account and am trying to follow the steps on </p> <p><a href="https://gitlab.com/help/ssh/README" rel="noreferrer">https://gitlab.com/help/ssh/README</a></p> <p>to deploy my SSH key to GitLab. I've completed up to step 5, and see my SSH key among 'Your SSH keys' in my User Settings -> SSH keys:</p> <p><a href="https://i.stack.imgur.com/V1njx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/V1njx.png" alt="enter image description here"></a></p> <p>I'm trying to now complete the optional 6th step, testing the key:</p> <p><a href="https://i.stack.imgur.com/Sbj68.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Sbj68.png" alt="enter image description here"></a></p> <p>My GitLab username is <code>khpeek</code>, so I guessed my 'GitLab domain' is <code>gitlab.com/khpeek</code>. However, the test command</p> <pre><code>ssh -T git@gitlab.com/khpeek </code></pre> <p>yields an error message:</p> <pre><code>ssh: Could not resolve hostname gitlab.com/khpeek: Name or service not known </code></pre> <p>Apparently this is the wrong hostname. What would be the right one?</p>
0debug
What is the benefit of using a pointer C++ : <p>I Was just confused on the part of using a pointer on C++.. well you might say, "a pointer is obviously a memory adress of another variable and there are certaintly conditions in your program where you will need them". But i dont mean pointer in general, i mean the pointer you use to like "simulate" a class... I think code will explain it more:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include "Book.h" int main() { Book book1; Book *bookPointer = &amp;book1; book1.setBooksId(123); std::cout &lt;&lt; "BOOK ID: " &lt;&lt; book1.getBookId() &lt;&lt; std::endl; (*bookPointer).setBooksId(300); std::cout &lt;&lt; (*bookPointer).getBookId() &lt;&lt; std::endl; /*When usage of arrow member selection member, left is always a pointer. Same thing as above, but better practice! */ bookPointer-&gt;setBooksId(100); std::cout &lt;&lt; "POINTER ARROW : " &lt;&lt; bookPointer-&gt;getBookId() &lt;&lt; std::endl; return 0; } </code></pre> <p>Here you see i have another pointer that is called bookPointer which all it does is the same as the original instance of book class book1... I dont get it.. What is the advantage of using this? Give me a scenario if you can! Thanks for Helping!!</p>
0debug
Sorting array of diffrent customers type? The main shoul have this : -Printing number of NormalCustomers -Printing number of MemberCustomers -Printing number of StudentCustomers -Creat Mylibrary objecr from library class with valus enterd from keybord -Creat number of subscribers (the number is enterd by the keyboard)and add them to the Mylibrary matrix -Craeat number of ordinary customers(the number is enterd by keyboard) and add them to the my library matrix and same thing for the other to types -Printing information after passing id -Print info for all custimers -Sort customers according to the bill value -Sortcustimer according to their type Note: i have created every thing i need in the classes exept the sortig according to type i just cant seem to get all of this together so i need help please
0debug
How to initiate a HashSet with Enumaration Values in Android Studio : I am working with a library with a method with have a HashSet with enumaration parameter, and i ain't able to call that method. I think that question is probably easiest that i think, but i have this problem from two days. Follow the method in library: public int searchCard(HashSet<CardSlotTypeEnum> var1, int var2, OnCardInfoListener var3) { if(var2 >= 0 && var3 != null) { u.a().a(var1, var2, var3); return 0; } else { return -2; } } Follow the enumaration CardSlotTypeEnum: public enum CardSlotTypeEnum { ICC1, ICC2, ICC3, PSAM1, PSAM2, PSAM3, RF, SWIPE, } Follow my code: reader = deviceEngine.getCardReader(); OnCardInfoListener info = new OnCardInfoListener() {}; HashSet<CardSlotTypeEnum> teste = new HashSet<CardSlotTypeEnum>(); reader.searchCard(teste,60,info); I'm having problems to initialize the 'teste' variable, this way was the only that don't are giving some message of error to me, but in this case the 'teste' aren't receiving nothing. If someone could help me i would stay quite grateful. Thank you.
0debug
How to convert strings into lists : <p>("1 34 23 12 -89 11)</p> <p>How do I make it like this:</p> <p>['1','34','23','12','-89','11']</p> <p>This is spaced string which I need to convert to a list.</p>
0debug
recursively find the second (kth generally) largest int in list of list of int python : As a newbie in programming, i am trying to do a func to find the second largest int in a list of list of ints. I tried list of ints before and it worked. However, for this function, its base case has too many possibilities, ex [1, 2], [[], 1], [[1], 2], [[1], [1]]. I got stuck at the base case. Can anyone give me a hint for this? This func would be like find_2smallest([1,1,3])->1, find_2smallest([[1,[]], 9, [[1], [3]], [4]])->3.
0debug
TensorFlow freeze_graph.py: The name 'save/Const:0' refers to a Tensor which does not exist : <p>I am currently trying to export a trained TensorFlow model as a ProtoBuf file to use it with the TensorFlow C++ API on Android. Therefore, I'm using the <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py" rel="noreferrer"><code>freeze_graph.py</code></a> script.</p> <p>I exported my model using <code>tf.train.write_graph</code>:</p> <p><code>tf.train.write_graph(graph_def, FLAGS.save_path, out_name, as_text=True) </code></p> <p>and I'm using a checkpoint saved with <code>tf.train.Saver</code>.</p> <p>I invoke <code>freeze_graph.py</code> as described at the top of the script. After compiling, I run</p> <pre><code>bazel-bin/tensorflow/python/tools/freeze_graph \ --input_graph=&lt;path_to_protobuf_file&gt; \ --input_checkpoint=&lt;model_name&gt;.ckpt-10000 \ --output_graph=&lt;output_protobuf_file_path&gt; \ --output_node_names=dropout/mul_1 </code></pre> <p>This gives me the following error message:</p> <pre><code>TypeError: Cannot interpret feed_dict key as Tensor: The name 'save/Const:0' refers to a Tensor which does not exist. The operation, 'save/Const', does not exist in the graph. </code></pre> <p>As the error states I do not have a tensor <code>save/Const:0</code> in my exported model. However, the code of <code>freeze_graph.py</code> says that one can specify this tensor name by the flag <code>filename_tensor_name</code>. Unfortunately I cannot find any information on what this tensor should be and how to set it correctly for my model.</p> <p>Can somebody tell my either how to produce a <code>save/Const:0</code> tensor in my exported ProtoBuf model or how to set the flag <code>filename_tensor_name</code> correctly?</p>
0debug
Define UIAlertViewController once and use it in different classes in OBJECTIVE - C : This might be a very basic question but yet i want to know a way out for this problem. It would be great to find any kind of help. //Modal.h -(void)errorAlert : (NSString *)title : (NSString *)desc : (NSString *)buttonTitle; //Modal.m -(void)errorAlert: (NSString *)title : (NSString *)desc : (NSString *)buttonTitle{ alert = [UIAlertController alertControllerWithTitle:title message:desc preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *ok = [UIAlertAction actionWithTitle:buttonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:ok]; [self presentViewController:alert animated:YES completion:nil]; } Now i want to use this `errorAlert` in other classes so that i don't have to write the validation for alert again //Login.m #import "Modal.m" @property (strong, nonatomic) Modal *modal; -(void)viewDidLoad{ _modal = [[Modal alloc] init]; } //MARK: Submit Clicked - (IBAction)submitClicked:(UIButton *)sender { // I want to use that method here. } Please suggest me a way out so that i can optimise my code according to this format
0debug
void ppc_slb_invalidate_all (CPUPPCState *env) { target_phys_addr_t sr_base; uint64_t tmp64; int n, do_invalidate; do_invalidate = 0; sr_base = env->spr[SPR_ASR]; for (n = 0; n < env->slb_nr; n++) { tmp64 = ldq_phys(sr_base); if (slb_is_valid(tmp64)) { slb_invalidate(&tmp64); stq_phys(sr_base, tmp64); do_invalidate = 1; } sr_base += 12; } if (do_invalidate) tlb_flush(env, 1); }
1threat
void ppc_slb_invalidate_all (CPUPPCState *env) { tlb_flush(env, 1); }
1threat
TYPO3 Plugin nur für Typoscript-Einbindung : <p>Ich habe ein Plugin einer Extension dass ich nur über TypoScript einbinden möchte. In der Plugin-Liste des CE-Wizards soll es nicht erscheinen. Ich möchte das dann im Fluid per typoscriptObject Viewhelper laden. </p> <p>Wie blende ich es im Wizard aus?</p>
0debug
void vnc_client_read(void *opaque) { VncState *vs = opaque; long ret; buffer_reserve(&vs->input, 4096); #ifdef CONFIG_VNC_TLS if (vs->tls.session) { ret = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096); if (ret < 0) { if (ret == GNUTLS_E_AGAIN) errno = EAGAIN; else errno = EIO; ret = -1; } } else #endif ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0); ret = vnc_client_io_error(vs, ret, socket_error()); if (!ret) return; vs->input.offset += ret; while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) { size_t len = vs->read_handler_expect; int ret; ret = vs->read_handler(vs, vs->input.buffer, len); if (vs->csock == -1) return; if (!ret) { memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len)); vs->input.offset -= len; } else { vs->read_handler_expect = ret; } } }
1threat
Android Jetpack navigation, host fragment inside another host fragment : <p>I'm trying to achieve a simple design. One activity with a host fragment.</p> <p>The thing is, one of the destinations has a bottom navigation bar.</p> <p>Here's a paint sketch <a href="https://i.stack.imgur.com/VyZSl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VyZSl.png" alt="enter image description here"></a></p> <p>After a little bit of research, I discovered that the best practice is to have a single Activity with a host fragment. </p> <p>In my particular case, the bottom navigation bar should not be visible in the login and register fragments and just hiding it doesn't seem right to me.</p> <p>I managed to create an activity with a bottom navigation bar connecting <strong>main fragment</strong> to <strong>frag 1</strong>, <strong>frag 2</strong> or <strong>frag 3</strong>, but now I need to add the <strong>login fragment</strong> and <strong>register fragment</strong> and I'm not sure how to handle the navigation.</p> <p>Here's the code for the app without the authentication fragments.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".Presentation.MainActivity"&gt; &lt;androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" app:title="Glucose Entries" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?colorPrimary" android:theme="@style/ToolbarTheme"/&gt; &lt;com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_nav" android:layout_width="match_parent" android:layout_height="wrap_content" app:menu="@menu/bottom_navigation_bar"/&gt; &lt;fragment android:id="@+id/nav_host_fragment" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:name="androidx.navigation.fragment.NavHostFragment" app:navGraph="@navigation/mobile_navigation" app:defaultNavHost="true" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Also:</p> <pre><code>class MainActivity : AppCompatActivity() { private lateinit var navController: NavController override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) setSupportActionBar(toolbar) navController = Navigation.findNavController(this, R.id.nav_host_fragment) bottom_nav.setupWithNavController(navController) NavigationUI.setupActionBarWithNavController(this, navController) } // stuff } </code></pre> <p>And the navigation file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mobile_navigation" app:startDestination="@id/mainListFragment"&gt; &lt;!--frag 1 --&gt; &lt;fragment android:id="@+id/mainListFragment" android:name="com.gluco.Presentation.MainList.MainListFragment" android:label="Glucose Entries" tools:layout="@layout/main_list_fragment"&gt; &lt;/fragment&gt; &lt;!--frag 2 --&gt; &lt;fragment android:id="@+id/statisticsFragment" android:name="com.gluco.Presentation.Statistics.StatisticsFragment" android:label="statistics_fragment" tools:layout="@layout/statistics_fragment" /&gt; &lt;!--frag 3 --&gt; &lt;fragment android:id="@+id/settingsFragment" android:name="com.gluco.Presentation.Settings.SettingsFragment" android:label="SettingsFragment" /&gt; &lt;/navigation&gt; </code></pre> <p>Should I just hide the navigation bar on fragments where is not supposed to be?</p> <p>Also, I'm thinking another solution could be to not use the automatic navigation provided from the bottom navigation bar and create my own actions to navigate from <strong>main fragment</strong> to <strong>frag 1</strong>, <strong>frag 2</strong> or <strong>frag 3</strong></p>
0debug
Is there any way to delegate the index property in typescript? : <p>Is there any way to delegate the index property to a member in typescript? I am writing a wrapper, and I would like to delegate the index property to the object I am wrapping.</p> <p>Something like:</p> <pre><code>interface MyStringArray { length : number; clear() : void; [index: number] : string; } export class MyStringArrayWrapper implements MyStringArray { private wrapped : MyStringArray; public get length() : number { return this.wrapped.length; } public clear() : void { this.wrapped.clear(); } // This doesn't work public get [index : number] : string { return this.wrapped[index]; } // This doesn't work either public set [index : number](value: string) { this.wrapped[index] = value; } } </code></pre>
0debug
ConfigurationManager and AppSettings in universal (UWP) app : <p>I would like to store an API key in a configuration file without checking it into source control, and read the data in my UWP app.</p> <p>A common solution is to store the key in .config file (such as <code>app.config</code> or <code>web.config</code>) and access it like so:</p> <pre><code>var apiKey = ConfigurationManager.AppSettings.Get("apiKey"); </code></pre> <p>I'm working on a Universal Windows (UWP) app and can't access the System.Configuration namespace that holds <code>ConfigurationManager</code>.</p> <p>How can I access AppSettings in UWP app? Alternatively, what's the best way to access configuration data in an UWP app?</p>
0debug
The difference between the "include" statement and the "#include" directive of Fortran : <p>What is the difference between the "include" statement and the preprocessor "#include" of Fortran?</p>
0debug
How can i get value in combobox with function : public string year( ComboBox cbYears) { string value = null; value= cbYears.SelectedText; return value; } This is my function but i get always null value, where is my mistake can anyone help me ?
0debug
Cumulative values of a column for each group (R) : <p>I have a data frame that looks like this :</p> <pre><code>&gt; year&lt;-c(2014,2014,2014,2015,2015,2015,2016,2016,2016) &gt; group&lt;-c("A","B","C","A","B","C","A","B","C") &gt; n&lt;-c(1,1,1,1,2,0,2,1,1) &gt; df&lt;-data.frame(year=year,group=group,n=n) &gt; df year group n 2014 A 1 2014 B 1 2014 C 1 2015 A 1 2015 B 2 2015 C 0 2016 A 2 2016 B 1 2016 C 1 </code></pre> <p>I want to create a column that contains the cumulated values of n for each group to have something like this : </p> <pre><code>year group n sum 2014 A 1 1 2014 B 1 1 2014 C 1 1 2015 A 1 2 2015 B 2 3 2015 C 0 1 2016 A 2 4 2016 B 1 4 2016 C 1 2 </code></pre>
0debug
static inline int array_roll(array_t* array,int index_to,int index_from,int count) { char* buf; char* from; char* to; int is; if(!array || index_to<0 || index_to>=array->next || index_from<0 || index_from>=array->next) return -1; if(index_to==index_from) return 0; is=array->item_size; from=array->pointer+index_from*is; to=array->pointer+index_to*is; buf=g_malloc(is*count); memcpy(buf,from,is*count); if(index_to<index_from) memmove(to+is*count,to,from-to); else memmove(from,from+is*count,to-from); memcpy(to,buf,is*count); free(buf); return 0; }
1threat
reffer to a class/method : I have this method in my Calroies Class which inhertis the User class. class Calories : User { public void CalcuateCaloriesMale() { var user = new User(); var equation = (10 * user.Weight) + (6.25 * user.Height) - (5 * user.Age) + 5; Console.WriteLine("Based on the Mifflin – St Jeor Formula You need to eat {0} Kalories a day\nTo Gain Weight ", equation); } } And i have this code in Program.cs if (newGoal.GoalStatusGainWeight == true) { var calories = new Calories(); switch (newUser.Gender) { case "m": calories.CalcuateCaloriesMale(); break; Now I dont understand how to make the Calories Class know what the user has typed in at the beginning of the Beginning. newUser.Name = Question.AskString("Name: "); newUser.Age = Question.AskInt("Age: "); newUser.Gender = Question.AskString("Gender(m/f): "); newUser.Height = Question.AskInt("Height(cm): "); newUser.Weight = Question.AskInt("Weight(kg): "); The Calories Class doesn't take into consideration waht the user has typed in. I tought i can juse make a new User, but i guess my thinking was wrong. What am i doing wrong ? How can i imagine this working so i can learn it better? Thank you
0debug
It gives errors when using Swift Static library with Objective-C project : <p>I need to make swift static library for my requirement. I made swift static library which uses swift and Obj-c code. I have included Obj-c files via bridge file. I am able to compile swift static library without any error and get libMySwift.a file. I use Xcode9.3 with Swift4 to compile library.</p> <p>I include libMySwift.a in obj-c project and also included obj-c compatible header to access my lib in the project. When I try to compile the project it give below warning and more than 200 errors. </p> <pre><code>Auto-Linking library not found for -lswiftSwiftOnoneSupport Auto-Linking library not found for -lswiftCore Auto-Linking library not found for -lswiftQuartzCore Auto-Linking library not found for -lswiftCoreImage Auto-Linking library not found for -lswiftCoreGraphics Auto-Linking library not found for -lswiftObjectiveC Auto-Linking library not found for -lswiftDispatch Auto-Linking library not found for -lswiftMetal Auto-Linking library not found for -lswiftFoundation Auto-Linking library not found for -lswiftUIKit Auto-Linking library not found for -lswiftDarwin Auto-Linking library not found for -lswiftCoreFoundation </code></pre> <p>Please let me know if I am missing any steps or need to add anything.</p>
0debug
javascript - lodash - create a unique list based on multiple attributes : <p>My collection looks like this. </p> <pre><code> var list = [{id:'12345', sequence:null}, {id:'12346', sequence:null}, {id:'12347', sequence:null}, {id:'12348', sequence:1}, {id:'12348', sequence:2}, {id:'12349', sequence:1}, {id:'12349', sequence:1}]; </code></pre> <p>I am trying to get a unique list so that object with same id AND sequence will only return one of the objects (we have 2 here- {id:'12349', sequence:1})</p> <p>my code</p> <pre><code> var uniqueList = _.uniq(list, function(obj) { return obj.id &amp;&amp; obj.sequence; }); </code></pre> <p>can we use lodash uniq like this? what is the approach to fix this issue?</p>
0debug
static void evalPrimary(Parser *p){ double d, d2=NAN; char *next= p->s; int i; d= strtod(p->s, &next); if(next != p->s){ push(p, d); p->s= next; return; } for(i=0; p->const_name[i]; i++){ if(strmatch(p->s, p->const_name[i])){ push(p, p->const_value[i]); p->s+= strlen(p->const_name[i]); return; } } p->s= strchr(p->s, '('); if(p->s==NULL){ av_log(NULL, AV_LOG_ERROR, "Parser: missing ( in \"%s\"\n", next); return; } p->s++; evalExpression(p); d= pop(p); p->s++; if(p->s[-1]== ','){ evalExpression(p); d2= pop(p); p->s++; } if( strmatch(next, "sinh" ) ) d= sinh(d); else if( strmatch(next, "cosh" ) ) d= cosh(d); else if( strmatch(next, "tanh" ) ) d= tanh(d); else if( strmatch(next, "sin" ) ) d= sin(d); else if( strmatch(next, "cos" ) ) d= cos(d); else if( strmatch(next, "tan" ) ) d= tan(d); else if( strmatch(next, "exp" ) ) d= exp(d); else if( strmatch(next, "log" ) ) d= log(d); else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d)); else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI); else if( strmatch(next, "abs" ) ) d= fabs(d); else if( strmatch(next, "max" ) ) d= d > d2 ? d : d2; else if( strmatch(next, "min" ) ) d= d < d2 ? d : d2; else if( strmatch(next, "gt" ) ) d= d > d2 ? 1.0 : 0.0; else if( strmatch(next, "lt" ) ) d= d > d2 ? 0.0 : 1.0; else if( strmatch(next, "eq" ) ) d= d == d2 ? 1.0 : 0.0; else{ int error=1; for(i=0; p->func1_name && p->func1_name[i]; i++){ if(strmatch(next, p->func1_name[i])){ d= p->func1[i](p->opaque, d); error=0; break; } } for(i=0; p->func2_name && p->func2_name[i]; i++){ if(strmatch(next, p->func2_name[i])){ d= p->func2[i](p->opaque, d, d2); error=0; break; } } if(error){ av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next); return; } } if(p->s[-1]!= ')'){ av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", next); return; } push(p, d); }
1threat
gradle build sync failed what should i do? : :app:processDebugResources C:\Users\admin\AndroidStudioProjects\ishan\app\src\main\res\layout\activity_main.xml Error:(11) Error parsing XML: junk after document element Error:Execution failed for task ':app:processDebugResources'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\admin\AppData\Local\Android\Sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1 Information:BUILD FAILED Information:2 errors Information:Total time: 5.789 secs
0debug
static void dec_rcsr(DisasContext *dc) { LOG_DIS("rcsr r%d, %d\n", dc->r2, dc->csr); switch (dc->csr) { case CSR_IE: tcg_gen_mov_tl(cpu_R[dc->r2], cpu_ie); break; case CSR_IM: gen_helper_rcsr_im(cpu_R[dc->r2], cpu_env); break; case CSR_IP: gen_helper_rcsr_ip(cpu_R[dc->r2], cpu_env); break; case CSR_CC: tcg_gen_mov_tl(cpu_R[dc->r2], cpu_cc); break; case CSR_CFG: tcg_gen_mov_tl(cpu_R[dc->r2], cpu_cfg); break; case CSR_EBA: tcg_gen_mov_tl(cpu_R[dc->r2], cpu_eba); break; case CSR_DC: tcg_gen_mov_tl(cpu_R[dc->r2], cpu_dc); break; case CSR_DEBA: tcg_gen_mov_tl(cpu_R[dc->r2], cpu_deba); break; case CSR_JTX: gen_helper_rcsr_jtx(cpu_R[dc->r2], cpu_env); break; case CSR_JRX: gen_helper_rcsr_jrx(cpu_R[dc->r2], cpu_env); break; case CSR_ICC: case CSR_DCC: case CSR_BP0: case CSR_BP1: case CSR_BP2: case CSR_BP3: case CSR_WP0: case CSR_WP1: case CSR_WP2: case CSR_WP3: cpu_abort(dc->env, "invalid read access csr=%x\n", dc->csr); break; default: cpu_abort(dc->env, "read_csr: unknown csr=%x\n", dc->csr); break; } }
1threat
how do I change the innerText on the li element with Javascript : [photo of code so far][1] [1]: https://i.stack.imgur.com/loo41.png Pic show's the browser loaded. Need to change the 'li' class "buddyName" - "strider" to "Aragon". This was most recent attempt but not working: document.querySelectorAll('buddyName'[3]).innerHTML = "Aragorn";
0debug
I want to group Columns in pandas : <p>I have Data frame which consist different columns and I want to group columns in the bases of AccountID <a href="https://i.stack.imgur.com/V755B.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V755B.jpg" alt="in the bases of AccountID"></a> </p> <p>and expected output looks like this <a href="https://i.stack.imgur.com/E4MLs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E4MLs.jpg" alt="enter image description here"></a></p>
0debug
Reset weights in Keras layer : <p>I'd like to reset (randomize) the weights of all layers in my Keras (deep learning) model. The reason is that I want to be able to train the model several times with different data splits without having to do the (slow) model recompilation every time.</p> <p>Inspired by <a href="https://github.com/fchollet/keras/pull/1908" rel="noreferrer">this discussion</a>, I'm trying the following code:</p> <pre><code># Reset weights for layer in KModel.layers: if hasattr(layer,'init'): input_dim = layer.input_shape[1] new_weights = layer.init((input_dim, layer.output_dim),name='{}_W'.format(layer.name)) layer.trainable_weights[0].set_value(new_weights.get_value()) </code></pre> <p>However, it only partly works.</p> <p>Partly, becuase I've inspected some layer.get_weights() values, and they seem to change. But when I restart the training, the cost values are much lower than the initial cost values on the first run. It's almost like I've succeeded resetting some of the weights, but not all of them.</p> <p>Any tips on where I'm going wrong would be deeply appreciated. Thx..</p>
0debug
static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len) { uint8_t *buf = bufptr ? *bufptr : NULL; int flags = 0; uint32_t timestamp; int rv = 0; if (!buf) { if (s->prev_ret <= 0) return rtp_parse_queued_packet(s, pkt); if (s->handler && s->handler->parse_packet) { timestamp = RTP_NOTS_VALUE; rv = s->handler->parse_packet(s->ic, s->dynamic_protocol_context, s->st, pkt, &timestamp, NULL, 0, 0, flags); finalize_packet(s, pkt, timestamp); return rv; } } if (len < 12) return -1; if ((buf[0] & 0xc0) != (RTP_VERSION << 6)) return -1; if (RTP_PT_IS_RTCP(buf[1])) { return rtcp_parse_packet(s, buf, len); } if (s->st) { int64_t received = av_gettime_relative(); uint32_t arrival_ts = av_rescale_q(received, AV_TIME_BASE_Q, s->st->time_base); timestamp = AV_RB32(buf + 4); rtcp_update_jitter(&s->statistics, timestamp, arrival_ts); } if ((s->seq == 0 && !s->queue) || s->queue_size <= 1) { return rtp_parse_packet_internal(s, pkt, buf, len); } else { uint16_t seq = AV_RB16(buf + 2); int16_t diff = seq - s->seq; if (diff < 0) { av_log(s->st ? s->st->codec : NULL, AV_LOG_WARNING, "RTP: dropping old packet received too late\n"); return -1; } else if (diff <= 1) { rv = rtp_parse_packet_internal(s, pkt, buf, len); return rv; } else { enqueue_packet(s, buf, len); *bufptr = NULL; if (s->queue_len >= s->queue_size) { av_log(s->st ? s->st->codec : NULL, AV_LOG_WARNING, "jitter buffer full\n"); return rtp_parse_queued_packet(s, pkt); } return -1; } } }
1threat
How to change this pseudo class with javascript? : <br> I have the following SVG element which is related to some other stuff <text x="370.9472783496851" y="141.05272165031482" text-anchor="middle" font="10px &quot;Arial&quot;" stroke="none" fill="#000000" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-anchor: middle; font: 10px Arial;" class="wheelnav-wheelDiv-title-basic-1" id="wheelnav-wheelDiv-title-1" transform="matrix(0.7071,-0.7071,0.7071,0.7071,8.7932,303.3224)" stroke-width="1.0360904852357105"><tspan dy="3.1620966503148225" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Multiformer II</tspan></text> so as you can see, there is a tspan element inside the text element and I am using <br> the css style sheet to give it a specific style like this: [class|=wheelnav-wheelDiv-title-basic]>tspan { fill: rgb(255, 255, 255); stroke: none; font-size: 100%; font-family: Lato; } and it works fine, but!! I want to change the style of the tspan while the programm is running<br> I mean with JS, I#ve tried the following: for(let i=0;i<3;i++){ let element_class = 'wheelnav-wheelDiv-title-basic-'+i; let element = document.getElementsByClassName(element_class).item(0); console.log(element); } but it gives me that the HTMLCollection is empty (null), so there is no children.<br> pls guys what should I do?<br> thanks in advance!!
0debug
[c#]Find dublicates in array : int[] array = { 10, 5, 10, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 11, 12, 12 }; for (int i = 0; i < array.Length; i++) { int count = 0; for (int j = 0; j < array.Length; j++) { if (array[i] == array[j]) { count = count + 1; } } Console.WriteLine(array[i] + " repeats " + count + " times"); } Console.ReadKey(); [Output][1] [1]: http://i.stack.imgur.com/vH1wi.jpg I don't want to use LINQ! My question is, how to print results only once. For example: 10 repeats 2 times 5 repeats 3 times 2 repeats 2 times ... Thanks.
0debug
ms-dos batch file - add text to beginning of first line and different text to beginning of all subsequent lines in file : source file contents (csv): 430,081216,081216,131231231231,,'',8686866,'Shamrock',, 1, ,5,,'',, ,01234567,32.50, 2,-,3,,'',, ,382847,25.92, 3, ,5,,'',, ,98765430,32.89, target file needs to be (csv): H,430,081216,081216,131231231231,,'',8686866,'Shamrock',, D,1, ,5,,'',, ,01234567,32.50, D,2,-,3,,'',, ,382847,25.92, D,3, ,5,,'',, ,98765430,32.89, I need to add an "H," to the beginning of the first line in the file, and a "D," to the beginning of all subsequent lines in the file, and save off as another file name. I don't know the best way to do this. I'm a newbie at this and would appreciate any help you can provide.
0debug
Order of regular expression operator (..|.. ... ..|..) : <p>What is the order of priority of expressions in <code>(..|. .. .|..)</code> operator - left to right, right to left or something else?</p>
0debug
C# - Display Files in a Folder on Button Click : <p>I am using Microsoft Visual Studio and i have a WPF project where i would like to be able to click a button and it displays all the .txt files in a specified folder.</p> <p>Is it possible to display the text files that are in the folder in a list?</p> <p>Any help appreciated.</p>
0debug
void nbd_client_session_attach_aio_context(NbdClientSession *client, AioContext *new_context) { aio_set_fd_handler(new_context, client->sock, nbd_reply_ready, NULL, client); }
1threat
Does the "static" keyword in these examples make a difference? : <p>I just realised I made a class member static unnecessarily. I wondered whether it made sense, or what the difference is between them. So I have:</p> <pre><code>struct Log { int a; std::string text; }; struct GUI { GUI() = delete; static void doSomething() {} static inline int a; static inline Foo fooObj; }; </code></pre> <p>or</p> <pre><code>struct GUI2 { GUI2() = delete; static void doSomething() {} int a; Foo fooObj; }; </code></pre> <p>So you can see that this GUI class is always going to be accessed with the scope operator GUI:: instead of the dot member operator, I won't be creating any instances of it, it's completely static. So the int and the Foo object in the two GUI classes either have the "static" keyword or not. In the case where the GUI classes won't be instantiated I don't believe this will make a difference. As a matter of best practice is it better to leave the static keyword out? Also, what if any difference is there between the two? I just noticed I think it makes no difference in my case.</p>
0debug
Signal/Method for every executed sql statement : <p>According to this 12 years old issue, django does not support a signal for every executed sql statement: <a href="https://code.djangoproject.com/ticket/5415" rel="noreferrer">https://code.djangoproject.com/ticket/5415</a></p> <p>I need this in a production environment where debug=False.</p> <p>This means overwriting connection.queries does not work.</p> <p>Is there a way to run some custom code after each sql statement (even if debug=False)?</p>
0debug
void ff_put_h264_qpel4_mc30_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hz_qrt_4w_msa(src - 2, stride, dst, stride, 4, 1); }
1threat
Visual C# Windows form Application dont know how to complete this question. : When squirrels get together for a party they like to eat acorns. A squirrel party is successful when the number of acorns is between 40 and 60, inclusive, unless it is the weekend, in which case there is no upper limit on the number of acorns. Write a program which will find out when the party is and how many acorns there are. Return “Good Party” if the party is within the rules or “Terrible Party” if they have the wrong number of acorns. I have done the part of the number of acorns but struggling in the weekend part also iam new to this This is my code { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int acorns = int.Parse(textBox1.Text); if (acorns >= 40 && acorns <= 60) { MessageBox.Show("Good Party"); } else { MessageBox.Show("Terrible Party"); } } } }
0debug
how to hide the dropdown box while entering value in the textarea : <table> NOTES OF A POST MORTEM EXAMINATION ON THE BODY OF A<br> <select name="select86" id="travel_arriveVia" onchange='CheckColors86(this.value);'> <option>Select</option> <option value="Cattle">Cattle</option> <option value="Buffalo">Buffalo</option> <option value="Horse">Horse</option> <option value="Camel">Camel</option> <option value="Dog">Dog</option> <option value="Sheep">Sheep</option> <option value="Pig">Pig</option> <option value="Goat">Goat</option> <option value="Deer">Deer</option> <option value="Others">Others</option> </select> <tr> <td></td><td></td><td></td> <td> <textarea rows="3" cols="25" name="div86" id="color86" style='display:none'></textarea> </td> </table> CSS: function CheckColors86(val) { var element=document.getElementById('color86'); if(val=='Others') element.style.display='block'; else element.style.display='none'; }
0debug
void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp) { SocketAddressLegacy *saddr = unix_build_address(path); socket_start_outgoing_migration(s, saddr, errp); }
1threat
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
static int decode_cabac_mb_ref( H264Context *h, int list, int n ) { int refa = h->ref_cache[list][scan8[n] - 1]; int refb = h->ref_cache[list][scan8[n] - 8]; int ref = 0; int ctx = 0; if( h->slice_type_nos == FF_B_TYPE) { if( refa > 0 && !h->direct_cache[scan8[n] - 1] ) ctx++; if( refb > 0 && !h->direct_cache[scan8[n] - 8] ) ctx += 2; } else { if( refa > 0 ) ctx++; if( refb > 0 ) ctx += 2; } while( get_cabac( &h->cabac, &h->cabac_state[54+ctx] ) ) { ref++; if( ctx < 4 ) ctx = 4; else ctx = 5; if(ref >= 32 ){ av_log(h->s.avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_ref\n"); return 0; } } return ref; }
1threat