problem
stringlengths
26
131k
labels
class label
2 classes
Swift stopwatch running slower than expected : <p>I am trying to implement a stopwatch into my app, but I've noticed that it actually runs slower than it should. Here is the code:</p> <pre><code>timer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(display), userInfo: nil, repeats: true) func stringFromTimeInterval(interval: TimeInterval) -&gt; NSString { let ti = Int(interval) let minutes = ti / 6000 let seconds = ti / 100 let ms = ti % 100 return NSString(format: "%0.2d:%0.2d.%0.2d",minutes,seconds,ms) } @objc func display() { interval += 1 lapInterval += 1 timeLabel.text = stringFromTimeInterval(interval: TimeInterval(interval)) as String lapLabel.text = stringFromTimeInterval(interval: TimeInterval(lapInterval)) as String } </code></pre> <p>Hopefully I've included enough information. Thanks in advance!</p>
0debug
to read .csv files in R : <p>I need some help. I'm begginer on R and I don't know how to read .csv files from different folders. I only know how to read files from one folder. One folder is with new data .csv and other with old data .csv and i have to read them in two massives. (Note: there are many files in both folders). Later I will have to compare new vs old files. Could you help me to write a code for that? or just tell some advices. Thank u.</p>
0debug
Html code not working in safari.But working in all other browsers : And i think its not able to submit form in safari browser This is working fine in all the browsers except safari <form action="/commonDashboard" name="loginForm" method="post" autocomplete="off" id="loginForm"> <div> <label>User Email ID</label> <input type="text" placeholder="Enter your Email Address" id="userEmail" name="userEmail" tabindex="1" /> </div> <div> <label>Password</label> <input type="password" placeholder="Enter your password" id="userPassword" name="userPassword" tabindex="2" /> </div> <div> <input type="button" value="Sign In" onclick="validatelogin();" tabindex="3" /> </div> </form>
0debug
How do I solve this? Either through recursion? Or possibly through the replace() method? Any help/ideas would be great : Look for patterns like "tip" and "top" in the string -- length-3, starting with 't' and ending with 'p'. Return a string where for all such words, the middle letter is gone, so "tipXtap" yields "tpXtp".
0debug
bracket is lost in PHP code : <blockquote> <p>Parse error: syntax error, unexpected '{'</p> </blockquote> <p>Plz, I wonder Can you help me, I can't find it.</p> <pre><code>if( isPost() ) { extract($_POST); if( validation_required([$name , $family ,$username , $email , $password]) ) { $conn = connectToDB(); if (!userGet($username,$conn){ saveUsers($_POST) ? redirect("index.php") : $status = 'you are failed'; } else { $status = "This username is exist"; } } else { $status = 'your information is not valid'; } } </code></pre>
0debug
Where to find an IDE extending code example which do not uses ExptIntf and ToolsIntf? : I'm doing my first tests about extending the IDE but I only find old source codes which uses `ExptInft` and `ToolsIntf`, which are deprecated (Delphi 2007). I'm looking for a newer example code or help for updating an old example. **Here's what I did for trying to update an old example:** I've started from [this][1] example source code: unit PanelEd; interface uses Classes, Forms, Windows, Dialogs, ExptIntf, ToolIntf, FileCtrl, SysUtils, EditIntf, DsgnIntf; type TPanelEditExpert = class (TIExpert) public function GetStyle: TExpertStyle; override; function GetName: string; override; function GetAuthor: string; override; function GetComment: string; override; function GetPage: string; override; function GetGlyph: HICON; override; function GetState: TExpertState; override; function GetIDString: string; override; function GetMenuText: string; override; procedure Execute; override; end; // custom module for the panel type TPanelModule = class (TCustomModule) public procedure ExecuteVerb(Index: Integer); override; function GetVerb(Index: Integer): string; override; function GetVerbCount: Integer; override; procedure ValidateComponent(Component: TComponent); override; end; procedure Register; implementation uses StdCtrls, ExtCtrls, Buttons; // "standard" project expert function TPanelEditExpert.GetStyle: TExpertStyle; begin // show up in the Help menu Result := esStandard; end; function TPanelEditExpert.GetName: String; begin // official name Result := 'Panel Edit Wizard' end; function TPanelEditExpert.GetAuthor: string; begin Result := 'Marco and Tim'; end; function TPanelEditExpert.GetComment: String; begin Result := 'TPanelEditExpert Wizard'; end; function TPanelEditExpert.GetPage: string; begin Result := ''; end; function TPanelEditExpert.GetGlyph: HICON; begin Result := 0; end; function TPanelEditExpert.GetState: TExpertState; begin Result := [esEnabled]; end; function TPanelEditExpert.GetIDString: String; begin // must be unique Result := 'DDHandbook.PanelEditWizard' end; function TPanelEditExpert.GetMenuText: String; begin // the text of the menu item Result := '&Panel Edit Wizard' end; procedure TPanelEditExpert.Execute; var ModuleName, FormName, FileName: string; ModIntf: TIModuleInterface; begin ToolServices.GetNewModuleAndClassName ( 'Panel', ModuleName, FormName, FileName); ModIntf := ToolServices.CreateModuleEx (FileName, FormName, 'Panel', '', nil, nil, [cmNewForm, cmAddToProject, cmUnNamed]); ModIntf.ShowSource; ModIntf.ShowForm; ModIntf.Release; end; // custom module methods function TPanelModule.GetVerbCount: Integer; begin Result := 1; end; function TPanelModule.GetVerb(Index: Integer): string; begin if Index = 0 then Result:= 'Rename...'; end; procedure TPanelModule.ExecuteVerb(Index: Integer); var NewName: string; begin if Index = 0 then begin NewName := Root.Name; if InputQuery ('Panel Module Editor', 'New panel name:', NewName) then Root.Name := NewName; end; end; procedure TPanelModule.ValidateComponent(Component: TComponent); begin if not (Component is TButton) and not (Component is TSpeedButton) then raise Exception.Create ('The panel can host only buttons'); end; procedure Register; begin RegisterCustomModule (TPanel, TPanelModule); RegisterLibraryExpert(TPanelEditExpert.Create); end; end. In the [official documentation][2] I read that I should use a `TNotifierObject` who implements `IOTAWizard` and `IOTAMenuWizard` interfaces (From `ToolsAPI` unit), instead of `ExptIntf` and `ToolsIntf`. In order to update the example code, I've followed these steps: 1. Removed `ExptIntf` and `ToolsIntf` from source code. 2. Added `ToolsAPI` to the uses clause. 3. Replaced `TExpertState` with `TWizardState` 4. Replaced `esEnabled` with `wsEnabled`. 5. Replaced `RegisterLibraryExpert` with `RegisterPackageWizard`. After doing this, I still have undeclared identifier errors on `TExpertStyle` and `ToolServices`. function TPanelEditExpert.GetStyle: TExpertStyle; begin // show up in the Help menu Result := esStandard; end; procedure TPanelEditExpert.Execute; var ModuleName, FormName, FileName: string; ModIntf: TIModuleInterface; begin ToolServices.GetNewModuleAndClassName ( 'Panel', ModuleName, FormName, FileName); ModIntf := ToolServices.CreateModuleEx (FileName, FormName, 'Panel', '', nil, nil, [cmNewForm, cmAddToProject, cmUnNamed]); ModIntf.ShowSource; ModIntf.ShowForm; ModIntf.Release; end; How should these parts be updated and/or where can I find an example which don't uses deprecated units? [1]: http://read.pudn.com/downloads21/sourcecode/book/71256/Delphi%203%20%E9%AB%98%E7%BA%A7%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97/15/COMPS/PANELED.PAS__.htm [2]: http://docwiki.embarcadero.com/RADStudio/XE5/en/Implementing_the_Wizard_Interfaces
0debug
ATMEGA2560 using UART interrupt to control global flag : I recently met a problem when I was playing with ATMEGA2560, and I really don't understand what's wrong with it. Here is my code. main : http://pastebin.com/raw/pNuKw1cF IRQ : http://pastebin.com/raw/uhz1uBUZ The problem is : When I received some datas from USART , I tried to set a RxFlag that can active the if-statement in main loop. But it didn't work , till I uncommented the function before if-statement which may be a _delay_ms() or a printf(). It make no sense. What I remember is that I don't need those functions and it can still set the global variables to affect main loop. Or is there any detail I had missed? Please give me some clue to figure out , I was confused.
0debug
target_ulong helper_ldr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, int mem_idx) { uint64_t tmp; tmp = do_lbu(env, arg2, mem_idx); arg1 = (arg1 & 0xFFFFFFFFFFFFFF00ULL) | tmp; if (GET_LMASK64(arg2) >= 1) { tmp = do_lbu(env, GET_OFFSET(arg2, -1), mem_idx); arg1 = (arg1 & 0xFFFFFFFFFFFF00FFULL) | (tmp << 8); } if (GET_LMASK64(arg2) >= 2) { tmp = do_lbu(env, GET_OFFSET(arg2, -2), mem_idx); arg1 = (arg1 & 0xFFFFFFFFFF00FFFFULL) | (tmp << 16); } if (GET_LMASK64(arg2) >= 3) { tmp = do_lbu(env, GET_OFFSET(arg2, -3), mem_idx); arg1 = (arg1 & 0xFFFFFFFF00FFFFFFULL) | (tmp << 24); } if (GET_LMASK64(arg2) >= 4) { tmp = do_lbu(env, GET_OFFSET(arg2, -4), mem_idx); arg1 = (arg1 & 0xFFFFFF00FFFFFFFFULL) | (tmp << 32); } if (GET_LMASK64(arg2) >= 5) { tmp = do_lbu(env, GET_OFFSET(arg2, -5), mem_idx); arg1 = (arg1 & 0xFFFF00FFFFFFFFFFULL) | (tmp << 40); } if (GET_LMASK64(arg2) >= 6) { tmp = do_lbu(env, GET_OFFSET(arg2, -6), mem_idx); arg1 = (arg1 & 0xFF00FFFFFFFFFFFFULL) | (tmp << 48); } if (GET_LMASK64(arg2) == 7) { tmp = do_lbu(env, GET_OFFSET(arg2, -7), mem_idx); arg1 = (arg1 & 0x00FFFFFFFFFFFFFFULL) | (tmp << 56); } return arg1; }
1threat
AngularJS ui-route exit page : <p>I need a possibility to ask the user if he/she is leaving a page. I read that his would be a possibility but the event is fired when I enter the page and not when I leave the page. <strong>onExit</strong> would work but this event I have to defined at the ... .routes.js and I need access to properties and functions at the controller. Is there an event that is fired by exit of page?</p> <pre><code>$scope.$on('$locationChangeStart', function( event ) { var answer = confirm("Are you sure you want to leave this page?") if (!answer) { event.preventDefault(); } }); </code></pre>
0debug
Adding logs to Airflow Logs : <p>How can I add my own logs onto the Apache Airflow logs that are automatically generated? any print statements wont get logged in there, so I was wondering how I can add my logs so that it shows up on the UI as well?</p>
0debug
how find elements with data attribute and id : is possible find a element id in the same sentence? ``` <div class="test"> <input id="999" type="text" data-test="2"> </div> Example $('.test').find('[data-test="2"] #999) ``` I try to find a specifict input in my html code, but this input exists many time with the same id value, the only diference is the attr "data-test" (the number is incremental) Any help for this?
0debug
How to fix expired client cert in docker-machine : <p>Doing a <code>docker-machine ls</code> a got the unexpected <code>Unable to query docker version: Get https://x.x.x.x:2376/v1.15/version: x509: certificate has expired or is not yet valid</code> for every machine. </p> <p>I hadn't done anything recently. Looking on SO, I tried some common culprits, VPN, virus, weird clock issues, etc. None of that applied. How can I fix make them useable again (via the <code>docker-machine</code> interface)? </p> <p>Using Docker for Mac, 17.12.0-ce-49</p>
0debug
Get the entry with Tkinter : <p>Hello I have this code :</p> <pre><code>import Tkinter as tk root = tk.Tk() margin = 0.23 entry = tk.entry(root).grid(row=1,column=1) def profit_calculator(): profit = margin*int(entry.get()) print(profit) button_calc = tk.Button(root, text="Calculate", command=profit_calculator).grid(row=2,column=1) root.mainloop() </code></pre> <p>I tried to execute this code I put a value in the entry but when I clicked on the button I get this :</p> <pre><code>AttributeError : 'NoneType' object has no attribute 'get' </code></pre> <p>I have to use grid absolutely but I don't know why I get this error...</p> <p>Can you help me ? </p> <p>Thank you :)</p>
0debug
Server error in asp.net? : <p>I just want to know what is the meaning of this error? The INSERT statement conflicted with the FOREIGN KEY constraint "FK__thumbnail__instr__160F4887". The conflict occurred in database "MusicStoreDB", table "dbo.instrumentItem", column 'instrumentId'. The statement has been terminated.</p> <p>Here is the stack trace:</p> <pre><code>Server Error in '/' Application. The INSERT statement conflicted with the FOREIGN KEY constraint "FK__thumbnail__instr__160F4887". The conflict occurred in database "MusicStoreDB", table "dbo.instrumentItem", column 'instrumentId'. The statement has been terminated. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK__thumbnail__instr__160F4887". The conflict occurred in database "MusicStoreDB", table "dbo.instrumentItem", column 'instrumentId'. The statement has been terminated. Source Error: Line 74: Line 75: obj.thumbnailImages.Add(subImg); Line 76: obj.SaveChanges(); Line 77: } Line 78: } Source File: c:\Users\User1\Documents\Visual Studio 2015\WebSites\MusicStore\App_Code\ConnectionClassGuitarItems.cs Line: 76 Stack Trace: [SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK__thumbnail__instr__160F4887". The conflict occurred in database "MusicStoreDB", table "dbo.instrumentItem", column 'instrumentId'. The statement has been terminated.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2434922 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5736592 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning (TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +285 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady) +3731 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +58 System.Data.SqlClient.SqlDataReader.get_MetaData() +89 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +379 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2026 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean asyncWrite) +375 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +240 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher. &lt;Reader&gt;b__c(DbCommand t, DbCommandInterceptionContext`1 c) +9 System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1 .Dispatch(TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher .Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) +355 System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader (CommandBehavior behavior) +167 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12 System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand. Execute(Dictionary`2 identifierValues, List`1 generatedValues) +234 System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() +139 [UpdateException: An error occurred while updating the entries. See the inner exception for details.] System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() +319 System.Data.Entity.Core.EntityClient.Internal.EntityAdapter. &lt;Update&gt;b__2(UpdateTranslator ut) +9 System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update(T noChangesResult, Func`2 updateFunction) +120 System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update() +77 System.Data.Entity.Core.Objects.ObjectContext.&lt;SaveChangesToStore&gt;b__35() +11 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +288 System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction) +163 System.Data.Entity.Core.Objects.&lt;&gt;c__DisplayClass2a. &lt;SaveChangesInternal&gt;b__27() +22 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +164 System.Data.Entity.Core.Objects.ObjectContext. SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction) +222 System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options) +7 System.Data.Entity.Internal.InternalContext.SaveChanges() +114 [DbUpdateException: An error occurred while updating the entries. See the inner exception for details.] System.Data.Entity.Internal.InternalContext.SaveChanges() +199 System.Data.Entity.Internal.LazyInternalContext.SaveChanges() +27 System.Data.Entity.DbContext.SaveChanges() +20 ConnectionClassGuitarItems.AddThumnailImage(thumbnailImage subImg) in c:\Users\User1\Documents\Visual Studio 2015\WebSites\MusicStore\App_Code\ConnectionClassGuitarItems.cs:76 Pages_CreateBrands.itemSaveButton_Click(Object sender, EventArgs e) in c:\Users\User1\Documents\Visual Studio 2015\WebSites\MusicStore\Pages\CreateBrands.aspx.cs:231 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9696694 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204 System.Web.UI.WebControls.Button.System.Web.UI. IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639 </code></pre>
0debug
static int qcow_create2(const char *filename, int64_t total_size, const char *backing_file, const char *backing_format, int flags, size_t cluster_size, int prealloc) { int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits; int ref_clusters, backing_format_len = 0; int rounded_ext_bf_len = 0; QCowHeader header; uint64_t tmp, offset; QCowCreateState s1, *s = &s1; QCowExtension ext_bf = {0, 0}; int ret; memset(s, 0, sizeof(*s)); fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) return -1; memset(&header, 0, sizeof(header)); header.magic = cpu_to_be32(QCOW_MAGIC); header.version = cpu_to_be32(QCOW_VERSION); header.size = cpu_to_be64(total_size * 512); header_size = sizeof(header); backing_filename_len = 0; if (backing_file) { if (backing_format) { ext_bf.magic = QCOW_EXT_MAGIC_BACKING_FORMAT; backing_format_len = strlen(backing_format); ext_bf.len = backing_format_len; rounded_ext_bf_len = (sizeof(ext_bf) + ext_bf.len + 7) & ~7; header_size += rounded_ext_bf_len; } header.backing_file_offset = cpu_to_be64(header_size); backing_filename_len = strlen(backing_file); header.backing_file_size = cpu_to_be32(backing_filename_len); header_size += backing_filename_len; } s->cluster_bits = get_bits_from_size(cluster_size); if (s->cluster_bits < MIN_CLUSTER_BITS || s->cluster_bits > MAX_CLUSTER_BITS) { fprintf(stderr, "Cluster size must be a power of two between " "%d and %dk\n", 1 << MIN_CLUSTER_BITS, 1 << (MAX_CLUSTER_BITS - 10)); return -EINVAL; } s->cluster_size = 1 << s->cluster_bits; header.cluster_bits = cpu_to_be32(s->cluster_bits); header_size = (header_size + 7) & ~7; if (flags & BLOCK_FLAG_ENCRYPT) { header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES); } else { header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE); } l2_bits = s->cluster_bits - 3; shift = s->cluster_bits + l2_bits; l1_size = (((total_size * 512) + (1LL << shift) - 1) >> shift); offset = align_offset(header_size, s->cluster_size); s->l1_table_offset = offset; header.l1_table_offset = cpu_to_be64(s->l1_table_offset); header.l1_size = cpu_to_be32(l1_size); offset += align_offset(l1_size * sizeof(uint64_t), s->cluster_size); s->refcount_table = qemu_mallocz(s->cluster_size); s->refcount_table_offset = offset; header.refcount_table_offset = cpu_to_be64(offset); header.refcount_table_clusters = cpu_to_be32(1); offset += s->cluster_size; s->refcount_block_offset = offset; tmp = offset >> s->cluster_bits; ref_clusters = (tmp >> (s->cluster_bits - REFCOUNT_SHIFT)) + 1; for (i=0; i < ref_clusters; i++) { s->refcount_table[i] = cpu_to_be64(offset); offset += s->cluster_size; } s->refcount_block = qemu_mallocz(ref_clusters * s->cluster_size); qcow2_create_refcount_update(s, 0, header_size); qcow2_create_refcount_update(s, s->l1_table_offset, l1_size * sizeof(uint64_t)); qcow2_create_refcount_update(s, s->refcount_table_offset, s->cluster_size); qcow2_create_refcount_update(s, s->refcount_block_offset, ref_clusters * s->cluster_size); ret = qemu_write_full(fd, &header, sizeof(header)); if (ret != sizeof(header)) { ret = -1; goto exit; } if (backing_file) { if (backing_format_len) { char zero[16]; int padding = rounded_ext_bf_len - (ext_bf.len + sizeof(ext_bf)); memset(zero, 0, sizeof(zero)); cpu_to_be32s(&ext_bf.magic); cpu_to_be32s(&ext_bf.len); ret = qemu_write_full(fd, &ext_bf, sizeof(ext_bf)); if (ret != sizeof(ext_bf)) { ret = -1; goto exit; } ret = qemu_write_full(fd, backing_format, backing_format_len); if (ret != backing_format_len) { ret = -1; goto exit; } if (padding > 0) { ret = qemu_write_full(fd, zero, padding); if (ret != padding) { ret = -1; goto exit; } } } ret = qemu_write_full(fd, backing_file, backing_filename_len); if (ret != backing_filename_len) { ret = -1; goto exit; } } lseek(fd, s->l1_table_offset, SEEK_SET); tmp = 0; for(i = 0;i < l1_size; i++) { ret = qemu_write_full(fd, &tmp, sizeof(tmp)); if (ret != sizeof(tmp)) { ret = -1; goto exit; } } lseek(fd, s->refcount_table_offset, SEEK_SET); ret = qemu_write_full(fd, s->refcount_table, s->cluster_size); if (ret != s->cluster_size) { ret = -1; goto exit; } lseek(fd, s->refcount_block_offset, SEEK_SET); ret = qemu_write_full(fd, s->refcount_block, ref_clusters * s->cluster_size); if (ret != s->cluster_size) { ret = -1; goto exit; } ret = 0; exit: qemu_free(s->refcount_table); qemu_free(s->refcount_block); close(fd); if (prealloc) { BlockDriverState *bs; bs = bdrv_new(""); bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR); preallocate(bs); bdrv_close(bs); } return ret; }
1threat
Post some content from website to Facebook page : <p>I want to create a website which will allow user to login with his/her Facebook credentials. Now, my website would allow user to post some content (text plus images) and also if user posts it on my website, it should also be posted on a page (which is also created and owned by me). </p> <p>Is it possible to do that? If yes, can anyone point to any resource which explains how to do it?</p>
0debug
PHP Regex for password: minim 4 charaters, of which at least one CAN'T be a letter or a number : <p>I have to make a regex for a password with the following conditions: - minimum 4 characters - at least 1 non-word character.</p> <p>I tried this way:</p> <pre><code>$regex_password = '@(\W)+@'; $regex_password1 = '@(?i)([a-z\d])+@'; if ((!preg_match($regex_password, trim($_POST['pass']))) &amp;&amp; (!preg_match($regex_password1, trim($_POST['pass']))) &amp;&amp; strlen(trim($_POST['pass'])) &lt;5){ //error } </code></pre> <p>And then tried to create a new account with the password: "pas" and it's working, so there's something wrong with my regex. Can someone help?</p>
0debug
Check if Object already exists in Collection - Laravel : <p>I am looking to add objects to a new collection as I loop through a series of different results.</p> <p>The query:</p> <pre><code>$osRed = Item::where('category', 'Hardware') -&gt;where(function ($query) { $query-&gt;where('operating_system', 'xxx') -&gt;orWhere('operating_system', 'xxx') -&gt;orWhere('operating_system', 'xxx'); }) -&gt;orderBy('operating_system', 'ASC') -&gt;get(); </code></pre> <p>Then, loop through these results and add related objects to a new collection.</p> <pre><code>foreach ($osRed as $os) { foreach ($os-&gt;services as $service) { if (!($servicesImpacted-&gt;contains($service))) { $servicesImpacted-&gt;push($service); } } } </code></pre> <p>I then go on to another set of results and add the related services from those results to the collection.</p> <p>However, it is not picking up that the object is already in the collection and I end up with a large number of (what appear to be) duplicates. </p> <p>Ideally, I would like to match up on the name attribute of the $service object, but that doesn't seem to be supported by the contains method.</p> <pre><code>toString() must not throw an exception </code></pre>
0debug
If/else statements not displaying correctly to console : <p>I'm trying to get the console to read "No goal!" but every time I run it, I get "Goal". I'm guessing there's some basic syntax error that I'm making? </p> <pre><code>let isSoccerFan = false; if (isSoccerFan=true) { console.log("Goal!"); } else{ console.log("No goal!") } </code></pre>
0debug
Splitting by ',' in a dictionary while retaining the lists inside : <p>I've been looking for a way to split by ',' in a dictionary while retaining the present lists but have not been succesful. I want to split this dictionary:</p> <pre><code>{'R_ARABR': ['YHR104W'], 'R_GLYCt': ['YLL043W'], 'R_LPP_SC': ['YDR284C', 'YDR503C'], 'R_TREH': ['YDR001C', 'YBR001C'], 'R_CTPS2': ['YBL039C', 'YJR103W'], 'R_CTPS1': ['YBL039C', 'YJR103W']} </code></pre> <p>To appear like this:</p> <pre><code>{'R_ARABR': ['YHR104W'], 'R_GLYCt': ['YLL043W'], 'R_LPP_SC': ['YDR284C', 'YDR503C'], 'R_TREH': ['YDR001C', 'YBR001C'], 'R_CTPS2': ['YBL039C', 'YJR103W'], 'R_CTPS1': ['YBL039C', 'YJR103W']} </code></pre> <p>Help is much appreciated!</p>
0debug
StatefulBeanToCsv with Column headers : <p>I am using <code>opencsv-4.0</code> to write a csv file and I need to add column headers in output file.</p> <p>Here is my code.</p> <pre><code>public static void buildProductCsv(final List&lt;Product&gt; product, final String filePath) { try { Writer writer = new FileWriter(filePath); // mapping of columns with their positions ColumnPositionMappingStrategy&lt;Product&gt; mappingStrategy = new ColumnPositionMappingStrategy&lt;Product&gt;(); // Set mappingStrategy type to Product Type mappingStrategy.setType(Product.class); // Fields in Product Bean String[] columns = new String[] { "productCode", "MFD", "EXD" }; // Setting the colums for mappingStrategy mappingStrategy.setColumnMapping(columns); StatefulBeanToCsvBuilder&lt;Product&gt; builder = new StatefulBeanToCsvBuilder&lt;Product&gt;(writer); StatefulBeanToCsv&lt;Product&gt; beanWriter = builder.withMappingStrategy(mappingStrategy).build(); // Writing data to csv file beanWriter.write(product); writer.close(); log.info("Your csv file has been generated!"); } catch (Exception ex) { log.warning("Exception: " + ex.getMessage()); } } </code></pre> <p>Above code create a csv file with data. But it not include column headers in that file.</p> <p>How could I add column headers to output csv?</p>
0debug
What's the character code for exclamation mark in circle? : <p>What's the Unicode or Segoe UI Symbols (or other font) code for exclamation mark in circle?</p> <p><a href="https://i.stack.imgur.com/cquC6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cquC6.png" alt="enter image description here"></a></p>
0debug
concat string in dynamic feild : I have the following code, where partial functionality is completed. but what I need to do next is to concat all the feild's that the user input in this form. <HTML> <HEAD> <TITLE> Add/Remove dynamic rows in HTML table </TITLE> <SCRIPT language="javascript"> function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell1 = row.insertCell(0); var element1 = document.createElement("input"); element1.type = "checkbox"; element1.name="chkbox[]"; cell1.appendChild(element1); var cell2 = row.insertCell(1); cell2.innerHTML = rowCount + 1; var cell3 = row.insertCell(2); var element2 = document.createElement("input"); element2.type = "text"; element2.name = "txtbox[]"; cell3.appendChild(element2); } function deleteRow(tableID) { try { var table = document.getElementById(tableID); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; var chkbox = row.cells[0].childNodes[0]; if(null != chkbox && true == chkbox.checked) { table.deleteRow(i); rowCount--; i--; } } }catch(e) { alert(e); } } </SCRIPT> </HEAD> <BODY> <INPUT type="button" value="Add Row" onclick="addRow('dataTable')" /> <INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" /> <TABLE id="dataTable" width="350px" border="1"> <TR> <TD><INPUT type="checkbox" name="chk"/></TD> <TD> 1 </TD> <TD> <INPUT type="text" /> </TD> </TR> </TABLE> </BODY> </HTML> -> for example if the user click on add row 4 times, the form will create 4 rows now while he click some button (to be made) the result should be concatination of all the inputs in one large text area.
0debug
static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) { VideoState *is = opaque; int audio_size, len1; int bytes_per_sec; int frame_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, 1, is->audio_tgt.fmt, 1); double pts; audio_callback_time = av_gettime(); while (len > 0) { if (is->audio_buf_index >= is->audio_buf_size) { audio_size = audio_decode_frame(is, &pts); if (audio_size < 0) { is->audio_buf = is->silence_buf; is->audio_buf_size = sizeof(is->silence_buf) / frame_size * frame_size; } else { if (is->show_mode != SHOW_MODE_VIDEO) update_sample_display(is, (int16_t *)is->audio_buf, audio_size); is->audio_buf_size = audio_size; } is->audio_buf_index = 0; } len1 = is->audio_buf_size - is->audio_buf_index; if (len1 > len) len1 = len; memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1); len -= len1; stream += len1; is->audio_buf_index += len1; } bytes_per_sec = is->audio_tgt.freq * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt); is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index; is->audio_current_pts = is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / bytes_per_sec; is->audio_current_pts_drift = is->audio_current_pts - audio_callback_time / 1000000.0; check_external_clock_sync(is, is->audio_current_pts); }
1threat
I wnt to connect php and mysql database : <pre><code>&lt;?php $host ="localhost"; $user = "root"; $pass = ""; $db = "StuDet"; $conn = mysql_connect($host,$user,$pass); mysql_select_db($db,$conn); @mysql_select_db($database) or die ("Unable to select database"); ?&gt; </code></pre> <p>I have a doubt in line "$conn = mysql_connect($host,$user,$pass);" </p>
0debug
how to add image from iPhone gallery to an array IOS : As i am very much new to iOS development,i am trying to add an uiimage from image gallery to an array.But when i try to use the array to add image to uiimageview it shows me an error [UIImage stringByDeletingPathExtension]: unrecognized selector sent to instance 0x7fefd3ea02f0.
0debug
what is capture mode on an event listener : <p>In the vue docs under <a href="https://vuejs.org/v2/guide/events.html#Event-Modifiers" rel="noreferrer">Event Modifiers</a>, there's an example of a modifier called <code>capture</code> which states the following:</p> <pre><code>&lt;!-- use capture mode when adding the event listener --&gt; &lt;div v-on:click.capture="doThis"&gt;...&lt;/div&gt; </code></pre> <p>I've done some searching, but haven't found a clear answer as to how this modifies the event binding, then I thought to myself 'You know who always has the answer? Stack Overflow'</p>
0debug
How can I use i in loop to make variance? : <p>How can I change this code</p> <pre><code>train_0.append(0) train_1.append(1) train_2.append(2) train_3.append(3) </code></pre> <p>using loop like under?</p> <pre><code>for i in range(4): train_i.append(i) </code></pre> <p>My code occurs this error.</p> <pre><code>NameError: name 'train_i' is not defined </code></pre> <p>Thank you.</p>
0debug
static int wc3_read_header(AVFormatContext *s, AVFormatParameters *ap) { Wc3DemuxContext *wc3 = s->priv_data; ByteIOContext *pb = s->pb; unsigned int fourcc_tag; unsigned int size; AVStream *st; int ret = 0; int current_palette = 0; char *buffer; int i; wc3->width = WC3_DEFAULT_WIDTH; wc3->height = WC3_DEFAULT_HEIGHT; wc3->palettes = NULL; wc3->palette_count = 0; wc3->pts = 0; wc3->video_stream_index = wc3->audio_stream_index = 0; url_fseek(pb, 12, SEEK_CUR); fourcc_tag = get_le32(pb); size = (get_be32(pb) + 1) & (~1); do { switch (fourcc_tag) { case SOND_TAG: case INDX_TAG: url_fseek(pb, size, SEEK_CUR); break; case PC__TAG: url_fseek(pb, 8, SEEK_CUR); wc3->palette_count = get_le32(pb); if((unsigned)wc3->palette_count >= UINT_MAX / PALETTE_SIZE){ wc3->palette_count= 0; return -1; } wc3->palettes = av_malloc(wc3->palette_count * PALETTE_SIZE); break; case BNAM_TAG: buffer = av_malloc(size+1); if (!buffer) return AVERROR(ENOMEM); if ((ret = get_buffer(pb, buffer, size)) != size) return AVERROR(EIO); buffer[size] = 0; av_metadata_set2(&s->metadata, "title", buffer, AV_METADATA_DONT_STRDUP_VAL); break; case SIZE_TAG: wc3->width = get_le32(pb); wc3->height = get_le32(pb); break; case PALT_TAG: if ((unsigned)current_palette >= wc3->palette_count) return AVERROR_INVALIDDATA; if ((ret = get_buffer(pb, &wc3->palettes[current_palette * PALETTE_SIZE], PALETTE_SIZE)) != PALETTE_SIZE) return AVERROR(EIO); for (i = current_palette * PALETTE_SIZE; i < (current_palette + 1) * PALETTE_SIZE; i++) { wc3->palettes[i] = wc3_pal_lookup[wc3->palettes[i]]; } current_palette++; break; default: av_log(s, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n", (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24), (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24)); return AVERROR_INVALIDDATA; break; } fourcc_tag = get_le32(pb); size = (get_be32(pb) + 1) & (~1); if (url_feof(pb)) return AVERROR(EIO); } while (fourcc_tag != BRCH_TAG); st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, WC3_FRAME_FPS); wc3->video_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_XAN_WC3; st->codec->codec_tag = 0; st->codec->width = wc3->width; st->codec->height = wc3->height; st->codec->palctrl = &wc3->palette_control; st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, WC3_FRAME_FPS); wc3->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_PCM_S16LE; st->codec->codec_tag = 1; st->codec->channels = WC3_AUDIO_CHANNELS; st->codec->bits_per_coded_sample = WC3_AUDIO_BITS; st->codec->sample_rate = WC3_SAMPLE_RATE; st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample; st->codec->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS; return 0; }
1threat
Need CSS for half filled Circle (at the bottom) with border : <p>I have already refered to this url and tried to tweak it but wasn't able to get it to work. <a href="https://stackoverflow.com/questions/42514884/need-css-for-half-filled-circle-with-complete-border">Need css for half filled circle with complete border</a></p> <p>I need css for below style (bottom half of circle filled)</p> <p><a href="https://i.stack.imgur.com/cjcsW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cjcsW.png" alt="enter image description here"></a></p> <p>Please help! Thanks. </p>
0debug
Difference Between 2 dates in days in Double Android : I am working on an app and i need to get the difference between the actual date and a date inserted by the user, in days and in Double. Any ideia on how to make this? I've tried some things but without success.
0debug
How to split the Billion or million : I am looking for an algorithm which splits the input number to number of millions . suppose if the input number is 51000000 and my lot size is 50 million, then i want an output as 2. if 110 million, then it would be 50+50+10 which means output as 3. I tried a number of ways to calculate, but still i am unlucky , please give some clue on this
0debug
Xamarin Forms Image fill width with proper aspect : <p>Here is xaml (an image in stacklayout). Everything is logical: I set Aspect to AspectFit and HorizontalOptions to FillAndExpand. Width of image must fill the width of stacklayout. Height must be calculated in order to image Aspect.</p> <pre><code>&lt;Image BackgroundColor="Fuchsia" Aspect="AspectFit" Source="{Binding GroupLogo}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/&gt; </code></pre> <p>It fill the width but It doesn't want to draw image full width. Why?</p> <p><a href="https://i.stack.imgur.com/JwCiw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JwCiw.png" alt="enter image description here"></a></p>
0debug
static int img_map(int argc, char **argv) { int c; OutputFormat output_format = OFORMAT_HUMAN; BlockBackend *blk; BlockDriverState *bs; const char *filename, *fmt, *output; int64_t length; MapEntry curr = { .length = 0 }, next; int ret = 0; bool image_opts = false; fmt = NULL; output = NULL; for (;;) { int option_index = 0; static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"format", required_argument, 0, 'f'}, {"output", required_argument, 0, OPTION_OUTPUT}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "f:h", long_options, &option_index); if (c == -1) { break; } switch (c) { case '?': case 'h': help(); break; case 'f': fmt = optarg; break; case OPTION_OUTPUT: output = optarg; break; case OPTION_OBJECT: { QemuOpts *opts; opts = qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { return 1; } } break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != argc - 1) { error_exit("Expecting one image file name"); } filename = argv[optind]; if (output && !strcmp(output, "json")) { output_format = OFORMAT_JSON; } else if (output && !strcmp(output, "human")) { output_format = OFORMAT_HUMAN; } else if (output) { error_report("--output must be used with human or json as argument."); return 1; } if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { return 1; } blk = img_open(image_opts, filename, fmt, 0, false, false); if (!blk) { return 1; } bs = blk_bs(blk); if (output_format == OFORMAT_HUMAN) { printf("%-16s%-16s%-16s%s\n", "Offset", "Length", "Mapped to", "File"); } length = blk_getlength(blk); while (curr.start + curr.length < length) { int64_t nsectors_left; int64_t sector_num; int n; sector_num = (curr.start + curr.length) >> BDRV_SECTOR_BITS; nsectors_left = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE) - sector_num; n = MIN(1 << (30 - BDRV_SECTOR_BITS), nsectors_left); ret = get_block_status(bs, sector_num, n, &next); if (ret < 0) { error_report("Could not read file metadata: %s", strerror(-ret)); goto out; } if (entry_mergeable(&curr, &next)) { curr.length += next.length; continue; } if (curr.length > 0) { dump_map_entry(output_format, &curr, &next); } curr = next; } dump_map_entry(output_format, &curr, NULL); out: blk_unref(blk); return ret < 0; }
1threat
How to set different .entitlements file for different targets : <p>I have 2 targets - Dev &amp; Prod config with different capabilities (Apple Pay disabled for Prod)</p> <p>I already have separated Info.plist files with needed target But I couldn't do same for Proj.entitlements files - Target Membership section in Utilities menu disabled</p> <p>I set corresponding "Code Signing Entitlements" in Build Settings of each target, but still receiving "Provision Profile 'X' doesn't support 'X' capability" in General tab</p> <p>Is there any way to say XCode, that for this target he should look at connected .entitlements file?</p>
0debug
static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr, qemu_irq **irqs) { QemuOptsList *list; qemu_irq *mpic; DeviceState *dev = NULL; SysBusDevice *s; int i; mpic = g_new(qemu_irq, 256); if (kvm_enabled()) { bool irqchip_allowed = true, irqchip_required = false; list = qemu_find_opts("machine"); if (!QTAILQ_EMPTY(&list->head)) { irqchip_allowed = qemu_opt_get_bool(QTAILQ_FIRST(&list->head), "kernel_irqchip", true); irqchip_required = qemu_opt_get_bool(QTAILQ_FIRST(&list->head), "kernel_irqchip", false); } if (irqchip_allowed) { dev = ppce500_init_mpic_kvm(params, irqs); } if (irqchip_required && !dev) { fprintf(stderr, "%s: irqchip requested but unavailable\n", __func__); abort(); } } if (!dev) { dev = ppce500_init_mpic_qemu(params, irqs); } for (i = 0; i < 256; i++) { mpic[i] = qdev_get_gpio_in(dev, i); } s = SYS_BUS_DEVICE(dev); memory_region_add_subregion(ccsr, MPC8544_MPIC_REGS_OFFSET, s->mmio[0].memory); return mpic; }
1threat
static int pci_pbm_map_irq(PCIDevice *pci_dev, int irq_num) { int bus_offset; if (pci_dev->devfn & 1) bus_offset = 16; else bus_offset = 0; return (bus_offset + (PCI_SLOT(pci_dev->devfn) << 2) + irq_num) & 0x1f; }
1threat
Listen cmd.exe by external application : <p>ı want to listen cmd.exe with my own application. I want to this. my application is running someone write cmd.exe and press enter button, my application realize that and take this command. Please someone answer me.</p>
0debug
Can anybody help me out installing python 3.6.4 on windows 8.1 pro? : Python installed but all the required folders are missing on the python folder. can anybody please help me out.[enter image description here][1] [1]: https://i.stack.imgur.com/k3Ptq.png
0debug
static void usb_keyboard_class_initfn(ObjectClass *klass, void *data) { USBDeviceClass *uc = USB_DEVICE_CLASS(klass); uc->init = usb_keyboard_initfn; uc->product_desc = "QEMU USB Keyboard"; uc->usb_desc = &desc_keyboard; uc->handle_packet = usb_generic_handle_packet; uc->handle_reset = usb_hid_handle_reset; uc->handle_control = usb_hid_handle_control; uc->handle_data = usb_hid_handle_data; uc->handle_destroy = usb_hid_handle_destroy; }
1threat
how to generate random long int in c where every digit is non-zero? morever the random numbers are reapeting : I am making a library management in c for practice. Now, in studentEntry I need to generate a long int studentID in which every number is non-zero.So, I am using this function. long int generateStudentID(){ srand(time(NULL)); long int n = 0; do { n = rand() % 10; }while(n == 0); int i; for(i = 1; i < 10; i++) { n *= 10; n += rand() % 10; } if(n < 0) n = n * (-1); //StudentID will be positive return n; } ** - output <pre> Name : khushit phone No. : 987546321 active : 1 login : 0 StudentID : 2038393052 Wanted to add another student?(y/n) </pre> ** I wanted to remove all zeros from it.
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Simplest and quickest way to portray an application for development : <p>As a designer I sometimes feel the need to portray the main idea of an application in a graphical form like a flowchart. Something that is easy enough to understand for the development firms and could convey the purpose of the application and possibly the main features it needs to provide which they could ultimately use to reply back with recommendations, rough estimates and turn around times.</p> <p>The application will still be in the ideation phase so creating a prototype is an overkill. I could do it as a flowchart but I thought there should already be a conventional way professionals follow instead of going through meetings or typing up the details. </p> <p>How do you go about doing this? If flowchart is the way to go then what type of flowcharts work best here? I just need the initial direction so I could start my research. </p> <p>For example for an application with 3 different sets of dashboards for customers, providers and admins how can I demonstrate the rough logic that connects all functions between these 3 type of users?</p> <p>Thank you.</p>
0debug
static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) { SegmentContext *seg = s->priv_data; AVStream *st = s->streams[pkt->stream_index]; int64_t end_pts = INT64_MAX, offset; int start_frame = INT_MAX; int ret; struct tm ti; int64_t usecs; int64_t wrapped_val; if (!seg->avf) return AVERROR(EINVAL); calc_times: if (seg->times) { end_pts = seg->segment_count < seg->nb_times ? seg->times[seg->segment_count] : INT64_MAX; } else if (seg->frames) { start_frame = seg->segment_count < seg->nb_frames ? seg->frames[seg->segment_count] : INT_MAX; } else { if (seg->use_clocktime) { int64_t avgt = av_gettime(); time_t sec = avgt / 1000000; localtime_r(&sec, &ti); usecs = (int64_t)(ti.tm_hour * 3600 + ti.tm_min * 60 + ti.tm_sec) * 1000000 + (avgt % 1000000); wrapped_val = (usecs + seg->clocktime_offset) % seg->time; if (seg->last_cut != usecs && wrapped_val < seg->last_val && wrapped_val < seg->clocktime_wrap_duration) { seg->cut_pending = 1; seg->last_cut = usecs; } seg->last_val = wrapped_val; } else { end_pts = seg->time * (seg->segment_count + 1); } } ff_dlog(s, "packet stream:%d pts:%s pts_time:%s duration_time:%s is_key:%d frame:%d\n", pkt->stream_index, av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), av_ts2timestr(pkt->duration, &st->time_base), pkt->flags & AV_PKT_FLAG_KEY, pkt->stream_index == seg->reference_stream_index ? seg->frame_count : -1); if (pkt->stream_index == seg->reference_stream_index && (pkt->flags & AV_PKT_FLAG_KEY || seg->break_non_keyframes) && (seg->segment_frame_count > 0 || seg->write_empty) && (seg->cut_pending || seg->frame_count >= start_frame || (pkt->pts != AV_NOPTS_VALUE && av_compare_ts(pkt->pts, st->time_base, end_pts - seg->time_delta, AV_TIME_BASE_Q) >= 0))) { if (seg->cur_entry.last_duration == 0) seg->cur_entry.end_time = (double)pkt->pts * av_q2d(st->time_base); if ((ret = segment_end(s, seg->individual_header_trailer, 0)) < 0) goto fail; if ((ret = segment_start(s, seg->individual_header_trailer)) < 0) goto fail; seg->cut_pending = 0; seg->cur_entry.index = seg->segment_idx + seg->segment_idx_wrap * seg->segment_idx_wrap_nb; seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base); seg->cur_entry.start_pts = av_rescale_q(pkt->pts, st->time_base, AV_TIME_BASE_Q); seg->cur_entry.end_time = seg->cur_entry.start_time; if (seg->times || (!seg->frames && !seg->use_clocktime) && seg->write_empty) goto calc_times; } if (pkt->stream_index == seg->reference_stream_index) { if (pkt->pts != AV_NOPTS_VALUE) seg->cur_entry.end_time = FFMAX(seg->cur_entry.end_time, (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base)); seg->cur_entry.last_duration = pkt->duration; } if (seg->segment_frame_count == 0) { av_log(s, AV_LOG_VERBOSE, "segment:'%s' starts with packet stream:%d pts:%s pts_time:%s frame:%d\n", seg->avf->filename, pkt->stream_index, av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), seg->frame_count); } av_log(s, AV_LOG_DEBUG, "stream:%d start_pts_time:%s pts:%s pts_time:%s dts:%s dts_time:%s", pkt->stream_index, av_ts2timestr(seg->cur_entry.start_pts, &AV_TIME_BASE_Q), av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base)); offset = av_rescale_q(seg->initial_offset - (seg->reset_timestamps ? seg->cur_entry.start_pts : 0), AV_TIME_BASE_Q, st->time_base); if (pkt->pts != AV_NOPTS_VALUE) pkt->pts += offset; if (pkt->dts != AV_NOPTS_VALUE) pkt->dts += offset; av_log(s, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n", av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base)); ret = ff_write_chained(seg->avf, pkt->stream_index, pkt, s, seg->initial_offset || seg->reset_timestamps); fail: if (pkt->stream_index == seg->reference_stream_index) { seg->frame_count++; seg->segment_frame_count++; } return ret; }
1threat
How do I reduce a bidimensional array to unidimensional in python? : <p>I have an array a = [[1,1],[2,2],[3,3]]. How could I reduce it to b = [1,2,3]?</p>
0debug
static void cabac_init_decoder(HEVCContext *s) { GetBitContext *gb = &s->HEVClc->gb; skip_bits(gb, 1); align_get_bits(gb); ff_init_cabac_decoder(&s->HEVClc->cc, gb->buffer + get_bits_count(gb) / 8, (get_bits_left(gb) + 7) / 8); }
1threat
document.location = 'http://evil.com?username=' + user_input;
1threat
Cannot find SQL Instance name on network PC : <p>I have been facing this type of situation a dozen of times now and final want a permanent solution to it.</p> <h2>Problem</h2> <p>Cannot find Server PC's SQL Instance name on client PC.<br><br> <strong>Note</strong>:- I have installed SQL Express And Management Studio on both server and client<br> <strong>Server PC Name</strong> : M-PC<br> <strong>Server SQL Version</strong> : SQL Server 2008<br> <strong>Client PC Name</strong> : SHIVANG<br> <strong>Client SQL Version</strong> : SQL Server 2008<br><br> Client's PC SQL Server Screenshot <a href="https://i.stack.imgur.com/C2aLl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/C2aLl.png" alt=""></a></p> <h2>Solution that i have tried</h2> <p>1) <strong>Switching OFF firewall</strong> of both server and client PC completely (Domain, Private &amp; Public)<br> 2) Enabling and restarting the services : <strong>SQL Server</strong> and <strong>Browser Service</strong> <a href="https://i.stack.imgur.com/Utbsp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Utbsp.png" alt="enter image description here"></a> 3) Enabling SQL Network Configuration settings <a href="https://i.stack.imgur.com/SsPpD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SsPpD.png" alt="enter image description here"></a> 4) Also enabled "Allow remote connection" from SQL Server of both the PC<br> 5) Networking between both the PC is perfect can access files through network of both the PC.<br> 6) Even changed the IP configuration settings from obtain to static of both the PC (<em>IP of Server is 192.168.1.41 and IP of client is 192.168.1.44</em>) <a href="https://i.stack.imgur.com/RV4KT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RV4KT.png" alt="enter image description here"></a><br> 7) I have completely uninstalled SQL Express and Management Studio from client and server and installed it again.<br> 8) I also told my client to format the PC and then installed SQL Express and Management Studio. Still nothing.<br> 9) They don't have any antivirus on any of the system (to block the connection)<br></p> <h2>FUN PART</h2> <p>Now the fun part here is while i was fiddling with the settings of client and server PC. <strong>Server PC started showing the client PC SQL Instance while client PC was still unable to find the server SQL Instance</strong>.<br></p> <p>Below image is of Server PC's SQL Server<br> <a href="https://i.stack.imgur.com/nFxsA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nFxsA.png" alt="enter image description here"></a> Below image is of Client PC's SQL Server<br> <a href="https://i.stack.imgur.com/Asenp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Asenp.png" alt="enter image description here"></a></p> <p><br>Here are the following settings i have been fiddling with:-<br></p> <ol> <li>Changed IP from <strong><em>Obtain</em></strong> to <strong><em>Static</em></strong> of both the PC's (client and server)</li> <li>Changed the Protocol : TCP/IP of SQL of both the PC's (client and server) [sorry i forgot to get the screenshots of it and was fiddling with it even more when the server PC stopped showing the client's PC SQL Instance]<br><br></li> </ol> <p>Now i don't have a clue what to do next to solve this problem. Please help me if you can.<br><br></p> <p>Thanks in advance</p>
0debug
bool qpci_msix_pending(QPCIDevice *dev, uint16_t entry) { uint32_t pba_entry; uint8_t bit_n = entry % 32; void *addr = dev->msix_pba + (entry / 32) * PCI_MSIX_ENTRY_SIZE / 4; g_assert(dev->msix_enabled); pba_entry = qpci_io_readl(dev, addr); qpci_io_writel(dev, addr, pba_entry & ~(1 << bit_n)); return (pba_entry & (1 << bit_n)) != 0; }
1threat
how to convert dictionary to string : I want to convert below given dictionary to string in python. dict = {'LocalType': 'foreign local', 'LocalDialingPattern': '10', 'AreaCode': '971', 'OfficeCodeExpression': '98[35]', 'EnterpriseFilterExpression': '(AREA-CODE==971 AND OFFICE- CODE==98[35])', 'EnterpriseFilterGroup': '3', 'ExpressFilterExpression': 'rule 8 /^91\\(97198[35]\\)/ /\\1/', 'ExpressFilterGroup': '9719'}
0debug
static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) { uint64_t end = addr + len; if ((addr & 511) || len < 512) if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) < 0) { fprintf(stderr, "sd_blk_write: read error on host side\n"); return; } if (end > (addr & ~511) + 512) { memcpy(sd->buf + (addr & 511), sd->data, 512 - (addr & 511)); if (bdrv_write(sd->bdrv, addr >> 9, sd->buf, 1) < 0) { fprintf(stderr, "sd_blk_write: write error on host side\n"); return; } if (bdrv_read(sd->bdrv, end >> 9, sd->buf, 1) < 0) { fprintf(stderr, "sd_blk_write: read error on host side\n"); return; } memcpy(sd->buf, sd->data + 512 - (addr & 511), end & 511); if (bdrv_write(sd->bdrv, end >> 9, sd->buf, 1) < 0) { fprintf(stderr, "sd_blk_write: write error on host side\n"); } } else { memcpy(sd->buf + (addr & 511), sd->data, len); if (!sd->bdrv || bdrv_write(sd->bdrv, addr >> 9, sd->buf, 1) < 0) { fprintf(stderr, "sd_blk_write: write error on host side\n"); } } }
1threat
int pt_setxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size, int flags) { char *buffer; int ret; buffer = rpath(ctx, path); ret = lsetxattr(buffer, name, value, size, flags); g_free(buffer); return ret; }
1threat
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ int i; int w= s->width; int h= s->height; InternalBuffer *buf; int *picture_number; if(pic->data[0]!=NULL) { av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n"); return -1; } if(s->internal_buffer_count >= INTERNAL_BUFFER_SIZE) { av_log(s, AV_LOG_ERROR, "internal_buffer_count overflow (missing release_buffer?)\n"); return -1; } if(avcodec_check_dimensions(s,w,h)) return -1; if(s->internal_buffer==NULL){ s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer)); } #if 0 s->internal_buffer= av_fast_realloc( s->internal_buffer, &s->internal_buffer_size, sizeof(InternalBuffer)*FFMAX(99, s->internal_buffer_count+1) ); #endif buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; (*picture_number)++; if(buf->base[0]){ pic->age= *picture_number - buf->last_pic_num; buf->last_pic_num= *picture_number; }else{ int h_chroma_shift, v_chroma_shift; int pixel_size, size[3]; AVPicture picture; avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); if(!(s->flags&CODEC_FLAG_EMU_EDGE)){ w+= EDGE_WIDTH*2; h+= EDGE_WIDTH*2; } avpicture_fill(&picture, NULL, s->pix_fmt, w, h); pixel_size= picture.linesize[0]*8 / w; assert(pixel_size>=1); if(pixel_size == 3*8) w= ALIGN(w, STRIDE_ALIGN<<h_chroma_shift); else w= ALIGN(pixel_size*w, STRIDE_ALIGN<<(h_chroma_shift+3)) / pixel_size; size[1] = avpicture_fill(&picture, NULL, s->pix_fmt, w, h); size[0] = picture.linesize[0] * h; size[1] -= size[0]; if(picture.data[2]) size[1]= size[2]= size[1]/2; else size[2]= 0; buf->last_pic_num= -256*256*256*64; memset(buf->base, 0, sizeof(buf->base)); memset(buf->data, 0, sizeof(buf->data)); for(i=0; i<3 && size[i]; i++){ const int h_shift= i==0 ? 0 : h_chroma_shift; const int v_shift= i==0 ? 0 : v_chroma_shift; buf->linesize[i]= picture.linesize[i]; buf->base[i]= av_malloc(size[i]+16); if(buf->base[i]==NULL) return -1; memset(buf->base[i], 128, size[i]); if((s->flags&CODEC_FLAG_EMU_EDGE) || (s->pix_fmt == PIX_FMT_PAL8) || !size[2]) buf->data[i] = buf->base[i]; else buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), STRIDE_ALIGN); } pic->age= 256*256*256*64; } pic->type= FF_BUFFER_TYPE_INTERNAL; for(i=0; i<4; i++){ pic->base[i]= buf->base[i]; pic->data[i]= buf->data[i]; pic->linesize[i]= buf->linesize[i]; } s->internal_buffer_count++; return 0; }
1threat
static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int src_x_offset, int src_y_offset, qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op){ MpegEncContext * const s = &h->s; const int mx= h->mv_cache[list][ scan8[n] ][0] + src_x_offset*8; const int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8; const int luma_xy= (mx&3) + ((my&3)<<2); uint8_t * src_y = pic->data[0] + (mx>>2) + (my>>2)*s->linesize; uint8_t * src_cb= pic->data[1] + (mx>>3) + (my>>3)*s->uvlinesize; uint8_t * src_cr= pic->data[2] + (mx>>3) + (my>>3)*s->uvlinesize; int extra_width= (s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16; int extra_height= extra_width; int emu=0; const int full_mx= mx>>2; const int full_my= my>>2; const int pic_width = 16*s->mb_width; const int pic_height = 16*s->mb_height; assert(pic->data[0]); if(mx&7) extra_width -= 3; if(my&7) extra_height -= 3; if( full_mx < 0-extra_width || full_my < 0-extra_height || full_mx + 16 > pic_width + extra_width || full_my + 16 > pic_height + extra_height){ ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5, full_mx-2, full_my-2, pic_width, pic_height); src_y= s->edge_emu_buffer + 2 + 2*s->linesize; emu=1; } qpix_op[luma_xy](dest_y, src_y, s->linesize); if(!square){ qpix_op[luma_xy](dest_y + delta, src_y + delta, s->linesize); } if(s->flags&CODEC_FLAG_GRAY) return; if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, s->uvlinesize, 9, 9, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); src_cb= s->edge_emu_buffer; } chroma_op(dest_cb, src_cb, s->uvlinesize, chroma_height, mx&7, my&7); if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, s->uvlinesize, 9, 9, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); src_cr= s->edge_emu_buffer; } chroma_op(dest_cr, src_cr, s->uvlinesize, chroma_height, mx&7, my&7); }
1threat
How to put a 2 array in config (.ini) file? : <p>I have this simple basic code of VBScript.</p> <pre class="lang-js prettyprint-override"><code>Dim cars: cars = Array("Volvo", "Saab", "BMW") Dim fruits: fruits = Array("Apple", "Orange", "Banana") Dim i: i = 0 For i = 0 To UBound(cars) Call Response.Write(cars(i) &amp; " " &amp; fruits(i)) Next </code></pre> <p>Output:</p> <pre class="lang-js prettyprint-override"><code>Volvo Apple Saab Orange BMW Banana </code></pre> <p>I want to put all the variables in a config <strong>.ini file</strong> in a way that the array variable is still in match. (e.g. <strong>Volvo</strong> and <strong>Apple</strong> for <strong>Volvo Apple</strong>) Anyone know or have an idea to do it? </p> <p>I tried to search for this on the internet but no topic for this one. A big appreciation for the answer.</p>
0debug
static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOSerial *vser = VIRTIO_SERIAL(dev); QLIST_REMOVE(vser, next); g_free(vser->ivqs); g_free(vser->ovqs); g_free(vser->ports_map); if (vser->post_load) { g_free(vser->post_load->connected); timer_del(vser->post_load->timer); timer_free(vser->post_load->timer); g_free(vser->post_load); } virtio_cleanup(vdev); }
1threat
How do I deploy my docker-compose project using Terraform? : <p>I've looked all over and can't find a coherent resource that describes how to do this straightforwardly. I have a project like so:</p> <pre><code>./ |-src/ |--.. |--Dockerfile |-docker-compose.yaml </code></pre> <p>A terraform config file like this:</p> <pre><code>variable "do_token" {} # Configure the DigitalOcean Provider provider "digitalocean" { token = "${var.do_token}" } # Create a web server resource "digitalocean_droplet" "web" { # ... } </code></pre> <p>I want to be able to do something like</p> <pre><code>provider "digitalocean" { ip = &lt;my-ip&gt; # docker-compose up ? } </code></pre> <p>My compose file sets up the application architecture properly. I just want a way to deploy that to a given box somewhere on digital ocean (via ip preferably) and the run <code>docker-compose up</code>. How can I do this?</p>
0debug
Error in C program, using VS2017 for the first time : <p>I getting code 0 error while compiling very simple code. How do I solve it? I using VS 2017 for the first time. </p> <pre><code>#include &lt;stdio.h&gt; void main() { printf("My name is Haim"); } </code></pre> <p><img src="https://i.ibb.co/wKsfMhp/haim.jpg" alt="a busy cat"></p> <p>The two rows in the middle are not supposed to be there!</p> <p>Haim</p>
0debug
static av_cold int seqvideo_decode_init(AVCodecContext *avctx) { SeqVideoContext *seq = avctx->priv_data; seq->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; seq->frame.data[0] = NULL; return 0; }
1threat
static void platform_mmio_write(ReadWriteHandler *handler, pcibus_t addr, uint32_t val, int len) { DPRINTF("Warning: attempted write of 0x%x to physical " "address 0x" TARGET_FMT_plx " in xen platform mmio space\n", val, addr); }
1threat
size_t v9fs_unmarshal(struct iovec *out_sg, int out_num, size_t offset, int bswap, const char *fmt, ...) { int i; va_list ap; size_t old_offset = offset; va_start(ap, fmt); for (i = 0; fmt[i]; i++) { switch (fmt[i]) { case 'b': { uint8_t *valp = va_arg(ap, uint8_t *); offset += v9fs_unpack(valp, out_sg, out_num, offset, sizeof(*valp)); break; } case 'w': { uint16_t val, *valp; valp = va_arg(ap, uint16_t *); offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); if (bswap) { *valp = le16_to_cpu(val); } else { *valp = val; } break; } case 'd': { uint32_t val, *valp; valp = va_arg(ap, uint32_t *); offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); if (bswap) { *valp = le32_to_cpu(val); } else { *valp = val; } break; } case 'q': { uint64_t val, *valp; valp = va_arg(ap, uint64_t *); offset += v9fs_unpack(&val, out_sg, out_num, offset, sizeof(val)); if (bswap) { *valp = le64_to_cpu(val); } else { *valp = val; } break; } case 's': { V9fsString *str = va_arg(ap, V9fsString *); offset += v9fs_unmarshal(out_sg, out_num, offset, bswap, "w", &str->size); str->data = g_malloc(str->size + 1); offset += v9fs_unpack(str->data, out_sg, out_num, offset, str->size); str->data[str->size] = 0; break; } case 'Q': { V9fsQID *qidp = va_arg(ap, V9fsQID *); offset += v9fs_unmarshal(out_sg, out_num, offset, bswap, "bdq", &qidp->type, &qidp->version, &qidp->path); break; } case 'S': { V9fsStat *statp = va_arg(ap, V9fsStat *); offset += v9fs_unmarshal(out_sg, out_num, offset, bswap, "wwdQdddqsssssddd", &statp->size, &statp->type, &statp->dev, &statp->qid, &statp->mode, &statp->atime, &statp->mtime, &statp->length, &statp->name, &statp->uid, &statp->gid, &statp->muid, &statp->extension, &statp->n_uid, &statp->n_gid, &statp->n_muid); break; } case 'I': { V9fsIattr *iattr = va_arg(ap, V9fsIattr *); offset += v9fs_unmarshal(out_sg, out_num, offset, bswap, "ddddqqqqq", &iattr->valid, &iattr->mode, &iattr->uid, &iattr->gid, &iattr->size, &iattr->atime_sec, &iattr->atime_nsec, &iattr->mtime_sec, &iattr->mtime_nsec); break; } default: break; } } va_end(ap); return offset - old_offset; }
1threat
How can I make timer for my game in c++ which works every 30 seconds? : <p>I want to add timer in my game.it works every 30 seconds and after any 30 seconds it should start another 30 seconds. Every player have 30 sec to play his turn and when it finished he just has 3 pack of 30 seconds to use them for playing his turn.If his packs are finished, it's the turn f another player. I don't have any idea of it, I don't know how to make timer in c or c++.</p>
0debug
c client socket program that transmits 10-digit to a server : I need to approximate e using the series: e= 1+ 1/1! +1/2!+..+1/n! which n=100000 this is what i did, but it refused to compile.. public class Test { public static void main(String args[]) { long e = 0; for (int i = 1; i <= 100000; i++) { e += 1.0 / factorial(i); } System.out.println(e); } public static long factorial(long number) { if (number <= 1) return 1; else return number * factorial(number - 1); } }
0debug
What's the difference between "c&&c" and "[c&&c]" in Java's regular expressions? : <p>With this call,</p> <pre><code>System.out.println(Pattern.matches("[c&amp;&amp;c]", "c")); </code></pre> <p>I got <code>true</code>. However, with this call,</p> <pre><code>System.out.println(Pattern.matches("c&amp;&amp;c", "c")); </code></pre> <p>I got <code>false</code>. The second call does not get any exceptions thrown, which means it's a valid regular expression. <strong>However, I'm not sure that's acceptable because, in Java API, the operator <code>&amp;&amp;</code> seems to only occur between brackets.</strong> Then, what's the meaning of <code>&amp;&amp;</code> in the second call?</p>
0debug
opneUrl react-native linking call, mailto : <p>I am trying to open a url ( "tel:061245124" or "mailto:test@test.com") and it says that i can handle url, also tried without the tel: or mail to but it crashes with a red screen. Urls like "<a href="http://test.com" rel="noreferrer">http://test.com</a>" work. What am I doing wrong?</p> <pre><code> handlePress(url) { console.tron.log('Trying to access url') console.tron.log(url) Linking.canOpenURL(url).then(supported =&gt; { if (!supported) { console.tron.log('Can\'t handle url: ' + url) } else { return Linking.openURL(url) } }).catch(err =&gt; console.error('An error occurred', err)) } </code></pre>
0debug
static void floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc, PutBitContext *pb, uint16_t *posts, float *floor, int samples) { int range = 255 / fc->multiplier + 1; int coded[MAX_FLOOR_VALUES]; int i, counter; put_bits(pb, 1, 1); put_bits(pb, ilog(range - 1), posts[0]); put_bits(pb, ilog(range - 1), posts[1]); coded[0] = coded[1] = 1; for (i = 2; i < fc->values; i++) { int predicted = render_point(fc->list[fc->list[i].low].x, posts[fc->list[i].low], fc->list[fc->list[i].high].x, posts[fc->list[i].high], fc->list[i].x); int highroom = range - predicted; int lowroom = predicted; int room = FFMIN(highroom, lowroom); if (predicted == posts[i]) { coded[i] = 0; continue; } else { if (!coded[fc->list[i].low ]) coded[fc->list[i].low ] = -1; if (!coded[fc->list[i].high]) coded[fc->list[i].high] = -1; } if (posts[i] > predicted) { if (posts[i] - predicted > room) coded[i] = posts[i] - predicted + lowroom; else coded[i] = (posts[i] - predicted) << 1; } else { if (predicted - posts[i] > room) coded[i] = predicted - posts[i] + highroom - 1; else coded[i] = ((predicted - posts[i]) << 1) - 1; } } counter = 2; for (i = 0; i < fc->partitions; i++) { vorbis_enc_floor_class * c = &fc->classes[fc->partition_to_class[i]]; int k, cval = 0, csub = 1<<c->subclass; if (c->subclass) { vorbis_enc_codebook * book = &venc->codebooks[c->masterbook]; int cshift = 0; for (k = 0; k < c->dim; k++) { int l; for (l = 0; l < csub; l++) { int maxval = 1; if (c->books[l] != -1) maxval = venc->codebooks[c->books[l]].nentries; if (coded[counter + k] < maxval) break; } assert(l != csub); cval |= l << cshift; cshift += c->subclass; } put_codeword(pb, book, cval); } for (k = 0; k < c->dim; k++) { int book = c->books[cval & (csub-1)]; int entry = coded[counter++]; cval >>= c->subclass; if (book == -1) continue; if (entry == -1) entry = 0; put_codeword(pb, &venc->codebooks[book], entry); } } ff_vorbis_floor1_render_list(fc->list, fc->values, posts, coded, fc->multiplier, floor, samples); }
1threat
static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is64) { TCGReg datalo, datahi, addrlo; TCGReg addrhi __attribute__((unused)); TCGMemOpIdx oi; TCGMemOp opc; #if defined(CONFIG_SOFTMMU) int mem_index; TCGMemOp s_bits; tcg_insn_unit *label_ptr[2]; #endif datalo = *args++; datahi = (TCG_TARGET_REG_BITS == 32 && is64 ? *args++ : 0); addrlo = *args++; addrhi = (TARGET_LONG_BITS > TCG_TARGET_REG_BITS ? *args++ : 0); oi = *args++; opc = get_memop(oi); #if defined(CONFIG_SOFTMMU) mem_index = get_mmuidx(oi); s_bits = opc & MO_SIZE; tcg_out_tlb_load(s, addrlo, addrhi, mem_index, s_bits, label_ptr, offsetof(CPUTLBEntry, addr_read)); tcg_out_qemu_ld_direct(s, datalo, datahi, TCG_REG_L1, -1, 0, 0, opc); add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, s->code_ptr, label_ptr); #else { int32_t offset = GUEST_BASE; TCGReg base = addrlo; int index = -1; int seg = 0; if (GUEST_BASE == 0 || guest_base_flags) { seg = guest_base_flags; offset = 0; if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { seg |= P_ADDR32; } } else if (TCG_TARGET_REG_BITS == 64) { if (TARGET_LONG_BITS == 32) { tcg_out_ext32u(s, TCG_REG_L0, base); base = TCG_REG_L0; } if (offset != GUEST_BASE) { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_L1, GUEST_BASE); index = TCG_REG_L1; offset = 0; } } tcg_out_qemu_ld_direct(s, datalo, datahi, base, index, offset, seg, opc); } #endif }
1threat
ANDROID STUDIO CARD VIEW : WHEN EVER I TRIED TO ADD DEPENDENCIES FOR CARD VIEW ANDROID STUDIO IS SHOWING FOLLOWING ERROR **[**> Error:Execution failed for task ':app:processDebugManifest'. > > Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from > \[com.android.support:design:25.3.1\] AndroidManifest.xml:27:9-31 is > also present at \[com.android.support:cardview-v7:26.0.0-alpha1\] > AndroidManifest.xml:24:9-38 value=(26.0.0-alpha1). Suggestion: add > 'tools:replace="android:value"' to <meta-data> element at > AndroidManifest.xml:25:5-27:34 to override.**][1]** [1]: https://i.stack.imgur.com/UoSiO.png
0debug
static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { A64Context *c = avctx->priv_data; AVFrame *const p = (AVFrame *) & c->picture; int frame; int x, y; int b_height; int b_width; int req_size, ret; uint8_t *buf; int *charmap = c->mc_charmap; uint8_t *colram = c->mc_colram; uint8_t *charset = c->mc_charset; int *meta = c->mc_meta_charset; int *best_cb = c->mc_best_cb; int charset_size = 0x800 * (INTERLACED + 1); int colram_size = 0x100 * c->mc_use_5col; int screen_size; if(CROP_SCREENS) { b_height = FFMIN(avctx->height,C64YRES) >> 3; b_width = FFMIN(avctx->width ,C64XRES) >> 3; screen_size = b_width * b_height; } else { b_height = C64YRES >> 3; b_width = C64XRES >> 3; screen_size = 0x400; } if (!pict) { if (!c->mc_lifetime) return 0; if (!c->mc_frame_counter) { c->mc_lifetime = 0; } else c->mc_lifetime = c->mc_frame_counter; } else { if (c->mc_frame_counter < c->mc_lifetime) { *p = *pict; p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; to_meta_with_crop(avctx, p, meta + 32000 * c->mc_frame_counter); c->mc_frame_counter++; if (c->next_pts == AV_NOPTS_VALUE) c->next_pts = pict->pts; return 0; } } if (c->mc_frame_counter == c->mc_lifetime) { req_size = 0; if (c->mc_lifetime) { req_size = charset_size + c->mc_lifetime*(screen_size + colram_size); if ((ret = ff_alloc_packet(pkt, req_size)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", req_size); return ret; } buf = pkt->data; ff_init_elbg(meta, 32, 1000 * c->mc_lifetime, best_cb, CHARSET_CHARS, 50, charmap, &c->randctx); ff_do_elbg (meta, 32, 1000 * c->mc_lifetime, best_cb, CHARSET_CHARS, 50, charmap, &c->randctx); render_charset(avctx, charset, colram); memcpy(buf, charset, charset_size); buf += charset_size; charset += charset_size; } for (frame = 0; frame < c->mc_lifetime; frame++) { for (y = 0; y < b_height; y++) { for (x = 0; x < b_width; x++) { buf[y * b_width + x] = charmap[y * b_width + x]; } } buf += screen_size; req_size += screen_size; if (c->mc_use_5col) { a64_compress_colram(buf, charmap, colram); buf += colram_size; req_size += colram_size; } charmap += 1000; } AV_WB32(avctx->extradata + 4, c->mc_frame_counter); AV_WB32(avctx->extradata + 8, charset_size); AV_WB32(avctx->extradata + 12, screen_size + colram_size); c->mc_frame_counter = 0; pkt->pts = pkt->dts = c->next_pts; c->next_pts = AV_NOPTS_VALUE; pkt->size = req_size; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = !!req_size; } return 0; }
1threat
void cpu_loop(CPUUniCore32State *env) { CPUState *cs = CPU(uc32_env_get_cpu(env)); int trapnr; unsigned int n, insn; target_siginfo_t info; for (;;) { cpu_exec_start(cs); trapnr = uc32_cpu_exec(cs); cpu_exec_end(cs); switch (trapnr) { case UC32_EXCP_PRIV: { get_user_u32(insn, env->regs[31] - 4); n = insn & 0xffffff; if (n >= UC32_SYSCALL_BASE) { n -= UC32_SYSCALL_BASE; if (n == UC32_SYSCALL_NR_set_tls) { cpu_set_tls(env, env->regs[0]); env->regs[0] = 0; } else { env->regs[0] = do_syscall(env, n, env->regs[0], env->regs[1], env->regs[2], env->regs[3], env->regs[4], env->regs[5], 0, 0); } } else { goto error; } } break; case UC32_EXCP_DTRAP: case UC32_EXCP_ITRAP: info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; info.si_code = TARGET_SEGV_MAPERR; info._sifields._sigfault._addr = env->cp0.c4_faultaddr; queue_signal(env, info.si_signo, &info); break; case EXCP_INTERRUPT: break; case EXCP_DEBUG: { int sig; sig = gdb_handlesig(cs, TARGET_SIGTRAP); if (sig) { info.si_signo = sig; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; queue_signal(env, info.si_signo, &info); } } break; default: goto error; } process_pending_signals(env); } error: fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr); cpu_dump_state(cs, stderr, fprintf, 0); abort(); }
1threat
How to select and order multiple columns in a Pyspark Dataframe after a join : <p>I want to select multiple columns from existing dataframe (which is created after joins) and would like to order the fileds as my target table structure. How can it be done ? The approached I have used is below. Here I am able to select the necessary columns required but not able to make in sequence.</p> <pre><code>Required (Target Table structure) : hist_columns = ("acct_nbr","account_sk_id", "zip_code","primary_state", "eff_start_date" ,"eff_end_date","eff_flag") account_sk_df = hist_process_df.join(broadcast(df_sk_lkp) ,'acct_nbr','inner' ) account_sk_df_ld = account_sk_df.select([c for c in account_sk_df.columns if c in hist_columns]) &gt;&gt;&gt; account_sk_df DataFrame[acct_nbr: string, primary_state: string, zip_code: string, eff_start_date: string, eff_end_date: string, eff_flag: string, hash_sk_id: string, account_sk_id: int] &gt;&gt;&gt; account_sk_df_ld DataFrame[acct_nbr: string, primary_state: string, zip_code: string, eff_start_date: string, eff_end_date: string, eff_flag: string, account_sk_id: int] </code></pre> <p>The account_sk_id need to be in 2nd place. What's the best way to do this ?</p>
0debug
Git LFS refused to track my large files properly, until I did the following : <h1>Problem</h1> <p>I had troubles trying to use <a href="https://git-lfs.github.com/" rel="noreferrer">git LFS</a>, despite the many suggestions here on SO, on Git and GitHub's documentation, and on some Gists I'd run across.</p> <p>My problem was as follows:</p> <p>After performing the necessary steps:</p> <pre><code>git lfs install git lfs track "&lt;file of interest&gt;" git commit </code></pre> <p>I would still not have any files being tracked. If I performed</p> <pre><code>git lfs ls-files </code></pre> <p>it would be blank. If I went ahead &amp; performed the push, the transaction would fail, saying that the files are too large. (As expected, but I was desperate.)</p>
0debug
static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; int stride = _stride/sizeof(pixel); const pixel4 a= ((pixel4*)(src-stride))[0]; ((pixel4*)(src+0*stride))[0]= a; ((pixel4*)(src+1*stride))[0]= a; ((pixel4*)(src+2*stride))[0]= a; ((pixel4*)(src+3*stride))[0]= a; }
1threat
Parsing JSON encoded PHP array with Javascript - unexpected character : <p>I'm using PHP to encode array to JSON string like this:</p> <pre><code>$price['price'] = "20"; $price = json_encode($price) return $price; </code></pre> <p>so when I'm accessing the script I get this data:</p> <pre><code>{"price":"20"} </code></pre> <p>Here is my jQuery/Javascript code:</p> <pre><code>$("#form_pickupDate_day").change(function() { var frm = $(document.form); var data = JSON.stringify(frm.serializeArray()); $.ajax ({ method: "POST", url: "script.php", data: {json : data }, dataType: 'json', cache: false, success: function(json) { var obj = JSON.parse(json); $("#form_price").val(obj.price); } }); }); </code></pre> <p>The error I get in Firefox:</p> <pre><code>SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data </code></pre>
0debug
static void qemu_rdma_cleanup(RDMAContext *rdma) { struct rdma_cm_event *cm_event; int ret, idx; if (rdma->cm_id && rdma->connected) { if (rdma->error_state) { RDMAControlHeader head = { .len = 0, .type = RDMA_CONTROL_ERROR, .repeat = 1, }; error_report("Early error. Sending error."); qemu_rdma_post_send_control(rdma, NULL, &head); } ret = rdma_disconnect(rdma->cm_id); if (!ret) { trace_qemu_rdma_cleanup_waiting_for_disconnect(); ret = rdma_get_cm_event(rdma->channel, &cm_event); if (!ret) { rdma_ack_cm_event(cm_event); } } trace_qemu_rdma_cleanup_disconnect(); rdma->connected = false; } g_free(rdma->block); rdma->block = NULL; for (idx = 0; idx < RDMA_WRID_MAX; idx++) { if (rdma->wr_data[idx].control_mr) { rdma->total_registrations--; ibv_dereg_mr(rdma->wr_data[idx].control_mr); } rdma->wr_data[idx].control_mr = NULL; } if (rdma->local_ram_blocks.block) { while (rdma->local_ram_blocks.nb_blocks) { rdma_delete_block(rdma, rdma->local_ram_blocks.block->offset); } } if (rdma->cq) { ibv_destroy_cq(rdma->cq); rdma->cq = NULL; } if (rdma->comp_channel) { ibv_destroy_comp_channel(rdma->comp_channel); rdma->comp_channel = NULL; } if (rdma->pd) { ibv_dealloc_pd(rdma->pd); rdma->pd = NULL; } if (rdma->listen_id) { rdma_destroy_id(rdma->listen_id); rdma->listen_id = NULL; } if (rdma->cm_id) { if (rdma->qp) { rdma_destroy_qp(rdma->cm_id); rdma->qp = NULL; } rdma_destroy_id(rdma->cm_id); rdma->cm_id = NULL; } if (rdma->channel) { rdma_destroy_event_channel(rdma->channel); rdma->channel = NULL; } g_free(rdma->host); rdma->host = NULL; }
1threat
Difference for spring-boot-starter-web and spring-boot-starter-data-rest for REST APIs : <p>I'm trying to figure out the best practise in Spring to develop a REST API.</p> <p>I found those two packages and as far as I understand the difference between them is:</p> <ul> <li>web supports other things on top of REST API</li> <li>web manages resource access via controllers</li> <li>data-rest manages resource access via the repository</li> </ul> <p>Is there anything that I'm missing? Most examples are on top of web so I wonder what decisions points would lead me to favor one over the other in my app.</p>
0debug
SQL : Conversion failed when converting date and/or time from character string : I am working with data stored in SQL and I am having troubles inserting NULLS into a DATETIME Column. Ideas?
0debug
I am trying to do inheritance in java and the extra varaibles that are outside the inheritance class aren't being shown when I display : Inheritance is not completely working for me as the extra variables outside the inhertance class are not being displayed. When I input the employee details and input the wage it is accepted. But then it is not shown when I list all employees in database or when searching for an employee public class Employee extends Person{ public Employee(){ } public Employee (int id, int wage, String name, String surname ){ super(id,name,surname); this.wage= wage; } private int wage; public void SetWage(int wg){ wage=wg; } public int GetWage (){ return wage; } public String toString(){ return "ID: " + this.GetId() + "\nName:" + this.GetName() + "\nSurname:" + this.GetSurname() + "Wage: " + this.GetWage(); } } Similairly the client class is not working. Also here is the code for the person class public class Person{ public Person(){ pId = 0; pName = ""; pSurname = ""; } public Person (int id, String nm, String sn ){ pId = id; pName = nm; pSurname = sn; } private int pId; private String pName; private String pSurname; public int GetId(){ return pId; } public void SetId(int id){ pId= id; } public String GetName(){ return pName; } public void SetName(String nm){ pName = nm; } public String GetSurname (){ return pSurname; } public void SetSurname(String sn){ pSurname = sn ; } public String ToString(){ return "ID: " + this.GetId() + "\nName:" + this.GetName() + "\nSurname:" + this.GetSurname(); } } Any suggestions?
0debug
What is the difference in floor function and truncate function? : <p>What is the difference between Math.Floor() and Math.Truncate() in .NET?</p> <p>For example, Math.Floor(4.4) = 4 Math.Truncate(4.4) = 4.</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
Write json object to .json file in javascirpt : var proj = { Name : "abc", Roll no : 123 }; How write proj data in json format in .json file in javascript ?
0debug
C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS : <p>I want to solve this problem without "#pragma warning (disable:4996)" please help me. I tried many things. I think it may have problem with visual studio.</p>
0debug
How easy to learn flex for a java developer : <p>Is flex similar to java programming model? How easy for a java developer to learn flex? Please suggest.</p>
0debug
How to fix string index out of rang on python : my code is [enter image description here][1] [1]: https://i.stack.imgur.com/IEkib.png im trying to convert the random integer used in line 13 into a string so that it can be encrypted, but it keeps saying string index out of rang on python plz help. code on the latest version of python
0debug
Hello. I am working at a vending machine software. I cannot get the if statement to work. It just simply ignores it : // Program.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int main() { char number; cout << "Hello. Please choose a drink type ! \n\n1.Coca-Cola \n2.Coca-Cola ZERO \n3.Pepsi\n" ; cin >> number; if (number == 1) cout << "Please tip in 8$"; }
0debug
static pxa2xx_timer_info *pxa2xx_timer_init(target_phys_addr_t base, qemu_irq *irqs) { int i; int iomemtype; pxa2xx_timer_info *s; s = (pxa2xx_timer_info *) qemu_mallocz(sizeof(pxa2xx_timer_info)); s->base = base; s->irq_enabled = 0; s->oldclock = 0; s->clock = 0; s->lastload = qemu_get_clock(vm_clock); s->reset3 = 0; for (i = 0; i < 4; i ++) { s->timer[i].value = 0; s->timer[i].irq = irqs[i]; s->timer[i].info = s; s->timer[i].num = i; s->timer[i].level = 0; s->timer[i].qtimer = qemu_new_timer(vm_clock, pxa2xx_timer_tick, &s->timer[i]); } iomemtype = cpu_register_io_memory(0, pxa2xx_timer_readfn, pxa2xx_timer_writefn, s); cpu_register_physical_memory(base, 0x00000fff, iomemtype); register_savevm("pxa2xx_timer", 0, 0, pxa2xx_timer_save, pxa2xx_timer_load, s); return s; }
1threat
TypeScript: Specify a directory to look for module type definitions : <p>Heyho,</p> <p>I want to use some javascript libraries in my typescript code for which there are no typings in npm. So I wrote the typings myself and put them in a <code>definitions</code> directory in my source tree. However, I could not get typescript to look in that directory for those modules.</p> <p>My directory structure looks like this:</p> <pre><code>+-node_modules | | | +-moduleA | | | +-moduleB | +-src | | | +-definitions | | | | | +-moduleA.d.ts | | | | | +-moduleB.d.ts | | | +-ts | | | + ... all typescript code ... | +-tsconfig.json </code></pre> <p>I tried including the modules in the <code>definitions</code>-directory using </p> <ul> <li><code>include</code></li> <li><code>files</code></li> <li><code>typeRoots</code></li> <li><code>paths</code></li> </ul> <p>However none of it worked.</p> <p>Can somebody tell me, how to get typescript to include those typings?</p> <p>PS: Why is the TypeScript module handling so complicated???</p>
0debug
sqlException was unhandled by user code incorrect syntax near ',' please help me dears : > using System; > using System.Collections; > using System.Configuration; > using System.Data; > using System.Web; > using System.Web.Security; > using System.Web.UI; > using System.Web.UI.HtmlControls; > using System.Web.UI.WebControls; > using System.Web.UI.WebControls.WebParts; > using System.Data.SqlClient; > > > public partial class Student_InsertStudentDeta : System.Web.UI.Page > { > protected void Page_Load(object sender, EventArgs e) > { > lblMsg.Visible = false; > > } > protected void btnSave_Click(object sender, EventArgs e) > { > btnDelete.Enabled = false; > btnFindValuse.Enabled = false; > btnUpdate.Enabled = false; > > > > SqlConnection connection = new SqlConnection(); > connection.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; > connection.Open(); > > > SqlCommand cmd = new SqlCommand("Insert into MoHE_Student values (N'" + txtName.Text + "',N'" + txtSureName.Text + "',N'" + > txtFatherName.Text + "',N'" + txtGFatherName.Text + "',N'" + > txtBirthYear.Text + "',N'" + txtNIDC.Text + "',N'" + txtTabdily.Text + > "',N'" + txtTitalMonugraf.Text + "',N'" + > ddlJeldBook.SelectedItem.Text + "',N'" + txtDescription.Text + "',N'" > + ddlUniversity.SelectedItem.Value + "',N'" + ddlFaculty.SelectedItem.Value + "',N'" + > ddlDepartment.SelectedItem.Value + "'," + txtStudentRegBook.Text + "," > + txtPageBook.Text + "," + ddlReciveBook.SelectedItem.Text + "," + txtGraduateYear.Text + "," + txtRegYear.Text + ",N'" + > ddlKoncurExam.SelectedItem.Text + "',N'" + > ddlDefaMonugraf.SelectedItem.Text + "',N'" + > ddlYearDefa.SelectedItem.Text + "',N'" + > ddlMonthDefa.SelectedItem.Text + "',N'" + ddlDayDefa.SelectedItem.Text > + "',N'" + ddlTakeDiplom.SelectedItem.Text + "',N'" + txtPhonNum.Text + "',N'" + ddlGender.SelectedItem.Text + "',N'" + ddlDarajaTahsili.SelectedItem.Text + "',N'" + User.Identity.Name + > "')", connection); > > **cmd.ExecuteNonQuery();** //ERROR IS HERE
0debug
Python - I'm getting a error saying 'can't assign to literal' : I'm trying to get this procedure check whether the user lands on a treasure square and if they do they get gold. Also the treasure can only be landed on 3 times until it turns into a bandit, therefore after each time the player lands on it the tiles name changes, to T2, T3, B. Whenever i attempt to run my code a error appear saying 'can't assign to literal' This is my code: [1]: https://i.stack.imgur.com/uxg51.png If anybody could help out i'd be grateful.
0debug
def swap_numbers(a,b): temp = a a = b b = temp return (a,b)
0debug
static av_cold int peak_init_writer(AVFormatContext *s) { WAVMuxContext *wav = s->priv_data; AVCodecContext *enc = s->streams[0]->codec; if (enc->codec_id != AV_CODEC_ID_PCM_S8 && enc->codec_id != AV_CODEC_ID_PCM_S16LE && enc->codec_id != AV_CODEC_ID_PCM_U8 && enc->codec_id != AV_CODEC_ID_PCM_U16LE) { av_log(s, AV_LOG_ERROR, "%s codec not supported for Peak Chunk\n", s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : "NONE"); return -1; } wav->peak_bps = av_get_bits_per_sample(enc->codec_id) / 8; if (wav->peak_bps == 1 && wav->peak_format == PEAK_FORMAT_UINT16) { av_log(s, AV_LOG_ERROR, "Writing 16 bit peak for 8 bit audio does not make sense\n"); return AVERROR(EINVAL); } wav->peak_maxpos = av_mallocz(enc->channels * sizeof(*wav->peak_maxpos)); if (!wav->peak_maxpos) goto nomem; wav->peak_maxneg = av_mallocz(enc->channels * sizeof(*wav->peak_maxneg)); if (!wav->peak_maxneg) goto nomem; wav->peak_output = av_malloc(PEAK_BUFFER_SIZE); if (!wav->peak_output) goto nomem; wav->peak_outbuf_size = PEAK_BUFFER_SIZE; return 0; nomem: av_log(s, AV_LOG_ERROR, "Out of memory\n"); peak_free_buffers(s); return AVERROR(ENOMEM); }
1threat
how to find the probability of each class respect to test data? : Here I am using naive bayse classifier, how to find the probability of each class respect to each test data set? #Import Library of Gaussian Naive Bayes model from sklearn.naive_bayes import GaussianNB import numpy as np #assigning predictor and target variables x= np.array([[-3,7],[1,5], [1,2], [-2,0], [2,3], [-4,0], [-1,1], [1,1], [-2,2], [2,7], [-4,1], [-2,7]]) y = np.array([3, 3, 3, 3, 4, 3, 3, 4, 3, 4, 4, 4]) #Create a Gaussian Classifier model = GaussianNB() # Train the model using the training sets model.fit(x, y) #Predict Output predicted= model.predict([[1,2],[3,4]]) print(predicted)
0debug
why addition using += operator is fast as compared to normal addition : <pre><code> str=str+(char)(newno+'0') str+=newno+'0' </code></pre> <p>statement(1) is showing TLE whereas statement(2) does not.</p>
0debug
static void dmix_sub_c(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len) { int i; for (i = 0; i < len; i++) dst[i] -= mul15(src[i], coeff); }
1threat
difference between '==' and '===' in kotlin? : <blockquote> <p>i have also read from this link <a href="https://kotlinlang.org/docs/reference/equality.html" rel="nofollow noreferrer">https://kotlinlang.org/docs/reference/equality.html</a></p> <p>but i didn't understand can anyone give me example with proper clarification!!</p> </blockquote> <p>i mean if we do:</p> <pre><code>val str1 = "Hello, World!" val str2 = "Hello," + " World!" println(str1 == str2)//print true println(str1 === str2)//also print true </code></pre> <p>so whats the difference between them??</p>
0debug
How do i find next available column in Xls file and write there using xlrd/xlwt in Python : I am writing a selenium script where I need to store username password information of all the accounts I am creating. So I am using xlrd and xlwt to write information in an excel file but I am not able to find a way how script automatically detects next available row in the sheet and writes the info there. I am very new to Python. Thanks in advance.
0debug
Don't understand java operator ? and : : <pre><code>public static void openWebpage(URI uri) { Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null &amp;&amp; desktop.isSupported(Desktop.Action.BROWSE)) { try { desktop.browse(uri); } catch (Exception e) { e.printStackTrace(); } } } </code></pre> <p>And I don't know what the ? and the : at the end is meaning.</p> <pre><code>Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; </code></pre> <p>Can you help me?</p>
0debug
static inline void gen_neon_narrow_sats(int size, TCGv dest, TCGv src) { switch (size) { case 0: gen_helper_neon_narrow_sat_s8(dest, cpu_env, src); break; case 1: gen_helper_neon_narrow_sat_s16(dest, cpu_env, src); break; case 2: gen_helper_neon_narrow_sat_s32(dest, cpu_env, src); break; default: abort(); } }
1threat
static int qemu_peek_byte(QEMUFile *f) { if (f->is_write) abort(); if (f->buf_index >= f->buf_size) { qemu_fill_buffer(f); if (f->buf_index >= f->buf_size) return 0; } return f->buf[f->buf_index]; }
1threat
Error when Creating SQLite Table Androic C# : I am trying to create an SQL Table in Anrdoid C# with SQLite and I am receiving an error. MainActivity.cs Database Code: public class DbHelper : SQLiteOpenHelper { private static String DB_NAME = "NotesDB"; private static int DB_VER = 1; public static String DB_TABLE = "Notes"; public static String DB_COLUMN = "NoteDesc"; public DbHelper (Context context):base(context, DB_NAME, null, DB_VER) { } public override void OnCreate(SQLiteDatabase db) { string query = $"CREATE TABLE {DbHelper.DB_TABLE} (ID INTEGER PRIMARY KEY AUTO_INCREMENT,{DbHelper.DB_COLUMN} VARCHAR(80) NOT NULL;"; db.ExecSQL(query); } I am receiving the below error.[![SQLite Error][1]][1] [1]: https://i.stack.imgur.com/b9Kc9.png
0debug