problem
stringlengths
26
131k
labels
class label
2 classes
static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash, uint32_t slb_pshift, bool secondary, target_ulong ptem, ppc_hash_pte64_t *pte) { CPUPPCState *env = &cpu->env; int i; uint64_t token; target_ulong pte0, pte1; target_ulong pte_index; pte_index = (hash & env->htab_mask) * HPTES_PER_GROUP; token = ppc_hash64_start_access(cpu, pte_index); if (!token) { return -1; } for (i = 0; i < HPTES_PER_GROUP; i++) { pte0 = ppc_hash64_load_hpte0(cpu, token, i); pte1 = ppc_hash64_load_hpte1(cpu, token, i); if ((pte0 & HPTE64_V_VALID) && (secondary == !!(pte0 & HPTE64_V_SECONDARY)) && HPTE64_V_COMPARE(pte0, ptem)) { uint32_t pshift = ppc_hash64_pte_size_decode(pte1, slb_pshift); if (pshift == 0) { continue; } pte->pte0 = pte0; pte->pte1 = pte1; ppc_hash64_stop_access(cpu, token); return (pte_index + i) * HASH_PTE_SIZE_64; } } ppc_hash64_stop_access(cpu, token); return -1; }
1threat
Android list view Base adapter getView fire multiple times? : <p><strong>This is my XML</strong> </p> <pre><code>&lt;RelativeLayout android:id="@+id/preview_header" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/socialbottom" android:padding="10dp"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Preview" android:textColor="@color/white" android:textStyle="bold" /&gt; &lt;ImageButton android:id="@+id/close_preview_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:background="@drawable/close_btn" /&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/empty_view" android:layout_below="@+id/preview_header"&gt; &lt;ListView android:id="@+id/preview_dialog_list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:divider="@android:color/transparent" android:dividerHeight="8dp" android:scrollbars="none"&gt;&lt;/ListView&gt; &lt;/RelativeLayout&gt; &lt;View android:id="@+id/empty_view" style="@style/Space" android:layout_width="match_parent" android:layout_above="@+id/preview_add_more_btn"&gt;&lt;/View&gt; &lt;Button android:id="@+id/preview_add_more_btn" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/empty_view1" android:background="@color/content_text" android:drawableLeft="@drawable/plus_icon" android:drawablePadding="50dp" android:gravity="center_horizontal" android:padding="8dp" android:paddingLeft="300dp" android:text="@string/add_more" android:textColor="@color/white" /&gt; &lt;View android:id="@+id/empty_view1" style="@style/Space" android:layout_width="match_parent" android:layout_above="@+id/footer_preview"&gt;&lt;/View&gt; &lt;RelativeLayout android:id="@+id/footer_preview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical"&gt; &lt;EditText android:id="@+id/preview_input_timeline" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentStart="true" android:background="@color/acticty_textbox" android:hint="What&amp;apos;s up, admin?" android:inputType="textMultiLine" android:padding="8dp" /&gt; &lt;Button android:id="@+id/preview_post_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@+id/preview_input_timeline" android:layout_centerHorizontal="true" android:layout_gravity="center_horizontal" android:background="@drawable/savebox" android:padding="8dp" android:text="Post" android:textAllCaps="true" android:textColor="@color/white" android:textStyle="bold" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p></p> <p><strong>This is JAVA</strong></p> <pre><code> public View getView(int position, View convertView, ViewGroup parent) { convertView = mInflater.inflate(R.layout.preview_list_view, null); ImageButton removeBtn = (ImageButton) convertView.findViewById(R.id.remove_preview); ImageView imageView = (ImageView) convertView.findViewById(R.id.preview_image); VideoView videoView = (VideoView) convertView.findViewById(R.id.preview_video); Log.e("video sizzzessssssss", String.valueOf(imagesList.size())); if (SocialActivity.MEDIA_TYPE_IMAGE == previewType) { videoView.setVisibility(View.INVISIBLE); imageView.setVisibility(View.VISIBLE); String path = imagesList.get(position); File imgFile = new File(path); if (imgFile.exists()) { // Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); // imageView.setImageBitmap(myBitmap); Bitmap d = new BitmapDrawable(context.getResources(), imgFile.getAbsolutePath()).getBitmap(); int nh = (int) (d.getHeight() * (512.0 / d.getWidth())); Bitmap scaled = Bitmap.createScaledBitmap(d, 512, nh, true); imageView.setImageBitmap(scaled); } } else { imageView.setVisibility(View.INVISIBLE); videoView.setVisibility(View.VISIBLE); videoView.setVideoPath(imagesList.get(position)); MediaController mediaControls = new MediaController(SocialActivity.socialActivity); videoView.setMediaController(mediaControls); videoView.start(); videoView.pause(); Log.e("path video", imagesList.get(position)); } removeBtn.setOnClickListener(new ListCustomClickEvents(callback, position)); return convertView; } </code></pre>
0debug
uint64_t helper_mullv (uint64_t op1, uint64_t op2) { int64_t res = (int64_t)op1 * (int64_t)op2; if (unlikely((int32_t)res != res)) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return (int64_t)((int32_t)res); }
1threat
Scala - programming a deck of cards : <p>so i have a task to make a deck of cards using scala. Im good at object oriented programming and so i made this in a few minutes. Now its time for me to learn functional programming. Oh boy.. Where do i begin with this? How do i even construct these cards? I was thinking maybe i shouls have 3 parallel arrays of information? For specific card id, face and suit? I can use enumerators for values but how do i actually initialize these arrays? Currently im stuck at using arrays. Maybe i should make a list? If so, how would i initialize them as well? -Thank you!!</p>
0debug
jQuery $('#form').submit() doesn't do anything : <p>I have a rather basic form (using the POST method) that I want to submit when the user clicks on a link (outside said form). I also have a submit button in the form, which works perfectly, so it's not a problem with the form per se.</p> <p>Basically, what I have is (simplified, obviously):</p> <p>HTML</p> <pre><code>&lt;form method="post" id="searchForm" action="[absolute https URL]"&gt; &lt;!-- (some text fields, checkboxes, select elms, hidden fields, a submit button) --&gt; &lt;/form&gt; &lt;a href="#" class="close"&gt;Confirm&lt;/a&gt; </code></pre> <p>JS</p> <pre><code>} else if ($(e.target).is('a.close')) { // do some stuff (&lt;- this works) // ... // then submit form $('#searchForm').submit(); // &lt;- no effect // $('#searchForm').trigger('submit'); // also no effect // document.forms['searchForm'].submit(); // still nothing console.log($('#searchForm')); // &lt;- this works } </code></pre> <p>My problem is: the .submit(); line doesn't seem to do anything. The form isn't submitted (the page doesn't even reload), and no error appear in the browser console either. I know the code is triggered when clicking the link because of the console.log inside it (which also confirms that the form element is found (length 1)).</p> <p>There's no other form on the page, and no other element with the id "searchForm". As far as I can tell, no event handler is bound to the form element.</p> <p>What am I missing? What should I check for?</p>
0debug
Ruby Simple method output : 139/5000 I want to print the table area entirely in one form, the bottom line in the above, but is this method a very simple and simple method? down vote area = find_by_id('SonDakika')`enter code here` p area.all('tr')[0].text`enter code here` p area.all('tr')[1].text`enter code here` p area.all('tr')[2].text`enter code here` p area.all('tr')[3].text`enter code here` p area.all('tr')[4].text`enter code here` p area.all('tr')[100].text`enter code here` I have a simple method?
0debug
Send SMS with AWS Javascript SDK : <p>I want to send an SMS with the AWS javascript sdk with a verification code.</p> <pre><code>var AWS = require('aws-sdk'); AWS.config.region = 'us-east-1'; var sns = new AWS.SNS(); var params = { Message: 'this is a test message', MessageStructure: 'string', PhoneNumber: '+12346759845' }; sns.publish(params, function(err, data) { if (err) console.log(err, err.stack); // an error occurred else console.log(data); // successful response }); </code></pre> <p>I keep getting "Unexpected key \'PhoneNumber\' found in params".</p> <p>I have followed the examples in the documentation and it seems what I have is valid as far as I can tell. Apparently, I do not need to create a topic to send individual text messages.</p>
0debug
How to trigger a Google Apps Script once an email get in the inbox? : <p>I have created a Google Apps Script that checks if an email has an attachment then send it to another email address.</p> <p>It's working fine, but I would like to create a trigger that would launch the script as soon as a new email arrives in the inbox.</p> <p>I have been able to create a trigger that launch the script every hour, but it's not what I want</p>
0debug
vu_message_read(VuDev *dev, int conn_fd, VhostUserMsg *vmsg) { char control[CMSG_SPACE(VHOST_MEMORY_MAX_NREGIONS * sizeof(int))] = { }; struct iovec iov = { .iov_base = (char *)vmsg, .iov_len = VHOST_USER_HDR_SIZE, }; struct msghdr msg = { .msg_iov = &iov, .msg_iovlen = 1, .msg_control = control, .msg_controllen = sizeof(control), }; size_t fd_size; struct cmsghdr *cmsg; int rc; do { rc = recvmsg(conn_fd, &msg, 0); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); if (rc <= 0) { vu_panic(dev, "Error while recvmsg: %s", strerror(errno)); return false; } vmsg->fd_num = 0; for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { fd_size = cmsg->cmsg_len - CMSG_LEN(0); vmsg->fd_num = fd_size / sizeof(int); memcpy(vmsg->fds, CMSG_DATA(cmsg), fd_size); break; } } if (vmsg->size > sizeof(vmsg->payload)) { vu_panic(dev, "Error: too big message request: %d, size: vmsg->size: %u, " "while sizeof(vmsg->payload) = %zu\n", vmsg->request, vmsg->size, sizeof(vmsg->payload)); goto fail; } if (vmsg->size) { do { rc = read(conn_fd, &vmsg->payload, vmsg->size); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); if (rc <= 0) { vu_panic(dev, "Error while reading: %s", strerror(errno)); goto fail; } assert(rc == vmsg->size); } return true; fail: vmsg_close_fds(vmsg); return false; }
1threat
Removing black background and make transparent from grabcut output in python open cv : <p>I have been trying to remove the black background from the grabcut output using python opencv. </p> <pre><code>import numpy as np import cv2 img = cv2.imread(r'myfile_1.png') mask = np.zeros(img.shape[:2],np.uint8) bgdModel = np.zeros((1,65),np.float64) fgdModel = np.zeros((1,65),np.float64) rect = (1,1,665,344) cv2.grabCut(img,mask,rect,bgdModel,fgdModel,5,cv2.GC_INIT_WITH_RECT) mask2 = np.where((mask==2)|(mask==0),0,1).astype('uint8') img = img*mask2[:,:,np.newaxis] cv2.imshow('img',img) cv2.imwrite('img.png',img) cv2.waitKey(0) cv2.destroyAllWindows() </code></pre> <p>Above code I had written to save the grabcut output. Please suggest, How I can remove the black background and make it transparent?</p> <p><a href="https://i.stack.imgur.com/M4rgG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/M4rgG.png" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/2lAK2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2lAK2.png" alt="enter image description here"></a></p>
0debug
Unable to find testhost.dll. Please publish your test project and retry : <p>I have a simple dotnet core class library with a single XUnit test method:</p> <pre><code>TestLib.csproj: &lt;Project Sdk="Microsoft.NET.Sdk"&gt; &lt;PropertyGroup&gt; &lt;TargetFramework&gt;netstandard2.0&lt;/TargetFramework&gt; &lt;/PropertyGroup&gt; &lt;ItemGroup&gt; &lt;PackageReference Include="Microsoft.NET.Test.SDK" Version="15.9.0" /&gt; &lt;PackageReference Include="xunit" Version="2.4.1" /&gt; &lt;PackageReference Include="xunit.runner.console" Version="2.4.1"&gt; &lt;IncludeAssets&gt;runtime; build; native; contentfiles; analyzers&lt;/IncludeAssets&gt; &lt;PrivateAssets&gt;all&lt;/PrivateAssets&gt; &lt;/PackageReference&gt; &lt;PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"&gt; &lt;IncludeAssets&gt;runtime; build; native; contentfiles; analyzers&lt;/IncludeAssets&gt; &lt;PrivateAssets&gt;all&lt;/PrivateAssets&gt; &lt;/PackageReference&gt; &lt;PackageReference Include="xunit.runners" Version="2.0.0" /&gt; &lt;/ItemGroup&gt; &lt;/Project&gt; BasicTest.cs: using Xunit; namespace TestLib { public class BasicTest { [Fact(DisplayName = "Basic unit test")] [Trait("Category", "unit")] public void TestStringHelper() { var sut = "sut"; var verify = "sut"; Assert.Equal(sut, verify); } } } </code></pre> <p>If I enter the project on the CLI and type <code>dotnet build</code> the project builds. If I type <code>dotnet test</code> I get this:</p> <pre><code>C:\git\Testing\TestLib&gt; dotnet test C:\git\Testing\TestLib\TestLib.csproj : warning NU1701: Package 'xunit.runner.visualstudio 2.4.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. Build started, please wait... C:\git\Testing\TestLib\TestLib.csproj : warning NU1701: Package 'xunit.runner.visualstudio 2.4.1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. Build completed. Test run for C:\git\Testing\TestLib\bin\Debug\netstandard2.0\TestLib.dll(.NETStandard,Version=v2.0) Microsoft (R) Test Execution Command Line Tool Version 16.0.0-preview-20181205-02 Copyright (c) Microsoft Corporation. All rights reserved. Starting test execution, please wait... Unable to find C:\git\Testing\TestLib\bin\Debug\netstandard2.0\testhost.dll. Please publish your test project and retry. Test Run Aborted. </code></pre> <p>What do I need to change to get the test to run?</p> <p>If it helps, VS Code is not displaying the tests in its test explorer, either.</p>
0debug
static void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting) { vs->read_handler = func; vs->read_handler_expect = expecting; }
1threat
How to align rows in matplotlib legend with 2 columns : <p>I have an issue where some mathtext formatting is making some labels take up more vertical space than others, which causes them to not line up when placed in two columns in the legend. This is particularly important because the rows are also used to indicate related data. </p> <p>Here is an example:</p> <pre><code>import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.mathtext as mathtext mpl.rc("font", family="Times New Roman",weight='normal') plt.rcParams.update({'mathtext.default': 'regular' }) plt.plot(1,1, label='A') plt.plot(2,2, label='B') plt.plot(3,3, label='C') plt.plot(4,4,label='$A_{x}^{y}$') plt.plot(5,5,label='$B_{x}^{y}$') plt.plot(6,6,label='$C_{x}^{y}$') plt.legend(fontsize='xx-large', ncol=2) plt.show() </code></pre> <p>This generates a figure like so: <a href="https://i.stack.imgur.com/Rmp2x.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Rmp2x.png" alt="enter image description here"></a></p> <p>For a while, I was able to "fake it" a bit by adding some empty subscripts and superscripts, however this only works when the plot is exported to pdf. It does not appear to work when exporting to png. How can I spread out the first column of labels so that they line up with the second column? </p>
0debug
Typescript and React setting initial state with empty typed array : <p>Say I have the following snippet:</p> <pre><code>interface State { alarms: Alarm[]; } export default class Alarms extends React.Component&lt;{}, State&gt; { state = { alarms: [] }; </code></pre> <p>Since I am trying to set <code>alarms: []</code> Typescript doesn't like it, as <code>[] != Alarm[]</code>. I found that I can use <code>alarms: new Array&lt;Alarm&gt;()</code> which initializes an empty typed array, however I don't really like this syntax - is there an easier/better approach?</p>
0debug
Writing HTML's Input Tag's Value To A File using php Script : <p>is there any way to write the values, passed by the user to a file using a php script. i have searched a lot around the web to find the examples for writing string to file using php but what they were doing was not working in scenario. actually they were writing the values of php variables to a file but in my case i want to write values passed by the user to the file using php. also problem arises is that i want to get the value from the HTML INPUT tag and maybe <strong>CONVERT</strong> it to a php string variable. finally, is there <strong>any</strong> way to get the value from the HTML INPUT tag and write it to file?</p>
0debug
Reassign unique_ptr object with make_unique statements - Memory leak? : <p>I don't get what following statement would do (specially second line)?</p> <pre><code>auto buff = std::make_unique&lt;int[]&gt;(128); buff = std::make_unique&lt;int[]&gt;(512); </code></pre> <p>Will the second call to <code>make_unique</code> followed by assignment operator will de-allocate memory allocated by first call, or will there be memory leak? Must I have to use <code>buff.reset(new int[512]);</code> ?</p> <p>I've debugged it, but didn't find any <code>operator=</code> being called, nor any destructor be invoked (by <code>unique_ptr</code>).</p>
0debug
int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, const uint8_t *buf, int len) { unsigned int ssrc, h; int payload_type, seq, ret; AVStream *st; uint32_t timestamp; int rv= 0; if (!buf) { if(s->st && s->parse_packet) { timestamp= 0; rv= s->parse_packet(s, pkt, &timestamp, NULL, 0); finalize_packet(s, pkt, timestamp); return rv; } else { if (s->read_buf_index >= s->read_buf_size) return -1; ret = mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index, s->read_buf_size - s->read_buf_index); if (ret < 0) return -1; s->read_buf_index += ret; if (s->read_buf_index < s->read_buf_size) return 1; else return 0; } } if (len < 12) return -1; if ((buf[0] & 0xc0) != (RTP_VERSION << 6)) return -1; if (buf[1] >= 200 && buf[1] <= 204) { rtcp_parse_packet(s, buf, len); return -1; } payload_type = buf[1] & 0x7f; seq = (buf[2] << 8) | buf[3]; timestamp = decode_be32(buf + 4); ssrc = decode_be32(buf + 8); s->ssrc = ssrc; if (s->payload_type != payload_type) return -1; st = s->st; #if defined(DEBUG) || 1 if (seq != ((s->seq + 1) & 0xffff)) { av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n", payload_type, seq, ((s->seq + 1) & 0xffff)); } #endif s->seq = seq; len -= 12; buf += 12; if (!st) { ret = mpegts_parse_packet(s->ts, pkt, buf, len); if (ret < 0) return -1; if (ret < len) { s->read_buf_size = len - ret; memcpy(s->buf, buf + ret, s->read_buf_size); s->read_buf_index = 0; return 1; } } else { switch(st->codec->codec_id) { case CODEC_ID_MP2: if (len <= 4) return -1; h = decode_be32(buf); len -= 4; buf += 4; av_new_packet(pkt, len); memcpy(pkt->data, buf, len); break; case CODEC_ID_MPEG1VIDEO: if (len <= 4) return -1; h = decode_be32(buf); buf += 4; len -= 4; if (h & (1 << 26)) { if (len <= 4) return -1; buf += 4; len -= 4; } av_new_packet(pkt, len); memcpy(pkt->data, buf, len); break; case CODEC_ID_MPEG4AAC: if (rtp_parse_mp4_au(s, buf)) return -1; { rtp_payload_data_t *infos = s->rtp_payload_data; if (infos == NULL) return -1; buf += infos->au_headers_length_bytes + 2; len -= infos->au_headers_length_bytes + 2; av_new_packet(pkt, infos->au_headers[0].size); memcpy(pkt->data, buf, infos->au_headers[0].size); buf += infos->au_headers[0].size; len -= infos->au_headers[0].size; } s->read_buf_size = len; s->buf_ptr = buf; rv= 0; break; default: if(s->parse_packet) { rv= s->parse_packet(s, pkt, &timestamp, buf, len); } else { av_new_packet(pkt, len); memcpy(pkt->data, buf, len); } break; } finalize_packet(s, pkt, timestamp); } return rv; }
1threat
static inline int64_t get_sector_offset(BlockDriverState *bs, int64_t sector_num, int write) { BDRVVPCState *s = bs->opaque; uint64_t offset = sector_num * 512; uint64_t bitmap_offset, block_offset; uint32_t pagetable_index, pageentry_index; pagetable_index = offset / s->block_size; pageentry_index = (offset % s->block_size) / 512; if (pagetable_index >= s->max_table_entries || s->pagetable[pagetable_index] == 0xffffffff) return -1; bitmap_offset = 512 * (uint64_t) s->pagetable[pagetable_index]; block_offset = bitmap_offset + s->bitmap_size + (512 * pageentry_index); if (write && (s->last_bitmap_offset != bitmap_offset)) { uint8_t bitmap[s->bitmap_size]; s->last_bitmap_offset = bitmap_offset; memset(bitmap, 0xff, s->bitmap_size); bdrv_pwrite(bs->file, bitmap_offset, bitmap, s->bitmap_size); } #if 0 #ifdef CACHE if (bitmap_offset != s->last_bitmap) { lseek(s->fd, bitmap_offset, SEEK_SET); s->last_bitmap = bitmap_offset; read(s->fd, s->pageentry_u8, 512); for (i = 0; i < 128; i++) be32_to_cpus(&s->pageentry_u32[i]); } if ((s->pageentry_u8[pageentry_index / 8] >> (pageentry_index % 8)) & 1) return -1; #else lseek(s->fd, bitmap_offset + (pageentry_index / 8), SEEK_SET); read(s->fd, &bitmap_entry, 1); if ((bitmap_entry >> (pageentry_index % 8)) & 1) return -1; #endif #endif return block_offset; }
1threat
How to split a screen into different parts in PHP? : I have 3 strings in PHP which contains a list of test input for a function with two parameters. I want to parse the strings and get the individual parameter values. example: "a,b" => "a", "b" "/"string_param1/", /"string_param2/"" => "string_param1", "string_param2" "[list,1], [list,2]" => "[list,1]", "[list,2]"
0debug
How to group invoices by total amount and line number with SQL server 2008 : I have a table look like this: [enter image description here][1] [1]: http://i.stack.imgur.com/j1YkF.jpg I want to auto fill group invoice number if totord accumulation is about 20,000,000 or count distinct invtid maximum is 16. the grouped invoice has to contain all rows of an order or that order will be eliminated. The grouped invoice number will be reset by promdate. Please help me to create a query or a sample SQL code to do it.
0debug
Fix div on scroll : I'm trying to fade in/out and fix the blue div on the left when scrolled relative to the image blocks on the right. http://www.warface.co.uk/#/testing/ pass: squared meta { /*This is the block I'm trying to stick/* background: blue; position: fixed; width: 372px; float: left; z-index: 3; right: 100%; }
0debug
Do I always need to return a value from a redux middleware? : <p>In the examples given in the <a href="http://redux.js.org/docs/advanced/Middleware.html#seven-examples" rel="noreferrer">redux docs</a>, there always seems to be something being returned from middlewares. However, when I call <code>next(action)</code> and return nothing everything seems to work fine.</p> <p>In the <a href="https://github.com/reactjs/redux/blob/master/src/applyMiddleware.js#L30" rel="noreferrer">redux source</a> it appears to be calling <code>dispatch</code> on the returned value of every middleware. </p> <p>This leads me to believe that it provides an optional way to run dispatch after all the middlewares have run.</p> <p>Can someone confirm if we must ALWAYS return a value from a middleware, and if so why?</p>
0debug
serwer linux - Unable to initialize OpenSSL library : I have a problem with run my application on vps server. I have there Ubuntu. On my personal computer I install ubuntu too. On my computer my application runs and work but on server I got this: An unhandled exception occurred at $080C9936 : Exception : Unable to initialize OpenSSL library, please check your OpenSSL installation $080C9936 TLSSLSESSION__CREATESSLCONTEXT, line 503 of ./lnet/lnetssl.pp $080C9B96 TLSSLSESSION__CREATE, line 547 of ./lnet/lnetssl.pp $0804866B TSERWER__CREATE, line 41 of serwer.lpr $08048BC7 main, line 123 of serwer.lpr probably on linux openssl is default installed but I do this: sudo apt-get install openssl Everything install ok and I do: apt-cache search libssl | grep SSL I didnt get any info... Its only error 'configure directory/file dosent exist' Probably I should configure this openssl but I dont know how. Can you help me?
0debug
static av_cold void compute_alpha_vlcs(void) { uint16_t run_code[129], level_code[256]; uint8_t run_bits[129], level_bits[256]; int run, level; for (run = 0; run < 128; run++) { if (!run) { run_code[run] = 0; run_bits[run] = 1; } else if (run <= 4) { run_code[run] = ((run - 1) << 2) | 1; run_bits[run] = 4; } else { run_code[run] = (run << 3) | 7; run_bits[run] = 10; } } run_code[128] = 3; run_bits[128] = 3; INIT_LE_VLC_STATIC(&ff_dc_alpha_run_vlc_le, ALPHA_VLC_BITS, 129, run_bits, 1, 1, run_code, 2, 2, 160); for (level = 0; level < 256; level++) { int8_t signed_level = (int8_t)level; int abs_signed_level = abs(signed_level); int sign = (signed_level < 0) ? 1 : 0; if (abs_signed_level == 1) { level_code[level] = (sign << 1) | 1; level_bits[level] = 2; } else if (abs_signed_level >= 2 && abs_signed_level <= 5) { level_code[level] = ((abs_signed_level - 2) << 3) | (sign << 2) | 2; level_bits[level] = 5; } else { level_code[level] = level << 2; level_bits[level] = 10; } } INIT_LE_VLC_STATIC(&ff_dc_alpha_level_vlc_le, ALPHA_VLC_BITS, 256, level_bits, 1, 1, level_code, 2, 2, 288); }
1threat
canvas.mpl_connect in jupyter notebook : <p>I have the following code in test.py:</p> <pre><code>fig = plt.figure() ax = fig.add_subplot(111) ax.plot(np.random.rand(10)) def onclick(event): print('button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % (event.button, event.x, event.y, event.xdata, event.ydata)) cid = fig.canvas.mpl_connect('button_press_event', onclick) </code></pre> <p>when i run test.py in the command line by "python test.py", 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f' gets printed as i click the plot</p> <p>however, the results are not printed in jupyter notebook.</p> <p>how to fix it?</p> <p>thanks in advance!</p>
0debug
Getting error: Uncaught Syntax Error: Unexpected token : <p>I need to add class to all the links that have "href=login". And i tried to use this javascript</p> <pre><code>jQuery(document).ready(function($){ $(.pageWidth).find('a[href*="/login/"]').addClass('OverlayTrigger');}) </code></pre> <p>Unfortunately, i tried so many times and it always getting this error</p> <blockquote> <p>Uncaught Syntax Error: Unexpected token</p> </blockquote> <p>How can i fix this? What's the problem here? Thank you!</p>
0debug
Error message is (#12) bio field is deprecated for versions v2.8 and higher : <p>I used version 2.0.3.RELEASE of spring-social-facebook and Facebook app api v2.8. I called Facebook login but returned this message. "(#12) bio field is deprecated for versions v2.8 and higher" How can i fix this?</p>
0debug
safari is not play video, how to play aal browser play video : safari browser is not play video, my code below youtuve video is not play, mp4 not play my site http://creativecartels.biz/demo/forget-reg/index.html http://creativecartels.biz/demo/forget-reg/index.html <div class="col-lg-5 col-md-6 col-sm-8 col-xs-12 pad-left"> <div class="videoWrapper"> <div class="bggg" id="uni_bggg"><img src="images/video-mage.png" alt=""></div> <div class="video-paly-button" id="uni_video_paly_button"> <button onclick="document.getElementById('video-bg').play();document.getElementById('uni_video_paly_button').remove();document.getElementById('uni_bggg').remove();"><i class="fa fa-play"></i></button> </div> <video controls id="video-bg"> <source src="images/Forget reg Tv Ad long.mp4" type="video/mp4"></source> Your broswer does not support the video tag </video> </div> </div> please Send your code and css .....`
0debug
PostgreSQL regular expression capture group in select : <p>How can the matched regular expression be returned from an SQL select? I tried using <code>REGEXP_EXTRACT</code> with no luck (function not available). What I've done <em>that does work</em> is this:</p> <pre><code>SELECT column ~ '^stuff.*$' FROM table; </code></pre> <p>but this gives me a list of true / false. I want to know what is extracted in each case.</p>
0debug
How to add a delay in Javascript : <p>I need to add a delay to some JavaScript code without importing anything. How do I do it?</p> <p>I need this for a unity project I am working on. It's like Minecraft but better and I need to add block break times. I have had a look on other websites but got nothing.</p> <p>I want the code to wait the delay time before proceeding on to the next task. I am quite new to JavaScript too.</p>
0debug
static int decode_group3_1d_line(AVCodecContext *avctx, GetBitContext *gb, int pix_left, int *runs) { int mode = 0, run = 0; unsigned int t; for(;;){ t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2); run += t; if(t < 64){ pix_left -= run; *runs++ = run; if(pix_left <= 0){ if(!pix_left) break; runs[-1] = 0; av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } run = 0; mode = !mode; }else if((int)t == -1){ av_log(avctx, AV_LOG_ERROR, "Incorrect code\n"); return -1; } } *runs++ = 0; return 0; }
1threat
How can I get pip to list the repositories it's using? : <p>I'm trying to get a codebase running on my machine, and pip isn't finding some of the dependencies. It seems to find them on another machine, so I'd like to see which repos pip is using on the two machines so I can compare.</p> <p>How can I do this?</p>
0debug
How to put a multi-row statement string into a variable? : <p>I want to a store a long string (specifically a SQL query) into a variable, which I'd like to have written on more row for a better readability.</p> <p>I'm using Jupyter notebook on Python 3.5 (Anaconda) if that's important.</p> <p>I've tried:</p> <pre><code># SQL query query = " SELECT Sued ,ApplicationNumber_Primary --,ApprovedLoanAmount, ApprovedLoanDuration, ApprovedMonthlyPayment, ,RequiredLoanDuration, RequiredMonthlyPaymentAmount, RequiredPaidAmount, RequiredCoefficientK1 ,ClientFreeSources, ClientTotalIncome, ClientNetIncome, ClientTotalExpenditures ,ClientAgeToApplicationDate, ClientFamilyStatusID, ClientEmploymentDuration, CreditExposure ,CalendarQuarter, MonthOfYear, WeekOfYear, DayOfMonth, DayOfWeek, RegionID, DistrictID, ZIPcodeID FROM dbo.vRisk GO " </code></pre> <p>...which does not store the string into the variable, as I'd like.</p> <p>Help would be appreciated.</p>
0debug
Workaround for Chrome 53 printing table header twice on 2nd and later pages? : <p>Users of my website need to be able to print web pages consisting of content on the first printed page followed by a table on the second page. A stripped down version is (jsFiddle at <a href="https://jsfiddle.net/jaydeedub/n3qhvtvx/25/">https://jsfiddle.net/jaydeedub/n3qhvtvx/25/</a> ):</p> <p>HTML:</p> <pre><code>&lt;body&gt; &lt;button class="button" onclick="window.print()"&gt;Print Me&lt;/button&gt; &lt;div class="page1"&gt; This is the page 1 content. Blah, blah, blah. &lt;/div&gt; &lt;table class="table"&gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt;Page 2 table header prints twice&lt;/td&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;Page 2 table body&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;tfoot&gt; &lt;tr&gt; &lt;td&gt;Page 2 table footer&lt;/td&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;/table&gt; &lt;/body&gt; </code></pre> <p>CSS:</p> <pre><code>@media print { div.page1 { page-break-after: always; } } .table { border-collapse: collapse; margin: 16px; } .table&gt;thead&gt;tr&gt;td, .table&gt;tbody&gt;tr&gt;td, .table&gt;tfoot&gt;tr&gt;td { border: 1px solid black; } .button { width: 6em; height: 2em; margin: 10px 0px; } </code></pre> <p>This prints as expected in Chrome 52 on Chrome OS, but in Chrome 53 on Windows 7 Home and Chrome 53 on Chrome OS, the table header prints twice on the second page: once by itself without the top margin, and once with the top margin, followed by the rest of the table. It used to print normally in Windows in an earlier version of Chrome, but I do not know if that was Chrome 52 (definitely within the last few versions). It also prints as expected in Firefox.</p> <p>I found one workaround, which is to put an empty 'thead' element before the real 'thead' element, but this solution is very kludgy and makes me uncomfortable.</p> <p>Is there a more robust workaround that would be likely not to have side-effects across browsers?</p>
0debug
How to know type of a linker whether it's a static/dynamic in c plus plus : How can we know that which type of linker(static/dynamic) our system is using? Is it decided on type of library(static/dynamic) we have used or is there any other thing?
0debug
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter){ SwsContext *c; int i; int usesFilter; SwsFilter dummyFilter= {NULL, NULL, NULL, NULL}; #ifdef ARCH_X86 if(gCpuCaps.hasMMX) asm volatile("emms\n\t"::: "memory"); #endif if(swScale==NULL) globalInit(); if(srcFormat==IMGFMT_IYUV) srcFormat=IMGFMT_I420; if(srcFormat==IMGFMT_Y8) srcFormat=IMGFMT_Y800; if(dstFormat==IMGFMT_Y8) dstFormat=IMGFMT_Y800; if(!isSupportedIn(srcFormat)) { fprintf(stderr, "swScaler: %s is not supported as input format\n", vo_format_name(srcFormat)); return NULL; } if(!isSupportedOut(dstFormat)) { fprintf(stderr, "swScaler: %s is not supported as output format\n", vo_format_name(dstFormat)); return NULL; } if(srcW<4 || srcH<1 || dstW<8 || dstH<1) { fprintf(stderr, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n", srcW, srcH, dstW, dstH); return NULL; } if(!dstFilter) dstFilter= &dummyFilter; if(!srcFilter) srcFilter= &dummyFilter; c= memalign(64, sizeof(SwsContext)); memset(c, 0, sizeof(SwsContext)); c->srcW= srcW; c->srcH= srcH; c->dstW= dstW; c->dstH= dstH; c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW; c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH; c->flags= flags; c->dstFormat= dstFormat; c->srcFormat= srcFormat; usesFilter=0; if(dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesFilter=1; if(dstFilter->lumH!=NULL && dstFilter->lumH->length>1) usesFilter=1; if(dstFilter->chrV!=NULL && dstFilter->chrV->length>1) usesFilter=1; if(dstFilter->chrH!=NULL && dstFilter->chrH->length>1) usesFilter=1; if(srcFilter->lumV!=NULL && srcFilter->lumV->length>1) usesFilter=1; if(srcFilter->lumH!=NULL && srcFilter->lumH->length>1) usesFilter=1; if(srcFilter->chrV!=NULL && srcFilter->chrV->length>1) usesFilter=1; if(srcFilter->chrH!=NULL && srcFilter->chrH->length>1) usesFilter=1; if(srcW==dstW && srcH==dstH && !usesFilter) { if(isPlanarYUV(srcFormat) && isBGR(dstFormat)) { #ifdef WORDS_BIGENDIAN if(dstFormat==IMGFMT_BGR32) yuv2rgb_init( dstFormat&0xFF , MODE_BGR); else yuv2rgb_init( dstFormat&0xFF , MODE_RGB); #else yuv2rgb_init( dstFormat&0xFF , MODE_RGB); #endif c->swScale= planarYuvToBgr; if(flags&SWS_PRINT_INFO) printf("SwScaler: using unscaled %s -> %s special converter\n", vo_format_name(srcFormat), vo_format_name(dstFormat)); return c; } if(srcFormat == dstFormat || (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat))) { c->swScale= simpleCopy; if(flags&SWS_PRINT_INFO) printf("SwScaler: using unscaled %s -> %s special converter\n", vo_format_name(srcFormat), vo_format_name(dstFormat)); return c; } if((srcFormat==IMGFMT_BGR32 && dstFormat==IMGFMT_BGR24) ||(srcFormat==IMGFMT_RGB32 && dstFormat==IMGFMT_RGB24)) { c->swScale= bgr32to24Wrapper; if(flags&SWS_PRINT_INFO) printf("SwScaler: using unscaled %s -> %s special converter\n", vo_format_name(srcFormat), vo_format_name(dstFormat)); return c; } if((srcFormat==IMGFMT_BGR24 && dstFormat==IMGFMT_BGR32) ||(srcFormat==IMGFMT_RGB24 && dstFormat==IMGFMT_RGB32)) { c->swScale= bgr24to32Wrapper; if(flags&SWS_PRINT_INFO) printf("SwScaler: using unscaled %s -> %s special converter\n", vo_format_name(srcFormat), vo_format_name(dstFormat)); return c; } if(srcFormat==IMGFMT_BGR15 && dstFormat==IMGFMT_BGR16) { c->swScale= bgr15to16Wrapper; if(flags&SWS_PRINT_INFO) printf("SwScaler: using unscaled %s -> %s special converter\n", vo_format_name(srcFormat), vo_format_name(dstFormat)); return c; } if(srcFormat==IMGFMT_BGR24 && dstFormat==IMGFMT_YV12) { c->swScale= bgr24toyv12Wrapper; if(flags&SWS_PRINT_INFO) printf("SwScaler: using unscaled %s -> %s special converter\n", vo_format_name(srcFormat), vo_format_name(dstFormat)); return c; } } if(cpuCaps.hasMMX2) { c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0; if(!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) { if(flags&SWS_PRINT_INFO) fprintf(stderr, "SwScaler: output Width is not a multiple of 32 -> no MMX2 scaler\n"); } } else c->canMMX2BeUsed=0; if(isHalfChrV(srcFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_V); if(isHalfChrH(srcFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_H_INP); if(isHalfChrH(dstFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_H_INT); if(flags&SWS_FULL_CHR_H_INP) c->chrSrcW= srcW; else c->chrSrcW= (srcW+1)>>1; if(flags&SWS_FULL_CHR_H_INT) c->chrDstW= dstW; else c->chrDstW= (dstW+1)>>1; if(flags&SWS_FULL_CHR_V) c->chrSrcH= srcH; else c->chrSrcH= (srcH+1)>>1; if(isHalfChrV(dstFormat)) c->chrDstH= (dstH+1)>>1; else c->chrDstH= dstH; c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW; c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH; if(flags&SWS_FAST_BILINEAR) { if(c->canMMX2BeUsed) { c->lumXInc+= 20; c->chrXInc+= 20; } else if(cpuCaps.hasMMX) { c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20; c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20; } } { const int filterAlign= cpuCaps.hasMMX ? 4 : 1; initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc, srcW , dstW, filterAlign, 1<<14, flags, srcFilter->lumH, dstFilter->lumH); initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc, (srcW+1)>>1, c->chrDstW, filterAlign, 1<<14, flags, srcFilter->chrH, dstFilter->chrH); #ifdef ARCH_X86 if(c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) { initMMX2HScaler( dstW, c->lumXInc, c->funnyYCode); initMMX2HScaler(c->chrDstW, c->chrXInc, c->funnyUVCode); } #endif } initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc, srcH , dstH, 1, (1<<12)-4, flags, srcFilter->lumV, dstFilter->lumV); initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc, (srcH+1)>>1, c->chrDstH, 1, (1<<12)-4, flags, srcFilter->chrV, dstFilter->chrV); c->vLumBufSize= c->vLumFilterSize; c->vChrBufSize= c->vChrFilterSize; for(i=0; i<dstH; i++) { int chrI= i*c->chrDstH / dstH; int nextSlice= MAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1, ((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)<<1)); nextSlice&= ~1; if(c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice) c->vLumBufSize= nextSlice - c->vLumFilterPos[i ]; if(c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>1)) c->vChrBufSize= (nextSlice>>1) - c->vChrFilterPos[chrI]; } c->lumPixBuf= (int16_t**)memalign(4, c->vLumBufSize*2*sizeof(int16_t*)); c->chrPixBuf= (int16_t**)memalign(4, c->vChrBufSize*2*sizeof(int16_t*)); for(i=0; i<c->vLumBufSize; i++) c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= (uint16_t*)memalign(8, 4000); for(i=0; i<c->vChrBufSize; i++) c->chrPixBuf[i]= c->chrPixBuf[i+c->vChrBufSize]= (uint16_t*)memalign(8, 8000); for(i=0; i<c->vLumBufSize; i++) memset(c->lumPixBuf[i], 0, 4000); for(i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, 8000); ASSERT(c->chrDstH <= dstH) if(cpuCaps.hasMMX) { c->lumMmxFilter= (int16_t*)memalign(8, c->vLumFilterSize* dstH*4*sizeof(int16_t)); c->chrMmxFilter= (int16_t*)memalign(8, c->vChrFilterSize*c->chrDstH*4*sizeof(int16_t)); for(i=0; i<c->vLumFilterSize*dstH; i++) c->lumMmxFilter[4*i]=c->lumMmxFilter[4*i+1]=c->lumMmxFilter[4*i+2]=c->lumMmxFilter[4*i+3]= c->vLumFilter[i]; for(i=0; i<c->vChrFilterSize*c->chrDstH; i++) c->chrMmxFilter[4*i]=c->chrMmxFilter[4*i+1]=c->chrMmxFilter[4*i+2]=c->chrMmxFilter[4*i+3]= c->vChrFilter[i]; } if(flags&SWS_PRINT_INFO) { #ifdef DITHER1XBPP char *dither= " dithered"; #else char *dither= ""; #endif if(flags&SWS_FAST_BILINEAR) fprintf(stderr, "\nSwScaler: FAST_BILINEAR scaler, "); else if(flags&SWS_BILINEAR) fprintf(stderr, "\nSwScaler: BILINEAR scaler, "); else if(flags&SWS_BICUBIC) fprintf(stderr, "\nSwScaler: BICUBIC scaler, "); else if(flags&SWS_X) fprintf(stderr, "\nSwScaler: Experimental scaler, "); else if(flags&SWS_POINT) fprintf(stderr, "\nSwScaler: Nearest Neighbor / POINT scaler, "); else if(flags&SWS_AREA) fprintf(stderr, "\nSwScaler: Area Averageing scaler, "); else fprintf(stderr, "\nSwScaler: ehh flags invalid?! "); if(dstFormat==IMGFMT_BGR15 || dstFormat==IMGFMT_BGR16) fprintf(stderr, "from %s to%s %s ", vo_format_name(srcFormat), dither, vo_format_name(dstFormat)); else fprintf(stderr, "from %s to %s ", vo_format_name(srcFormat), vo_format_name(dstFormat)); if(cpuCaps.hasMMX2) fprintf(stderr, "using MMX2\n"); else if(cpuCaps.has3DNow) fprintf(stderr, "using 3DNOW\n"); else if(cpuCaps.hasMMX) fprintf(stderr, "using MMX\n"); else fprintf(stderr, "using C\n"); } if((flags & SWS_PRINT_INFO) && verbose) { if(cpuCaps.hasMMX) { if(c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR)) printf("SwScaler: using FAST_BILINEAR MMX2 scaler for horizontal scaling\n"); else { if(c->hLumFilterSize==4) printf("SwScaler: using 4-tap MMX scaler for horizontal luminance scaling\n"); else if(c->hLumFilterSize==8) printf("SwScaler: using 8-tap MMX scaler for horizontal luminance scaling\n"); else printf("SwScaler: using n-tap MMX scaler for horizontal luminance scaling\n"); if(c->hChrFilterSize==4) printf("SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling\n"); else if(c->hChrFilterSize==8) printf("SwScaler: using 8-tap MMX scaler for horizontal chrominance scaling\n"); else printf("SwScaler: using n-tap MMX scaler for horizontal chrominance scaling\n"); } } else { #ifdef ARCH_X86 printf("SwScaler: using X86-Asm scaler for horizontal scaling\n"); #else if(flags & SWS_FAST_BILINEAR) printf("SwScaler: using FAST_BILINEAR C scaler for horizontal scaling\n"); else printf("SwScaler: using C scaler for horizontal scaling\n"); #endif } if(isPlanarYUV(dstFormat)) { if(c->vLumFilterSize==1) printf("SwScaler: using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", cpuCaps.hasMMX ? "MMX" : "C"); else printf("SwScaler: using n-tap %s scaler for vertical scaling (YV12 like)\n", cpuCaps.hasMMX ? "MMX" : "C"); } else { if(c->vLumFilterSize==1 && c->vChrFilterSize==2) printf("SwScaler: using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n" "SwScaler: 2-tap scaler for vertical chrominance scaling (BGR)\n",cpuCaps.hasMMX ? "MMX" : "C"); else if(c->vLumFilterSize==2 && c->vChrFilterSize==2) printf("SwScaler: using 2-tap linear %s scaler for vertical scaling (BGR)\n", cpuCaps.hasMMX ? "MMX" : "C"); else printf("SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", cpuCaps.hasMMX ? "MMX" : "C"); } if(dstFormat==IMGFMT_BGR24) printf("SwScaler: using %s YV12->BGR24 Converter\n", cpuCaps.hasMMX2 ? "MMX2" : (cpuCaps.hasMMX ? "MMX" : "C")); else if(dstFormat==IMGFMT_BGR32) printf("SwScaler: using %s YV12->BGR32 Converter\n", cpuCaps.hasMMX ? "MMX" : "C"); else if(dstFormat==IMGFMT_BGR16) printf("SwScaler: using %s YV12->BGR16 Converter\n", cpuCaps.hasMMX ? "MMX" : "C"); else if(dstFormat==IMGFMT_BGR15) printf("SwScaler: using %s YV12->BGR15 Converter\n", cpuCaps.hasMMX ? "MMX" : "C"); printf("SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH); } if((flags & SWS_PRINT_INFO) && verbose>1) { printf("SwScaler:Lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc); printf("SwScaler:Chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc); } c->swScale= swScale; return c; }
1threat
¿Como puedo ordenar de manenara adecuada una lista de elementos en python? : Estoy ordenando una lista de elementos que remplace por nuevos, pero al cambiar las letras por un equivalente en numero y despues ordenarlo, pues me corta el ordenamiento y lo hace en partes. for (i) in range(len(unico)): if unico[i] == 'A': unico[i] = '14' elif unico[i] == 'D': unico[i] = '10' elif unico[i] == 'J': unico[i] = '11' elif unico[i] == 'Q': unico[i] = '12' elif unico[i] == 'K': unico[i] = '13' for (i) in range(len(unico2)): if unico2[i] == 'A': unico2[i] = '14' elif unico2[i] == 'D': unico2[i] = '10' elif unico2[i] == 'J': unico2[i] = '11' elif unico2[i] == 'Q': unico2[i] = '12' elif unico2[i] == 'K': unico2[i] = '13' repetido, repetido2, unico, unico2 = sorted(repetido, reverse=True), sorted(repetido2, reverse=True), sorted(unico, reverse=True), sorted(unico2, reverse=True) print (unico,unico2) Espero esta salida: ['14', '13', '10','8','4','3'] ['14', '13', '12', '10', '7', '6', '5'] pero la salida es: ['8', '4', '3', '14', '13', '10'] ['7', '6', '5', '14', '13', '12', '10']
0debug
static inline void gen_op_eval_fbu(TCGv dst, TCGv src, unsigned int fcc_offset) { gen_mov_reg_FCC0(dst, src, fcc_offset); gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); tcg_gen_and_tl(dst, dst, cpu_tmp0); }
1threat
How can I change attribute value of Html tag ? : I have this HTML code. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <div class="container-fluid"> <div class="block-header"> <h2>SECURITY DASHBOARD</h2> </div> <div id="burayaset"> <!-- Widgets --> <div class="row clearfix"> <div class="col-lg-4 col-md-3 col-sm-6 col-xs-12"> <div class="info-box-4"> <div class="icon"> <i class="material-icons col-blue">remove_from_queue</i> </div> <div class="content"> <div class="text">HOSTS</div> <div id="HostsBar" class="number count-to" data-from="0" data-to="125" data-speed="15" data-fresh-interval="20"></div> </div> </div> </div> <div class="col-lg-4 col-md-3 col-sm-6 col-xs-12"> <div class="info-box-4"> <div class="icon"> <i class="material-icons col-blue-grey">storage</i> </div> <div class="content"> <div class="text">PRODUCTS</div> <div class="number count-to" data-from="0" data-to="257" data-speed="1000" data-fresh-interval="20"></div> </div> </div> </div> <div class="col-lg-4 col-md-3 col-sm-6 col-xs-12"> <div class="info-box-4"> <div class="icon"> <i class="material-icons col-cyan">warning</i> </div> <div class="content"> <div class="text">VULNERABILITIES</div> <div class="number count-to" data-from="0" data-to="1225" data-speed="1000" data-fresh-interval="20"></div> </div> </div> </div> </div> <!-- end snippet --> I want to change count-to value with data that come from backend. How can I do that in Javascript. I tried document.getElementById("HostsBar").setAttribute("data-to", "120"); But it not worked.
0debug
VS2015 pubxml: how to exclude or eliminate the <PublishDatabaseSettings> section : <p>I need to exclude database related settings from the Web Deploy publishing. I tried to delete the section in the pubxml file, but it comes back when I create a deployment package.</p> <p>Is there any way way to exclude database related settings from the Web Deploy publishing?</p>
0debug
void HELPER(cas2w)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) { uint32_t Dc1 = extract32(regs, 9, 3); uint32_t Dc2 = extract32(regs, 6, 3); uint32_t Du1 = extract32(regs, 3, 3); uint32_t Du2 = extract32(regs, 0, 3); int16_t c1 = env->dregs[Dc1]; int16_t c2 = env->dregs[Dc2]; int16_t u1 = env->dregs[Du1]; int16_t u2 = env->dregs[Du2]; int16_t l1, l2; uintptr_t ra = GETPC(); if (parallel_cpus) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } else { l1 = cpu_lduw_data_ra(env, a1, ra); l2 = cpu_lduw_data_ra(env, a2, ra); if (l1 == c1 && l2 == c2) { cpu_stw_data_ra(env, a1, u1, ra); cpu_stw_data_ra(env, a2, u2, ra); } } if (c1 != l1) { env->cc_n = l1; env->cc_v = c1; } else { env->cc_n = l2; env->cc_v = c2; } env->cc_op = CC_OP_CMPW; env->dregs[Dc1] = deposit32(env->dregs[Dc1], 0, 16, l1); env->dregs[Dc2] = deposit32(env->dregs[Dc2], 0, 16, l2); }
1threat
How to add another condition in this functio : so i want to add another condition for another textfield and trying to make this code is more simple func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { if let text = textField.text { if let floatingLabelTextField = textField as? SkyFloatingLabelTextField { if(text.characters.count < 3 || !text.containsString("@")) { floatingLabelTextField.errorMessage = "Invalid email" } else { // The error message will only disappear when we reset it to nil or empty string floatingLabelTextField.errorMessage = "" } } } return true }
0debug
php display confirmation message : I need to get confirmation before proceding. My code is: echo "<SCRIPT> confirm('Are you sure you want to continue') </SCRIPT>"; //press ok should keep on processing the code while cancel not. Currently any button pressed continue. How can I validate what button in the confirmation pop up window pressed?
0debug
static int writev_f(BlockBackend *blk, int argc, char **argv) { struct timeval t1, t2; int Cflag = 0, qflag = 0; int c, cnt; char *buf; int64_t offset; int total = 0; int nr_iov; int pattern = 0xcd; QEMUIOVector qiov; while ((c = getopt(argc, argv, "CqP:")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'q': qflag = 1; break; case 'P': pattern = parse_pattern(optarg); if (pattern < 0) { return 0; } break; default: return qemuio_command_usage(&writev_cmd); } } if (optind > argc - 2) { return qemuio_command_usage(&writev_cmd); } offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } optind++; if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n", offset); return 0; } nr_iov = argc - optind; buf = create_iovec(blk, &qiov, &argv[optind], nr_iov, pattern); if (buf == NULL) { return 0; } gettimeofday(&t1, NULL); cnt = do_aio_writev(blk, &qiov, offset, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("writev failed: %s\n", strerror(-cnt)); goto out; } if (qflag) { goto out; } t2 = tsub(t2, t1); print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag); out: qemu_iovec_destroy(&qiov); qemu_io_free(buf); return 0; }
1threat
Filing with VBA macros form do not valid : I have poor English, sorry :-) I have a macros to fill form on site. Macro work good, all web form get text from excell and it works fine. I get problem after filing form with macro. Web forms do not see text there macro inserted. Web forms need to do action with keybord in form. Just after i am doing anything from keyboard in form, it begin see a text, that inserted with macro. For example, typing space from keyboard and deleting it helps to form to be valid. How can i deleting symbol in form? I used getElementsByTagName and getElementsByClassname and with this to commands SendKeys return error. For example: getElementsByTagName(0).SendKeys"{BACKSPACE}" - return error :-( Please, help me.
0debug
static void pc87312_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = pc87312_realize; dc->reset = pc87312_reset; dc->vmsd = &vmstate_pc87312; dc->props = pc87312_properties; }
1threat
How to inject Webpack build hash to application code : <p>I'm using Webpack's [hash] for cache busting locale files. But I also need to hard-code the locale file path to load it from browser. Since the file path is altered with [hash], I need to inject this value to get right path.</p> <p>I don't know how can get Webpack [hash] value programmatically in config so I can inject it using WebpackDefinePlugin.</p> <pre><code>module.exports = (env) =&gt; { return { entry: 'app/main.js', output: { filename: '[name].[hash].js' } ... plugins: [ new webpack.DefinePlugin({ HASH: ***???*** }) ] } } </code></pre>
0debug
Check if element contains #shadow-root : <p>Is it possible to see if a Shadow DOM element exists? I'm not too concerned with manipulating it, or even really targeting it per-say. I understand the reasoning of the encapsulation. But I'd like to be able to style other elements in the regular DOM, based on whether or not the Shadow DOM element is present.</p> <p>Sort of like:</p> <pre><code>if ( $('#element-id #shadow-root').length ) { // true } </code></pre> <p>Or if not for the shadow-root, at least a specific element within, like the id of a div. So if that div exists, then clearly that Shadow DOM element is on the page.</p> <p>I know it wouldn't be that simple... From some research I've done, there are things like <code>&gt;&gt;&gt;</code> and <code>/deep/</code> but their support seems to be low/none/deprecated. Buy maybe there's another way, however inelegant it may be?</p>
0debug
Setting state on componentDidMount() : <p>I know that it is an anti-pattern to set state on <code>componentDidMount</code> and a state should be set on <code>componentWillMount</code> but suppose I want to set the length of the number of <code>li</code> tags as a state. In that case, I can't set the state on <code>componentWillMount</code> since the <code>li</code> tags might not have been mounted during that phase. So, what should be the best option here? Will it be fine if I set the state on <code>componentDidMount</code>?</p>
0debug
What is the python equivalent of below perl code? : I am trying to capture the result of a command in python. use Capture::Tiny ':all'; my ($stdout, $stderr, $exit_code) = capture { system( "$cmd"); };
0debug
static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov) { int pos, i; pos = url_ftell(pb); put_be32(pb, 0); put_tag(pb, "moov"); mov->timescale = globalTimescale; for (i=0; i<MAX_STREAMS; i++) { if(mov->tracks[i].entry <= 0) continue; if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) { mov->tracks[i].timescale = mov->tracks[i].enc->frame_rate; mov->tracks[i].sampleDuration = mov->tracks[i].enc->frame_rate_base; } else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) { if(mov->tracks[i].enc->codec_id == CODEC_ID_AMR_NB) { mov->tracks[i].sampleDuration = 160; mov->tracks[i].timescale = 8000; } else { mov->tracks[i].timescale = mov->tracks[i].enc->sample_rate; mov->tracks[i].sampleDuration = mov->tracks[i].enc->frame_size; } } mov->tracks[i].trackDuration = mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration; mov->tracks[i].time = mov->time; mov->tracks[i].trackID = i+1; } mov_write_mvhd_tag(pb, mov); for (i=0; i<MAX_STREAMS; i++) { if(mov->tracks[i].entry > 0) { mov_write_trak_tag(pb, &(mov->tracks[i])); } } return updateSize(pb, pos); }
1threat
C++ multi threaded sever : I'm working on a server that just connects a client and sends back what they type. So far it works well,but I want to make it multi-threaded so I can connect more than clients, so they can "Talk." Can you guys refer me to any source code that I can look over to make some adjustments to my own code? Thanks. I would also like this to work on different networks, and I am not sure how to do this so some source code to that as well would work. Also I'm in eighth grade and haven't had a lot of experience so a well enplaned answer would be appreciated. int main() { WSADATA wsaData; // Initialize Winsock int iResult = WSAStartup(MAKEWORD(2,2), &wsaData); if(iResult != 0) { printf("WSAStartup failed: %d\n", iResult); return 1; } struct addrinfo *result = NULL, hints; ZeroMemory(&hints, sizeof(hints)); hints.ai_family = AF_INET; // Internet address family is unspecified so that either an IPv6 or IPv4 address can be returned hints.ai_socktype = SOCK_STREAM; // Requests the socket type to be a stream socket for the TCP protocol hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = AI_PASSIVE; // Resolve the local address and port to be used by the server iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result); if (iResult != 0) { printf("getaddrinfo failed: %d\n", iResult); WSACleanup(); return 1; } SOCKET ListenSocket = INVALID_SOCKET; // Create a SOCKET for the server to listen for client connections ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol); if (ListenSocket == INVALID_SOCKET) { printf("Error at socket(): %d\n", WSAGetLastError()); freeaddrinfo(result); WSACleanup(); return 1; } // Setup the TCP listening socket iResult = bind(ListenSocket, result->ai_addr, (int)result->ai_addrlen); if (iResult == SOCKET_ERROR) { printf("bind failed: %d", WSAGetLastError()); freeaddrinfo(result); closesocket(ListenSocket); WSACleanup(); return 1; } freeaddrinfo(result); // To listen on a socket if ( listen(ListenSocket, SOMAXCONN) == SOCKET_ERROR) { printf("listen failed: %d\n", WSAGetLastError()); closesocket(ListenSocket); WSACleanup(); return 1; } SOCKET ClientSocket; ClientSocket = INVALID_SOCKET; // Accept a client socket ClientSocket = accept(ListenSocket, NULL, NULL); if (ClientSocket == INVALID_SOCKET) { printf("accept failed: %d\n", WSAGetLastError()); closesocket(ListenSocket); WSACleanup(); return 1; } char recvbuf[DEFAULT_BUFFER_LENGTH]; int iSendResult; // reveice until the client shutdown the connection do { iResult = recv(ClientSocket, recvbuf, DEFAULT_BUFFER_LENGTH, 0); if (iResult > 0) { char msg[DEFAULT_BUFFER_LENGTH]; memset(&msg, 0, sizeof(msg)); strncpy(msg, recvbuf, iResult); printf("Received: %s\n", msg); iSendResult = send(ClientSocket, recvbuf, iResult, 0); if (iSendResult == SOCKET_ERROR) { printf("send failed: %d\n", WSAGetLastError()); closesocket(ClientSocket); WSACleanup(); return 1; } printf("Bytes sent: %ld\n", iSendResult); } else if (iResult == 0) printf("Connection closed\n"); else { printf("recv failed: %d\n", WSAGetLastError()); closesocket(ClientSocket); WSACleanup(); //return 1; } } while (iResult > 0); // Free the resouces closesocket(ListenSocket); WSACleanup(); getchar(); return 0; }
0debug
int ff_mjpeg_find_marker(MJpegDecodeContext *s, const uint8_t **buf_ptr, const uint8_t *buf_end, const uint8_t **unescaped_buf_ptr, int *unescaped_buf_size) { int start_code; start_code = find_marker(buf_ptr, buf_end); av_fast_padded_malloc(&s->buffer, &s->buffer_size, buf_end - *buf_ptr); if (!s->buffer) return AVERROR(ENOMEM); if (start_code == SOS && !s->ls) { const uint8_t *src = *buf_ptr; uint8_t *dst = s->buffer; while (src < buf_end) { uint8_t x = *(src++); *(dst++) = x; if (s->avctx->codec_id != AV_CODEC_ID_THP) { if (x == 0xff) { while (src < buf_end && x == 0xff) x = *(src++); if (x >= 0xd0 && x <= 0xd7) *(dst++) = x; else if (x) break; } } } *unescaped_buf_ptr = s->buffer; *unescaped_buf_size = dst - s->buffer; memset(s->buffer + *unescaped_buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); av_log(s->avctx, AV_LOG_DEBUG, "escaping removed %"PTRDIFF_SPECIFIER" bytes\n", (buf_end - *buf_ptr) - (dst - s->buffer)); } else if (start_code == SOS && s->ls) { const uint8_t *src = *buf_ptr; uint8_t *dst = s->buffer; int bit_count = 0; int t = 0, b = 0; PutBitContext pb; while (src + t < buf_end) { uint8_t x = src[t++]; if (x == 0xff) { while ((src + t < buf_end) && x == 0xff) x = src[t++]; if (x & 0x80) { t -= FFMIN(2, t); break; } } } bit_count = t * 8; init_put_bits(&pb, dst, t); while (b < t) { uint8_t x = src[b++]; put_bits(&pb, 8, x); if (x == 0xFF) { x = src[b++]; if (x & 0x80) { av_log(s->avctx, AV_LOG_WARNING, "Invalid escape sequence\n"); x &= 0x7f; } put_bits(&pb, 7, x); bit_count--; } } flush_put_bits(&pb); *unescaped_buf_ptr = dst; *unescaped_buf_size = (bit_count + 7) >> 3; memset(s->buffer + *unescaped_buf_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } else { *unescaped_buf_ptr = *buf_ptr; *unescaped_buf_size = buf_end - *buf_ptr; } return start_code; }
1threat
Does Python execute code from the top or bottom of the script : <p>I am working on learning Python and was wondering in what way the scripts are executed what i mean like this if Python runs the code from the beginning of the script or the bottom </p>
0debug
Create React App: using environment variables in index.html : <p>Is there a way to inject environment variables, e.g. <code>REACT_APP_MY_API</code> into the <code>index.html</code> file? </p> <p>According to <a href="https://github.com/facebook/create-react-app/pull/1440" rel="noreferrer">this</a>, it can be done, but I can't seem to get it to work. </p> <h2>.env</h2> <pre><code>REACT_APP_MY_API=https://something.com </code></pre> <h2>index.html</h2> <pre><code>&lt;script type="text/javascript"&gt; console.log("%REACT_APP_MY_API%") // undefined console.log("%NODE_ENV%") // development &lt;/script&gt; </code></pre>
0debug
Perl list referencing reversing : Folks, I am newbie to perl. And have been working with csv's, json's, list and hashes.</br> **I have written this code, but it is giving me error. I want to use this *$header_copy* in foreach loop.** 1. my @headers=qw/January February March April May June/; 2. my $header_copy=\@headers; 3. print("$header_copy->[2]"); # Prints "March" Correctly 4. print("$header_copy[2]"); #Gives Error. >>**Error :** ***Global symbol "@header_copy" requires explicit package name at line 4*** And I want to use $header_copy in for loop: like</br> </br > foreach $i ($header_copy){ **code..** } Help! Urgent!!
0debug
Missing credentials for "PLAIN" nodemailer : <p>I'm trying to use nodemailer in my contact form to receive feedback and send them directly to an email. This is the form below.</p> <pre><code>&lt;form method="post" action="/contact"&gt; &lt;label for="name"&gt;Name:&lt;/label&gt; &lt;input type="text" name="name" placeholder="Enter Your Name" required&gt;&lt;br&gt; &lt;label for="email"&gt;Email:&lt;/label&gt; &lt;input type="email" name="email" placeholder="Enter Your Email" required&gt;&lt;br&gt; &lt;label for="feedback"&gt;Feedback:&lt;/label&gt; &lt;textarea name="feedback" placeholder="Enter Feedback Here"&gt;&lt;/textarea&gt;&lt;br&gt; &lt;input type="submit" name="sumbit" value="Submit"&gt; &lt;/form&gt; </code></pre> <p>This is what the request in the server side looks like</p> <pre><code>app.post('/contact',(req,res)=&gt;{ let transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: 'user@gmail.com', password: 'password' } }); var mailOptions = { from: req.body.name + '&amp;lt;' + req.body.email + '&amp;gt;', to: 'bantspl@gmail.com', subject: 'Plbants Feedback', text: req.body.feedback }; transporter.sendMail(mailOptions,(err,res)=&gt;{ if(err){ console.log(err); } else { } }); </code></pre> <p>I'm getting the error <code>Missing credentials for "PLAIN"</code>. Any help is appreciated, thank you very much.</p>
0debug
JAVA LOOP FOR GAME : I'm having trouble with my code. For some reason, each time I run the code the " if (guess <1 || guess >10 ) System.out.println ("Your guess needs to be between 1 and 10");" statement is counted as a guessing attempt. The goal is to not have the attempt count if the player is guessing out of the 1-10 range. I've tried a break;, but I can't get it right? Does anyone know how to break the loop and return to the guessing, if a user is out of range(without it counting as an attempt)? Thank you import java.security.SecureRandom; import java.util.Scanner; public class GuessTheNumber { private Scanner input = new Scanner(System.in); private SecureRandom randomNumbers = new SecureRandom(); private int numberOfGuesses; public void play() { numberOfGuesses = 0; int magicNumber = 1 + randomNumbers.nextInt(10); int guess = askForGuess(); while(guess != magicNumber){ // Some kind of loop, maybe while numberOfGuesses++; // is theGuess equal to magicNumber or is it guess = input.nextInt(); // too high or is it too low if (guess == magicNumber) System.out.println("Yes, the number is " + magicNumber); else if (guess > magicNumber) System.out.println("Your guess is too high"); else if (guess < magicNumber) System.out.println("Your guess is too low"); System.out.println ("Number of times guessed: " + numberOfGuesses ); // Display "correct in numberOfGuesses" } } } private int askForGuess( ) { int guess = 0; // prompt for a guess System.out.println("Enter a number:"); if (guess <1 || guess >10 ) System.out.println ("Your guess needs to be between 1 and 10"); return guess; } }
0debug
static ssize_t usbnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { USBNetState *s = DO_UPCAST(NICState, nc, nc)->opaque; struct rndis_packet_msg_type *msg; if (is_rndis(s)) { msg = (struct rndis_packet_msg_type *) s->in_buf; if (!s->rndis_state == RNDIS_DATA_INITIALIZED) return -1; if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf)) return -1; memset(msg, 0, sizeof(struct rndis_packet_msg_type)); msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG); msg->MessageLength = cpu_to_le32(size + sizeof(struct rndis_packet_msg_type)); msg->DataOffset = cpu_to_le32(sizeof(struct rndis_packet_msg_type) - 8); msg->DataLength = cpu_to_le32(size); memcpy(msg + 1, buf, size); s->in_len = size + sizeof(struct rndis_packet_msg_type); } else { if (size > sizeof(s->in_buf)) return -1; memcpy(s->in_buf, buf, size); s->in_len = size; } s->in_ptr = 0; return size; }
1threat
How to check in Java whether the input string is of palindrome in nature or not? : I have a String input as "I LOVE MY COUNTRY INDIA COUNTRY MY LOVE I". This is a perfect palindrome sentence as the word sequence exactly matches from start to middle and end to middle.<br/> I want to create a function to prove this using Java. I have tried following code: void checkPalindrome() { String str = "I LOVE MY COUNTRY INDIA COUNTRY MY LOVE I"; List<String> list=new ArrayList<String>(); int i,flag=0,cnt=0; for(i=0;i<str.length();i++) { if(str.charAt(i)==' ') { list.add(str.substring(flag, i).toString()); flag=i; } }list.add(str.substring(flag, i).toString()); Iterator<String> it1=list.iterator(); ListIterator<String> it2=list.listIterator(list.size()); while(it1.hasNext() && it2.hasPrevious()) { if(it1.next().equals(it2.previous())) { cnt++; } } if(cnt==list.size()) System.out.println("Palindrome nature found"); } <br/> This is not working by the way, please help me to do it in exact way.
0debug
void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, int64_t grow, int64_t shrink, Error **errp) { ctx->poll_max_ns = max_ns; ctx->poll_ns = 0; ctx->poll_grow = grow; ctx->poll_shrink = shrink; aio_notify(ctx); }
1threat
void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val) { uint16_t pm1_sts = acpi_pm1_evt_get_sts(ar, ar->tmr.overflow_time); if (pm1_sts & val & ACPI_BITMASK_TIMER_STATUS) { acpi_pm_tmr_calc_overflow_time(ar); } ar->pm1.evt.sts &= ~val; }
1threat
Task<bool> causes Entity Framework to Hang : <p>When I change the method signature to be Task Entity Framework hangs at SaveChanges. Why would this be happening?</p> <p>This code fails</p> <pre><code>public async Task&lt;bool&gt; SaveAsync(agency agency) { using (var ctx = new AvnEntities()) { try { ctx.agencies.Add(agency); await ctx.SaveChangesAsync(); return true; } catch (System.Exception) { return false; } } } </code></pre> <p>This code works</p> <pre><code>public async Task SaveAsync(agency agency) { using (var ctx = new AvnEntities()) { try { ctx.agencies.Add(agency); await ctx.SaveChangesAsync(); } catch (System.Exception) { throw; } } } </code></pre>
0debug
cannot be cast to android.location.LocationListener : Here its my logcat 12-01 14:53:24.164 17910-17910/com.swetha.pc.barcoderead E/AndroidRuntime: FATAL EXCEPTION: main Process: com.swetha.pc.barcoderead, PID: 17910 java.lang.ClassCastException: com.swetha.pc.barcoderead.tools.MapsActivity cannot be cast to android.location.LocationListener at com.swetha.pc.barcoderead.tools.MapsActivity.onMapReady(MapsActivity.java:265) at com.google.android.gms.maps.SupportMapFragment$zza$1.zza(Unknown Source) at com.google.android.gms.maps.internal.zzt$zza.onTransact(Unknown Source) at android.os.Binder.transact(Binder.java:380) at zu.a(:com.google.android.gms.DynamiteModulesB:82) at maps.ad.t$5.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5273) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 12-01 14:53:25.020 17910-20204/com.swetha.pc.barcoderead I/b: Received API Token: AH0uPGEAVz4Fv0lIM1ZNa72XhP7ITCAK41eqC_INs_c63sE2LxzjlfURVrWkQ33r8PUe1ED9uW8HZEVSk6NjJG53kHmlU9iLrTrWXo57bcxPrqgeUEzTkfgKd9m6wuh93aolf3k47OakjOpk2uGiJtC8UNMq-VUQ8V4-HxgAA-ZQIrm_GsYUZXi42JEYrAG2k9IDosUy9xfJ / Expires in: 432000000ms 12-01 14:53:25.020 17910-20204/com.swetha.pc.barcoderead I/c: Scheduling next attempt in 431700 seconds. 12-01 14:53:25.022 17910-20204/com.swetha.pc.barcoderead W/f: Suppressed StrictMode policy violation: StrictModeDiskWriteViolation 12-01 14:53:25.023 17910-20204/com.swetha.pc.barcoderead I/d: Saved auth token 12-01 14:53:25.027 17910-20265/com.swetha.pc.barcoderead W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 12-01 14:53:26.070 17910-20198/com.swetha.pc.barcoderead W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found. 12-01 14:53:26.089 17910-20198/com.swetha.pc.barcoderead I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:2 12-01 14:53:26.089 17910-20198/com.swetha.pc.barcoderead I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 2 12-01 14:53:26.093 17910-20198/com.swetha.pc.barcoderead E/DynamiteModule: Failed to load DynamiteLoader: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader" on path: DexPathList[[zip file "/data/app/com.swetha.pc.barcoderead-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] 12-01 14:53:26.093 17910-20198/com.swetha.pc.barcoderead W/DynamiteModule: Failed to load remote module: Failed to get module context 12-01 14:53:26.093 17910-20198/com.swetha.pc.barcoderead W/DynamiteModule: Failed to load module via fast routetn: Remote load failed. No local fallback found. 12-01 14:53:26.096 17910-20198/com.swetha.pc.barcoderead W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found. 12-01 14:53:26.101 17910-20198/com.swetha.pc.barcoderead I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:2 12-01 14:53:26.101 17910-20198/com.swetha.pc.barcoderead I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 2
0debug
change filename : <p>I need some help in renaming a large amount of files I am using bash pretty cutting _Filestore and everything that ends after key and crt in files. Thx for your help</p> <hr> <p><strong>Current File</strong></p> <p>_Filestore.dev.orange.key_12345_1</p> <p>_Filestore.dev.orange.crt_57397_1</p> <p>_Filestore.dev.apple.key_95672566_1</p> <p>_Filestore.dev.apple.crt_22258_1</p> <p><strong>Need it to look like this</strong></p> <p>dev.orange.key</p> <p>dev.orange.crt</p> <p>dev.apple.key</p> <p>dev.apple.crt</p>
0debug
Php fatal error- how to include class in index.php : I am having problem with my site. PHP Fatal error: Class 'innovation_ruby_util' not found in D:\inetpub\vhosts\blacklisthackers.com\httpdocs\wp-content\themes\innovation\index.php on line 7 Please help me adding classes in this code below 1. <?php /** * Innovation created by ThemeRuby * This file display home layout */ //get home options $ruby_options['page_layout'] = innovation_ruby_util::get_theme_option( 'home_layout' ); $ruby_options['sidebar_name'] = innovation_ruby_util::get_theme_option( 'home_sidebar' ); $ruby_options['sidebar_position'] = innovation_ruby_util::get_theme_option( 'home_sidebar_position' ); $ruby_options['big_first'] = innovation_ruby_util::get_theme_option( 'big_post_first' ); if ( 'default' == $ruby_options['sidebar_position'] ) { $ruby_options['sidebar_position'] = innovation_ruby_util::get_theme_option( 'site_sidebar_position' ); } //render featured area get_template_part( 'templates/section', 'featured' ); //render home columns get_template_part('templates/section','columns'); //render layout innovation_ruby_blog_layout::render( $ruby_options );
0debug
Why big websites don't prefer localstorage over cookie? : <p>I'd like to ask why big players like facebook, google still uses cookies if localstorage is much better and secure for same.</p>
0debug
I wanna use url's data in method : I wanna use url's data in method.Now urls.py is from django.urls import path from . import views urlpatterns = [ path('data/<int:id>', views.data, name='data'), ] I wrote in views.py @csrf_exempt def data(request,<int:id>): results = Users.objects.filter(user=id) print(results) return HttpResponse('<h1>OK</h1>') But I got an error,formal parameter name expected in <int:id>of (request,<int:id>).If I access http://127.0.0.1:8000/data/3,my ideal system print user's data has id=3.I cannot understand how I can do it.What is wrong in my code?
0debug
Why we can't put null key in linkedHashMap in java : <p>We can put single null key in hashMap. but in linkedHashMap we can't pull null key. what is the reason behind this. </p>
0debug
void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq, DBDMA_rw rw, DBDMA_flush flush, void *opaque) { DBDMAState *s = dbdma; DBDMA_channel *ch = &s->channels[nchan]; DBDMA_DPRINTF("DBDMA_register_channel 0x%x\n", nchan); ch->irq = irq; ch->channel = nchan; ch->rw = rw; ch->flush = flush; ch->io.opaque = opaque; ch->io.channel = ch; }
1threat
Change form fields value inside controller and then save it to db in Symfony : I am working on Symfony and i have got a problem.Which is as follows:- ***OrderAdminController:-*** <?php namespace AppBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Sonata\AdminBundle\Controller\CRUDController as Controller; use AppBundle\Entity\Order; use AppBundle\Entity\Month; class OrderAdminController extends Controller { //overriding Default CRUD create action public function createAction() { $request = $this->getRequest(); // this is the code where i am trying to change the coming values of ofrm fileds if(!empty($_POST)){ $key =array_keys($_POST)[0]; $date_to_floor = $_POST[$key]["date_to_floor"]; $user_id = $_POST[$key]["assigned"]; $hours_to_complete = $_POST[$key]["estimate"]; $final_data = $this->adjust_working_hours($date_to_floor,$user_id,$hours_to_complete); $_POST[$key]["start_datetime"] = date('n/j/Y H:i',strtotime($final_data['start_date'])); $_POST[$key]["end_datetime"] = date('n/j/Y H:i',strtotime($final_data['end_date'])); $_POST[$key]["hours_remaining"] = $final_data['hours_remaining']; $request->request->set('start_datetime', date('n/j/Y H:i',strtotime($final_data['start_date']))); $request->request->set('end_datetime', date('n/j/Y H:i',strtotime($final_data['end_date']))); $request->request->set('hours_remaining', $final_data['hours_remaining']); } // the key used to lookup the template $templateKey = 'edit'; $this->admin->checkAccess('create'); $class = new \ReflectionClass($this->admin->hasActiveSubClass() ? $this->admin->getActiveSubClass() : $this->admin->getClass()); if ($class->isAbstract()) { return $this->render( 'SonataAdminBundle:CRUD:select_subclass.html.twig', array( 'base_template' => $this->getBaseTemplate(), 'admin' => $this->admin, 'action' => 'create', ), null, $request ); } $object = $this->admin->getNewInstance(); $preResponse = $this->preCreate($request, $object); if ($preResponse !== null) { return $preResponse; } $this->admin->setSubject($object); /** @var $form \Symfony\Component\Form\Form */ $form = $this->admin->getForm(); $form->setData($object); $form->handleRequest($request); if ($form->isSubmitted()) { //TODO: remove this check for 4.0 if (method_exists($this->admin, 'preValidate')) { $this->admin->preValidate($object); } $isFormValid = $form->isValid(); // persist if the form was valid and if in preview mode the preview was approved if ($isFormValid && (!$this->isInPreviewMode($request) || $this->isPreviewApproved($request))) { $this->admin->checkAccess('create', $object); try { $object = $this->admin->create($object); if ($this->isXmlHttpRequest()) { return $this->renderJson(array( 'result' => 'ok', 'objectId' => $this->admin->getNormalizedIdentifier($object), ), 200, array()); } $this->addFlash( 'sonata_flash_success', $this->admin->trans( 'flash_create_success', array('%name%' => $this->escapeHtml($this->admin->toString($object))), 'SonataAdminBundle' ) ); // redirect to edit mode return $this->redirectTo($object); } catch (ModelManagerException $e) { $this->handleModelManagerException($e); $isFormValid = false; } } // show an error message if the form failed validation if (!$isFormValid) { if (!$this->isXmlHttpRequest()) { $this->addFlash( 'sonata_flash_error', $this->admin->trans( 'flash_create_error', array('%name%' => $this->escapeHtml($this->admin->toString($object))), 'SonataAdminBundle' ) ); } } elseif ($this->isPreviewRequested()) { // pick the preview template if the form was valid and preview was requested $templateKey = 'preview'; $this->admin->getShow(); } } $view = $form->createView(); // set the theme for the current Admin Form $this->get('twig')->getExtension('form')->renderer->setTheme($view, $this->admin->getFormTheme()); return $this->render($this->admin->getTemplate($templateKey), array( 'action' => 'create', 'form' => $view, 'object' => $object, ), null); } } ***Now what i am trying is when form submitted, i need to change some form field values based on `adjust_working_hours()`.*** ***The problem is :-*** ***if i added this code:-*** if(!empty($_POST)){ $key =array_keys($_POST)[0]; $date_to_floor = $_POST[$key]["date_to_floor"]; $user_id = $_POST[$key]["assigned"]; $hours_to_complete = $_POST[$key]["estimate"]; $final_data = $this->adjust_working_hours($date_to_floor,$user_id,$hours_to_complete); $_POST[$key]["start_datetime"] = date('n/j/Y H:i',strtotime($final_data['start_date'])); $_POST[$key]["end_datetime"] = date('n/j/Y H:i',strtotime($final_data['end_date'])); $_POST[$key]["hours_remaining"] = $final_data['hours_remaining']; $request->request->set('start_datetime', date('n/j/Y H:i',strtotime($final_data['start_date']))); $request->request->set('end_datetime', date('n/j/Y H:i',strtotime($final_data['end_date']))); $request->request->set('hours_remaining', $final_data['hours_remaining']); } ***Before:- `if ($form->isSubmitted()) {`*** ***the original form values are saved into db not the changed one.*** ***And if i add the same code after `if ($form->isSubmitted()) {`*** ***then it says error :-*** > You cannot changes the data of submitted form So how to change those field values so that my changed values will save? Let me know if any other details needed.
0debug
How to change the position of the object when the window size is changed? : <p>As in the title. I would like objects moving on the board to change position propositionally to change the size of the window. How to do it?</p>
0debug
static int flac_write_trailer(struct AVFormatContext *s) { ByteIOContext *pb = s->pb; uint8_t *streaminfo = s->streams[0]->codec->extradata; int len = s->streams[0]->codec->extradata_size; int64_t file_size; if (streaminfo && len > 0 && !url_is_streamed(s->pb)) { file_size = url_ftell(pb); url_fseek(pb, 8, SEEK_SET); put_buffer(pb, streaminfo, len); url_fseek(pb, file_size, SEEK_SET); put_flush_packet(pb); } return 0; }
1threat
static int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int i, j, level, last_non_zero, q; const int *qmat; int minLevel, maxLevel; if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){ minLevel= -2048; maxLevel= 2047; }else if(s->out_format==FMT_MPEG1){ minLevel= -255; maxLevel= 255; }else if(s->out_format==FMT_MJPEG){ minLevel= -1023; maxLevel= 1023; }else{ minLevel= -128; maxLevel= 127; } av_fdct (block); block_permute(block); if (s->mb_intra) { if (n < 4) q = s->y_dc_scale; else q = s->c_dc_scale; q = q << 3; block[0] = (block[0] + (q >> 1)) / q; i = 1; last_non_zero = 0; if (s->out_format == FMT_H263) { qmat = s->q_non_intra_matrix; } else { qmat = s->q_intra_matrix; } } else { i = 0; last_non_zero = -1; qmat = s->q_non_intra_matrix; } for(;i<64;i++) { j = zigzag_direct[i]; level = block[j]; level = level * qmat[j]; #ifdef PARANOID { static int count = 0; int level1, level2, qmat1; double val; if (qmat == s->q_non_intra_matrix) { qmat1 = default_non_intra_matrix[j] * s->qscale; } else { qmat1 = default_intra_matrix[j] * s->qscale; } if (av_fdct != jpeg_fdct_ifast) val = ((double)block[j] * 8.0) / (double)qmat1; else val = ((double)block[j] * 8.0 * 2048.0) / ((double)qmat1 * aanscales[j]); level1 = (int)val; level2 = level / (1 << (QMAT_SHIFT - 3)); if (level1 != level2) { fprintf(stderr, "%d: quant error qlevel=%d wanted=%d level=%d qmat1=%d qmat=%d wantedf=%0.6f\n", count, level2, level1, block[j], qmat1, qmat[j], val); count++; } } #endif if (((level << (31 - (QMAT_SHIFT - 3))) >> (31 - (QMAT_SHIFT - 3))) != level) { level = level / (1 << (QMAT_SHIFT - 3)); if (level > maxLevel) level = maxLevel; else if (level < minLevel) level = minLevel; block[j] = level; last_non_zero = i; } else { block[j] = 0; } } return last_non_zero; }
1threat
static int process_cc608(CCaptionSubContext *ctx, int64_t pts, uint8_t hi, uint8_t lo) { int ret = 0; #define COR3(var, with1, with2, with3) ( (var) == (with1) || (var) == (with2) || (var) == (with3) ) if ( hi == ctx->prev_cmd[0] && lo == ctx->prev_cmd[1]) { } else if ( (hi == 0x10 && (lo >= 0x40 || lo <= 0x5f)) || ( (hi >= 0x11 && hi <= 0x17) && (lo >= 0x40 && lo <= 0x7f) ) ) { handle_pac(ctx, hi, lo); } else if ( ( hi == 0x11 && lo >= 0x20 && lo <= 0x2f ) || ( hi == 0x17 && lo >= 0x2e && lo <= 0x2f) ) { handle_textattr(ctx, hi, lo); } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x20 ) { ctx->mode = CCMODE_POPON; } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x24 ) { handle_delete_end_of_row(ctx, hi, lo); } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x25 ) { ctx->rollup = 2; ctx->mode = CCMODE_ROLLUP_2; } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x26 ) { ctx->rollup = 3; ctx->mode = CCMODE_ROLLUP_3; } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x27 ) { ctx->rollup = 4; ctx->mode = CCMODE_ROLLUP_4; } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x29 ) { ctx->mode = CCMODE_PAINTON; } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x2B ) { ctx->mode = CCMODE_TEXT; } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x2C ) { ret = handle_edm(ctx, pts); } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x2D ) { av_dlog(ctx, "carriage return\n"); reap_screen(ctx, pts); roll_up(ctx); ctx->screen_changed = 1; ctx->cursor_column = 0; } else if ( COR3(hi, 0x14, 0x15, 0x1C) && lo == 0x2F ) { av_dlog(ctx, "handle_eoc\n"); ret = handle_eoc(ctx, pts); } else if (hi>=0x20) { handle_char(ctx, hi, lo, pts); } else { av_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo); } ctx->prev_cmd[0] = hi; ctx->prev_cmd[1] = lo; #undef COR3 return ret; }
1threat
void pci_bus_get_w64_range(PCIBus *bus, Range *range) { range->begin = range->end = 0; pci_for_each_device_under_bus(bus, pci_dev_get_w64, range); }
1threat
static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s) { int copy_count; uint8_t *end_ptr; if (s->cirrus_srccounter > 0) { if (s->cirrus_blt_mode & CIRRUS_BLTMODE_PATTERNCOPY) { cirrus_bitblt_common_patterncopy(s, s->cirrus_bltbuf); the_end: s->cirrus_srccounter = 0; cirrus_bitblt_reset(s); } else { do { (*s->cirrus_rop)(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, s->cirrus_bltbuf, 0, 0, s->cirrus_blt_width, 1); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, 0, s->cirrus_blt_width, 1); s->cirrus_blt_dstaddr += s->cirrus_blt_dstpitch; s->cirrus_srccounter -= s->cirrus_blt_srcpitch; if (s->cirrus_srccounter <= 0) goto the_end; end_ptr = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; copy_count = s->cirrus_srcptr_end - end_ptr; memmove(s->cirrus_bltbuf, end_ptr, copy_count); s->cirrus_srcptr = s->cirrus_bltbuf + copy_count; s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch; } while (s->cirrus_srcptr >= s->cirrus_srcptr_end); } } }
1threat
Android Permission 6.0 : Hi guys i just want to know on how can u have a listener for this one like i know android have onRequestPermissionsResult but the thing is if i changed it from the application information and manually changed the permission from there thats where my problem lies because i dont have any callback do you guys have any idea for this one because i have a service running and if i changed the permission the activity is recreated and i need to know that the permission was disable manually then user enable it again in the application information http://i.stack.imgur.com/vxWKu.png
0debug
static void prom_set(uint32_t* prom_buf, int index, const char *string, ...) { va_list ap; int32_t table_addr; if (index >= ENVP_NB_ENTRIES) return; if (string == NULL) { prom_buf[index] = 0; return; } table_addr = sizeof(int32_t) * ENVP_NB_ENTRIES + index * ENVP_ENTRY_SIZE; prom_buf[index] = tswap32(ENVP_ADDR + table_addr); va_start(ap, string); vsnprintf((char *)prom_buf + table_addr, ENVP_ENTRY_SIZE, string, ap); va_end(ap); }
1threat
static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, const char *name, uint64_t ram_size) { if (mem_path) { #ifdef __linux__ Error *err = NULL; memory_region_init_ram_from_file(mr, owner, name, ram_size, false, mem_path, &err); if (err) { error_report_err(err); memory_region_init_ram(mr, owner, name, ram_size, &error_abort); } #else fprintf(stderr, "-mem-path not supported on this host\n"); exit(1); #endif } else { memory_region_init_ram(mr, owner, name, ram_size, &error_abort); } vmstate_register_ram_global(mr); }
1threat
Convert Date to DateTime using Joda : <p>Is there a way to convert a date in the format "YYYY-MM-dd" to "YYYY-MM-dd HH:mm:ss" using Joda?</p> <p>Eg: "2016-01-21" to "2016-01-21 00:00:00"</p>
0debug
This is my code for a simple java game. How can I display the letters already guessed so they cannot guess the same letter twice. : //import java.util; import java.util.Scanner; public class HangmanJava { public static void main(String[] args) //creates an array { String input; boolean NotFullMan = true; */runs when NotFullMan is true- all letters haven't been guessed/* char guessedLetter = ' '; Scanner hm = new Scanner(System.in); System.out.println("Enter the hangman word"); input = hm.nextLine(); */after word is entered, moves to next line and game begins/* //Convert String to CharArray char[] charArray = input.toCharArray(); //array tests characters StringBuffer buffer = new StringBuffer(input.length()); //stringbuffer so it can modified as needed int totalCorrect = 0; >>//created totalCorrect variable to help program end at the right time for (int i = 0; i < input.length(); i++) >>//buffer can be used as long as int is less than total length of word buffer.append('_'); while (NotFullMan) { System.out.println("Enter a letter"); guessedLetter = hm.nextLine().charAt(0); //starts game, player must guess a letter int correct = 0; for ( int i=0; i < charArray.length; i++) { //Checks each letter if(guessedLetter == charArray[i] && buffer.charAt(i) == '_') { correct++; totalCorrect++; > //totalCorrect so it can keep track buffer.setCharAt(i, guessedLetter); } } System.out.println("You got " + correct + " correct!"); System.out.println(buffer.toString()); if (totalCorrect == input.length()) > //ends when totalCorrect is equal to the number of characters in word return; } } }
0debug
static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, struct iovec *iov, int niov, bool create, enum AIOCBState aiocb_type) { int nr_copies = s->inode.nr_copies; SheepdogObjReq hdr; unsigned int wlen = 0; int ret; uint64_t oid = aio_req->oid; unsigned int datalen = aio_req->data_len; uint64_t offset = aio_req->offset; uint8_t flags = aio_req->flags; uint64_t old_oid = aio_req->base_oid; if (!nr_copies) { error_report("bug"); } memset(&hdr, 0, sizeof(hdr)); switch (aiocb_type) { case AIOCB_FLUSH_CACHE: hdr.opcode = SD_OP_FLUSH_VDI; break; case AIOCB_READ_UDATA: hdr.opcode = SD_OP_READ_OBJ; hdr.flags = flags; break; case AIOCB_WRITE_UDATA: if (create) { hdr.opcode = SD_OP_CREATE_AND_WRITE_OBJ; } else { hdr.opcode = SD_OP_WRITE_OBJ; } wlen = datalen; hdr.flags = SD_FLAG_CMD_WRITE | flags; break; case AIOCB_DISCARD_OBJ: hdr.opcode = SD_OP_DISCARD_OBJ; break; } if (s->cache_flags) { hdr.flags |= s->cache_flags; } hdr.oid = oid; hdr.cow_oid = old_oid; hdr.copies = s->inode.nr_copies; hdr.data_length = datalen; hdr.offset = offset; hdr.id = aio_req->id; qemu_co_mutex_lock(&s->lock); s->co_send = qemu_coroutine_self(); aio_set_fd_handler(s->aio_context, s->fd, co_read_response, co_write_request, s); socket_set_cork(s->fd, 1); ret = qemu_co_send(s->fd, &hdr, sizeof(hdr)); if (ret != sizeof(hdr)) { error_report("failed to send a req, %s", strerror(errno)); goto out; } if (wlen) { ret = qemu_co_sendv(s->fd, iov, niov, aio_req->iov_offset, wlen); if (ret != wlen) { error_report("failed to send a data, %s", strerror(errno)); } } out: socket_set_cork(s->fd, 0); aio_set_fd_handler(s->aio_context, s->fd, co_read_response, NULL, s); s->co_send = NULL; qemu_co_mutex_unlock(&s->lock); }
1threat
static Rom *find_rom(target_phys_addr_t addr) { Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (rom->fw_file) { continue; } if (rom->addr > addr) { continue; } if (rom->addr + rom->romsize < addr) { continue; } return rom; } return NULL; }
1threat
function from Java to R : The java code that im having is completely complex for me to translate to R. Can anyone help to solve convert to R from this java codes, because it is my reference to learn. public static void enumerate(int n) { int[] a = new int[n]; enumerate(a, 0); } public static void enumerate(int[] q, int k) { int n = q.length; if (k == n) printQueens(q); else { for (int i = 0; i < n; i++) { q[k] = i; if (isConsistent(q, k)) enumerate(q, k+1); } } }
0debug
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint16_t *flags, QCryptoTLSCreds *tlscreds, const char *hostname, QIOChannel **outioc, off_t *size, Error **errp) { char buf[256]; uint64_t magic, s; int rc; bool zeroes = true; TRACE("Receiving negotiation tlscreds=%p hostname=%s.", tlscreds, hostname ? hostname : "<null>"); rc = -EINVAL; if (outioc) { *outioc = NULL; } if (tlscreds && !outioc) { error_setg(errp, "Output I/O channel required for TLS"); goto fail; } if (read_sync(ioc, buf, 8, errp) < 0) { error_prepend(errp, "Failed to read data"); goto fail; } buf[8] = '\0'; if (strlen(buf) == 0) { error_setg(errp, "Server connection closed unexpectedly"); goto fail; } TRACE("Magic is %c%c%c%c%c%c%c%c", qemu_isprint(buf[0]) ? buf[0] : '.', qemu_isprint(buf[1]) ? buf[1] : '.', qemu_isprint(buf[2]) ? buf[2] : '.', qemu_isprint(buf[3]) ? buf[3] : '.', qemu_isprint(buf[4]) ? buf[4] : '.', qemu_isprint(buf[5]) ? buf[5] : '.', qemu_isprint(buf[6]) ? buf[6] : '.', qemu_isprint(buf[7]) ? buf[7] : '.'); if (memcmp(buf, "NBDMAGIC", 8) != 0) { error_setg(errp, "Invalid magic received"); goto fail; } if (read_sync(ioc, &magic, sizeof(magic), errp) < 0) { error_prepend(errp, "Failed to read magic"); goto fail; } magic = be64_to_cpu(magic); TRACE("Magic is 0x%" PRIx64, magic); if (magic == NBD_OPTS_MAGIC) { uint32_t clientflags = 0; uint16_t globalflags; bool fixedNewStyle = false; if (read_sync(ioc, &globalflags, sizeof(globalflags), errp) < 0) { error_prepend(errp, "Failed to read server flags"); goto fail; } globalflags = be16_to_cpu(globalflags); TRACE("Global flags are %" PRIx32, globalflags); if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { fixedNewStyle = true; TRACE("Server supports fixed new style"); clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE; } if (globalflags & NBD_FLAG_NO_ZEROES) { zeroes = false; TRACE("Server supports no zeroes"); clientflags |= NBD_FLAG_C_NO_ZEROES; } clientflags = cpu_to_be32(clientflags); if (write_sync(ioc, &clientflags, sizeof(clientflags), errp) < 0) { error_prepend(errp, "Failed to send clientflags field"); goto fail; } if (tlscreds) { if (fixedNewStyle) { *outioc = nbd_receive_starttls(ioc, tlscreds, hostname, errp); if (!*outioc) { goto fail; } ioc = *outioc; } else { error_setg(errp, "Server does not support STARTTLS"); goto fail; } } if (!name) { TRACE("Using default NBD export name \"\""); name = ""; } if (fixedNewStyle) { if (nbd_receive_query_exports(ioc, name, errp) < 0) { goto fail; } } if (nbd_send_option_request(ioc, NBD_OPT_EXPORT_NAME, -1, name, errp) < 0) { goto fail; } if (read_sync(ioc, &s, sizeof(s), errp) < 0) { error_prepend(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); if (read_sync(ioc, flags, sizeof(*flags), errp) < 0) { error_prepend(errp, "Failed to read export flags"); goto fail; } be16_to_cpus(flags); } else if (magic == NBD_CLIENT_MAGIC) { uint32_t oldflags; if (name) { error_setg(errp, "Server does not support export names"); goto fail; } if (tlscreds) { error_setg(errp, "Server does not support STARTTLS"); goto fail; } if (read_sync(ioc, &s, sizeof(s), errp) < 0) { error_prepend(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, &oldflags, sizeof(oldflags), errp) < 0) { error_prepend(errp, "Failed to read export flags"); goto fail; } be32_to_cpus(&oldflags); if (oldflags & ~0xffff) { error_setg(errp, "Unexpected export flags %0x" PRIx32, oldflags); goto fail; } *flags = oldflags; } else { error_setg(errp, "Bad magic received"); goto fail; } TRACE("Size is %" PRIu64 ", export flags %" PRIx16, *size, *flags); if (zeroes && drop_sync(ioc, 124, errp) < 0) { error_prepend(errp, "Failed to read reserved block"); goto fail; } rc = 0; fail: return rc; }
1threat
Data type mismatch in criteria expression. i can find the solution : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New OleDb.OleDbConnection Dim str As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=..\VisitorPass.accdb" Dim sql As String sql = "Update Visitor set [password]='" & txtPassword.Text & "',FirstName='" & txtFirstName.Text & "',LastName='" & txtLastName.Text & "',Gender='" & txtGender.Text & "',MobileNo='" & txtMobileNO.Text & "',DateOfBirth='" & txtDateOfBirth.Text & "',VisitorAddress='" & txtVisitorAddress.Text & "'where ID='" & lblID2.Text & "'" con = New OleDbConnection(str) Dim cmd As New OleDbCommand(sql, con) con.Open() cmd.ExecuteNonQuery() Dim obj1 As New VisitorProfile obj1.StringPass = txtName.Text MsgBox("profile is updated") obj1.Show() con.Close() Me.Close() End Sub
0debug
How to use Blob URL, MediaSource or other methods to play concatenated Blobs of media fragments? : <p>Am attempting to implement, for lack of a different description, an offline media context.</p> <p>The concept is to create 1 second <code>Blob</code>s of recorded media, with the ability to </p> <ol> <li>Play the 1 second <code>Blobs</code> independently at an <code>HTMLMediaElement</code></li> <li>Play the full media resource from concatenated <code>Blob</code>s</li> </ol> <p>The issue is that once the <code>Blob</code>s are concatenated the media resource does not play at <code>HTMLMedia</code> element using either a <code>Blob URL</code> or <code>MediaSource</code>.</p> <p>The created <code>Blob URL</code> only plays 1 second of the concatenated <code>Blob</code>'s. <code>MediaSource</code> throws two exceptions</p> <pre><code>DOMException: Failed to execute 'addSourceBuffer' on 'MediaSource': The MediaSource's readyState is not 'open' </code></pre> <p>and</p> <pre><code>DOMException: Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer has been removed from the parent media source. </code></pre> <p>How to properly encode the concatenated <code>Blob</code>s or otherwise implement a workaround to play the media fragments as a single re-constituted media resource?</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;script&gt; const src = "https://nickdesaulniers.github.io/netfix/demo/frag_bunny.mp4"; fetch(src) .then(response =&gt; response.blob()) .then(blob =&gt; { const blobURL = URL.createObjectURL(blob); const chunks = []; const mimeCodec = "vdeo/webm; codecs=opus"; let duration; let media = document.createElement("video"); media.onloadedmetadata = () =&gt; { media.onloadedmetadata = null; duration = Math.ceil(media.duration); let arr = Array.from({ length: duration }, (_, index) =&gt; index); // record each second of media arr.reduce((p, index) =&gt; p.then(() =&gt; new Promise(resolve =&gt; { let recorder; let video = document.createElement("video"); video.onpause = e =&gt; { video.onpause = null; console.log(e); recorder.stop(); } video.oncanplay = () =&gt; { video.oncanplay = null; video.play(); let stream = video.captureStream(); recorder = new MediaRecorder(stream); recorder.start(); recorder.ondataavailable = e =&gt; { console.log("data event", recorder.state, e.data); chunks.push(e.data); } recorder.onstop = e =&gt; { resolve(); } } video.src = `${blobURL}#t=${index},${index+1}`; }) ), Promise.resolve()) .then(() =&gt; { console.log(chunks); let video = document.createElement("video"); video.controls = true; document.body.appendChild(video); let select = document.createElement("select"); document.body.appendChild(select); let option = new Option("select a segment"); select.appendChild(option); for (let chunk of chunks) { let index = chunks.indexOf(chunk); let option = new Option(`Play ${index}-${index + 1} seconds of media`, index); select.appendChild(option) } let fullMedia = new Blob(chunks, { type: mimeCodec }); let opt = new Option("Play full media", "Play full media"); select.appendChild(opt); select.onchange = () =&gt; { if (select.value !== "Play full media") { video.src = URL.createObjectURL(chunks[select.value]) } else { const mediaSource = new MediaSource(); video.src = URL.createObjectURL(mediaSource); mediaSource.addEventListener("sourceopen", sourceOpen); function sourceOpen(event) { // if the media type is supported by `mediaSource` // fetch resource, begin stream read, // append stream to `sourceBuffer` if (MediaSource.isTypeSupported(mimeCodec)) { var sourceBuffer = mediaSource.addSourceBuffer(mimeCodec); // set `sourceBuffer` `.mode` to `"sequence"` sourceBuffer.mode = "segments"; fetch(URL.createObjectURL(fullMedia)) // return `ReadableStream` of `response` .then(response =&gt; response.body.getReader()) .then(reader =&gt; { const processStream = (data) =&gt; { if (data.done) { return; } // append chunk of stream to `sourceBuffer` sourceBuffer.appendBuffer(data.value); } // at `sourceBuffer` `updateend` call `reader.read()`, // to read next chunk of stream, append chunk to // `sourceBuffer` sourceBuffer.addEventListener("updateend", function() { reader.read().then(processStream); }); // start processing stream reader.read().then(processStream); // do stuff `reader` is closed, // read of stream is complete return reader.closed.then(() =&gt; { // signal end of stream to `mediaSource` mediaSource.endOfStream(); return mediaSource.readyState; }) }) // do stuff when `reader.closed`, `mediaSource` stream ended .then(msg =&gt; console.log(msg)) .catch(err =&gt; console.log(err)) } // if `mimeCodec` is not supported by `MediaSource` else { alert(mimeCodec + " not supported"); } }; } } }) } media.src = blobURL; }) &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>using <code>Blob URL</code> at <code>else</code> statement at <code>select</code> <code>change</code> event, which only plays first second of media resource</p> <pre><code>video.src = URL.createObjectURL(fullMedia); </code></pre> <p>plnkr <a href="http://plnkr.co/edit/dNznvxe504JX7RWY658T?p=preview" rel="noreferrer">http://plnkr.co/edit/dNznvxe504JX7RWY658T?p=preview</a> version 1 <code>Blob URL</code>, version 2 <code>MediaSource</code></p>
0debug
void xen_cmos_set_s3_resume(void *opaque, int irq, int level) { pc_cmos_set_s3_resume(opaque, irq, level); if (level) { xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 3); } }
1threat
How can i express my code using functions? : How can i express my code by using functions, i have tried different solutions but still cant figure out how, any tip would help. It is a simple maze game that i have in my school, so it is a learning project and i dont need necessary the solution rather than any tip how to. x = 1 y = 1 valid_selection = True while True: if x == 1 and y == 1: if valid_selection == True: print("You can travel: (N)orth.") valid_selection = True choice = input("Direction: ") if choice.lower() == "n": y += 1 else: print("Not a valid direction!") valid_selection = False elif x == 1 and y == 2: if valid_selection == True: print("You can travel: (N)orth or (E)ast or (S)outh.") valid_selection = True choice = input("Direction: ") if choice.lower() == "n": y += 1 elif choice.lower() == "e": x += 1 elif choice.lower() == "s": y -= 1 else: print("Not a valid direction!") valid_selection = False elif x == 3 and y == 1: print("Victory!") break
0debug
static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = av_new_stream(c->fc, c->fc->nb_streams); if (!st) return AVERROR(ENOMEM); sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = CODEC_TYPE_DATA; sc->ffindex = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; if(sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))){ av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); sc->sample_count = 0; return 0; } if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= c->time_scale; av_set_pts_info(st, 64, sc->time_rate, sc->time_scale); if (st->codec->codec_type == CODEC_TYPE_AUDIO && !st->codec->frame_size && sc->stts_count == 1) { st->codec->frame_size = av_rescale(sc->stts_data[0].duration, st->codec->sample_rate, sc->time_scale); dprintf(c->fc, "frame size %d\n", st->codec->frame_size); } if(st->duration != AV_NOPTS_VALUE){ assert(st->duration % sc->time_rate == 0); st->duration /= sc->time_rate; } mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { if (url_fopen(&sc->pb, sc->drefs[sc->dref_id-1].path, URL_RDONLY) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening file %s: %s\n", st->index, sc->drefs[sc->dref_id-1].path, strerror(errno)); } else sc->pb = c->fc->pb; switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case CODEC_ID_MPEG4: #endif st->codec->width= 0; st->codec->height= 0; break; } av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); return 0; }
1threat
Is it possible to do this? : Admittedly im not a great coder ------------------------------------ So Im making a project for school and Its a dice game, This snippet of my code is like a catch 22 I need to define a variable otherwise it flags, so I do this but then every time the button is run it changes the value to zero instead of increasing it. > if Rollnop1 == 0 : > Userscore1 = Randomnumber > print ("User 1 ",Userscore1 ) > Rollnop1 = Rollnop1+1 #But this changes it so it will go to the next players roll, every > #time the button is pressed it changes the variable back to 0 ``` #========================================================================================# def gamerun(): global Player global usernamestr global passwordstr global usernamestr2 global passwordstr2 Rollnop1 = 0 def roll2(): Rollnop2 = 0 Randomnumber = random.randint(2,12) print ("Console: Random Number 2 = ",Randomnumber) if Rollnop2 == 0 : Userscore2 = Randomnumber print ("User 2 ",Userscore2 ) def roll1(): Rollnop1 = 0 #Need to define this here otherwise It wont work Randomnumber = random.randint(2,12) print ("Console: Random Number = ",Randomnumber) if Rollnop1 == 0 : Userscore1 = Randomnumber print ("User 1 ",Userscore1 ) Rollnop1 = Rollnop1+1 #But this changes it so it will go to the next players roll, every #time the button is pressed it changes the variable back to 0 else: roll2() actdicegame = Tk() gamerunl0 = Label(actdicegame, text = usernamestr, fg = "black") gamerunl0.pack() gamerunl1 = Label(actdicegame, text = "Roll The Dice", fg = "black") gamerunl1.pack() gamerunb1 = Button(actdicegame, text="ROLL",fg="Black", command=roll1)#Register Butto gamerunb1.pack() actdicegame.geometry("350x500") print ("Console: GUI RUNNING 1") actdicegame.mainloop() #========================================================================================# ```
0debug
Using time module in Python : <p>I have a text file named as 'time' and want to save the current date and time from the computer in the text file every-time the player plays the game(Snake and ladder). Please help me to figure it. I have tried making a function for it and add the current date in the file and append the new date and time in text file when the user plays the game but an error occurs every-time.</p>
0debug
tensorflow neural net with continuous / floating point output? : <p>I'm trying to create a simple neural net in tensorflow that learns some simple relationship between inputs and outputs (for example, y=-x) where the inputs and outputs are floating point values (meaning, no softmax used on the output).</p> <p>I feel like this should be pretty easy to do, but I must be messing up somewhere. Wondering if there are any tutorials or examples out there that do something similar. I looked through the existing tensorflow tutorials and didn't see anything like this and looked through several other sources of tensorflow examples I found by googling, but didn't see what I was looking for.</p> <p>Here's a trimmed down version of what I've been trying. In this particular version, I've noticed that my weights and biases always seem to be stuck at zero. Perhaps this is due to my single input and single output?</p> <p>I've had good luck altering the mist example for various nefarious purposes, but everything I've gotten to work successfully used softmax on the output for categorization. If I can figure out how to generate a raw floating point output from my neural net, there are several fun projects I'd like to do with it.</p> <p>Anyone see what I'm missing? Thanks in advance! - J.</p> <pre><code> # Trying to define the simplest possible neural net where the output layer of the neural net is a single # neuron with a "continuous" (a.k.a floating point) output. I want the neural net to output a continuous # value based off one or more continuous inputs. My real problem is more complex, but this is the simplest # representation of it for explaining my issue. Even though I've oversimplified this to look like a simple # linear regression problem (y=m*x), I want to apply this to more complex neural nets. But if I can't get # it working with this simple problem, then I won't get it working for anything more complex. import tensorflow as tf import random import numpy as np INPUT_DIMENSION = 1 OUTPUT_DIMENSION = 1 TRAINING_RUNS = 100 BATCH_SIZE = 10000 VERF_SIZE = 1 # Generate two arrays, the first array being the inputs that need trained on, and the second array containing outputs. def generate_test_point(): x = random.uniform(-8, 8) # To keep it simple, output is just -x. out = -x return ( np.array([ x ]), np.array([ out ]) ) # Generate a bunch of data points and then package them up in the array format needed by # tensorflow def generate_batch_data( num ): xs = [] ys = [] for i in range(num): x, y = generate_test_point() xs.append( x ) ys.append( y ) return (np.array(xs), np.array(ys) ) # Define a single-layer neural net. Originally based off the tensorflow mnist for beginners tutorial # Create a placeholder for our input variable x = tf.placeholder(tf.float32, [None, INPUT_DIMENSION]) # Create variables for our neural net weights and bias W = tf.Variable(tf.zeros([INPUT_DIMENSION, OUTPUT_DIMENSION])) b = tf.Variable(tf.zeros([OUTPUT_DIMENSION])) # Define the neural net. Note that since I'm not trying to classify digits as in the tensorflow mnist # tutorial, I have removed the softmax op. My expectation is that 'net' will return a floating point # value. net = tf.matmul(x, W) + b # Create a placeholder for the expected result during training expected = tf.placeholder(tf.float32, [None, OUTPUT_DIMENSION]) # Same training as used in mnist example cross_entropy = -tf.reduce_sum(expected*tf.log(tf.clip_by_value(net,1e-10,1.0))) train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy) sess = tf.Session() init = tf.initialize_all_variables() sess.run(init) # Perform our training runs for i in range( TRAINING_RUNS ): print "trainin run: ", i, batch_inputs, batch_outputs = generate_batch_data( BATCH_SIZE ) # I've found that my weights and bias values are always zero after training, and I'm not sure why. sess.run( train_step, feed_dict={x: batch_inputs, expected: batch_outputs}) # Test our accuracy as we train... I am defining my accuracy as the error between what I # expected and the actual output of the neural net. #accuracy = tf.reduce_mean(tf.sub( expected, net)) accuracy = tf.sub( expected, net) # using just subtract since I made my verification size 1 for debug # Uncomment this to debug #import pdb; pdb.set_trace() batch_inputs, batch_outputs = generate_batch_data( VERF_SIZE ) result = sess.run(accuracy, feed_dict={x: batch_inputs, expected: batch_outputs}) print " progress: " print " inputs: ", batch_inputs print " outputs:", batch_outputs print " actual: ", result </code></pre>
0debug
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) { AVStream *st; int len, ret, i; av_init_packet(pkt); for(;;) { st = s->cur_st; if (st) { if (!st->need_parsing || !st->parser) { *pkt = st->cur_pkt; st->cur_pkt.data= NULL; compute_pkt_fields(s, st, NULL, pkt); s->cur_st = NULL; if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && (pkt->flags & AV_PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) { ff_reduce_index(s, st->index); av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME); } break; } else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) { len = av_parser_parse2(st->parser, st->codec, &pkt->data, &pkt->size, st->cur_ptr, st->cur_len, st->cur_pkt.pts, st->cur_pkt.dts, st->cur_pkt.pos); st->cur_pkt.pts = AV_NOPTS_VALUE; st->cur_pkt.dts = AV_NOPTS_VALUE; st->cur_ptr += len; st->cur_len -= len; if (pkt->size) { got_packet: pkt->duration = 0; pkt->stream_index = st->index; pkt->pts = st->parser->pts; pkt->dts = st->parser->dts; pkt->pos = st->parser->pos; if(pkt->data == st->cur_pkt.data && pkt->size == st->cur_pkt.size){ s->cur_st = NULL; pkt->destruct= st->cur_pkt.destruct; st->cur_pkt.destruct= NULL; st->cur_pkt.data = NULL; assert(st->cur_len == 0); }else{ pkt->destruct = NULL; } compute_pkt_fields(s, st, st->parser, pkt); if((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & AV_PKT_FLAG_KEY){ int64_t pos= (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->pos : st->parser->frame_offset; ff_reduce_index(s, st->index); av_add_index_entry(st, pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME); } break; } } else { av_free_packet(&st->cur_pkt); s->cur_st = NULL; } } else { AVPacket cur_pkt; ret = av_read_packet(s, &cur_pkt); if (ret < 0) { if (ret == AVERROR(EAGAIN)) return ret; for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; if (st->parser && st->need_parsing) { av_parser_parse2(st->parser, st->codec, &pkt->data, &pkt->size, NULL, 0, AV_NOPTS_VALUE, AV_NOPTS_VALUE, AV_NOPTS_VALUE); if (pkt->size) goto got_packet; } } return ret; } st = s->streams[cur_pkt.stream_index]; st->cur_pkt= cur_pkt; if(st->cur_pkt.pts != AV_NOPTS_VALUE && st->cur_pkt.dts != AV_NOPTS_VALUE && st->cur_pkt.pts < st->cur_pkt.dts){ av_log(s, AV_LOG_WARNING, "Invalid timestamps stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d\n", st->cur_pkt.stream_index, st->cur_pkt.pts, st->cur_pkt.dts, st->cur_pkt.size); } if(s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", st->cur_pkt.stream_index, st->cur_pkt.pts, st->cur_pkt.dts, st->cur_pkt.size, st->cur_pkt.duration, st->cur_pkt.flags); s->cur_st = st; st->cur_ptr = st->cur_pkt.data; st->cur_len = st->cur_pkt.size; if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) { st->parser = av_parser_init(st->codec->codec_id); if (!st->parser) { av_log(s, AV_LOG_WARNING, "parser not found for codec " "%s, packets or times may be invalid.\n", avcodec_get_name(st->codec->codec_id)); st->need_parsing = AVSTREAM_PARSE_NONE; }else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){ st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; }else if(st->need_parsing == AVSTREAM_PARSE_FULL_ONCE){ st->parser->flags |= PARSER_FLAG_ONCE; } } } } if(s->debug & FF_FDEBUG_TS) av_log(s, AV_LOG_DEBUG, "read_frame_internal stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d, duration=%d, flags=%d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->size, pkt->duration, pkt->flags); return 0; }
1threat
static void test_visitor_out_enum_errors(TestOutputVisitorData *data, const void *unused) { EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 }; Error *err; for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { err = NULL; visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err); g_assert(err); error_free(err); visitor_reset(data); } }
1threat
.Net Core tag helper intellisense and color coding not working : <p>I am having issues with .NET core and tag helpers. The color coding and the intellisense are not displaying or being registered when I type in asp-for. I've tried creating a new solution in a separate instance, verified that the intellisense works, and then copied the project.json into the project that doesn't have working intellisense/color coding, and it doesn't fix the issue.</p> <p>Here is my project.json</p> <pre><code>{ "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0", "type": "platform" }, "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final", "Microsoft.AspNetCore.Diagnostics": "1.0.0", "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.1", "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", "Microsoft.AspNetCore.StaticFiles": "1.0.0", "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1", "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.AspNetCore.Routing": "1.0.1", "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview2-final", "type": "build" }, "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { "version": "1.0.0-preview2-final", "type": "build" }, "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": { "version": "1.0.0-preview2-final", "type": "build" } }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" }, "frameworks": { "netcoreapp1.0": { "imports": [ "dotnet5.6", "portable-net45+win8" ] } }, "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, "publishOptions": { "include": [ "wwwroot", "web.config" ] }, "scripts": { "prepublish": [ "bower install" ], "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] } } </code></pre> <p>I've also made the reference/injection in the _ViewImports file for the mvc tag helpers. This is the view where I'm testing that it works. <a href="https://i.stack.imgur.com/DWHyV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DWHyV.png" alt="enter image description here"></a></p> <p>And here is my project structure, just in case you can see something that I'm not seeing.</p> <p><a href="https://i.stack.imgur.com/SL2k4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SL2k4.png" alt="enter image description here"></a></p> <p>If it helps at all, here is the version of Visual Studio I am using.</p> <p><a href="https://i.stack.imgur.com/VFPT8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VFPT8.png" alt="enter image description here"></a></p>
0debug
How to use cronjobs with python email script? : <p>I am new to this, but am trying to learn. With a cronjob does it go in a complete other file or in the script its self? Here is my code if that helps.</p> <p><a href="https://i.stack.imgur.com/sXS7d.jpg" rel="nofollow noreferrer">My code</a></p> <p>I couldn't put in code with the code example so i did that.</p>
0debug
void bdrv_get_backing_filename(BlockDriverState *bs, char *filename, int filename_size) { if (!bs->backing_hd) { pstrcpy(filename, filename_size, ""); } else { pstrcpy(filename, filename_size, bs->backing_file); } }
1threat
How did Neil Patel make the text on http://www.quicksprout.com/pro dynamically insert the cirt name into the HTML? : <p>This is an awesome way to appeal to folks from the city that they are browsing from. Is this some kind of JS technique? Would love a link to an example or if it already exists on GitHub? Sorry for the newbie question--I'm new to front-end dev.</p> <p>Screenshot:</p> <p><a href="http://i.stack.imgur.com/sCWqD.png" rel="nofollow">Quicksprout site:</a></p>
0debug