problem
stringlengths
26
131k
labels
class label
2 classes
this pogo-uwp has lotsofproblems in it it is annoying : i have a problem [error][1] [1]: http://i.stack.imgur.com/84flo.png <Page.DataContext> <viewModels:CapturePokemonPageViewModel x:Name="ViewModel" /> </Page.DataContext> //this error <<< and errors lots of them i have tried everything asking the community asking people everything but it wont go away it is like the embodiment of Satan but for programmers and Pogo deves or someone help me
0debug
static int vaapi_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { H264Context * const h = avctx->priv_data; H264SliceContext *sl = &h->slice_ctx[0]; VASliceParameterBufferH264 *slice_param; ff_dlog(avctx, "vaapi_h264_decode_slice(): buffer %p, size %d\n", buffer, size); slice_param = (VASliceParameterBufferH264 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size); if (!slice_param) return -1; slice_param->slice_data_bit_offset = get_bits_count(&sl->gb); slice_param->first_mb_in_slice = (sl->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + sl->mb_x; slice_param->slice_type = ff_h264_get_slice_type(sl); slice_param->direct_spatial_mv_pred_flag = sl->slice_type == AV_PICTURE_TYPE_B ? sl->direct_spatial_mv_pred : 0; slice_param->num_ref_idx_l0_active_minus1 = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0; slice_param->num_ref_idx_l1_active_minus1 = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0; slice_param->cabac_init_idc = sl->cabac_init_idc; slice_param->slice_qp_delta = sl->qscale - h->pps.init_qp; slice_param->disable_deblocking_filter_idc = sl->deblocking_filter < 2 ? !sl->deblocking_filter : sl->deblocking_filter; slice_param->slice_alpha_c0_offset_div2 = sl->slice_alpha_c0_offset / 2; slice_param->slice_beta_offset_div2 = sl->slice_beta_offset / 2; slice_param->luma_log2_weight_denom = sl->pwt.luma_log2_weight_denom; slice_param->chroma_log2_weight_denom = sl->pwt.chroma_log2_weight_denom; fill_vaapi_RefPicList(slice_param->RefPicList0, sl->ref_list[0], sl->list_count > 0 ? sl->ref_count[0] : 0); fill_vaapi_RefPicList(slice_param->RefPicList1, sl->ref_list[1], sl->list_count > 1 ? sl->ref_count[1] : 0); fill_vaapi_plain_pred_weight_table(h, 0, &slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0, &slice_param->chroma_weight_l0_flag, slice_param->chroma_weight_l0, slice_param->chroma_offset_l0); fill_vaapi_plain_pred_weight_table(h, 1, &slice_param->luma_weight_l1_flag, slice_param->luma_weight_l1, slice_param->luma_offset_l1, &slice_param->chroma_weight_l1_flag, slice_param->chroma_weight_l1, slice_param->chroma_offset_l1); return 0; }
1threat
xCode: Table View Error : I'm pretty new to Xcode and I'm learning, but I'm trying to make a Test app. I can't get it to show up in the app like i=I set it in xCode?[This shows my problem.][1] [1]: https://i.stack.imgur.com/0IPtg.png
0debug
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, MachineState *machine, ISADevice *floppy, BusState *idebus0, BusState *idebus1, ISADevice *s) { int val, nb, i; FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE }; static pc_cmos_init_late_arg arg; PCMachineState *pc_machine = PC_MACHINE(machine); val = MIN(ram_size / 1024, 640); rtc_set_memory(s, 0x15, val); rtc_set_memory(s, 0x16, val >> 8); if (ram_size > 1024 * 1024) { val = (ram_size - 1024 * 1024) / 1024; } else { val = 0; } if (val > 65535) val = 65535; rtc_set_memory(s, 0x17, val); rtc_set_memory(s, 0x18, val >> 8); rtc_set_memory(s, 0x30, val); rtc_set_memory(s, 0x31, val >> 8); if (ram_size > 16 * 1024 * 1024) { val = (ram_size - 16 * 1024 * 1024) / 65536; } else { val = 0; } if (val > 65535) val = 65535; rtc_set_memory(s, 0x34, val); rtc_set_memory(s, 0x35, val >> 8); val = above_4g_mem_size / 65536; rtc_set_memory(s, 0x5b, val); rtc_set_memory(s, 0x5c, val >> 8); rtc_set_memory(s, 0x5d, val >> 16); rtc_set_memory(s, 0x5f, smp_cpus - 1); object_property_add_link(OBJECT(machine), "rtc_state", TYPE_ISA_DEVICE, (Object **)&pc_machine->rtc, object_property_allow_set_link, OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); object_property_set_link(OBJECT(machine), OBJECT(s), "rtc_state", &error_abort); if (set_boot_dev(s, boot_device)) { exit(1); } if (floppy) { for (i = 0; i < 2; i++) { fd_type[i] = isa_fdc_get_drive_type(floppy, i); } } val = (cmos_get_fd_drive_type(fd_type[0]) << 4) | cmos_get_fd_drive_type(fd_type[1]); rtc_set_memory(s, 0x10, val); val = 0; nb = 0; if (fd_type[0] < FDRIVE_DRV_NONE) { nb++; } if (fd_type[1] < FDRIVE_DRV_NONE) { nb++; } switch (nb) { case 0: break; case 1: val |= 0x01; break; case 2: val |= 0x41; break; } val |= 0x02; val |= 0x04; rtc_set_memory(s, REG_EQUIPMENT_BYTE, val); arg.rtc_state = s; arg.idebus[0] = idebus0; arg.idebus[1] = idebus1; qemu_register_reset(pc_cmos_init_late, &arg); }
1threat
Links not clickable? : <p>I'm making a simple launchpage for class, but now some of my links aren't clickable. The Home link is fine,but all the other links won't respond to a click or hover.</p> <p>See the live page <a href="http://ahays.lindenweb.us/klh165" rel="nofollow noreferrer" title="here">here</a>.</p>
0debug
remove the first line from my directiry : how can i remove the first line from my list of file , this is my code, open my directory use strict; use warnings; use utf8; use Encode; use Encode::Guess; use Devel::Peek; my $new_directory = '/home/lenovo/corpus'; my $directory = '/home/lenovo/corpus'; open( my $FhResultat, '>:encoding(UTF-8)', $FichierResulat ); my $dir = '/home/corpus'; opendir (DIR, $directory) or die $!; my @tab; while (my $file = readdir(DIR)) { next if ($file eq "." or $file eq ".." ); #print "$file\n"; my $filename_read = decode('utf8', $file); #print $FichierResulat "$file\n"; push @tab, "$filename_read"; } closedir(DIR); open my file foreach my $val(@tab){ utf8::encode($val); my $filename = $val; open(my $in, '<:utf8', $filename) or die "Unable to open '$filename' for read: $!"; my $newfile = "$filename.new"; open(my $out, '>:utf8', $newfile) or die "Unable to open '$newfile' for write: $!"; remove the first line my @ins = <$in>; # read the contents into an array chomp @ins; shift @ins; # remove the first element from the array print $out @ins; close($in); close $out; `rename $newfile,$filename or die "unable to rename '$newfile' to '$filename': $!"; } it seems true but the result is an empty file can some one help me PLZ !!!
0debug
Loop over Foreach Values : <p>I have a Nested array, within my JSON <code>$repsonse</code> The <code>ImageURI</code> vary from <code>[0]-[16]</code> sometimes there is 5 sometimes there is 16.</p> <p>I would like to loop over <code>$car['Images'][0]['ImageURI'];</code> for example: This is car has 4 cars and for the rest responds with a <code>Notice: Undefined offset:</code> So that when there is not 16 cars it accepts that's how many there are. </p> <pre><code>https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&amp;VUID=39bcc4df-b550-e911-a2cf-00155d187d03&amp;Rank=1&amp;Width=960https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&amp;VUID=39bcc4df-b550-e911-a2cf-00155d187d03&amp;Rank=2&amp;Width=960https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&amp;VUID=39bcc4df-b550-e911-a2cf-00155d187d03&amp;Rank=3&amp;Width=960https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&amp;VUID=39bcc4df-b550-e911-a2cf-00155d187d03&amp;Rank=4&amp;Width=960https://vehiclestock-public.pinnacledms.net/ViewVehiclePhoto.aspx?BUID=a3db2a66-b4fb-4ac2-a78a-0f042aab50af&amp;VUID=39bcc4df-b550-e911-a2cf-00155d187d03&amp;Rank=5&amp;Width=960 Notice: Undefined offset: 5 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 101 Notice: Undefined offset: 6 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 102 Notice: Undefined offset: 7 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 103 Notice: Undefined offset: 8 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 104 Notice: Undefined offset: 9 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 105 Notice: Undefined offset: 10 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 106 Notice: Undefined offset: 11 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 107 Notice: Undefined offset: 12 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 108 Notice: Undefined offset: 13 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 109 Notice: Undefined offset: 14 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 110 Notice: Undefined offset: 15 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 111 Notice: Undefined offset: 16 in /customers/8/9/9/testsite.agency/httpd.www/api/wp-content/themes/divi-child/functions.php on line 112 ` </code></pre> <p>Heres my Code:</p> <pre><code>if(array_key_exists(0,$car['Images'])) { if( isset($car['Images']) ) { //it exists echo $car['Images'][0]['ImageURI']; echo $car['Images'][1]['ImageURI']; echo $car['Images'][2]['ImageURI']; echo $car['Images'][3]['ImageURI']; echo $car['Images'][4]['ImageURI']; echo $car['Images'][5]['ImageURI']; echo $car['Images'][6]['ImageURI']; echo $car['Images'][7]['ImageURI']; echo $car['Images'][8]['ImageURI']; echo $car['Images'][9]['ImageURI']; echo $car['Images'][10]['ImageURI']; echo $car['Images'][11]['ImageURI']; echo $car['Images'][12]['ImageURI']; echo $car['Images'][13]['ImageURI']; echo $car['Images'][14]['ImageURI']; echo $car['Images'][15]['ImageURI']; echo $car['Images'][16]['ImageURI']; echo "&lt;br&gt;";echo "&lt;br&gt;";echo "&lt;br&gt;"; } }else{ continue; } </code></pre>
0debug
static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); if (dev->hotplugged) { cpu_synchronize_post_init(cpu); cpu_resume(cpu); } }
1threat
How to send data to server using volley? : I want to send data to server in the following format using volley.How can i do this.. $orders = [ ['cid' => 1, 'pid' => 1, 'quantity' => 5, 'rid' => 1, 'eid' => 1, 'did' => 1, 'takenAt' => '2017-07-24 04:03:23'], ['cid' => 1, 'pid' => 1, 'quantity' => 5, 'rid' => 2, 'eid' => 1, 'did' => 1, 'takenAt' => '2017-07-24 04:03:23'], ['cid' => 1, 'pid' => 1, 'quantity' => 5, 'rid' => 3, 'eid' => 1, 'did' => 1, 'takenAt' => '2017-07-24 04:03:23'] ]; so far i have done this but its raising exception StringRequest stringRequest = new StringRequest(Request.Method.POST, Constant.API_SUBMIT_ORDER, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.e("DATA", "RESPONSE===" + response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { error.printStackTrace(); } }) { @Override protected Map<String, String> getParams() { Calendar cal = Calendar.getInstance(); String time2 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss a ").format(cal.getTime()); Map<String, String> orders = new HashMap<>(); for (int i = 0; i < myProductArrayList.size(); i++) { orders.put("cid", "1"); orders.put("skuid", myProductArrayList.get(i).getProductId()); orders.put("qty", "50"); orders.put("rid", "1"); orders.put("eid", "mukulsingh"); orders.put("did", "1"); orders.put("takenAt", time2); } return orders; } }; stringRequest.setRetryPolicy(new DefaultRetryPolicy( MY_SOCKET_TIMEOUT_MS, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); RequestQueue requestQueue = Volley.newRequestQueue(this); requestQueue.add(stringRequest);
0debug
Why wont this batch script run after login? : So after school, since the school doesn't allow us to use Visual Studio because we aren't able to download files that require admin perms, i typically screw around with Batch. However, I started a small project a few days ago. The project is supposed to be a cool little command terminal with a login screen. However, after I get passed the login, it fails to open any more. Does anyone have any suggestions/fixes? (Also, I realize that parts of the code weren't made 100% by me) @echo off :LOGIN set/p uname= < HoodedBlack set/p pass=< Password title Login cls echo ------------------------------------------------- echo HoodedBlack's Mainframe V0.1 echo Login echo ------------------------------------------------- echo. echo. set/p "unamel= Username : set/p "passwordl= Password : echo. IF "%passwordl%"=="Password" goto LOADING IF NOT "%passwordl%"=="Password" goto ERROR :ERROR echo ------------------------------------------------- echo Error echo ------------------------------------------------- echo Invalid Username or password echo An Admin has been notified of this attempt. pause :LOADING title Loading... set load=%load%!!!!!!! cls echo ------------------------------------------------- echo Login echo ------------------------------------------------- echo. echo. echo Username : %unamel% echo Password : %passwordl% echo. echo. echo Logging in... echo =================================== echo %load% echo =================================== echo. Please Wait... echo. ping localhost -n 2 >nul set/a loadnum=%loadnum% +1 if %loadnum%==5 goto DONE goto LOADING :DONE title Done cls echo ------------------------------------------------- echo Done echo ------------------------------------------------- echo. echo # echo # echo # # Login Successfully echo # # echo # echo. echo. echo ------------------------------------------------- pause goto WELCOME :WELCOME title Welcome cls echo ---------------------------------------------------- echo Welcome, HoodedBlack! Your rank is: Mainframe Owner echo Mainframe v0.1 HoodedBlack echo ---------------------------------------------------- echo. echo Hello! echo Say "cmds" for a list of commands echo or say "exit" to exit the mainframe echo. echo. echo. echo. set INPUT= set /P INPUT=Type input: %=% If %INPUT%=="cmds" goto cmds If NOT %INPUT%=="cmds" then If %INPUT%=="exit" goto exit If NOT %INPUT%=="exit" then If %INPUT%=="DDoS" goto DDoS If %INPUT%=="DDoS" then If %INPUT%=="DoS" goto DoS If %INPUT%=="DoS" then If %INPUT%=="Password" goto pword If NOT %INPUT%=="Password" then pause :cmds title cmds cls echo ------------------------------------------------- echo Commands list echo ------------------------------------------------- echo. echo DDoS: Redirects you to a ddos service. echo DoS: Sends a ping dos attack echo (More commands coming soon!) echo ------------------------------------------------- pause goto WELCOME :exit title exit exit :DDoS start www.alphastress.com :DoS title cmds cls echo ------------------------------------------------- echo Ping attack (Denial Of Service) echo ------------------------------------------------- echo Select an IP to send the attack to echo echo ------------------------------------------------- :pword title Password Generator cls echo I will make you a new password. echo Please write the password down somewhere in case you forget it. echo ----------------------------------------­----------------------- echo 1) 1 Random Password echo 2) 5 Random Passwords echo 3) 10 Random Passwords echo Input your choice set input= set /p input= Choice: if %input%==1 goto A if NOT goto Start2 if %input%==2 goto B if NOT goto Start2 if %input%==3 goto C if NOT goto Start2 :A cls echo Your password is %random% echo Now choose what you want to do. echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if %input%==1 goto Start2 if NOT goto Start 2 if %input%==2 goto Exit if NOT goto Start 2 :Exit exit :B cls echo Your 5 passwords are %random%, %random%, %random%, %random%, %random%. echo Now choose what you want to do. echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if %input%==1 goto Start2 if NOT goto Start 2 if %input%==2 goto Exit if NOT goto Start 2 :C cls echo Your 10 Passwords are %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random%, %random% echo Now choose what you want to do. echo 1) Go back to the beginning echo 2) Exit set input= set /p input= Choice: if %input%==1 goto Start2 if NOT goto Start 2 if %input%==2 goto Exit if NOT goto Start 2
0debug
How to test Django's UpdateView? : <p>As a simplified example, I've written an <code>UpdateView</code> for a <code>Book</code> model, as well as a <code>ListView</code> to redirect to upon success:</p> <pre><code>from django.urls import reverse from django.views.generic import ListView from django.views.generic.edit import UpdateView from .models import Book class BookUpdate(UpdateView): model = Book fields = ['title', 'author'] class BookList(ListView): model = Book </code></pre> <p>The <code>Book</code> model is defined as</p> <pre><code>class Book(models.Model): title = models.CharField(max_length=100) author = models.CharField(max_length=100, blank=True) def get_absolute_url(self): return reverse('books-list') </code></pre> <p>where <code>urls.py</code> is</p> <pre><code>from django.urls import path from books.views import BookUpdate, BookList urlpatterns = [ path('books/', BookList.as_view(), name='books-list'), path('book/&lt;int:pk&gt;/', BookUpdate.as_view(), name='book-update') ] </code></pre> <p>In <code>books/tests.py</code> I've tried to write the following test:</p> <pre><code>class BookUpdateTest(TestCase): def test_update_book(self): book = Book.objects.create(title='The Catcher in the Rye') response = self.client.post( reverse('book-update', kwargs={'pk': book.id}), {'author': 'J.D. Salinger'}) self.assertEqual(response.status_code, 200) book.refresh_from_db() self.assertEqual(book.author, 'J.D. Salinger') </code></pre> <p>However, this test fails because the <code>book</code>'s <code>author</code> appears not to be updated after the <code>POST</code> request, even after refreshing from the database:</p> <pre><code>FAIL: test_update_book (books.tests.BookUpdateTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/kurtpeek/Documents/Scratch/book_project/books/tests.py", line 46, in test_update_book self.assertEqual(book.author, 'J.D. Salinger') AssertionError: '' != 'J.D. Salinger' + J.D. Salinger </code></pre> <p>On the other hand, if I run the development server and fill out the fields manually, everything seems to work as expected. How can I write a unit test for the <code>UpdateView</code> which captures the user updating the fields, submitting the form, and making changes to the corresponding objects?</p>
0debug
Javascrypt Dynamic Text in Header Band : I have put a dynamic text header band thanks to a code I have found and adapted <marquee behavior="scroll" direction="left" scrollamount="3" scrolldelay="60" onmouseover="this.stop()" onmouseout="this.start()" bgcolor="#232F3E"> <strong>NOUVEAU : 1 article acheté = <u><a target="_blank" class="header" href=/pages/arbres title="1 article acheté = 1arbre – Trésor Ethnique">1 ARBRE PLANTÉ</a></u></strong> avec l’association <i>One Tree Planted</i> &nbsp;&nbsp;·&nbsp;&nbsp; Première Commande: 10% de Réduction avec le Coupon BIENVENUE &nbsp;&nbsp;·&nbsp;&nbsp; Livraison Suivie OFFERTE &nbsp;&nbsp;·&nbsp;&nbsp; Plus de 5.000 Clientes Satisfaites </marquee> It works pretty well, but I'd like instead the text to be on 4 different lines. Each 3 seconds, it would switch (no scroll) to the next line of text (in a vertical movement) The total sequence would then last 12 seconds Here is the website: https://www.tresor-ethnique.com/ Any idea on how to do that? PS: I use a theme, so I can just enter HTML into the field I know how to integrate a Javascript code inside HTML if this is needed Let me know thanks :)
0debug
static void register_subpage(AddressSpaceDispatch *d, MemoryRegionSection *section) { subpage_t *subpage; hwaddr base = section->offset_within_address_space & TARGET_PAGE_MASK; MemoryRegionSection *existing = phys_page_find(d->phys_map, base, next_map.nodes, next_map.sections); MemoryRegionSection subsection = { .offset_within_address_space = base, .size = int128_make64(TARGET_PAGE_SIZE), }; hwaddr start, end; assert(existing->mr->subpage || existing->mr == &io_mem_unassigned); if (!(existing->mr->subpage)) { subpage = subpage_init(d->as, base); subsection.mr = &subpage->iomem; phys_page_set(d, base >> TARGET_PAGE_BITS, 1, phys_section_add(&subsection)); } else { subpage = container_of(existing->mr, subpage_t, iomem); } start = section->offset_within_address_space & ~TARGET_PAGE_MASK; end = start + int128_get64(section->size) - 1; subpage_register(subpage, start, end, phys_section_add(section)); }
1threat
find which values satisfy a boolean formula : <p>I have the following Boolean expression x > 5 AND y > 10</p> <pre><code>C:\&gt;python Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36)Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; x = 3 &gt;&gt;&gt; y = 11 &gt;&gt;&gt; eval("x&gt;5 and y &gt; 10") False &gt;&gt;&gt; x = 6 &gt;&gt;&gt; eval("x&gt;5 and y &gt; 10") True &gt;&gt;&gt; </code></pre> <p>When x > 5 and y > 10 the evaluation is formula is evaluated to "true". </p> <p>When x == 6 and y == 5 the formula is evaluated to "false" because y &lt; 10. </p> <p>I would like to know if there is a library/software (python is used as an example, the language is not a problem) that can answer to the caller which values satisfy the formula. </p>
0debug
static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt) { MpegTSContext *ts = s->priv_data; int ret, i; ts->pkt = pkt; ret = handle_packets(ts, 0); if (ret < 0) { for (i = 0; i < NB_PID_MAX; i++) { if (ts->pids[i] && ts->pids[i]->type == MPEGTS_PES) { PESContext *pes = ts->pids[i]->u.pes_filter.opaque; if (pes->state == MPEGTS_PAYLOAD && pes->data_index > 0) { new_pes_packet(pes, pkt); pes->state = MPEGTS_SKIP; ret = 0; break; } } } } if (!ret && pkt->size < 0) ret = AVERROR(EINTR); return ret; }
1threat
How to get current location or move to current location in Xamarin.Forms.Map : <p>Since the Map already shows the user location (with IsShowingUser) I just want to zoom to this location. Is this easily possible or do I need to get the location on every platform, since I don't find any GeoLocation object. Only the GeoCoder... Is this not a common usecase to zoom to users position?</p>
0debug
select name,(name,1,3||phone_no,1,3)from users order by (name); : I'm writing a query for the above problem and it is showing error. Write a to display user name and password. Password should be generate by concatenate first three characters of user name and first three numbers in phone number and give an alias name as password. Sort the result based on user name
0debug
Sort a list in all possible ways in Python : <p>Let's suppose we make this list</p> <pre><code>a=[1,2,3] </code></pre> <p>a can be sorted in 6 possible ways</p> <pre><code>a=[1,2,3] a=[1,3,2] a=[2,1,3] a=[2,3,1] a=[3,1,2] a=[3,2,1] </code></pre> <p>How do I make a function that automatically does that but with bigger lists?</p>
0debug
uint32_t do_arm_semihosting(CPUARMState *env) { target_ulong args; char * s; int nr; uint32_t ret; uint32_t len; #ifdef CONFIG_USER_ONLY TaskState *ts = env->opaque; #else CPUARMState *ts = env; #endif nr = env->regs[0]; args = env->regs[1]; switch (nr) { case TARGET_SYS_OPEN: if (!(s = lock_user_string(ARG(0)))) return (uint32_t)-1; if (ARG(1) >= 12) return (uint32_t)-1; if (strcmp(s, ":tt") == 0) { if (ARG(1) < 4) return STDIN_FILENO; else return STDOUT_FILENO; } if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0), (int)ARG(2)+1, gdb_open_modeflags[ARG(1)]); return env->regs[0]; } else { ret = set_swi_errno(ts, open(s, open_modeflags[ARG(1)], 0644)); } unlock_user(s, ARG(0), 0); return ret; case TARGET_SYS_CLOSE: if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "close,%x", ARG(0)); return env->regs[0]; } else { return set_swi_errno(ts, close(ARG(0))); } case TARGET_SYS_WRITEC: { char c; if (get_user_u8(c, args)) return (uint32_t)-1; if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "write,2,%x,1", args); return env->regs[0]; } else { return write(STDERR_FILENO, &c, 1); } } case TARGET_SYS_WRITE0: if (!(s = lock_user_string(args))) return (uint32_t)-1; len = strlen(s); if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "write,2,%x,%x\n", args, len); ret = env->regs[0]; } else { ret = write(STDERR_FILENO, s, len); } unlock_user(s, args, 0); return ret; case TARGET_SYS_WRITE: len = ARG(2); if (use_gdb_syscalls()) { arm_semi_syscall_len = len; gdb_do_syscall(arm_semi_cb, "write,%x,%x,%x", ARG(0), ARG(1), len); return env->regs[0]; } else { if (!(s = lock_user(VERIFY_READ, ARG(1), len, 1))) return (uint32_t)-1; ret = set_swi_errno(ts, write(ARG(0), s, len)); unlock_user(s, ARG(1), 0); if (ret == (uint32_t)-1) return -1; return len - ret; } case TARGET_SYS_READ: len = ARG(2); if (use_gdb_syscalls()) { arm_semi_syscall_len = len; gdb_do_syscall(arm_semi_cb, "read,%x,%x,%x", ARG(0), ARG(1), len); return env->regs[0]; } else { if (!(s = lock_user(VERIFY_WRITE, ARG(1), len, 0))) return (uint32_t)-1; do ret = set_swi_errno(ts, read(ARG(0), s, len)); while (ret == -1 && errno == EINTR); unlock_user(s, ARG(1), len); if (ret == (uint32_t)-1) return -1; return len - ret; } case TARGET_SYS_READC: return 0; case TARGET_SYS_ISTTY: if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "isatty,%x", ARG(0)); return env->regs[0]; } else { return isatty(ARG(0)); } case TARGET_SYS_SEEK: if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "lseek,%x,%x,0", ARG(0), ARG(1)); return env->regs[0]; } else { ret = set_swi_errno(ts, lseek(ARG(0), ARG(1), SEEK_SET)); if (ret == (uint32_t)-1) return -1; return 0; } case TARGET_SYS_FLEN: if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_flen_cb, "fstat,%x,%x", ARG(0), env->regs[13]-64); return env->regs[0]; } else { struct stat buf; ret = set_swi_errno(ts, fstat(ARG(0), &buf)); if (ret == (uint32_t)-1) return -1; return buf.st_size; } case TARGET_SYS_TMPNAM: return -1; case TARGET_SYS_REMOVE: if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "unlink,%s", ARG(0), (int)ARG(1)+1); ret = env->regs[0]; } else { if (!(s = lock_user_string(ARG(0)))) return (uint32_t)-1; ret = set_swi_errno(ts, remove(s)); unlock_user(s, ARG(0), 0); } return ret; case TARGET_SYS_RENAME: if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "rename,%s,%s", ARG(0), (int)ARG(1)+1, ARG(2), (int)ARG(3)+1); return env->regs[0]; } else { char *s2; s = lock_user_string(ARG(0)); s2 = lock_user_string(ARG(2)); if (!s || !s2) ret = (uint32_t)-1; else ret = set_swi_errno(ts, rename(s, s2)); if (s2) unlock_user(s2, ARG(2), 0); if (s) unlock_user(s, ARG(0), 0); return ret; } case TARGET_SYS_CLOCK: return clock() / (CLOCKS_PER_SEC / 100); case TARGET_SYS_TIME: return set_swi_errno(ts, time(NULL)); case TARGET_SYS_SYSTEM: if (use_gdb_syscalls()) { gdb_do_syscall(arm_semi_cb, "system,%s", ARG(0), (int)ARG(1)+1); return env->regs[0]; } else { if (!(s = lock_user_string(ARG(0)))) return (uint32_t)-1; ret = set_swi_errno(ts, system(s)); unlock_user(s, ARG(0), 0); return ret; } case TARGET_SYS_ERRNO: #ifdef CONFIG_USER_ONLY return ts->swi_errno; #else return syscall_err; #endif case TARGET_SYS_GET_CMDLINE: { char *output_buffer; size_t input_size = ARG(1); size_t output_size; int status = 0; #if !defined(CONFIG_USER_ONLY) output_size = strlen(ts->boot_info->kernel_filename) + 1 + strlen(ts->boot_info->kernel_cmdline) + 1; #else unsigned int i; output_size = ts->info->arg_end - ts->info->arg_start; if (!output_size) { output_size = 1; } #endif if (output_size > input_size) { return -1; } SET_ARG(1, output_size - 1); output_buffer = lock_user(VERIFY_WRITE, ARG(0), output_size, 0); if (!output_buffer) { return -1; } #if !defined(CONFIG_USER_ONLY) pstrcpy(output_buffer, output_size, ts->boot_info->kernel_filename); pstrcat(output_buffer, output_size, " "); pstrcat(output_buffer, output_size, ts->boot_info->kernel_cmdline); #else if (output_size == 1) { output_buffer[0] = '\0'; goto out; } if (copy_from_user(output_buffer, ts->info->arg_start, output_size)) { status = -1; goto out; } for (i = 0; i < output_size - 1; i++) { if (output_buffer[i] == 0) { output_buffer[i] = ' '; } } out: #endif unlock_user(output_buffer, ARG(0), output_size); return status; } case TARGET_SYS_HEAPINFO: { uint32_t *ptr; uint32_t limit; #ifdef CONFIG_USER_ONLY if (!ts->heap_limit) { abi_ulong ret; ts->heap_base = do_brk(0); limit = ts->heap_base + ARM_ANGEL_HEAP_SIZE; for (;;) { ret = do_brk(limit); if (ret >= limit) { break; } limit = (ts->heap_base >> 1) + (limit >> 1); } ts->heap_limit = limit; } if (!(ptr = lock_user(VERIFY_WRITE, ARG(0), 16, 0))) return (uint32_t)-1; ptr[0] = tswap32(ts->heap_base); ptr[1] = tswap32(ts->heap_limit); ptr[2] = tswap32(ts->stack_base); ptr[3] = tswap32(0); unlock_user(ptr, ARG(0), 16); #else limit = ram_size; if (!(ptr = lock_user(VERIFY_WRITE, ARG(0), 16, 0))) return (uint32_t)-1; ptr[0] = tswap32(limit / 2); ptr[1] = tswap32(limit); ptr[2] = tswap32(limit); ptr[3] = tswap32(0); unlock_user(ptr, ARG(0), 16); #endif return 0; } case TARGET_SYS_EXIT: gdb_exit(env, 0); exit(0); default: fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr); cpu_dump_state(env, stderr, fprintf, 0); abort(); } }
1threat
How can ı fix response text? : I use Google Cloud Vision Api (Text_Detection) it is working normal but when ı return answer from the Google, message style like image I want just one text e.g "ACADEMIC PLANNER" so how can ı remove front of Academic "null:" and other words ? İmage e.g (https://i.stack.imgur.com/OE5U4.png) And here is my code ; private String convertResponseToString(BatchAnnotateImagesResponse response) { String message = "I found these things:\n\n"; List<EntityAnnotation> labels = response.getResponses().get(0).getTextAnnotations(); if (labels != null) { for (EntityAnnotation label : labels) { message += String.format("%.3f: %s", label.getScore(), label.getDescription()); message += "\n"; } } else { message += "nothing"; } return message; }
0debug
Using Regex to swap some letters and numbers around : <p>I'm trying to use RegEx in vb.net to swap a pattern of letters and numbers around and am just having no luck in understanding how to use RegEx or if it is even possible with RegEx.</p> <p>I have a string that looks like this "blah blah ABCXY20 blah blah" and I need to change it to "blah blah ABC20XY blah blah"</p> <p>So there is other text before and after the part I need to work with that I just need to stay how it is. I'm just interested in moving the "XY" letters to after the number. It may not be the actual letters "ABC" or "XY" it could be a different pattern, but whatever it is, the pattern is always consistent or the same three letters then the same two letters then a number or arbitary length.</p>
0debug
static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, ARMMMUIdx mmu_idx, ARMMMUFaultInfo *fi) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; MemTxAttrs attrs = {}; AddressSpace *as; attrs.secure = is_secure; as = arm_addressspace(cs, attrs); addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi); if (fi->s1ptw) { return 0; } if (regime_translation_big_endian(env, mmu_idx)) { return address_space_ldq_be(as, addr, attrs, NULL); } else { return address_space_ldq_le(as, addr, attrs, NULL); } }
1threat
Word Permutations : <p>Hey I am trying to figure out how to find all permutations of a set of words. The goal I am attempting to reach is to create all of the different ways a set of words can be jumbled. The phrase "Stack over flow" could become</p> <p>Stack over flow</p> <p>Over flow stack</p> <p>flow stack over</p> <p>over stack flow</p> <p>flow over stack</p> <p>stack flow over</p> <p>Whenever I try to do the above, it ends up printing permutations of the characters within the string, not permutations of whole words.</p> <p>Help?</p>
0debug
How to lunch 100 and more servers in Chef : i am new to chef i have successfully configured chef workstation and server so by using this below command i can be able to launch only one instance knife ec2 server create –image ami-cc5af9a5 -i ram.pem –flavor m1.small -x root –groups chef-client -Z us-east-1a -r “role[webserver]” By this command i can bootstrap only one node knife ec2 server create –image ami-a4827dc9 -i NVirginia.pem –flavor t2.micro -x root –groups RC-Corporation -Z us-east-1a -r “role[learn_chef_httpd]” So hear i want to launch&Bootstrap 100 and more instance so where i have to customize these commands
0debug
how to restrict user to input only upto two decimal point float numbers in python? : <p>I am new in python, i want to do is limit the float input by the user only upto two decimal point, eg: 1.11, user is not allowed to input 1.111 or more than to after two decimal point . Thank you </p>
0debug
RST: how to present the output of a `tree` command? : <p>I would like to present the output of a <code>tree</code> command in a Restructured Text document. I am using this code:</p> <pre><code>.. code-block:: bash project ├── demo.py ├── LICENCE.txt ├── processes │   ├── area.py │   └── bboxinout.py ├── pywps.cfg ├── requirements.txt ├── server.py ├── setup.py ├── static ├── templates └── tests </code></pre> <p>Which is producing the following output:</p> <p><a href="https://i.stack.imgur.com/4O7gs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4O7gs.png" alt="enter image description here"></a></p> <p>I then tried to replace the <code>tree</code> characters with unicode definitions, such as:</p> <p><code>.. |hbar| unicode:: 01C0 ..</code></p> <p>But the <code>|hbar|</code> sequence is printed verbatim when used inside a code block.</p> <p>Is there any other way to force these characters to be printed correctly?</p>
0debug
How to read JSON {"success": true} in Retrofit 2? : <p>In normal <code>JSONObject jsonResponse</code>, I simply use <code>boolean success = jsonResponse.getBoolean("success");</code> . Now, I am required to use Retrofit library. I know that the response is in GSON format. That's why I'm having a hard time figuring out how to deal with the <code>$response["success"]</code> in my <code>php</code> file.</p> <p>I tried this:</p> <pre><code> call.enqueue(new Callback&lt;User_Account_Model&gt;() { @Override public void onResponse(Call&lt;User_Account_Model&gt; call, Response&lt;User_Account_Model&gt; response) { try { JSONObject jsonResponse = new JSONObject(new Gson().toJson(response)); boolean success = jsonResponse.getBoolean("success"); Toast.makeText(MainActivity.this,String.valueOf(success),Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } </code></pre> <p>but what's inside the <code>try and catch</code> seems not to be executed. No Toast messages showing. Is my method correct and just missing something or it's completely wrong? </p>
0debug
IllegalArgumentException in Retrofit / must not have replace block : <p>I have the following code : </p> <pre><code> @GET("api.php?company_name={name}") Call&lt;Model&gt; getRoms_center(@Query("name") String name); </code></pre> <p>According to the official docs, I must use @Query, and i'm using it, but i'm getting the following error : </p> <pre><code>java.lang.IllegalArgumentException: URL query string "company_name={name}" must not have replace block. For dynamic query parameters use @Query. </code></pre>
0debug
import re regex = r'^[a-z]$|^([a-z]).*\1$' def check_char(string): if(re.search(regex, string)): return "Valid" else: return "Invalid"
0debug
Copy value of list not reference : <p>I have a list that i want to compare to after it gets modified. The previous_list = current_list followed by a modification to the current_list. But the issue i have is anytime the current_list is updated, the previous_list is also updated because everything in python is a reference. Ive tried, </p> <pre><code>previous_list = current_list[:] previous_list = current_list.copy() previous_list = list(current_list) </code></pre> <p>but none of these work, every time current_list is updated the previous list is updated immediately without reading this line,</p> <pre><code>previous_list = current_list[:] </code></pre> <p>again. </p> <p>My goal is to have a while loop the runs until the list are equal. Each loop the current_list is modified after the previous_list is updated with the current_value. I thought the solution was using one of the copy methods above to create a copy of the list and assign but maybe that is a reference too then.</p>
0debug
docker-compose.yml file naming convention : <p>What is the naming convention for the <code>docker-compose.yml</code> file? Should it always be named like this or am I free to rename it to, for instance, <code>docker-compose-jenkins.yml</code>?</p>
0debug
Chrome mousedown and mouseup events no longer working, other browsers are fine : <p>As of today (or yesterday, didn't notice it then), mousedown and mouseup events are no longer working. I am on Chrome Version 55.0.2883.95 (64-bit). Safari and FireFox are working fine (I am on a mac computer).</p> <p>Here is the code:</p> <pre><code>document.getElementById("floorplan-backdrop-rect").addEventListener('mousedown', function(ev) { o.clickDown(ev); }, false); document.getElementById("floorplan-backdrop-rect").addEventListener('mouseup', function(ev) { o.clickUp(ev); }, false); </code></pre> <p>Were there any API changes regarding mouse-events that we missed? Chrome does not throw any warning when registering the events either. Touchdown and touch up event seem to fail too (in emulated iPad mode in developer tools)</p> <p><strong><em>EDIT: Right after changing tab, or when resizing the window, the events seem to come through for a short while. Then they stop again..</em></strong></p> <p>Regards</p>
0debug
static void idct(uint8_t *dst, int dst_linesize, int src[64]) { int i, j, k; double tmp[64]; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { double sum = 0.0; for (k = 0; k < 8; k++) sum += c[k*8+j] * src[8*i+k]; tmp[8*i+j] = sum; } } for (j = 0; j < 8; j++) { for (i = 0; i < 8; i++) { double sum = 0.0; for (k = 0; k < 8; k++) sum += c[k*8+i]*tmp[8*k+j]; dst[dst_linesize*i + j] = av_clip_uint8((int)floor(sum+0.5)); } } }
1threat
Basic functionality of cljc files : <p>Normally, Clojure source files are named (for example) foo.clj, and Clojurescript source files are named foo.cljs. My impression is that in Clojure versions >= 1.7, I can name a file foo.cljc if I want it to be available for loading with <code>require</code> or <code>use</code> both from Clojure and Clojurescript. </p> <p>Is this correct? It seems to be implicit in the primary documentation pages on <a href="https://github.com/clojure/clojurescript/wiki/Using-cljc" rel="noreferrer">Using cljc</a> and <a href="https://github.com/clojure/clojurescript/wiki/Using-cljc" rel="noreferrer">reader conditions</a>, but as far as I can see it's never explicitly stated.</p> <p>This is not a question about using reader conditionals to specify alternate code for running in Clojure and Clojurescript; it's more fundamental. For example, I have a source file that contains code that's completely generic: It will run in both Clojure and Clojurescript unchanged. Can I assume that by naming it with ".cljc", <code>require</code> will always find it from inside both Clojure and Clojurescript (assuming it's named correctly, is in the correct location, etc.)?</p> <p>[I'm pretty sure that I'm right, but I'm not certain, and I thought it would be worth having the answer documented here if I'm correct.]</p>
0debug
void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val) { ARMCPU *cpu = arm_env_get_cpu(env); switch (reg) { case 0: xpsr_write(env, val, 0xf8000000); break; case 1: xpsr_write(env, val, 0xf8000000); break; case 2: xpsr_write(env, val, 0xfe00fc00); break; case 3: xpsr_write(env, val, 0xfe00fc00); break; case 5: break; case 6: xpsr_write(env, val, 0x0600fc00); break; case 7: xpsr_write(env, val, 0x0600fc00); break; case 8: if (env->v7m.current_sp) env->v7m.other_sp = val; else env->regs[13] = val; break; case 9: if (env->v7m.current_sp) env->regs[13] = val; else env->v7m.other_sp = val; break; case 16: if (val & 1) { env->daif |= PSTATE_I; } else { env->daif &= ~PSTATE_I; } break; case 17: env->v7m.basepri = val & 0xff; break; case 18: val &= 0xff; if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0)) env->v7m.basepri = val; break; case 19: if (val & 1) { env->daif |= PSTATE_F; } else { env->daif &= ~PSTATE_F; } break; case 20: env->v7m.control = val & 3; switch_v7m_sp(env, (val & 2) != 0); break; default: cpu_abort(CPU(cpu), "Unimplemented system register write (%d)\n", reg); return; } }
1threat
Preventing NullPointerException error on empty result set returned in JDBC : <p>I need advice on how I can avoid <code>java.lang.NullPointerException</code> when dealing with <code>JDBC</code> result set which I put on <code>Swing</code> components such as <code>JTable</code></p> <p>I have written a method which gets the result set encapsulated in an object from a DAO Implementation which I populate inside a <code>DefaultTableModel</code>.</p> <p>The problems is, the object returned by the dao implementation service may or may not have data/result set if the database table has no record yet.</p> <p>This results to a <code>NullPointerException</code></p> <pre><code>public DefaultTableModel getMiscellaneous(int gradeLevelId){ DefaultTableModel defaultTableModel = new DefaultTableModel(); String[] columns = {"Name","Amount"}; MiscellaneousFees miscellaneousFees = schoolFeesDaoImpl.getMiscellaneous(gradeLevelId); List&lt;Fee&gt; feeList = miscellaneousFees.getFees(); for(Fee fee: feeList){ Object[] rowData = {fee.getName(),fee.getAmount()}; defaultTableModel.addRow(rowData); } defaultTableModel.setColumnIdentifiers(columns); return defaultTableModel; } public MiscellaneousFees getMiscellaneous(int gradeLevelId) { MiscellaneousFees miscellaneousFees = new MiscellaneousFees(); List&lt;Fee&gt; feeList = new ArrayList&lt;&gt;(); String SQL = "{CALL getMiscellaneousFeesByGradeLevelId(?)}"; try (Connection con = DBUtil.getConnection(DBType.MYSQL); CallableStatement cs = con.prepareCall(SQL);){ cs.setInt(1, gradeLevelId); try(ResultSet rs = cs.executeQuery();){ while(rs.next()){ SchoolYear schoolYear = new SchoolYear(); schoolYear.setSchoolYearId(rs.getInt("schoolyear_id")); schoolYear.setYearFrom(rs.getInt("yearFrom")); schoolYear.setYearTo(rs.getInt("yearTo")); schoolYear.setIsActive(rs.getBoolean("isActive")); schoolYear.setStart_date(rs.getDate("start_date")); schoolYear.setEnd_date(rs.getDate("end_date")); schoolYear.setIsCurrentSchoolYear(rs.getBoolean("isCurrentSchoolYear")); GradeLevel gradeLevel = new GradeLevel(); gradeLevel.setId(rs.getInt("gradelevel_id")); gradeLevel.setLevel(rs.getInt("grade_level")); gradeLevel.setIsActive(rs.getBoolean("isActive")); FeeCategory feeCategory = new FeeCategory(); feeCategory.setCategory(rs.getString("fee_category")); feeCategory.setId(rs.getInt("fee_category_id")); Fee fee = new Fee(); fee.setId(rs.getInt("fee_id")); fee.setName(rs.getString("fee_name")); fee.setDescription(rs.getString("fee_description")); fee.setAmount(rs.getDouble("fee_amount")); fee.setFeeCategory(feeCategory); fee.setGradeLevel(gradeLevel); fee.setSchoolYear(schoolYear); feeList.add(fee); } miscellaneousFees.setFees(feeList); } } catch (SQLException e) { JOptionPane.showMessageDialog(null,e.getMessage()); } return miscellaneousFees; } </code></pre> <p>Any suggestion or advice of how I can prevent the <code>NullPointerException</code> when result set contained in the <code>miscellaneous</code> object is empty?</p> <p>I get the <code>NullPointerException</code> error in this line of code </p> <pre><code>MiscellaneousFees miscellaneousFees = schoolFeesDaoImpl.getMiscellaneous(gradeLevelId); </code></pre> <p>Thank you. </p>
0debug
Convert milliseconds into day,hour,minute and second iOS? : <p>I need to convert an milliseconds into Days, Hours, Minutes Second.</p> <p>ex: 5 Days, 4 hours, 13 minutes, 1 second.</p> <p>Thanks</p>
0debug
static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFPackage *package = arg; switch(tag) { case 0x4403: package->tracks_count = avio_rb32(pb); if (package->tracks_count >= UINT_MAX / sizeof(UID)) return -1; package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID)); if (!package->tracks_refs) return -1; avio_skip(pb, 4); avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); break; case 0x4401: avio_skip(pb, 16); avio_read(pb, package->package_uid, 16); break; case 0x4701: avio_read(pb, package->descriptor_ref, 16); break; } return 0; }
1threat
How to handle socket events as background service in Android? : <p>I'm new to Android development and I wanted my app to be able to detect socket events even when app is not active via Background service (so I can do push notification e.g if there's a new message triggered by a socket event like how Whatsapp and others do it). </p> <p>I implemented Background service and an application class that starts the service but stuck where and how to put the socket events as Runnable task in my Background service. </p> <p>I modified the socket.io android chat project example below and added service and application class.</p> <p><strong>ChatApplication.java</strong></p> <pre><code>package com.github.nkzawa.socketio.androidchat; import android.app.Application; import android.content.Intent; import android.content.res.Configuration; import io.socket.client.IO; import io.socket.client.Socket; import java.net.URISyntaxException; public class ChatApplication extends Application { @Override // called when the application is starting, before any other application objects have been created public void onCreate() { super.onCreate(); // represents our background service Intent background = new Intent(this, SocketBackgroundService.class); startService(background); } private Socket mSocket; { try { mSocket = IO.socket(Constants.CHAT_SERVER_URL); } catch (URISyntaxException e) { throw new RuntimeException(e); } } public Socket getSocket() { return mSocket; } } </code></pre> <p><strong>SocketBackgroundService.java</strong></p> <pre><code>package com.github.nkzawa.socketio.androidchat; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; public class SocketBackgroundService extends Service { private boolean isRunning; private Thread backgroundThread; @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { this.isRunning = false; this.backgroundThread = new Thread(myTask); } private Runnable myTask = new Runnable() { @Override public void run() { // do something in here Log.i("INFO", "SOCKET BACKGROUND SERVICE IS RUNNING"); //TODO - how to handle socket events here? //How do I do something like mSocket.on(Socket.EVENT_CONNECT,onConnect); here? } }; @Override public void onDestroy() { this.isRunning = false; } @Override public int onStartCommand(Intent intent, int flags, int startId) { if( !this.isRunning) { this.isRunning = true; this.backgroundThread.start(); } return START_STICKY; } } </code></pre>
0debug
change the URL path one folder before in javascript string : my url look like below. i need to move one folder before for reference. i can you regex. I have also tried several things. bot nothing works for me. var str = "../../myfolder"; var str0 = "../myfolder"; var str1 = "../../../myfolder"; i need to change this as str = "../myfolder"; str0 = "myfolder"; str1 = "../../myfolder"; please help me for this.
0debug
asp.net Send email failedConversion from string "" to type 'Boolean' is not valid : Imports System.Net.Mail Partial Class ch5_proj4_ch5_proj4 Inherits System.Web.UI.Page Protected Sub EmailBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EmailBtn.Click ' insert code here Dim MySmtpClient As New SmtpClient() Dim MM As New MailMessage() Try MySmtpClient.Host = "stmp.gmail.com" MySmtpClient.Port = 587 MySmtpClient.EnableSsl = True MySmtpClient.UseDefaultCredentials = True MySmtpClient.Credentials = New System.Net.NetworkCredential() 'mail message MM.To.Add(New MailAddress(TextBox2.Text, TextBox1.Text)) Dim fromAddress As New MailAddress(TextBox4.Text, TextBox3.Text) MM.From = fromAddress MM.Subject = TextBox4.Text MM.IsBodyHtml = RadioButtonList1.SelectedValue MM.Body = txtMessage.Text MySmtpClient.Send(MM) Label5.Text = "Email successfully sent." Catch exc As Exception Label5.Text = "Send email failed" + exc.Message End Try MM = Nothing MySmtpClient = Nothing End Sub End Class what am I doing wrong. Every time I do it I have an error "Send email failedConversion from string "" to type 'Boolean' is not valid." help thank you
0debug
MySQLI query date range - find common periods : Please accept my apologies for a lack of attempted code. I can't get my head around this - or even figure out if it's feasible! I have a table filled with 'date slots', these can be booked by an individual. The time slots table looks like this: ID | Price | Available_from | Available_ to ------------------------------------ 1 | 20.00 | 2017-10-01 | 2018-01-01 ------------------------------------ 2 | 20.00 | 2017-11-01 | 2017-12-07 ------------------------------------ 3 | 20.00 | 2017-10-31 | 2018-01-31 ------------------------------------ 4 | 20.00 | 2017-10-22 | 2017-11-21 ------------------------------------ In these rows, there is a common date range where all four results are available, 2017-11-01 > 2017-11-21 I would like to query my database to see if 1) there is a common range for every result and 2) if there is, get the date range. Desperate for help! Thank you
0debug
import re regex = '[a-zA-z0-9]$' def check_alphanumeric(string): if(re.search(regex, string)): return ("Accept") else: return ("Discard")
0debug
Please Help me how to use inline query : select e.EMPNO, e.ENAME from emp e where e.DEPTNO in (select case when 'D'='D' then q'[10,20]' END DPT from dual )
0debug
static void spr_read_decr(DisasContext *ctx, int gprn, int sprn) { if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_decr(cpu_gpr[gprn], cpu_env); if (ctx->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } }
1threat
def second_smallest(numbers): if (len(numbers)<2): return if ((len(numbers)==2) and (numbers[0] == numbers[1]) ): return dup_items = set() uniq_items = [] for x in numbers: if x not in dup_items: uniq_items.append(x) dup_items.add(x) uniq_items.sort() return uniq_items[1]
0debug
Insert padding so that points do not overlap with y or x-axis : <p>I have the created this plot in D3: <a href="http://bl.ocks.org/cddesja/aee65f660c24cb2144fd" rel="noreferrer">http://bl.ocks.org/cddesja/aee65f660c24cb2144fd</a></p> <p>There are two things I would like to change.</p> <p>1) I would like to make it so that none of my points overlap with the y or x-axis. I thought I could use <code>transform()</code> to create a little bit of a buffer but that creates a gap between the x and y axis lines, something I do not want. How should I do this correctly? </p> <p>2) I would like to get rid of the tick marks at the intersection of the x and y lines. I am hoping that once I move the tick marks (and subsequently the pts and lines) that these tick marks automagically disappear. I don't know if that's really true or not.</p> <p>Thanks in advance. Chris</p>
0debug
static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg t0, tcg_target_long arg) { uint8_t *old_code_ptr = s->code_ptr; uint32_t arg32 = arg; if (type == TCG_TYPE_I32 || arg == arg32) { tcg_out_op_t(s, INDEX_op_movi_i32); tcg_out_r(s, t0); tcg_out32(s, arg32); } else { assert(type == TCG_TYPE_I64); #if TCG_TARGET_REG_BITS == 64 tcg_out_op_t(s, INDEX_op_movi_i64); tcg_out_r(s, t0); tcg_out64(s, arg); #else TODO(); #endif } old_code_ptr[1] = s->code_ptr - old_code_ptr; }
1threat
How do you resolve git conflicts in yarn.lock : <p>When multiple git branches modify the dependencies in a project that uses <a href="http://yarnpkg.com" rel="noreferrer">Yarn</a>, it is likely to introduce a conflict in the yarn.lock file. It is not a good idea to delete and regenerate the yarn.lock file because this will probably cause several packages to be unintentionally upgraded. What is the best way to quickly resolve conflicts in this file?</p>
0debug
React Native: View onPress does not work : <p>I'm facing a weird problem. In my react native app, if I set <code>onPress</code> event to <code>View</code> it is not triggered but if I set the same to <code>Text</code> inside <code>View</code>, it fires. What am I missing here?</p> <pre><code>&lt;View style={{backgroundColor: "red", padding: 20}}&gt; &lt;Text onPress={()=&gt; { console.log('works'); } }&gt;X&lt;/Text&gt; &lt;/View&gt; &lt;View style={{backgroundColor: "red", padding: 20}} onPress={()=&gt; { console.log('does not work'); } }&gt; &lt;Text&gt;X&lt;/Text&gt; &lt;/View&gt; </code></pre> <p>Why is this so? Is this an issue with React Native? I'm using version 0.43</p>
0debug
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags, QCryptoTLSCreds *tlscreds, const char *hostname, QIOChannel **outioc, off_t *size, Error **errp) { char buf[256]; uint64_t magic, s; int rc; TRACE("Receiving negotiation tlscreds=%p hostname=%s.", tlscreds, hostname ? hostname : "<null>"); rc = -EINVAL; if (outioc) { *outioc = NULL; } if (tlscreds && !outioc) { error_setg(errp, "Output I/O channel required for TLS"); goto fail; } if (read_sync(ioc, buf, 8) != 8) { error_setg(errp, "Failed to read data"); goto fail; } buf[8] = '\0'; if (strlen(buf) == 0) { error_setg(errp, "Server connection closed unexpectedly"); goto fail; } TRACE("Magic is %c%c%c%c%c%c%c%c", qemu_isprint(buf[0]) ? buf[0] : '.', qemu_isprint(buf[1]) ? buf[1] : '.', qemu_isprint(buf[2]) ? buf[2] : '.', qemu_isprint(buf[3]) ? buf[3] : '.', qemu_isprint(buf[4]) ? buf[4] : '.', qemu_isprint(buf[5]) ? buf[5] : '.', qemu_isprint(buf[6]) ? buf[6] : '.', qemu_isprint(buf[7]) ? buf[7] : '.'); if (memcmp(buf, "NBDMAGIC", 8) != 0) { error_setg(errp, "Invalid magic received"); goto fail; } if (read_sync(ioc, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(errp, "Failed to read magic"); goto fail; } magic = be64_to_cpu(magic); TRACE("Magic is 0x%" PRIx64, magic); if (magic == NBD_OPTS_MAGIC) { uint32_t clientflags = 0; uint32_t opt; uint32_t namesize; uint16_t globalflags; uint16_t exportflags; bool fixedNewStyle = false; if (read_sync(ioc, &globalflags, sizeof(globalflags)) != sizeof(globalflags)) { error_setg(errp, "Failed to read server flags"); goto fail; } globalflags = be16_to_cpu(globalflags); *flags = globalflags << 16; TRACE("Global flags are %" PRIx32, globalflags); if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { fixedNewStyle = true; TRACE("Server supports fixed new style"); clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE; } clientflags = cpu_to_be32(clientflags); if (write_sync(ioc, &clientflags, sizeof(clientflags)) != sizeof(clientflags)) { error_setg(errp, "Failed to send clientflags field"); goto fail; } if (tlscreds) { if (fixedNewStyle) { *outioc = nbd_receive_starttls(ioc, tlscreds, hostname, errp); if (!*outioc) { goto fail; } ioc = *outioc; } else { error_setg(errp, "Server does not support STARTTLS"); goto fail; } } if (!name) { TRACE("Using default NBD export name \"\""); name = ""; } if (fixedNewStyle) { if (nbd_receive_query_exports(ioc, name, errp) < 0) { goto fail; } } magic = cpu_to_be64(magic); if (write_sync(ioc, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(errp, "Failed to send export name magic"); goto fail; } opt = cpu_to_be32(NBD_OPT_EXPORT_NAME); if (write_sync(ioc, &opt, sizeof(opt)) != sizeof(opt)) { error_setg(errp, "Failed to send export name option number"); goto fail; } namesize = cpu_to_be32(strlen(name)); if (write_sync(ioc, &namesize, sizeof(namesize)) != sizeof(namesize)) { error_setg(errp, "Failed to send export name length"); goto fail; } if (write_sync(ioc, (char *)name, strlen(name)) != strlen(name)) { error_setg(errp, "Failed to send export name"); goto fail; } if (read_sync(ioc, &s, sizeof(s)) != sizeof(s)) { error_setg(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, &exportflags, sizeof(exportflags)) != sizeof(exportflags)) { error_setg(errp, "Failed to read export flags"); goto fail; } exportflags = be16_to_cpu(exportflags); *flags |= exportflags; TRACE("Export flags are %" PRIx16, exportflags); } else if (magic == NBD_CLIENT_MAGIC) { if (name) { error_setg(errp, "Server does not support export names"); goto fail; } if (tlscreds) { error_setg(errp, "Server does not support STARTTLS"); goto fail; } if (read_sync(ioc, &s, sizeof(s)) != sizeof(s)) { error_setg(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, flags, sizeof(*flags)) != sizeof(*flags)) { error_setg(errp, "Failed to read export flags"); goto fail; } *flags = be32_to_cpu(*flags); } else { error_setg(errp, "Bad magic received"); goto fail; } if (read_sync(ioc, &buf, 124) != 124) { error_setg(errp, "Failed to read reserved block"); goto fail; } rc = 0; fail: return rc; }
1threat
Counting and numbering range of text : <p>I am after a clever combination of Excel formulas that will be able to produce what I have manually typed into the yellow highlighted boxes on the screenshot.</p> <p>What I need to produce is essentially, for the range of months on the far right column, to count each instance of it and order each one starting with 1 and incrementing by 1 until it changes to the next month. </p> <p><a href="https://i.stack.imgur.com/gmKLY.png" rel="nofollow noreferrer">Screeshot example</a></p> <p>I'm wondering if someone has in their brain a nice combination of nested formulas or something similar ready to go they could enlighten me with?</p> <p>Much appreciated.</p>
0debug
Score function on python : I have to create a basic 3 question quiz on farming. It needs to ask the 3 questions, output whether you got it correct or incorrect and if you got it incorrect you can try again. It also needs to have a score function. I have completed the questions and the incorrect/correct part of the specification but no matter what I try I cannot get the score function to work. I have tried: score = 0 def counter(score) score = score + 1 def counter(score) score = 0 score = score + 1 def counter(score) global score score = 0 score = score + 1 and then following that once the answer was correct the line read : counter(score) I have also tried score = 0 then score = score + 1 but nothing is working and I cannot figure out what is going wrong. It also needs to print how many the user got right at the end. CODE: score = 0 def quiz(): print("Here is a quiz to test your knowledge of farming...") print() print() print("Question 1") print("What percentage of the land is used for farming?") print() print("a. 25%") print("b. 50%") print("c. 75%") answer = input("Make your choice: ") if answer == "c": print("Correct!") score = score + 1 else: print("Incorrect.") answer = input("Try again! ") if answer == "c": print("Correct") score = score + 1 else: print("Incorrect! Sorry the answer was C.") print() print() print("Question 2") print("Roughly how much did farming contribute to the UK economy in 2014.") print() print("a. £8 Billion.") print("b. £10 Billion.") print("c. £12 Billion.") answer = input("Make your choice: ") if answer == "b": print("Correct!") score = score + 1 else: print("Incorrect.") answer = input("Try again! ") if answer == "b": print("Ccrrect!") score = score + 1 else: print("Incorrect! Sorry the answer was B.") print() print() print("Question 3.") print("This device, which was invented in 1882 has revolutionised farming. What is it called?") print() print("a. Tractor") print("b. Wagon.") print("c. Combine.") answer == input("Make your choice. ") if answer == "a": print("Correct!") score = score + 1 else: print("Incorrect.") answer == input("Try again! ") if answer == "a": print("Correct!") score = score + 1 else: print("Incorrect! Sorry the answer was A.") print("You got {0}/3 right!".format(score))
0debug
How to print an alternate element of string array in java : package com.javaprograms; import java.util.Arrays; public class PracticeJava { public static void main(String args[]) { String[] array = {"ABC","XYZ","PQR","STW"}; //int num = array.length; for(int i=0;i<=array.length-1;i++) { System.out.println(Arrays.asList(array)); } } } **I want to print Alternate element of string array for ex. {"ABC","PQR"} OR {"XYZ","STW"}. I used above code but it is not working. Can anyone please help me how can i achieve given output.Any help can be appreciated.**
0debug
Android Studio Logcat colors best practice : <p>It is really hard to follow up Android logcat output all in a same color. is there any best practice for changing different logs color?</p>
0debug
Unable to open Tensorboard in browser : <p>I am following <a href="https://cloud.google.com/ml/docs/quickstarts/training" rel="noreferrer">google cloud machine learning tutorial</a> and I am unable to Launch TensorBoard </p> <p>I've followed the steps in the above tutorial (also set up my environment using docker container) until typing the below command in the terminal</p> <pre><code>tensorboard --logdir=data/ --port=8080 </code></pre> <p>Where the terminal outputs the below prompt </p> <pre><code>Starting TensorBoard 29 on port 8080 (You can navigate to http://172.17.0.2:8080) </code></pre> <p>When I visit <code>http://172.17.0.2:8080</code> in my browser I see nothing (the server where this page is located is not responding). </p> <p>Can someone please advice how I can launch Tensor Board ?</p>
0debug
void json_prop_str(QJSON *json, const char *name, const char *str) { json_emit_element(json, name); qstring_append_chr(json->str, '"'); qstring_append(json->str, str); qstring_append_chr(json->str, '"'); }
1threat
perl /pyhton/bash script to get values from files and group them : i have an requirement to process values from different files. i have 5 dirs input,success,manual,retry,current. Each dir has multiple txt files. Each txt file has hostname=<hostname>. I would want to know for each hostname how many files are in input,success,retry,current and manual dir. For eg. input -> A.txt (HOSTNAME=host1) -> B.txt (HOSTNAME=host2) -> C.txt (HOSTNAME=host3) -> D.txt (HOSTNAME=host1) success -> P.txt (HOSTNAME=host1) -> Q.txt (HOSTNAME=host2) -> R.txt (HOSTNAME=host1) OUTPUT Host | Input | Success | Current | Retry | Manual host1 | 2 | 2 | 0 | 0 | 0 host2 | 1 | 1 | 0 | 0 | 0 host3 | 1 |0 | 0 | 0 | 0 Would like to know if there are any libraries in perl, python or bash to do this. Thanks
0debug
Is it possible in an android to put the drawableLeft image of radio button to the left of the icon? : By following this link [android-radiobutton-image-and-text ][1] I'm able to show radio button with image and text both. if I use drawableLeft, the drawable image comes in between the radio icon(circular icon to show if selected or not) and the text. But what I want is to show first the drawable image to extreme left, then radio icon having some space(margin/padding) from drawable and then the text to right side. So is it possible? [1]: http://stackoverflow.com/questions/14514728/android-radiobutton-image-and-text
0debug
Why does map() mask the 'undefined value' error? : <p>I'm wondering why a call to <code>map</code> in the second snippet makes the 'undefined value' error gone?</p> <pre><code>use strict; use warnings; my $x; my @a = @{ $x }; # error: Can't use an undefined value as an ARRAY reference </code></pre> <p>Compare to: </p> <pre><code>use strict; use warnings; my $x; my @a = map $_, @{ $x }; # no error, @a is empty </code></pre>
0debug
vagrant up - server not starting because a ssh library issue : <p>I get this errormessage:</p> <blockquote> <p>An error occurred in the underlying SSH library that Vagrant uses. The error message is shown below. In many cases, errors from this library are caused by ssh-agent issues. Try disabling your SSH agent or removing some keys and try again.</p> </blockquote> <p>It is my first time with vagrant.</p> <p>I took a tour through this tutorial.</p> <p><a href="https://wpbeaches.com/setting-up-a-wordpress-vvv-vagrant-workflow/" rel="noreferrer">https://wpbeaches.com/setting-up-a-wordpress-vvv-vagrant-workflow/</a></p> <p>I've windows 10, vagrant 1.8.5, Oracle VM newest version.</p> <p>I read a lot about this issue but nothing helps me.</p> <p>Maybe somebody knows a solution.</p>
0debug
How can I implement social network login on Groovy/Grails? : <p>I am trying to implement Google and LinkedIn as well as regular mail login on my grails app.</p> <p>Do you have any recommendations on a plugin or any other particular way to do this?</p> <p>I'm using Grails 3.3.10.</p> <p>Thanks in advance</p>
0debug
static int nsv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { NSVContext *nsv = s->priv_data; AVStream *st = s->streams[stream_index]; NSVStream *nst = st->priv_data; int index; index = av_index_search_timestamp(st, timestamp, flags); if(index < 0) return -1; avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET); nst->frame_offset = st->index_entries[index].timestamp; nsv->state = NSV_UNSYNC; return 0; }
1threat
How to completely uninstall python 2.7.13 on Ubuntu 16.04 : <p>I installed <code>Python 2.7.13</code> on <code>Ubuntu 16.04</code> according to <a href="https://tecadmin.net/install-python-2-7-on-ubuntu-and-linuxmint/" rel="noreferrer">this guide</a>, and it became the default version as an alternative to the <code>version 2.7.12</code>. But, I wanted to completely remove <code>Python 2.7.13</code> and return back to the <code>version 2.7.12</code> as the default version since the <code>pip</code> command does not work with the following error. </p> <pre><code>bash: /usr/local/bin/pip: /usr/bin/python: bad interpreter: No such file or directory </code></pre> <p>Could you please help me how to completely remove <code>Python 2.7.13</code> from <code>Ubuntu 16.04</code>? Otherwise, could you please suggest how to fix the above error?</p>
0debug
Issue for Retrieving of Special Characters from SQL Server using C# : When i try to retrieve special characters it turns into HTML Number. for example i tried to retrieve ñ it the retrieved value becomes "&# 241;" can anyone help me Please! Thanks a Lot
0debug
Python not standart list sorting : <p>Let's say I have a list like this: <code>[2, 3, 3, 2, 1, 1]</code> and I want to sort it to get <code>[1, 1, 3, 3, 2, 2]</code>. How I can do it in good pythonic way? I've tried like this:</p> <pre><code>import random alist = [1, 1, 2, 2, 3, 3] random.shuffle(alist) print(alist) ones = [] twos = [] threes = [] for item in alist: if item == 1: ones.append(item) elif item == 2: twos.append(item) else: threes.append(item) ordered_list = [] ordered_list.extend(ones) ordered_list.extend(threes) ordered_list.extend(twos) print(ordered_list) </code></pre> <p>But I guess it's not the best way to do it. Maybe there is a better way?</p>
0debug
Error parsing proxy URL. Bad port number : <p>When I use wget command in RHEL 6.5, getting the error </p> <p><code>Error parsing proxy URL. Bad port number</code>. </p> <p>The command used to set the proxy was </p> <p><code>export http_proxy="http_proxy://username:password@address:port/"</code>.</p> <p>Yes I know this issue can be resolved by using </p> <p><code>http_proxy=address wget --proxy-user=username --proxy-password=&lt;password&gt; url</code>.</p> <p>But I want to install a package and during installation, it will need to download few other packages. so the proxy should be already set and ready before the installation. How can we resolve this?</p>
0debug
Hibernate 5.2.2: No Persistence provider for EntityManager : <p>What has changed between Hibernate 5.1.1 and 5.2.2? If I use 5.2.2 I'll get an error message "No Persistence provider for EntityManager named pu". Exactly the same configuration works with 5.1.1. How should I change my code to get 5.2.2 to work?</p> <p>pom.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;jpatest&lt;/groupId&gt; &lt;artifactId&gt;jpatest&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;properties&gt; &lt;hibernate.version&gt;5.2.2.Final&lt;/hibernate.version&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;!-- https://mvnrepository.com/artifact/junit/junit --&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.12&lt;/version&gt; &lt;/dependency&gt; &lt;!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --&gt; &lt;dependency&gt; &lt;groupId&gt;org.postgresql&lt;/groupId&gt; &lt;artifactId&gt;postgresql&lt;/artifactId&gt; &lt;version&gt;9.4.1209.jre7&lt;/version&gt; &lt;/dependency&gt; &lt;!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --&gt; &lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt; &lt;version&gt;${hibernate.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt; &lt;version&gt;${hibernate.version}&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/project&gt; </code></pre> <p>persistence.xml in src/main/resources/META-INF</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"&gt; &lt;persistence-unit name="pu" &gt; &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt; &lt;properties&gt; &lt;property name="hibernate.archive.autodetection" value="class" /&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /&gt; &lt;property name="hibernate.connection.driver_class" value="org.postgresql.Driver" /&gt; &lt;property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/mydb" /&gt; &lt;property name="hibernate.default_schema" value="myschema" /&gt; &lt;property name="hibernate.connection.username" value="xxx" /&gt; &lt;property name="hibernate.connection.password" value="zzz" /&gt; &lt;!-- &lt;property name="hibernate.show_sql" value="true"/&gt; --&gt; &lt;property name="hibernate.flushMode" value="FLUSH_AUTO" /&gt; &lt;property name="hibernate.hbm2ddl.auto" value="validate" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; &lt;/persistence&gt; </code></pre> <p>creating EntityManager </p> <pre><code>factory = Persistence.createEntityManagerFactory("pu"); em = factory.createEntityManager(); tx = em.getTransaction(); </code></pre>
0debug
Autoit script that record the user activity on pc : I wrote a script that record the user activity on pc and store the data in text file and that file will be each 10 seconde updated so that i knew how many time spend the user on file or folder but the question is whicg way is am bestten for processing the data such as the data aggregate by activity name .... I'm looking forward to tips :)
0debug
Get new ArrayList<String> of obtained Strings after searching from an ArrayList<String> using TextWatcher Android : **How can I get a new ArrayList<String> of search results after searching from an ArrayList<String> using TextWatcher in android?**<br> The following is my code for searching from an ArrayList<String> using EditText >> **edtSearch**. The search function is working well. Need to put the obtained data into a new ArrayList<String>: > edtSearch.addTextChangedListener(new TextWatcher()){ > > @Override > public void beforeTextChanged(CharSequence s, int start, int count, int after) { > > } > > @Override > public void onTextChanged(CharSequence s, int start, int before, int count) { > MainActivity.this.adapter.getFilter().filter(s); > } > > @Override > public void afterTextChanged(Editable s) { > > } > });
0debug
Why a I getting a TypeError in this JavaScript code? : I am a beginner JavaScript programmer and I am following a book called "Create with < code >" and I am having trouble with the code. I have been following along with the book but when I have tried running it, there is an error. I have been typing the code into a plain-text editor and viewing it on Chrome. I do not know how to fix this. Help? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE html> <html> <head> <title>Nanonaut Action</title> </head> <body> <script> //CONSTANTS var CANVAS_WIDTH = 800; var CANVAS_HEIGHT = 600; var NANONAUT_WIDTH = 181; var NANONAUT_HEIGHT = 229; var GROUND_Y = 540; var NANONAUT_Y_ACCELERATION = 1; var SPACE_KEYCODE = 32; var NANONAUT_JUMP_SPEED = 20; var NANONAUT_X_SPEED = 5; var BACKGROUND_WIDTH = 1000; var NANONAUT_NR_FRAMES_PER_ROW = 5; var NANONAUT_NR_ANIMATION_FRAMES = 7; var NANONAUT_ANIMATION_SPEED = 5; //SETUP var gameFrameCounter = 0; var bushx var cameraX = 0; var cameraY = 0; var nanonautYSpeed = 0; var nanonautIsInTheAir = false; var spaceKeyIsPressed = false; var nanonautFrameNr = 0; var bushData = generateBushes(); var canvas = document.createElement('canvas'); var c = canvas.getContext('2d'); canvas.width = CANVAS_WIDTH; canvas.height = CANVAS_HEIGHT; document.body.appendChild(canvas); var nanonautImage = new Image (); nanonautImage.src = 'animatedNanonaut.png'; var backgroundImage = new Image (); backgroundImage.src = 'background.png'; var bush1Image = new Image (); bush1Image.src = 'bush1.png'; var bush2Image = new Image (); bush2Image.src = 'bush2.png'; var nanonautX = CANVAS_WIDTH / 2; var nanonautY = GROUND_Y - NANONAUT_HEIGHT; window.addEventListener('keydown', onKeyDown); window.addEventListener('keyup', onKeyUp); window.addEventListener('load', start); function start() { window.requestAnimationFrame(mainLoop); } function generateBushes() { var generatedBushData = []; var bushX = 0; while (bushX < (2 * CANVAS_WIDTH)) { var bushImage; if (Math.random() >= 0.5) { bushImage = bush1Image; } else { bushImage = bush2Image } generatedBushData.push ({ x: bushX, y: 80 + Math.random() * 20, image: bushImage }); bushX += 150 + Math.random() * 200; } return generatedBushData; } //MAIN LOOP function mainLoop() { update(); draw(); window.requestAnimationFrame(mainLoop); } //PLAYER INPUT function onKeyDown(event) { if (event.keyCode === SPACE_KEYCODE) { spaceKeyIsPressed = true; } } function onKeyUp(event) { if (event.keyCode === SPACE_KEYCODE) { spaceKeyIsPressed = false; } } //UPDATING function update() { gameFrameCounter = gameFrameCounter + 1; nanonautX = nanonautX + NANONAUT_X_SPEED; if (spaceKeyIsPressed && !nanonautIsInTheAir) { nanonautYSpeed = - NANONAUT_JUMP_SPEED; nanonautIsInTheAir = true; } //Update Nanonaut nanonautY = nanonautY + nanonautYSpeed; nanonautYSpeed = nanonautYSpeed + NANONAUT_Y_ACCELERATION; if (nanonautY > (GROUND_Y - NANONAUT_HEIGHT)) { nanonautY = GROUND_Y - NANONAUT_HEIGHT; nanonautYSpeed = 0; nanonautIsInTheAir = false; } //Update animaion if ((gameFrameCounter % NANONAUT_ANIMATION_SPEED) === 0) { nanonautFrameNr = nanonautFrameNr +1; if (nanonautFrameNr >= NANONAUT_NR_ANIMATION_FRAMES) { nanonautFrameNr = 0; } } //Update camera cameraX = nanonautX - 150 //Update bushes. for (var i=0; i<bushData.length; i++) { if ((bushData[i].x - cameraX) < -CANVAS_WIDTH) { bushData[i].x += (2 * CANVAS_WIDTH) + 150; } } } //DRAWING function draw() { c.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); //Draw the Sky. c.fillStyle = 'LightSkyBlue'; c.fillRect(0, 0, CANVAS_WIDTH, GROUND_Y - 40); //Draw the background. var backgroundX = - (cameraX % BACKGROUND_WIDTH); c.drawImage(backgroundImage, backgroundX, -210); c.drawImage(backgroundImage, backgroundX + BACKGROUND_WIDTH, -210); //Draw the bushes for (var i=0; i<bushData.length; i++) { c.drawImage( bushData[i].image, bushData[i].x, GROUND_Y - bushData[i].y); } //Draw the ground. c.fillStyle = 'Green'; c.fillRect(0, GROUND_Y - 40, CANVAS_WIDTH, CANVAS_HEIGHT - GROUND_Y + 40); //Draw the Nanonaut. var nanonautSpriteSheetRow = Math.floor(nanonautFrameNr / NANONAUT_NR_FRAMES_PER_ROW); var nanonautSpriteSheetColumn = nanonautFrameNr % NANONAUT_NR_FRAMES_PER_ROW; var nanonautSpriteSheetX = nanonautSpriteSheetColumn * NANONAUT_WIDTH var nanonautSpriteSheetY = nanonautSpriteSheetRow * NANONAUT_HEIGHT c.drawImage(nanonautImage, nanonautSpriteSheetX, nanonautSpriteSheetY, NANONAUT_WIDTH, NANONAUT_HEIGHT, nanonautX - cameraX, nanonautY - cameraY, NANONAUT_WIDTH, NANONAUT_HEIGHT); } </script> </body> </html> <!-- end snippet -->
0debug
I dont know how can I solve this problem with my python code : Im trying to get only the names of playlist from a json file that I have but I cannot make it {'playlists': [{'description': '', 'lastModifiedDate': '2018-11-20', 'name': 'Piano', 'numberOfFollowers': 0, 'tracks': [{'artistName': 'Kenzie Smith Piano', 'trackName': "You've Got a Friend in Me (From " '"Toy Story")'}, {'artistName': 'Kenzie Smith Piano', 'trackName': 'A Whole New World (From "Aladdin")'}, {'artistName': 'Kenzie Smith Piano', 'trackName': 'Can You Feel the Love Tonight? (From ' '"The Lion King")'}, {'artistName': 'Kenzie Smith Piano', 'trackName': "He's a Pirate / The Black Pearl " '(From "Pirates of the Caribbean")'}, {'artistName': 'Kenzie Smith Piano', 'trackName': "You'll be in My Heart (From " '"Tarzan") [Soft Version]'}, import json from pprint import pprint json_data=open('C:/Users/alvar/Desktop/Alvaro/Nueva carpeta/Playlist.json', encoding="utf8").read() playlist = json.loads(json_data) pprint(playlist) #here is where is not workint for names in playlist_list: print(names['name']) print '\n' What I want is to extract only the names of the playlists.
0debug
convert mysql to mysqli error : I'm trying to convert mysql to mysqli, but I get some errors first error : mysqli_query() expects at least 2 parameters, 1 given in /home/.........../class/class.mysql.php on line 55 public function query($res, $pass_no = 1) { $q1 = mysqli_query($res, $this->db_link); if (!$q1) { $this->sql_error(); if ($pass_no == 1) { if ($this->output_error == 1) { echo 'Attempting to reconnect to MySQL...' . "\n"; } $this->db_close(); $this->db_connect(); $this->query($res, 2); } else { if ($this->output_error == 1) { echo 'Reconnection failed; please check your MySQL server settings!' . "\n"; } } } else { return $q1; } } second error : mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /home/..../index.php on line 14 global $db ; $username = mysqli_real_escape_string($_POST['username_login']); $q ="select * from ".DB_PREFIX."admins where username='".$username."' ". "and password='".md5( $_POST['password_login'])."'"; // echo $q; $res =$db->query($q); if($db->num_rows($res)==1) { return true ; } return false ; I don't understand the 2 errors
0debug
static void listener_add_address_space(MemoryListener *listener, AddressSpace *as) { FlatView *view; FlatRange *fr; if (listener->address_space_filter && listener->address_space_filter != as) { return; } if (global_dirty_log) { if (listener->log_global_start) { listener->log_global_start(listener); } } view = as->current_map; FOR_EACH_FLAT_RANGE(fr, view) { MemoryRegionSection section = { .mr = fr->mr, .address_space = as, .offset_within_region = fr->offset_in_region, .size = fr->addr.size, .offset_within_address_space = int128_get64(fr->addr.start), .readonly = fr->readonly, }; if (listener->region_add) { listener->region_add(listener, &section); } } }
1threat
R: ggplot box plot : <p>I have a data frame as follows:</p> <pre><code> Calories Protein TotalFat 1 717 0.85 81.11 2 717 0.85 81.11 3 876 0.28 99.48 4 353 21.40 28.74 5 371 23.24 29.68 6 334 20.75 27.68 7 300 19.80 24.26 9 403 24.90 33.14 11 394 23.76 32.11 12 98 11.12 4.30 </code></pre> <p>I would like to make a <code>boxplot</code> using <code>ggplot</code>. I can do this using base R using the following code</p> <pre><code>boxplot(df) </code></pre> <p>But how do I do with <code>ggplot</code>?</p>
0debug
HTML reserve space for scrollbar : <p>I have a div that may overflow as content is added or removed.</p> <p>However the UI designer does not want a visible, but inactive scrollbar (as with <code>overflow: scroll</code>), and they don't want the content layout to change when one is added and remove (as with <code>overflow: auto</code>).</p> <p>Is there a means to get this behavior, and considering the different scrollbars on different platforms and browsers.</p> <p><a href="https://i.stack.imgur.com/MQi3P.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MQi3P.png" alt="enter image description here"></a> <a href="https://jsfiddle.net/qy9a2r00/1/" rel="noreferrer">https://jsfiddle.net/qy9a2r00/1/</a> </p>
0debug
How to calculate F1 Macro in Keras? : <p>i've tried to use the codes given from Keras before they're removed. Here's the code :</p> <pre><code>def precision(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1))) precision = true_positives / (predicted_positives + K.epsilon()) return precision def recall(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) possible_positives = K.sum(K.round(K.clip(y_true, 0, 1))) recall = true_positives / (possible_positives + K.epsilon()) return recall def fbeta_score(y_true, y_pred, beta=1): if beta &lt; 0: raise ValueError('The lowest choosable beta is zero (only precision).') # If there are no true positives, fix the F score at 0 like sklearn. if K.sum(K.round(K.clip(y_true, 0, 1))) == 0: return 0 p = precision(y_true, y_pred) r = recall(y_true, y_pred) bb = beta ** 2 fbeta_score = (1 + bb) * (p * r) / (bb * p + r + K.epsilon()) return fbeta_score def fmeasure(y_true, y_pred): return fbeta_score(y_true, y_pred, beta=1) </code></pre> <p>From what i saw (i'm an amateur in this), it seems like they use the correct formula. But, when i tried to use it as a metrics in the training process, I got exactly equal output for val_accuracy, val_precision, val_recall, and val_fmeasure. I do believe that it might happen even if the formula correct, but i believe it is unlikely. Any explanation for this issue? Thank you</p>
0debug
static inline void RENAME(hScale)(int16_t *dst, int dstW, uint8_t *src, int srcW, int xInc, int16_t *filter, int16_t *filterPos, long filterSize) { #ifdef HAVE_MMX assert(filterSize % 4 == 0 && filterSize>0); if(filterSize==4) { long counter= -2*dstW; filter-= counter*2; filterPos-= counter/2; dst-= counter/2; asm volatile( "pxor %%mm7, %%mm7 \n\t" "movq "MANGLE(w02)", %%mm6 \n\t" "push %%"REG_BP" \n\t" "mov %%"REG_a", %%"REG_BP" \n\t" ASMALIGN16 "1: \n\t" "movzwl (%2, %%"REG_BP"), %%eax \n\t" "movzwl 2(%2, %%"REG_BP"), %%ebx\n\t" "movq (%1, %%"REG_BP", 4), %%mm1\n\t" "movq 8(%1, %%"REG_BP", 4), %%mm3\n\t" "movd (%3, %%"REG_a"), %%mm0 \n\t" "movd (%3, %%"REG_b"), %%mm2 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "pmaddwd %%mm1, %%mm0 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "psrad $8, %%mm0 \n\t" "psrad $8, %%mm3 \n\t" "packssdw %%mm3, %%mm0 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "packssdw %%mm0, %%mm0 \n\t" "movd %%mm0, (%4, %%"REG_BP") \n\t" "add $4, %%"REG_BP" \n\t" " jnc 1b \n\t" "pop %%"REG_BP" \n\t" : "+a" (counter) : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) : "%"REG_b ); } else if(filterSize==8) { long counter= -2*dstW; filter-= counter*4; filterPos-= counter/2; dst-= counter/2; asm volatile( "pxor %%mm7, %%mm7 \n\t" "movq "MANGLE(w02)", %%mm6 \n\t" "push %%"REG_BP" \n\t" "mov %%"REG_a", %%"REG_BP" \n\t" ASMALIGN16 "1: \n\t" "movzwl (%2, %%"REG_BP"), %%eax \n\t" "movzwl 2(%2, %%"REG_BP"), %%ebx\n\t" "movq (%1, %%"REG_BP", 8), %%mm1\n\t" "movq 16(%1, %%"REG_BP", 8), %%mm3\n\t" "movd (%3, %%"REG_a"), %%mm0 \n\t" "movd (%3, %%"REG_b"), %%mm2 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "pmaddwd %%mm1, %%mm0 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "movq 8(%1, %%"REG_BP", 8), %%mm1\n\t" "movq 24(%1, %%"REG_BP", 8), %%mm5\n\t" "movd 4(%3, %%"REG_a"), %%mm4 \n\t" "movd 4(%3, %%"REG_b"), %%mm2 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "pmaddwd %%mm1, %%mm4 \n\t" "pmaddwd %%mm2, %%mm5 \n\t" "paddd %%mm4, %%mm0 \n\t" "paddd %%mm5, %%mm3 \n\t" "psrad $8, %%mm0 \n\t" "psrad $8, %%mm3 \n\t" "packssdw %%mm3, %%mm0 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "packssdw %%mm0, %%mm0 \n\t" "movd %%mm0, (%4, %%"REG_BP") \n\t" "add $4, %%"REG_BP" \n\t" " jnc 1b \n\t" "pop %%"REG_BP" \n\t" : "+a" (counter) : "c" (filter), "d" (filterPos), "S" (src), "D" (dst) : "%"REG_b ); } else { uint8_t *offset = src+filterSize; long counter= -2*dstW; filterPos-= counter/2; dst-= counter/2; asm volatile( "pxor %%mm7, %%mm7 \n\t" "movq "MANGLE(w02)", %%mm6 \n\t" ASMALIGN16 "1: \n\t" "mov %2, %%"REG_c" \n\t" "movzwl (%%"REG_c", %0), %%eax \n\t" "movzwl 2(%%"REG_c", %0), %%ebx \n\t" "mov %5, %%"REG_c" \n\t" "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" "2: \n\t" "movq (%1), %%mm1 \n\t" "movq (%1, %6), %%mm3 \n\t" "movd (%%"REG_c", %%"REG_a"), %%mm0\n\t" "movd (%%"REG_c", %%"REG_b"), %%mm2\n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "pmaddwd %%mm1, %%mm0 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "paddd %%mm3, %%mm5 \n\t" "paddd %%mm0, %%mm4 \n\t" "add $8, %1 \n\t" "add $4, %%"REG_c" \n\t" "cmp %4, %%"REG_c" \n\t" " jb 2b \n\t" "add %6, %1 \n\t" "psrad $8, %%mm4 \n\t" "psrad $8, %%mm5 \n\t" "packssdw %%mm5, %%mm4 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "packssdw %%mm4, %%mm4 \n\t" "mov %3, %%"REG_a" \n\t" "movd %%mm4, (%%"REG_a", %0) \n\t" "add $4, %0 \n\t" " jnc 1b \n\t" : "+r" (counter), "+r" (filter) : "m" (filterPos), "m" (dst), "m"(offset), "m" (src), "r" (filterSize*2) : "%"REG_b, "%"REG_a, "%"REG_c ); } #else #ifdef HAVE_ALTIVEC hScale_altivec_real(dst, dstW, src, srcW, xInc, filter, filterPos, filterSize); #else int i; for(i=0; i<dstW; i++) { int j; int srcPos= filterPos[i]; int val=0; for(j=0; j<filterSize; j++) { val += ((int)src[srcPos + j])*filter[filterSize*i + j]; } dst[i] = FFMIN(FFMAX(0, val>>7), (1<<15)-1); } #endif #endif }
1threat
static int mm_decode_inter(MmContext * s, int half_horiz, int half_vert) { int data_off = bytestream2_get_le16(&s->gb), y; GetByteContext data_ptr; if (bytestream2_get_bytes_left(&s->gb) < data_off) return AVERROR_INVALIDDATA; bytestream2_init(&data_ptr, s->gb.buffer + data_off, bytestream2_get_bytes_left(&s->gb) - data_off); while (s->gb.buffer < data_ptr.buffer_start) { int i, j; int length = bytestream2_get_byte(&s->gb); int x = bytestream2_get_byte(&s->gb) + ((length & 0x80) << 1); length &= 0x7F; if (length==0) { y += x; continue; } if (y + half_vert >= s->avctx->height) return 0; for(i=0; i<length; i++) { int replace_array = bytestream2_get_byte(&s->gb); for(j=0; j<8; j++) { int replace = (replace_array >> (7-j)) & 1; if (replace) { int color = bytestream2_get_byte(&data_ptr); s->frame.data[0][y*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][y*s->frame.linesize[0] + x + 1] = color; if (half_vert) { s->frame.data[0][(y+1)*s->frame.linesize[0] + x] = color; if (half_horiz) s->frame.data[0][(y+1)*s->frame.linesize[0] + x + 1] = color; } } x += 1 + half_horiz; } } y += 1 + half_vert; } return 0; }
1threat
static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code) { AVFormatContext *s = nut->avf; AVIOContext *bc = s->pb; int size, stream_id, discard; int64_t pts, last_IP_pts; StreamContext *stc; uint8_t header_idx; size = decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code); if (size < 0) return size; stc = &nut->stream[stream_id]; if (stc->last_flags & FLAG_KEY) stc->skip_until_key_frame = 0; discard = s->streams[stream_id]->discard; last_IP_pts = s->streams[stream_id]->last_IP_pts; if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) || (discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts) || discard >= AVDISCARD_ALL || stc->skip_until_key_frame) { avio_skip(bc, size); return 1; } if (av_new_packet(pkt, size + nut->header_len[header_idx]) < 0) return AVERROR(ENOMEM); memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]); pkt->pos = avio_tell(bc); if (stc->last_flags & FLAG_SM_DATA) { int sm_size; if (read_sm_data(s, bc, pkt, 0, pkt->pos + size) < 0) return AVERROR_INVALIDDATA; if (read_sm_data(s, bc, pkt, 1, pkt->pos + size) < 0) return AVERROR_INVALIDDATA; sm_size = avio_tell(bc) - pkt->pos; size -= sm_size; pkt->size -= sm_size; } avio_read(bc, pkt->data + nut->header_len[header_idx], size); pkt->stream_index = stream_id; if (stc->last_flags & FLAG_KEY) pkt->flags |= AV_PKT_FLAG_KEY; pkt->pts = pts; return 0; }
1threat
How to malloc , calloc , realloc a bidimensional pointer structure? : I have this code : #include <stdio.h> #include <stdlib.h> int main() { int i,j,width,height,operatie; struct pixel { unsigned char r, g, b; } ; struct pixel **poza; scanf("%d",&operatie); scanf("%d",&width); scanf("%d",&height); poza = malloc ( height * width * sizeof(pixel)); for (i=0 ; i<height ; i++ ) { for ( j=0 ; j<width ; j++ ) { scanf("%c",&(poza[i][j].r)); scanf("%c",&(poza[i][j].g)); scanf("%c",&(poza[i][j].b)); } } for (i=0 ; i<height ; i++ ) { for ( j=0 ; j<width ; j++ ) { printf("%d ",(poza[i][j].r)); printf("%d ",(poza[i][j].g)); printf("%d ",(poza[i][j].b)); } printf("\n"); } return 0; } I want to know hot can i use malloc , calloc and realloc on this .
0debug
Simple way to keep Front-end Angular 5 and back-end Web API code separate? : <p>I have developed an Angular 5 app with plenty of moving parts (Services, Bootstrap, Angular Material, internal+external JS scripts, etc). Now I want to add database connectivity to this app as well (MS SQL Server only). The app has been developed in Visual Studio Code.</p> <p>I am following <a href="https://code.msdn.microsoft.com/Angular-5-ASPNET-Core-CRUD-a7f382ab" rel="noreferrer">this tutorial</a> from MSDN in order to learn how to connect this app with an SQL Server database. I believe I'll need Web API and .NET Core support for connectivity, and I can't find out a way to do that without starting from scratch in either of the VS Code (e.g. <a href="https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-vsc" rel="noreferrer">here</a>) or Visual Studio (like in the referenced article) since almost all the articles/tutorials I could find on the topic begin from scratch. The way I see it, creating a new Angular + Core project in Visual Studio and migrating the app logic there file-by-file is not a feasible solution for me.</p> <p>My questions are:</p> <ul> <li>Is there a simple way to create a <em>separate</em> Web API-based back-end app which serves data from my SQL Server database for the front-end Angular 5 app to consume? Or would all the .NET Core, Web API, and Angular front-end support be rendered from the same app?</li> <li>If not, is there a simple/official way to add .NET Core and Web API functionality to an Angular 5 app built in VS Code?</li> </ul>
0debug
How can I supress Error messages in python : So I'm trying to make a program to delete all duplicate Letters from a given String. The code is basically a selfmade iterator, that I got from another post here: <https://stackoverflow.com/questions/50427501/how-do-i-reset-a-list-iterator-in-python> string = "NNEEXXxxTTGGEENNCCOODDEERR" class rmvDuplicates: def __init__(self, list, newString): self.newString = newString self.list = list self.idx = 0 self.content = list[self.idx] def __iter__(self): return self def get_content(self, content): return content def get_index(self): return self.idx def get_content_next(self, content): try: self.idx += 1 return self.content finally: self.idx -= 1 def remove(self, elem): del self.list[self.idx] return def rewind(self): self.idx = 0 def __next__(self): try: return self.list[self.idx] except IndexError: pass finally: self.idx += 1 self.content = self.list[self.idx] new_String = [] li = rmvDuplicates(list(string), new_String) for elem in li: if li.get_content(elem) == li.get_content_next(elem): print(li.get_content(elem)) li.remove(elem) print(li.list) print("Hello") I modified it a bit to match my needings and it works just fine, until it reaches the point of the IndexError. def __next__(self): try: return self.list[self.idx] except IndexError: pass finally: self.idx += 1 self.content = self.list[self.idx] I already tried to figure that out myself, using the Except-Block with the pass method. But still, the program displays this message: Traceback (most recent call last): File "rmv_dplc_cls.py", line 49, in <module> for elem in li: File "rmv_dplc_cls.py", line 42, in __next__ self.content = self.list[self.idx] IndexError: list index out of range Does anyone here know how to fix this, so the program keeps on running and doesn't abort. Thanks
0debug
Get the value of --locale on runtime for an AOT compiled Angular App : <p>I have an multilanguale app which is compiled with --aot in each language, for instance for German:</p> <pre><code>ng build --aot --env=prod --prod --build-optimizer --i18nFile=src/locale/DARI_messages_de_DE.xlf --i18nFormat=xlf --locale=de --missingTranslation warning --output-path dist/de --base-href /de/ </code></pre> <p>We need want to get the value on locale on runtime to handle it over to our backend too.</p> <p>If have looked tryed to get from </p> <pre><code> import { LOCALE_ID } from '@angular/core'; constructor(private modalService: BsModalService) { console.log("LOCALE_ID", LOCALE_ID); } </code></pre> <p>But the LOCAL_ID is empty I think it only for use with JIT</p> <p>Is there any method to get this parameter on runtime?</p>
0debug
def Split(list): ev_li = [] for i in list: if (i % 2 == 0): ev_li.append(i) return ev_li
0debug
Is there a way to enable auditing in all entities via sql sever in dynamic crm? : In Dynamics Crm I need to enable all auditing in all entities without over each entity one by one.
0debug
Second Derivative in Python - scipy/numpy/pandas : <p>I'm trying to take a second derivative in python with two numpy arrays of data. </p> <p>For example, the arrays in question look like this: </p> <pre><code>import numpy as np x = np.array([ 120. , 121.5, 122. , 122.5, 123. , 123.5, 124. , 124.5, 125. , 125.5, 126. , 126.5, 127. , 127.5, 128. , 128.5, 129. , 129.5, 130. , 130.5, 131. , 131.5, 132. , 132.5, 133. , 133.5, 134. , 134.5, 135. , 135.5, 136. , 136.5, 137. , 137.5, 138. , 138.5, 139. , 139.5, 140. , 140.5, 141. , 141.5, 142. , 142.5, 143. , 143.5, 144. , 144.5, 145. , 145.5, 146. , 146.5, 147. ]) y = np.array([ 1.25750000e+01, 1.10750000e+01, 1.05750000e+01, 1.00750000e+01, 9.57500000e+00, 9.07500000e+00, 8.57500000e+00, 8.07500000e+00, 7.57500000e+00, 7.07500000e+00, 6.57500000e+00, 6.07500000e+00, 5.57500000e+00, 5.07500000e+00, 4.57500000e+00, 4.07500000e+00, 3.57500000e+00, 3.07500000e+00, 2.60500000e+00, 2.14500000e+00, 1.71000000e+00, 1.30500000e+00, 9.55000000e-01, 6.65000000e-01, 4.35000000e-01, 2.70000000e-01, 1.55000000e-01, 9.00000000e-02, 5.00000000e-02, 2.50000000e-02, 1.50000000e-02, 1.00000000e-02, 1.00000000e-02, 1.00000000e-02, 1.00000000e-02, 1.00000000e-02, 1.00000000e-02, 1.00000000e-02, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03, 5.00000000e-03]) </code></pre> <p>I currently then have <code>f(x) = y</code>, and I want <code>d^2 y / dx^2</code>. </p> <p>Numerically, I know I can either interpolate the function and take the derivative analytically or use <a href="https://en.wikipedia.org/wiki/Finite_difference#Higher-order_differences" rel="noreferrer">higher order finite-differences</a>. I think that there is enough data to use either, if one or the other is considered faster, more accurate, etc. </p> <p>I have looked at <code>np.interp()</code> and <code>scipy.interpolate</code> with no success, as this returns me a fitted (linear or cubic) spline, but don't know how to get the derivative at that point. </p> <p>Any guidance is much appreciated.</p>
0debug
My let's arent saving when i assign a value to them : <p>I am using electron version 2.0.5 and ipcMain and ipcRenderer to pass data between my HTML and my main.js</p> <pre><code>let fna,lna,emaila,passa; ipcMain.on('fname', function(er, fn){ fna = fn; console.log(fn) }); console.log(fna); </code></pre> <p>When I test it the function runs and when the first console.log runs. I get the right data. But when the second one runs I get undefined... I do not understand electron very well as I am new to it.</p> <p>Thank you in advance.</p>
0debug
php extract text between nth and nth character : <p>How can I use php to get the sting bewteen the 7th and 8th /</p> <pre><code>http://uk.soccerway.com/matches/2015/01/01/england/premier-league/stoke-city-fc/manchester-united-fc/1703889/?ICID=HP_MS_01_01 </code></pre> <p>so the above would grab england</p>
0debug
How do you get the current figure number in Python's matplotlib? : <p>I'm playing around with an example script that shows how to switch back and forth between figures. I found the example here: <a href="http://matplotlib.org/examples/pylab_examples/multiple_figs_demo.html" rel="noreferrer">http://matplotlib.org/examples/pylab_examples/multiple_figs_demo.html</a> When I try to print out the figure number I get "Figure(640x480)" instead of the number 1 I was expecting. How do you get the number?</p> <pre><code># Working with multiple figure windows and subplots import matplotlib.pyplot as plt import numpy as np t = np.arange(0.0, 2.0, 0.01) s1 = np.sin(2*np.pi*t) s2 = np.sin(4*np.pi*t) plt.figure(1) plt.subplot(211) plt.plot(t, s1) plt.subplot(212) plt.plot(t, 2*s1) plt.figure(2) plt.plot(t, s2) # now switch back to figure 1 and make some changes plt.figure(1) plt.subplot(211) plt.plot(t, s2, 's') ax = plt.gca() ax.set_xticklabels([]) # Return a list of existing figure numbers. print "Figure numbers are = " + str(plt.get_fignums()) print "current figure = " + str(plt.gcf()) print "current axes = " + str(plt.gca()) plt.show() </code></pre> <p>Here is the output:</p> <pre><code>Figure numbers are = [1, 2] current figure = Figure(640x480) current axes = Axes(0.125,0.53;0.775x0.35) </code></pre>
0debug
Open downloaded file on Android N using FileProvider : <p>I've got to fix our App for Android N due to the FileProvider changes. I've basically read all about this topic for the last ours, but no solution found did work out for me.</p> <p>Here's our prior code which starts downloads from our app, stores them in the <code>Download</code> folder and calls an <code>ACTION_VIEW</code> intent as soons as the <code>DownloadManager</code> tells he's finished downloading:</p> <pre><code>BroadcastReceiver onComplete = new BroadcastReceiver() { public void onReceive(Context ctxt, Intent intent) { Log.d(TAG, "Download commplete"); // Check for our download long referenceId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1); if (mDownloadReference == referenceId) { DownloadManager.Query query = new DownloadManager.Query(); query.setFilterById(mDownloadReference); Cursor c = mDownloadManager.query(query); if (c.moveToFirst()) { int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) { String localUri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); String fileExtension = MimeTypeMap.getFileExtensionFromUrl(localUri); String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension); if (mimeType != null) { Intent openFileIntent = new Intent(Intent.ACTION_VIEW); openFileIntent.setDataAndTypeAndNormalize(Uri.parse(localUri), mimeType); openFileIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); try { mAcme.startActivity(openFileIntent); } catch (ActivityNotFoundException e) { // Ignore if no activity was found. } } } } } } }; </code></pre> <p>This works on Android M, but breaks on N due to the popular <code>FileUriExposedException</code>. I've now tried to fix this by using the <code>FileProvider</code>, but I cannot get it to work. It's breaking when I try to get the content URI:</p> <p><code>Failed to find configured root that contains /file:/storage/emulated/0/Download/test.pdf</code></p> <p>The <code>localUri</code> returned from the <code>DownloadManager</code> for the file is:</p> <p><code>file:///storage/emulated/0/Download/test.pdf</code></p> <p>The <code>Environment.getExternalStorageDirectory()</code> returns <code>/storage/emulated/0</code> and this is the code for the conversion:</p> <pre><code>File file = new File(localUri); Log.d(TAG, localUri + " - " + Environment.getExternalStorageDirectory()); Uri contentUri = FileProvider.getUriForFile(ctxt, "my.file.provider", file); </code></pre> <p>From <code>AndroidManifest.xml</code></p> <pre><code> &lt;provider android:name="android.support.v4.content.FileProvider" android:authorities="my.file.provider" android:exported="false" android:grantUriPermissions="true"&gt; &lt;meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/&gt; &lt;/provider&gt; </code></pre> <p>The <code>file_paths.xml</code>:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;external-path name="external_path" path="." /&gt; &lt;/paths&gt; </code></pre> <p>And I've tried all values I could find in that xml file. :(</p>
0debug
static uint32_t ehci_mem_readl(void *ptr, target_phys_addr_t addr) { EHCIState *s = ptr; uint32_t val; val = s->mmio[addr] | (s->mmio[addr+1] << 8) | (s->mmio[addr+2] << 16) | (s->mmio[addr+3] << 24); trace_usb_ehci_mmio_readl(addr, addr2str(addr), val); return val; }
1threat
How to extract arrays out of another array in PHP : <p>I have an array:</p> <pre><code>Array ( [0] =&gt; Array ( [filePath] =&gt; 0000000023.jpg ) [1] =&gt; Array ( [0] =&gt; Array ( [Label] =&gt; Array ( [0] =&gt; Person [1] =&gt; Person ) [Score] =&gt; Array ( [0] =&gt; 0.999217033 [1] =&gt; 0.999318361 ) [Coordinates] =&gt; Array ( [0] =&gt; Array ( [0] =&gt; 338 [1] =&gt; 430 [2] =&gt; 307 [3] =&gt; 506 ) [1] =&gt; Array ( [0] =&gt; 71 [1] =&gt; 104 [2] =&gt; 318 [3] =&gt; 483 ) ) ) ) ) </code></pre> <p>I need to make it to be look like this:</p> <pre><code>Array ( [0] =&gt; Array ( [filePath] =&gt; 0000000023.jpg ) [1] =&gt; Array ( [0] =&gt; Array ( [Label] =&gt; Person [Score] =&gt; 0.999217033 [Coordinates] =&gt; [0] =&gt; Array ( [0] =&gt; 338 [1] =&gt; 430 [2] =&gt; 307 [3] =&gt; 506 ) ) [1] =&gt; Array ( [Label] =&gt; Person [Score] =&gt; 0.999318361 [Coordinates] =&gt; [0] =&gt; Array ( [0] =&gt; 71 [1] =&gt; 104 [2] =&gt; 318 [3] =&gt; 483 ) ) ) ) </code></pre> <p>In Ruby I can use map and select to get the result however in PHP I can't figure it out. I managed to do it with <code>Foreach</code> loop however it is very ugly and lots of if statement. </p> <p>I'd appreciate any guidance. </p>
0debug
Is it possible to create a third party version of another website with a login page? : <p>We have a school website where you are able to log in and see your schedule, assignments etc. Is it possible to create my own version of our school website where you can log in and get access to schedule, assignments etc? My goal is to create a simplified and cleaner look for it. What kind of code do i need to log in to the school website through my own website and retrieve the information in variables? </p>
0debug
int kvm_has_sync_mmu(void) { return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU); }
1threat
static int vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset, int64_t offset_in_cluster, QEMUIOVector *qiov, int bytes) { int ret; int cluster_bytes, buf_bytes; uint8_t *cluster_buf, *compressed_data; uint8_t *uncomp_buf; uint32_t data_len; VmdkGrainMarker *marker; uLongf buf_len; if (!extent->compressed) { ret = bdrv_co_preadv(extent->file->bs, cluster_offset + offset_in_cluster, bytes, qiov, 0); if (ret < 0) { return ret; } return 0; } cluster_bytes = extent->cluster_sectors * 512; buf_bytes = cluster_bytes * 2; cluster_buf = g_malloc(buf_bytes); uncomp_buf = g_malloc(cluster_bytes); ret = bdrv_pread(extent->file, cluster_offset, cluster_buf, buf_bytes); if (ret < 0) { goto out; } compressed_data = cluster_buf; buf_len = cluster_bytes; data_len = cluster_bytes; if (extent->has_marker) { marker = (VmdkGrainMarker *)cluster_buf; compressed_data = marker->data; data_len = le32_to_cpu(marker->size); } if (!data_len || data_len > buf_bytes) { ret = -EINVAL; goto out; } ret = uncompress(uncomp_buf, &buf_len, compressed_data, data_len); if (ret != Z_OK) { ret = -EINVAL; goto out; } if (offset_in_cluster < 0 || offset_in_cluster + bytes > buf_len) { ret = -EINVAL; goto out; } qemu_iovec_from_buf(qiov, 0, uncomp_buf + offset_in_cluster, bytes); ret = 0; out: g_free(uncomp_buf); g_free(cluster_buf); return ret; }
1threat
How share x axis of two subplots after they are created? : <p>I'm trying to share two subplots axis, but I need to share x axis after the figure was created. So, for instance, I create this figure:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt t= np.arange(1000)/100. x = np.sin(2*np.pi*10*t) y = np.cos(2*np.pi*10*t) fig=plt.figure() ax1 = plt.subplot(211) plt.plot(t,x) ax2 = plt.subplot(212) plt.plot(t,y) # some code to share both x axis plt.show() </code></pre> <p>Instead of the comment I would insert some code to share both x axis. I didn't find any clue how i can do that. There are some attributes <code>_shared_x_axes</code> and <code>_shared_x_axes</code> when i check to figure axis (<code>fig.get_axes()</code>) but I don't know how to link them.</p>
0debug
static int aio_flush_f(BlockBackend *blk, int argc, char **argv) { blk_drain_all(); return 0; }
1threat
How to configure VS Code Auto import? : <p>Is there a way of tweaking TypeScript Auto import feature in Visual Studio Code?</p> <p>As an example, observe the following attempt: </p> <p><a href="https://i.stack.imgur.com/X6xWb.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/X6xWb.gif" alt="enter image description here"></a></p> <p>The added line by the Auto import was the following: </p> <pre><code>import { Pins } from '../types/index'; </code></pre> <p>I would like it to be added straight away without the comma, in respect to TSLint, and without the <code>/index</code> path, due to my subject sense of aesthetics, like the following:</p> <pre><code>import { Pins } from '../types' </code></pre> <p>Is there a way of saving those few "extra" keyboard hits?</p>
0debug
How to return gzipped content with AWS API Gateway : <p>We have developed an application that offers serveral rest services and supports <code>Accept-Encoding</code> header to return compressed content through <code>Content-Encoding:gzip</code> header value. </p> <p>This application is deployed on ec2 instances on aws and when we send a request with <code>Accept-Encoding</code> value set the response is correctly built.</p> <p>We want to expose this api by using api gateway but it is just working for not compressing requests. When we send a request asking for gzipped content the <code>Content-Encoding</code> header is set correctly but the response content is corrupt.</p> <p>Do we have to set some special parameter or configuration in integration response or method response steps?</p> <p>Regards.</p>
0debug