_id
stringlengths
2
6
partition
stringclasses
3 values
text
stringlengths
4
46k
language
stringclasses
1 value
title
stringclasses
1 value
d4201
train
The problem was in Registering ActionFilterClass in structuremap. I have changed it as follows: public class ActionFilterRegisteryClass : StructureMap.Registry { public ActionFilterRegisteryClass(Func<StructureMap.IContainer> containerFactory) { For<IFilterProvider>().Use( new StructurMapFilterProvider(containerFactory)); Policies.SetAllProperties(x => { x.Matching(p => p.DeclaringType.CanBeCastTo( !p.PropertyType.IsPrimitive && !p.PropertyType.IsEnum && p.PropertyType != typeof(string)); }); } }
unknown
d4202
train
What you're looking for is the DWM (Desktop Window Manager) API, especially the function DwmExtendFrameIntoClientArea. Here's some C# code that demonstrates how to do this: CodeProject Also, make sure not to extend the frame when desktop composition is enabled, or you'll run into problems.
unknown
d4203
train
You should not be trying to directly manipulate the layout of the table from outside of Tabulator. Tabulator uses a virtual DOM which means that it will create and destroy elements of the table as needed, which means that you can only style elements that are currently visible, when these elements are updated any previous formatting can be lost without notice. If you wish to style cell elements you must use the formatter function in the column definition or the rowFormatter function on the table which are called when the rows/cells are redrawn. Full details of these can be found in the Formatter Documentation If you are wanting to change the state of rows based on something outside of the table, then your formatters should reference this external variable and when you update the external state you should trigger the redraw function on the table to retrigger the formatters
unknown
d4204
train
Pass the item index to splice and specify that one item is to be removed: <li *ngFor="let toDo of toDoList; let i = index" (click)="toDoList.splice(i, 1)"> See this stackblitz for a demo. A: On your click function send the object you are removing: <li *ngFor="let toDo of toDoList" (click)="removeFromList(toDo)">{{ toDo }}</li> And in your function, find the index of the element, and then use splice to remove it removeFromList(addedItem) { var index = this.toDoList.indexOf(addedItem); this.toDoList.splice(index, 1); // Removes one element, starting from index } A: Splice will remove the item from the array by index (and how many items you want to remove), not by value. To work with arrays and collections, I would suggest to use https://underscorejs.org/ I know it may be an overkill for this problem, but will be useful for more complex scenarios. You can add the library to your angular project by running the following command: npm i underscore --save You may want to also add the typings by running: npm i @types/underscore --save-dev Your app.component.ts would then look like import { Component } from '@angular/core'; import * as _ from 'underscore'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'to-do-list-app'; listItem = ''; toDoList = []; addToList() { this.toDoList.push(this.listItem); } removeFromList(addedItem) { this.toDoList = _.without(this.toDoList, addedItem); } } And your app.component.html will look like: <h1>To Do List</h1> <label for="">What do you need to to?</label> <input type="text" [(ngModel)]="listItem"> <br> <button (click)="addToList()">Add</button> <hr> <ul> <li *ngFor="let toDo of toDoList" (click)="removeFromList(toDo)">{{ toDo }}</li> </ul>
unknown
d4205
train
you need to close your StreamReader and StreamWriter, in onder to save your written text, you need to close StreamWriter Extra https://msdn.microsoft.com/en-us/library/system.io.streamwriter%28v=vs.110%29.aspx System.IO is IDisposable, you should dispose it after read and write. private static void Main() { FileStream englishFile = new FileStream("English.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamReader engSR = new StreamReader(englishFile); StreamWriter engSW = new StreamWriter(englishFile); FileStream arabicFile = new FileStream("Arabic.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamWriter arabSW = new StreamWriter(arabicFile); StreamReader arabSR = new StreamReader(arabicFile); char delimiter = '|'; try { englishFile.Seek(0, SeekOrigin.Begin); while(!engSR.EndOfStream){ string line = engSR.ReadLine(); string[] arr = line.Split(delimiter); for (int j = 0; j < arr.Count();j++ ) { if (j > 0) { arabSW.Write(delimiter); } String outStr = ConvertStr(arr[j]); arabSW.Write(outStr); } arabSW.Write(arabSW.NewLine); } } catch { } finally { arabSW.Close(); //arabSR.Close(); engSR.Close(); //engSW.Close(); arabicFile.Close(); englishFile.Close(); } } i tried this, it work well A: The problem is that i have to make flush whenever i finished writing so after seeking to the begin and writing i should flush and at the end of the method i should close the StreamWriter as they said. string line = engSR.ReadLine(); string[] arr = line.Split('|'); int numberOfLines = int.Parse(arr[1]) + 1; englishFile.Seek(0, SeekOrigin.Begin); engSW.WriteLine("*|{0}", numberOfLines); arabicFile.Seek(0, SeekOrigin.Begin); arabSW.WriteLine("*|{0}", numberOfLines); engSW.Flush(); arabSW.Flush(); englishFile.Seek(0, SeekOrigin.End); line = engSR.ReadLine(); engSW.WriteLine("{0}|{1}", numberOfLines, englishin.Text); arabicFile.Seek(0, SeekOrigin.End); line = arabSR.ReadLine(); arabSW.WriteLine("{0}|{1}", numberOfLines, arabicin.Text); } catch { } finally { engSW.Close(); arabSW.Close(); arabSR.Close(); engSR.Close(); arabicFile.Close(); englishFile.Close(); }
unknown
d4206
train
Since you create the URLs from database entries, I would replace the spaces at URL creation time. You can use str_replace for this $url = str_replace(' ', '-', $db_column);
unknown
d4207
train
Take a look at pyinputplus for enhanced input() functionality. If the online documentation isn't enough, you can also read Automate the Boring Stuff with Python for a good guide on using the module https://pypi.org/project/PyInputPlus/ All input functions have the following parameters: default (str, None): A default value to use should the user time out or exceed the number of tries to enter valid input.
unknown
d4208
train
You can create a single class with response and message properties, then use mappings: @"response" : @"response", @"result.error_message" : @"message" Or you can just map into a dictionary for error responses and then use the keypath to access the message.
unknown
d4209
train
You forget to scope.$apply()! See forked plunk: http://plnkr.co/edit/zo1GrfwyQ8T82TJiW16h?p=preview You need to call $apply() every time an external source touches Angular values (in this case the "external source" is the browser event handled by on()).
unknown
d4210
train
just changed Project SDK to 20 (from 21) and all compiled. A: I have solved the problem by checking the Is Library option and I referenced appcompat_v7 A: I was also facing same problem, but now it's been resolved. Below are the steps I followed - Go to project properties->Android - Under 'Project Build Target', select Android 5.0.1. Press and clean the library project.
unknown
d4211
train
If you're working with ASP.NET 3.5 SP1 then you should investigate the new routing engine that has been introduced from the MVC project. It will make for a clean solution. A: We are using the DLL from http://urlrewriting.net and rules similar to the following: <urlrewritingnet xmlns="http://www.urlrewriting.net/schemas/config/2006/07"> <rewrites> <add name="Customer" virtualUrl="^~/([^/]+)/([^/]+).aspx" destinationUrl="~/$2.aspx?customer=$1"/> <add name="CustomerStart" virtualUrl="^~/([^/]+)/$" destinationUrl="~/Default.aspx?customer=$1"/> <add name="CustomerStartAddSlash" virtualUrl="^http\://([^/]+)/([a-zA-Z0-9_-]+)$" destinationUrl="http://www.example.com/$2/" redirect="Domain" redirectMode="Permanent" /> </rewrites> </urlrewritingnet> Those rules do the following mappings. These are rewrites, so the user always sees the left-hand URL in his browser: Rule 1: http://www.example.com/customerA/something.aspx => http://www.example.com/something.aspx?customer=customerA Rule 2: http://www.example.com/customerA/ => http://www.example.com/Default.aspx?customer=customerA The third rule is a redirect rather than a rewrite, i.e., it ensures that the trailing slash is added in the user's browser (makes sure that relative paths work correctly): Rule 3: http://www.example.com/customerA => http://www.example.com/customerA/ A: Take a look at these questions. Your approach has a name. It's called Multitenancy. A: I did not found any solution that fully suites my requirement , I have written my own logic for this , which uses Global.ascx's BeginRequest, Login page, Base page and common classes created for Response.Redirect. I am no longer directly using Asp.Net's Response.Redirect, Paths and Session variables, instead I have created wrappers over them to add companyName from url to the Paths. Let me know if you need more information on my code Other answers are welcome. Thanks
unknown
d4212
train
replace expect single value, not unbounded. limit the result of your subquery. you use a subquery to join the filter again to your main table select r.rolekey from roles r inner join (select r.rolekey from roles r inner join savroles s on r.role_name like concat('%', replace(s.rolename, 'ROLE_REPONSABLE_RESSOURCE_',''), '%') inner join user_savroles us on s.rolekey = us.rolekey where us.userkey = 24) t1 on t1.rolekey = r.rolekey;
unknown
d4213
train
If the first character of the month portion of the string is '0' the second must be between '1' and '9' inclusive to be valid. If the first character is '1' the second must be between '0' and '2' inclusive to be valid. Any other initial character is invalid. In code bool valid_month (const char * yyyymm) { return ((yyymm[4] == '0') && (yyymm[5] >= '1') && (yyymm[5] <= '9')) || ((yyymm[4] == '1') && (yyymm[5] >= '0') && (yyymm[5] <= '2')); } A: You can do atoi() of the substring or you can simply compare the ASCII values. For example: if (buf[4] == '0') { // check buf[5] for values between '1' and '9' } else if (buf[4] == '1') { // check buf[5] for values between '0' and '2' } else { // error } Either way is acceptable. I guess it really depends on how you will eventually store the information (as int or string). A: Assuming your char* variable is called "pstr" and is null terminated after the MM you can do: int iMon = atoi(pstr + 4); if ( (iMon >= 1) && (iMon <= 12) ) { // Month is valid }
unknown
d4214
train
By looking at your database I can see that your mFriendsDatabase DatabseReference points to some 'String' Values and you are telling your firebaseRecyclerAdapter that those are of type 'Friends,that is why the exception is thrown.Most probably your are doing a mistake while saving the value to database,instead of saving a Friends object you are saving some String value.But if that's not the case you can change your firebaseRecyclerAdapter to this... FirebaseRecyclerAdapter<String,MainViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<String,MainViewHolder>( String.class, R.layout.single_service_layout, MainViewHolder.class, mFriendsDatabase ) { @Override protected void populateViewHolder(MainViewHolder viewHolder, String mString, int position) { Log.d("TAG",mString); } }; mSubsList.setAdapter(firebaseRecyclerAdapter); A: To display those messages, please use the following code: DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference(); DatabaseReference uidRef = rootRef.child("subscribers").child(mCurrent_user_id); ValueEventListener eventListener = new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for(DataSnapshot ds : dataSnapshot.getChildren()) { String message = ds.getValue(String.class); Log.d("TAG", message); } } @Override public void onCancelled(DatabaseError databaseError) {} }; uidRef.addListenerForSingleValueEvent(eventListener);
unknown
d4215
train
So the trick is anytime you deal with @Output in angular, pass in the $event to emit the new value to the function. Just add that to your duder() and you will be set. (selectedChanged)="duder($event)" duder(date){ console.log('duder', date); this.wtf = date; } I have updated the demo
unknown
d4216
train
If you open the .otf file, you can see the name of the font. This is what you need to use to the FontFamily resource, without the file extension. Try the following code: <FontFamily x:Key="Icons">pack://application:,,,/{YOUR PROJECT NAME};component/Fonts/#Font Awesome 5 Free Solid</FontFamily>
unknown
d4217
train
You can do this using window.matchMedia(), which is basically media queries in javascript. And if it matches your condition load your templates accordingly. https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
unknown
d4218
train
This is not a error. It's just information about cron job which execute command: /usr/bin/php /home/app/foxorders/scripts/restart_apache.php and redirect STDOUT and STDERR to NULL device
unknown
d4219
train
For future reference: Most often you should clear the cache and sessions. Use the appadmin interface to have a gui for this. This solved the issue for me more than once. Sessions are pickled files which might lead to these problems. For example if you synchronize between different platforms, python versions and maybe sometimes even between upgrades on web2py (though i'm not certain on the latter).
unknown
d4220
train
Use the following dax formula: Fiscal Purchase Index = VAR __entity = 'Purchases'[Entity ID] var __year = 'Purchases'[FISCAL YEAR] var __table = FILTER ( all('Purchases'), 'Purchases'[Entity ID] = __entity && 'Purchases'[FISCAL YEAR] = __year ) var __result = RANKX(__table, Purchases[Date] ,, 1, Dense) RETURN __result Hope it helps.
unknown
d4221
train
I found the problem. My second test is wrong as it's actually submitting a valid request to the server in that 'name' is not blank. I removed it and now the test passes. A: Rails will by default save records created from nested attributes even if the validations of the parent record fails. Thats why Item.count increases. .count unlike collection#size always queries the database. What you need to do is create a validation on Item that tells Rails that an Item is not valid unless the parent collection is valid. class Item < ActiveRecord::Base belongs_to :collection has_many :item_ownerships, :dependent => :destroy accepts_nested_attributes_for :item_ownerships validates :name, :presence => true, length: { maximum: 50 } validates :collection, :presence => true validates_associated :collection #! end http://guides.rubyonrails.org/active_record_validations.html#validates-associated
unknown
d4222
train
Consider using Maven Shade Plugin. This plugin provides the capability to package the artifact in an uber-jar, including its dependencies Spring framework can do similar thing for you. Generate sample project and check its pom file. A: maven-jar-plugin provides the capability to build jars without dependencies. To create jar with all it's dependencies you can use maven-assembly-plugin or maven-shade-plugin. Below is maven-assembly-plugin configuration in pom.xml: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <archive> <manifest> <mainClass> fully.qualified.classpath.Main </mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin> More information: executable-jar-with-maven A: Try this out inside your pom.xml file: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <id>copy-dependencies</id> <phase>prepare-package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/classes/lib</outputDirectory> <includeScope>runtime</includeScope> </configuration> </execution> </executions> </plugin> </plugins>
unknown
d4223
train
HTML::Entities does the conversion in a little sub named num_entry. Redefine that to be whatever you want: use utf8; use HTML::Entities qw(encode_entities_numeric); { no warnings 'redefine'; sub HTML::Entities::num_entity { sprintf "&#%d;", ord($_[0]); } } my $str = "some special chars like € ™ © ®"; encode_entities_numeric($str); print $str; For what it's worth, this is the sort of thing Perl wants you to do. It's designed so that you can change things in this manner. It would be nicer if HTML::Entities were set up to allow derived classes, but it's not. Perl, recognizing that the world is messy like this, has ways for you to adjust that for what you need. A: No, it's not configurable (because &#x20AC; and &#8364; are 100% equivalent in HTML).
unknown
d4224
train
I continued my search and I did it, I was thinking about delete this post but I'll post what I did here so others can use it. MyChronometer.setOnChronometerTickListener(new OnChronometerTickListener() { public void onChronometerTick(Chronometer p1) { if (MyChronometer.getText().toString().contains(MyEditText.getText().toString())) { //Do something } } }); I use contains(something) to compare, i don't know why but it didn't work as expected when I used ==something Hope it helps someone.
unknown
d4225
train
Have you thought about using strtok to parse the tokens after the fgets? A: What I would use is the 'a' modifier for the scanf-format: Simply say 'fscanf("%as:%as:...", ...)', pass in the addresses of unallocated pointers and let fscanf malloc them for you. This originated as a gnu extension, but AFAIK, it has made it into the C11 standart.
unknown
d4226
train
Your expressions are treated as text because they are not inside curly braces ({}). Curly braces are already part of the computed element constructor syntax, but they need to be added when using a direct element constuctor to differentiate between plain text and expressions: <numerator>{ m:evaluate($tree/*[1]/numerator) * m:evaluate($tree/*[2]/numerator)}</numerator>
unknown
d4227
train
All of those (HTML, CSS, JavaScript) work on the client side, always have, they are part of the presentation layer and the web browsers have always been capable of displaying the source code for what's presented to the user. So no, you can't have closed-source projects that are solely based upon HTML, CSS and/or JavaScript A: You can't really protect JavaScript since it has be run by the browser. There are tools to obfuscate JavaScript but it's trivial to reverse the process. A: One of the things that really irritates me about JavaScript is the fact that it is non-compiled. One way you can help combat this is by using a minifier before you deploy your source. Here is a good one for CSS and Javascript: http://aspnet.codeplex.com/releases/view/40584 Another way you can manipulate the Document Object Model (DOM) without using Javascript is the use Silverlight/Flash or a Java/DOM API like: http://www-archive.mozilla.org/projects/blackwood/dom/ You can also try using an obfuscator but usually minification does a fair job of obfuscation. Please don't rely on JavaScript to enforce secuity for your site since Javascript can be easily hacked. It is okay to use JavaScript to help the user find his/her way, but all client side Javascript validation must be followed up with Server Side validation.
unknown
d4228
train
FYI Spring Security 5 does not yet support private_key_jwt which is why you're having to do extra work to get it working. (Adding an answer as I don't have enough reputation to comment)
unknown
d4229
train
It helps to not think about workflow behavior in terms of replay. Replay is just a mechanism for recovering workflow state. But when workflow logic is written it is not really visible besides the requirement of determinism and that workflow code is asynchronous and non blocking. So never think about replay when designing your workflow logic. Write it as it is a locally executing asynchronous program. So when replay is not in a way the @Signal is just a callback method that executes once per received signal. So if you invoke some action from the @Signal method then it is going to execute once. As for second question it depends on the order in which cancellation and activity completion are received. If cancellation is first then cancellation is delivered to a workflow first which might cause the cancellation of the activity. Cancellation is actually blocking waiting for activity to cancel. Completion of activity (which is the next event) unblocks the cancellation for it. If completion is second then activity completes and whatever follows it is cancelled by the next event. In majority of cases the result is exactly the same that activity completion is received but all logic after that is cancelled.
unknown
d4230
train
Sounds like you've got CSS rules interfering with the CSS rule of ngx-extended-pdf-viewer. Create a greenfield project to check if it's a general problem: * *Open a terminal and navigate to the root folder of your project. *Run this command and accept the defaults: ng add ngx-extended-pdf-viewer *Add the new component <app-example-pdf-viewer> to your <app-component> to display the PDF file. Now you've got a working project that almost certainly does not suffer from your bug. Use the developer tools of your browser to compare the CSS code of the two projects to hunt down the bug.
unknown
d4231
train
After much head scratching, scouring the internet, and trial and error, I have my answer. The crux of the problem was that when I opened my pipe for writing, I didn't specify a "buffering" argument. This caused my pipe write to be cached somewhere in a buffer instead of being immediately written to the pipe. Whenever I "opened" my write pipe, it flushed the buffer to the pipe and my reader then picked it up. The solution was to add ",0" as an additional argument to my "open" command (PipeOut = open(PipeName, 'w',0) instead of PipeOut = open(PipeName, 'w')), thus setting the buffer size to zero. Now when I "write" to the pipe, the data goes directly to the pipe and doesn't sit around in limbo until flushed.
unknown
d4232
train
As shown in the slice documentation: [x,y,z] = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2); v = x.*exp(-x.^2-y.^2-z.^2); xslice = [-1.2,.8,2]; yslice = 2; zslice = [-2,0]; slice(x,y,z,v,xslice,yslice,zslice) colormap hsv You can pass the coordinate system as the first three arguments to slice, then express the slice locations in this coordinate system, so in your case: [x,y,z] = meshgrid(0:100,0:100,0:7); slice(x,y,z,xslice,yslice,zslice) Where you'd express zslice in the range [0,7] when defining your desired slice locations.
unknown
d4233
train
Never mind, I fixed it add import com.adobe.crypto.MD5; also deleted all the " :* "
unknown
d4234
train
To get the nthItems: function nthItems(array, n){ const r = []; for(let i=n-1,l=array.length; i<l; i+=n){ r.push(array[i]); } return r; } const a = [ 'red', 'dark_red', 'dark_dark_red', 'green', 'dark_green', 'dark_dark_green', 'blue', 'dark_blue', 'dark_dark_blue' ]; console.log(nthItems(a, 2)); console.log(nthItems(a, 3)); A: StackSlave's answer is the most efficient way but if you want a recursive way you could do const a = [ 'red', 'dark_red', 'dark_dark_red', 'green', 'dark_green', 'dark_dark_green', 'blue', 'dark_blue', 'dark_dark_blue' ]; const nthItems = (array, n) => { const results = []; const addItem = index => { if (index < array.length) { results.push(array[index]); addItem(index + n); } }; addItem(0); return results; }; console.log(nthItems(a, 2)); console.log(nthItems(a, 3)); But this is recursive purely for the sake of recursion, it adds values to the stack unnecessarily when a for loop will do.
unknown
d4235
train
You should use routerLink. not href. You can routerLink. after import RouterModule. If you want to route to about component, you should write route info for about component in app-routing.module.ts. Official document is here =>> https://angular.io/api/router/RouterLink example code is (only required code) app-navbar.component.html <a class="nav-link" [routerLink]="['/about']">About</a> app-navbar.module.ts @NgModule({ imports: [RouterModule] }) app-routing.module.ts const routes: Routes = [{path: 'about', component: AboutComponent}]; A: You Should Use routerLink <a routerLink="/about.component"> and Make Sure that u added that component in Routes{ path: 'about.component', component: AboutComponent },
unknown
d4236
train
I bet, the script is before the jquery all, so the function "disappears". Try placing the script in a external file and making sure that try «I hope it helps» $this->registerJsFile( '@web/js/your_file.js', ['depends' => [\yii\web\JqueryAsset::class]] ); If it's not exactly this, but probably the function is being placed after the call, so it will be undefined, so try to be sure that the function gets rendered before the call.
unknown
d4237
train
From the Unity forums, "Order of Entities": * *ComponentDataArray<> / ComponentGroup makes zero gurantees on the actual ordering of your entities except for that its deterministic. But generally the indices are not stable. (E.g. Adding a component to an entity, will change the index in ComponentDataArray of that entity and likely of another one) The only stable id is the "Entity" ID. To answer your questions: So a few questions: 1. Should I ever rely on the order of an injected array for behaviour logic? Based on "...makes zero guarantees on the actual ordering of your entities..." I would say no. *Are there any better methods in achieving what I want using ECS? You don't need arrayIndex to access entities in your tile group. You can iterate through the entities and access x and y for each to perform the required behavior. Depending on your actual functionality you may want to use the job system as well. for (int i = 0; i < m_tileGroup.Length; i++) { int x = m_tileGroup.tile[i].xIndex; int y = m_tileGroup.tile[i].yIndex; // do something with x and y }
unknown
d4238
train
First, always use use strict; use warnings;!!! The problem is that you're not encoding your output. File handles can only transmit bytes, but you're passing decoded text. Perl will output UTF-8 (-ish) when you pass something that's obviously wrong. chr(0x865F) is obviously not a byte, so: $ perl -we'print "\xE8\x{865F}\n"' Wide character in print at -e line 1. è號 But it's not always obvious that something is wrong. chr(0xE8) could be a byte, so: $ perl -we'print "\xE8\n"' � The process of converting a value into to a series of bytes is called "serialization". The specific case of serializing text is known as character encoding. Encode's encode is used to provide character encoding. You can also have encode called automatically using the open module. $ perl -we'use open ":std", ":locale"; print "\xE8\x{865F}\n"' è號 $ perl -we'use open ":std", ":locale"; print "\xE8\n"' è
unknown
d4239
train
I feel like your function keeps repeating. So, you may possibly set a simple check to make sure it's done only once: var container = $('#Banner').children('div'); var previous = $('<a href="#" class="previous">'); // Check if element already exists before appending. if (container.find(".previous").length === 0) previous.appendTo(container); This way, it checks if the DOM element exists before it appends. I really feel that the big picture needs some alteration, but for this case, this solution should work out.
unknown
d4240
train
You can add several databases using the Database wizard. You will be missing the binding navigator but you can get this easily by creating a temporary form in your project add the database to this then just copy over the binding navigator before deleting the temp form. A: See this thread Display data from access using dataset The use the following. Try something like this after you load your table into a Dataset For Each row1 In (From dr As DataRow In yourDataSet.Tables(0).Rows Select dr Where dr("Column_Name").ToString.StartsWith(yourstring) somestring = row1("Column_Name").ToString
unknown
d4241
train
When you get the Add-on result it comes as part of the Twilio voice webhook, with all the normal request parameters as well as an extra AddOns parameter which contains the JSON that you have shared above. Webhook requests from Twilio are in the format application/x-www-form-urlencoded and then within the AddOns parameter the data is a JSON string. In a (Ruby-like) pseudo code, you can access the call sid and the add on data like this: post "/webhook" do call_sid = params["CallSid"] add_on_json = params["AddOns"] add_on_data = JSON.parse(add_on_json) # return TwiML end
unknown
d4242
train
Yes default libraries vary on different systems with different compilers. If you use a certain function, include the respective header. On your Mac the reverse function seems to be include somewhere deep in the string header. Use #include <algorithm> and it should work on the other systems too. A: The default standard library on Mac OS is libc++. The default standard library on Ubuntu is libstdc++. You can try on Ubuntu by passing -stdlib=libc++ to the compiler, and see what happens. The difference is (I suspect, but do not know for sure) that on libc++ string::iterator is a type in namespace std, so ADL lookup occurs, but in libstdc++ the iterators are just char *, and since they don't live in namespace std, no lookup in that namespace occurs.
unknown
d4243
train
Try this: function createNewTemplates() { const ss = SpreadsheetApp.getActive(); const sh1 = ss.getSheetByName('Test'); const sh2 = ss.getSheetByName('Exclusive Template Creation'); const vs2 = sh2.getRange('e1:l150').getValues(); const sr = 2; const vs1 = sh1.getRange(sr, 1, sh1.getLastRow() - sr + 1, 5).getValues(); const tss = SpreadsheetApp.openById('16nn9mfSOpVbPZBsB_nwhRNRv4nYQblrS1GzAD4jgmoQ'); let sh = tss.getSheetByName('Single Template'); vs1.forEach((r, i) => { if (r[0] !== '') { sh2.getRange('E3').setValue(r[0]); sh2.getRange('B1').setValue(r[1]); sh2.getRange('B2').setValue(r[2]); sh2.getRange('B3').setValue(r[3]); sh2.getRange('H2').setValue(r[4]); let shnew = sh.copyTo(tss).setName(r[0]); shnew.getRange(1, 1, vs2.length, vs2[0].length).setValues(vs2); } }); }
unknown
d4244
train
First time I had the problem it disappeared when I rebooted my computer, but today the problem appeared again. I've read on Google forums that the conflict comes when you are semi-logged with your Google account. If I log out completely my account or log in the map re-starts to work. In Safari you will find the same issue. A temporary solution is sandbox the map iframe to forbid it to access the cookies. A: https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame> or <iframe>. Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites. The counter-question I have to you is why are you implementing that URL in an iframe, when it specifically tells the browser it does not want to be loaded in an iframe? Did you follow the instructions at https://support.google.com/mapsenginelite/answer/3024935?hl=en when embedding the map? * *Make sure you have your desired map open and that it is set to be accessible by the Public. *Click the folder button. *Select Embed on my site. *In the box that appears, copy the HTML under 'Embed on the web,' and paste it into the source code of your website or blog. A: You're linking to the Google Account login page for the maps generator, not to a map. The link is probably not what you want. To make an embeddable map from Google Maps Engine, * *click on the green "Share" button on the top right and set you map to public *click on the folder icon on the top left (next to "Add layer") and choose "Embed on my site" A: 1) in the left bottom corner click on 6 teeth wheel , 'Share and integration of map' 2) In opened dialog press on 'integrate map' 3) you got iframe line with correct src .
unknown
d4245
train
Since you are plotting one point at a time, you need either a scatter plot or a plot with markers for dd in range (0, 1200, 100): tt1 = some_function(ff, dd) scatter(dd, tt1) # Way number 1 # plot(dd,tt1, 'o') # Way number 2 EDIT (answering your second question in the comments below): Save the results in a list and plot outside the for loop result = [] dd_range = range (0, 1200, 100) for dd in dd_range: tt1 = some_function(ff, dd) result.append(tt1) plt.plot(dd_range, result, '-o') A: You can vectorize your function and work with NumPy arrays to avoid the for-loop and better inform matplotlib of what you want to plot import numpy as np from pylab import * def some_function(ff, dd): if dd >=0 and dd <=200: tt = (22/-90)*ff+24 elif dd >=200 and dd <=1000: st = (22/-90)*(ff)+24 gg = (st-2)/-800 tt = gg*dd+(gg*-1000+2) else: tt = 2.0 return tt vectorized_some_function = np.vectorize(some_function) ff = float(25) dd = np.linspace(0, 1100, 12) tt = vectorized_some_function(ff, dd) plot(dd, tt) title("Something") xlabel("x label") ylabel("y label") show()
unknown
d4246
train
With InProc (in-memory) session state, you will lose session if any of the following conditions occur: * *IIS worker process restarts *User is transferred to another worker process on the same webserver, or another webserver *IIS restarts I would verify that you are not seeing any strange restart behavior on IIS, or if you are bouncing around in your cloud environment. A: If your using Forms authentication this has a timeout as well. <authentication mode="Forms"> <forms timeout="20"/> </authentication>
unknown
d4247
train
PyCharm Community doesn't have database tools. See comparison matrix https://www.jetbrains.com/pycharm/features/editions_comparison_matrix.html
unknown
d4248
train
This code will copy 7th row from all first 5 sheets into 6th sheet. Sub row_copy() For i = 1 To Worksheets.Count - 1 Sheets(i).Rows(7).Copy Sheets(6).Cells(i, 1) Next i End Sub A: Here is a sample for 6 sheets and rows # 7: Sub copyrow() Dim Nrow As Long, Nsheet As Long Dim i As Long Nrow = 7 Nsheet = 6 For i = 1 To Nsheet - 1 Sheets(i).Cells(Nrow, 1).EntireRow.Copy Sheets(Nsheet).Cells(i, 1) Next i End Sub The row # 7 from the first 5 sheets will be copied into the 6th sheet.
unknown
d4249
train
if you want to connect to a Windows IoT Core raspberry-pi computer and wish to control GPIO remotely over the internet, you could download w3pi.info web-server and download the flipled atl server (visual c++) sample (requires raspberry pi 2). The flipled sample is configured to read the LED light on the raspberry pi 2 board, but you could re-code the sample to use a different pin number.
unknown
d4250
train
If you package your data into your res/raw folder, it will indeed be duplicated and unfortunatley cannot be removed once the phone is done with it ie after first run. You could experiment which is a smaller in size - packaging the data as a csv or xml file or as a precompiled DB in the res/raw folder and if acceptible go with the best. If you went with the csv or xml file option, you could run a parser on first run and process the data into a DB. Something I only found recently but the res/raw folder can only handle files of around 1mb, this is one solution I came across for packaging a large DB and moving it on first run, it doesn't get over the repition of data within the app: Database Populating Solution Here is an alternative from the android blogspot, the third one down maybe exactly what you are looking for: The downloader activity runs at the beginning of your application and makes sure that a set of files have been downloaded from a web server to the phone's SD card. Downloader is useful for applications that need more local data than can fit into an .apk file. Downloader Blogspot Possibly adapt this example - download the DB file from the server and then move it into your database folder. A: I was confronted to the same kind of situation: I am writing an app which has to access - locally – a database containing mainly text and weighing more than 20MB (7MB zip compressed). The best solution in my opinion for this kind of problem is to download the zipped compiled database on first execution of the app. The advantages of this solution: * *The APK stays light. This is a good because: * *very large APKs may discourage some potential users *testing is faster, as uploading a 7MB+ APK to an AVD (as I did initially) is pretty SLOW. * *There is no duplicate of your data (if you take care of deleting the ZIP archive after extracting it * *You don’t fill up your users phones internal memory. Indeed, your app should download the database directly to the SD CARD. Including big files in res/raw folders would cause much trouble to all users who run Android < 2.2, as they won’t be able to move the app to the SD CARD (I’ve seen several negative user comments due to this on some apps that use a few MBs on the internal memory). One last thing: I don’t recommend including a CSV or XML and populate the database from it on first run. The reason being this would be very SLOW, and this kind of processing is not supposed to be done by every client. A: Not a proper answer, but on the subject of option 1: remember an apk is a zip, so a text file, containing the same words over and over, would become a lot smaller.
unknown
d4251
train
This is what I ended up doing. public render(){ let htmlText = //The string above let doc = new DOMParser().parseFromString(htmlRender,'text/html'); let xpathNode = doc.evaluate("/html/body/ul/li[1]/a[1]", doc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); const highlightedNode = xpathNode.singleNodeValue.innerText; const textValuePrev = highlightedNode.slice(0, char_start); const textValueAfter = highlightedNode.slice(char_end, highlightedNode.length); xpathNode.singleNodeValue.innerHTML = `${textValuePrev} <span class='pt-tag'> ${highlightedNode.slice(char_start, char_end)} </span> ${textValueAfter}`; return( <h5> Display html data </h5> <div dangerouslySetInnerHTML={{__html: doc.body.outerHTML}} /> ) A: Xpath is inherently cross component, and React components shouldn't know much about each other. Xpath also basically requires all of the DOM to be created in order to query it. I would render your component first, then simply mutate the rendered output in the DOM using the Xpath selector. https://jsfiddle.net/69z2wepo/73860/ var HighlightXpath = React.createClass({ componentDidMount() { let el = document.evaluate(this.props.xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); el.singleNodeValue.style.background = 'pink'; }, render: function() { return this.props.children; } }); Usage: <HighlightXpath xpath="html//body//div/p/span"> ... app ... </HighlightXpath>
unknown
d4252
train
You could set the SelectedIndex to -1 in the LostFocus event, thus losing the selected item and removing the highlight.
unknown
d4253
train
Just thought i would be clear with my comment: try String var=""; for(int i=0;i<40;i++) { var=var+"text"; } //Then use the variable got text(var, x, y, 50, 50); There may be built in functions to do this in a better way, but this would be a simple way to solve your problem. This method though is in-efficient as String operations are costly in Java because they are immutable. The above example would print the same string 40 times in a single line(depending upon the length of the line). If the horizontal length of the line is not sufficient, either increase the line size or decrease the spacing or decrease the number of times you are repeating the string.
unknown
d4254
train
After looking at the same for how to upload a string as a file with Jquery and then looking at how the server processed the information. I determined that the data saved doesnt nessicarily have to be that of a file. When looking at responsees, all that information was in the string the next time it was pulled. I actually just removed the data and pushed it up and it returned what i wanted. var myData = { user: top.USERNAME, pass: top.PW_HASH, secure: true, url: top.BASE_URL, ext: "foo", data:saveXML }; which as you can see, the data being passed in the object to my $.ajax wrapper was just the saveXML.
unknown
d4255
train
The code is missing the modr/m byte between the opcode C7 and the displacement and immediate. mov dword [0x000B8000], 0x78073807 C7, 05, 00, 80, 0B, 00, 07, 38, 07, 78
unknown
d4256
train
You're on the right track. I think in your for loop in the controller, just put $scope.list.favorites[i].affiliateLink = [whatever the returned value of the specific affiliate link should be]; Then in the HTML, it would just interpolate as {{favorite.affiliateLink}} A: You probably want to use ng-click and this will call another method in your controller: <li><a ng-click="doSomething(favorite.product_id)" href="">{{favorite.product_id}}</a></li> in your controller : $scope.doSomething = function (prodId) { // Do whatever you want here }; A: You can accomplish this in a more elegant way using a tool that you already have - promises. Promises are there to help you chain events like this. A simple example would be: get('story.json').then(function(response) { return JSON.parse(response); }).then(function(response) { console.log("Yey JSON!", response); }); A very good introduction to promises can be found here [1]. [1] http://www.html5rocks.com/en/tutorials/es6/promises/
unknown
d4257
train
You could try NGINX, it can support HTTP/2. http://nginx.org/en/docs/windows.html Run your node applications by using default node, nodemon, pm2... Then use NGINX as a static web server and you can reverse proxy your node apps. A: If you want to use Node then this article seems to cover the basics: https://webapplog.com/http2-server-push-node-express/ and it seems the node-spdy module is the best option (it includes support for HTTP/2 despite the name). There is a node-http2 module but it seems much less well maintained and doesn't support Express (the most popular HTTP framework for Node). However, as discussed in the comments, while not the question you asked, I recommend running a traditional web server (e.g. Apache, Nginx or IIS) in front of NodeJS or any other traditionally back end server. While NodeJS is very flexible and most (if not all) of the functionality of a webserver can be added to it, a traditional web server comes out of the box with a lot of functionality and requires just configuration rather than programming and/or pulling in multiple other modules to set it up properly. For just serving static files Node seems the wrong solution to me so, for the rest of my answer I'll discuss not not using Node directly for the reasons given above but instead using a front end webserver. I don't know IIS too well but from a quick Google it seems HTTP/2 was only introduced in IIS 10 and, as far as I know, even IIS 10 doesn't support Push except through API calls so I agree with your decision not to use that for now. Nginx could be installed instead of IIS, as suggested, and while it supports HTTP/2 it doesn't yet support HTTP/2 (though Cloudflare have added it and run on Nginx so imagine it won't be long coming). Apache fully supports HTTP/2 including server push. Packaged windows versions of Apache can be downloaded from Apache Lounge so is probably the easiest way of supporting HTTP/2 push on Windows Server and would be my recommendation for the scenario you've given. While I mostly use Apache on Linux boxes I've a number of servers on Windows and have quite happily been running Apache on that as a Service (so it automatically restarts on server reboot) with no issues so not sure what "bad experience" you had previously but it really is quite stable to me. To set up Apache on a Windows Server use the following steps: * *Download the last version from Apache Lounge. *Unzip the files and save them to C:\ (or C:\Program Files\ if you prefer but update all the config to change the default C:\apache24 to C:\Program Files\) *Edit the conf\httpd.conf file to check ServerRoot, DocumentRoot and any Directory values are set to where you want it (C:\Apache24 by default). *Run a DOS->Command Prompt as Administrator *In the Administrator CD to the Apache location and the bin director. *Run httpd.exe and deal with any error messages (note port 80 must be free so stop anything else running on that report). *Check you get the default "It works!" message on http://localhost/ *Install Apache as a service by killing the httpd.exe process and instead running httpd.exe -install. *Start the Apache24 service and again verify you get the "It works!" message on http://localhost/ To add HTTP/2 and HTTPS (necessary for HTTP/2 on all browsers), uncomment the following lines from httpd.conf: LoadModule http2_module modules/mod_http2.so ... LoadModule socache_shmcb_module modules/mod_socache_shmcb.so ... LoadModule ssl_module modules/mod_ssl.so ... Include conf/extra/httpd-ssl.conf Install a cert and key to conf/server.crt and conf/server.key - note Apache 2.4 expects the cert file to include the cert plus any intermediary certs in X509 Base 64 DER format so should look something like this when opened in a text editor: -----BEGIN CERTIFICATE----- MII...etc. -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MII...etc. -----END CERTIFICATE----- Where the first cert is the server cert and the 2nd and subsequent certs are the intermediaries. You should make sure you're running good HTTPS config (the defaults in Apache are very poor), but the defaults will do for now. I've a blog post on that here. Restart Apache in the service menu and check you can access https://localhost (ignoring any cert error assuming your cert does not cover localhost). To add HTTP/2 to Apache Edit the conf/extra/httpd-ssl.conf file to add the following near the top (e.g. after the Listen 443 line): Protocols h2 http/1.1 Restart Apache in the service menu and check you can access https://localhost (ignoring any cert error assuming your cert does not cover localhost) and you should see h2 as the protocol in the developer tools of your web browser. To use HTTP/2 push in Apache add the following to push a style sheet: Header add Link "</path/to/css/styles.css>;rel=preload;as=style" env=!cssloaded And you should see it pushed to your page in developer tools. Again, I've a blog post on that if you want more information on this. If you do want to use Node for some (or all) of your calls you can uncomment the following line from conf/httpd.conf: LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so And then add the following config: ProxyPass /nodecontent http://127.0.0.1:8000/ Which will send any of those requests to node service running on port 8000. Restart to pick up this config. If your node service adds any HTTP headers like this: link:</path/to/style/styles.css>;rel=preload;as=style Then Apache should pick them up and push them too. For example if using Express you can use the following to set the headers: app.get('/test/', function (req, res) { res.header('link','</path/to/style.css>;rel=preload;as=style'); res.send('This is a test page which also uses Apache to push a CSS file!\n'); }); Finally, while on the subject of HTTP/2 push this article includes a lot of interesting food for thought: https://jakearchibald.com/2017/h2-push-tougher-than-i-thought/ A: I know this is a fairly old question, but I thought I would give an answer for those that come here looking for info. Node now has a native http2 module and there are some examples on the web that show exactly how to implement a static web server. NOTE: At the time of this answer Node 9.6.1 is current and the native module is still experimental Example https://dexecure.com/blog/how-to-create-http2-static-file-server-nodejs-with-examples/ NOTE: I have no affiliation to the author of the example
unknown
d4258
train
Turns out that the problem was caused by me requesting the data with $.get instead of with $.getJSON This is the correct call... var year = $("#year").text(); var month = $("#month").text(); $maintenance_schedule_calendar_table = $("#vehicles_maintenance_schedule_calendar").fullCalendar({ year: year, month: month -1, header: { left: 'prev,next today', center: 'title', right: '' }, editable: true, disableResizing: true, events: function(start, end, callback) { var start_timestamp = Math.round(start.getTime() / 1000); var end_timestamp = Math.round(end.getTime() / 1000); var url = "/tripsys/new_admin/vehicles/get_maintenance_schedule_data/" + start_timestamp + "/" + end_timestamp; $.getJSON(url, function(events) { callback(events); }); } });
unknown
d4259
train
You cannot do this. Rust macros are not C macros that perform dumb textual manipulation; Rust macros must result in valid Rust code and a, b, c is not valid. The closest would be to pass in the function to the macro: macro_rules! rgb { ($f:expr, $rgb:expr) => { $f($rgb.0, $rgb.1, $rgb.2) }; } let white = (1., 1., 1.); rgb!(set_color, white);
unknown
d4260
train
Try this syntax. Add the constant values to select query select list INSERT INTO settings (user_id, setting_id, value) SELECT id,16,true FROM users A: Use insert . . . select: INSERT INTO settings (user_id, setting_id, value) SELECT id, 16, true FROM users;
unknown
d4261
train
Here you go straight from the docs: Registering a Service with $provide You can also register services via the $provide service inside of a module 's config function: angular .module('myModule', []) .config(['$provide ', function($provide) { $provide.factory('serviceId ', function() { var shinyNewServiceInstance; // factory function body that constructs shinyNewServiceInstance return shinyNewServiceInstance; }); } ]); This technique is often used in unit tests to mock out a service' s dependencies. Hope this helps. (function() { 'use strict'; angular .module('example.app', []) .config(['$provide', function($provide) { $provide.factory('serviceId', function() { var shinyNewServiceInstance; // factory function body that constructs shinyNewServiceInstance return shinyNewServiceInstance; }); } ]) .controller('ExampleController', ExampleController) .service('exampleService', exampleService); exampleService.$inject = ['$http']; function ExampleController(exampleService) { var vm = this; vm.update = function(person, index) { exampleService.updatePeople(person).then(function(response) { vm.persons = response; }, function(reason) { console.log(reason); }); }; } // good practice to use uppercase variable for URL, to denote constant. //this part should be done in a service function exampleService($http) { var URL = 'https://beta.test.com/auth/authenticate/', data = {}, service = { updatePeople: updatePeople }; return service; function updatePeople(person) { //person would be update of person. return $http .post(URL, person) .then(function(response) { return response.data; }, function(response) { return response; }); } } })(); A: you can use like: angular.module('app', ["ui.router"]) .config(function config ($stateProvider){ $stateProvider.state("index", { url:"", controller: "FirstCtrl as first", templateUrl: "first.html" }) .state("second", { url:"/second", controller:"SecondCtrl as second", templateuRL:"second.html" }) }) here is the full working example with plunker
unknown
d4262
train
No, user is NOT logged in: callback with FALSE return process.nextTick(() => cb(null, false)); } var user = app.models.user; var objUser = user.findById(userId); console.log('obj',objUser) if(objUser.admin==1){ return cb(null, true); } else{ return cb(null, false); } }); Do you have any idea what's wrong am I doing. Any help would be appreciated. Thank you. A: you should read about javascript Promises, it's crucial to understand javascript in general and async programming. Also, check the async/await
unknown
d4263
train
The assertion fails because get: function number() {...} isn't the same function as in the descriptor, function number() {} !== function number() {}. It should be asserted to be any function with: ... number: { get: expect.any(Function), set: undefined, enumerable: true, configurable: true } ...
unknown
d4264
train
Fairly sure you can't do this with CSS alone--because any negative margin workarounds for horizontal and vertical centering only works when you can used fixed sizes (as using a negative percentage margin will take the percentage from the parent container rather than the element's original size.) However, you can do this with JS. http://jsfiddle.net/HkuMW/7/ So, we apply the percentage left and top to sit exactly in the middle (but from the image's top-left corner): div.imgInner>img { display:block; position:absolute; top:50%; left:50%; } Then we use jQuery to re-position the image by finding out the exact pixel dimensions, halving it, and popping that in: $('.imgInner > img').each(function (i) { var imgWidth = ((0 - parseInt($(this).css('width'))) / 2); var imgHeight = ((0 - parseInt($(this).css('height'))) / 2); $(this).css('margin-top', imgHeight); $(this).css('margin-left', imgWidth); }); A: See if this answers your question. http://jsfiddle.net/HkuMW/17/ You can change the background-size:100% auto; to background-size:auto 100%; if you need to swap the resizing method.
unknown
d4265
train
You could maybe look into different mouse events, such as 'mousedown' or 'mouseup'? and possibly add a small script to handle the callback. <!DOCTYPE html> <html> <head> <title>S S</title> <link rel="stylesheet" href="style.css"> </head> <body> <ul> <li class="box a" onmouseup="flipCard($event, true)">S</li> <li class="box b" onmouseup="flipCard($event, false)">S</li> </ul> <script> function flipCard(event, goRight) { var classToToggle = goRight ? 'rflip' : 'flip'; event.target.classList.toggle(classToToggle); } </script> </body> </html> If you want the transition to occur at a specific time, you can also use a timeout (1000 is milliseconds, so 1 second): function flipCard(event, goRight) { setTimeout(function() { var classToToggle = goRight ? 'rflip' : 'flip'; event.target.classList.toggle(classToToggle); }, 1000); } this was written without any testing, but the concept should be there A: From ur rflip class, I think u wish to have reverse flip thats why you have transform: rotateY(180deg); in a class If this is what you want to get rid of u can try .a { background: #fff; color: #000; transform: rotateY(360deg); } .rflip { transform: rotateY(180deg); }
unknown
d4266
train
There is a builtin CMY color model for the palette, but I don't think that helps for this purpose. I can propose an alternative method that is slightly simpler than what you show. It works specifically for CMY, whereas the scheme you show could be adapted for other sets of colors. So honestly I think you may be better off with what you have. # Assume input CMY values are in the range [0:1] # We will convert to RGB values also in the range [0:1] # Since color component values by default run from 0-255 we must # first reset that range. # set rgbmax 1.0 # this command introduced in version 5.2.1 plot data using 1:2:(1.-$3):(1.-$4):(1.-$5) with rgbimage
unknown
d4267
train
The purpose of raising an exception is to provide an alternate exit point in the event where a valid return value can't be found. You are using exceptions exactly as they are intended. However, I would probably check if exhale_dir is non-positive first, which would save you from performing a calculation with an invalid value. if exhale_dur <= 0: raise error.ConfigurationError elif (inh_dur + breath_hold_dur + exhale_dur) > single_breath_dur): raise error.ConfigurationError # You can also omit the else, since the only way to reach this point # is to *not* have raised an exception. This is a matter of style, though. return exhale_dur A: No. Exceptions are either handled in a piece of code, or thrown, and leave it to the caller to decide what to do with them. If you return something, you have to choose the first option. You chose the second. Makes perfect sense. That's the whole idea of throwing an exception
unknown
d4268
train
This is possible using flexbox. html, body { height: 100%; } body { display: flex; flex-direction: column; justify-content: center; align-items: center; } See this CodePen
unknown
d4269
train
I just realized I needed to install docker-compose which deals with running multiple docker containers instead of just using docker client. For docker-compose installation, I consulted the manual A: I think you did not start your fabric, if you are developing locally. Please look at https://hyperledger.github.io/composer/installing/development-tools.html for the environment setup and the scripts you need to run inorder to have a local fabric. When you run docker ps you should see something like this docker list of containers
unknown
d4270
train
Short answer, I would try helm upgrade. A: In recent helm versions you can run helm upgrade --install which does an upgrade-or-install. Another alternative is you can use helm template to generate a template and pipe it to kubectl apply -f -. This way you can install or upgrade with the same command.
unknown
d4271
train
RTL support was introduced in Android 4.2 (API 17). You can specify android:layoutDirection="rtl" for all top layouts of your app. By default, it will be inherited by all child layouts and views.
unknown
d4272
train
Aha! In <system.webServer>: <httpErrors existingResponse="PassThrough" /> This does exactly what I want.
unknown
d4273
train
use a QTimer and in the slot update the value of the progressbar MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); t = new QTimer(this); t->setSingleShot(false); c = 0; connect(t, &QTimer::timeout, [this]() { c++; if (c==100) { c=0; } qDebug() << "T..."; ui->progressBar->setValue(c); }); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { t->start(100); } A: I'm not sure about your intentions with such sleep: are you simulating long wait? do you have feedback about progress during such process? Is it a blocking task (as in the example) or it will be asynchronous? As a direct answer (fixed waiting time, blocking) I think it is enough to make a loop with smaller sleeps, like: EscreveVariavel(wEndereco, wValor); for (int ii = 0; ii < 100; ++ii) { progresso->setValue(ii); qApp->processEvents(); // necessary to update the UI std::this_thread::sleep_for(std::chrono::milliseconds(150)); } EscreveVariavel(wEndereco, ifValor); Note that you may end waiting a bit more time due to thread scheduling and UI refresh. For an async task you should pass the progress bar to be updated, or some kind of callback that does such update. Keep in mind that UI can only be refreshed from main thread.
unknown
d4274
train
If these are different applications (to the user) then yes, user should be asked to confirm if he is willing to authorise A to access B. If he does not want to that, then A has no biz talking to B on behalf of the said user. If this is set of microservices then user need to interact with via Web Page and any subsequent calls if being made to n different services is something that user should not be concerned with. As such he is trusting the web page and asking web page for some data. You have set of microservices sitting behind to answer that, is not of concern for user and his token. So you can make use of second option. Talking about user context, well that can shared in some other forms like passing via headers. Should the access token be passed around microservices? Yes, there should be no harm in that. It adds to the payload but certainly can be done. Important thing to note is that users access token can be used by services to mimic a user call to another service. If such calls are threat to your design then you should reconsider. But mostly we feel that what ever you do within your boundary is safe and you can trust other services in that boundary and hence can pass it along. Should there be a different authorization framework for internal requests? It depends, if you want to separate it for security reason, you can, if you want to do it for load reason you can. You can also think of stripping tokens at the gateway (verify the token at the entrypoint) and let go off it. For systems where you can trust other services (amongst your microservices) and ensure no on one can access them directly, other than the API gateways, you can just let the token go. You loose authorization bit, but again our point is we trust services and believe they know what they are doing, so we do not put restrictions to such calls.
unknown
d4275
train
You are trying to parse characters into a double and that's why it's throwing an exception. Declare your first name & last name as strings and get them from input by using Input.nextLine() Instead of Input.nextDouble() A: Are you storing text into your firstname and lastname variables? That is obvious data type mismatch. Use Strings, they are what stores text. String firstname; // Stuff firstname = input.nextLine(); Doubles are for floating point number of a certain length. Also, use int whenever possible. final int UNITS1 = 1000; final int UNITS2 = 3000; final int UNITS3 = 6000; final int BONUS1 = 25; final int BONUS2 = 50; final int BONUS3 = 100; final int BONUS4 = 200; // Stuff int bonusAmount; Work on your primitive datatype knowledge. Hope this helps! A: Cases when these exception are thrown:- InputMismatchException − if the next token does not match the Float regular expression, or is out of range lastname=scaner.nextDouble(); At this line you would have been entering string value, however it expecting double. NoSuchElementException − if the input is exhausted IllegalStateException − if this scanner is closed
unknown
d4276
train
In your exam activity, override onPause() and paste cancel exam method before super.onPause(). Edit: I think you need onPause() instead of onStop(). Learn more about Activity Life cycle A: When you minimize app, onStop will called. Called when you are no longer visible to the user So inside onStop you can cancel the example @Override protected void onStop() { super.onStop(); // cancel exam here }
unknown
d4277
train
property tag should be within configuration tag <configuration> <property> <name>hadoop.tmp.dir</name> <value>/usr/local/Cellar/hadoop/hdfs/tmp</value> <description>A base for other temporary directories.</description> </property> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> </configuration>
unknown
d4278
train
Turns out the issue is with running Nginx withing VirtualBox. in /etc/nginx/nginx.conf sendfile needs to be off
unknown
d4279
train
use print pickle.load(process.stdout) does this work? read may not return the whole string. A: This line: print index, each.name() Causes issues, as it is sending debug output to stdout before the pickle is sent.
unknown
d4280
train
Once you have value in px, multiply it by 100/($(window).width()) For example(in your case): $('.textarea').css('font-size')*(100/($(window).width())) Please let me know, if it works A: When using jQuery .css('font-size'), the value returned will always be the computed font size in pixels instead of the value used (vw, em, %, etc). You will need to convert this number into your desired value. (The following uses a font size of 24px and a window width of 1920px as an example) To convert the px into vw, first convert the computed font size into a number. // e.g. converts '24px' into '24' fontSize = parseFloat($('.textarea').css('font-size')); Next, multiply this number by 99.114 divided by the window width. (Usually when converting px to vw, you would divide 100 by the window width, however I find the results are slightly incorrect when converting for font sizes). // returns 1.2389249999999998 fontSize = fontSize * (99.114 / $(window).width()); You can optionally clean up the large decimal returned by rounding to the nearest 100th decimal place. // returns 1.24 fontSize.toFixed(2) And now you have the final number you need, just manually add 'vw' where desired. // returns 1.24vw fontSize = fontSize + 'vw'; Of course, you can put this all together if you want to shorten your code // returns 1.24vw newFontSize = (parseFloat($('.textarea').css('font-size'))*(99.114/ $(window).width())).toFixed(2) + 'vw';
unknown
d4281
train
Yeah, the article you referenced, essentially stipulates that since the reads and writes are "simplified", at the OS level, they can be unpredictable resulting in "loss in translation" issues when going local-network-remote. They also point out, it may very well work totally fine in testing and perhaps in production for a time, but there are known side effects which are hard to detect and mitigate against -- so its a slight gamble. Again the implementation they are describing is not Google Cloud Disk, but rather simply stated as a remote networked arrangement. My point is more that Google Cloud Disk may be more "virtual" rather than purely networked attached storage... to my mind that would be where to look, and evaluate it from there. Checkout this thread for some additional insight into the issues, https://serverfault.com/questions/823532/sqlite-on-google-cloud-persistent-disk Additionally, I was looking around and I found this thread, where one poster suggest using SQLite as a read-only asset, then deploying updates in a far more controlled process. https://news.ycombinator.com/item?id=26441125 A: the persistend disk acts like a normal disk in your vm. and is only accessable to one vm at a time. so it's safe to use, you won't lose any data. For the performance part. you just have to test it. for your specific workload. if you have plenty of spare ram, and your database is read heavy, and seldom writes. the whole database will be cached by the os (linux) disk cache. so it will be crazy fast. even on hdd storage. but if you are low on spare ram. than the database won't be in the os cache. and writes are always synced to disk. and that causes lots of I/O operations. in that case use the highest performing disk you can / are willing to afford.
unknown
d4282
train
The Expression<Func<string,bool>> is only a representation of an expression, it cannot be executed. Calling Compile() gives you a compiled delegate, a piece of code that you can call. Essentially, your program composes a small code snippet at runtime, and then call it as if it were processed by the compiler. This is what the last two lines of your code do: as you can see, the compiled snippet can analyze the length of the string that you pass in - when the length is less than five, you get a True back; when it's five or more, you get a False. What happens on first execution of the compiled snippet is platform-dependent, and should not be detectable by programmers using the .NET platform. A: Compile() takes the expression tree (which is a data representation of some logic) and converts it to IL which can then be executed directly as a delegate. The only difference between the first execution and later executions is the possibility that Compile() won't trigger the JIT compilation from IL to native processor code. That may happen on first execution. A: When you are building the expression tree at runtime there's no code emitted. It's a way to represent .NET code at runtime. Once you call the .Compile method on the expression tree the actual IL code is emitted to convert this expression tree into a delegate (Func<string, bool> in your case) that you could invoke at runtime. So the code that this expression tree represents can be executed only after you compile it. Calling Compile is an expensive operation. Basically you should be calling it once and then caching the resulting delegate that you could use to invoke the code many times.
unknown
d4283
train
Keep it simple and the bugs will fix themselves. Don't mix up the position in the result buffer with the loop iterators. No need for temporary variables. #include <stdio.h> typedef struct { char *str; int wordSize; } word; void concat(word words[], int arraySize, int maxSize) { char result[maxSize]; int count=0; for(int i=0; i<arraySize; i++) { for(int j=0; j<words[i].wordSize; j++) { result[count]= words[i].str[j]; count++; } } result[count] = '\0'; puts(result); } int main() { word w[3] = { {"he", 2}, {"ll", 2}, {"o", 1} }; concat(w, 3, 128); } A: In this for loop for (int j = 0; j < words[i].wordSize; j++, resultSize++) { result[resultSize + j] = tmp.str[j]; } you are incrementing resultSize and j simultaneously while you need to increase only the variable j and after the loop increase the variable resultSize by j. But in any case the function is wrong because there is no check that resultSize is less than maxSize. And moreover the built string is not appended with the terminating zero '\0'. As a result this statement puts(result); invokes undefined behavior. There is no need to create the variable length array char result[maxSize]; just to output the concatenated string. The function can be declared and defined the following way as it is shown in the demonstrative program below. #include <stdio.h> struct word { char *str; int wordSize; }; void concat( const struct word words[], size_t arraySize, size_t maxSize ) { for ( size_t i = 0, j = 0; i < maxSize && j < arraySize; j++ ) { for ( size_t k = 0; i < maxSize && k < words[j].wordSize; i++, k++ ) { putchar( words[j].str[k] ); } } putchar( '\n' ); } int main(void) { struct word words[] = { { "he", 2 }, { "ll", 2 }, { "o", 1 } }; const size_t arraySize = sizeof( words ) / sizeof( *words ); concat( words, arraySize, 5 ); return 0; } The program output is hello A: You have a couple of problems here. result[resultSize + j] means you are effectively skipping over half the characters in result. Secondly, if you copy the entire string, including the null character, puts will stop printing the result string at the end of the first word itself. So you need to skip copying the string terminator and put it in at the end of your whole concatenated string. #include <stdio.h> struct word { char *str; int wordSize; }; void concat(struct word words[], int maxSize) { // word array and max size given char result[maxSize]; int resultSize = 0; struct word tmp; for (int i = 0; i < 3; i++) { tmp = words[i]; // Keep copying the words to result, one after the other // But drop the last NULL character for (int j = 0; j < (words[i].wordSize - 1); j++, resultSize++) { result[resultSize] = tmp.str[j]; } } // Put the NULL character in after all words have been copied result[resultSize] = 0; puts(result); } struct word mywords[] = { { "TestWord", sizeof("TestWord")}, { "TestWord2", sizeof("TestWord2")} }; int main(void) { concat(mywords, 100); return 0; }
unknown
d4284
train
I've found a workaround, but would still like to hear if anyone had a similar problem. Workaround: * *Replaced Activity's theme DialogWhenLarge with Theme.AppCompat.Light.Dialog. This allows the adjustResize to behave as expected with ActionBarActivity *Added toolbar.xml layout as android.support.v7.widget.Toolbar *Assigned the toolbar as action bar in my Activity *Set activity's height for 10' tablets layout-sw720dp to 500dp for better presentation Configure toolbar as action bar: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout...); Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); setSupportActionBar(toolbar); } More on toolbar at android developer blog and stackoverflow
unknown
d4285
train
You are probably looking for ImageButton since your picture shows something similar to that. Alternatively, take a look at ImageView A: set layout's orientation to horizontal, then add 4 images in xml, one after another, add ids like image1, image2 etc, then call them in your onCreate like ImageView image ImageView image1 = (ImageView) findViewById(R.id.image1) and so on, then you can either set "src" attribute in yoru xml or say image1.setImageBitmap or any other method available in ImageView class to set the image you want from your res/drawable/ A: you can use ImageButton in horizontal LinearLayout make background of the ImageButton @null then put the margins between them
unknown
d4286
train
I guess you must replace: RadioGroup radioGroupEtat=(RadioGroup) findViewById(R.id.rardEtat); to RadioGroup radioGroupEtat=(RadioGroup) view2.findViewById(R.id.rardEtat); because you have to find your children views inside your inflated parent view, and your parent view for alert dialog is view2
unknown
d4287
train
At a guess, that'll be so that the controller can deliver viewDidLayoutSubviews and the similar messages. A: The delegate used when the view controller adds a subview to its own view or add a view to a window. Also used so that a UIView can call nextResponder.
unknown
d4288
train
If you want to pass a file you can skip the byte array and MemoryStream and just use Response.WriteFile(string)
unknown
d4289
train
You can connect to a remote database or on your local machine. Define which database you want to use, so in your database server be 127.0.0.1:PORT (that means that the database is your machine) (THE PORT will change depending on which SGDB you want
unknown
d4290
train
If you want to run your server in the cloud so that customers can access your React application you need two things: * *one server/service to run your database, e.g. Neo4j AuraDB (Free/Pro) or other Cloud Marketplaces https://neo4j.com/docs/operations-manual/current/cloud-deployments/ *A service to run your react application, e.g. netlify, vercel or one of the cloud providers (GCP, AWS, Azure) that you then have to configure with the server URL + credentials of your Neo4j server You can run neo4j-admin dump --to database.dump on your local instance to create a copy of your database content and upload it to the cloud service. For 5.x the syntax is different, I think neo4j-admin database dump --path folder.
unknown
d4291
train
I'm going to make my own minimal reproducible example so if you need to tweak it to apply to your use case, hopefully you can. Imagine I have this Foo class that takes a message and concats dates or times or something onto it: class Foo { message: string; constructor(message: string) { this.message = message; } concatDate() { this.message += " @ " + new Date().toLocaleTimeString(); } } let f = new Foo("hello there"); console.log(f.message); // "hello there" f.concatDate(); console.log(f.message); // "hello there @ 12:56:10 PM" await new Promise(resolve => setTimeout(resolve, 2000)); f.concatDate(); console.log(f.message); // "hello there @ 12:56:10 PM @ 12:56:12 PM" Oops, every time I call concatDate() it adds to the end of message. How can I fix it? Well, one idea is that you can try to look at message and strip off any date string if one is there. Like this: class BadFixFoo { message: string; constructor(message: string) { this.message = message; } concatDate() { this.message = this.message.replace(/ @[^@]*$/, "") + " @ " + new Date().toLocaleTimeString(); } } It kind of works: f = new BadFixFoo("hello there"); console.log(f.message); // "hello there" f.concatDate(); console.log(f.message); // "hello there @ 12:56:12 PM" await new Promise(resolve => setTimeout(resolve, 2000)); f.concatDate(); console.log(f.message); // "hello there @ 12:56:14 PM" Until it doesn't work: f = new BadFixFoo("what if I use an @-sign in the message"); console.log(f.message); // "what if I use an @-sign in the message" f.concatDate(); console.log(f.message); // "what if I use an @ 12:56:14 PM" await new Promise(resolve => setTimeout(resolve, 2000)); f.concatDate(); console.log(f.message); // "what if I use an @ 12:56:16 PM" See, the method I used to strip off the date just looked for the last @ sign (after a space) in the message and removed it and everything after it. But if the original message has an @ sign in it, then the stripping will mess it up. Oops. Maybe we can write an even more clever way of identifying a date string, but if the user can truly write anything for the original message, there's nothing we can do to stop them from writing an actual date string. Do we want to strip that off? If not, you need to refactor so that you're not trying to forensically determine what the original message was. Instead, store it: class GoodFoo { originalMessage: string; message: string; constructor(message: string) { this.originalMessage = message; this.message = message; } concatDate() { this.message = this.originalMessage + " @ " + new Date().toLocaleTimeString(); } } This means that concatDate() never tries to modify the current message. Instead, it copies the originalMessage and appends to that: f = new GoodFoo("what if I use an @-sign in the message"); console.log(f.message); // "what if I use an @-sign in the message" f.concatDate(); console.log(f.message); // "what if I use an @-sign in the message @ 12:56:16 PM" await new Promise(resolve => setTimeout(resolve, 2000)); f.concatDate(); console.log(f.message); // "what if I use an @-sign in the mssage @ 12:56:18 PM" Playground link to code
unknown
d4292
train
This is because you have fixed props, which makes v-col thinks there is nothing inside the column. So the height of the button is not calculated, which makes the buttons overlap. Try something like this (example) <v-row> <v-col sm="12"> <v-btn fab dark small color="primary"> <v-icon dark>mdi-minus</v-icon> </v-btn> </v-col> <v-col sm="12"> <v-btn fab dark small color="pink"> <v-icon dark>mdi-heart</v-icon> </v-btn> </v-col> </v-row>; Your code <v-row v-for="(button, index) in socialMediaButtons" :key="index"> <v-col sm="12> <v-btn fab class="mt-5 ml-1"><v-icon>{{ button.logo }}</v-icon></v-btn> </v-col> </v-row>
unknown
d4293
train
The warning message you are receiving is because you are compiling your code with a C++ compiler. Probably with with -std=c++98 or -ansi or otherwise implicitly using the 1998 standard. You are trying to create a default initializer for a member of a struct, which is a feature not added to C++ until the 2011 standard. To compile a C++ program with this feature without the compiler warning you about this, you need to pass in the -std=c++11 or -std=gnu++11 flags to the compiler command as the warning states. If this is expected to be C code rather than C++ code, default initializers for structs are simply not a part of the language. You can initialize its member variables upon declaration of an object of that struct's type. An example of how you might do this with a C compiler: // definition of the struct struct uninter { char nome[5]; int RU; }; // declaration of an instance of an object of type struct uninter struct uninter x = {{'L','U','C','A','S'}, 2613496}; // alternative declaration if using C99 standard with designated initializers struct uninter y = { .nome={'L','U','C','A','S'}, .RU= 2613496 }; A: in general, cannot initialize a struct contents in C in the definition of the struct. Suggest something similar to: struct uninter { char nome[5]; int RU; }; struct uninter aluno = {.nome = "LUCAS", .RU = 2613496}; A: The problem with the code is that it is using non-static data member intializers: struct uninter { char nome[5] = {'L','U','C','A','S'}; int RU = 2613496; }; struct uninter aluno; ... which is a C++11 feature, and therefore isn't portable unless you are using a C++11 (or later) compiler. (It might still compile under older compilers, if they have that feature enabled as a compiler-specific extension, but they are politely warning you that you can't expect it to compile everywhere) If you don't want your program to require C++11 or later to compile, the easiest thing to do would be to rewrite it so that the struct's member variables are initialized via a different mechanism. For example (assuming your c tag is intentional) you could have an init-method do it for you: struct uninter { char nome[5+1]; // +1 for the NUL/terminator byte! int RU; }; struct uninter aluno; void Init_uninter(uninter * u) { strcpy(u->nome, "LUCAS"); u->RU = 2613496; } [...] int main() { int i; Init_uninter(&aluno); [...] ... or if you actually intended to specify/use a pre-C++11 version of C++, a default-constructor would do the trick a bit more gracefully: struct uninter { uninter() { strcpy(nome, "LUCAS"); RU = 2613496; } char nome[5+1]; // +1 for the NUL terminator byte! int RU; }; struct uninter aluno;
unknown
d4294
train
you can use Container instead of Ink and able to use gradient effect. Positioned( right: -5.0, bottom: -5.0, child: SizedBox( height: 30.0, width: 30.0, child: Container( decoration: BoxDecoration( gradient: gradient, borderRadius: BorderRadius.all(Radius.circular(5.0)), ), child: Icon( OMIcons.cameraAlt, color: Colors.white, size: 15.0, ), ), ), ) A: I tried this in dart pad it worked alright. Positioned( right: -5.0, bottom: -5.0, child: SizedBox( height: 30.0, width: 30.0, child: Material( child: Ink( decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.pink, Colors.yellow]), borderRadius: BorderRadius.all(Radius.circular(5.0)), ), child: Icon( Icons.camera, color: Colors.white, size: 15.0, ), ), ), ), )
unknown
d4295
train
You'll need a language parser from which you can generate a control flow graph. Then you need to calculate the CC using this formula. I know of no library that will do this for you. You may be able to use the free pascal source to generate the control flow graph (its a common technique used in compilers to eliminate unreachable code). Unfortunately, Delphi hasn't shipped with a complete formal definition(bnf grammar) of the language in its documentation since Delphi 6 I believe. (even then it wasn't completely accurate) So all third party parsers are shooting in the dark.
unknown
d4296
train
You can use the RowDataBound event to add the ToolTip property to a GridViewRow. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { //check if the row is d datarow if (e.Row.RowType == DataControlRowType.DataRow) { //cast the row back to a datarowview DataRowView row = e.Row.DataItem as DataRowView; StringBuilder tooltip = new StringBuilder(); //add the data to the tooltip stringbuilder tooltip.Append(row["Last_Name"] + ", "); tooltip.Append(row["First_Name"] + ", "); tooltip.Append(row["Middle_Int"] + ", "); tooltip.Append(row["Telephone"] + ", "); tooltip.Append(row["Cell_Phone"]); //add the tooltip attribute to the row e.Row.Attributes.Add("ToolTip", tooltip.ToString()); } }
unknown
d4297
train
Please review the python docs on how to write functions with arguments: http://docs.python.org/tutorial/controlflow.html#defining-functions def myFunction1(): user = "foo" return user def myFunction2(user): print user user = myFunction1() myFunction2(user) Ideally you would organize a nice class structure, instead of using globals everywhere which I think is messy. Its a good sign that you should indeed be using a class when all of your functions end up needing to share some kind of state and you think you might need to start defining a ton of globals: class Client(object): def __init__(self): self.userId = None def getClient(self): self.userId = raw_input("To begin, enter your ID number: ") def parseClientInfo(self): # do something with self.userId print self.userId def clientPersonalInfo(self): # do something with self.userId print self.userId Please note that this class is a really simple example. A: You can reuse whatever you want, you just have to store it somewhere that is visible to both funcitons. You could make a class and put the information in a field or you could return it from the function and pass it on when you call the other function. Global variables are bad style, but that's doable too. A: To preserve the content of "user" (which would be better named "user_input" or some such), one way is to return the content of "user" along with whatever else you are returning in client(), perhaps in a tuple, and then passing it to clientpersonalinfo() as an argument, i.e. clientpersonalinfo(user). Another way is to put the code for getting "user" higher up in the hierarchy so that user exists in the function that calls both client() and clientpersonalinfo(), and then passing it as an argument to both functions. A: If I understand your question correctly, then I think that the best thing for you to do is to take the input call out of the first function and change the function definitions of both functions to take the user as an argument. The code would look something like: def client(user): clients = [] with open("clientes.txt",'r') as f: for client in f: clients.append(client.split('$')) for client in clients: if client[0] == user: ... user = raw_input("To begin, enter your ID number: ") client(user) and the other would be similar. There are a couple of changes from how you handle things. It is recommended that use use the "with open" form since it handles problems better than just opening the file, for instance. Also, naming variables so that the name is relevant to what you are doing makes your code easier to read, so avoid using names like A. Finally, you should use raw_input rather than input in general. The input function evaluates what is input by the user, which means that a user could call some code which is generally not what you want. The raw_input function returns a string which contains what the user put in.
unknown
d4298
train
Try this, it should work and go straight to finish: public boolean findPath(int row, int col) { board[row][col].visit(); if ((col == 7) && (row == 7)) { board[row][col].selectCell(); return true; } if ((row < 7) && !board[row + 1][col].marked() && !board[row + 1][col].blocked() && !board[row + 1][col].visited()) { block(row, col); if (findPath(row + 1, col)) { board[row][col].selectCell(); return true; } unblock(row, col); } if ((col > 0) && !board[row][col - 1].marked() && !board[row][col - 1].blocked() && !board[row][col - 1].visited()) { block(row,col); if (findPath(row, col - 1)) { board[row][col].selectCell(); return true; } unblock(row,col); } if ((col < 7) && !board[row][col + 1].marked() && !board[row][col + 1].blocked() && !board[row][col + 1].visited()) { block(row,col); if (findPath(row, col + 1)) { board[row][col].selectCell(); return true; } unblock(row,col); } if ((row > 0) && !board[row - 1][col].marked() && !board[row - 1][col].blocked() && !board[row - 1][col].visited()) { block(row, col); if (findPath(row - 1, col)) { board[row][col].selectCell(); return true; } unblock(row, col); } return false; } You needed to change orders.
unknown
d4299
train
Do you animate the root view of the activity or fragment? If yes, that makes sense. The whole screen will be rotated. If you want to animate the background of the view, you should add a new view which holds only the background then rotate it. <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorPurple_A400" tools:context=".MainActivity"> <View android:id="@+id/animation_view" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/drawable_purple_gradient"/> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"/> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
unknown
d4300
train
this might get you started http://code.google.com/p/dollar-touch/
unknown