problem
stringlengths
26
131k
labels
class label
2 classes
Create one activity to show multiple strings by buttons id : for example, i have to activities, first activity contain three buttons, when i click button 1 they go to second activity and show the string by id in the TextView, if click button 2 they go to same activity that is (second activity) and show the string for button 2 by id and more... please help me!
0debug
static av_cold int flashsv_encode_end(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; deflateEnd(&s->zstream); av_free(s->encbuffer); av_free(s->previous_frame); av_free(s->tmpblock); av_frame_free(&avctx->coded_frame); return 0; }
1threat
what is wrong is here? : File "/Users/user/Desktop/Dp1/simplesocial/groups/views.py", line 24 messages.warning(self.request=,('Warning already a member!')) SyntaxError: invalid syntax from django.shortcuts import render from django.contrib.auth.mixins import (LoginRequiredMixin,PermissionRequiredMixin) from django.urls import reverse from django.views import generic from groups.models import Group,GroupMember from django.shortcuts import get_object_or_404 from django.contrib import messages # Create your views here. class CreateGroup(LoginRequiredMixin,generic.CreateView): fields = ('name','description') model = Group class SingleGroup(generic.DetailView): model = Group class ListGroups(generic.ListView): model = Group class JoinGroup(LoginRequiredMixin,generic.RedirectView): def get_redirect_url(self,*args,**kwargs): return reverse('groups:single',kwargs={'slug':self.kwargs.get('slug')}) def get(self,request,*args,**kwargs): group = get_object_or_404(Group,slug=self.kwargs.get('slug')) try: GroupMember.objects.create(user=self.request.user,group=group) except IntegrityError: messages.warning(self.request=,('Warning already a member!')) else: messages.success(self.request,'You are now a member!') return super().get(request,*args,**kwargs) class LeaveGroup(LoginRequiredMixin,generic.RedirectView): def get_redirect_url(self,*args,**kwargs): return reverse('groups:single',kwargs={'slug':self.kwargs.get('slug')}) def get(self,request,*args,**kwargs): try: membership = models.GroupMember.objects.filter(user=self.request.user,group__slug=self.kwargs.get('slug')).get() except models.GroupMember.DoesNotExist: messages.warning(self.request,'Sorry you are not in this group!') else: membership.delete() messages.success(self.request,'You have left the group!') return super().get(request,*args,**kwargs)
0debug
Express server not listening to specific port 3000 on localhost : <p>app.listen(port, (err) => { if (err) return console.log(err); console.log('Server running on port ' + port); })</p>
0debug
VB.NET - Query will not update SQL Server : In the below code, my second query will not insert into the SQL database, but the first one will update. I can copy the query (from the msgbox i added for testing) and paste it in SQL Server Management Studio, and it will execute fine. I also do not get any error messages back from SQL, though i'm not sure if that code is correct (it was copied + pasted from another source). Also, can i simplify the code to pass both queries at the same time? Dim Conn As New System.Data.SqlClient.SqlConnection 'sql server datastream connection Dim Cmd As New System.Data.SqlClient.SqlCommand 'sql command vars Dim SqlQuery As String 'string var used to hold various SQL queries Dim data As System.Data.SqlClient.SqlDataReader 'datareader object variable Dim MVDataset As New DataSet Dim MVDatatable As DataTable Dim MVDatarow As DataRow Private Sub MVUpdateButton_Click(sender As Object, e As EventArgs) Handles MVUpdateButton.Click vbyn = MsgBox("Are you sure you want to update Tally Sheet Master Variables?" & vbCrLf & vbCrLf & "Changes to these variables will change the functionality of the Tally Sheet!", vbYesNo, ) Try Select Case vbyn Case vbNo GoTo MVTableUpdateBypass Case vbYes 'get new data from textboxes Vers = TextBox1.Text If TextBox2.Text = True Then Testing = 1 Else Testing = 0 End If FlatFeeCharge = TextBox3.Text PrepricingCharge = TextBox4.Text SendMailAcct = TextBox5.Text SendMailPW = TextBox6.Text TestingEmail = TextBox7.Text PrePricingEmail = TextBox8.Text ImperataEmail = TextBox9.Text 'update existing active row to mark inactive SqlQuery = "Update MasterVars set Active = 0 where PKEY = " & PKEY & ";" MsgBox(SqlQuery) If Conn.State = ConnectionState.Closed Then Conn.ConnectionString = "Data Source=SQL01;Initial Catalog=TallySheet;Integrated Security=SSPI;" End If Conn.Open() Dim MVDataAdapter As New SqlDataAdapter(SqlQuery, Conn) Dim MVUpdateCommand As SqlCommand MVUpdateCommand = New SqlCommand(SqlQuery) MVDataAdapter.UpdateCommand = MVUpdateCommand 'insert new active row SqlQuery = "Insert into MasterVars (Vers, Testing, FlatFeeCharge, PrePricingCharge, SendMailAcct, SendMailPW, TestingEmail, PrePricingEmail, ImperataEmail, DTS, UserName, Active) Values (" & "'" & Vers & "', " & Testing & ", '" & FlatFeeCharge & "'" & ", '" & PrepricingCharge & "'" & ", '" & SendMailAcct & "'" & ", '" & SendMailPW & "'" & ", '" & TestingEmail & "'" & ", '" & PrePricingEmail & "'" & ", '" & ImperataEmail & "'" & ", '" & Date.Now & "'," & "'QGDOMAIN\" & Environment.UserName & "'," & 1 & ");" MsgBox(SqlQuery) Dim MVInsertCommand As SqlCommand MVInsertCommand = New SqlCommand(SqlQuery) MVDataAdapter.InsertCommand = MVInsertCommand MVDataAdapter.Fill(MVDataset, "MasterVars") End Select Catch ex As SqlException Dim i As Integer Dim errormessages As String errormessages = "" For i = 0 To ex.Errors.Count - 1 errormessages = errormessages & " " & ("Index #" & i.ToString() & ControlChars.NewLine _ & "Message: " & ex.Errors(i).Message & ControlChars.NewLine _ & "LineNumber: " & ex.Errors(i).LineNumber & ControlChars.NewLine _ & "Source: " & ex.Errors(i).Source & ControlChars.NewLine _ & "Procedure: " & ex.Errors(i).Procedure & ControlChars.NewLine) Next i Console.WriteLine(errorMessages.ToString()) End Try 'reload form with updated variables Conn.Close() Conn.Dispose() MVTableUpdateBypass: End Sub
0debug
iOS must run pod install after every checkup : <p>I am using cocoapods for an iOS project and every time I checkout a new branch I have to run <code>pod install</code>, as the pods don't run. </p> <p>Is there a solution to not have to run <code>pod install</code> every time?</p>
0debug
What is the difference between Int and Integer in Kotlin? : <p>I have tried using Int and Integer types in Kotlin.Although I don't see any difference. Is there a difference between Int and Integer types in Kotlin?Or are they the same?</p>
0debug
How to verify call on setter in kotlin using mockito? : <pre><code>interface LoginDisplay { var username: String var password: String } class LoginActivityLoginDisplay : LoginDisplay { override var username: String get() = usernameEditView.text.toString() set(value) { usernameEditView.setText(value) } override var password: String get() = passwordEditView.text.toString() set(value) { passwordEditView.setText(value) } } </code></pre> <p>This is the example of code I'd like to test with Mockito as follows:</p> <pre><code>verify(contract.loginDisplay).username </code></pre> <p>Tricky thing is - that in this call i can only verify getter of field username, meanwhile I'd like to test call on setter of this field.</p> <p>Any help?</p>
0debug
Naming convention for models that get posted against a controller? : <p>We use the term <em>ViewModel</em> for classes that get returned from a controller and are passed to the view. Instead of using ViewBag or ViewData, we are using a strongly typed class which basically stores every value the view needs.</p> <pre><code>public IActionResult OrderStep1() { var model = new ViewModelStep1() { SomeProperty = "SomeValue", ... } return View(model); } </code></pre> <p>I'm looking for a naming convention that specifies how we should name a class that contains the properties that are posted from the submit button of a form to the controller. In the following example, I've chosen <code>OrderStep2</code> as a temporary name for that class. </p> <p>For our multiple step order wizard, we are using <a href="https://en.wikipedia.org/wiki/Post/Redirect/Get" rel="nofollow noreferrer">Post/Redirect/Get</a> pattern. Therefore, I can enrich the information from <code>OrderStep2</code> and return a specific ViewModel <code>OrderStep2VM</code>.</p> <pre><code>[HttpPost] [ValidateAntiForgeryToken] [Route("order/step2")] public async Task&lt;IActionResult&gt; OrderStep2(OrderStep2 model) { // save some changes into the database and retrieve a GUID configurationId return RedirectToAction(nameof(OrderStep2()), new { configurationId = "GUID" }); } [Route("order/step2/{configurationId}")] public IActionResult OrderStep2(Guid configurationId) { // retrieve configuration from database based on the configurationID // do something else var model = new OrderStep2VM() { .... }; return View(model); } </code></pre> <p>Since I want the code to be well organized, I'd like to group classes such as <code>OrderStep2</code> into a seperate namespace. Currently, I'm thinking of calling them <em>PostModels</em>, i.e., <code>OrderStep2PM</code>, but I don't want to define a new term for something that probably already exists.</p> <p>(In case you are wondering why I'm not using TempData: The workflow of the application requires saving incomplete form data which allows me to skip TempData since I need to store in the database anyway).</p>
0debug
How to reverse the exon numbers on the minus strand? : <p>As shown below, the exon numbers (on the 5th column) when the gene is on the minus strand ("-" on the 6th column) should be reversed. For example, for NT5C3B gene, exon numbered from 1, 2....9 should be reversed to 9, 8, ...1 , I don't know how to programmatically do this with awk or Python. I would greatly appreciate your kind help. </p> <hr> <pre><code>chr17 39968961 39969531 FKBP10 1 + chr17 39973309 39973455 FKBP10 2 + chr17 39974340 39974530 FKBP10 3 + chr17 39974633 39974779 FKBP10 4 + chr17 39975461 39975651 FKBP10 5 + chr17 39975781 39975927 FKBP10 6 + chr17 39976520 39976713 FKBP10 7 + chr17 39977198 39977341 FKBP10 8 + chr17 39977905 39978069 FKBP10 9 + chr17 39978474 39979469 FKBP10 10 + chr17 39981333 39981909 NT5C3B 1 - chr17 39983677 39983878 NT5C3B 2 - chr17 39985041 39985204 NT5C3B 3 - chr17 39987052 39987142 NT5C3B 4 - chr17 39988643 39988729 NT5C3B 5 - chr17 39991321 39991368 NT5C3B 6 - chr17 39991454 39991524 NT5C3B 7 - chr17 39992110 39992209 NT5C3B 8 - chr17 39992433 39992523 NT5C3B 9 - chr17 39994042 39994378 KLHL10 1 + chr17 39998074 39998564 KLHL10 2 + chr17 40001377 40001995 KLHL10 3 + chr17 40003512 40003662 KLHL10 4 + chr17 40004184 40004599 KLHL10 5 + chr17 40009798 40011573 KLHL11 1 - chr17 40021078 40021629 KLHL11 2 - chr17 40023178 40024157 ACLY 1 - chr17 40024961 40025038 ACLY 2 - chr17 40025295 40025378 ACLY 3 - chr17 40025726 40025840 ACLY 4 - chr17 40027941 40028085 ACLY 5 - chr17 40028284 40028435 ACLY 6 - chr17 40030063 40030218 ACLY 7 - chr17 40034355 40034449 ACLY 8 - chr17 40035049 40035177 ACLY 9 - chr17 40039374 40039485 ACLY 10 - chr17 40040445 40040527 ACLY 11 - chr17 40042364 40042561 ACLY 12 - chr17 40043851 40043956 ACLY 13 - chr17 40048531 40048700 ACLY 14 - chr17 40049285 40049427 ACLY 15 - chr17 40052872 40052902 ACLY 16 - chr17 40054001 40054092 ACLY 17 - chr17 40054883 40055038 ACLY 18 - chr17 40057948 40058066 ACLY 19 - chr17 40060981 40061043 ACLY 20 - chr17 40061774 40061911 ACLY 21 - chr17 40062780 40062899 ACLY 22 - chr17 40063694 40063825 ACLY 23 - chr17 40065241 40065321 ACLY 24 - chr17 40065762 40065953 ACLY 25 - chr17 40066474 40066537 ACLY 26 - chr17 40068672 40068795 ACLY 27 - chr17 40069967 40070149 ACLY 28 - chr17 40075132 40075272 ACLY 29 - </code></pre> <hr> <p>Jeff</p>
0debug
iOS 11 URL Scheme for specific Settings section stopped working : <p>My app uses a URL scheme to take users directly to Settings/General/About section, the following URL was working fine in 10.3.x.<br> "App-Prefs:root=General&amp;path=About"</p> <p>However, this URL scheme no longer works in iOS 11 GM build. It only launches the Settings app, but doesn't take user any further. Does anybody know if this is expected in iOS 11 official release? Thanks in advance.</p>
0debug
How to get substring out of String in java? : <p>i am getting this String input="One Two Three"; how to get substrings out of it? I want to get optimized solutions. help me!</p>
0debug
Whats best practice for loading keys in a Go web app? : <p>I usually worry about memory corruption with leaving my public and private keys in memory for access throughout my applications. I'm very new to Go and I'm wondering what the best practice is for making these keys available.</p> <p>Is Go safe enough that I should be able to store these in memory, no problem. Or should I only keep my public key in memory for validation and load my private key every time I need to sign a token?</p>
0debug
static void FUNCC(pred16x16_horizontal)(uint8_t *_src, int stride){ int i; pixel *src = (pixel*)_src; stride /= sizeof(pixel); for(i=0; i<16; i++){ ((pixel4*)(src+i*stride))[0] = ((pixel4*)(src+i*stride))[1] = ((pixel4*)(src+i*stride))[2] = ((pixel4*)(src+i*stride))[3] = PIXEL_SPLAT_X4(src[-1+i*stride]); } }
1threat
Using GraphQL Fragment on multiple types : <p>If I have a set of field that is common to multiple types in my GraphQL schema, is there a way to do something like this?</p> <pre><code>type Address { line1: String city: String state: String zip: String } fragment NameAndAddress on Person, Business { name: String address: Address } type Business { ...NameAndAddress hours: String } type Customer { ...NameAndAddress customerSince: Date } </code></pre>
0debug
static int ea_read_header(AVFormatContext *s, AVFormatParameters *ap) { EaDemuxContext *ea = s->priv_data; AVStream *st; if (!process_ea_header(s)) return AVERROR(EIO); if (ea->video_codec) { st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); ea->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = ea->video_codec; st->codec->codec_tag = 0; st->codec->time_base = ea->time_base; st->codec->width = ea->width; st->codec->height = ea->height; if (ea->num_channels <= 0) { av_log(s, AV_LOG_WARNING, "Unsupported number of channels: %d\n", ea->num_channels); if (ea->audio_codec) { st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, ea->sample_rate); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = ea->audio_codec; st->codec->codec_tag = 0; st->codec->channels = ea->num_channels; st->codec->sample_rate = ea->sample_rate; st->codec->bits_per_coded_sample = ea->bytes * 8; st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample / 4; st->codec->block_align = st->codec->channels*st->codec->bits_per_coded_sample; ea->audio_stream_index = st->index; ea->audio_frame_counter = 0; return 1;
1threat
static int omap_validate_emifs_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { return range_covers_byte(OMAP_EMIFS_BASE, OMAP_EMIFF_BASE - OMAP_EMIFS_BASE, addr); }
1threat
Can't display a string from an array of strings : When i press button VK_LEFT / VK_RIGHT nothing happens, why??? I would like it to print the next string in the array but it won't do it for some reason!!! what am i doing wrong here? thanks for anyone helping me out here! ``` int TotalItems = 0, IntForItem = 0; struct Item { int * Index; std::string* stringArray = new std::string[3]; }; Item item[120]; int AddNewItem(int i, int * Index, std::string stringarray[]) { item[i].Index = Index; item[i].stringArray = stringarray; return (i + 1); } void GetItems() { int i = 0; std::string * test = new std::string[3]{ "hi", "and", "bye" }; i = AddNewItem(i, &IntForItem, test); TotalItems = i; } int main() { GetItems(); while (true) { system("CLS"); std::cout << item[0].stringArray[*item[0].Index].c_str() << std::endl; while (true) { if (GetAsyncKeyState(VK_LEFT)) *item[0].Index -= 1; else if (GetAsyncKeyState(VK_RIGHT)) *item[0].Index += 1; } } Sleep(1); return 0; } ```
0debug
I'm getting a stack overflow exception in my get method : <p>while I was refactoring my code, I got a System.StackOverflowException thrown by my <strong>get</strong> method when my view try to access a member of my class. That's the first time that I'm using the <strong>?? (null-coalescing operator)</strong> in c#.</p> <p>That's my <strong>model</strong>:</p> <pre><code>using System; using System.ComponentModel.DataAnnotations; namespace Extranet45.Models { public class Complaint { public string Nome { get =&gt; Nome ?? "Nome não informado."; private set =&gt; Nome = value ?? "Nome não informado."; } public string Email { get =&gt; Email ?? "Email não informado."; private set =&gt; Email = value ?? "Email não informado."; } [Required(ErrorMessage = "A denuncia não possui o texto obrigatório do seu conteúdo. (Corpo da Mensagem)")] public string Denuncia { get =&gt; Denuncia ?? "O texto da denuncia não foi encontrado."; private set =&gt; Denuncia = value ?? throw new ArgumentNullException("O campo denúncia é obrigatório."); } public Complaint() { } public Complaint(string nome, string email, string denuncia) { Nome = nome; Email = email; Denuncia = denuncia; } } } </code></pre> <p>That's my <strong>controller/action</strong>:</p> <pre><code>using System; using System.Web.Mvc; using Extranet45.Models; using Utils; namespace Extranet45.Controllers { public class ComplaintController : Controller { public ActionResult Index() { return RedirectToAction("Send"); } // GET: Complaint/Send public ActionResult Send() { return View(new Complaint()); } } } </code></pre> <p>That's the <em>part of</em> my <strong>view</strong> where the exception is raised.</p> <pre><code>@model Extranet45.Models.Complaint @{ Layout = "~/Views/Shared/_Layout.cshtml"; ViewBag.Title = "Denúncia"; ViewBag.ShowHeader = false; ViewBag.BodyClass = "profile-page"; //Faz com que o header fique com a altura menor, porém ñão é uma solução elegante, refatorar ViewBag.HeaderImageUrl = "https://github.com/creativetimofficial/material-kit/blob/master/assets/img/city-profile.jpg?raw=true"; } @using (Html.BeginForm("Send", "Complaint", FormMethod.Post, new { @Class = "contact-form"})) { &lt;div class="section section-contacts"&gt; &lt;div class="col-md-8 ml-auto mr-auto"&gt; @ViewBag.ErrorMessage &lt;h2 id="main-title" class="text-center title"&gt;Denuncie&lt;/h2&gt; &lt;h4 class="text-center description"&gt;Caso você tenha alguma reclamação ou precise comunicar algo incorreto ao Ceape, nos envie uma mensagem abaixo ou um email para &lt;a href="mailto:denuncias@ceapema.org.br"&gt;denuncias@@ceapema.org.br&lt;/a&gt;&lt;/h4&gt; &lt;div class="row justify-content-center"&gt; &lt;div class="col-md-8"&gt; &lt;div class=" form-group bmd-form-group"&gt; &lt;label for="textbox-nome" class="bmd-label-static"&gt;Nome - Opcional&lt;/label&gt; @Html.TextBoxFor(m =&gt; m.Nome, new { @id = "textbox-nome", @Type = "Text", @Class = "form-control", name = "nome" }) &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>More precisely at this line, when the view try to access the member <strong>m.Nome</strong></p> <pre><code>@Html.TextBoxFor(m =&gt; m.Nome, new { @id = "textbox-nome", @Type = "Text", @Class = "form-control", name = "nome" }) </code></pre> <p>I don't know why my usage of null coalescing operator is causing an stack overflow.</p>
0debug
Negative chat id in log file of telegram bot : <p>I have a telegram bot and save all user activity in a log file. When check log file, find user with negative chat id <code>-107606558</code>. Is this usual?</p>
0debug
Macro to fill down based on number contents of adjacent cell or other sheet : I've seen a few other posts similar to this but I can seem to get mine to work. Right now I have data in Column A, from A5 to A50 but the end point is subject to change. I am looking for a macro to select B5 to Y5 and fill down to the end of column A (in this case to row 50, but this will change every time). The amount of rows depends on another sheet. As an alternative to my question above, if there is a way to go to the other sheet, and count the rows in column A, from A4 down and then fill down in my other sheet that amount that would be just as good. **Summary** - I have one sheet with the data, starting at A4 and going down for an amount that will be changing. - I would like to be able to fill down on another sheet the number of rows there are in the first sheet. Hopefully this makes sense, and thanks for the help.
0debug
static int get_pci_config_device(QEMUFile *f, void *pv, size_t size) { PCIDevice *s = container_of(pv, PCIDevice, config); uint8_t config[size]; int i; qemu_get_buffer(f, config, size); for (i = 0; i < size; ++i) if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) return -EINVAL; memcpy(s->config, config, size); pci_update_mappings(s); return 0; }
1threat
BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file) { char *filename_full = NULL; char *backing_file_full = NULL; char *filename_tmp = NULL; int is_protocol = 0; BlockDriverState *curr_bs = NULL; BlockDriverState *retval = NULL; if (!bs || !bs->drv || !backing_file) { return NULL; } filename_full = g_malloc(PATH_MAX); backing_file_full = g_malloc(PATH_MAX); filename_tmp = g_malloc(PATH_MAX); is_protocol = path_has_protocol(backing_file); for (curr_bs = bs; curr_bs->backing; curr_bs = curr_bs->backing->bs) { if (is_protocol || path_has_protocol(curr_bs->backing_file)) { if (strcmp(backing_file, curr_bs->backing_file) == 0) { retval = curr_bs->backing->bs; break; } bdrv_get_full_backing_filename(curr_bs, backing_file_full, PATH_MAX, &local_error); if (local_error == NULL) { if (strcmp(backing_file, backing_file_full) == 0) { retval = curr_bs->backing->bs; break; } } else { error_free(local_error); local_error = NULL; } } else { path_combine(filename_tmp, PATH_MAX, curr_bs->filename, backing_file); if (!realpath(filename_tmp, filename_full)) { continue; } path_combine(filename_tmp, PATH_MAX, curr_bs->filename, curr_bs->backing_file); if (!realpath(filename_tmp, backing_file_full)) { continue; } if (strcmp(backing_file_full, filename_full) == 0) { retval = curr_bs->backing->bs; break; } } } g_free(filename_full); g_free(backing_file_full); g_free(filename_tmp); return retval; }
1threat
TREE LIKE STRUCTURE / GRID IN LISTVIEW XAF BUSINESS OBJECT : I have been having super difficulties on creating a view that will display my data grouped in levels (Screenshot attached). I don't know on how to go about this, my data is stored in **ONE single table** in database which is mapped to a business object in application. Therefore what I want is to **group elements based on PROPERTIES** (attributes of table) , for instance, group level one based on first property etc. Probably some of you may have worked previously on devexpress and have some suggestions. It would be extremely helpful if you could help on this. Thank you !!!
0debug
The simplest way to serve webpages with dynamic content with nodejs + express : <p>I'm building a web application with nodejs and express which has two views, one for writing and submitting the written data to a database, and another one for viewing the data from the database. </p> <p>What would be the simplest way to serve the html file with the content loaded from the database? Would I need to use a templating engine or is there a simpler way of adding the loaded content to a html file? I'm trying to avoid bloating the app with unnecessary overhead and keeping it as simple as possible.</p>
0debug
Python invalid syntax on define : <p>I made a piece of code for taking the cpu temp for my rpi and if it's more than 60 C to send a signal on GPIO port 7 and if it's not more than 60 C to not send the signal on the port but I get this error:</p> <pre><code> File "tempgate.py", line 17 def FanController(CPU_temp) : ^ SyntaxError: invalid syntax </code></pre> <p>The file is:</p> <pre><code>#Module import and variables import getinfo import RPi.GPIO as GPIO import time import atexit import datetime CPU_temp = getinfo.getCPUtemperature #Start info st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') print("[LOG] [" + st + "] Program has started") #Setup and definitions try: GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) def FanController(CPU_temp) : CPU_temp = int(float(CPU_temp)) print(CPU_temp) if(int(CPU_temp) &gt; int(60)) : GPIO.setup(7, GPIO.OUT) ts = time.time() st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') print("[LOG] [" + st + "] Fan is now on") time.sleep(5) else : GPIO.setup(7, GPIO.IN) ts = time.time() st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') print("[LOG] [" + st + "] Fan is now off") time.sleep(5) #main app while True : CPU_temp = getinfo.getCPUtemperature() print("[LOG] [" + st + "] Cpu CPU_temp is: " + CPU_temp) FanController(CPU_temp) GPIO.cleanup() atexit.register(GPIO.cleanup()) </code></pre>
0debug
Curl to return http status code along with the response : <p>I use curl to get http headers to find http status code and also return response. I get the http headers with the command</p> <pre><code>curl -I http://localhost </code></pre> <p>To get the response, I use the command </p> <pre><code>curl http://localhost </code></pre> <p>As soon as use the -I flag, I get only the headers and the response is no longer there. Is there a way to get both the http response and the headers/http status code in in one command?</p>
0debug
Docker stuck on "Waiting for SSH to be available..." : <p>I'm using a docker with Windows and Hyper-v to create containers. I've added a docker machine <strong>vmachine</strong> to my docker configuration. First time the machine is created, it gets an IP (although I cannot manage nginx to access it - ERR_CONNECTION_REFUSED) and finishes the bootup.</p> <p>When I turn off the machine and then try to boot it, i get stuck in this message</p> <p><strong>Waiting for SSH to be available...</strong></p> <p>And it doesn't evolve from there. The machine is booted, however, I get an IPv6 when I input the command <code>docker-machine ip vmachine</code> like - <code>fe80::215:5dff:fe21:10b</code> insted of a IPv4 </p> <p>What am I doing wrong?</p>
0debug
javascript variables and google maps distance service : <p>I use Google Maps Distance Service API to get driving distance and time between two points. Here's my code:</p> <pre><code>&lt;div id="right-panel"&gt; &lt;div id="output"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="map"&gt;&lt;/div&gt; &lt;script&gt; function initMap() { var bounds = new google.maps.LatLngBounds; var markersArray = []; var origin1 = "&lt;?php echo $partenza; ?&gt;"; var destinationA = "&lt;?php echo $destinazione; ?&gt;"; var destinationIcon = 'https://chart.googleapis.com/chart?' + 'chst=d_map_pin_letter&amp;chld=D|FF0000|000000'; var originIcon = 'https://chart.googleapis.com/chart?' + 'chst=d_map_pin_letter&amp;chld=O|FFFF00|000000'; var map = new google.maps.Map(document.getElementById('map'), { center: {lat: 55.53, lng: 9.4}, zoom: 10 }); var geocoder = new google.maps.Geocoder; var service = new google.maps.DistanceMatrixService; distanza = 0; service.getDistanceMatrix({ origins: [origin1], destinations: [destinationA], travelMode: 'DRIVING', unitSystem: google.maps.UnitSystem.METRIC, avoidHighways: false, avoidTolls: false }, function(response, status) { if (status !== 'OK') { alert('Error was: ' + status); } else { var originList = response.originAddresses; var destinationList = response.destinationAddresses; var outputDiv = document.getElementById('output'); outputDiv.innerHTML = ''; deleteMarkers(markersArray); var showGeocodedAddressOnMap = function(asDestination) { var icon = asDestination ? destinationIcon : originIcon; return function(results, status) { if (status === 'OK') { map.fitBounds(bounds.extend(results[0].geometry.location)); markersArray.push(new google.maps.Marker({ map: map, position: results[0].geometry.location, icon: icon })); } else { alert('Geocode was not successful due to: ' + status); } }; }; results = response.rows[0].elements; geocoder.geocode({'address': originList[0]}, showGeocodedAddressOnMap(false)); geocoder.geocode({'address': destinationList[0]}, showGeocodedAddressOnMap(true)); outputDiv.innerHTML += results[0].distance.text + ' in ' + results[0].duration.text + '&lt;br&gt;'; distanza = results[0].distance.value; durata = results[0].duration.value; document.innerHTML = distanza + "&lt;br&gt;" + durata; } }); } function deleteMarkers(markersArray) { for (var i = 0; i &lt; markersArray.length; i++) { markersArray[i].setMap(null); } markersArray = []; } console.log("Distanza: "+distanza); console.log("Durata: "+durata); &lt;/script&gt; &lt;script async defer src="https://maps.googleapis.com/maps/api/js?key=MY_API_HERE&amp;callback=initMap"&gt; &lt;/script&gt; </code></pre> <p>I would like to get the distance and time between the points with a "console.log", but when I type console.log("Distanza: "+distanza); the javascript console says: "distanza is not defined"... How could I access these two variables also outside the function?</p>
0debug
How can this for-loop with range be explained : <p>Can someone please help me how to understand this code:</p> <pre><code>j = 0 for i in range(1, 8, 2): j += i print (j) </code></pre> <p>The output is: 1 4 9 16</p> <p>But I just cannot understand why. I get the concept of for-loops and range. But the involvement of the variable and the += operand makes me confused. Can someone explain this step by step, so that I can understand why the output is what it is?</p>
0debug
MySQL: How do I match escaped urls using LIKE or REPLACE : My Situation: I have url's that are stored in my database with escape characters. **Original URL:** http://test01.mysite.com **As Stored in DB:** http:\/\/test01.mysite.com If I run SELECT * FROM table WHERE field LIKE '%http://test01.mysite.com%' OR field LIKE '%http:\/\/test01.mysite.com%' zero records are returned. Similarly, if I run UPDATE table SET field = REPLACE(field, 'http://test01.mysite.com', 'https://test01.mysite.com') or UPDATE table SET field = REPLACE(field, 'http:\/\/test01.mysite.com', 'https://test01.mysite.com') Zero records are affected. I have also experimented with REGEXP and RLIKE, but I have very limited experience there and my attempts have all resulted in either zero records found or all records containing links being found. Anybody know how I can write these queries so that LIKE and REPLACE will find matches to those url's? Any help is greatly appreciated! Thanks!
0debug
SceneKit SCNNode init(mdlObject:) missing? : <p>I'm using Xcode 7.3.1, Swift 2.x, iOS target is 9.3. I can find convenience init <code>init(MDLObject mdlObject: MDLObject)</code> in <a href="https://developer.apple.com/library/ios/documentation/SceneKit/Reference/SCNNode_Class/#//apple_ref/occ/clm/SCNNode/nodeWithMDLObject:" rel="noreferrer" title="docs">Apple docs</a>, but I don't see it in my project. I opened standard game project starter, SceneKit is imported. I've tried:</p> <ul> <li>Double checking iOS version</li> <li>Adding <code>import ModelIO</code></li> <li>Finding "mdlObject:" in header files in SceneKit.framework - not found</li> <li>Looking for alternative methods (maybe Apple moved it somewhere) but there are no other inits with that parameter, no class function, nor I found any corresponding export function in <code>MDLObject</code></li> <li>Cleaning project...</li> </ul> <p>I can see all SceneKit classes, and I can create MDLAsset (part of ModelIO, can return MDLObjects) instance. Any ideas, maybe I've overlooked something obvious?</p>
0debug
How To Format Email to Send as SMS : <p>I want to be notify people via SMS when certain things happen. Seems like it should be pretty straighforward. But when the SMS arrives it has the sender and subject line in the message, and I can't figure out how to adjust the message to get rid of it.</p> <pre><code>import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText message = MIMEMultipart() message['From'] = "xyz@gmail.com" message['To'] = "5551234567@tmomail.net" message['Subject'] = "FOOBAR!" text = "Hello, world!" message.attach(MIMEText(text.encode("utf-8"), "plain", "utf-8")) server = smtplib.SMTP("smtp.gmail.com", 587) server.starttls() server.login(message["From"], "SuperSecretString") server.sendmail(message["From"], [message["To"]], text) </code></pre> <p>Produces something like:</p> <p><code>xyz@gmail.com / FOOBAR!/ Hello, world!</code>, and all I want to see is <code>Hello, world!</code></p>
0debug
why is the storage class of global variables in C implicitly defined as "extern"? : when we declare any global variable , for instance int x ; it is equivalent to extern int x; Now by default global variables are intialized to 0 by the compiler ,which means they are allocated memory .But if I simply write extern int x ; Then this will only declare the variable , while no memory would be allocated o it , so my query is that if I write **extern** before int x or I do not write it , **in case of global variables** , how is the compiler treating them differently since in case where I simply write `int x` , it allocates memory and simultaneously it puts **extern** before int x , while in case where I write `extern int x` , It only declares the variable while no memory is allocated to it , please clarify how the compiler is behaving in both ways .
0debug
x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) { struct x11_grab *x11grab = s1->priv_data; Display *dpy; AVStream *st = NULL; enum PixelFormat input_pixfmt; XImage *image; int x_off = 0; int y_off = 0; int use_shm; char *param, *offset; int ret = 0; AVRational framerate; param = av_strdup(s1->filename); offset = strchr(param, '+'); if (offset) { sscanf(offset, "%d,%d", &x_off, &y_off); x11grab->nomouse= strstr(offset, "nomouse"); *offset= 0; } if ((ret = av_parse_video_size(&x11grab->width, &x11grab->height, x11grab->video_size)) < 0) { av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); goto out; } if ((ret = av_parse_video_rate(&framerate, x11grab->framerate)) < 0) { av_log(s1, AV_LOG_ERROR, "Could not parse framerate: %s.\n", x11grab->framerate); goto out; } #if FF_API_FORMAT_PARAMETERS if (ap->width > 0) x11grab->width = ap->width; if (ap->height > 0) x11grab->height = ap->height; if (ap->time_base.num) framerate = (AVRational){ap->time_base.den, ap->time_base.num}; #endif av_log(s1, AV_LOG_INFO, "device: %s -> display: %s x: %d y: %d width: %d height: %d\n", s1->filename, param, x_off, y_off, x11grab->width, x11grab->height); dpy = XOpenDisplay(param); if(!dpy) { av_log(s1, AV_LOG_ERROR, "Could not open X display.\n"); ret = AVERROR(EIO); goto out; } st = av_new_stream(s1, 0); if (!st) { ret = AVERROR(ENOMEM); goto out; } av_set_pts_info(st, 64, 1, 1000000); use_shm = XShmQueryExtension(dpy); av_log(s1, AV_LOG_INFO, "shared memory extension %s found\n", use_shm ? "" : "not"); if(use_shm) { int scr = XDefaultScreen(dpy); image = XShmCreateImage(dpy, DefaultVisual(dpy, scr), DefaultDepth(dpy, scr), ZPixmap, NULL, &x11grab->shminfo, x11grab->width, x11grab->height); x11grab->shminfo.shmid = shmget(IPC_PRIVATE, image->bytes_per_line * image->height, IPC_CREAT|0777); if (x11grab->shminfo.shmid == -1) { av_log(s1, AV_LOG_ERROR, "Fatal: Can't get shared memory!\n"); ret = AVERROR(ENOMEM); goto out; } x11grab->shminfo.shmaddr = image->data = shmat(x11grab->shminfo.shmid, 0, 0); x11grab->shminfo.readOnly = False; if (!XShmAttach(dpy, &x11grab->shminfo)) { av_log(s1, AV_LOG_ERROR, "Fatal: Failed to attach shared memory!\n"); ret = AVERROR(EIO); goto out; } } else { image = XGetImage(dpy, RootWindow(dpy, DefaultScreen(dpy)), x_off,y_off, x11grab->width, x11grab->height, AllPlanes, ZPixmap); } switch (image->bits_per_pixel) { case 8: av_log (s1, AV_LOG_DEBUG, "8 bit palette\n"); input_pixfmt = PIX_FMT_PAL8; break; case 16: if ( image->red_mask == 0xf800 && image->green_mask == 0x07e0 && image->blue_mask == 0x001f ) { av_log (s1, AV_LOG_DEBUG, "16 bit RGB565\n"); input_pixfmt = PIX_FMT_RGB565; } else if (image->red_mask == 0x7c00 && image->green_mask == 0x03e0 && image->blue_mask == 0x001f ) { av_log(s1, AV_LOG_DEBUG, "16 bit RGB555\n"); input_pixfmt = PIX_FMT_RGB555; } else { av_log(s1, AV_LOG_ERROR, "RGB ordering at image depth %i not supported ... aborting\n", image->bits_per_pixel); av_log(s1, AV_LOG_ERROR, "color masks: r 0x%.6lx g 0x%.6lx b 0x%.6lx\n", image->red_mask, image->green_mask, image->blue_mask); ret = AVERROR(EIO); goto out; } break; case 24: if ( image->red_mask == 0xff0000 && image->green_mask == 0x00ff00 && image->blue_mask == 0x0000ff ) { input_pixfmt = PIX_FMT_BGR24; } else if ( image->red_mask == 0x0000ff && image->green_mask == 0x00ff00 && image->blue_mask == 0xff0000 ) { input_pixfmt = PIX_FMT_RGB24; } else { av_log(s1, AV_LOG_ERROR,"rgb ordering at image depth %i not supported ... aborting\n", image->bits_per_pixel); av_log(s1, AV_LOG_ERROR, "color masks: r 0x%.6lx g 0x%.6lx b 0x%.6lx\n", image->red_mask, image->green_mask, image->blue_mask); ret = AVERROR(EIO); goto out; } break; case 32: input_pixfmt = PIX_FMT_RGB32; break; default: av_log(s1, AV_LOG_ERROR, "image depth %i not supported ... aborting\n", image->bits_per_pixel); ret = AVERROR(EINVAL); goto out; } x11grab->frame_size = x11grab->width * x11grab->height * image->bits_per_pixel/8; x11grab->dpy = dpy; x11grab->time_base = (AVRational){framerate.den, framerate.num}; x11grab->time_frame = av_gettime() / av_q2d(x11grab->time_base); x11grab->x_off = x_off; x11grab->y_off = y_off; x11grab->image = image; x11grab->use_shm = use_shm; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->width = x11grab->width; st->codec->height = x11grab->height; st->codec->pix_fmt = input_pixfmt; st->codec->time_base = x11grab->time_base; st->codec->bit_rate = x11grab->frame_size * 1/av_q2d(x11grab->time_base) * 8; out: return ret; }
1threat
Using Visual Studio 2010, trying to link a database to the desgin. But it shows error : When I try to connect them. It shows error: The database is version 782, VS 2010 supports version 655 and below. What should I do in such situation please guide me. I'm mentally frustrated coz of this!
0debug
Is decimal quadruple precision? : <p>Float is 32 bits and is single precision (floating point format). Double is 64 bits and is double precision (floating point format). Decimal is 128 bits, but is it quadruple precision (floating point format)?</p>
0debug
iOS 10 barTintColor animation : <p>I've noticed a change in the way bar tint color animates in ios 10. I've created a sample project outlining the change: <a href="https://github.com/johnryan/ios10BarTintDemo" rel="noreferrer">Github: ios10BarTintDemo</a></p> <p>Basically on ios 9 the barTintColor animates smoothly using <code>[UIViewControllerTransitionCoordinator animateAlongsideTransition]</code></p> <p>but on ios 10 the animations are much less smooth and when popping a view controller doesn't animate at all, I've tried adding <code>[self.navigationController.navigationBar layoutIfNeeded]</code> as mentioned in some similar answers but this doesn't seem to have any effect when pushing/popping controllers.</p>
0debug
How to use "find View by id " in non activity class below is my code snippet. Error message "cant resolve method find View by id" : public class Broadcast extends Receiver { @Override protected void Name(Context context) { //................. } @Override public void onButton(Context context, boolean isClick) { if(isClick) { ImageView blueImage = (ImageView) findViewById(R.id.imageView); .......and so on
0debug
static inline void xan_wc3_copy_pixel_run(XanContext *s, AVFrame *frame, int x, int y, int pixel_count, int motion_x, int motion_y) { int stride; int line_inc; int curframe_index, prevframe_index; int curframe_x, prevframe_x; int width = s->avctx->width; uint8_t *palette_plane, *prev_palette_plane; if (y + motion_y < 0 || y + motion_y >= s->avctx->height || x + motion_x < 0 || x + motion_x >= s->avctx->width) return; palette_plane = frame->data[0]; prev_palette_plane = s->last_frame->data[0]; if (!prev_palette_plane) prev_palette_plane = palette_plane; stride = frame->linesize[0]; line_inc = stride - width; curframe_index = y * stride + x; curframe_x = x; prevframe_index = (y + motion_y) * stride + x + motion_x; prevframe_x = x + motion_x; if (prev_palette_plane == palette_plane && FFABS(curframe_index - prevframe_index) < pixel_count) { avpriv_request_sample(s->avctx, "Overlapping copy"); return ; } while (pixel_count && curframe_index < s->frame_size && prevframe_index < s->frame_size) { int count = FFMIN3(pixel_count, width - curframe_x, width - prevframe_x); memcpy(palette_plane + curframe_index, prev_palette_plane + prevframe_index, count); pixel_count -= count; curframe_index += count; prevframe_index += count; curframe_x += count; prevframe_x += count; if (curframe_x >= width) { curframe_index += line_inc; curframe_x = 0; } if (prevframe_x >= width) { prevframe_index += line_inc; prevframe_x = 0; } } }
1threat
Why does console.log("hello") inside console return undefined? : <p>Out of curiosity, why does writing <code>console.log("hello")</code> inside console return undefined?</p> <p>Is it for the same reasons in defining void function in C?</p> <p><a href="https://i.stack.imgur.com/uonpR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uonpR.png" alt="enter image description here"></a></p>
0debug
install not complete mongodb on windows 7 64 bit : <p>when install mongo database on windows 7 is not complete instillation</p> <p><a href="https://i.stack.imgur.com/kUGAp.png" rel="noreferrer">image of the problem</a></p> <p>how to solve this problem </p>
0debug
Why does C# implement anonymous methods and closures as instance methods, rather than as static methods? : <p>As I'm not exactly an expert on programming languages I'm well aware this may be a stupid question, but as best as I can tell C# handles anonymous methods and closures by making them into instance methods of an anonymous nested class [1], instantiating this class, and then pointing delegates at those instance methods.</p> <p>It appears that this anonymous class can only ever be instantiated once (or am I wrong about that?), so why not have the anonymous class be static instead?</p> <hr> <p>[1] Actually, it looks like there's one class for closures and one for anonymous methods that don't capture any variables, which I don't entirely understand the rationale for either.</p>
0debug
Please help me write the outcome of is statement to a python file : I have a rather stupid question to ask, but I have, can someone explain to me what I am doing wrong ? I have two files: file1 looks like this NOP7 305 CDC24 78 SSA1 41 NOP7 334 LCB5 94 FUS3 183 file2 looks like this SSA1 550 S HSP70 1YUW FUS3 181 Y Pkinase 1QMZ FUS3 179 T Pkinase 1QMZ CDC28 18 Y Pkinase 1QMZ And I'm using the following code-lit to get proteins-names that match in lists from other files file = open('file1') for line in file1: line=line.strip().split() with open('file2') as file2: for l in out: l=l.strip().split() if line[0]==l[0]: take=line[0] with open('file3', 'w') as file3: file3.write("{}".format(take)) what I get a file with one protein name only CDC28 And what I want is all the proteins that matches, eg SSA1 CDC28 FUS3 Please guide ...... ?? PS: when I print the result I get the required values (protein names) printed but can not able to write to a file.
0debug
This iPhone 6 is running iOS 12.3.1 (16F203), which may not be supported by this version of Xcode : <p>Xcode updated to the latest version 10.2 recently and so did the iOS to 12.3.1. My Mac is an older mac that's working on High Sierra and I cannot update to Mojave. I have Xcode 10.1. How do I add the supporting files and where can I find them? Any help would be appriciated. Thank you</p> <p>I have tried copying the files from a folder with 12.2 and restarting Xcode but to no luck</p>
0debug
Azure storage account: general purpose vs blob storage : <p>Having the need to store and access blobs which type of storage account is the most appropriate? Both types (general purpose and blob storage) seem to support blobs and in addition to this general purpose accounts allow selecting default or premium performance while blob storage accounts allow only default performance but on the other hand they also allow selecting the access tier (cool or hot).</p> <p>In the end I find unclear what would be the best option.</p>
0debug
How to add period to only TIME (02:00:00) in PHP : <p>I want to add a specific period like 2 hours to only time. <br /> BUT only TIME. There will be no date related issue.</p> <p>Like my time is 02:00:00 <br /> And I want to add 1 hour to this time. <br /> So, the result will be 03:00:00 <br /></p> <p>Is there any PHP built-in function like strtotime()? <br /> I don't want explode related function for this like explode(":", $time)</p> <p>Is it possible? Please help someone.</p>
0debug
Is `using Base::operator T` allowed where `T` is a template type parameter? : <p>Consider this example:</p> <pre><code>struct B { operator int(); }; template&lt;class T&gt; struct X:B { using B::operator T; }; </code></pre> <p><a href="http://coliru.stacked-crooked.com/a/2602ae50955f3977">GCC</a> accepts the code, while <a href="http://coliru.stacked-crooked.com/a/39685d409341de73">Clang</a> and MSVC rejects it. Which is correct?</p> <p>Note that if the base type is dependent, all the compilers accept the code:</p> <pre><code>template&lt;class T&gt; struct B { operator T(); }; template&lt;class T&gt; struct X:B&lt;T&gt; { using B&lt;T&gt;::operator T; }; </code></pre>
0debug
static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff){ MpegEncContext * const s = &h->s; static const int coeff_token_table_index[17]= {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}; int level[16]; int zeros_left, coeff_token, total_coeff, i, trailing_ones, run_before; if(max_coeff <= 8){ if (max_coeff == 4) coeff_token = get_vlc2(gb, chroma_dc_coeff_token_vlc.table, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 1); else coeff_token = get_vlc2(gb, chroma422_dc_coeff_token_vlc.table, CHROMA422_DC_COEFF_TOKEN_VLC_BITS, 1); total_coeff= coeff_token>>2; }else{ if(n >= LUMA_DC_BLOCK_INDEX){ total_coeff= pred_non_zero_count(h, (n - LUMA_DC_BLOCK_INDEX)*16); coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2); total_coeff= coeff_token>>2; }else{ total_coeff= pred_non_zero_count(h, n); coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2); total_coeff= coeff_token>>2; } } h->non_zero_count_cache[ scan8[n] ]= total_coeff; if(total_coeff==0) return 0; if(total_coeff > (unsigned)max_coeff) { av_log(h->s.avctx, AV_LOG_ERROR, "corrupted macroblock %d %d (total_coeff=%d)\n", s->mb_x, s->mb_y, total_coeff); return -1; } trailing_ones= coeff_token&3; tprintf(h->s.avctx, "trailing:%d, total:%d\n", trailing_ones, total_coeff); assert(total_coeff<=16); i = show_bits(gb, 3); skip_bits(gb, trailing_ones); level[0] = 1-((i&4)>>1); level[1] = 1-((i&2) ); level[2] = 1-((i&1)<<1); if(trailing_ones<total_coeff) { int mask, prefix; int suffix_length = total_coeff > 10 & trailing_ones < 3; int bitsi= show_bits(gb, LEVEL_TAB_BITS); int level_code= cavlc_level_tab[suffix_length][bitsi][0]; skip_bits(gb, cavlc_level_tab[suffix_length][bitsi][1]); if(level_code >= 100){ prefix= level_code - 100; if(prefix == LEVEL_TAB_BITS) prefix += get_level_prefix(gb); if(prefix<14){ if(suffix_length) level_code= (prefix<<1) + get_bits1(gb); else level_code= prefix; }else if(prefix==14){ if(suffix_length) level_code= (prefix<<1) + get_bits1(gb); else level_code= prefix + get_bits(gb, 4); }else{ level_code= 30 + get_bits(gb, prefix-3); if(prefix>=16){ if(prefix > 25+3){ av_log(h->s.avctx, AV_LOG_ERROR, "Invalid level prefix\n"); return -1; } level_code += (1<<(prefix-3))-4096; } } if(trailing_ones < 3) level_code += 2; suffix_length = 2; mask= -(level_code&1); level[trailing_ones]= (((2+level_code)>>1) ^ mask) - mask; }else{ level_code += ((level_code>>31)|1) & -(trailing_ones < 3); suffix_length = 1 + (level_code + 3U > 6U); level[trailing_ones]= level_code; } for(i=trailing_ones+1;i<total_coeff;i++) { static const unsigned int suffix_limit[7] = {0,3,6,12,24,48,INT_MAX }; int bitsi= show_bits(gb, LEVEL_TAB_BITS); level_code= cavlc_level_tab[suffix_length][bitsi][0]; skip_bits(gb, cavlc_level_tab[suffix_length][bitsi][1]); if(level_code >= 100){ prefix= level_code - 100; if(prefix == LEVEL_TAB_BITS){ prefix += get_level_prefix(gb); } if(prefix<15){ level_code = (prefix<<suffix_length) + get_bits(gb, suffix_length); }else{ level_code = (15<<suffix_length) + get_bits(gb, prefix-3); if(prefix>=16) level_code += (1<<(prefix-3))-4096; } mask= -(level_code&1); level_code= (((2+level_code)>>1) ^ mask) - mask; } level[i]= level_code; suffix_length+= suffix_limit[suffix_length] + level_code > 2U*suffix_limit[suffix_length]; } } if(total_coeff == max_coeff) zeros_left=0; else{ if (max_coeff <= 8) { if (max_coeff == 4) zeros_left = get_vlc2(gb, chroma_dc_total_zeros_vlc[total_coeff - 1].table, CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1); else zeros_left = get_vlc2(gb, chroma422_dc_total_zeros_vlc[total_coeff - 1].table, CHROMA422_DC_TOTAL_ZEROS_VLC_BITS, 1); } else { zeros_left= get_vlc2(gb, total_zeros_vlc[total_coeff - 1].table, TOTAL_ZEROS_VLC_BITS, 1); } } #define STORE_BLOCK(type) \ scantable += zeros_left + total_coeff - 1; \ if(n >= LUMA_DC_BLOCK_INDEX){ \ ((type*)block)[*scantable] = level[0]; \ for(i=1;i<total_coeff && zeros_left > 0;i++) { \ if(zeros_left < 7) \ run_before= get_vlc2(gb, run_vlc[zeros_left - 1].table, RUN_VLC_BITS, 1); \ else \ run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2); \ zeros_left -= run_before; \ scantable -= 1 + run_before; \ ((type*)block)[*scantable]= level[i]; \ } \ for(;i<total_coeff;i++) { \ scantable--; \ ((type*)block)[*scantable]= level[i]; \ } \ }else{ \ ((type*)block)[*scantable] = ((int)(level[0] * qmul[*scantable] + 32))>>6; \ for(i=1;i<total_coeff && zeros_left > 0;i++) { \ if(zeros_left < 7) \ run_before= get_vlc2(gb, run_vlc[zeros_left - 1].table, RUN_VLC_BITS, 1); \ else \ run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2); \ zeros_left -= run_before; \ scantable -= 1 + run_before; \ ((type*)block)[*scantable]= ((int)(level[i] * qmul[*scantable] + 32))>>6; \ } \ for(;i<total_coeff;i++) { \ scantable--; \ ((type*)block)[*scantable]= ((int)(level[i] * qmul[*scantable] + 32))>>6; \ } \ } if (h->pixel_shift) { STORE_BLOCK(int32_t) } else { STORE_BLOCK(int16_t) } if(zeros_left<0){ av_log(h->s.avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y); return -1; } return 0; }
1threat
unrecognized selector sent to instance in objective c : I have the following code lazy private var _containerView: UIView = { let view = UIView(frame: self.view.frame) let tapGesture = UITapGestureRecognizer( target: self, action: Selector(("didtapContainerView:")) ) view.translatesAutoresizingMaskIntoConstraints = false view.backgroundColor = UIColor(white: 0.0, alpha: 0) view.addGestureRecognizer(tapGesture) tapGesture.delegate = self return view }() and this is the method @objc final func didtapContainerView(gesture: UITapGestureRecognizer) { setDrawerState(state: .Closed, animated: true) } and I am getting this error Forsa.KYDrawerController didtapContainerView]: unrecognized selector sent to instance
0debug
I want to show Native_Ads_view In XML file in android studio but it give me error? : hope you will be all fine basically my problem is that when i add native_ads_view in XML file it give me error ("Required XML_attribute "adSize" was missing"). i am stuck here i search alot but failed.I hope you guys give me better a response i am waiting for your answer. XML FILE ``` <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" xmlns:ads="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#72B2D1" tools:context=".SplashScreen"> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginTop="10dp" app:adSize="BANNER" app:adUnitId="ca-app-pub-3940256099942544/6300978111" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> </com.google.android.gms.ads.AdView> <com.google.android.gms.ads.NativeExpressAdView android:id="@+id/sndNativeAds" ads:adUnitId="ca-app-pub-3940256099942544/2247696110" android:layout_width="match_parent" android:layout_height="wrap_content" ads:adSize="300x200" app:layout_constraintBottom_toTopOf="@+id/btn_move" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/adView"> </com.google.android.gms.ads.NativeExpressAdView> <Button android:id="@+id/btn_move" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:text="Move To Next" android:textSize="20sp" android:background="#000000" android:textColor="#fff" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> Error ``` Required XML_attribute "adSize" was missing
0debug
Python web scraping using 're' : I'm running into a wall why this code does not work, even thought it's the same code as on an online tutorial [Python Web Scraping Tutorial 5 (Network Requests)][1]. I tried running the code also via online Python interpreter. import urllib import re htmltext = urllib.urlopen("https://www.google.com/finance?q=AAPL") regex = '<span id="ref_[^.]*_l">(.+?)</span>' pattern = re.compile(regex) results = re.findall(pattern,htmltext) results I get: re.pyc in findall(pattern, string, flags) 175 176 Empty matches are included in the result.""" --> 177 return _compile(pattern, flags).findall(string) 178 179 if sys.hexversion >= 0x02020000: TypeError: expected string or buffer Expected result(s): 112.71 Help appreciated. I tried using "read()" on the url but that didn't work. According to documentation even empty results should be included. Thanks [1]: http://www.youtube.com/watch?v=5FoSwMZ4uJg&t=6m22s
0debug
which version of eclipse for android development is light and stable? : <p>I have started android development recently and i'm working on eclipse but it is very slow, i think because of it's heavy appearance. Please suggest me a good version which is totally light, it may lack in appearance but performance must be good.</p>
0debug
Controller under a controller: Laravel 5.5 : <p>I have two controllers:</p> <pre><code>AdminController ProductController </code></pre> <p><code>AdminController</code> has some functions:</p> <pre><code>index create etc </code></pre> <p><code>ProductController</code> also has some functions:</p> <pre><code> index create etc </code></pre> <p>In <code>admin dashboard</code> there is a button <code>Product</code>. When I will click it it will call ProductController index page.</p> <p>Then in Product button subsection create, edit, delete etc will be available. at last my url will be: <code>admin/product/create</code></p> <p>How is this possible? Give me idea.</p>
0debug
static void gen_mttr(CPUMIPSState *env, DisasContext *ctx, int rd, int rt, int u, int sel, int h) { int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC); TCGv t0 = tcg_temp_local_new(); gen_load_gpr(t0, rt); if ((env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) == 0 && ((env->tcs[other_tc].CP0_TCBind & (0xf << CP0TCBd_CurVPE)) != (env->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE)))) ; else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) > (env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC))) ; else if (u == 0) { switch (rd) { case 1: switch (sel) { case 1: gen_helper_mttc0_vpecontrol(cpu_env, t0); break; case 2: gen_helper_mttc0_vpeconf0(cpu_env, t0); break; default: goto die; break; } break; case 2: switch (sel) { case 1: gen_helper_mttc0_tcstatus(cpu_env, t0); break; case 2: gen_helper_mttc0_tcbind(cpu_env, t0); break; case 3: gen_helper_mttc0_tcrestart(cpu_env, t0); break; case 4: gen_helper_mttc0_tchalt(cpu_env, t0); break; case 5: gen_helper_mttc0_tccontext(cpu_env, t0); break; case 6: gen_helper_mttc0_tcschedule(cpu_env, t0); break; case 7: gen_helper_mttc0_tcschefback(cpu_env, t0); break; default: gen_mtc0(ctx, t0, rd, sel); break; } break; case 10: switch (sel) { case 0: gen_helper_mttc0_entryhi(cpu_env, t0); break; default: gen_mtc0(ctx, t0, rd, sel); break; } case 12: switch (sel) { case 0: gen_helper_mttc0_status(cpu_env, t0); break; default: gen_mtc0(ctx, t0, rd, sel); break; } case 13: switch (sel) { case 0: gen_helper_mttc0_cause(cpu_env, t0); break; default: goto die; break; } break; case 15: switch (sel) { case 1: gen_helper_mttc0_ebase(cpu_env, t0); break; default: goto die; break; } break; case 23: switch (sel) { case 0: gen_helper_mttc0_debug(cpu_env, t0); break; default: gen_mtc0(ctx, t0, rd, sel); break; } break; default: gen_mtc0(ctx, t0, rd, sel); } } else switch (sel) { case 0: gen_helper_0e1i(mttgpr, t0, rd); break; case 1: switch (rd) { case 0: gen_helper_0e1i(mttlo, t0, 0); break; case 1: gen_helper_0e1i(mtthi, t0, 0); break; case 2: gen_helper_0e1i(mttacx, t0, 0); break; case 4: gen_helper_0e1i(mttlo, t0, 1); break; case 5: gen_helper_0e1i(mtthi, t0, 1); break; case 6: gen_helper_0e1i(mttacx, t0, 1); break; case 8: gen_helper_0e1i(mttlo, t0, 2); break; case 9: gen_helper_0e1i(mtthi, t0, 2); break; case 10: gen_helper_0e1i(mttacx, t0, 2); break; case 12: gen_helper_0e1i(mttlo, t0, 3); break; case 13: gen_helper_0e1i(mtthi, t0, 3); break; case 14: gen_helper_0e1i(mttacx, t0, 3); break; case 16: gen_helper_mttdsp(cpu_env, t0); break; default: goto die; } break; case 2: if (h == 0) { TCGv_i32 fp0 = tcg_temp_new_i32(); tcg_gen_trunc_tl_i32(fp0, t0); gen_store_fpr32(fp0, rd); tcg_temp_free_i32(fp0); } else { TCGv_i32 fp0 = tcg_temp_new_i32(); tcg_gen_trunc_tl_i32(fp0, t0); gen_store_fpr32h(fp0, rd); tcg_temp_free_i32(fp0); } break; case 3: { TCGv_i32 fs_tmp = tcg_const_i32(rd); gen_helper_0e2i(ctc1, t0, fs_tmp, rt); tcg_temp_free_i32(fs_tmp); } break; case 4: case 5: default: goto die; } LOG_DISAS("mttr (reg %d u %d sel %d h %d)\n", rd, u, sel, h); tcg_temp_free(t0); return; die: tcg_temp_free(t0); LOG_DISAS("mttr (reg %d u %d sel %d h %d)\n", rd, u, sel, h); generate_exception(ctx, EXCP_RI); }
1threat
MVC model is null in controller during HTTP Post ASP.NET : <p>When I post data via submit, I see that model is null in controller. I already see that this question is asked many times, and the root cause is the name conflict between model property name and the same name we use in action parameter of controller. But this is not the case in my scenario. Not sure why the model is null. Any help is appreciated. In the below code, "pm" variable is null.</p> <p>View:</p> <pre><code>&lt;div&gt; @Html.LabelFor(model =&gt;model.procedureName)&lt;/div&gt; &lt;div&gt; @Html.ValidationMessageFor(model =&gt; model.procedureName)&lt;/div&gt; &lt;div&gt;@Html.TextBoxFor(model =&gt; model.procedureName)&lt;/div&gt; &lt;div&gt; @Html.ValidationMessageFor(model =&gt; model.ServiceDate)&lt;/div&gt; &lt;div&gt; @Html.TextBoxFor(model =&gt;model.ServiceDate) &lt;/div&gt; &lt;div&gt; @using (Html.BeginForm()) { &lt;input type="submit" value="Save Procedure" id="btnPost" /&gt; } &lt;/div&gt; </code></pre> <p>Model:</p> <pre><code>public partial class MemberProcedure { public int procedureid { get; set; } [Display(Name = "Name")] [Required(ErrorMessage = "Please select a name")] public string procedureName { get; set; } public string updatedbyUserName { get; set; } public Nullable&lt;System.DateTime&gt; LastUpdatetime { get; set; } public Nullable&lt;System.DateTime&gt; Createtime { get; set; } [Required(ErrorMessage = "Please select a service date")] public Nullable&lt;System.DateTime&gt; ServiceDate { get; set; } } </code></pre> <p>Controller action method:</p> <pre><code>[HttpPost] public ActionResult Procedure(MemberProcedure pm) { if (ModelState.IsValid) { savedata.... } return View(pm); } </code></pre> <p>HTML:</p> <pre><code>&lt;input id="procedureName" name="procedureName" type="text" value=""&gt; &lt;input id="ServiceDate" name="ServiceDate" type="text" value=""&gt; </code></pre>
0debug
How to get first char of string in python? : <p>I want to enter a word from keyboard, put it in a string variable and return first and last letter from the word. But I don't know to to do this.</p> <pre><code>input: "Hello" output: "H", "o" </code></pre> <p>P.S: I want to put this 2 letters in a variable:</p> <pre><code>print(first) output:"H" print(last) output:"o" </code></pre> <p>Please give me a solution!</p>
0debug
Image in circle not working in iphone 5 (the circle is not accurate) : In my iphone 7 simulator, my image is an exact circle. For some reason my image in iphone 5 becomes a little squarish. This is the code that I have to make the image a circle: private func setImage(){ self.profileImage.layer.borderWidth = 0.0; self.profileImage.layer.cornerRadius = self.profileImage.frame.size.height/2; self.profileImage.clipsToBounds = true } And I add an image to show the problem in the result in iphone 5. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/C8r4S.png
0debug
How to check bad word in string or not using php? : This is my php code for replace bad word in string to *, it's work good. But i want to check in string have bad word or not. How can i do ? index.php <?php include("badwords.php"); $content = "cat fuck dog"; $badword = new badword(); echo $badword->word_fliter("$content"); ?> badword.php <?php $bad_words = array ( "asshole", "ass", "bitch", "bastard", "cunt", "dick", "dike", "dildo", "fuck", "gay", "hoe", "nigger", "pussy", "slut", "whore", "god damn", "goddamn" ); class badword { function word_fliter($content) { global $bad_words, $wordreplace; $count = count($bad_words); for ($n = 0; $n < $count; ++$n, next ($bad_words)) { $filter = "*"; //Search for bad_words in content $search = "$bad_words[$n]"; $content = preg_replace("'$search'i","<i>$filter</i>",$content); } return $content; } } ?> ............................................................................................................................................................
0debug
static int bmp_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; BMPContext *s = avctx->priv_data; AVFrame *picture = data; AVFrame *p = &s->picture; unsigned int fsize, hsize; int width, height; unsigned int depth; BiCompression comp; unsigned int ihsize; int i, j, n, linesize; uint32_t rgb[3]; uint8_t *ptr; int dsize; const uint8_t *buf0 = buf; if(buf_size < 14){ av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size); return -1; } if(bytestream_get_byte(&buf) != 'B' || bytestream_get_byte(&buf) != 'M') { av_log(avctx, AV_LOG_ERROR, "bad magic number\n"); return -1; } fsize = bytestream_get_le32(&buf); if(buf_size < fsize){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d), trying to decode anyway\n", buf_size, fsize); fsize = buf_size; } buf += 2; buf += 2; hsize = bytestream_get_le32(&buf); ihsize = bytestream_get_le32(&buf); if(ihsize + 14 > hsize){ av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize); return -1; } if(fsize == 14 || fsize == ihsize + 14) fsize = buf_size - 2; if(fsize <= hsize){ av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n", fsize, hsize); return -1; } switch(ihsize){ case 40: case 64: case 108: case 124: width = bytestream_get_le32(&buf); height = bytestream_get_le32(&buf); break; case 12: width = bytestream_get_le16(&buf); height = bytestream_get_le16(&buf); break; default: av_log(avctx, AV_LOG_ERROR, "unsupported BMP file, patch welcome\n"); return -1; } if(bytestream_get_le16(&buf) != 1){ av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n"); return -1; } depth = bytestream_get_le16(&buf); if(ihsize == 40) comp = bytestream_get_le32(&buf); else comp = BMP_RGB; if(comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp); return -1; } if(comp == BMP_BITFIELDS){ buf += 20; rgb[0] = bytestream_get_le32(&buf); rgb[1] = bytestream_get_le32(&buf); rgb[2] = bytestream_get_le32(&buf); } avctx->width = width; avctx->height = height > 0? height: -height; avctx->pix_fmt = PIX_FMT_NONE; switch(depth){ case 32: if(comp == BMP_BITFIELDS){ rgb[0] = (rgb[0] >> 15) & 3; rgb[1] = (rgb[1] >> 15) & 3; rgb[2] = (rgb[2] >> 15) & 3; if(rgb[0] + rgb[1] + rgb[2] != 3 || rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){ break; } } else { rgb[0] = 2; rgb[1] = 1; rgb[2] = 0; } avctx->pix_fmt = PIX_FMT_BGR24; break; case 24: avctx->pix_fmt = PIX_FMT_BGR24; break; case 16: if(comp == BMP_RGB) avctx->pix_fmt = PIX_FMT_RGB555; if(comp == BMP_BITFIELDS) avctx->pix_fmt = rgb[1] == 0x07E0 ? PIX_FMT_RGB565 : PIX_FMT_RGB555; break; case 8: if(hsize - ihsize - 14 > 0) avctx->pix_fmt = PIX_FMT_PAL8; else avctx->pix_fmt = PIX_FMT_GRAY8; break; case 1: case 4: if(hsize - ihsize - 14 > 0){ avctx->pix_fmt = PIX_FMT_PAL8; }else{ av_log(avctx, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\n", 1<<depth); return -1; } break; default: av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth); return -1; } if(avctx->pix_fmt == PIX_FMT_NONE){ av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n"); return -1; } if(p->data[0]) avctx->release_buffer(avctx, p); p->reference = 0; if(avctx->get_buffer(avctx, p) < 0){ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; buf = buf0 + hsize; dsize = buf_size - hsize; n = ((avctx->width * depth) / 8 + 3) & ~3; if(n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", dsize, n * avctx->height); return -1; } if(comp == BMP_RLE4 || comp == BMP_RLE8) memset(p->data[0], 0, avctx->height * p->linesize[0]); if(depth == 4 || depth == 8) memset(p->data[1], 0, 1024); if(height > 0){ ptr = p->data[0] + (avctx->height - 1) * p->linesize[0]; linesize = -p->linesize[0]; } else { ptr = p->data[0]; linesize = p->linesize[0]; } if(avctx->pix_fmt == PIX_FMT_PAL8){ int colors = 1 << depth; if(ihsize >= 36){ int t; buf = buf0 + 46; t = bytestream_get_le32(&buf); if(t < 0 || t > (1 << depth)){ av_log(avctx, AV_LOG_ERROR, "Incorrect number of colors - %X for bitdepth %d\n", t, depth); }else if(t){ colors = t; } } buf = buf0 + 14 + ihsize; if((hsize-ihsize-14) < (colors << 2)){ for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = bytestream_get_le24(&buf); }else{ for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = bytestream_get_le32(&buf); } buf = buf0 + hsize; } if(comp == BMP_RLE4 || comp == BMP_RLE8){ if(height < 0){ p->data[0] += p->linesize[0] * (avctx->height - 1); p->linesize[0] = -p->linesize[0]; } ff_msrle_decode(avctx, (AVPicture*)p, depth, buf, dsize); if(height < 0){ p->data[0] += p->linesize[0] * (avctx->height - 1); p->linesize[0] = -p->linesize[0]; } }else{ switch(depth){ case 1: for (i = 0; i < avctx->height; i++) { int j; for (j = 0; j < n; j++) { ptr[j*8+0] = buf[j] >> 7; ptr[j*8+1] = (buf[j] >> 6) & 1; ptr[j*8+2] = (buf[j] >> 5) & 1; ptr[j*8+3] = (buf[j] >> 4) & 1; ptr[j*8+4] = (buf[j] >> 3) & 1; ptr[j*8+5] = (buf[j] >> 2) & 1; ptr[j*8+6] = (buf[j] >> 1) & 1; ptr[j*8+7] = buf[j] & 1; } buf += n; ptr += linesize; } break; case 8: case 24: for(i = 0; i < avctx->height; i++){ memcpy(ptr, buf, n); buf += n; ptr += linesize; } break; case 4: for(i = 0; i < avctx->height; i++){ int j; for(j = 0; j < n; j++){ ptr[j*2+0] = (buf[j] >> 4) & 0xF; ptr[j*2+1] = buf[j] & 0xF; } buf += n; ptr += linesize; } break; case 16: for(i = 0; i < avctx->height; i++){ const uint16_t *src = (const uint16_t *) buf; uint16_t *dst = (uint16_t *) ptr; for(j = 0; j < avctx->width; j++) *dst++ = av_le2ne16(*src++); buf += n; ptr += linesize; } break; case 32: for(i = 0; i < avctx->height; i++){ const uint8_t *src = buf; uint8_t *dst = ptr; for(j = 0; j < avctx->width; j++){ dst[0] = src[rgb[2]]; dst[1] = src[rgb[1]]; dst[2] = src[rgb[0]]; dst += 3; src += 4; } buf += n; ptr += linesize; } break; default: av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n"); return -1; } } *picture = s->picture; *data_size = sizeof(AVPicture); return buf_size; }
1threat
how to store text field of toast into SQLite database : i have been writing this code for getting location.how to store "mg" in SQLite database of android public void onLocationChanged(Location location) { String mg = " Latitude:" + location.getLatitude() + " Longitude:" + location.getLatitude(); Toast.makeText(getBaseContext(),mg, Toast.LENGTH_LONG).show();
0debug
Match everything between characters in Regex? : <p>I am trying to match everything between</p> <blockquote> <p>/* <strong><em>and</em></strong> */</p> </blockquote> <p>And also include the in between characters.</p> <p>I currently managed to create a pattern that kind of does this</p> <pre><code>\/\*(.+?)\*\/ </code></pre> <p><a href="https://regex101.com/r/2MBabj/1" rel="nofollow noreferrer">Regex Tester</a></p> <p>But it doesn't match multi line quotes and only matches once.</p> <p><a href="https://i.stack.imgur.com/6vl50.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6vl50.png" alt="enter image description here"></a></p> <p>How can I improve this pattern to match everything that starts with /* and ends with */ ?</p>
0debug
int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) { CPUS390XState *env = &cpu->env; uint64_t offset, data; S390PCIBusDevice *pbdev; uint8_t len; uint32_t fh; uint8_t pcias; cpu_synchronize_state(CPU(cpu)); if (env->psw.mask & PSW_MASK_PSTATE) { program_interrupt(env, PGM_PRIVILEGED, 4); return 0; } if (r2 & 0x1) { program_interrupt(env, PGM_SPECIFICATION, 4); return 0; } fh = env->regs[r2] >> 32; pcias = (env->regs[r2] >> 16) & 0xf; len = env->regs[r2] & 0xf; offset = env->regs[r2 + 1]; pbdev = s390_pci_find_dev_by_fh(fh); if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) { DPRINTF("pcistg no pci dev\n"); setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE); return 0; } if (pbdev->lgstg_blocked) { setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r2, ZPCI_PCI_ST_BLOCKED); return 0; } data = env->regs[r1]; if (pcias < 6) { if ((8 - (offset & 0x7)) < len) { program_interrupt(env, PGM_OPERAND, 4); return 0; } MemoryRegion *mr; if (trap_msix(pbdev, offset, pcias)) { offset = offset - pbdev->msix.table_offset; mr = &pbdev->pdev->msix_table_mmio; update_msix_table_msg_data(pbdev, offset, &data, len); } else { mr = pbdev->pdev->io_regions[pcias].memory; } memory_region_dispatch_write(mr, offset, data, len, MEMTXATTRS_UNSPECIFIED); } else if (pcias == 15) { if ((4 - (offset & 0x3)) < len) { program_interrupt(env, PGM_OPERAND, 4); return 0; } switch (len) { case 1: break; case 2: data = bswap16(data); break; case 4: data = bswap32(data); break; case 8: data = bswap64(data); break; default: program_interrupt(env, PGM_OPERAND, 4); return 0; } pci_host_config_write_common(pbdev->pdev, offset, pci_config_size(pbdev->pdev), data, len); } else { DPRINTF("pcistg invalid space\n"); setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS); return 0; } setcc(cpu, ZPCI_PCI_LS_OK); return 0; }
1threat
How to get the ip address of a windows 7/8/8.1/10 phone programmatically : <p>i am new to this community &amp; windows phone app development. I need to get the ip address of the network (wifi and mobile) to which the device is connected pro-grammatically on a windows phone app (C#). windows version 7/8/8.1/10 is required.</p>
0debug
static void test_qemu_strtoul_max(void) { char *str = g_strdup_printf("%lu", ULONG_MAX); char f = 'X'; const char *endptr = &f; unsigned long res = 999; int err; err = qemu_strtoul(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, ULONG_MAX); g_assert(endptr == str + strlen(str)); g_free(str); }
1threat
How to setup EF6 Migrations with ASP.NET Core : <p>I am trying to adopt Jimmy Bogard's <a href="https://github.com/jbogard/ContosoUniversityCore" rel="noreferrer">ContosoUniversityCore project</a></p> <p>I would like to do code first migrations, but not sure how to properly set it up. I added Migrator.EF6.Tools to my project.</p> <p>When I run Enable-Migrations I get this error:</p> <pre><code>Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\Users\SomeUser\.nuget\packages\entityframework\6.1.3\tools\EntityFramework.psm1:718 char:5 + $domain.SetData('project', $project) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SerializationException Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\Users\SomeUser\.nuget\packages\entityframework\6.1.3\tools\EntityFramework.psm1:719 char:5 + $domain.SetData('contextProject', $contextProject) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SerializationException Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\Users\SomeUser\.nuget\packages\entityframework\6.1.3\tools\EntityFramework.psm1:720 char:5 + $domain.SetData('startUpProject', $startUpProject) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SerializationException System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName) at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory) at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName) at System.Data.Entity.Migrations.EnableMigrationsCommand.&lt;&gt;c__DisplayClass2.&lt;.ctor&gt;b__0() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) Object reference not set to an instance of an object. </code></pre>
0debug
static void *colo_compare_thread(void *opaque) { CompareState *s = opaque; GSource *timeout_source; s->worker_context = g_main_context_new(); qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read, compare_pri_chr_in, NULL, NULL, s, s->worker_context, true); qemu_chr_fe_set_handlers(&s->chr_sec_in, compare_chr_can_read, compare_sec_chr_in, NULL, NULL, s, s->worker_context, true); s->compare_loop = g_main_loop_new(s->worker_context, FALSE); timeout_source = g_timeout_source_new(REGULAR_PACKET_CHECK_MS); g_source_set_callback(timeout_source, (GSourceFunc)check_old_packet_regular, s, NULL); g_source_attach(timeout_source, s->worker_context); g_main_loop_run(s->compare_loop); g_source_unref(timeout_source); g_main_loop_unref(s->compare_loop); g_main_context_unref(s->worker_context); return NULL; }
1threat
Angular 5 Breaking change - manually import locale : <p>Changelog says:</p> <blockquote> <p>By default Angular now only contains locale data for the language en-US, if you set the value of LOCALE_ID to another locale, you will have to import new locale data for this language because we don’t use the intl API anymore.</p> </blockquote> <p>But I can not find any reference what "importing" means, how to do it and I get</p> <blockquote> <p>xxx.html:30 ERROR Error: Missing locale data for the locale "de-CH"</p> </blockquote> <p>I configure locale with :</p> <pre><code>import { LOCALE_ID } from '@angular/core'; </code></pre> <p>and</p> <pre><code> providers: [ { provide: LOCALE_ID, useValue: 'de-CH' } ], </code></pre>
0debug
static void fill_caches(H264Context *h, int mb_type, int for_deblock){ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; int topleft_xy, top_xy, topright_xy, left_xy[2]; int topleft_type, top_type, topright_type, left_type[2]; int * left_block; int topleft_partition= -1; int i; top_xy = mb_xy - (s->mb_stride << FIELD_PICTURE); if(for_deblock && (h->slice_num == 1 || h->slice_table[mb_xy] == h->slice_table[top_xy]) && !FRAME_MBAFF) return; topleft_xy = top_xy - 1; topright_xy= top_xy + 1; left_xy[1] = left_xy[0] = mb_xy-1; left_block = left_block_options[0]; if(FRAME_MBAFF){ const int pair_xy = s->mb_x + (s->mb_y & ~1)*s->mb_stride; const int top_pair_xy = pair_xy - s->mb_stride; const int topleft_pair_xy = top_pair_xy - 1; const int topright_pair_xy = top_pair_xy + 1; const int topleft_mb_frame_flag = !IS_INTERLACED(s->current_picture.mb_type[topleft_pair_xy]); const int top_mb_frame_flag = !IS_INTERLACED(s->current_picture.mb_type[top_pair_xy]); const int topright_mb_frame_flag = !IS_INTERLACED(s->current_picture.mb_type[topright_pair_xy]); const int left_mb_frame_flag = !IS_INTERLACED(s->current_picture.mb_type[pair_xy-1]); const int curr_mb_frame_flag = !IS_INTERLACED(mb_type); const int bottom = (s->mb_y & 1); tprintf(s->avctx, "fill_caches: curr_mb_frame_flag:%d, left_mb_frame_flag:%d, topleft_mb_frame_flag:%d, top_mb_frame_flag:%d, topright_mb_frame_flag:%d\n", curr_mb_frame_flag, left_mb_frame_flag, topleft_mb_frame_flag, top_mb_frame_flag, topright_mb_frame_flag); if (bottom ? !curr_mb_frame_flag : (!curr_mb_frame_flag && !top_mb_frame_flag) ) { top_xy -= s->mb_stride; } if (bottom ? !curr_mb_frame_flag : (!curr_mb_frame_flag && !topleft_mb_frame_flag) ) { topleft_xy -= s->mb_stride; } else if(bottom && curr_mb_frame_flag && !left_mb_frame_flag) { topleft_xy += s->mb_stride; topleft_partition = 0; } if (bottom ? !curr_mb_frame_flag : (!curr_mb_frame_flag && !topright_mb_frame_flag) ) { topright_xy -= s->mb_stride; } if (left_mb_frame_flag != curr_mb_frame_flag) { left_xy[1] = left_xy[0] = pair_xy - 1; if (curr_mb_frame_flag) { if (bottom) { left_block = left_block_options[1]; } else { left_block= left_block_options[2]; } } else { left_xy[1] += s->mb_stride; left_block = left_block_options[3]; } } } h->top_mb_xy = top_xy; h->left_mb_xy[0] = left_xy[0]; h->left_mb_xy[1] = left_xy[1]; if(for_deblock){ topleft_type = 0; topright_type = 0; top_type = h->slice_table[top_xy ] < 255 ? s->current_picture.mb_type[top_xy] : 0; left_type[0] = h->slice_table[left_xy[0] ] < 255 ? s->current_picture.mb_type[left_xy[0]] : 0; left_type[1] = h->slice_table[left_xy[1] ] < 255 ? s->current_picture.mb_type[left_xy[1]] : 0; if(FRAME_MBAFF && !IS_INTRA(mb_type)){ int list; for(list=0; list<h->list_count; list++){ if(USES_LIST(mb_type,list)){ int8_t *ref = &s->current_picture.ref_index[list][h->mb2b8_xy[mb_xy]]; *(uint32_t*)&h->ref_cache[list][scan8[ 0]] = *(uint32_t*)&h->ref_cache[list][scan8[ 2]] = pack16to32(ref[0],ref[1])*0x0101; ref += h->b8_stride; *(uint32_t*)&h->ref_cache[list][scan8[ 8]] = *(uint32_t*)&h->ref_cache[list][scan8[10]] = pack16to32(ref[0],ref[1])*0x0101; }else{ fill_rectangle(&h-> mv_cache[list][scan8[ 0]], 4, 4, 8, 0, 4); fill_rectangle(&h->ref_cache[list][scan8[ 0]], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1); } } } }else{ topleft_type = h->slice_table[topleft_xy ] == h->slice_num ? s->current_picture.mb_type[topleft_xy] : 0; top_type = h->slice_table[top_xy ] == h->slice_num ? s->current_picture.mb_type[top_xy] : 0; topright_type= h->slice_table[topright_xy] == h->slice_num ? s->current_picture.mb_type[topright_xy]: 0; left_type[0] = h->slice_table[left_xy[0] ] == h->slice_num ? s->current_picture.mb_type[left_xy[0]] : 0; left_type[1] = h->slice_table[left_xy[1] ] == h->slice_num ? s->current_picture.mb_type[left_xy[1]] : 0; } if(IS_INTRA(mb_type)){ h->topleft_samples_available= h->top_samples_available= h->left_samples_available= 0xFFFF; h->topright_samples_available= 0xEEEA; if(!IS_INTRA(top_type) && (top_type==0 || h->pps.constrained_intra_pred)){ h->topleft_samples_available= 0xB3FF; h->top_samples_available= 0x33FF; h->topright_samples_available= 0x26EA; } for(i=0; i<2; i++){ if(!IS_INTRA(left_type[i]) && (left_type[i]==0 || h->pps.constrained_intra_pred)){ h->topleft_samples_available&= 0xDF5F; h->left_samples_available&= 0x5F5F; } } if(!IS_INTRA(topleft_type) && (topleft_type==0 || h->pps.constrained_intra_pred)) h->topleft_samples_available&= 0x7FFF; if(!IS_INTRA(topright_type) && (topright_type==0 || h->pps.constrained_intra_pred)) h->topright_samples_available&= 0xFBFF; if(IS_INTRA4x4(mb_type)){ if(IS_INTRA4x4(top_type)){ h->intra4x4_pred_mode_cache[4+8*0]= h->intra4x4_pred_mode[top_xy][4]; h->intra4x4_pred_mode_cache[5+8*0]= h->intra4x4_pred_mode[top_xy][5]; h->intra4x4_pred_mode_cache[6+8*0]= h->intra4x4_pred_mode[top_xy][6]; h->intra4x4_pred_mode_cache[7+8*0]= h->intra4x4_pred_mode[top_xy][3]; }else{ int pred; if(!top_type || (IS_INTER(top_type) && h->pps.constrained_intra_pred)) pred= -1; else{ pred= 2; } h->intra4x4_pred_mode_cache[4+8*0]= h->intra4x4_pred_mode_cache[5+8*0]= h->intra4x4_pred_mode_cache[6+8*0]= h->intra4x4_pred_mode_cache[7+8*0]= pred; } for(i=0; i<2; i++){ if(IS_INTRA4x4(left_type[i])){ h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[0+2*i]]; h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[1+2*i]]; }else{ int pred; if(!left_type[i] || (IS_INTER(left_type[i]) && h->pps.constrained_intra_pred)) pred= -1; else{ pred= 2; } h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= pred; } } } } if(top_type){ h->non_zero_count_cache[4+8*0]= h->non_zero_count[top_xy][4]; h->non_zero_count_cache[5+8*0]= h->non_zero_count[top_xy][5]; h->non_zero_count_cache[6+8*0]= h->non_zero_count[top_xy][6]; h->non_zero_count_cache[7+8*0]= h->non_zero_count[top_xy][3]; h->non_zero_count_cache[1+8*0]= h->non_zero_count[top_xy][9]; h->non_zero_count_cache[2+8*0]= h->non_zero_count[top_xy][8]; h->non_zero_count_cache[1+8*3]= h->non_zero_count[top_xy][12]; h->non_zero_count_cache[2+8*3]= h->non_zero_count[top_xy][11]; }else{ h->non_zero_count_cache[4+8*0]= h->non_zero_count_cache[5+8*0]= h->non_zero_count_cache[6+8*0]= h->non_zero_count_cache[7+8*0]= h->non_zero_count_cache[1+8*0]= h->non_zero_count_cache[2+8*0]= h->non_zero_count_cache[1+8*3]= h->non_zero_count_cache[2+8*3]= h->pps.cabac && !IS_INTRA(mb_type) ? 0 : 64; } for (i=0; i<2; i++) { if(left_type[i]){ h->non_zero_count_cache[3+8*1 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[0+2*i]]; h->non_zero_count_cache[3+8*2 + 2*8*i]= h->non_zero_count[left_xy[i]][left_block[1+2*i]]; h->non_zero_count_cache[0+8*1 + 8*i]= h->non_zero_count[left_xy[i]][left_block[4+2*i]]; h->non_zero_count_cache[0+8*4 + 8*i]= h->non_zero_count[left_xy[i]][left_block[5+2*i]]; }else{ h->non_zero_count_cache[3+8*1 + 2*8*i]= h->non_zero_count_cache[3+8*2 + 2*8*i]= h->non_zero_count_cache[0+8*1 + 8*i]= h->non_zero_count_cache[0+8*4 + 8*i]= h->pps.cabac && !IS_INTRA(mb_type) ? 0 : 64; } } if( h->pps.cabac ) { if(top_type) { h->top_cbp = h->cbp_table[top_xy]; } else if(IS_INTRA(mb_type)) { h->top_cbp = 0x1C0; } else { h->top_cbp = 0; } if (left_type[0]) { h->left_cbp = h->cbp_table[left_xy[0]] & 0x1f0; } else if(IS_INTRA(mb_type)) { h->left_cbp = 0x1C0; } else { h->left_cbp = 0; } if (left_type[0]) { h->left_cbp |= ((h->cbp_table[left_xy[0]]>>((left_block[0]&(~1))+1))&0x1) << 1; } if (left_type[1]) { h->left_cbp |= ((h->cbp_table[left_xy[1]]>>((left_block[2]&(~1))+1))&0x1) << 3; } } #if 1 if(IS_INTER(mb_type) || IS_DIRECT(mb_type)){ int list; for(list=0; list<h->list_count; list++){ if(!USES_LIST(mb_type, list) && !IS_DIRECT(mb_type) && !h->deblocking_filter){ continue; } h->mv_cache_clean[list]= 0; if(USES_LIST(top_type, list)){ const int b_xy= h->mb2b_xy[top_xy] + 3*h->b_stride; const int b8_xy= h->mb2b8_xy[top_xy] + h->b8_stride; *(uint32_t*)h->mv_cache[list][scan8[0] + 0 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 0]; *(uint32_t*)h->mv_cache[list][scan8[0] + 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 1]; *(uint32_t*)h->mv_cache[list][scan8[0] + 2 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 2]; *(uint32_t*)h->mv_cache[list][scan8[0] + 3 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 3]; h->ref_cache[list][scan8[0] + 0 - 1*8]= h->ref_cache[list][scan8[0] + 1 - 1*8]= s->current_picture.ref_index[list][b8_xy + 0]; h->ref_cache[list][scan8[0] + 2 - 1*8]= h->ref_cache[list][scan8[0] + 3 - 1*8]= s->current_picture.ref_index[list][b8_xy + 1]; }else{ *(uint32_t*)h->mv_cache [list][scan8[0] + 0 - 1*8]= *(uint32_t*)h->mv_cache [list][scan8[0] + 1 - 1*8]= *(uint32_t*)h->mv_cache [list][scan8[0] + 2 - 1*8]= *(uint32_t*)h->mv_cache [list][scan8[0] + 3 - 1*8]= 0; *(uint32_t*)&h->ref_cache[list][scan8[0] + 0 - 1*8]= ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101; } for(i=0; i<2; i++){ int cache_idx = scan8[0] - 1 + i*2*8; if(USES_LIST(left_type[i], list)){ const int b_xy= h->mb2b_xy[left_xy[i]] + 3; const int b8_xy= h->mb2b8_xy[left_xy[i]] + 1; *(uint32_t*)h->mv_cache[list][cache_idx ]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0+i*2]]; *(uint32_t*)h->mv_cache[list][cache_idx+8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[1+i*2]]; h->ref_cache[list][cache_idx ]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0+i*2]>>1)]; h->ref_cache[list][cache_idx+8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[1+i*2]>>1)]; }else{ *(uint32_t*)h->mv_cache [list][cache_idx ]= *(uint32_t*)h->mv_cache [list][cache_idx+8]= 0; h->ref_cache[list][cache_idx ]= h->ref_cache[list][cache_idx+8]= left_type[i] ? LIST_NOT_USED : PART_NOT_AVAILABLE; } } if((for_deblock || (IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)) && !FRAME_MBAFF) continue; if(USES_LIST(topleft_type, list)){ const int b_xy = h->mb2b_xy[topleft_xy] + 3 + h->b_stride + (topleft_partition & 2*h->b_stride); const int b8_xy= h->mb2b8_xy[topleft_xy] + 1 + (topleft_partition & h->b8_stride); *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy]; h->ref_cache[list][scan8[0] - 1 - 1*8]= s->current_picture.ref_index[list][b8_xy]; }else{ *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= 0; h->ref_cache[list][scan8[0] - 1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; } if(USES_LIST(topright_type, list)){ const int b_xy= h->mb2b_xy[topright_xy] + 3*h->b_stride; const int b8_xy= h->mb2b8_xy[topright_xy] + h->b8_stride; *(uint32_t*)h->mv_cache[list][scan8[0] + 4 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy]; h->ref_cache[list][scan8[0] + 4 - 1*8]= s->current_picture.ref_index[list][b8_xy]; }else{ *(uint32_t*)h->mv_cache [list][scan8[0] + 4 - 1*8]= 0; h->ref_cache[list][scan8[0] + 4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; } if((IS_SKIP(mb_type) || IS_DIRECT(mb_type)) && !FRAME_MBAFF) continue; h->ref_cache[list][scan8[5 ]+1] = h->ref_cache[list][scan8[7 ]+1] = h->ref_cache[list][scan8[13]+1] = h->ref_cache[list][scan8[4 ]] = h->ref_cache[list][scan8[12]] = PART_NOT_AVAILABLE; *(uint32_t*)h->mv_cache [list][scan8[5 ]+1]= *(uint32_t*)h->mv_cache [list][scan8[7 ]+1]= *(uint32_t*)h->mv_cache [list][scan8[13]+1]= *(uint32_t*)h->mv_cache [list][scan8[4 ]]= *(uint32_t*)h->mv_cache [list][scan8[12]]= 0; if( h->pps.cabac ) { if(USES_LIST(top_type, list)){ const int b_xy= h->mb2b_xy[top_xy] + 3*h->b_stride; *(uint32_t*)h->mvd_cache[list][scan8[0] + 0 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + 0]; *(uint32_t*)h->mvd_cache[list][scan8[0] + 1 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + 1]; *(uint32_t*)h->mvd_cache[list][scan8[0] + 2 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + 2]; *(uint32_t*)h->mvd_cache[list][scan8[0] + 3 - 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + 3]; }else{ *(uint32_t*)h->mvd_cache [list][scan8[0] + 0 - 1*8]= *(uint32_t*)h->mvd_cache [list][scan8[0] + 1 - 1*8]= *(uint32_t*)h->mvd_cache [list][scan8[0] + 2 - 1*8]= *(uint32_t*)h->mvd_cache [list][scan8[0] + 3 - 1*8]= 0; } if(USES_LIST(left_type[0], list)){ const int b_xy= h->mb2b_xy[left_xy[0]] + 3; *(uint32_t*)h->mvd_cache[list][scan8[0] - 1 + 0*8]= *(uint32_t*)h->mvd_table[list][b_xy + h->b_stride*left_block[0]]; *(uint32_t*)h->mvd_cache[list][scan8[0] - 1 + 1*8]= *(uint32_t*)h->mvd_table[list][b_xy + h->b_stride*left_block[1]]; }else{ *(uint32_t*)h->mvd_cache [list][scan8[0] - 1 + 0*8]= *(uint32_t*)h->mvd_cache [list][scan8[0] - 1 + 1*8]= 0; } if(USES_LIST(left_type[1], list)){ const int b_xy= h->mb2b_xy[left_xy[1]] + 3; *(uint32_t*)h->mvd_cache[list][scan8[0] - 1 + 2*8]= *(uint32_t*)h->mvd_table[list][b_xy + h->b_stride*left_block[2]]; *(uint32_t*)h->mvd_cache[list][scan8[0] - 1 + 3*8]= *(uint32_t*)h->mvd_table[list][b_xy + h->b_stride*left_block[3]]; }else{ *(uint32_t*)h->mvd_cache [list][scan8[0] - 1 + 2*8]= *(uint32_t*)h->mvd_cache [list][scan8[0] - 1 + 3*8]= 0; } *(uint32_t*)h->mvd_cache [list][scan8[5 ]+1]= *(uint32_t*)h->mvd_cache [list][scan8[7 ]+1]= *(uint32_t*)h->mvd_cache [list][scan8[13]+1]= *(uint32_t*)h->mvd_cache [list][scan8[4 ]]= *(uint32_t*)h->mvd_cache [list][scan8[12]]= 0; if(h->slice_type_nos == FF_B_TYPE){ fill_rectangle(&h->direct_cache[scan8[0]], 4, 4, 8, 0, 1); if(IS_DIRECT(top_type)){ *(uint32_t*)&h->direct_cache[scan8[0] - 1*8]= 0x01010101; }else if(IS_8X8(top_type)){ int b8_xy = h->mb2b8_xy[top_xy] + h->b8_stride; h->direct_cache[scan8[0] + 0 - 1*8]= h->direct_table[b8_xy]; h->direct_cache[scan8[0] + 2 - 1*8]= h->direct_table[b8_xy + 1]; }else{ *(uint32_t*)&h->direct_cache[scan8[0] - 1*8]= 0; } if(IS_DIRECT(left_type[0])) h->direct_cache[scan8[0] - 1 + 0*8]= 1; else if(IS_8X8(left_type[0])) h->direct_cache[scan8[0] - 1 + 0*8]= h->direct_table[h->mb2b8_xy[left_xy[0]] + 1 + h->b8_stride*(left_block[0]>>1)]; else h->direct_cache[scan8[0] - 1 + 0*8]= 0; if(IS_DIRECT(left_type[1])) h->direct_cache[scan8[0] - 1 + 2*8]= 1; else if(IS_8X8(left_type[1])) h->direct_cache[scan8[0] - 1 + 2*8]= h->direct_table[h->mb2b8_xy[left_xy[1]] + 1 + h->b8_stride*(left_block[2]>>1)]; else h->direct_cache[scan8[0] - 1 + 2*8]= 0; } } if(FRAME_MBAFF){ #define MAP_MVS\ MAP_F2F(scan8[0] - 1 - 1*8, topleft_type)\ MAP_F2F(scan8[0] + 0 - 1*8, top_type)\ MAP_F2F(scan8[0] + 1 - 1*8, top_type)\ MAP_F2F(scan8[0] + 2 - 1*8, top_type)\ MAP_F2F(scan8[0] + 3 - 1*8, top_type)\ MAP_F2F(scan8[0] + 4 - 1*8, topright_type)\ MAP_F2F(scan8[0] - 1 + 0*8, left_type[0])\ MAP_F2F(scan8[0] - 1 + 1*8, left_type[0])\ MAP_F2F(scan8[0] - 1 + 2*8, left_type[1])\ MAP_F2F(scan8[0] - 1 + 3*8, left_type[1]) if(MB_FIELD){ #define MAP_F2F(idx, mb_type)\ if(!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ h->ref_cache[list][idx] <<= 1;\ h->mv_cache[list][idx][1] /= 2;\ h->mvd_cache[list][idx][1] /= 2;\ } MAP_MVS #undef MAP_F2F }else{ #define MAP_F2F(idx, mb_type)\ if(IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0){\ h->ref_cache[list][idx] >>= 1;\ h->mv_cache[list][idx][1] <<= 1;\ h->mvd_cache[list][idx][1] <<= 1;\ } MAP_MVS #undef MAP_F2F } } } } #endif h->neighbor_transform_size= !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[0]); }
1threat
Indentation in ERB templates : <p>I have the following entry in an <code>erb</code> template:</p> <pre><code># Lorem Ipsum... &lt;% unless @foo['bar'] == nil %&gt; &lt;% @foo['bar'].each do |property, value| %&gt; &lt;%= "zaz.#{property} #{value}" %&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre> <p>That is parsed to:</p> <pre><code># Lorem Ipsum... zaz.property value </code></pre> <p>How can I remove the leading spaces so that lines are not indented in the resolved template?</p> <p>I would like to avoid using something like:</p> <pre><code># Lorem Ipsum... &lt;% unless @foo['bar'] == nil %&gt; &lt;% @foo['bar'].each do |property, value| %&gt; &lt;%= "zaz.#{property} #{value}" %&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre>
0debug
What happens to uninitialized class members in c++? : <p>What happens to uninitialized class members in c++? If I have to do this, what should I take care of?</p> <pre><code>#include &lt;iostream&gt; using namespace std; class Foo { int attr1, attr2; public: Foo (); Foo::Foo () { attr1 = 5; } Foo myThing(); </code></pre>
0debug
static int ehci_state_writeback(EHCIQueue *q, int async) { int again = 0; ehci_trace_qtd(q, NLPTR_GET(q->qtdaddr), (EHCIqtd*) &q->qh.next_qtd); put_dwords(NLPTR_GET(q->qtdaddr),(uint32_t *) &q->qh.next_qtd, sizeof(EHCIqtd) >> 2); if (q->qh.token & QTD_TOKEN_HALT) { ehci_set_state(q->ehci, async, EST_HORIZONTALQH); again = 1; } else { ehci_set_state(q->ehci, async, EST_ADVANCEQUEUE); again = 1; } return again; }
1threat
How to display dictionary in label like table : <p>I have dictinary</p> <pre><code>var dic = ["A":23,"B":3,"C":13,...] </code></pre> <p>I want to display this dic in one label and it need to be formatted like this</p> <pre><code>A 23 B 3 C 13 ... </code></pre> <p>I want text to be aligned in left and right like table</p>
0debug
Is there a PHP function that can decode a string containing &= : <p>I know this is a basic question but I can't find it or even thing what it might be called.</p> <p>But is there a function to easily decode strings with multiple vars like this?</p> <pre><code>$vars = 'status=true&amp;stackoverflow=great&amp;apple=red&amp;orange=orange'; </code></pre> <p>How would I get the value of "apple" with a function?</p> <p>Something like <code>echo '$vars.apple';</code> etc...</p>
0debug
int qemu_fdt_setprop_sized_cells_from_array(void *fdt, const char *node_path, const char *property, int numvalues, uint64_t *values) { uint32_t *propcells; uint64_t value; int cellnum, vnum, ncells; uint32_t hival; propcells = g_new0(uint32_t, numvalues * 2); cellnum = 0; for (vnum = 0; vnum < numvalues; vnum++) { ncells = values[vnum * 2]; if (ncells != 1 && ncells != 2) { return -1; } value = values[vnum * 2 + 1]; hival = cpu_to_be32(value >> 32); if (ncells > 1) { propcells[cellnum++] = hival; } else if (hival != 0) { return -1; } propcells[cellnum++] = cpu_to_be32(value); } return qemu_fdt_setprop(fdt, node_path, property, propcells, cellnum * sizeof(uint32_t)); }
1threat
How to add multiple attributes with jQuery? : <p>I followed all the answers on this post <a href="https://stackoverflow.com/questions/13014317/jquery-adding-two-attributes-via-the-attr-method">jQuery: Adding two attributes via the .attr(); method</a> and none of them work for multiple attributes, only single attribute work.</p> <p>E.g. </p> <pre><code>$("img").attr({ data-aos: "fade-down", data-aos-duration: "600" }); </code></pre> <p>Does not work. But single attribute does work:</p> <pre><code>$("img").attr("data-aos", "fade-down"); </code></pre> <p><a href="https://jsfiddle.net/bwj5uex0/3/" rel="nofollow noreferrer">https://jsfiddle.net/bwj5uex0/3/</a> You can test on JSFiddle with your browser's built-in dev tools after CTRL+Enter.</p>
0debug
static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda) { BandCodingPath path[120][CB_TOT_ALL]; int w, swb, cb, start, size; int i, j; const int max_sfb = sce->ics.max_sfb; const int run_bits = sce->ics.num_windows == 1 ? 5 : 3; const int run_esc = (1 << run_bits) - 1; int idx, ppos, count; int stackrun[120], stackcb[120], stack_len; float next_minrd = INFINITY; int next_mincb = 0; abs_pow34_v(s->scoefs, sce->coeffs, 1024); start = win*128; for (cb = 0; cb < CB_TOT_ALL; cb++) { path[0][cb].cost = 0.0f; path[0][cb].prev_idx = -1; path[0][cb].run = 0; } for (swb = 0; swb < max_sfb; swb++) { size = sce->ics.swb_sizes[swb]; if (sce->zeroes[win*16 + swb]) { for (cb = 0; cb < CB_TOT_ALL; cb++) { path[swb+1][cb].prev_idx = cb; path[swb+1][cb].cost = path[swb][cb].cost; path[swb+1][cb].run = path[swb][cb].run + 1; } } else { float minrd = next_minrd; int mincb = next_mincb; next_minrd = INFINITY; next_mincb = 0; for (cb = 0; cb < CB_TOT_ALL; cb++) { float cost_stay_here, cost_get_here; float rd = 0.0f; if (cb >= 12 && sce->band_type[win*16+swb] < aac_cb_out_map[cb] || cb < aac_cb_in_map[sce->band_type[win*16+swb]] && sce->band_type[win*16+swb] > aac_cb_out_map[cb]) { path[swb+1][cb].prev_idx = -1; path[swb+1][cb].cost = INFINITY; path[swb+1][cb].run = path[swb][cb].run + 1; continue; } for (w = 0; w < group_len; w++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb]; rd += quantize_band_cost(s, sce->coeffs + start + w*128, s->scoefs + start + w*128, size, sce->sf_idx[(win+w)*16+swb], aac_cb_out_map[cb], lambda / band->threshold, INFINITY, NULL, 0); } cost_stay_here = path[swb][cb].cost + rd; cost_get_here = minrd + rd + run_bits + 4; if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run] != run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1]) cost_stay_here += run_bits; if (cost_get_here < cost_stay_here) { path[swb+1][cb].prev_idx = mincb; path[swb+1][cb].cost = cost_get_here; path[swb+1][cb].run = 1; } else { path[swb+1][cb].prev_idx = cb; path[swb+1][cb].cost = cost_stay_here; path[swb+1][cb].run = path[swb][cb].run + 1; } if (path[swb+1][cb].cost < next_minrd) { next_minrd = path[swb+1][cb].cost; next_mincb = cb; } } } start += sce->ics.swb_sizes[swb]; } stack_len = 0; idx = 0; for (cb = 1; cb < CB_TOT_ALL; cb++) if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) idx = cb; ppos = max_sfb; while (ppos > 0) { av_assert1(idx >= 0); cb = idx; stackrun[stack_len] = path[ppos][cb].run; stackcb [stack_len] = cb; idx = path[ppos-path[ppos][cb].run+1][cb].prev_idx; ppos -= path[ppos][cb].run; stack_len++; } start = 0; for (i = stack_len - 1; i >= 0; i--) { cb = aac_cb_out_map[stackcb[i]]; put_bits(&s->pb, 4, cb); count = stackrun[i]; memset(sce->zeroes + win*16 + start, !cb, count); for (j = 0; j < count; j++) { sce->band_type[win*16 + start] = cb; start++; } while (count >= run_esc) { put_bits(&s->pb, run_bits, run_esc); count -= run_esc; } put_bits(&s->pb, run_bits, count); } }
1threat
c# Update object in List using Linq : <p>I have an viewmodel that has some relationships built.</p> <pre><code>public class object() { public int Id {get; set;} public string Name {get;set;} public decimal Amount {get;set;} } public class myViewModel() { public int Id {get;set;} public List&lt;object&gt; myObjects {get;set;} } </code></pre> <p>What I would like to do is change the Amount for a specific myObject element given the object name.</p> <pre><code>var query = new myViewModel(); </code></pre> <p>Assume that I have populated data into the myObjects List.</p> <pre><code>var record = query.myobjects.FirstOrDefault(x =&gt; x.Name = "Test"); </code></pre> <p>Pulls the correct element from this list, but how to update the vale within the list is what I am stuck on. I have tried:</p> <pre><code>query.myObject.FirstOrDefault(x =&gt; x.Name == "Test").Amount = 99; </code></pre> <p>and</p> <pre><code>query.myObject.FirstOrDefault(x =&gt; x.Name == "Test") == record; </code></pre> <p>neither works.</p>
0debug
How to open flutter application from url? : <p>For example, i have case in my flutter app when user can recover his password. In that case user will receive link on e-mail, and i want by clicking on that link, my flutter app will open, and route to specific screen.</p>
0debug
static void pc_init1(MachineState *machine) { PCMachineState *pc_machine = PC_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); MemoryRegion *system_io = get_system_io(); int i; ram_addr_t below_4g_mem_size, above_4g_mem_size; PCIBus *pci_bus; ISABus *isa_bus; PCII440FXState *i440fx_state; int piix3_devfn = -1; qemu_irq *cpu_irq; qemu_irq *gsi; qemu_irq *i8259; qemu_irq *smi_irq; GSIState *gsi_state; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; BusState *idebus[MAX_IDE_BUS]; ISADevice *rtc_state; ISADevice *floppy; MemoryRegion *ram_memory; MemoryRegion *pci_memory; MemoryRegion *rom_memory; DeviceState *icc_bridge; FWCfgState *fw_cfg = NULL; PcGuestInfo *guest_info; ram_addr_t lowmem; if (machine->ram_size >= 0xe0000000) { lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000; } else { lowmem = 0xe0000000; } if (lowmem > pc_machine->max_ram_below_4g) { lowmem = pc_machine->max_ram_below_4g; if (machine->ram_size - lowmem > lowmem && lowmem & ((1ULL << 30) - 1)) { error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64 ") not a multiple of 1G; possible bad performance.", pc_machine->max_ram_below_4g); } } if (machine->ram_size >= lowmem) { above_4g_mem_size = machine->ram_size - lowmem; below_4g_mem_size = lowmem; } else { above_4g_mem_size = 0; below_4g_mem_size = machine->ram_size; } if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size, &ram_memory) != 0) { fprintf(stderr, "xen hardware virtual machine initialisation failed\n"); exit(1); } icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE); object_property_add_child(qdev_get_machine(), "icc-bridge", OBJECT(icc_bridge), NULL); pc_cpus_init(machine->cpu_model, icc_bridge); if (kvm_enabled() && kvmclock_enabled) { kvmclock_create(); } if (pci_enabled) { pci_memory = g_new(MemoryRegion, 1); memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); rom_memory = pci_memory; } else { pci_memory = NULL; rom_memory = system_memory; } guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size); guest_info->has_acpi_build = has_acpi_build; guest_info->legacy_acpi_table_size = legacy_acpi_table_size; guest_info->isapc_ram_fw = !pci_enabled; guest_info->has_reserved_memory = has_reserved_memory; guest_info->rsdp_in_ram = rsdp_in_ram; if (smbios_defaults) { MachineClass *mc = MACHINE_GET_CLASS(machine); smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", mc->name, smbios_legacy_mode, smbios_uuid_encoded); } if (!xen_enabled()) { fw_cfg = pc_memory_init(machine, system_memory, below_4g_mem_size, above_4g_mem_size, rom_memory, &ram_memory, guest_info); } else if (machine->kernel_filename != NULL) { fw_cfg = xen_load_linux(machine->kernel_filename, machine->kernel_cmdline, machine->initrd_filename, below_4g_mem_size, guest_info); } gsi_state = g_malloc0(sizeof(*gsi_state)); if (kvm_irqchip_in_kernel()) { kvm_pc_setup_irq_routing(pci_enabled); gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, GSI_NUM_PINS); } else { gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); } if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io, machine->ram_size, below_4g_mem_size, above_4g_mem_size, pci_memory, ram_memory); } else { pci_bus = NULL; i440fx_state = NULL; isa_bus = isa_bus_new(NULL, get_system_memory(), system_io); no_hpet = 1; } isa_bus_irqs(isa_bus, gsi); if (kvm_irqchip_in_kernel()) { i8259 = kvm_i8259_init(isa_bus); } else if (xen_enabled()) { i8259 = xen_interrupt_controller_init(); } else { cpu_irq = pc_allocate_cpu_irq(); i8259 = i8259_init(isa_bus, cpu_irq[0]); } for (i = 0; i < ISA_NUM_IRQS; i++) { gsi_state->i8259_irq[i] = i8259[i]; } if (pci_enabled) { ioapic_init_gsi(gsi_state, "i440fx"); } qdev_init_nofail(icc_bridge); pc_register_ferr_irq(gsi[13]); pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); assert(pc_machine->vmport != ON_OFF_AUTO_MAX); if (pc_machine->vmport == ON_OFF_AUTO_AUTO) { pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; } pc_basic_device_init(isa_bus, gsi, &rtc_state, true, &floppy, (pc_machine->vmport != ON_OFF_AUTO_ON), 0x4); pc_nic_init(isa_bus, pci_bus); ide_drive_get(hd, ARRAY_SIZE(hd)); if (pci_enabled) { PCIDevice *dev; if (xen_enabled()) { dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); } else { dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); } idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); } else { for(i = 0; i < MAX_IDE_BUS; i++) { ISADevice *dev; char busname[] = "ide.0"; dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); busname[4] = '0' + i; idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); } } pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order, machine, floppy, idebus[0], idebus[1], rtc_state); if (pci_enabled && usb_enabled()) { pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); } if (pci_enabled && acpi_enabled) { DeviceState *piix4_pm; I2CBus *smbus; smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1); smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, gsi[9], *smi_irq, kvm_enabled(), fw_cfg, &piix4_pm); smbus_eeprom_init(smbus, 8, NULL, 0); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, TYPE_HOTPLUG_HANDLER, (Object **)&pc_machine->acpi_dev, object_property_allow_set_link, OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); object_property_set_link(OBJECT(machine), OBJECT(piix4_pm), PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); } if (pci_enabled) { pc_pci_device_init(pci_bus); } }
1threat
Using MSMTP with CodeIgniter email library : <p>Has anyone successfully been able to send email using the standard CodeIgniter email library when using msmtp?</p> <p>I'm running Ubuntu and I've successfully installed and configured MSMTP. I've been able to send email from the command line and also using the default PHP <code>mail()</code> function. </p> <p>My <code>application/config/email.php</code> file looks like this</p> <pre><code>$config = array( 'protocol' =&gt; 'sendmail', 'mailpath' =&gt; '/usr/bin/msmtp -C /etc/msmtp/.msmtprc -t', 'smtp_host' =&gt; 'smtp.gmail.com', 'smtp_user' =&gt; 'myemail@gmail.com', 'smtp_pass' =&gt; 'xxxxxxxx', 'smtp_port' =&gt; 587, 'smtp_timeout' =&gt; 30, 'smtp_crypto' =&gt; 'tls', ); </code></pre> <p>But this doesn't work. If anyone's been successful it would be good to know how you did it. Ideally I'd like to use CodeIgniter's email library as it has a lot of good functionality that I don't want to have to write myself. </p>
0debug
static int ape_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; APEContext *s = avctx->priv_data; int16_t *samples = data; uint32_t nblocks; int i; int blockstodecode; int bytes_used; if (BLOCKS_PER_LOOP * 2 * avctx->channels > *data_size) { av_log (avctx, AV_LOG_ERROR, "Output buffer is too small.\n"); return AVERROR(EINVAL); } av_assert0(s->samples >= 0); if(!s->samples){ uint32_t offset; void *tmp_data; if (buf_size < 8) { av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); return AVERROR_INVALIDDATA; } tmp_data = av_realloc(s->data, FFALIGN(buf_size, 4)); if (!tmp_data) return AVERROR(ENOMEM); s->data = tmp_data; s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2); s->ptr = s->last_ptr = s->data; s->data_end = s->data + buf_size; nblocks = bytestream_get_be32(&s->ptr); offset = bytestream_get_be32(&s->ptr); if (offset > 3) { av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n"); s->data = NULL; return AVERROR_INVALIDDATA; } if (s->data_end - s->ptr < offset) { av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); return AVERROR_INVALIDDATA; } s->ptr += offset; if (!nblocks || nblocks > INT_MAX) { av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks); return AVERROR_INVALIDDATA; } s->samples = nblocks; memset(s->decoded0, 0, sizeof(s->decoded0)); memset(s->decoded1, 0, sizeof(s->decoded1)); if (init_frame_decoder(s) < 0) { av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n"); return AVERROR_INVALIDDATA; } } if (!s->data) { *data_size = 0; return buf_size; } nblocks = s->samples; blockstodecode = FFMIN(BLOCKS_PER_LOOP, nblocks); s->error=0; if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO)) ape_unpack_mono(s, blockstodecode); else ape_unpack_stereo(s, blockstodecode); emms_c(); if (s->error) { s->samples=0; av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n"); return AVERROR_INVALIDDATA; } for (i = 0; i < blockstodecode; i++) { *samples++ = s->decoded0[i]; if(s->channels == 2) *samples++ = s->decoded1[i]; } s->samples -= blockstodecode; *data_size = blockstodecode * 2 * s->channels; bytes_used = s->samples ? s->ptr - s->last_ptr : buf_size; s->last_ptr = s->ptr; return bytes_used; }
1threat
How to just make a specific link colorful? : <p>I did not want to make all links on my custom blog red. Just specific ones. Only the "Destiny" text and "Read more" should be red color. As you can see the titles is also red and that's what I don't want. All links should be red but not the titles!</p> <p>Screenshot: <a href="https://gyazo.com/daaa771613ffd444b65e38119c45c2dd" rel="nofollow">https://gyazo.com/daaa771613ffd444b65e38119c45c2dd</a></p> <p>How can I fix this, what needs to be done?</p> <p>Thank you</p>
0debug
static void extract_exponents(AC3EncodeContext *s) { int blk, ch, i; for (ch = 0; ch < s->channels; ch++) { for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { AC3Block *block = &s->blocks[blk]; for (i = 0; i < AC3_MAX_COEFS; i++) { int e; int v = abs(SCALE_COEF(block->mdct_coef[ch][i])); if (v == 0) e = 24; else { e = 23 - av_log2(v) + block->exp_shift[ch]; if (e >= 24) { e = 24; block->mdct_coef[ch][i] = 0; } } block->exp[ch][i] = e; } } } }
1threat
C# Console App Unable to load Program.cs or <Project_Name>.csproj : For my console app, I am getting the error Assets file 'D:\Folder Name\Tool Name\Tool Name\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. Tool Name C:\Program Files\dotnet\sdk\2.2.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 208 The issue with this is that the <Folder Name> path in actuality is "D:\ProductName%20Utilities", but the solution seems to be looking for "D:\ProductName Utilities" instead. Is there a way to change the solution to look for a the correct filepath?
0debug
static QObject *parse_object(JSONParserContext *ctxt, QList **tokens, va_list *ap) { QDict *dict = NULL; QObject *token, *peek; QList *working = qlist_copy(*tokens); token = qlist_pop(working); if (token == NULL) { goto out; } if (!token_is_operator(token, '{')) { goto out; } qobject_decref(token); token = NULL; dict = qdict_new(); peek = qlist_peek(working); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(peek, '}')) { if (parse_pair(ctxt, dict, &working, ap) == -1) { goto out; } token = qlist_pop(working); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } while (!token_is_operator(token, '}')) { if (!token_is_operator(token, ',')) { parse_error(ctxt, token, "expected separator in dict"); goto out; } qobject_decref(token); token = NULL; if (parse_pair(ctxt, dict, &working, ap) == -1) { goto out; } token = qlist_pop(working); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } } qobject_decref(token); token = NULL; } else { token = qlist_pop(working); qobject_decref(token); token = NULL; } QDECREF(*tokens); *tokens = working; return QOBJECT(dict); out: qobject_decref(token); QDECREF(working); QDECREF(dict); return NULL; }
1threat
static inline uint64_t vmdk_find_offset_in_cluster(VmdkExtent *extent, int64_t offset) { uint64_t offset_in_cluster, extent_begin_offset, extent_relative_offset; uint64_t cluster_size = extent->cluster_sectors * BDRV_SECTOR_SIZE; extent_begin_offset = (extent->end_sector - extent->sectors) * BDRV_SECTOR_SIZE; extent_relative_offset = offset - extent_begin_offset; offset_in_cluster = extent_relative_offset % cluster_size; return offset_in_cluster; }
1threat
duplicate value in lists how can i avoid it : Public Class clsA Public icounter As Integer Public dtime As DateTime End Class Dim list_A As New List(Of clsA) Dim dyus As DateTime = DateTime.Now oB = New clsA oB.dtime = dyus oB.counter = counter2 (comes from COM Port) Dim b As Integer = oB.counter Dim t1 As TimeSpan = New TimeSpan(0, 1, 0) list_A.Add(oB) If DateTime.Now - (list_A(0).dtime) > t1 Then If list_A.Sum(Function(x) x.counter) > 10 Then MessageBox.Show("TEST") End If End If hello, list_A.Add(oB) has 2 values, time and counter. and list_A is in timer. So it always increases, But i want to avoid duplicate counters in this list. How can i do that.
0debug
static inline void check_io(CPUX86State *env, int addr, int size) { int io_offset, val, mask; if (!(env->tr.flags & DESC_P_MASK) || ((env->tr.flags >> DESC_TYPE_SHIFT) & 0xf) != 9 || env->tr.limit < 103) { goto fail; } io_offset = cpu_lduw_kernel(env, env->tr.base + 0x66); io_offset += (addr >> 3); if ((io_offset + 1) > env->tr.limit) { goto fail; } val = cpu_lduw_kernel(env, env->tr.base + io_offset); val >>= (addr & 7); mask = (1 << size) - 1; if ((val & mask) != 0) { fail: raise_exception_err(env, EXCP0D_GPF, 0); } }
1threat
static gboolean gd_leave_event(GtkWidget *widget, GdkEventCrossing *crossing, gpointer opaque) { VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) { gd_ungrab_keyboard(s); } return TRUE; }
1threat
Index error :list out of range : <p>the problem statement is :</p> <p>Given an array of integers, calculate the fractions of its elements that are positive, negative, and are zeros. Print the decimal value of each fraction on a new line.</p> <p>Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to are acceptable.</p> <p>Input Format</p> <p>The first line contains an integer,n, denoting the size of the array. The second line contains space-separated integers describing an array of numbers .</p> <p>Output Format</p> <p>You must print the following lines:</p> <p>A decimal representing of the fraction of positive numbers in the array compared to its size. A decimal representing of the fraction of negative numbers in the array compared to its size. A decimal representing of the fraction of zeros in the array compared to its size.</p> <p>A screenshot of my code has been attached. <a href="https://i.stack.imgur.com/kuafq.png" rel="nofollow noreferrer">enter image description here</a></p> <p>the error message says File "solution.py", line 15, in plusMinus if arr[i] > 0 : IndexError: list index out of range </p> <p>help is much appreciated, thanks in advance.</p>
0debug
Convert PDF to Excel in Java : <p>How to convert PDF file to Excel using Java. We have generate PDF file using itext. Now we want to convert it to excel. we want sample code to convert pdf to excel. or kindly Suggest API.</p>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
static void tmu2_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistTMU2State *s = opaque; trace_milkymist_tmu2_memory_write(addr, value); addr >>= 2; switch (addr) { case R_CTL: s->regs[addr] = value; if (value & CTL_START_BUSY) { tmu2_start(s); } break; case R_BRIGHTNESS: case R_HMESHLAST: case R_VMESHLAST: case R_CHROMAKEY: case R_VERTICESADDR: case R_TEXFBUF: case R_TEXHRES: case R_TEXVRES: case R_TEXHMASK: case R_TEXVMASK: case R_DSTFBUF: case R_DSTHRES: case R_DSTVRES: case R_DSTHOFFSET: case R_DSTVOFFSET: case R_DSTSQUAREW: case R_DSTSQUAREH: case R_ALPHA: s->regs[addr] = value; break; default: error_report("milkymist_tmu2: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } tmu2_check_registers(s); }
1threat
Using JSON.stringify in an expression in Angular2 template : <p>I have a small expression to check whether 2 objects are different or not, in order to display this element (via adding class name):</p> <pre><code>&lt;div ngClass='{{JSON.stringify(obj1) != JSON.stringify(obj2) ? "div-show" : ""}}'&gt;&lt;/div&gt; </code></pre> <p>The problem is I get this error: <code>Cannot read property 'stringify' of undefined</code>.</p> <p>What I need a way to work around, or a proper solution if available. Thanks.</p> <p>PS: I use JSON.stringify() to compare 2 simple objects, nothing fancy here.</p>
0debug
HealthMonitoring Failure Audits Repercussions in ASP.NET : <p>Our event viewer shows two information-level messages that we want to omit from the event logs: </p> <ol> <li>When a user fails authentication (Event code: 4006 Event message: Membership credential verification failed.)</li> <li>When forms authentication has expired and the user navigates to the default page (Event code: 4005 Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.)</li> </ol> <p>Researching how to exclude these types of messages has led me to understand that if I include the following in my web.config file, these messages won't show up. When I test this, I see that is indeed the case.</p> <pre><code>&lt;healthMonitoring&gt; &lt;rules&gt; &lt;clear /&gt; &lt;add name="All Errors Default" eventName="All Errors" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom=""/&gt; &lt;/rules&gt; &lt;/healthMonitoring&gt; </code></pre> <p>In other words, I omit this from the default web.config:</p> <pre><code>&lt;add name="Failure Audits Default" eventName="Failure Audits" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" custom=""/&gt; </code></pre> <p>My question is: what else could I potentially be excluding the event log by removing this node? And if there are other potential repercussions, is there another or a better way to exclude just those two types of error logs that I mentioned above?</p> <p>Thanks in advance!</p>
0debug
Need to filter value from string which can have dynamic number with text after that using regex : <p>I want to filter value from string which should result me a number followed by text. For example string looks like "There are 9 steps in the house which can be used to visit first floor". Output :"<strong>9 steps</strong>". Here number can change to any value. but that will be followed by steps</p>
0debug
static int x8_setup_spatial_predictor(IntraX8Context * const w, const int chroma){ MpegEncContext * const s= w->s; int range; int sum; int quant; w->dsp.setup_spatial_compensation(s->dest[chroma], s->edge_emu_buffer, s->current_picture.f.linesize[chroma>0], &range, &sum, w->edges); if(chroma){ w->orient=w->chroma_orient; quant=w->quant_dc_chroma; }else{ quant=w->quant; } w->flat_dc=0; if(range < quant || range < 3){ w->orient=0; if(range < 3){ w->flat_dc=1; sum+=9; w->predicted_dc = (sum*6899)>>17; } } if(chroma) return 0; assert(w->orient < 3); if(range < 2*w->quant){ if( (w->edges&3) == 0){ if(w->orient==1) w->orient=11; if(w->orient==2) w->orient=10; }else{ w->orient=0; } w->raw_orient=0; }else{ static const uint8_t prediction_table[3][12]={ {0,8,4, 10,11, 2,6,9,1,3,5,7}, {4,0,8, 11,10, 3,5,2,6,9,1,7}, {8,0,4, 10,11, 1,7,2,6,9,3,5} }; w->raw_orient=x8_get_orient_vlc(w); if(w->raw_orient<0) return -1; assert(w->raw_orient < 12 ); assert(w->orient<3); w->orient=prediction_table[w->orient][w->raw_orient]; } return 0; }
1threat
jquery issue with chekbox : <p>This is my html checkbox --</p> <pre><code>&lt;input type="checkbox" id="export_1_field_title" value="title"&gt; </code></pre> <p>in jquery, i want to check whether checkbox is checked or not, if check then will read the value, so this is my query --</p> <pre><code> var title = ''; if($("#export_1_field_title").is("checked")) { title = 'title'; } alert('Here '+title); </code></pre> <p>but not able to read the checkbox, kindly suggest any changes required</p>
0debug
static inline int cris_swap(const int mode, int x) { switch (mode) { case N: asm ("swapn\t%0\n" : "+r" (x) : "0" (x)); break; case W: asm ("swapw\t%0\n" : "+r" (x) : "0" (x)); break; case B: asm ("swapb\t%0\n" : "+r" (x) : "0" (x)); break; case R: asm ("swapr\t%0\n" : "+r" (x) : "0" (x)); break; case B|R: asm ("swapbr\t%0\n" : "+r" (x) : "0" (x)); break; case W|R: asm ("swapwr\t%0\n" : "+r" (x) : "0" (x)); break; case W|B: asm ("swapwb\t%0\n" : "+r" (x) : "0" (x)); break; case W|B|R: asm ("swapwbr\t%0\n" : "+r" (x) : "0" (x)); break; case N|R: asm ("swapnr\t%0\n" : "+r" (x) : "0" (x)); break; case N|B: asm ("swapnb\t%0\n" : "+r" (x) : "0" (x)); break; case N|B|R: asm ("swapnbr\t%0\n" : "+r" (x) : "0" (x)); break; case N|W: asm ("swapnw\t%0\n" : "+r" (x) : "0" (x)); break; default: err(); break; } return x; }
1threat