_id
stringlengths
2
6
partition
stringclasses
3 values
text
stringlengths
4
46k
language
stringclasses
1 value
title
stringclasses
1 value
d19901
test
To remove the tab instead of hiding it, create a template overload of this file: buddypress\bp-templates\bp-legacy\buddypress\members\index.php And simply delete the list element that creates the All Members tab. To change what is displayed below those tabs, create a template overload of this file: buddypress\bp-templates\bp-legacy\buddypress\members\members-loop.php And adjust as necessary. A: You may make both tabs invisble using CSS which is less painful (but it can be undone changing the css property using dev tools). Try searching both tabs ID's or classes, then modify your buddypress css template file with: .TabClassName { display:none!important; } or #TabId { display:none!important; } The !important is to overwrite any other tab visibility modifier. More info where.
unknown
d19902
test
The part of code called Do query stuff here i assume is async already, why put it inside a dispatch_queue then? If instead you manage to do a synchronous query, your code (the second snippet) would work, as the dispatch to the main queue would be executed only after the query finished. If you don't have an option to execute the query in a synchronous manner, then you need some mechanism to register either a block or a callback to be executed when the download is finished. At the end of the day, it all depends on what kind of query you have in there and what methods it offers for you to register an action to be performed when the download is finished.
unknown
d19903
test
You don't mention what is exactly what you don't understand. Basically when you add a button it knows how to trigger events when you click it to a thread called Event Dispatcher Thread ( EDT ). Every time you click on a button this event will notify to every "Listener" registered within that button ( They are listening for notifications ) So a simpler example would be: import javax.swing.*; import java.awt.event.*; import java.awt.*; class Click { public static void main( String ... args ) { JButton clickMe = new JButton("Click Me"); ActionListener aListener = new OneActionListener(); clickMe.addActionListener( aListener ); JFrame frame = new JFrame(); frame.add( clickMe ); frame.pack(); frame.setVisible( true ); } } class OneActionListener implements ActionListener { public void actionPerformed( ActionEvent e ) { System.out.printf("Clicked. Thread: %s, action: %s%n", Thread.currentThread().getName(), e.getActionCommand() ); } } Here you declare a class OneActionListener that implements ActionListener interface to let know the button he can handle the event ( with the actionPerformed method ) I hope this clear out a bit how this works.
unknown
d19904
test
try this.... private void Button_Click_2(object sender, EventArgs e) { string query = "select * from student"; SqlCommand cmd = new SqlCommand(query, con); con.Open(); DataTable dt = new DataTable(); // create data adapter SqlDataAdapter da = new SqlDataAdapter(cmd); // this will query your database and return the result to your datatable da.Fill(dt); con.Close(); da.Dispose(); dataGridView1.DataSource = dt; } A: MySqlCommand command = conn.CreateCommand(); command.CommandText = "Select * from student"; try { con.Open(); MySqlDataAdapter sda = new MySqlDataAdapter(); sda.SelectCommand = command; DataTable dbdataset = new DataTable(); sda.Fill(dbdataset); BindingSource bSource = new BindingSource(); bSource.DataSource = dbdataset; dataGridView1.DataSource = bSource; sda.Update(dbdataset); } catch (Exception ex) { Console.WriteLine(ex.Message); } con.Close(); Try this A: Just fill DataTable with your table and bind it to GridView.DataContext. Like so: First Add DataGrid in XAML editor <DataGrid Name="customDataGrid" ItemsSource="{Binding}"> then Code behind: namespace WpfApplication4 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { string connectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True"; public MainWindow() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { DataTable table = null; string query = "select * from student"; try { using (SqlConnection connection = new SqlConnection(this.connectionString)) { connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(query, connection)) { table = new DataTable(); adapter.Fill(table); } } } catch (Exception ex) { //handle caught exception } if (table != null) { customDataGrid.DataContext = table.DefaultView; } } } } Binding part: customDataGrid.DataContext = table.DefaultView;
unknown
d19905
test
Have you tried to use Ant instead of graddle? Try this command: ionic cordova build android -- --ant
unknown
d19906
test
The given construction: SomeType st = new SomeType(){ ... } creates anonymous subclass extending SomeType and allows to override/add methods, add members, make initialization etc In your case {} creates anonymous subclass extending ActionBarDrawerToggle and overriding methods onDrawerOpened() and onDrawerClosed(). P.S. It's useful when you need class only once. A: ActionBarDrawerToggle implements DrawerLayout.DrawerListener which has abstract methods. This means you have to define them. ActionBarDrawerToggle does define them itself but you can overwrite them in {} after the constructor. Actually you are creating an anonymous subclass of ActionBarDrawerToggle. (A class without a name) You can read about it in the Java documantation
unknown
d19907
test
While I can't answer your question on a mathematical basis, I'll try on an intuitive one: fixpoint techniques need a "flat" function graph around their ..well.. fixpoint. This means: if you picture your fixpoint function on an X-Y chart, you'll see that the function crosses the diagonal (+x,+y) exactly at the true result. In one step of your fixpoint algorithm you are guessing an X value which needs to be within the interval around the intersection point where the first derivative is between (-1..+1) and take the Y value. The Y that you took will be closer to the intersection point because starting from the intersection it is reachable by following a path which has a smaller slope than +/-1 , in contrast to the previous X value that you utilized, which has in this sense, the exact slope -1. It is immediately clear now that the smaller the slope, the more way you make towards the intersection point (the true function value) when using the Y as new X. The best interpolation function is trivially a constant, which has slope 0, giving you the true value in the first step. Sorry to all mathematicians. A: It only speeds up those functions whose repeated applications "hop around" the fixpoint. Intuitively, it's like adding a brake to a pendulum - it'll stop sooner with the brake. But not every function has this property. Consider f(x)=x/2. This function will converge sooner without the average damping (log base 2 steps vs log base (4/3) steps), because it approaches the fixpoint from one side.
unknown
d19908
test
The CPaintDC constructor calls BeginPaint to get a DC that is clipped to the invalid area (the area that needs painting). Constructing a second CPaintDC gets an empty invalid area, so it can't paint anything. The default code constructs a CPaintDC only at line 2 because it is not going to call CDialogEx::OnPaint when the dialog is minimized. When the dialog is not minimized then CDialogEx::OnPaint will construct a CPaintDC. One and only one CPaintDC can be used for any particlular call to OnPaint. You can use CClientDC to paint your rectangle, as long as you leave the original treatment of CPaintDC as it was.
unknown
d19909
test
You can use map-coloring (graph-coloring) for it. You just need to define rules for edges and nodes. Nodes will be classes, rooms will be colors and you connect classes that can't be in same time. This is actually k-coloring problem, where you need to color specific graph with k colors in order to minimize number of classes per color. However in this special case, you just need to have less or equal to t per color. You can achieve this by going by standard rule of coloring, and switch to new color as soon as it has t number of classes. This is still a NP-complete problem. Only exception is when you have 1 or 2 classes, then its in polynomial time. When you have 1 room, you just need to check if n<=t. When you have 2 rooms, you just need to check if it can be colored by 2 colors. You can achieve this by DFS (but first check if n <= 2t) and color odd steps with first color and even steps with second color. If it is possible to color all nodes with this tactic, you have a positive solution. When k>=3, its NP-complete.
unknown
d19910
test
You are missing a height attribute on .item-details Is this what you're after? DEMO
unknown
d19911
test
As you know the main problem with async coding is losing reference to the current object That's not true, the arrow function does not bind its own this therefore you don't need to send this to doPromise export class PromiseComponent { doPromise () { return new Promise(function (resolve) { setTimeout(function () { resolve({ num: 3113 }) }, 5000) }) } } promiseVal = 0 doMyPromise() { this.myPromise.doPromise() .then(res => { this.promiseVal = res.num }) } A: If you want to consume a promise inside your component: promiseVal = 0 doMyPromise() { this.myPromise.doPromise().then((res) => { this.promiseVal = res.num }); } And I don't know the reasoning behind your Service but it usually is like this (optional): export class PromiseComponent { doPromise() { //This method will return a promise return new Promise(function (resolve2) { setTimeout(function () { resolve2({ num: 3113, obj: obj }); }, 5000); }); } } After OP edited the post: You can change this: doMyPromise() { this.myPromise.doPromise(this).then(this.secondFunc);//UPDATED HERE } to doMyPromise() { this.myPromise.doPromise(this).then(this.secondFunc.bind(this));//UPDATED HERE }
unknown
d19912
test
Angular: scaffold a front end folder angular for your component ng g component upload --spec false import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { HttpEventType, HttpClient } from '@angular/common/http'; @Component({ selector: 'file-upload-toAspCore', templateUrl: './upload.component.html', styleUrls: ['./upload.component.css'] }) export class UploadComponent implements OnInit { public progress: progressPercentage; // you can yse this to display progress in HTML public message: string; @Output() public onUploadFinished = new EventEmitter(); constructor(private http: HttpClient) { } ngOnInit() {} public uploadFile = (files) => { if (files.length === 0) { return; } let filesToUpload = <File>files[0]; const formData = new FormData(); formData.append('file', filesToUpload, filesToUpload.name); this.http.post('https://localhost:4200/api/uploaderAction', formData, {reportProgress: true, observe: 'events'}) .subscribe(event => { if (event.type === HttpEventType.UploadProgress) // helps display progress to user this.progress = Math.round(100 * event.loaded / event.total); else if (event.type === HttpEventType.Response) { this.message = 'Upload success.'; this.onUploadFinished.emit(event.body); } }); } } ASP Action that receives the file [HttpPost, DisableRequestSizeLimit] public async Task<IActionResult> UploaderAction() { try { var formCollection = await Request.ReadFormAsync(); var file = formCollection.Files.First();
unknown
d19913
test
This measure should do what you want, by filtering all players, but leaving the club filter in place: Club Overall Average = IF ( HASONEVALUE ( data[Club] ), CALCULATE ( AVERAGE ( data[Overall] ), ALL ( data[Name] ), data[Club] = VALUES ( data[Club] ) ), BLANK() ) See https://pwrbi.com/2019/05/stack-overflow-56128872/ for worked example
unknown
d19914
test
This is not intended to be a definitive answer, but merely an example of you could accomplish this using stackalloc and unsafe code. public unsafe class Example { [DllImport("library.dll")] private static extern int CFunction(A* pointerToFirstElementOfArray, int NumberOfArrayElements); public void DoSomething() { A* a = stackalloc A[LENGTH]; CFunction(a, LENGTH); } } Also, pay attention to the packing of the struct that the API accepts. You may have to play around with the Pack property of the StructLayout attribute. I believe the default is 4, but some APIs expect 1. Edit: For this to work you will have to change the declaration of A from a class to a struct. public struct A { public int data; }
unknown
d19915
test
I hope you have added okio dependency in your gradle file. This will resolve Cannot access ByteString class file error. compile 'com.squareup.okio:okio:1.13.0' Then Edit your iUpload interface file like: public interface iUpload{ @Multipart @POST("/uploadmultiplepropimages/") SamplePojoClass getUploadData( @Part MultipartBody.Part file @Part MultipartBody.Part prop_id, @Part MultipartBody.Part type ); } Then write MultipartBody.Part like this: RequestBody lRequestBody = RequestBody.create(MediaType.parse("multipart/form-data"), pFile); MultipartBody.Part lFile = MultipartBody.Part.createFormData("file", pFile.getName(), lRequestBody); MultipartBody.Part id = MultipartBody.Part.createFormData("prop_id", "WRITE_ID_HERE"); MultipartBody.Part type = MultipartBody.Part.createFormData("type", "WRITE TYPE HERE"); and finally pass these parameters to your api like this: uploadImageResponse = RequestResponse.getUploadData(lFile,id,type); I hope it will resolve your problem. Note: Here pFile is instance of File. To get file from dicrectory you can write code like: File pFile = new File("PATH_OF_FILE"); A: I have done Multipart upload in okhttp. I hope this will help. MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); multipartBuilder.addFormDataPart("prop_photos", photoFile, RequestBody.create(MEDIA_TYPE_PNG, file)); multipartBuilder .addFormDataPart("type", type) .addFormDataPart("prop_id", prop_id); RequestBody requestBody = multipartBuilder.build(); Request request1 = new Request.Builder().url(urlString).post(requestBody).build(); A: Use the following fuction for your problem public static RegisterResponse Uploadimage(String id, String photo,String proof) { File file1 = null, file2 = null; try { if (photo.trim() != null && !photo.trim().equals("")) { file1 = new File(photo); } if (proof.trim() != null && !proof.trim().equals("")) { file2 = new File(proof); } HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(WEB_SERVICE + "protoupload.php?"); MultipartEntity reqEntity = new MultipartEntity(); // reqEntity.addPart("studentid", new StringBody( // Global.profileDetail.id)); reqEntity.addPart("id", new StringBody(id)); if (file1 == null) { reqEntity.addPart("photo", new StringBody("")); } else { FileBody bin1 = new FileBody(file1); reqEntity.addPart("photo", bin1); } if (file2 == null) { reqEntity.addPart("proof", new StringBody("")); } else { FileBody bin2 = new FileBody(file2); reqEntity.addPart("proof", bin2); } post.setEntity(reqEntity); HttpResponse response = client.execute(post); HttpEntity resEntity = response.getEntity(); String inputStreamString = EntityUtils.toString(resEntity); if (inputStreamString.contains("result")) { return new Gson().fromJson(inputStreamString, RegisterResponse.class); } } catch (Exception ex) { Log.e("Debug", "error: " + ex.getMessage(), ex); } return new RegisterResponse(); }
unknown
d19916
test
Neither, it is a value (or a stringification of a value in the case of an alert) Whether or not you can ignore the fact that a variable/property/whatever is undefined depends on the needs of the program you are writing. If a message displays "undefined" when it should display "sweet cuppin' cakes", then that would be a logic error; conversely, if a message displays undefined when it is merely intended to reflect an internal state that can legitimately be undefined, it would not be an error. A: It sounds to me like an incomplete error message; like when a developer prints "This should never appear!11" Undefined is nothing more than a value, so seeing it on its own does not assign any meaning or importance to the message. A: 'undefined' means exactly what it says - you have referenced a variable name that is not defined. Some languages, like Python, are stricter about this kind of thing, and will throw an error if you try to do this. Javascript assumes you know what you are doing, and so doesn't complain. A: undefined is a special data type. For example, a common case is a missing parameter in a function call: var foobar = function(val) { alert(typeof val); // alerts 'undefined' alert(foobar.length); // throws an error } foobar(); The author of this example function should have checked for the type of val before trying to access the length property. A: Undefined is, what its name says, a sign for something beeing not defined, like var a=new Array(10); It is an array: Array.isArray(a)is true, a.length is 10; but all it contains are undefined values: e.g. a[5] is undefined. So it is no error. ERROR message or just a NOTICE message? Neither nor.
unknown
d19917
test
I've encountered the same issue with legacy code. It appears to be a problem with the implementation of Python 2's file object's __next__ method; it uses a Python level buffer (which -u/PYTHONUNBUFFERED=1 doesn't affect, because those only unbuffer the stdio FILE*s themselves, but file.__next__'s buffering isn't related; similarly, stdbuf/unbuffer can't change any of the buffering at all, because Python replaces the default buffer made by the C runtime; the last thing file.__init__ does for a newly opened file is call PyFile_SetBufSize which uses setvbuf/setbuf [the APIs] to replace the default stdio buffer). The problem is seen when you have a loop of the form: for line in sys.stdin: where the first call to __next__ (called implicitly by the for loop to get each line) ends up blocking to fill the block before producing a single line. There are three possible fixes: * *(Only on Python 2.6+) Rewrap sys.stdio with the io module (backported from Python 3 as a built-in) to bypass file entirely in favor of the (frankly superior) Python 3 design (which uses a single system call at a time to populate the buffer without blocking for the full requested read to occur; if it asks for 4096 bytes and gets 3, it'll see if a line is available and produce it if so) so: import io import sys # Add buffering=0 argument if you won't always consume stdin completely, so you # can't lose data in the wrapper's buffer. It'll be slower with buffering=0 though. with io.open(sys.stdin.fileno(), 'rb', closefd=False) as stdin: for line in stdin: # Do stuff with the line This will typically be faster than option 2, but it's more verbose, and requires Python 2.6+. It also allows for the rewrap to be Unicode friendly, by changing the mode to 'r' and optionally passing the known encoding of the input (if it's not the locale default) to seamlessly get unicode lines instead of (ASCII only) str. *(Any version of Python) Work around problems with file.__next__ by using file.readline instead; despite nearly identical intended behavior, readline doesn't do its own (over)buffering, it delegates to C stdio's fgets (default build settings) or a manual loop calling getc/getc_unlocked into a buffer that stops exactly when it hits end of line. By combining it with two-arg iter you can get nearly identical code without excess verbosity (it'll probably be slower than the prior solution, depending on whether fgets is used under the hood, and how the C runtime implements it): # '' is the sentinel that ends the loop; readline returns '' at EOF for line in iter(sys.stdin.readline, ''): # Do stuff with line *Move to Python 3, which doesn't have this problem. :-) A: In Linux, bash, what you are looking for seems to be the stdbuf command. If you want no buffering (i.e. an unbuffered stream), try this, # batch_job | stdbuf -o0 myparser If you want line buffering, try this, # batch_job | stdbuf -oL myparser A: You can unbuffer the output: unbuffer batch_job | myparser
unknown
d19918
test
For printing a variable into your title, you need to use paste(), as explained here: Inserting function variable into graph title in R Does this help you?
unknown
d19919
test
If you drop the first line, then it can be used in python. import json test = '''{ "Name": "SKY", "SuggestedBots": 50, "MaxCPM": 3000, "LastModified": "2019-11-03T23:24:24.0854425-03:00", "AdditionalInfo": "", "Author": "KATO", "Version": "1.1.4", "IgnoreResponseErrors": false, "MaxRedirects": 8, "NeedsProxies": true, "OnlySocks": false, "OnlySsl": false, "MaxProxyUses": 0, "BanProxyAfterGoodStatus": false, "EncodeData": false, "AllowedWordlist1": "", "AllowedWordlist2": "", "DataRules": [], "CustomInputs": [], "ForceHeadless": false, "AlwaysOpen": false, "AlwaysQuit": false, "DisableNotifications": false, "CustomUserAgent": "", "RandomUA": false, "CustomCMDArgs": "" }''' json.loads(test) # {u'AlwaysQuit': False, u'Author': u'KATO', u'LastModified': u'2019-11-03T23:24:24.0854425-03:00', u'DataRules': [], u'AlwaysOpen': False, u'Version': u'1.1.4', u'DisableNotifications': False, u'NeedsProxies': True, u'CustomInputs': [], u'EncodeData': False, u'BanProxyAfterGoodStatus': False, u'SuggestedBots': 50, u'ForceHeadless': False, u'RandomUA': False, u'AdditionalInfo': u'', u'Name': u'SKY', u'CustomUserAgent': u'', u'MaxRedirects': 8, u'CustomCMDArgs': u'', u'OnlySocks': False, u'MaxProxyUses': 0, u'IgnoreResponseErrors': False, u'AllowedWordlist1': u'', u'AllowedWordlist2': u'', u'OnlySsl': False, u'MaxCPM': 3000}
unknown
d19920
test
Your xcorn and zcorn values repeat, so consider caching the result of some of the computations. Take a look at the timeit and profile modules to get more information about what is taking the most computational time. A: It is very inefficient to access individual elements of a numpy array in a Python loop. For example, this Python loop: for i in xrange(0, len(a), 2): a[i] = i would be much slower than: a[::2] = np.arange(0, len(a), 2) You could use a better algorithm (less time complexity) or use vector operations on numpy arrays as in the example above. But the quicker way might be just to compile the code using Cython: #cython: boundscheck=False, wraparound=False #procedure_module.pyx import numpy as np cimport numpy as np ctypedef np.float64_t dtype_t def procedure(np.ndarray[dtype_t,ndim=1] x, np.ndarray[dtype_t,ndim=1] xcorn): cdef: Py_ssize_t i, j dtype_t x1, x2, z1, z2, r1, r2, O1, O2 np.ndarray[dtype_t,ndim=1] grav = np.empty_like(x) for i in range(x.shape[0]): for j in range(xcorn.shape[0]-1): x1 = xcorn[j]-x[i] x2 = xcorn[j+1]-x[i] ... grav[i] = ... return grav It is not necessary to define all types but if you need a significant speed up compared to Python you should define at least types of arrays and loop indexes. You could use cProfile (Cython supports it) instead of manual calls to time.clock(). To call procedure(): #!/usr/bin/env python import pyximport; pyximport.install() # pip install cython import numpy as np from procedure_module import procedure x = np.arange(-30.0,30.0,0.5) xcorn = np.array((-9.79742526,9.78716693 ,9.78716693 ,-9.79742526,-9.79742526)) grav = procedure(x, xcorn)
unknown
d19921
test
This is because the job messages become available for other consumers. In your config/queue.php configuration file, each queue connection defines a retry_after option. This option specifies how many seconds the queue connection should wait before retrying a job that is being processed. For example, if the value of retry_after is set to 90, the job will be released back onto the queue if it has been processing for 90 seconds without being deleted. Typically, you should set the retry_after value to the maximum number of seconds your jobs should reasonably take to complete processing. See https://laravel.com/docs/5.7/queues#queue-workers-and-deployment When a consumer receives and processes a message from a queue, the message remains in the queue. The queue doesn’t automatically delete the message. Because a queue is a distributed system, there’s no guarantee that the consumer actually receives the message (for example, due to a connectivity issue, or due to an issue in the consumer application). Therefore, the consumer must delete the message from the queue after receiving and processing it. Immediately after a message is received, it remains in the queue. To prevent other consumers from processing the message again, you should set the retry_after value to the maximum number of seconds your jobs should reasonably take to complete processing. For Amazon SQS: The only queue connection which does not contain a retry_after value is SQS. SQS will retry the job based on the Default Visibility Timeout which is managed within the AWS console. Amazon SQS sets a visibility timeout, a period of time during which Amazon SQS prevents other consumers from receiving and processing the message. The default visibility timeout for a message is 30 seconds.This means that other consumers can see and pickup the message again after 30 seconds. A: If there is an exception or the job inexplicably fails, the job will automatically be retried. This will occur even if most of the job has already ran.
unknown
d19922
test
1) So, why am I able to add multiple phone numbers? ** While adding a phone number to the database, simply search if the current user has a phone number. If yes, then update it. Else, create a new one. Check updateOrCreate // If there is a user with id 2 then SET the phone to 7897897890. // If no user with id 2 found, then CREATE one with user_id 2 and phone number to 7897897890 Phone::updateOrCreate( ['user_id' => 2], ['phone' => '7897897890'] ); 2) Does it mean that App\User::find(1)->phone only returns the first phone found in the database? ** As long as your relation is hasOne, you fetched data will be one where user_id = current user. If you are planning to have one phone number for each user throughout the project then might I suggest to simply add the phone number column to the users table. 3) Should I add a unique constraint to the user_id column in the phones migration? ** Yes, you can. However, as I suggested in the second point, just have a phone column in the users table (if you want to, otherwise this will work too) A: Schema::create('phones', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('user_id')->unique(); $table->string('phone'); $table->timestamps(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); }); A: You can try this .... In the User model, define the One-to-One relationship with the Phone model: User Model class User extends Model { public function phone() { return $this->hasOne(Phone::class); } } In the Phone model, define the reverse relationship: Phone Model class Phone extends Model { public function user() { return $this->belongsTo(User::class); } }
unknown
d19923
test
Check the srcElement before plugin executions. If it's not an input element, do trigger the contextmenu plugin: $(document).on("contextmenu", function(e) { if (!$(e.srcElement).is(":input")) { // if it's not an input element... $(this).triggerTheContextMenuPlugin(); } }); A: Use an event listener on the document and check if it was initiated by an input element. $(document).on("contextmenu", function (e) { if (e.target.tagName.toUpperCase() === "INPUT") { console.log("context menu triggered"); } }); Demo here A: Inspired by Salman's solution. You can stop the event propagation in all input elements, with the e.stopPropagation() function. In doing so, you keep the default behavior of the inputs elements: $(function() { $(document).on("contextmenu", function(e) { alert("Context menu triggered, preventing default"); e.preventDefault(); }); $("input").on("contextmenu", function(e) { e.stopPropagation(); }); }); JSFiddle Demo
unknown
d19924
test
The underlying issue you're having here is that you're using physical tab characters and not spaces for indentation. While a space character has a very definite width (one character), a tab character has no intrinsic width. It's a single character that means "insert a level of indent here". How big that indent displays as is entirely controlled by whatever it is that's displaying the text. The general idea of using a physical tab in this manner is that each individual person can set the display size of the tab to whatever they like, and as a result the text of the file doesn't change, but it's display does. In contrast, using spaces for indent causes the physical file to look the same for everyone that views it, regardless of their settings. While you have set tab_size to 4 in Sublime, that is of no consequence to GitLab (or any other editor or display mechanism for your file) because all the file contains is a single tab character with no defined width. It so happens that GitLab has a default tab size of 8 characters instead of 4. Hence, it appears as if there is one extra tab everywhere, but in reality if you use your mouse to select your text a character at a time you'll see that the tab is actually 8 characters wide. For GitLab, there's a setting that controls this: * *Click on your profile picture in the top right and select Settings *In the menu along the left hand side of the settings page, select Preferences *In the section labeled behaviour, there's a setting for Tab Size; set that to your desired tab width and click Save Changes at the bottom of the window. This particular setting is currently per-user and not per-project, so what you set here applies to everything across GitLab. GitHub also has a default tab width of 8; however there you can append ?ts=4 to a URL displaying a file to alter the tab size on the fly.
unknown
d19925
test
* *Better check whether the checkbox is checked or not code write under the button_click *Remove Items remove selectedConatcts.remove(phone_nos[arg2]); contactdisp.removeViewAt(arg2);
unknown
d19926
test
Just add OR(||) condition function test() { const elm = document.getElementById("myinput") alert(elm.value === '' || regex.test(elm.value)); } A: ^$|pattern var regex = /^$|(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g; A: Add an alternation with empty string (I've simplified a bit your regex): ^((?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_\+.~#?&\/=]*|)$ or ^((?:https?:\/\/)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&\/=]*|)$ Demo & explanation
unknown
d19927
test
You must be using the old version of the Scheduler SDK. Please find the latest SDK here. We also have a code sample for said SDK: https://github.com/Azure-Samples/scheduler-dotnet-getting-started
unknown
d19928
test
You need to define the association class ContentA { String name static hasMany = [contentBList: ContentB] } GORM oneToMany
unknown
d19929
test
There are several approaches: * *Append urls to list and lookup while iterating if actual url is not in list else skip scraping it. *Or as mentioned use set and operate from the links: articles = [] for e in set(soup.select('h3>a')): e = e.find_parent('div') articles.append({ 'url':e.a.get('href'), 'title':e.get_text(strip=True), 'date':e.select_one('.article-category-section-date').get_text(strip=True) if e.select_one('.article-category-section-date') else None }) articles *Or collect your information in list of dicts and iterate over values to get unique one: list({v['url']:v for v in articles}.values()) *... Example import requests from bs4 import BeautifulSoup r = requests.get('https://www.ig.com/uk/news-and-trade-ideas/') soup = BeautifulSoup(r.content) articles = [] for e in soup.select('h3:has(>a)'): articles.append({ 'url':e.a.get('href'), 'title':e.get_text(strip=True) }) print('Whit duplicates: ',len(articles)) print('Whitout duplicates: ', len(list({v['url']:v for v in articles}.values()))) list({v['url']:v for v in articles}.values()) Output With duplicates: 36 Without duplicates: 29 [{'url': '/uk/news-and-trade-ideas/_brent-crude-oil--gold-and-us-natural-gas-rallies-pause-amid-us--221108', 'title': '\u200bBrent crude oil, gold and US natural gas ral...'}, {'url': '/uk/news-and-trade-ideas/early-morning-call--gloomy-festive-season-ahead-amid-consumer-we-221108', 'title': 'Early Morning Call: dollar basket steady ahead of ...'}, {'url': '/uk/news-and-trade-ideas/nasdaq-listed-ryanair-posts-record-h1-results-221107', 'title': 'Ryanair shares up after record H1 result...'},...]
unknown
d19930
test
I doubt if this is a memory issue because he already said that the program actually runs and he inputs 100000000. One things that I noticed, in the if condition you're doing a lookup[n] even if n == MAXSIZE (in this exact condition). Since C++ is uses 0-indexed vectors, then this would be 1 beyond the end of the vector. if (n < MAXSIZE) { ... } ... if (temp >= lookup[n] ) { lookup[n] = temp; } return lookup[n]; I can't guess what the algorithm is doing but I think the closing brace } of the first "if" should be lower down and you could return an error on this boundary condition. A: You either don't have enough memory or don't have enough contiguous address space to store 100,000,000 unsigned longs. A: This mostly is a memory issue. For a vector, you need contiguous memory allocation [so that it can keep up with its promise of constant time lookup]. In your case, with an 8 byte double, you are basically requesting your machine to give you around 762 mb of memory, in a single block. I don't know which problem you're solving, but it looks like you're solving Bytelandian coins. For this, it is much better to use a map, because: * *You will mostly not be storing the values for all 100000000 cases in a test case run. So, what you need is a way to allocate memory for only those values that you are actually memoize. *Even if you are, you have no need for a constant time lookup. Although it would speed up your program, std::map uses trees to give you logarithmic look up time. And it does away with the requirement of using up 762 mb contiguously. 762 mb is not a big deal, but expecting in a single block is. So, the best thing to use in your situation is an std::map. In your case, actually just replacing std::vector<unsigned long> by std::map<int, unsigned long> would work as map also has [] operator access [for the most part, it should].
unknown
d19931
test
Well, my personal favorite way of solving such requirements involves using a computed column and a UDF to compute the values in that column. So first, you create the UDF: CREATE FUNCTION dbo.GenerateStudyID ( @PatientType varchar(5), @id int ) RETURNS char(11) AS BEGIN RETURN ( SELECT @PatientType +'/'+ RIGHT('00000', CAST(COUNT(*) as char(5)), 5) FROM [dbo].[PatientID] WHERE PatientType = @PatientType AND Id <= @id ) END GO Then, you add the computed column to your table: ALTER TABLE [dbo].[PatientID] ADD StudyID as dbo.GenerateStudyID (PatientType, id) GO Please note that you can't use this method if you need this column to be persisted, since once you will delete a record the values will change.
unknown