problem
stringlengths
26
131k
labels
class label
2 classes
Determine when DOM Loaded : <p>I am in need of some JS assistance.</p> <p>I need to run some code after the DOM was updated.</p> <p>For example: when I click a button, it fires a function. I need to run that function code and when the DOM is fully updated, run some more code. How could I go about doing this in a clean fashion?</p> <p>I am sure this is relatively simple but I am drawing blanks. I am using jQuery.</p> <pre><code>$('.btn').click(function() { do some stuff // then ensure dom has fully updated and do some more???? }) </code></pre>
0debug
static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset, uint32_t value, MemTxAttrs attrs) { switch (offset) { case 0x00: gic_set_cpu_control(s, cpu, value, attrs); break; case 0x04: s->priority_mask[cpu] = (value & 0xff); break; case 0x08: if (s->security_extn && !attrs.secure) { s->abpr[cpu] = MAX(value & 0x7, GIC_MIN_ABPR); } else { s->bpr[cpu] = MAX(value & 0x7, GIC_MIN_BPR); } break; case 0x10: gic_complete_irq(s, cpu, value & 0x3ff); return MEMTX_OK; case 0x1c: if (!gic_has_groups(s) || (s->security_extn && !attrs.secure)) { return MEMTX_OK; } else { s->abpr[cpu] = MAX(value & 0x7, GIC_MIN_ABPR); } break; case 0xd0: case 0xd4: case 0xd8: case 0xdc: qemu_log_mask(LOG_UNIMP, "Writing APR not implemented\n"); break; default: qemu_log_mask(LOG_GUEST_ERROR, "gic_cpu_write: Bad offset %x\n", (int)offset); return MEMTX_ERROR; } gic_update(s); return MEMTX_OK; }
1threat
Retrieve multiple data from firebase to my android applciation : I am building an application that needs to retrieve a multiple data from my firebase database and store the data in my application. > This is my Database Structure, and I want to retrieve all data from 1 upto the last number as well as retrieve the data inside each number. [Click me to view image][1] [1]: https://i.stack.imgur.com/2YMRG.png Does anyone have any idea how to this? Thanks in advance.
0debug
NumPy: consequences of using 'np.save()' with 'allow_pickle=False' : <p>According to NumPy documentation <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html">here</a>, by default, a matrix is saved with <code>allow_pickle=True</code>, and furthermore, they tell what could be problematic with this default behavior:</p> <blockquote> <p>allow_pickle : bool, optional<br> Allow saving object arrays using Python pickles. Reasons for disallowing pickles include security (loading pickled data can execute arbitrary code) and portability (pickled objects may not be loadable on different Python installations, for example if the stored objects require libraries that are not available, and not all pickled data is compatible between Python 2 and Python 3). <br>Default: True</p> </blockquote> <p>After reading it, I would of course prefer to use <code>allow_pickle=False</code> - but they do not tell what is different when it is used this way. There must be some reason they use <code>allow_pickel=True</code> by default despite its disadvantages.</p> <p>Could you please tell whether you use <code>allow_pickle=False</code> and how it behaves differently?</p>
0debug
Why can’t name the variable const, but in objects can : <p>I wrote.</p> <pre><code>let const = 10; </code></pre> <p>and got error.and for objects everything works</p> <pre><code>let x = {const:10} </code></pre> <p>What is the difference.</p>
0debug
static int encrypt_sectors(BDRVQcowState *s, int64_t sector_num, uint8_t *buf, int nb_sectors, bool enc, Error **errp) { union { uint64_t ll[2]; uint8_t b[16]; } ivec; int i; int ret; for(i = 0; i < nb_sectors; i++) { ivec.ll[0] = cpu_to_le64(sector_num); ivec.ll[1] = 0; if (qcrypto_cipher_setiv(s->cipher, ivec.b, G_N_ELEMENTS(ivec.b), errp) < 0) { return -1; } if (enc) { ret = qcrypto_cipher_encrypt(s->cipher, buf, buf, 512, errp); } else { ret = qcrypto_cipher_decrypt(s->cipher, buf, buf, 512, errp); } if (ret < 0) { return -1; } sector_num++; buf += 512; } return 0; }
1threat
static void mem_add(MemoryListener *listener, MemoryRegionSection *section) { AddressSpaceDispatch *d = container_of(listener, AddressSpaceDispatch, listener); MemoryRegionSection now = limit(*section), remain = limit(*section); if ((now.offset_within_address_space & ~TARGET_PAGE_MASK) || (now.size < TARGET_PAGE_SIZE)) { now.size = MIN(TARGET_PAGE_ALIGN(now.offset_within_address_space) - now.offset_within_address_space, now.size); register_subpage(d, &now); remain.size -= now.size; remain.offset_within_address_space += now.size; remain.offset_within_region += now.size; } while (remain.size >= TARGET_PAGE_SIZE) { now = remain; if (remain.offset_within_region & ~TARGET_PAGE_MASK) { now.size = TARGET_PAGE_SIZE; register_subpage(d, &now); } else { now.size &= TARGET_PAGE_MASK; register_multipage(d, &now); } remain.size -= now.size; remain.offset_within_address_space += now.size; remain.offset_within_region += now.size; } now = remain; if (now.size) { register_subpage(d, &now); } }
1threat
The line number on the SQL Editor in DBeaver : <p>How to toggle the line number on the SQL Editor in <em>DBeaver</em>?</p> <p>I can't find this option in <em>Window / Preferences / General / Editors / SQL Editor</em>.</p> <p>Is it possible to do this?</p>
0debug
static int vnc_display_connect(VncDisplay *vd, SocketAddress **saddr, size_t nsaddr, SocketAddress **wsaddr, size_t nwsaddr, Error **errp) { QIOChannelSocket *sioc = NULL; if (nwsaddr != 0) { error_setg(errp, "Cannot use websockets in reverse mode"); return -1; } if (nsaddr != 1) { error_setg(errp, "Expected a single address in reverse mode"); return -1; } vd->is_unix = saddr[0]->type == SOCKET_ADDRESS_KIND_UNIX; sioc = qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse"); if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) { return -1; } vnc_connect(vd, sioc, false, false); object_unref(OBJECT(sioc)); return 0; }
1threat
static int http_connect(URLContext *h, const char *path, const char *local_path, const char *hoststr, const char *auth, const char *proxyauth, int *new_location) { HTTPContext *s = h->priv_data; int post, err; char headers[1024] = ""; char *authstr = NULL, *proxyauthstr = NULL; int64_t off = s->off; int len = 0; const char *method; post = h->flags & AVIO_FLAG_WRITE; if (s->post_data) { post = 1; s->chunked_post = 0; } method = post ? "POST" : "GET"; authstr = ff_http_auth_create_response(&s->auth_state, auth, local_path, method); proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth, local_path, method); if (!has_header(s->headers, "\r\nUser-Agent: ")) len += av_strlcatf(headers + len, sizeof(headers) - len, "User-Agent: %s\r\n", LIBAVFORMAT_IDENT); if (!has_header(s->headers, "\r\nAccept: ")) len += av_strlcpy(headers + len, "Accept: * if (s->headers) av_strlcpy(headers + len, s->headers, sizeof(headers) - len); snprintf(s->buffer, sizeof(s->buffer), "%s %s HTTP/1.1\r\n" "%s" "%s" "%s" "%s%s" "\r\n", method, path, post && s->chunked_post ? "Transfer-Encoding: chunked\r\n" : "", headers, authstr ? authstr : "", proxyauthstr ? "Proxy-" : "", proxyauthstr ? proxyauthstr : ""); av_freep(&authstr); av_freep(&proxyauthstr); if ((err = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) return err; if (s->post_data) if ((err = ffurl_write(s->hd, s->post_data, s->post_datalen)) < 0) return err; s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->off = 0; s->filesize = -1; s->willclose = 0; s->end_chunked_post = 0; s->end_header = 0; if (post && !s->post_data) { s->http_code = 200; return 0; } err = http_read_header(h, new_location); if (err < 0) return err; return (off == s->off) ? 0 : -1; }
1threat
Download fb videos, I have attached two images, just need download after on click : I have attached two image: -------------------------- first is: my link where fb video link second is: after click video opening & play **Actually I want to download this video from the url when user click on the link then video will be download but currently its opening video & play.... but I don't want this, I want to download this video when click on link or click on button then facebook video will start downloading! Thanks in advanced. You can suggest me please** [My FB Video Link image][1] [After Click the link its open like this image, but I don't want this][2] [1]: https://i.stack.imgur.com/RK17r.png [2]: https://i.stack.imgur.com/cwgH6.png
0debug
What does %d do in this line? : <p>What does %d do in this line of my code?</p> <pre><code>puppy+="and Puppy %d (User %d) "%((j+1),(i+1)) </code></pre> <p>Here's my code.</p> <pre><code>u=int(input("Number of users:")) puppy="" for i in range (0,u): upos=input("Position of User "+str(i+1)+":") upos_list=upos.split() upos_x=int(upos_list[0]) upos_y=int(upos_list[1]) p=input("Number of puppies for User "+str(i+1)+":") for j in range (0,int(p)): ppos=input("Position of Puppy "+str(j+1)+":") ppos_list=ppos.split() ppos_x=int(ppos_list[0]) ppos_y=int(ppos_list[1]) d=abs((ppos_x)-(upos_x))+abs((ppos_y)-(upos_y)) if d&gt;10: puppy+="and Puppy %d (User %d) "%((j+1),(i+1)) if puppy=="": print("No puppies too far away") else: print(puppy[4:]+"too far away") </code></pre> <p>Here's the input and output for your reference.</p> <p><a href="https://i.stack.imgur.com/EyvfX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EyvfX.png" alt="Here&#39;s the input and output for reference"></a></p>
0debug
UWP ObservableCollection sorting and grouping : <p>In UWP apps, how can you group and sort an ObservableCollection and keep all the live notification goodness? </p> <p>In most simple UWP examples I've seen, there is generally a ViewModel that exposes an ObservableCollection which is then bound to a ListView in the View. When items are added or removed from the ObservableCollection, the ListView automatically reflects the changes by reacting to the INotifyCollectionChanged notifications. This all works fine in the case of an unsorted or ungrouped ObservableCollection, but if the collection needs to be sorted or grouped, there seems to be no readily apparent way to preserve the update notifications. What's more, changing the sort or group order on the fly seems to throw up significant implementation issues.</p> <p>++ </p> <p>Take a scenario where you have an existing datacache backend that exposes an ObservableCollection of very simple class Contact.</p> <pre><code>public class Contact { public string FirstName { get; set; } public string LastName { get; set; } public string State { get; set; } } </code></pre> <p>This ObservableCollection changes over time, and we want to present a realtime grouped and sorted list in the view that updates in response to changes in the datacache. We also want to give the user the option to switch the grouping between LastName and State on the fly.</p> <p>++</p> <p>In a WPF world, this is relatively trivial. We can create a simple ViewModel referencing the datacache that presents the cache's Contacts collection as-is.</p> <pre><code>public class WpfViewModel { public WpfViewModel() { _cache = GetCache(); } Cache _cache; public ObservableCollection&lt;Contact&gt; Contacts { get { return _cache.Contacts; } } } </code></pre> <p>Then we can bind this to a view where we implement a CollectionViewSource and Sort and Group definitions as XAML resources.</p> <pre><code>&lt;Window ..... xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"&gt; &lt;Window.DataContext&gt; &lt;local:WpfViewModel /&gt; &lt;/Window.DataContext&gt; &lt;Window.Resources&gt; &lt;CollectionViewSource x:Key="cvs" Source="{Binding Contacts}" /&gt; &lt;PropertyGroupDescription x:Key="stategroup" PropertyName="State" /&gt; &lt;PropertyGroupDescription x:Key="initialgroup" PropertyName="LastName[0]" /&gt; &lt;scm:SortDescription x:Key="statesort" PropertyName="State" Direction="Ascending" /&gt; &lt;scm:SortDescription x:Key="lastsort" PropertyName="LastName" Direction="Ascending" /&gt; &lt;scm:SortDescription x:Key="firstsort" PropertyName="FirstName" Direction="Ascending" /&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="*" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;ListView ItemsSource="{Binding Source={StaticResource cvs}}"&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="100" /&gt; &lt;ColumnDefinition Width="100" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TextBlock Text="{Binding LastName}" /&gt; &lt;TextBlock Text="{Binding FirstName}" Grid.Column="1" /&gt; &lt;TextBlock Text="{Binding State}" Grid.Column="2" /&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; &lt;ListView.GroupStyle&gt; &lt;GroupStyle&gt; &lt;GroupStyle.HeaderTemplate&gt; &lt;DataTemplate&gt; &lt;Grid Background="Gainsboro"&gt; &lt;TextBlock FontWeight="Bold" FontSize="14" Margin="10,2" Text="{Binding Name}"/&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/GroupStyle.HeaderTemplate&gt; &lt;/GroupStyle&gt; &lt;/ListView.GroupStyle&gt; &lt;/ListView&gt; &lt;StackPanel Orientation="Horizontal" Grid.Row="1"&gt; &lt;Button Content="Group By Initial" Click="InitialGroupClick" /&gt; &lt;Button Content="Group By State" Click="StateGroupClick" /&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>Then when the user clicks on the GroupBy buttons at the bottom of the window we can we can group and sort on the fly in code-behind.</p> <pre><code>private void InitialGroupClick(object sender, RoutedEventArgs e) { var cvs = FindResource("cvs") as CollectionViewSource; var initialGroup = (PropertyGroupDescription)FindResource("initialgroup"); var firstSort = (SortDescription)FindResource("firstsort"); var lastSort = (SortDescription)FindResource("lastsort"); using (cvs.DeferRefresh()) { cvs.GroupDescriptions.Clear(); cvs.SortDescriptions.Clear(); cvs.GroupDescriptions.Add(initialGroup); cvs.SortDescriptions.Add(lastSort); cvs.SortDescriptions.Add(firstSort); } } private void StateGroupClick(object sender, RoutedEventArgs e) { var cvs = FindResource("cvs") as CollectionViewSource; var stateGroup = (PropertyGroupDescription)FindResource("stategroup"); var stateSort = (SortDescription)FindResource("statesort"); var lastSort = (SortDescription)FindResource("lastsort"); var firstSort = (SortDescription)FindResource("firstsort"); using (cvs.DeferRefresh()) { cvs.GroupDescriptions.Clear(); cvs.SortDescriptions.Clear(); cvs.GroupDescriptions.Add(stateGroup); cvs.SortDescriptions.Add(stateSort); cvs.SortDescriptions.Add(lastSort); cvs.SortDescriptions.Add(firstSort); } } </code></pre> <p>This all works fine, and the items are updated automatically as the data cache collection changes. The Listview grouping and selection remains unaffected by collection changes, and the new contact items are correctly grouped.The grouping can be swapped between State and LastName initial by user at runtime.</p> <p>++</p> <p>In the UWP world, the CollectionViewSource no longer has the GroupDescriptions and SortDescriptions collections, and sorting/grouping need to be carried out at the ViewModel level. The closest approach to a workable solution I've found is along the lines of Microsoft's sample package at</p> <p><a href="https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlListView" rel="noreferrer">https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlListView</a></p> <p>and this article</p> <p><a href="http://motzcod.es/post/94643411707/enhancing-xamarinforms-listview-with-grouping" rel="noreferrer">http://motzcod.es/post/94643411707/enhancing-xamarinforms-listview-with-grouping</a></p> <p>where the ViewModel groups the ObservableCollection using Linq and presents it to the view as an ObservableCollection of grouped items</p> <pre><code>public ObservableCollection&lt;GroupInfoList&gt; GroupedContacts { ObservableCollection&lt;GroupInfoList&gt; groups = new ObservableCollection&lt;GroupInfoList&gt;(); var query = from item in _cache.Contacts group item by item.LastName[0] into g orderby g.Key select new { GroupName = g.Key, Items = g }; foreach (var g in query) { GroupInfoList info = new GroupInfoList(); info.Key = g.GroupName; foreach (var item in g.Items) { info.Add(item); } groups.Add(info); } return groups; } </code></pre> <p>where GroupInfoList is defined as </p> <pre><code>public class GroupInfoList : List&lt;object&gt; { public object Key { get; set; } } </code></pre> <p>This does at least get us a grouped collection displayed in the View, but updates to the datacache collection are no longer reflected in real time. We could capture the datacache's CollectionChanged event and use it in the viewmodel to refresh the GroupedContacts collection, but this creates a new collection for every change in the datacache, causing the ListView to flicker and reset selection etc which is clearly suboptimal.</p> <p>Also swapping the grouping on the fly would seem to require a completely seperate ObservableCollection of grouped items for each grouping scenario, and for the ListView's ItemSource binding to be swapped at runtime.</p> <p>The rest of what I've seen of the UWP environment seems extremely useful, so I'm surprised to find something as vital as grouping and sorting lists throwing up obstacles...</p> <p>Anyone know how to do this properly?</p>
0debug
Mystical anomaly with getch(); : Today i was testing how key pressing might work in C++ and made simple loop for it,and found that getch() duplicate itself for some reason or idk what is going on honestly,just look at that: #include <iostream> #include <windows.h> #include <conio.h> #define VK_H 0x48 using namespace std; int main() { int n=1; int total=0; bool theEnd=true; while(theEnd) { cout<<total<<endl; getch(); if(GetAsyncKeyState(VK_LEFT)) { total -=n; }else if(GetAsyncKeyState(VK_RIGHT)) { total +=n; }else if(GetAsyncKeyState(VK_LSHIFT) && GetAsyncKeyState(VK_F1)) { total = 0; } else if(GetAsyncKeyState(VK_ESCAPE)) { break; } } cout<<total<<endl; } Its pretty simple.Program starts with a loop,where endlessly outputs value of variable "total",and after pressing left/right buttons "total" decrements/increments by 1. Its was worked fine and perfect when i was using system("pause"); Sleep(milliseconds); cin.get();*(but this one assume pressing enter each time,so it is not proper one)* ,all that output right value on the screen after each pressing on the buttons.But in case with getch(); it somehow appear to working like only one time per/two cycles of the loop. So the result i've get is like this: i'm pressing button right - current loop working fine,but next one working like without getch()... I've siting and thinking couple hours,trying find any answers in google and here but nothing... P.S.without using getch() or other things for purpose stoping loop till next pressing - it will add not +1 to total by single pressing(as i need),but hundreds(average pressing key will do 150-300 loops lol).
0debug
How can I validate email in this PHP contact form? : <p>is there a way to validate an email in this form without rewriting it completely? It'd be great if I could just add something to this. I'm new to PHP and this form is taken from mmtuts video. If you know how to help, I'd be glad if you did.</p> <pre><code>&lt;?php if (isset($_POST['submit'])) { $name = $_POST['name']; $number = $_POST['number']; $subject = $_POST['subject']; $mailFrom = $_POST['mail']; $message = $_POST['message']; $mailTo = "misavoz@seznam.cz"; $headers = "From: ".$mailFrom; $txt = "Pan/í ".$name." vám poslal/a zprávu. Telefonní číslo: ".$number."\n\n".$message; mail($mailTo, $subject, $txt, $headers); header("Location: index.php?mailsend"); } </code></pre>
0debug
C++ Why make new int is error ?? : Why my code error ? int *x ; x = new int[5]; x[0] = 3; x[1] = 4; x[2] = 5; x[3] = 1; x[4] = 2; x[5] = 11; x[6] = 90; int *y ; y = new int[5]; cout << "if no error, then this command should be run" << endl; but the output is : Process exited after 0.07883 seconds with return value 3221226356 Press any key to continue . . .
0debug
startActivity cannot start another activty without any exception : <p>My application got crash when tried to call startActivity(intent) to start new activity. But there is no any exception in LogCat. Is there any best way to catch the root cause?</p>
0debug
int inet_connect(const char *str, bool block, Error **errp) { QemuOpts *opts; int sock = -1; opts = qemu_opts_create(&dummy_opts, NULL, 0); if (inet_parse(opts, str) == 0) { if (block) { qemu_opt_set(opts, "block", "on"); } sock = inet_connect_opts(opts, errp); } else { error_set(errp, QERR_SOCKET_CREATE_FAILED); } qemu_opts_del(opts); return sock; }
1threat
Pet.Acropromazine(): Not all code paths return a value : <p>I am trying to make a class for a pet name, age, weight and if it is a dog or cat and the have to methods to calculate the dosage for Aceptomazine and Carprofen. I want to return a different value for both the Aceptomazine and Carprofen method for a cat and a dog but when I do it says Pet.Acropromazine: not all code paths return a value and the same error for the Carprofen method. I am not sure why it's doing this. any help would be appericated</p> <pre><code> class Pet { private string mName; private int mAge; private double mWeight; private string mType; public string Name { get { return mName; } set { if (string.IsNullOrEmpty(value) ) { mName = value; } else { throw new Exception("Name cannot be empty"); } } } public int Age { get { return mAge; } set { if (value &gt; 1) { mAge = value; } else { throw new Exception("Age must be greater than 1"); } } } public double Weight { get { return mWeight; } set { if (value &gt; 5) { mWeight = value; } else { throw new Exception("Age must be greater than 5"); } } } public Pet() { mName = "Super Pet"; mType = "Dog"; mAge = 1; mWeight = 5; } public double Acropromazine() { if (mType == "Dog") { return (mWeight / 2.205) * (0.03 / 10); } else if(mType =="Cat") { return (mWeight / 2.205) * (0.002/ 10); } } public double Carprofen() { if (mType == "Dog") { return (mWeight / 2.205) * (0.5 / 10); } else if (mType == "Cat") { return (mWeight / 2.205) * (0.25 / 10); } } } </code></pre>
0debug
static void ehci_queues_rip_device(EHCIState *ehci, USBDevice *dev) { EHCIQueue *q, *tmp; QTAILQ_FOREACH_SAFE(q, &ehci->queues, next, tmp) { if (q->packet.owner == NULL || q->packet.owner->dev != dev) { continue; } ehci_free_queue(q); } }
1threat
static void qobject_input_start_struct(Visitor *v, const char *name, void **obj, size_t size, Error **errp) { QObjectInputVisitor *qiv = to_qiv(v); QObject *qobj = qobject_input_get_object(qiv, name, true, errp); if (obj) { *obj = NULL; } if (!qobj) { return; } if (qobject_type(qobj) != QTYPE_QDICT) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "QDict"); return; } qobject_input_push(qiv, qobj, obj); if (obj) { *obj = g_malloc0(size); } }
1threat
Prorgam not outputting variable : I am new to C++ and want to make a simple program to find common factors between 2 numbers. I am using MSYS2 to compile. My code compiles with no errors, however the program won't output anything after defining the lrg variable Here is the code: #include <iostream> #include <algorithm> using namespace std; int main() { int num1; int num2; std::cout << "Enter the first number:"; std::cin >> num1; std::cout << "Enter the second number:"; std::cin >> num2; int lrg = std::max(num1,num2); std::cout << "The largest number is " << lrg; for (int i = 0; i < lrg; i++) { if (num1 % i == 0 && num2 % i == 0) { std::cout << i; }; }; return 0; } When I compile and run I do not get the largest number nor the common factors. Please tell me what I am doing wrong. Thanks!
0debug
static S390PCIBusDevice *s390_pci_find_dev_by_uid(uint16_t uid) { int i; S390PCIBusDevice *pbdev; S390pciState *s = s390_get_phb(); for (i = 0; i < PCI_SLOT_MAX; i++) { pbdev = s->pbdev[i]; if (!pbdev) { continue; } if (pbdev->uid == uid) { return pbdev; } } return NULL; }
1threat
Bash Regex: Remove charcters from filenames : <p>How we can bulk rename multiple files? What I seek is a regex approach to remove random characters from the beginning of the filenames?</p> <p>For example suppose I have the following files in a directory </p> <pre><code>_3cc10c0294ce15295e17e737a1d4dde1_C1W2L08.pptx _7beaa0a223aca1d64505e8382275bb8e_C1W2L09-2.05.53-PM.pptx _090fd2695e7f30570037a0fae658035a_C1W2L07.pptx </code></pre> <p>and here is what i intend to see:</p> <pre><code>C1W2L08.pptx C1W2L09-2.05.53-PM.pptx C1W2L07.pptx </code></pre>
0debug
static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; ADPCMDecodeContext *c = avctx->priv_data; ADPCMChannelStatus *cs; int n, m, channel, i; short *samples; const uint8_t *src; int st; int count1, count2; int nb_samples, coded_samples, ret; nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples); if (nb_samples <= 0) { av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n"); return AVERROR_INVALIDDATA; } c->frame.nb_samples = nb_samples; if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } samples = (short *)c->frame.data[0]; if (coded_samples) { if (coded_samples != nb_samples) av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n"); c->frame.nb_samples = nb_samples = coded_samples; } src = buf; st = avctx->channels == 2 ? 1 : 0; switch(avctx->codec->id) { case CODEC_ID_ADPCM_IMA_QT: for (channel = 0; channel < avctx->channels; channel++) { int16_t predictor; int step_index; cs = &(c->status[channel]); predictor = AV_RB16(src); step_index = predictor & 0x7F; predictor &= 0xFF80; src += 2; if (cs->step_index == step_index) { int diff = (int)predictor - cs->predictor; if (diff < 0) diff = - diff; if (diff > 0x7f) goto update; } else { update: cs->step_index = step_index; cs->predictor = predictor; } if (cs->step_index > 88){ av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); cs->step_index = 88; } samples = (short *)c->frame.data[0] + channel; for (m = 0; m < 32; m++) { *samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3); samples += avctx->channels; *samples = adpcm_ima_qt_expand_nibble(cs, src[0] >> 4 , 3); samples += avctx->channels; src ++; } } break; case CODEC_ID_ADPCM_IMA_WAV: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; for(i=0; i<avctx->channels; i++){ cs = &(c->status[i]); cs->predictor = *samples++ = (int16_t)bytestream_get_le16(&src); cs->step_index = *src++; if (cs->step_index > 88){ av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); cs->step_index = 88; } if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null but is %d!!\n", src[-1]); } for (n = (nb_samples - 1) / 8; n > 0; n--) { for (i = 0; i < avctx->channels; i++) { cs = &c->status[i]; for (m = 0; m < 4; m++) { uint8_t v = *src++; *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 3); samples += avctx->channels; *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 3); samples += avctx->channels; } samples -= 8 * avctx->channels - 1; } samples += 7 * avctx->channels; } break; case CODEC_ID_ADPCM_4XM: for (i = 0; i < avctx->channels; i++) c->status[i].predictor= (int16_t)bytestream_get_le16(&src); for (i = 0; i < avctx->channels; i++) { c->status[i].step_index= (int16_t)bytestream_get_le16(&src); c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88); } for (i = 0; i < avctx->channels; i++) { samples = (short *)c->frame.data[0] + i; cs = &c->status[i]; for (n = nb_samples >> 1; n > 0; n--, src++) { uint8_t v = *src; *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 4); samples += avctx->channels; *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 4); samples += avctx->channels; } } break; case CODEC_ID_ADPCM_MS: { int block_predictor; if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; block_predictor = av_clip(*src++, 0, 6); c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor]; c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor]; if (st) { block_predictor = av_clip(*src++, 0, 6); c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor]; c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor]; } c->status[0].idelta = (int16_t)bytestream_get_le16(&src); if (st){ c->status[1].idelta = (int16_t)bytestream_get_le16(&src); } c->status[0].sample1 = bytestream_get_le16(&src); if (st) c->status[1].sample1 = bytestream_get_le16(&src); c->status[0].sample2 = bytestream_get_le16(&src); if (st) c->status[1].sample2 = bytestream_get_le16(&src); *samples++ = c->status[0].sample2; if (st) *samples++ = c->status[1].sample2; *samples++ = c->status[0].sample1; if (st) *samples++ = c->status[1].sample1; for(n = (nb_samples - 2) >> (1 - st); n > 0; n--, src++) { *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], src[0] >> 4 ); *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F); } break; } case CODEC_ID_ADPCM_IMA_DK4: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; for (channel = 0; channel < avctx->channels; channel++) { cs = &c->status[channel]; cs->predictor = (int16_t)bytestream_get_le16(&src); cs->step_index = av_clip(*src++, 0, 88); src++; *samples++ = cs->predictor; } for (n = nb_samples >> (1 - st); n > 0; n--, src++) { uint8_t v = *src; *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3); } break; case CODEC_ID_ADPCM_IMA_DK3: { unsigned char last_byte = 0; unsigned char nibble; int decode_top_nibble_next = 0; int end_of_packet = 0; int diff_channel; if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; c->status[0].predictor = (int16_t)AV_RL16(src + 10); c->status[1].predictor = (int16_t)AV_RL16(src + 12); c->status[0].step_index = av_clip(src[14], 0, 88); c->status[1].step_index = av_clip(src[15], 0, 88); src += 16; diff_channel = c->status[1].predictor; while (1) { DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[0], nibble, 3); DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[1], nibble, 3); diff_channel = (diff_channel + c->status[1].predictor) / 2; *samples++ = c->status[0].predictor + c->status[1].predictor; *samples++ = c->status[0].predictor - c->status[1].predictor; DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[0], nibble, 3); diff_channel = (diff_channel + c->status[1].predictor) / 2; *samples++ = c->status[0].predictor + c->status[1].predictor; *samples++ = c->status[0].predictor - c->status[1].predictor; } break; } case CODEC_ID_ADPCM_IMA_ISS: for (channel = 0; channel < avctx->channels; channel++) { cs = &c->status[channel]; cs->predictor = (int16_t)bytestream_get_le16(&src); cs->step_index = av_clip(*src++, 0, 88); src++; } for (n = nb_samples >> (1 - st); n > 0; n--, src++) { uint8_t v1, v2; uint8_t v = *src; if (st) { v1 = v >> 4; v2 = v & 0x0F; } else { v2 = v >> 4; v1 = v & 0x0F; } *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v1, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3); } break; case CODEC_ID_ADPCM_IMA_APC: while (src < buf + buf_size) { uint8_t v = *src++; *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3); } break; case CODEC_ID_ADPCM_IMA_WS: for (channel = 0; channel < avctx->channels; channel++) { const uint8_t *src0; int src_stride; int16_t *smp = samples + channel; if (c->vqa_version == 3) { src0 = src + channel * buf_size / 2; src_stride = 1; } else { src0 = src + channel; src_stride = avctx->channels; } for (n = nb_samples / 2; n > 0; n--) { uint8_t v = *src0; src0 += src_stride; *smp = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3); smp += avctx->channels; *smp = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3); smp += avctx->channels; } } src = buf + buf_size; break; case CODEC_ID_ADPCM_XA: while (buf_size >= 128) { xa_decode(samples, src, &c->status[0], &c->status[1], avctx->channels); src += 128; samples += 28 * 8; buf_size -= 128; } break; case CODEC_ID_ADPCM_IMA_EA_EACS: src += 4; for (i=0; i<=st; i++) c->status[i].step_index = av_clip(bytestream_get_le32(&src), 0, 88); for (i=0; i<=st; i++) c->status[i].predictor = bytestream_get_le32(&src); for (n = nb_samples >> (1 - st); n > 0; n--, src++) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], *src>>4, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], *src&0x0F, 3); } break; case CODEC_ID_ADPCM_IMA_EA_SEAD: for (n = nb_samples >> (1 - st); n > 0; n--, src++) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] >> 4, 6); *samples++ = adpcm_ima_expand_nibble(&c->status[st],src[0]&0x0F, 6); } break; case CODEC_ID_ADPCM_EA: { int32_t previous_left_sample, previous_right_sample; int32_t current_left_sample, current_right_sample; int32_t next_left_sample, next_right_sample; int32_t coeff1l, coeff2l, coeff1r, coeff2r; uint8_t shift_left, shift_right; src += 4; current_left_sample = (int16_t)bytestream_get_le16(&src); previous_left_sample = (int16_t)bytestream_get_le16(&src); current_right_sample = (int16_t)bytestream_get_le16(&src); previous_right_sample = (int16_t)bytestream_get_le16(&src); for (count1 = 0; count1 < nb_samples / 28; count1++) { coeff1l = ea_adpcm_table[ *src >> 4 ]; coeff2l = ea_adpcm_table[(*src >> 4 ) + 4]; coeff1r = ea_adpcm_table[*src & 0x0F]; coeff2r = ea_adpcm_table[(*src & 0x0F) + 4]; src++; shift_left = 20 - (*src >> 4); shift_right = 20 - (*src & 0x0F); src++; for (count2 = 0; count2 < 28; count2++) { next_left_sample = sign_extend(*src >> 4, 4) << shift_left; next_right_sample = sign_extend(*src, 4) << shift_right; src++; next_left_sample = (next_left_sample + (current_left_sample * coeff1l) + (previous_left_sample * coeff2l) + 0x80) >> 8; next_right_sample = (next_right_sample + (current_right_sample * coeff1r) + (previous_right_sample * coeff2r) + 0x80) >> 8; previous_left_sample = current_left_sample; current_left_sample = av_clip_int16(next_left_sample); previous_right_sample = current_right_sample; current_right_sample = av_clip_int16(next_right_sample); *samples++ = (unsigned short)current_left_sample; *samples++ = (unsigned short)current_right_sample; } } if (src - buf == buf_size - 2) src += 2; break; } case CODEC_ID_ADPCM_EA_MAXIS_XA: { int coeff[2][2], shift[2]; for(channel = 0; channel < avctx->channels; channel++) { for (i=0; i<2; i++) coeff[channel][i] = ea_adpcm_table[(*src >> 4) + 4*i]; shift[channel] = 20 - (*src & 0x0F); src++; } for (count1 = 0; count1 < nb_samples / 2; count1++) { for(i = 4; i >= 0; i-=4) { for(channel = 0; channel < avctx->channels; channel++) { int32_t sample = sign_extend(src[channel] >> i, 4) << shift[channel]; sample = (sample + c->status[channel].sample1 * coeff[channel][0] + c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8; c->status[channel].sample2 = c->status[channel].sample1; c->status[channel].sample1 = av_clip_int16(sample); *samples++ = c->status[channel].sample1; } } src+=avctx->channels; } src = buf + buf_size; break; } case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: case CODEC_ID_ADPCM_EA_R3: { const int big_endian = avctx->codec->id == CODEC_ID_ADPCM_EA_R3; int32_t previous_sample, current_sample, next_sample; int32_t coeff1, coeff2; uint8_t shift; unsigned int channel; uint16_t *samplesC; const uint8_t *srcC; const uint8_t *src_end = buf + buf_size; int count = 0; src += 4; for (channel=0; channel<avctx->channels; channel++) { int32_t offset = (big_endian ? bytestream_get_be32(&src) : bytestream_get_le32(&src)) + (avctx->channels-channel-1) * 4; if ((offset < 0) || (offset >= src_end - src - 4)) break; srcC = src + offset; samplesC = samples + channel; if (avctx->codec->id == CODEC_ID_ADPCM_EA_R1) { current_sample = (int16_t)bytestream_get_le16(&srcC); previous_sample = (int16_t)bytestream_get_le16(&srcC); } else { current_sample = c->status[channel].predictor; previous_sample = c->status[channel].prev_sample; } for (count1 = 0; count1 < nb_samples / 28; count1++) { if (*srcC == 0xEE) { srcC++; if (srcC > src_end - 30*2) break; current_sample = (int16_t)bytestream_get_be16(&srcC); previous_sample = (int16_t)bytestream_get_be16(&srcC); for (count2=0; count2<28; count2++) { *samplesC = (int16_t)bytestream_get_be16(&srcC); samplesC += avctx->channels; } } else { coeff1 = ea_adpcm_table[ *srcC>>4 ]; coeff2 = ea_adpcm_table[(*srcC>>4) + 4]; shift = 20 - (*srcC++ & 0x0F); if (srcC > src_end - 14) break; for (count2=0; count2<28; count2++) { if (count2 & 1) next_sample = sign_extend(*srcC++, 4) << shift; else next_sample = sign_extend(*srcC >> 4, 4) << shift; next_sample += (current_sample * coeff1) + (previous_sample * coeff2); next_sample = av_clip_int16(next_sample >> 8); previous_sample = current_sample; current_sample = next_sample; *samplesC = current_sample; samplesC += avctx->channels; } } } if (!count) { count = count1; } else if (count != count1) { av_log(avctx, AV_LOG_WARNING, "per-channel sample count mismatch\n"); count = FFMAX(count, count1); } if (avctx->codec->id != CODEC_ID_ADPCM_EA_R1) { c->status[channel].predictor = current_sample; c->status[channel].prev_sample = previous_sample; } } c->frame.nb_samples = count * 28; src = src_end; break; } case CODEC_ID_ADPCM_EA_XAS: for (channel=0; channel<avctx->channels; channel++) { int coeff[2][4], shift[4]; short *s2, *s = &samples[channel]; for (n=0; n<4; n++, s+=32*avctx->channels) { for (i=0; i<2; i++) coeff[i][n] = ea_adpcm_table[(src[0]&0x0F)+4*i]; shift[n] = 20 - (src[2] & 0x0F); for (s2=s, i=0; i<2; i++, src+=2, s2+=avctx->channels) s2[0] = (src[0]&0xF0) + (src[1]<<8); } for (m=2; m<32; m+=2) { s = &samples[m*avctx->channels + channel]; for (n=0; n<4; n++, src++, s+=32*avctx->channels) { for (s2=s, i=0; i<8; i+=4, s2+=avctx->channels) { int level = sign_extend(*src >> (4 - i), 4) << shift[n]; int pred = s2[-1*avctx->channels] * coeff[0][n] + s2[-2*avctx->channels] * coeff[1][n]; s2[0] = av_clip_int16((level + pred + 0x80) >> 8); } } } } break; case CODEC_ID_ADPCM_IMA_AMV: case CODEC_ID_ADPCM_IMA_SMJPEG: if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) { c->status[0].predictor = sign_extend(bytestream_get_le16(&src), 16); c->status[0].step_index = av_clip(bytestream_get_le16(&src), 0, 88); src += 4; } else { c->status[0].predictor = sign_extend(bytestream_get_be16(&src), 16); c->status[0].step_index = av_clip(bytestream_get_byte(&src), 0, 88); src += 1; } for (n = nb_samples >> (1 - st); n > 0; n--, src++) { char hi, lo; lo = *src & 0x0F; hi = *src >> 4; if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) FFSWAP(char, hi, lo); *samples++ = adpcm_ima_expand_nibble(&c->status[0], lo, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], hi, 3); } break; case CODEC_ID_ADPCM_CT: for (n = nb_samples >> (1 - st); n > 0; n--, src++) { uint8_t v = *src; *samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 ); *samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F); } break; case CODEC_ID_ADPCM_SBPRO_4: case CODEC_ID_ADPCM_SBPRO_3: case CODEC_ID_ADPCM_SBPRO_2: if (!c->status[0].step_index) { *samples++ = 128 * (*src++ - 0x80); if (st) *samples++ = 128 * (*src++ - 0x80); c->status[0].step_index = 1; nb_samples--; } if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) { for (n = nb_samples >> (1 - st); n > 0; n--, src++) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] >> 4, 4, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], src[0] & 0x0F, 4, 0); } } else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) { for (n = nb_samples / 3; n > 0; n--, src++) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] >> 5 , 3, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x07, 3, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] & 0x03, 2, 0); } } else { for (n = nb_samples >> (2 - st); n > 0; n--, src++) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] >> 6 , 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], (src[0] >> 4) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], src[0] & 0x03, 2, 2); } } break; case CODEC_ID_ADPCM_SWF: { GetBitContext gb; const int *table; int k0, signmask, nb_bits, count; int size = buf_size*8; init_get_bits(&gb, buf, size); nb_bits = get_bits(&gb, 2)+2; table = swf_index_tables[nb_bits-2]; k0 = 1 << (nb_bits-2); signmask = 1 << (nb_bits-1); while (get_bits_count(&gb) <= size - 22*avctx->channels) { for (i = 0; i < avctx->channels; i++) { *samples++ = c->status[i].predictor = get_sbits(&gb, 16); c->status[i].step_index = get_bits(&gb, 6); } for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) { int i; for (i = 0; i < avctx->channels; i++) { int delta = get_bits(&gb, nb_bits); int step = ff_adpcm_step_table[c->status[i].step_index]; long vpdiff = 0; int k = k0; do { if (delta & k) vpdiff += step; step >>= 1; k >>= 1; } while(k); vpdiff += step; if (delta & signmask) c->status[i].predictor -= vpdiff; else c->status[i].predictor += vpdiff; c->status[i].step_index += table[delta & (~signmask)]; c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88); c->status[i].predictor = av_clip_int16(c->status[i].predictor); *samples++ = c->status[i].predictor; } } } src += buf_size; break; } case CODEC_ID_ADPCM_YAMAHA: for (n = nb_samples >> (1 - st); n > 0; n--, src++) { uint8_t v = *src; *samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F); *samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 ); } break; case CODEC_ID_ADPCM_THP: { int table[2][16]; int prev[2][2]; int ch; src += 4; src += 4; for (i = 0; i < 32; i++) table[0][i] = (int16_t)bytestream_get_be16(&src); for (i = 0; i < 4; i++) prev[0][i] = (int16_t)bytestream_get_be16(&src); for (ch = 0; ch <= st; ch++) { samples = (short *)c->frame.data[0] + ch; for (i = 0; i < nb_samples / 14; i++) { int index = (*src >> 4) & 7; unsigned int exp = *src++ & 15; int factor1 = table[ch][index * 2]; int factor2 = table[ch][index * 2 + 1]; for (n = 0; n < 14; n++) { int32_t sampledat; if(n&1) sampledat = sign_extend(*src++, 4); else sampledat = sign_extend(*src >> 4, 4); sampledat = ((prev[ch][0]*factor1 + prev[ch][1]*factor2) >> 11) + (sampledat << exp); *samples = av_clip_int16(sampledat); prev[ch][1] = prev[ch][0]; prev[ch][0] = *samples++; samples += st; } } } break; } default: return -1; } *got_frame_ptr = 1; *(AVFrame *)data = c->frame; return src - buf; }
1threat
Bundle Config in MVC 5 is not referring after hosting in IIS : We are developing an application in MVC5 and using Visual studio 2017. We have added all the common jquery and css files in bundle config but those are not rendering after the application is getting hosted in IIS. In the development phase, the application is working perfectly. [BundleConfig.cs][1] Referring the layout page. [Layout.cshtml][2] WebGrease is also added by default as a reference in the project. [WebConfig][3] [1]: https://i.stack.imgur.com/vO6no.png [2]: https://i.stack.imgur.com/JGxU9.png [3]: https://i.stack.imgur.com/R9TQD.png Please help to complete the hosting.
0debug
(p ∧ q) ∧ (p ⇒ ¬q) prove contradiction? : <p>So I have reached dead end after this I tried doing de Morgan rule after this but and faced dead end after that. I have tried this</p> <pre><code>(p ∧ q) ∧ (¬p ∨ ¬q) (p ∧ q) ∧ ¬(p ∧ q) </code></pre>
0debug
void qmp_block_resize(bool has_device, const char *device, bool has_node_name, const char *node_name, int64_t size, Error **errp) { Error *local_err = NULL; BlockDriverState *bs; AioContext *aio_context; int ret; bs = bdrv_lookup_bs(has_device ? device : NULL, has_node_name ? node_name : NULL, &local_err); if (local_err) { error_propagate(errp, local_err); return; } aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); if (!bdrv_is_first_non_filter(bs)) { error_setg(errp, QERR_FEATURE_DISABLED, "resize"); goto out; } if (size < 0) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size"); goto out; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) { error_setg(errp, QERR_DEVICE_IN_USE, device); goto out; } bdrv_drain_all(); ret = bdrv_truncate(bs, size); switch (ret) { case 0: break; case -ENOMEDIUM: error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); break; case -ENOTSUP: error_setg(errp, QERR_UNSUPPORTED); break; case -EACCES: error_setg(errp, "Device '%s' is read only", device); break; case -EBUSY: error_setg(errp, QERR_DEVICE_IN_USE, device); break; default: error_setg_errno(errp, -ret, "Could not resize"); break; } out: aio_context_release(aio_context); }
1threat
static int aiff_read_packet(AVFormatContext *s, AVPacket *pkt) { AVStream *st = s->streams[0]; AIFFInputContext *aiff = s->priv_data; int64_t max_size; int res, size; max_size = aiff->data_end - avio_tell(s->pb); if (max_size <= 0) return AVERROR_EOF; if (st->codec->block_align >= 33) size = st->codec->block_align; else size = (MAX_SIZE / st->codec->block_align) * st->codec->block_align; size = FFMIN(max_size, size); res = av_get_packet(s->pb, pkt, size); if (res < 0) return res; pkt->stream_index = 0; pkt->duration = (res / st->codec->block_align) * aiff->block_duration; return 0; }
1threat
static void qnull_visit_test(void) { QObject *obj; QmpOutputVisitor *qov; Visitor *v; g_assert(qnull_.refcnt == 1); obj = qnull(); v = qmp_input_visitor_new(obj, true); qobject_decref(obj); visit_type_null(v, NULL, &error_abort); visit_free(v); qov = qmp_output_visitor_new(); visit_type_null(qmp_output_get_visitor(qov), NULL, &error_abort); obj = qmp_output_get_qobject(qov); g_assert(obj == &qnull_); qobject_decref(obj); qmp_output_visitor_cleanup(qov); g_assert(qnull_.refcnt == 1); }
1threat
Preserve component state with vue-router? : <p>I have a listing/detail use case, where the user can double-click an item in a product list, go to the detail screen to edit and then go back to the listing screen when they're done. I've already done this using the dynamic components technique described here: <a href="https://vuejs.org/v2/guide/components.html#Dynamic-Components" rel="noreferrer">https://vuejs.org/v2/guide/components.html#Dynamic-Components</a>. But now that I'm planning to use vue-router elsewhere in the application, I'd like to refactor this to use routing instead. With my dynamic components technique, I used keep-alive to ensure that when the user switched back to the list view, the same selection was present as before the edit. But it seems to me that with routing the product list component would be re-rendered, which is not what I want.</p> <p>Now, it looks like router-view can be wrapped in keep-alive, which would solve one problem but introduce lots of others, as I only want that route kept alive, not all of them (and at present I'm just using a single top level router-view). Vue 2.1 has clearly done something to address this by introducing include and exclude parameters for router-view. But I don't really want to do this either, as it seems very clunky to have to declare up front in my main page all the routes which should or shouldn't use keep-alive. It would be much neater to declare whether I want keep-alive at the point I'm configuring the route (i.e., in the routes array). So what's my best option?</p>
0debug
React Native - TouchableOpacity not working inside an absolute positioned View : <p>I've got an absolute positioned View that holds 3 TouchableOpacity components and the 3 fail to respond they are just not working at all, what is going wrong here please help me :)</p> <p><strong>Code</strong></p> <pre><code>&lt;View style={[styles.highNormalLowDocListHeaderStateContainer, {width: this.windowWidth, height: this.headerSmallHeight, position: 'absolute', left: 0, top: floatedHeaderTitleTop, elevation: 2}]}&gt; &lt;TouchableOpacity onPress={() =&gt; this.getDocuments('high')} style={[styles.highNormalLowDocListHeaderStateTextContainer, highSelected.borderStyle]}&gt; &lt;Text style={[styles.highNormalLowDocListHeaderStateText, highSelected.textStyle]}&gt;HIGH&lt;/Text&gt; &lt;/TouchableOpacity&gt; &lt;TouchableOpacity onPress={() =&gt; this.getDocuments('normal')} style={[styles.highNormalLowDocListHeaderStateTextContainer, normalSelected.borderStyle]}&gt; &lt;Text style={[styles.highNormalLowDocListHeaderStateText, normalSelected.textStyle]}&gt;NORMAL&lt;/Text&gt; &lt;/TouchableOpacity&gt; &lt;TouchableOpacity onPress={() =&gt; this.getDocuments('low')} style={[styles.highNormalLowDocListHeaderStateTextContainer, lowSelected.borderStyle]}&gt; &lt;Text style {[styles.highNormalLowDocListHeaderStateText, lowSelected.textStyle]}&gt;LOW&lt;/Text&gt; &lt;/TouchableOpacity&gt; &lt;/View&gt; </code></pre> <p><strong>Screenshot</strong></p> <p><a href="https://i.stack.imgur.com/kLCUU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kLCUU.png" alt="enter image description here"></a></p>
0debug
static int monitor_fprintf(FILE *stream, const char *fmt, ...) { va_list ap; va_start(ap, fmt); monitor_vprintf((Monitor *)stream, fmt, ap); va_end(ap); return 0; }
1threat
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
System.IdentityModel.Tokens.JwtSecurityToken custom properties : <p>My AuthServer is currently using the following code to generate a JwtSecurityToken:</p> <pre><code>var token = new JwtSecurityToken(_issuer, audienceId, data.Identity.Claims, issued.Value.UtcDateTime, expires.Value.UtcDateTime, signingKey); var handler = new JwtSecurityTokenHandler(); var jwt = handler.WriteToken(token); </code></pre> <p>The payload looks like this:</p> <pre><code>{ "unique_name": "myUserName", "sub": "myUserName", "role": "API_User", "iss": "Automation", "aud": "099153c2625149bc8ecb3e85e03f0022", "exp": 1486056731, "nbf": 1483464731 } </code></pre> <p>I would like to add some custom fields/properties within the token payload, such as ProfilePicURL, so that the payload can look something like this:</p> <pre><code>{ "unique_name": "myUserName", "sub": "myUserName", "role": "API_User", "iss": "Automation", "aud": "099153c2625149bc8ecb3e85e03f0022", "exp": 1486056731, "nbf": 1483464731, "profilePicture": "http://url/user.jpg" } </code></pre> <p>How do I go about adding these custom properties and ensuring that the token contains them?</p>
0debug
Search for folder name in VS Code : <p>How can I search for a folder name and see it in Explorer?</p> <p>File search using <kbd>CMD</kbd> + <kbd>P</kbd> required me to know file name. Sometimes I know the folder which have desired file.</p>
0debug
Finding minimum String length of all lines in a CSV and printing them : <p>So let's say I have a CSV file of random alphabets in columns for example's sake:</p> <pre><code>a wrrq jt pkto b </code></pre> <p>They are in String format and I want to be able to find the minimum String length in this CSV list. In the example given, the minimum being 1 (the maximum being 4). Then I want to print all the minimums in order, resulting in:</p> <pre><code>a b </code></pre> <p>This is my code that reads each line from the top and it's barely anything to a helpful guideline but I'm kind of stuck right now.</p> <pre><code> BufferedReader br = new BufferedReader(new FileReader("Example.csv")); while ((nextLine = br.readLine()) != null) { ... } </code></pre> <p>Is there a way to do this a simple way without using fancy 3rd party scripts. Maybe putting them into an array and then working from there perhaps(?) Keeping in mind that the minimum may not always be 1.</p>
0debug
How to detect if building with address sanitizer when building with gcc 4.8? : <p>I'm working on a program written in C that I occasionally build with address sanitizer, basically to catch bugs. The program prints a banner in the logs when it starts up with info such as: who built it, the branch it was built on, compiler etc. I was thinking it would be nice to also spell out if the binary was built using address sanitizer. I know there's __has_feature(address_sanitizer), but that only works for clang. I tried the following simple program: </p> <pre><code>#include &lt;stdio.h&gt; int main() { #if defined(__has_feature) # if __has_feature(address_sanitizer) printf ("We has ASAN!\n"); # else printf ("We have has_feature, no ASAN!\n"); # endif #else printf ("We got nothing!\n"); #endif return 0; } </code></pre> <p>When building with <code>gcc -Wall -g -fsanitize=address -o asan asan.c</code>, this yields: </p> <pre><code>We got nothing! </code></pre> <p>With <code>clang -Wall -g -fsanitize=address -o asan asan.c</code> I get: </p> <pre><code>We has ASAN! </code></pre> <p>Is there a gcc equivalent to __has_feature? </p> <p>I know there are ways to check, like the huge VSZ value for programs built with address sanitizer, just wondering if there's a compile-time define or something. </p>
0debug
Xcode 8.2 cannot set entitlements membership : <p>I am trying to configure universal links on my App, but is not working. I read that a common cause of universal links are not working is that the entitlements file is not include in the build.</p> <p>But I am not able to set the target membership of my entitlements (screenshot bellow), all the checkbox are disable.</p> <p><a href="https://i.stack.imgur.com/1wzs6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1wzs6.png" alt="enter image description here"></a></p>
0debug
When I Use Persian Calendar I Get Error: "Additional information: String was not recognized as a valid DateTime" : I use Persian Date (Iranian Date Format or Jalali Calendar) in my program. and when i use this: string A = "1396/2/30"; string Test = String.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(A)); i get the following error: An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: String was not recognized as a valid DateTime.
0debug
static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type) { ByteIOContext *pb = mxf->fc->pb; MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf; uint64_t klv_end = url_ftell(pb) + klv->length; if (!ctx) return -1; while (url_ftell(pb) + 4 < klv_end) { int tag = get_be16(pb); int size = get_be16(pb); uint64_t next = url_ftell(pb) + size; UID uid; if (!size) { av_log(mxf->fc, AV_LOG_ERROR, "local tag 0x%04X with 0 size\n", tag); continue; } if (tag > 0x7FFF) { int i; for (i = 0; i < mxf->local_tags_count; i++) { int local_tag = AV_RB16(mxf->local_tags+i*18); if (local_tag == tag) { memcpy(uid, mxf->local_tags+i*18+2, 16); dprintf(mxf->fc, "local tag 0x%04X\n", local_tag); #ifdef DEBUG PRINT_KEY(mxf->fc, "uid", uid); #endif } } } if (ctx_size && tag == 0x3C0A) get_buffer(pb, ctx->uid, 16); else read_child(ctx, pb, tag, size, uid); url_fseek(pb, next, SEEK_SET); } if (ctx_size) ctx->type = type; return ctx_size ? mxf_add_metadata_set(mxf, ctx) : 0; }
1threat
Selenium not working Mac : <p>I am just starting to learn web scraping with selenium. I am not sure why I am getting the following errors. I have shared the image below. The following code seems to not work.</p> <pre><code>chrome_path = r"\\Users\\prateek\\Desktop\\MSc\\MWA\\chromedriver.exe" browser = webdriver.Chrome(chrome_path) # the url we want to open url = u'https://www.currys.co.uk/gbuk/phones-broadband-and-sat-nav/mobile-phones-and-accessories/mobile-phones/apple-iphone-8-64-gb-space-grey-10168742-pdt.html?intcmpid=display~RR' # the browser will start and load the webpage browser.get(url) </code></pre> <p>There is more to it but this doesn't seem to work Error I'm getting <a href="https://i.stack.imgur.com/LAXei.png" rel="nofollow noreferrer">Error I'm getting</a></p>
0debug
AWS Security Groups -- Name vs. Group Name : <p>In AWS Security Groups, what is the difference between "Name" and "Group Name"? It's confusing because when one creates a "Security Group", "Name" would seem to be interpreted as "name of the security group"...but then there is "Group Name". Seems redundant to the point of confusion. "Group Name" seems to be the more substantive and important field.</p> <p>The "Name" field can be changed by clicking the pencil icon as shown in the screenshot below:</p> <p><a href="https://i.stack.imgur.com/BTP4U.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BTP4U.png" alt="enter image description here"></a></p> <p>But the "Group Name" cannot be edited and can be specified only at the time of creation:</p> <p><a href="https://i.stack.imgur.com/shovG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/shovG.png" alt="enter image description here"></a></p> <p>I've been simply setting Name to be the same as Group Name for consistency and simplicity. I can't find any guidance on best practices for the "Name" field and how or if it should be named relative to the "Group Name" field (the pop-up help on AWS simply describes required naming syntax). Is "Name" just a convenience field which has little to zero significance (since it can be easily changed at any point)? What are the programmatic and functional effects of these names?</p>
0debug
static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { IscsiLun *iscsilun = bs->opaque; struct scsi_get_lba_status *lbas = NULL; struct scsi_lba_status_descriptor *lbasd = NULL; struct IscsiTask iTask; uint64_t lba; int64_t ret; if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { ret = -EINVAL; goto out; } ret = BDRV_BLOCK_DATA; ret |= (sector_num << BDRV_SECTOR_BITS) | BDRV_BLOCK_OFFSET_VALID; *pnum = nb_sectors; if (!iscsilun->lbpme) { goto out; } lba = sector_qemu2lun(sector_num, iscsilun); iscsi_co_init_iscsitask(iscsilun, &iTask); qemu_mutex_lock(&iscsilun->mutex); retry: if (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun, lba, 8 + 16, iscsi_co_generic_cb, &iTask) == NULL) { ret = -ENOMEM; goto out_unlock; } while (!iTask.complete) { iscsi_set_events(iscsilun); qemu_mutex_unlock(&iscsilun->mutex); qemu_coroutine_yield(); qemu_mutex_lock(&iscsilun->mutex); } if (iTask.do_retry) { if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; } iTask.complete = 0; goto retry; } if (iTask.status != SCSI_STATUS_GOOD) { error_report("iSCSI GET_LBA_STATUS failed at lba %" PRIu64 ": %s", lba, iTask.err_str); goto out_unlock; } lbas = scsi_datain_unmarshall(iTask.task); if (lbas == NULL) { ret = -EIO; goto out_unlock; } lbasd = &lbas->descriptors[0]; if (sector_qemu2lun(sector_num, iscsilun) != lbasd->lba) { ret = -EIO; goto out_unlock; } *pnum = sector_lun2qemu(lbasd->num_blocks, iscsilun); if (lbasd->provisioning == SCSI_PROVISIONING_TYPE_DEALLOCATED || lbasd->provisioning == SCSI_PROVISIONING_TYPE_ANCHORED) { ret &= ~BDRV_BLOCK_DATA; if (iscsilun->lbprz) { ret |= BDRV_BLOCK_ZERO; } } if (ret & BDRV_BLOCK_ZERO) { iscsi_allocmap_set_unallocated(iscsilun, sector_num, *pnum); } else { iscsi_allocmap_set_allocated(iscsilun, sector_num, *pnum); } if (*pnum > nb_sectors) { *pnum = nb_sectors; } out_unlock: qemu_mutex_unlock(&iscsilun->mutex); g_free(iTask.err_str); out: if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); } if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID) { *file = bs; } return ret; }
1threat
Extract n words from string : i have a text containing sentences in each line, and in front of each word its lemmetize form exemple: he "he" went "go" to "to" school "school" with "with" his "his" freinds "freind" i would like to extract for example three by three word in in each line. The result seems like this: he "he" went "go" to "to" \n went "go" to "to" school "school" \n to "to" school "school" with "with" \n school "school" with "with" his "his" \n with "with" his "his" freinds "freind" \n Please, have you any idea to do this, many thanks,
0debug
static void test_smbios_ep_table(test_data *data) { struct smbios_entry_point *ep_table = &data->smbios_ep_table; uint32_t addr = data->smbios_ep_addr; ACPI_READ_ARRAY(ep_table->anchor_string, addr); g_assert(!memcmp(ep_table->anchor_string, "_SM_", 4)); ACPI_READ_FIELD(ep_table->checksum, addr); ACPI_READ_FIELD(ep_table->length, addr); ACPI_READ_FIELD(ep_table->smbios_major_version, addr); ACPI_READ_FIELD(ep_table->smbios_minor_version, addr); ACPI_READ_FIELD(ep_table->max_structure_size, addr); ACPI_READ_FIELD(ep_table->entry_point_revision, addr); ACPI_READ_ARRAY(ep_table->formatted_area, addr); ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr); g_assert(!memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)); ACPI_READ_FIELD(ep_table->intermediate_checksum, addr); ACPI_READ_FIELD(ep_table->structure_table_length, addr); g_assert_cmpuint(ep_table->structure_table_length, >, 0); ACPI_READ_FIELD(ep_table->structure_table_address, addr); ACPI_READ_FIELD(ep_table->number_of_structures, addr); g_assert_cmpuint(ep_table->number_of_structures, >, 0); ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr); g_assert(!acpi_checksum((uint8_t *)ep_table, sizeof *ep_table)); g_assert(!acpi_checksum((uint8_t *)ep_table + 0x10, sizeof *ep_table - 0x10)); }
1threat
UINavigationBar change colors on push : <p>I'm using 2 different bar tint colors at <code>UINavigationBar</code> in different views. I'n changing color with that method in both views:</p> <pre><code>override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) self.navigationController?.navigationBar.barTintColor = COLOR } </code></pre> <p>When I tap on back button color is not changed smoothly (you can see blink on last second).</p> <p><a href="https://i.stack.imgur.com/2J27k.gif"><img src="https://i.stack.imgur.com/2J27k.gif" alt="Visual bug"></a></p> <p>But everything is okay if just swipe view back instead of tapping on back button.</p> <p><a href="https://i.stack.imgur.com/vYc3o.gif"><img src="https://i.stack.imgur.com/vYc3o.gif" alt="No visual bug"></a></p> <p>How to make smooth transition in both situations?</p>
0debug
static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size) { int res; HuffContext huff; HuffContext tmp1, tmp2; VLC vlc[2]; int escapes[3]; DBCtx ctx; tmp1.length = 256; tmp1.maxlength = 0; tmp1.current = 0; tmp1.bits = av_mallocz(256 * 4); tmp1.lengths = av_mallocz(256 * sizeof(int)); tmp1.values = av_mallocz(256 * sizeof(int)); tmp2.length = 256; tmp2.maxlength = 0; tmp2.current = 0; tmp2.bits = av_mallocz(256 * 4); tmp2.lengths = av_mallocz(256 * sizeof(int)); tmp2.values = av_mallocz(256 * sizeof(int)); memset(&vlc[0], 0, sizeof(VLC)); memset(&vlc[1], 0, sizeof(VLC)); if(get_bits1(gb)) { smacker_decode_tree(gb, &tmp1, 0, 0); get_bits1(gb); res = init_vlc(&vlc[0], SMKTREE_BITS, tmp1.length, tmp1.lengths, sizeof(int), sizeof(int), tmp1.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE); if(res < 0) { av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n"); } else { av_log(smk->avctx, AV_LOG_ERROR, "Skipping low bytes tree\n"); if(get_bits1(gb)){ smacker_decode_tree(gb, &tmp2, 0, 0); get_bits1(gb); res = init_vlc(&vlc[1], SMKTREE_BITS, tmp2.length, tmp2.lengths, sizeof(int), sizeof(int), tmp2.bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE); if(res < 0) { av_log(smk->avctx, AV_LOG_ERROR, "Cannot build VLC table\n"); } else { av_log(smk->avctx, AV_LOG_ERROR, "Skipping high bytes tree\n"); escapes[0] = get_bits(gb, 8); escapes[0] |= get_bits(gb, 8) << 8; escapes[1] = get_bits(gb, 8); escapes[1] |= get_bits(gb, 8) << 8; escapes[2] = get_bits(gb, 8); escapes[2] |= get_bits(gb, 8) << 8; last[0] = last[1] = last[2] = -1; ctx.escapes[0] = escapes[0]; ctx.escapes[1] = escapes[1]; ctx.escapes[2] = escapes[2]; ctx.v1 = &vlc[0]; ctx.v2 = &vlc[1]; ctx.recode1 = tmp1.values; ctx.recode2 = tmp2.values; ctx.last = last; huff.length = ((size + 3) >> 2) + 3; huff.maxlength = 0; huff.current = 0; huff.values = av_mallocz(huff.length * sizeof(int)); smacker_decode_bigtree(gb, &huff, &ctx); get_bits1(gb); if(ctx.last[0] == -1) ctx.last[0] = huff.current++; if(ctx.last[1] == -1) ctx.last[1] = huff.current++; if(ctx.last[2] == -1) ctx.last[2] = huff.current++; *recodes = huff.values; if(vlc[0].table) free_vlc(&vlc[0]); if(vlc[1].table) free_vlc(&vlc[1]); av_free(tmp1.bits); av_free(tmp1.lengths); av_free(tmp1.values); av_free(tmp2.bits); av_free(tmp2.lengths); av_free(tmp2.values); return 0;
1threat
void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) { VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); GArray *table_offsets; unsigned dsdt, rsdt; GArray *tables_blob = tables->table_data; table_offsets = g_array_new(false, true , sizeof(uint32_t)); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE, tables_blob, 64, false ); dsdt = tables_blob->len; build_dsdt(tables_blob, tables->linker, vms); acpi_add_table(table_offsets, tables_blob); build_fadt(tables_blob, tables->linker, vms, dsdt); acpi_add_table(table_offsets, tables_blob); build_madt(tables_blob, tables->linker, vms); acpi_add_table(table_offsets, tables_blob); build_gtdt(tables_blob, tables->linker, vms); acpi_add_table(table_offsets, tables_blob); build_mcfg(tables_blob, tables->linker, vms); acpi_add_table(table_offsets, tables_blob); build_spcr(tables_blob, tables->linker, vms); if (nb_numa_nodes > 0) { acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, vms); } if (its_class_name() && !vmc->no_its) { acpi_add_table(table_offsets, tables_blob); build_iort(tables_blob, tables->linker); } rsdt = tables_blob->len; build_rsdt(tables_blob, tables->linker, table_offsets, NULL, NULL); build_rsdp(tables->rsdp, tables->linker, rsdt); g_array_free(table_offsets, true); }
1threat
Não consigo enviar meu campo de data para o backend, está vindo como nulo! Uso o date-fns : - Tenho o meu frontend em React - Tenho o meu backend em Java - SpringBoot - O formato que meu backend entende é: 2011-10-05T14:48:00.000Z - Para isso, tentei usar o date-fns para enviar correto do front para o back, mas mesmo seguindo a documentação, minha data chega no backend como null e não cadastra. ``Salvar = async () => { const {update} = this.state; const {dtInclusao} = this.state.compra.dtInclusao var result = parse( dtInclusao, "dd/mm/yyyy", new Date() ) const response = await api.post('SolicCompra/compra', {...this.state.compra, dtInclusao: result}, {'Content-type': 'application/json'});`` Espero que minha data seja salva no formato dd/MM/yyyy
0debug
How can I change my Source code into a real application which can be install in windows or other OS systems using java programming language? : <p>I would like to know, if I have calculator source code in java and I want that source code to be changed into a real application which could be able to install in any OS(operating systems), so how can I install such source code or transfer it in the way, which it will be able to instal on OS? thanks.</p>
0debug
Azure Service Fabric activation error : <p>The deployment of one of my apps to a <code>Service Fabric Cluster</code> failed and triggered an Unhealthy Evaluation with an error event saying: <code>There was an error during CodePackage activation.The service host terminated with exit code:3762504530</code></p> <p>However, on the node where the app is deployed, Health State indicates: <code>The application was activated successfully.</code></p> <p>Is there any way to get a more detailed report on the error event?</p>
0debug
Retry connection to Cassandra node upon startup : <p>I want to use Docker to start my application and Cassandra database, and I would like to use Docker Compose for that. Unfortunately, Cassandra starts much slower than my application, and since my application eagerly initializes the <code>Cluster</code> object, I get the following exception:</p> <pre><code>com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: cassandra/172.18.0.2:9042 (com.datastax.driver.core.exceptions.TransportException: [cassandra/172.18.0.2:9042] Cannot connect)) at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:233) at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79) at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1454) at com.datastax.driver.core.Cluster.init(Cluster.java:163) at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:334) at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:309) at com.datastax.driver.core.Cluster.connect(Cluster.java:251) </code></pre> <p>According to the stacktrace and a little debugging, it seems that Cassandra Java driver does not apply retry policies to the initial startup. This seems kinda weird to me. Is there a way for me to configure the driver so it will continue its attempts to connect to the server until it succeeds?</p>
0debug
MemdevList *qmp_query_memdev(Error **errp) { Object *obj; MemdevList *list = NULL; obj = object_get_objects_root(); if (obj == NULL) { return NULL; } if (object_child_foreach(obj, query_memdev, &list) != 0) { goto error; } return list; error: qapi_free_MemdevList(list); return NULL; }
1threat
static uint64_t lan9118_readl(void *opaque, hwaddr offset, unsigned size) { lan9118_state *s = (lan9118_state *)opaque; if (offset < 0x20) { return rx_fifo_pop(s); } switch (offset) { case 0x40: return rx_status_fifo_pop(s); case 0x44: return s->rx_status_fifo[s->tx_status_fifo_head]; case 0x48: return tx_status_fifo_pop(s); case 0x4c: return s->tx_status_fifo[s->tx_status_fifo_head]; case CSR_ID_REV: return 0x01180001; case CSR_IRQ_CFG: return s->irq_cfg; case CSR_INT_STS: return s->int_sts; case CSR_INT_EN: return s->int_en; case CSR_BYTE_TEST: return 0x87654321; case CSR_FIFO_INT: return s->fifo_int; case CSR_RX_CFG: return s->rx_cfg; case CSR_TX_CFG: return s->tx_cfg; case CSR_HW_CFG: return s->hw_cfg; case CSR_RX_DP_CTRL: return 0; case CSR_RX_FIFO_INF: return (s->rx_status_fifo_used << 16) | (s->rx_fifo_used << 2); case CSR_TX_FIFO_INF: return (s->tx_status_fifo_used << 16) | (s->tx_fifo_size - s->txp->fifo_used); case CSR_PMT_CTRL: return s->pmt_ctrl; case CSR_GPIO_CFG: return s->gpio_cfg; case CSR_GPT_CFG: return s->gpt_cfg; case CSR_GPT_CNT: return ptimer_get_count(s->timer); case CSR_WORD_SWAP: return s->word_swap; case CSR_FREE_RUN: return (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / 40) - s->free_timer_start; case CSR_RX_DROP: return 0; case CSR_MAC_CSR_CMD: return s->mac_cmd; case CSR_MAC_CSR_DATA: return s->mac_data; case CSR_AFC_CFG: return s->afc_cfg; case CSR_E2P_CMD: return s->e2p_cmd; case CSR_E2P_DATA: return s->e2p_data; } hw_error("lan9118_read: Bad reg 0x%x\n", (int)offset); return 0; }
1threat
embedded sql in c,how to check if records exist : <p>I have tried these:</p> <pre><code>1.if (EXEC SQL EXIST SELECT ...) 2.EXEC SQL IF EXIST SELECT ... </code></pre> <p>but none of these work,any help?</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
AWS Batch executor with Airflow : <p>I'm currently using airflow on Amazon Web services using EC2 instances. The big issue is that the average usage of the instances are about 2%... </p> <p>I'd like to use a scalable architecture and creating instances only for the duration of the job and kill it. I saw on the roadmap that AWS BATCH was suppose to be an executor in 2017 but no new about that.</p> <p>Do you know if it possible to use AWS BATCH as an executor for all airflow jobs ?</p> <p>Regards, Romain.</p>
0debug
void pc_basic_device_init(qemu_irq *isa_irq, FDCtrl **floppy_controller, ISADevice **rtc_state) { int i; DriveInfo *fd[MAX_FD]; PITState *pit; qemu_irq rtc_irq = NULL; qemu_irq *a20_line; ISADevice *i8042, *port92, *vmmouse; qemu_irq *cpu_exit_irq; register_ioport_write(0x80, 1, 1, ioport80_write, NULL); register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); if (!no_hpet) { DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL); if (hpet) { for (i = 0; i < 24; i++) { sysbus_connect_irq(sysbus_from_qdev(hpet), i, isa_irq[i]); } rtc_irq = qdev_get_gpio_in(hpet, 0); } } *rtc_state = rtc_init(2000, rtc_irq); qemu_register_boot_set(pc_boot_set, *rtc_state); pit = pit_init(0x40, isa_reserve_irq(0)); pcspk_init(pit); for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { serial_isa_init(i, serial_hds[i]); } } for(i = 0; i < MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { parallel_init(i, parallel_hds[i]); } } a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2); i8042 = isa_create_simple("i8042"); i8042_setup_a20_line(i8042, &a20_line[0]); vmport_init(); vmmouse = isa_try_create("vmmouse"); if (vmmouse) { qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042); } port92 = isa_create_simple("port92"); port92_init(port92, &a20_line[1]); cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); for(i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } *floppy_controller = fdctrl_init_isa(fd); }
1threat
static int check_timecode(void *log_ctx, AVTimecode *tc) { if (tc->fps <= 0) { av_log(log_ctx, AV_LOG_ERROR, "Timecode frame rate must be specified\n"); return AVERROR(EINVAL); } if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps != 30 && tc->fps != 60) { av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with 30000/1001 or 60000/1001 FPS\n"); return AVERROR(EINVAL); } if (check_fps(tc->fps) < 0) { av_log(log_ctx, AV_LOG_WARNING, "Using non-standard frame rate %d/%d\n", tc->rate.num, tc->rate.den); } return 0; }
1threat
static void vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, unsigned idx) { int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_state state = { .index = vhost_vq_index, }; int r; r = dev->vhost_ops->vhost_get_vring_base(dev, &state); if (r < 0) { VHOST_OPS_DEBUG("vhost VQ %d ring restore failed: %d", idx, r); } else { virtio_queue_set_last_avail_idx(vdev, idx, state.num); } virtio_queue_invalidate_signalled_used(vdev, idx); virtio_queue_update_used_idx(vdev, idx); /* In the cross-endian case, we need to reset the vring endianness to * native as legacy devices expect so by default. if (vhost_needs_vring_endian(vdev)) { vhost_virtqueue_set_vring_endian_legacy(dev, !virtio_is_big_endian(vdev), vhost_vq_index); } vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx), 1, virtio_queue_get_used_size(vdev, idx)); vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx), 0, virtio_queue_get_avail_size(vdev, idx)); vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx), 0, virtio_queue_get_desc_size(vdev, idx)); }
1threat
How do I add a second die to this elm effects example? : <p>I am new to Elm and have been looking at the following example (note this is under the newer 0.17 architecture, where Action is now Command): <a href="http://elm-lang.org/examples/random" rel="noreferrer">http://elm-lang.org/examples/random</a></p> <p>There is a follow up challenge to add a second die to the example, so that a single click of the button rolls a new value for each die. My idea is to change the model to hold two separate values, one for each die, ala</p> <pre><code>type alias Model = { dieFace1 : Int , dieFace2 : Int } </code></pre> <p>This works fine until I get to the update block. I am not sure how to update the Random number generator to create two values. The function is a bit confusing to me.</p> <pre><code>type Msg = Roll | NewFace Int Int update : Msg -&gt; Model -&gt; (Model, Cmd Msg) update msg model = case msg of Roll -&gt; **(model, Random.generate NewFace (Random.int 1 6))** &lt;-- not sure what to do here NewFace newFace1 newFace2 -&gt; (Model newFace1 newFace2, Cmd.none) </code></pre> <p>The documentation for the Random.generate function is a bit light - </p> <blockquote> <p>generate : (a -> msg) -> Generator a -> Cmd msg</p> <p>Create a command that will generate random values.</p> </blockquote> <p>Is this even the correct approach to handle two dice, or is there a better way? I am an elm noob, please be nice :)</p>
0debug
How get Environment Variables from lambda (nodejs aws-sdk) : <p>We can set up Environment Variables in aws-lambda for example via AWS SAM:</p> <pre><code>Environment: Variables: TABLE_NAME: !Ref Table </code></pre> <p>How can I get this variables from current lambda via Node JS AWS-SDK?</p>
0debug
def count_charac(str1): total = 0 for i in str1: total = total + 1 return total
0debug
+= and -= expressions in Python (?) : <p>I am trying to follow the example in <a href="http://cs231n.github.io/neural-networks-case-study/#loss" rel="nofollow noreferrer">this post</a>, and it was going smoothly until I ran into the lines of code with <code>-=</code> and <code>+=</code> calls.</p> <p>I believe this might be some sort of misprint in expressions that are supposed to update the object on the RHS of <code>=</code> according to some condition.</p> <p>Unfortunately, interpreting this expression is key in getting what the code is doing, and guessing defeats the purpose.</p> <p>Do these fragments of code or operators make any sense? </p> <p>What was intended by the author?</p>
0debug
Create View - Declare a variable : <p>I am creating a view that is using that <code>STUFF</code> function. I want to put the result of <code>STUFF</code> in a variable for my view. The problem I am having is declaring my variable. It gives me the message <em>"Incorrect Syntax near 'DECLARE'. Expecting '(' or SELECT."</em> I already have the '(' in there. I have tried putting a <code>BEGIN</code> before it. I have tried putting it after the <code>SELECT</code> word. But nothing seems to work and I cannot find a solution in my search. I am using SQL Server 2012</p> <pre><code>CREATE VIEW [AQB_OB].[GISREQUESTEDBURNS] AS (DECLARE @CONDITIONS AS varchar(20) SET @CONDITIONS = (SELECT DISTINCT BD.[RequestedBurnsID] ,[ConditionsReasonsID] = STUFF((SELECT ', ' + CONVERT(VARCHAR (20),[ConditionsReasonsID]) FROM [AQB_OB].[BurnDecisions] WHERE [RequestedBurnsID]= BD.[RequestedBurnsID] ORDER BY [RequestedBurnsID] ASC FOR XML PATH ('')) , 1 , 1, '') FROM [AQB_OB].[BurnDecisions] BD) SELECT RB.[RequestedBurnsID] AS REQUESTEDBURNID ,BUY.[BurnYear] AS BURNYEAR ,CY.[CurrentYear] AS CURRENTYEAR ,RB.[BurnSitesID] AS BURNSITESID ,[BurnerID] AS BURNERID ,[Contact] AS CONTACT ,[BurnDecision] AS BURNDECISION ,RB.[Comment] AS COMMENT ,@CONDITIONS AS CONDITIONS FROM [AQB_MON].[AQB_OB].[RequestedBurns] RB LEFT join AQB_MON.[AQB_OB].[PileDryness] PD on RB.[PileDrynessID] = PD.[PileDrynessID] inner join AQB_MON.[AQB_OB].[BurnYear] BUY on BUY.BurnYearID = BP.BurnYearID inner join AQB_MON.[AQB_OB].[CurrentYear] CY on CY.CurrentYearID = BUY.CurrentYearID GO </code></pre>
0debug
static void generic_loader_realize(DeviceState *dev, Error **errp) { GenericLoaderState *s = GENERIC_LOADER(dev); hwaddr entry; int big_endian; int size = 0; s->set_pc = false; if (s->data || s->data_len || s->data_be) { if (s->file) { error_setg(errp, "Specifying a file is not supported when loading " "memory values"); return; } else if (s->force_raw) { error_setg(errp, "Specifying force-raw is not supported when " "loading memory values"); return; } else if (!s->data_len) { error_setg(errp, "Both data and data-len must be specified"); return; } else if (s->data_len > 8) { error_setg(errp, "data-len cannot be greater then 8 bytes"); return; } } else if (s->file || s->force_raw) { if (s->data || s->data_len || s->data_be) { error_setg(errp, "data can not be specified when loading an " "image"); return; } if (s->cpu_num != CPU_NONE) { s->set_pc = true; } } else if (s->addr) { if (s->data || s->data_len || s->data_be) { error_setg(errp, "data can not be specified when setting a " "program counter"); return; } else if (!s->cpu_num) { error_setg(errp, "cpu_num must be specified when setting a " "program counter"); return; } s->set_pc = true; } else { error_setg(errp, "please include valid arguments"); return; } qemu_register_reset(generic_loader_reset, dev); if (s->cpu_num != CPU_NONE) { s->cpu = qemu_get_cpu(s->cpu_num); if (!s->cpu) { error_setg(errp, "Specified boot CPU#%d is nonexistent", s->cpu_num); return; } } else { s->cpu = first_cpu; } #ifdef TARGET_WORDS_BIGENDIAN big_endian = 1; #else big_endian = 0; #endif if (s->file) { if (!s->force_raw) { size = load_elf_as(s->file, NULL, NULL, &entry, NULL, NULL, big_endian, 0, 0, 0, s->cpu->as); if (size < 0) { size = load_uimage_as(s->file, &entry, NULL, NULL, NULL, NULL, s->cpu->as); } } if (size < 0 || s->force_raw) { size = load_image_targphys_as(s->file, s->addr, ram_size, s->cpu->as); } else { s->addr = entry; } if (size < 0) { error_setg(errp, "Cannot load specified image %s", s->file); return; } } if (s->data_be) { s->data = cpu_to_be64(s->data); } else { s->data = cpu_to_le64(s->data); } }
1threat
order by most frequent occurence sql : I have a table CARDUSR.SPPAYTB with transaction informations. The table contains ACAUREQ_AUREQ_ENV_M_CMONNM which is the Common Merchant Name. Now I want an output like this: orders ACAUREQ_AUREQ_ENV_M_CMONNM ---------+---------+---------------- 100 Antique Shop 30 Airleisure 23 Books 12 .... How can I contruct the "orders" column which is the count of all transaction with a certain common merchant name?
0debug
static int raw_open(BlockDriverState *bs, const char *filename, int flags) { BDRVRawState *s = bs->opaque; int access_flags, create_flags; DWORD overlapped; s->type = FTYPE_FILE; if ((flags & BDRV_O_ACCESS) == O_RDWR) { access_flags = GENERIC_READ | GENERIC_WRITE; } else { access_flags = GENERIC_READ; } if (flags & BDRV_O_CREAT) { create_flags = CREATE_ALWAYS; } else { create_flags = OPEN_EXISTING; } #ifdef QEMU_TOOL overlapped = FILE_ATTRIBUTE_NORMAL; #else overlapped = FILE_FLAG_OVERLAPPED; #endif s->hfile = CreateFile(filename, access_flags, FILE_SHARE_READ, NULL, create_flags, overlapped, NULL); if (s->hfile == INVALID_HANDLE_VALUE) return -1; return 0; }
1threat
Angular Dynamic Components - Add Class and other attributes : <p>I am using the following code for creating the dynamic components</p> <pre><code>import { Component, OnInit, ViewContainerRef, ViewChild, ViewChildren, ReflectiveInjector, ComponentFactoryResolver, ViewEncapsulation, QueryList, Input, AfterViewInit } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { forEach } from '@angular/router/src/utils/collection'; import { IComponent } from 'app/app.icomponent'; @Component({ encapsulation: ViewEncapsulation.None, selector: 'dynamic-component', entryComponents: [HomeComponent, HighlevelSignalComponent], template: ` &lt;div #dynamicDiv [ngClass]="classFromMenu" &gt; &lt;ng-template #dynamicComponentContainer&gt;&lt;/ng-template&gt; &lt;/div&gt; `, styleUrls: [ './dynamic-content.component.css' ], }) export class DynamicComponent implements IComponent, OnInit, AfterViewInit { classFromMenu: any; @ViewChild('dynamicComponentContainer', { read: ViewContainerRef }) dynamicComponentContainer: ViewContainerRef; constructor(private resolver: ComponentFactoryResolver, private route: Router, private activatedRoute: ActivatedRoute, ) { } ....... buildComponent(passedData) { // orderAndObjs has the data for creating the component this.orderAndObjs.forEach(obj =&gt; { var componentFactory = this.resolver.resolveComponentFactory(obj.component); var compRef = this.dynamicComponentContainer.createComponent(componentFactory); // compRef is the component that is created. //Assuming the component that i am trying to create is &lt;dynamic-component&gt;. //I want to add either a class or any other attribute like this //&lt;dynamic-component class="flex"&gt; }); } } } </code></pre> <p>The dynamic-component is created perfectly fine and everything is working as expected. But the only issue is I want to add a class for dynamic-component so that it can be </p> <pre><code>&lt;dynamic-component class="dynamicClass"&gt; </code></pre> <p>Any help is appreciated :( </p>
0debug
Flutter image preload : <p>Is it possible to preload somehow the image on the app start? Like I have an background image in my drawer but for the first time when I open the drawer I can see the image blinks like it is fetched from assets and then displayed and it gives bad experience to me once I see it for the first time other openings of the drawer are behaving as expected because it is cached. I would like to prefetch it on the app load so there is no such effect.</p>
0debug
do_command(GIOChannel *source, GIOCondition condition, gpointer data) { char *string; VCardEmulError error; static unsigned int default_reader_id; unsigned int reader_id; VReader *reader = NULL; GError *err = NULL; g_assert(condition & G_IO_IN); reader_id = default_reader_id; g_io_channel_read_line(source, &string, NULL, NULL, &err); if (err != NULL) { g_error("Error while reading command: %s", err->message); } if (string != NULL) { if (strncmp(string, "exit", 4) == 0) { VReaderList *list = vreader_get_reader_list(); VReaderListEntry *reader_entry; printf("Active Readers:\n"); for (reader_entry = vreader_list_get_first(list); reader_entry; reader_entry = vreader_list_get_next(reader_entry)) { VReader *reader = vreader_list_get_reader(reader_entry); vreader_id_t reader_id; reader_id = vreader_get_id(reader); if (reader_id == -1) { continue; } if (vreader_card_is_present(reader) == VREADER_OK) { send_msg(VSC_CardRemove, reader_id, NULL, 0); } send_msg(VSC_ReaderRemove, reader_id, NULL, 0); } exit(0); } else if (strncmp(string, "insert", 6) == 0) { if (string[6] == ' ') { reader_id = get_id_from_string(&string[7], reader_id); } reader = vreader_get_reader_by_id(reader_id); if (reader != NULL) { error = vcard_emul_force_card_insert(reader); printf("insert %s, returned %d\n", vreader_get_name(reader), error); } else { printf("no reader by id %u found\n", reader_id); } } else if (strncmp(string, "remove", 6) == 0) { if (string[6] == ' ') { reader_id = get_id_from_string(&string[7], reader_id); } reader = vreader_get_reader_by_id(reader_id); if (reader != NULL) { error = vcard_emul_force_card_remove(reader); printf("remove %s, returned %d\n", vreader_get_name(reader), error); } else { printf("no reader by id %u found\n", reader_id); } } else if (strncmp(string, "select", 6) == 0) { if (string[6] == ' ') { reader_id = get_id_from_string(&string[7], VSCARD_UNDEFINED_READER_ID); } if (reader_id != VSCARD_UNDEFINED_READER_ID) { reader = vreader_get_reader_by_id(reader_id); } if (reader) { printf("Selecting reader %u, %s\n", reader_id, vreader_get_name(reader)); default_reader_id = reader_id; } else { printf("Reader with id %u not found\n", reader_id); } } else if (strncmp(string, "debug", 5) == 0) { if (string[5] == ' ') { verbose = get_id_from_string(&string[6], 0); } printf("debug level = %d\n", verbose); } else if (strncmp(string, "list", 4) == 0) { VReaderList *list = vreader_get_reader_list(); VReaderListEntry *reader_entry; printf("Active Readers:\n"); for (reader_entry = vreader_list_get_first(list); reader_entry; reader_entry = vreader_list_get_next(reader_entry)) { VReader *reader = vreader_list_get_reader(reader_entry); vreader_id_t reader_id; reader_id = vreader_get_id(reader); if (reader_id == -1) { continue; } printf("%3u %s %s\n", reader_id, vreader_card_is_present(reader) == VREADER_OK ? "CARD_PRESENT" : " ", vreader_get_name(reader)); } printf("Inactive Readers:\n"); for (reader_entry = vreader_list_get_first(list); reader_entry; reader_entry = vreader_list_get_next(reader_entry)) { VReader *reader = vreader_list_get_reader(reader_entry); vreader_id_t reader_id; reader_id = vreader_get_id(reader); if (reader_id != -1) { continue; } printf("INA %s %s\n", vreader_card_is_present(reader) == VREADER_OK ? "CARD_PRESENT" : " ", vreader_get_name(reader)); } } else if (*string != 0) { printf("valid commands:\n"); printf("insert [reader_id]\n"); printf("remove [reader_id]\n"); printf("select reader_id\n"); printf("list\n"); printf("debug [level]\n"); printf("exit\n"); } } vreader_free(reader); printf("> "); fflush(stdout); return TRUE; }
1threat
SQL Server Management Studio Setting : <p>How to enable the more accurate help, please ?</p> <p>Because I have this :</p> <p><a href="https://i.stack.imgur.com/2DsgH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2DsgH.png" alt="enter image description here"></a></p>
0debug
static int open_f(BlockBackend *blk, int argc, char **argv) { int flags = BDRV_O_UNMAP; int readonly = 0; bool writethrough = true; int c; QemuOpts *qopts; QDict *opts; bool force_share = false; while ((c = getopt(argc, argv, "snro:kt:d:U")) != -1) { switch (c) { case 's': flags |= BDRV_O_SNAPSHOT; break; case 'n': flags |= BDRV_O_NOCACHE; writethrough = false; break; case 'r': readonly = 1; break; case 'k': flags |= BDRV_O_NATIVE_AIO; break; case 't': if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) { error_report("Invalid cache option: %s", optarg); qemu_opts_reset(&empty_opts); return 0; } break; case 'd': if (bdrv_parse_discard_flags(optarg, &flags) < 0) { error_report("Invalid discard option: %s", optarg); qemu_opts_reset(&empty_opts); return 0; } break; case 'o': if (imageOpts) { printf("--image-opts and 'open -o' are mutually exclusive\n"); qemu_opts_reset(&empty_opts); return 0; } if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) { qemu_opts_reset(&empty_opts); return 0; } break; case 'U': force_share = true; break; default: qemu_opts_reset(&empty_opts); return qemuio_command_usage(&open_cmd); } } if (!readonly) { flags |= BDRV_O_RDWR; } if (imageOpts && (optind == argc - 1)) { if (!qemu_opts_parse_noisily(&empty_opts, argv[optind], false)) { qemu_opts_reset(&empty_opts); return 0; } optind++; } qopts = qemu_opts_find(&empty_opts, NULL); opts = qopts ? qemu_opts_to_qdict(qopts, NULL) : NULL; qemu_opts_reset(&empty_opts); if (optind == argc - 1) { return openfile(argv[optind], flags, writethrough, force_share, opts); } else if (optind == argc) { return openfile(NULL, flags, writethrough, force_share, opts); } else { QDECREF(opts); return qemuio_command_usage(&open_cmd); } }
1threat
What is the proper way to put divider lines between navigation links? : <p>I have a CSS/HTML homework assignment to make a page look like the page my instructor gave me. I need to add "pipes" in between the links. I added pipe characters to my HTML, but I don't feel like that is the proper way to do it. Thanks! Here is a screenshot of what it needs to look like: </p> <p><a href="https://i.imgur.com/sC7OLut.png" rel="nofollow noreferrer">https://i.imgur.com/sC7OLut.png</a></p>
0debug
opts_next_list(Visitor *v, GenericList **list, size_t size) { OptsVisitor *ov = to_ov(v); GenericList **link; switch (ov->list_mode) { case LM_STARTED: ov->list_mode = LM_IN_PROGRESS; link = list; break; case LM_SIGNED_INTERVAL: case LM_UNSIGNED_INTERVAL: link = &(*list)->next; if (ov->list_mode == LM_SIGNED_INTERVAL) { if (ov->range_next.s < ov->range_limit.s) { ++ov->range_next.s; break; } } else if (ov->range_next.u < ov->range_limit.u) { ++ov->range_next.u; break; } ov->list_mode = LM_IN_PROGRESS; case LM_IN_PROGRESS: { const QemuOpt *opt; opt = g_queue_pop_head(ov->repeated_opts); if (g_queue_is_empty(ov->repeated_opts)) { g_hash_table_remove(ov->unprocessed_opts, opt->name); return NULL; } link = &(*list)->next; break; } default: abort(); } *link = g_malloc0(size); return *link; }
1threat
static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num) { if(!is_sector_in_chunk(s,s->current_chunk,sector_num)) { int ret; uint32_t chunk = search_chunk(s,sector_num); if(chunk>=s->n_chunks) return -1; s->current_chunk = s->n_chunks; switch(s->types[chunk]) { case 0x80000005: { int i; i=0; do { ret = pread(s->fd, s->compressed_chunk+i, s->lengths[chunk]-i, s->offsets[chunk] + i); if(ret<0 && errno==EINTR) ret=0; i+=ret; } while(ret>=0 && ret+i<s->lengths[chunk]); if (ret != s->lengths[chunk]) return -1; s->zstream.next_in = s->compressed_chunk; s->zstream.avail_in = s->lengths[chunk]; s->zstream.next_out = s->uncompressed_chunk; s->zstream.avail_out = 512*s->sectorcounts[chunk]; ret = inflateReset(&s->zstream); if(ret != Z_OK) return -1; ret = inflate(&s->zstream, Z_FINISH); if(ret != Z_STREAM_END || s->zstream.total_out != 512*s->sectorcounts[chunk]) return -1; break; } case 1: ret = pread(s->fd, s->uncompressed_chunk, s->lengths[chunk], s->offsets[chunk]); if (ret != s->lengths[chunk]) return -1; break; case 2: memset(s->uncompressed_chunk, 0, 512*s->sectorcounts[chunk]); break; } s->current_chunk = chunk; } return 0; }
1threat
Split assets by ABI on Android : <p>I've seen <a href="https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split" rel="noreferrer">this guide</a> on how to build split APKs for each ABI.</p> <p>However my app embeds a bunch of native executables as assets. Is it possible to filter them based on the ABI?</p> <p>Relevant parts of <code>build.gradle</code>:</p> <pre><code>android { ... splits { abi { enable true } } externalNativeBuild { cmake { path "CMakeLists.txt" // builds assets and places them in src/main/assets } } sourceSets { main { assets.srcDirs = ['src/main/assets'] } } } </code></pre> <p>Sample app tree after building native executables with CMake:</p> <pre><code>src + main + assets + x86 | + native-x86.bin + x86_64 | + native-x86_64.bin + armeabi-v7a | + native-arm.bin + arm64-v8a + native-aarch64.bin </code></pre> <p>Each ABI directory contains native binaries</p> <p>I would like each split APK to contain only the ABI-specific assets directory, with the other ones filtered. For example, for the arm64 APK:</p> <pre><code>assets + arm64-v8a + native-aarch64.bin </code></pre>
0debug
com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE : <p>Im implementing an android app that enables users to stream to a youtube channel straight from the app. I have created an API key and a OAuth 2.0 client ID <a href="https://i.stack.imgur.com/3CVJ8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3CVJ8.png" alt="enter image description here"></a></p> <p>But I get a the following exeption: <code>com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE</code> either when I try to ceate an event or when i try to fetch the one a created manually on the youtube channel.</p> <p>I use the following code for create a youtube object</p> <pre><code>String accountName = mContext.getString(R.string.google_account_name); String apiKey = mContext.getString(R.string.google_api_key); String clientID = mContext.getString(R.string.google_api_client_id); String clientName = mContext.getString(R.string.google_api_client_name); GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(mContext, Arrays.asList(YouTubeScopes.YOUTUBE)); credential.setSelectedAccountName(accountName); // String SCOPE = "audience:server:client_id:" + clientID + ":api_scope:" + YouTubeScopes.YOUTUBE; // GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(mContext, SCOPE); // credential.setSelectedAccountName(accountName); youtube = new YouTube.Builder(transport, jsonFactory, credential) .setApplicationName(clientName) .setYouTubeRequestInitializer(new YouTubeRequestInitializer(apiKey)) /*.setGoogleClientRequestInitializer(new YouTubeRequestInitializer(apiKey))*/ .build(); </code></pre> <p>Then to create an event:</p> <pre><code>LiveBroadcastSnippet broadcastSnippet = new LiveBroadcastSnippet(); broadcastSnippet.setTitle(name); broadcastSnippet.setScheduledStartTime(new DateTime(futureDate)); LiveBroadcastContentDetails contentDetails = new LiveBroadcastContentDetails(); MonitorStreamInfo monitorStream = new MonitorStreamInfo(); monitorStream.setEnableMonitorStream(false); contentDetails.setMonitorStream(monitorStream); // Create LiveBroadcastStatus with privacy status. LiveBroadcastStatus status = new LiveBroadcastStatus(); status.setPrivacyStatus("unlisted"); LiveBroadcast broadcast = new LiveBroadcast(); broadcast.setKind("youtube#liveBroadcast"); broadcast.setSnippet(broadcastSnippet); broadcast.setStatus(status); broadcast.setContentDetails(contentDetails); // Create the insert request YouTube.LiveBroadcasts.Insert liveBroadcastInsert = youtube .liveBroadcasts().insert("snippet,status,contentDetails", broadcast); // Request is executed and inserted broadcast is returned LiveBroadcast returnedBroadcast = liveBroadcastInsert.execute(); //&lt;= This line generates the exception </code></pre> <p>I obviously did something wrong, but I can't figure out what. Any help is appreciated. Thanks in advance</p>
0debug
static int vnc_display_listen(VncDisplay *vd, SocketAddressLegacy **saddr, size_t nsaddr, SocketAddressLegacy **wsaddr, size_t nwsaddr, Error **errp) { size_t i; for (i = 0; i < nsaddr; i++) { if (vnc_display_listen_addr(vd, saddr[i], "vnc-listen", &vd->lsock, &vd->lsock_tag, &vd->nlsock, errp) < 0) { return -1; } } for (i = 0; i < nwsaddr; i++) { if (vnc_display_listen_addr(vd, wsaddr[i], "vnc-ws-listen", &vd->lwebsock, &vd->lwebsock_tag, &vd->nlwebsock, errp) < 0) { return -1; } } return 0; }
1threat
How to setup a simple email server to send and receive email in localhost in Ubuntu? : <p>I am using Ubuntu 16.04 LTS. I would like to setup a simple email server in my box, to test email sending and receiving capabilities of my application. I am looking for a simple-to-setup solution, which enable this capability. My expectations are;</p> <ol> <li>Two email IDs <code>sender@localhost</code> and <code>receiver@localhost</code></li> <li>Emails should be configurable in email clients like Thunderbird</li> <li>Should work without Internet connection</li> </ol> <p>A detailed, beginner level answer on how to setup or a beginner level tutorial link will be greatly helpful.</p> <p>Thank you.</p>
0debug
Error on parsing json result? : Greeting! After I removed hardcoded json data and moved to request data from url. I am having exception error. The code is pretty much same as final official git but I am getting these errors. > Problem parsing the earthquake JSON results org.json.JSONException: > Index 10 out of range [0..10) You can view more on github link [gitlink here][1] [1]: https://github.com/SimonAstaniPersonal/QuakeReportTEst
0debug
static void spapr_dr_connector_class_init(ObjectClass *k, void *data) { DeviceClass *dk = DEVICE_CLASS(k); sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k); dk->reset = reset; dk->realize = realize; dk->unrealize = unrealize; drck->set_isolation_state = set_isolation_state; drck->set_indicator_state = set_indicator_state; drck->set_allocation_state = set_allocation_state; drck->get_index = get_index; drck->get_type = get_type; drck->get_name = get_name; drck->get_fdt = get_fdt; drck->set_configured = set_configured; drck->entity_sense = entity_sense; drck->attach = attach; drck->detach = detach; drck->release_pending = release_pending; }
1threat
Find the mode in array : <p>This code can only get the mode when single mode exist. I want to know how to return -1 when 2 modes exist. For example : 1 1 1 2 2 2 3. And return -1 when no mode exist, 1 2 3 4 5 6.</p> <pre><code> public Long getMode() { long [] num = this.getElements(); long maxValue=0, maxCount=0; for (int i = 0; i &lt; num.length; ++i){ long count = 0; for (int j = 0; j &lt; num.length; ++j){ if (num[j] == num[i]) ++count; } if (count &gt; maxCount){ maxCount = count; maxValue = num[i]; } } return maxValue; } </code></pre>
0debug
Find and replace text in a file between range of lines using sed : <p>I have a big text file (URL.txt) and I wish to perform the following using a single <em>sed</em> command:</p> <ol> <li><p>Find and replace text 'google' with 'facebook' between line numbers 19 and 33. </p></li> <li><p>Display the output on the terminal without altering the original file.</p></li> </ol>
0debug
Razor Generating Html : <p>my razor code</p> <pre><code>@Html.CheckBox("cbMSSProvider",true) </code></pre> <p>is generating HTML like</p> <pre><code> &lt;input checked="checked" id="cbHHAProvider" name="cbHHAProvider" type="checkbox" value="true"&gt; &lt;input name="cbHHAProvider" type="hidden" value="false"&gt; </code></pre> <p>Can some one tell why there is input(type=hidden)?</p>
0debug
I need the sequence in the list starting with 'b' and the next value is 'e' in sql server quering and eliminate all he other : [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/qwaTK.png Here is the image and i need the query which shows a value 'b' followed by 'e' and eliminate rest of the rows
0debug
When I submit my form, not all the information is being sent to my email : <p>I'm relatively new at coding and I've run into an issue. When I submit the filled out data in the form to my email, it won't submit the name or phone number so I essentially see it as a random, authorless message in my inbox. For obvious reasons, I need to capture and send ALL the data from the form to the specified email. I've used up all my knowledge so hopefully someone can help. </p> <p>TLDR; Form sends an email, but not with ALL the filled out information</p> <p>Thanks</p> <p>HTML:</p> <pre><code>&lt;form id="contact" action="send.php" method="post"&gt; &lt;fieldset&gt; &lt;input placeholder="Your name" type="text" name="name" tabindex="1" autofocus&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;input placeholder="Your Email Address" type="text" name="email" tabindex="2"&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;input placeholder="Your Phone Number" type="text" name"phone" tabindex="3"&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;textarea placeholder="Type your Message Here...." type="text" name="message" tabindex="5"&gt;&lt;/textarea&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;button name="submit" type="submit" id="contact-submit" data-submit="...Sending"&gt;Submit&lt;/button&gt; &lt;/fieldset&gt; </code></pre> <p></p> <p>PHP:</p> <pre><code> &lt;?php $from="noreply@email.com"; $email="my email"; $name=$_POST['name']; $phone=$_POST['phone']; $subject=$_POST['subject']; $message=$_POST['message']; mail ( $email, $subject, $message, "From:".$from); Print "Thank you! Your message has been sent!" ?&gt; </code></pre>
0debug
How do I get the size (width x height) of my pygame window : <p>I have created a window using</p> <pre><code>pygame.display.set_mode((width, height), pygame.OPENGL | pygame.DOUBLEBUF | pygame.RESIZABLE) </code></pre> <p>Later on in the app I want to be able to ask that window its width and height so I can decide how to process the mouse position.</p> <p>How do I access the dimensions of that pygame window elsewhere in the program? (event processing loop)</p>
0debug
Get only numbers from strings that are in the list : <p>So I have list that looks like this</p> <pre><code>mylist = ['storeitem_1','storeitem_2','storeitem_3'] </code></pre> <p>How would I go about getting only numbers from those strings? I tried following but it came out totally wrong.</p> <pre><code>for items in mylist: print(items.split("storeitem_")) </code></pre> <p>Any help is appreciated</p>
0debug
static void strongarm_ppc_handler_update(StrongARMPPCInfo *s) { uint32_t level, diff; int bit; level = s->olevel & s->dir; for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) { bit = ffs(diff) - 1; qemu_set_irq(s->handler[bit], (level >> bit) & 1); } s->prev_level = level; }
1threat
how to Increase Form Size?? Thisn't working : private void button2_Click(object sender, EventArgs e) { int i; for (i = 243; i >= 850; i++) { this.Width = i; } }
0debug
What is the design pattern used to write this code ? : what is the design pattern for this code ? class Foo { private $_connection; private static $_instance; private $_host = "Host"; private $_username = "Name"; private $_password = "encrypted Word"; private $_database = "Name"; public static function getInstance() { if(self::$_instance = 'Connected') { self::$_instance = new self(); } return self::$_instance; } private function __construct() { $this->_connection = new mysqli($this->_host, $this->_username, $this->_password, $this->_database); } public function getConnection() { return $this->_connection; } }
0debug
Deep Link with Push Notification - FCM - Android : <p><strong>What I want:</strong> I want to send push notification to users. When user tap on that notification, user should navigate to specific activity.</p> <p><strong>What I did:</strong> I created one deep link in Firebase console. I implemented <strong>FirebaseInstanceIdService</strong> &amp; <strong>FirebaseMessagingService</strong> as well. I'm able to catch Firebase message which I sent from Firebase console.</p> <p><strong>What is the issue:</strong> I'm not able to catch the dynamic link what I have created in Firebase console.</p> <p>My code is like below.</p> <p><strong>MyFirebaseInstanceIDService.java</strong></p> <pre><code> public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { private final String TAG = "MyFirebaseInstanceID"; @Override public void onTokenRefresh() { String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.e(TAG, "Refreshed token: " + refreshedToken); } } </code></pre> <p><strong>MyFirebaseMessagingService.java</strong></p> <pre><code> public class MyFirebaseMessagingService extends FirebaseMessagingService { private final String TAG = "MyFbaseMessagingService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { String message = remoteMessage.getNotification().getBody(); Log.e(TAG, "\nmessage: " + message); sendNotification(message); } private void sendNotification(String message) { Intent intent = new Intent(this, TestDeepLinkActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setAutoCancel(true) .setContentTitle("FCM Test") .setContentText(message) .setSound(defaultSoundUri) .setSmallIcon(R.drawable.common_google_signin_btn_icon_dark) .setContentIntent(pendingIntent); NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); manager.notify(0, builder.build()); } } </code></pre> <p><strong>Firebase Console Image</strong></p> <p><a href="https://i.stack.imgur.com/trqRp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/trqRp.png" alt="Firebase Console Image"></a></p>
0debug
Translate my website content : <p>Guys I know that this question asked before but its not the same.</p> <p>I have a website that I want to translate its content.</p> <p><strong>What I came up with:</strong></p> <p>1-gettext //its not good for me</p> <p>2-google api //google translate is very bad and also google add its name in my wbesite</p> <p>3-make another files with different language.</p> <p>I prefer the last one because I only want my website to be English and Arabic.</p> <p>Any more solutions? and what disadvantages of making the third solution ?</p> <p>thanks</p>
0debug
Extracting variables from data printed to screen : <p>I am working on older code, oldCode.py Basically it prints to screen some data, like the sales of items 1,2 and 3.</p> <p>print '1 500' print '2 842' print '3 734'</p> <p>I want to extract this data for further processing. I know I can stop python from printing this information to the screen, and make it write the information to some file output.dat by writing</p> <pre><code>python oldCode.py &gt;&gt; output.dat </code></pre> <p>However, in the first place how do I even extract the data to process from output.dat when that isn't defined in the script in the first place? And I have to write the results of my processing step to the same output file. Short of rewriting the entire code (final option), how will I be able to do this?</p>
0debug
static uint16_t *phys_page_find_alloc(target_phys_addr_t index, int alloc) { PhysPageEntry *lp, *p; int i, j; lp = &phys_map; for (i = P_L2_LEVELS - 1; i >= 0; i--) { if (lp->u.node == NULL) { if (!alloc) { return NULL; } lp->u.node = p = g_malloc0(sizeof(PhysPageEntry) * L2_SIZE); if (i == 0) { for (j = 0; j < L2_SIZE; j++) { p[j].u.leaf = phys_section_unassigned; } } } lp = &lp->u.node[(index >> (i * L2_BITS)) & (L2_SIZE - 1)]; } return &lp->u.leaf; }
1threat
how to execute simultaneous builds in jenkins? : build 1 is started to execute, I want to execute build 2 even if the build 1 is not fully executed(during the execution of build 1 only).but build 1 should start first,because first build is server we need to start first,it wont stop during this execution only we need to start next build to obtain the proper output.
0debug
how to print u32string and u16string to the console in c++ : <p>I recently bumped into string literals and found some new strings like u16string and u32string. I found that wstring can be printed to the console using std::wcout, but that doesn't work for u16string or u32string. How can i print these to the Console??</p>
0debug
static int nvdec_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { NVDECContext *ctx = avctx->internal->hwaccel_priv_data; void *tmp; tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated, (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets)); if (!tmp) return AVERROR(ENOMEM); ctx->slice_offsets = tmp; if (!ctx->bitstream) ctx->bitstream = (uint8_t*)buffer; ctx->slice_offsets[ctx->nb_slices] = buffer - ctx->bitstream; ctx->bitstream_len += size; ctx->nb_slices++; return 0; }
1threat