INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Hyphenation penalty Say I have done `\hyphenation{a-no-ma-ly}`. In the text, the word is broken ano-maly. This is (etymologically) displeasing, but may be better than the spacing that would result from barring it. Can I do something in the text to penalize this break? I tried `… ano\penalty100maly`, but that just produced a break with no hyphen. PS: Is there no way to use `\penalty` (or something) with discretionary hyphens? Could one, for instance, redefine `\-` to work like this: `a\-1no\-2ma\-1ly`?
Not in `\hyphenation`, this is a well known limitation of tex. It most often comes up for languages with lots of compound words where it would be good (but not possible) to prefer breaking between the compounds. Also with the default settings of `\lefthyphenmin` and `\righthyphenmin` for English TeX will not use `a-nomaly` or `anoma-ly` so `\hyphenation{a-no-ma-ly}` is the same as `\hyphenation{ano-maly}`. Within the text, in a given instance you can of course manually break anywhere For example: Forced break: ... an-\linebreak omaly ... or explicit discretionary: ... an\-omaly The precedence for hyphenation selection is (1) explicit discretionaries within the word in text; (2) a pattern specified in the `\hyphenation` list (which can be limited to a particular language); (3) the specified patterns for the current language.
stackexchange-tex
{ "answer_score": 11, "question_score": 10, "tags": "hyphenation, discretionary" }
uitableview's index is shrinking I have an app very similar to address book of iphone. The entire search and index stuff is implemented using the searchdisplay controller. The problem is, from the search results when i click some cell, it actually loads a new screen and while pressing back and going to home tableview screen the index is shrinks The possible reason which I could think is the keyboard. Is there way to make auto resizing of the index on the right side of the uitableview even after the keyboard appears for searchbar.
i got the problem in my source code. I actually release the keyboard when i am loading the view from the search results. when i come back from the newly loaded view and press the standard cancel button it loaded the tableview with half index view. Now i deleted the code which actually releases the keyboard. Then it worked normally.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "iphone, uitableview, uisearchbar" }
How to query Internet Explorer version so it works for IE10 also? My old code in C++ desktop application detected IE version by querying the value in HKLM\SOFTWARE\Microsoft\Internet Explorer\Version registry key. This works for Internet Explorer 9 and below but doesn't work for Internet Explorer 10 (still returns 9). What is the correct way to find out the IE version including IE 10 and higher?
There is another value called `svcVersion`, which I believe is only for IE10. This will correctly say `10.0.x`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c++, internet explorer, registry, internet explorer 9, internet explorer 10" }
When Payment Fails on a Redirect Payment Method should the Order be Cancelled? We have a payment method that redirects off the magento site to make payment then returns to the success or failed controller. When the `Place Order` button is pressed on the Payment page, it redirects to the payment website and **Creates an Order** with no status. When the payment is successful the Order status is set to `Processing`. If it fails the order is `Cancelled`. Is this correct?
> it redirects to the payment website and Creates an Order with no status. Actually, an order always must have some status. If your payment gateway can impact on the place order flow, for example, payment can trigger fraud rules and you need to change an order status depends on these rules, the order can have `Pending` status while your payment method will process fraud rules.
stackexchange-magento
{ "answer_score": 0, "question_score": 0, "tags": "magento2, magento 2.1" }
Eclipse Luna marketplace I've just installed Eclipse Luna v4.4.0 and trying to access marketplace. During load Eclipse fails, reports nothing to stderr and terminates. I'm using no proxy if that means. Does anybody met any bug like that?
There are some bugs with Eclipse Luna and the Marketplace Client. You should follow the instructions here to get the fixed version. <
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "termination, eclipse marketplace, eclipse luna" }
How can we genetrate the secret/key to sign in JWT so that it can be used? I want to use the JWT secretorkey in my code.So I need to store it at a different place.How can I generate it? It is used in the code as follows: This secret is present in `config/auth` module.exports = { 'secret': 'eypZAZy0CY^g9%KreypZAZy0CY^g9%Kr', //how will I generate this?? } In `config/passport.js` var config = require('./auth'); var jwtOptions = { jwtFromRequest: ExtractJwt.fromAuthHeader(), secretOrKey: config.secret };
Assuming you just need a crypto random string you could for example use this < In nodejs you can use crypto.randomBytes (< to generate cryptographically strong pseudo-random data. In .Net you can use RngCryptoServiceProvider to generate random sequences Or if it is one time you could just close your eyes and type a bunch of "random" characters on the keyboard :)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "jwt" }
Laravel: Eloquent / Tinker Class not found I'm trying to get data in a relationship with tinker. I get an error that says Class 'App\Date' not found. I think cause I am not using the right code, but I have no idea what code I need. I have 2 models: Contact (app\Models\Contact.php) Date (app\Models\Date.php) **Contact** public function dates(){ return $this->hasMany(Date::class); } **Tinker** php artisan tinker $test = App\Models\Contact::find(516); $test returns a user. If I uses $test->dates after that I get an error saying this: [Symfony\Component\Debug\Exception\FatalErrorException]Class 'App\Date' not found
`$test->dates` is most likely a relationship. In that relation, it's failing to find the class used in the relationship. public function dates(){ return $this->hasMany('App\Models\Date'); }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 5, "tags": "php, laravel, eloquent" }
Android interface : show form like the grouped listview style? I'm building an App for Android that already exists for iOS. On iOS, we really like to use the listview grouped style to show details and forms. It is really useful to show details of objects that we don't know how much properties they have before loading it. I know that Android doesn't have a similar tableview style. And I don't want to use a custom library to recreate it, because I don't want to force an iOS like interface to my Android's users. But how would you create a consistent Android interface that show similar information? Do you have example for me?
First of all, your instinct to not force iOS style UI onto Android users is correct and I respect you for it. Android's ListView is roughly the equivalent of iOS's UITableView. There are important differences. For instance, you should never use a ListView inside another scrollable container. If a ListView is in a particular layout, it should (usually) be the only scrollable component. If you want multiple ListViews in a layout, you probably don't want ListViews at all. You should instead use (vertical) LinearLayouts and add the items in order. Cyril Mottier writes excellent posts on implementing custom behavior for Android's ListView.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "android, listview, interface" }
AutoRest error : (Duplicate Operation detected (This is most likely due to 2 operation using the same 'operationId' or 'tags') I am trying to automatically generate a REST client (C#) from swagger.json file. The generation ends up with an error: > node.exe : ERROR (DuplicateOperation): Duplicate Operation '' > 'Exports' detected(This is most likely due to 2 operation using the same 'operationId' or 'tags'). Duplicates have those paths: I find this error little bit strange, as we are not using operationId's at all (I can confirm that there are no operationId's in swagger.json). We are using duplicate 'tags', yes. But as far as I understand, tags are used by SwaggerUI to group related methods together. Does AutoRest really require "tags" to be unique, or it is a misleading error message?
I added unique operationId's to my swagger.json (did not have operationId's at all previously) and that solved the issue.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "swagger, openapi, autorest" }
How to include an HTML button inside Laravel code I want to show a button if a condition is not true. In the code below I need to show the "follow group" button if the output is not true. It is working fine, but I don't know the syntax to put the button inside the Laravel code. {{ Auth::user()->grpusers()->where('group_id', $group->id)->first() == True ? 'You are following this group' : <a href="{{ route('group.follow', ['id' =>$group->id])}}" class="btn btn-primary">Follow Group</a> }}
You can simply use `if else` <p> @if( Auth::user()->grpusers()->where('group_id', $group->id)->first() == True) You are following this group @else <a href="{{ route('group.follow', ['id' =>$group->id])}}" class="btn btn-primary">Follow Group</a> @endif </p>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, laravel" }
Lightning web component is not visible in lighting home or app page I am trying to upload a custom component on the community site page, but it's not visible on the community site.
Just give it a try <?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns=" <apiVersion>51.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightningCommunity__Page</target> </targets> </LightningComponentBundle> Hope it will help you.
stackexchange-salesforce
{ "answer_score": 2, "question_score": 2, "tags": "lightning, lightning web components, lightning apps" }
Are there any disadvantages of using jar files from the internet? Are there any disadvantages of using jar files from the internet? I'm afraid of downloading jar file from the internet and import to my project.
You should use MAVEN or a similar library repository, almost every popular library will be managed automatically by the tool and you won't have to bother with dependencies and potential malware. If you are going to code in JAVA, and are worried about public untrusted .JAR, this is the way to go.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "java" }
How do I get the vote result in Vote API? I have installed the rate module, and found out that the votes associated to a node are stored in the votingapi_vote table. Is there a function to use to get the sum of all the votes for a node?
As you have installed the Rate module, then you can use the function rate_get_results(), which can be called as `rate_get_results('node', $nid, $widget_id)`; `$nid` is the node ID of the node for which you want to get the result, and `$widget_id` is the identifier of the widget used to cast the vote. The result is an array that contains many values (some of them are present only for a particular widget); in particular `$output['rating']` is the rating, and `$output['count']` is the number of the votes. If the widget saves the sum of the votes, then `$output['rating']` (where `$output` contains the result returned from `rate_get_results('node', $nid, $widget_id)`) contains the sum of the votes, which is what you are looking for.
stackexchange-drupal
{ "answer_score": 2, "question_score": 5, "tags": "7" }
Can I read the state of controls in non-UI threads Can I read the state of controls (not change it) in non-UI threads like this if (!string.IsNullOrWhiteSpace(notifyIcon.BalloonTipText)) { // ... } Is it safe?
See this artice from Visual Studio Magazine about Multithreading in WinForms. As explained on page 2, one of the problems of accessing UI controls from a thread other than the thread that created the control is that that thread doesn't have a message pump (or at least not necessarily has one). "Reading" UI controls state is done through window messages (for example, WM_GETTEXT.aspx)) just as writing to them, and this is wrong in the same way.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "c#, multithreading, winforms" }
Accepting comments and reviews constructively When we do a review and mark an answer as URL only, stackoverflow pastes a message as comment. So the author hits back at reviewer in an unfair manner. Is there a way to stop it?
If you aren't prepared to defend your actions as a reviewer when the post's author responds with either further requests for clarification or (constructive) arguments as to why your statements don't apply, then you shouldn't be reviewing the posts. Not attaching a name to the review action comments would only encourage users to make review decisions that they are capable of defending, which is an action that they shouldn't have taken in the first place. If the users respond in an unconstructive, insulting, offensive, or otherwise inappropriate manor, simply flag the comments and do not respond further. A mod will be able to resolve the situation for you.
stackexchange-meta
{ "answer_score": 7, "question_score": 3, "tags": "discussion, review, low quality posts, link only answers" }
Only echo integers Is there a way in PHP to only echo the integers from a variable? For example say I had this piece of code: $variable = "something123"; How would I echo out only the "123"?
You should use a regular expression for this. preg_match('/\d+/', $variable, $match); echo $match[0]; The `$match` variable is filled with the first numerical part of the string you pass to the `preg_match` function. `\d+` means "1 or more digits"
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, variables" }
"Did not find handler method for" log messages with Spring Boot Actuator When I include the `actuator` and enable `debug` logging messages then there are lots of `Did not find handler method for` log messages. 2015-08-14 18:34:25.335 DEBUG 94889 --- [nio-8080-exec-5] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /index.html 2015-08-14 18:34:25.336 DEBUG 94889 --- [nio-8080-exec-5] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/index.html] When I remove the `actuator` then these log messages disappear. I have tried with versions Spring Boot 1.2.5 and 1.3.0.M3 and it works the same. It is easy to try out by generating a project with `spring initializr` using `web` and `actuator` dependencies. Do you know what could be the reason? Thank you.
The Actuator adds `EndpointHandlerMapping` to route requests to the various endpoints that it provides. When a request is received, Spring MVC asks each handler mapping in turn for the handler for the request, stopping as soon as one is provided. The log messages are produced when a request for `/index.html` is made. There's no endpoint mapped to that path so `EndpointHandlerMapping` returns `null` and Spring MVC moves on to the next mapping.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 6, "tags": "spring boot, spring boot actuator" }
Particle's material color only changes in Material View mode, and not when rendered I've set up a plane with a material that changes color from red to grey over the life of a particle. I also set up a particle emitter that's particles are duplicates of the plane. The color of the particles change in my material viewmode, but when rendering or in the rendering viewmode it just stays the first color. I've attached a screenshot and a .blend. ![Note that the color changes in the material viewpoint, but in render view in the top left it stays one color]( <
The problem you are facing is mentioned on the manual page for the particle info node: > This node currently only supports parent particles, info from child particles is not available. Because you are only rendering child particles rather than the parents, you encounter this issue. If you `Shift`+`Ctrl` click this node to see all of its outputs, you will see that they all show up black in the rendered mode of the viewport. IDK why exactly it is showing up correctly in the viewport in material mode... To fix it, you obviously just switch to only using parent particles in the particle system, or find some alternate way to achieve the effect you are seeking.
stackexchange-blender
{ "answer_score": 2, "question_score": 1, "tags": "rendering, particles, color" }
How to share domain classes and business rules between client and server like in RIA Services by writing them only once In an ASP.NET - WCF application I want to share domain classes and business rules between client and server without rewriting them, just like in Silverlight RIA Services. Collecting these in one assembly and referencing this from client and server can solve the problem, but how: by adding service refence to client will generate these classes in client proxy, without any behaviour (methods). How can I achive this? NOTE: RIA Services will not be used. EDIT: After some Googling I came across CSLA.NET. Can it solve this issue?
Ok here is how I've done it: As blowdart said I put all the domain code that I want to share between server and client into a seperate assembly. Then I had both server and client referencing to this shared assembly. Then added service reference to client, with one exception: In add service reference dialog there is a button "Advanced". There I have checked reuse types in referenced assemblies. This way I had all proxy goodies, asynchronous method calls etc., generated for me.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": ".net, asp.net, wcf, client server" }
HOw do I limit array to a certain number? actually what I am trying to do is store incoming searches in a database and then display to a web page limiting to a certain number say 10 with the heading of "Recent Searches". if you LIMIT 10 in database query then It stops after 10. so thought will cut off loop but both case it stops at 10. so after that what ever searches happens it wont update it. is there any one can help me in this situation?? $result = mysql_query("SELECT * FROM query ORDER BY regtime DESC"); while($row = mysql_fetch_array($result)) { echo "<img src='bullet.gif' align='absmiddle' class='col1ab'><a class='col1ab' href=".$row['web']." >www.".$row['web']."</a><br>"; }
$count = 0; $result = mysql_query("SELECT * FROM query ORDER BY regtime DESC"); while($count < 10 && $row = mysql_fetch_array($result)) { $count++; echo "<img src='bullet.gif' align='absmiddle' class='col1ab'><a class='col1ab' href=".$row['web']." >www.".$row['web']."</a><br>"; }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "php, mysql" }
Quantum Computing Could quantum computing ultimately harness the Higgs boson interactions to artificially provide mass (energy) to particles in order to manipulate them?
Quantum computing as we understand now doesn't change fundamental interactions (coupling constants) between particles, Higgs or otherwise. Quantum computing merely utilizes the superposition of multiple states of quantum bits to perform operations in one go, that would require many separate operations to classical bits.
stackexchange-physics
{ "answer_score": 1, "question_score": -3, "tags": "quantum information, quantum computer, nanoscience" }
Ubuntu 12.04 get stucked on boot (ubuntu logo + mouse cursor) After running the latest update on my Thinkpad running Ubuntu 12.04 i got the kernel `3.5.0-44-generic`. After rebooting, the system stucks at the "Ubuntu Loading Screen" (with the dots) and shows the mouse cursor, which cant be moved. I use Gnome 3 and Autologin, but when i try to switch to another login (via `CRTL`+`ALT`+`F2`) nothing happens as well. When I hit `ESC` during boot, i see 2 messages that appear strange to me: * Stopping GNOME Display Manager [OK] * Stopping save kernel messages [OK] (no fail here) I can start the recovery-mode. But how to fix this...?
Ok, fixed it on my own. The problem was most likely related to Steam. I added the x-swat ppa few days ago (as suggested by Steam). After removing it (and removing all related packages), problems are gone. 1. Started in Recovery Mode 2. Repair Packages (to get file system mounted read+write) 3. Activate Network 4. Run following commands: sudo apt-get install ppa-purge sudo ppa-purge ppa:ubuntu-x-swat/x-updates 5. Reboot
stackexchange-askubuntu
{ "answer_score": 0, "question_score": 2, "tags": "12.04, boot" }
Is there pmXor pen mode or similar mode for .NET system.drawing.pen? I am programming in Delphi Prism. I am drawing line using mouse clicks as an input. I see that the lines are being drawn on my winform, but they are not being cleared as you move the mouse. It keeps drawing and eventually fills the winform adding lines for every mouse movement. I did try to invalidate the form or the region, but it causes my winform to flicker really bad. I know you can use pmXor pen mode on Delphi for win32. Are there similar pen mode for .NET? How do you make the lines disappear and only keep the active line on the form? I searched Google, Stackoverflow and even MSDN library, there seems to be very little information on .NET penmode. Thanks in advance.
There is no xor pen mode in .net graphics.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": ".net, 2d, line, system.drawing, delphi prism" }
Experiences with (cheap) third-party SFP modules? > **Possible Duplicate:** > Are Arista SFP Transceivers Compatible with Cisco Switches? As the topic suggests, it would be interesting to hear what some of you with more experience have to say about this. Pros * supported * known to reliable * in use by all major companies Cons * not supported * probability of low quality?
This question covers most of this.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 0, "tags": "cisco, sfp" }
NSDateFormatter is returning null date Below is my code NSString *dateandtime =[NSString stringWithFormat:@"%@",self.eventtime]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss Z"]; NSDate *dateFromString = [[NSDate alloc] init]; dateFromString = [dateFormatter dateFromString:dateandtime]; if i print my self.event name i am getting the output as `Mon, 7 Jan 2013 15:30:00 CST` but when i pass this string in `NSDateFormatter` i am getting `null` value i don't know why i tried `many` `combinations` of `date formats`, but i cant solve it, can anyone help me
i solved my problem as Per Prateek comments, now its working for me...Thanks Prateek. in your self.event, you are getting CST, it should be time zone for example +0530
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 4, "tags": "iphone, ios, ipad" }
float behaviour of two adjacent blocks I'm a CSS newbie. Please help confirm if my understanding is correct. I have two block element: the first is floating, and the second is not. with all settings as below, is it correct that my resulting layout will display two blocks adjacent to each other in one line? My understanding is since the first block is floated to the left, but the second is not, so the latter's supposed to remain in the same line it's originally positioned and wrap around. #box1{ float:left; width: 200px; background-color: purple; } #box2{ width:250px; background-color: orange; } <div id="box1">box 1</div> <div id="box2">box 2</div>
As long as the container around both boxes is large enough, yes, box 1 will be at the left edge of the container and 200 pixels further right is box 2 (itself shortened to 50 pixels. See here. And if box 2 gets larger (due to more content) it will look like this: +-------+----------+ | box 1 | box 2 | +-------+ | | | +-------+----------+
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "html, css" }
When was/will Polaris's declination be maximised? When was/will Polaris's declination be maximised? In what year was/will Polaris be closest to the north celestial pole.
Soon after 2100: > In 2018 Polaris was 0.66° away from the pole of rotation (1.4 times the Moon disc) and so revolves around the pole in a small circle 1.3° in diameter. It will be closest to the pole (about 0.45 degree) soon after the year 2100. (text from Wikipedia) Nutation (a wobble in the precession motion) means that it will actually approach and receed slightly from the Pole several times in 2100, in the model used by Stellarium. In that model it is never closer than on March 26 2100.
stackexchange-astronomy
{ "answer_score": 8, "question_score": 5, "tags": "star, declination, polaris" }
JavaScript Domain with Sub dictionaries matching My code: const checkoutUrl = ' window.onload = startup() function startup() { if (window.location.href == checkoutUrl) { // DO something //call a function } } But the actual URL is: ' So (window.location.href == checkoutUrl) did't work. What is the correct formet for `checkoutUrl`?
Check if the string starts with `checkoutUrl`. For this to work, you need to remove `*` from `checkoutUrl`, since there's no wildcard matching. const checkoutUrl = ' if (window.location.href.startsWith(checkoutUrl))
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript" }
Convert this SQL Count statement to LINQ statement How would this SQL statement be with LINQ if I use Count? select count(*) from GoalCard where GoalCard.Completed_Date is not null Thanks in advance! Update: I would remove the " too localized " votes, beacuse there are peoples that use google to find how count can be used in a LINQ statement.
Use this: context.GoalCards.Count(gc => gc.Completed_Data != null);
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql, linq, sql to linq conversion" }
How to use a if statement in XML I have the following code: If dr("dlat").ToString <> "0.000000" Then XmlWriter.WriteStartElement("mapped") XmlWriter.WriteString("Yes") XmlWriter.WriteEndElement() Else XmlWriter.WriteStartElement("mapped") XmlWriter.WriteString("No") XmlWriter.WriteEndElement() End If I wanted to know how could I use the Yes or no part. The reason is `IF mapped = yes` then add address in xml, If no then dont write address. XmlWriter.WriteStartElement("address") XmlWriter.WriteCData(dr("sStreetNumber") & " " & dr("sStreetName")) XmlWriter.WriteEndElement()
If dr("dlat").ToString <> "0.000000" Then XmlWriter.WriteStartElement("mapped") XmlWriter.WriteString("Yes") XmlWriter.WriteStartElement("address") XmlWriter.WriteCData(dr("sStreetNumber") & " " & dr("sStreetName")) XmlWriter.WriteEndElement() Else XmlWriter.WriteStartElement("mapped") XmlWriter.WriteString("No") XmlWriter.WriteEndElement() End If This should be working just fine right ?
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -4, "tags": "xml" }
What is wrong with my for loop? I'm a newbie on Javascript and I'm trying to do some exercises. I have found other ways on here that are more efficient at solving this, but anyway, here's how I tried doing it: var char = prompt("Give me a letter"); char = char.toLowerCase(); function isVowel(char){ var vowels = new Array('a','e','i','o','u'); for(i = 0; i < vowels.length; i++){ if(vowels[i] == char){ return "This letter is a vowel."; }else{ return "This letter is not a vowel."; } } } alert(isVowel(char)); Now, I understand this isn't the best way to do this, but I'd like to understand what's wrong with my for loop, since "a" is the only letter it recognizes as being a vowel. Can someone point me out the reason why it isn't running trough the whole array? Thanks in advance
You should not return until you have a definite "yes" or "no" answer. Try something like this instead: var char = prompt("Give me a letter"); char = char.toLowerCase(); function isVowel(char){ var vowels = new Array('a','e','i','o','u'); for(i = 0; i < vowels.length; i++){ if(vowels[i] == char){ return "This letter is a vowel."; } } return "This letter is not a vowel."; } alert(isVowel(char));
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript, for loop" }
Rewriting quadratic form using coordinate transformation I just finished a linear algebra exam and I could answer most of it except for the bonus question. From memory, it looked something like this: > $x_1^2 - x_3^2 - 4x_1x_2 + 4x_2x_3$ can be written as $-3y_2^2 + 3y_3^2$ using a well chosen coordinate transformation. Show it without actually doing that transformation, and afterwards with the transformation. I've tried doing a transformation, but you're supposed to be able to do this without doing one. I am lost. Any pointers?
The matrix for the quadratic form is $$\begin{bmatrix}1&-2&0\\\\-2&0&2\\\0&2&-1\end{bmatrix}$$ Its characteristic equation is $$(1-\lambda)(-\lambda)(-1-\lambda)-4(1-\lambda)+4(1+\lambda)=\lambda-\lambda^3-4+4\lambda +4+4\lambda=-(\lambda^3-9\lambda)$$ so the eigenvalues are 0, +3 and -3. Under the orthogonal change of basis (which will exist because the matrix is symmetric), you would get the diagonal matrix $$\begin{bmatrix}0&0&0\\\0&3&0\\\0&0&-3\end{bmatrix}$$ which corresponds to the quadratic form $$3y_2^2-3y_3^2$$
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "linear algebra" }
Is it possible to specify sub-sub classes within a <style>? Example: <style> div.Style1 div img { border: 3px red solid } </style> ... <div class="Style1" id="divMain"> <img src=" /> <!--WON'T be styled--> <div id="divSub"> <img src=" /> <!--WILL be styled--> </div> <!--End of divSub--> </div> <!--End of divMain-->
Try this, it selects only images that are children of a div that are themselves children of the element with class `Style1`. .Style1 > div > img { border: 3px red solid }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "html, css, class" }
Converting C# RegEx to JavaScript gives error Invalid Group I have the following C# Regular Expression: var r = new Regex(@" (?<=[A-Z])(?=[A-Z][a-z]) | (?<=[^A-Z])(?=[A-Z]) | (?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace); r.Replace(PageName, " ") And I'm trying to convert it to JavaScript: var r= new RegExp('(?<=[A-Z])(?=[A-Z][a-z]) | (?<=[^A-Z])(?=[A-Z]) | (?<=[A-Za-z])(?=[^A-Za-z])'); PageName.split(pageRegex).join(" ") But it gives me the error: Uncaught SyntaxError: Invalid regular expression: /(?<=[A-Z])(?=[A-Z][a-z]) | (?<=[^A-Z])(?=[A-Z]) | (?<=[A-Za-z])(?=[^A-Za-z])/: Invalid group Update: Some examples of what the RegEx should convert: * AllPeople to All People * PeopleCRB to People CRB * People to People
([A-Z])(?=[A-Z][a-z])|([^A-Z])(?=[A-Z])|([A-Za-z])(?=[^A-Za-z]) Javascript doesn't support lookbehind: `(?<=` So make the lookbehind a group and replace it later. Replace by `$1$2$3 `. See demo. < var re = /([A-Z])(?=[A-Z][a-z])|([^A-Z])(?=[A-Z])|([A-Za-z])(?=[^A-Za-z])/gm; var str = 'AllPeople\nPeopleCRB\nPeople'; var subst = '$1$2$3 '; var result = str.replace(re, subst);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, c#, regex" }
Opening File AND Directories Using FileChooser only in JavaFX Someone asked this question 4 years ago here. The answer was, Linux systems didn't support that functionality natively, therefore it couldn't be supported across all of JavaFX. Just for clarification, I'm looking for a way to give users the ability to select multiple files and directories at once using only FileChooser, not DirectoryChooser. I have the system working now where I ask the user if they'd like to import music files or search folders for music files. Depending on their response, I open either FileChooser or DirectoryChooser. This however, is confusing for some users and it's more cumbersome than I'd like. Does anyone know if this functionality is up and running yet?
There is no way using javafx from what I know. But you could go for the awt FileChooser. It doesnt look remotly like a native FileChooser, but at least it gets the job done. (Ps. Layout can always be altered)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "file, javafx, directory, filechooser" }
jquery stop sliding delay if button is pressed more than once I know there is a way to stop the code from looping everytime you call an animation in jquery but for the life of me i can not find it! How can i turn this code below in order for it not to keep looping if i push the button more than one? $('#message-box').slideDown('slow').delay(10000).slideUp('slow'); If i hit the button that calls that more than once then it slides down, displays for 10 secs, slides back up then back down again. What i would like it to do is if its already down and i hit the button then **NOT** to display it again. Or if nothing else, slide up the current message and slide down the new one right then and there without the delay between. Any help would be great! David
You could try this: $('#message-box').stop(true,true).slideDown('slow').delay(10000).slideUp('slow'); If there is a down-delay-up animation already in progress for the element then `.stop(true)` will stop that, clear the element's animation queue, and only then requeue the down-delay-up thing. Demo: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, slider" }
How to export Wordpress posts database tables with polylang? My current site is outdated (not updated for a long time), so created WordPress with all updated plugins, etc. I am using Polylang on my website for the language switching (English = Arabic), and I need to export all my posts in English and Arabic to my newly created WordPress website. I tried to export/import with the default that comes with WordPress, but they don't map the language posts and I don’t want to remap the English to Arabic pages/posts as they are around 2500+ items. If I can do the export /import from the database side, which all tables to be exported so I don't miss out on the Polylang translation strings and mappings. Thanks
I found a few tables that seem to be used by Polylang plugin wp_terms (contains pll_) wp_term_taxonomy (contains post_translations)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "mysql, wordpress, polylang" }
A Photoshop term for "body double" or "doppelgänger" I saw a tutorial on TV. The tutorial was like this: > Take your snap sitting on chair, another standing on left side of chair and then last one standing on the right side of the chair. Now, use Photoshop to merge these three pics. After everything it will be three look alike on the pic. Now, I want to search this tutorial on web but I don't know what to write for "How to create ___ _ in Photoshop"? Please suggest. **Edit** I tried _body double_ and _doppelgänger_ but it is not the word I am looking for.
**Clone** Clone Yourself Using Adobe Photoshop
stackexchange-english
{ "answer_score": 8, "question_score": 5, "tags": "word choice, single word requests, terminology" }
android: Google APIs (Android API 13) I am trying to install Third party add-ons using Android SDK. Below is what I am trying to install. **Android SDK >> Available packages >> Third party Add-ons >> Google Inc. >> Google APIs by Google Inc., Android API 13, revision 1** It gives me error like this. Downloading Google APIs by Google Inc., Android API 13, revision 1 File not found: C:\Program Files (x86)\Android\android-sdk\temp\google_apis-13_r01.zip (Access is denied) I am not sure what is the problem. Can you please help me to install this? Thanks.
You need to run the SDK manager as Administrator for it to install updates otehrwise Windows refuses to let it create files.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "android emulator, android" }
Reglar Expression 5 digit number with special character at 3 posistion I had requirement to validate 5 digit String with - at third position. For example i want to validate number like these 12-18 ,20-35,40-45.I need java string for the same
you can use the regex ^\d{2}-\d{2}$ to match , see the regex101 demo
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -5, "tags": "java, regex" }
How can I get the primary key index prefix length from information_schema in MySQL? Let us suppose I have a table created as follows: create table `test_table` ( `col1` varchar(128) NOT NULL, PRIMARY KEY (`col1`(16)) ); Now, suppose I have a script that is examining the schema, looking for information about primary keys. How can that script find the index prefix length (16 in the above example) without parsing the output of `show create table`? This information is not in `information_schema.key_column_usage` (in MySQL 5.1, anyway), but is it somewhere else in information_schema?
Try to use information_schema.STATISTICS table (`SUB_PART` field) - SELECT TABLE_SCHEMA, TABLE_NAME, INDEX_NAME, SUB_PART FROM information_schema.STATISTICS or SHOW INDEX statement.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mysql, key, information schema" }
Using a for loop with JSON Should be very simple, but I only get Jimmy cricket output and I'm expecting all the names in li tags. Thanks for any help. <ul id="members"></ul> <script> var teammembers = [ {"name":"John Doe", "profile":"/img/profile/user1.jpg", "position":"President", "email":"[email protected]", "phone":"242-abcd"}, {"name":"James Bond", "profile":"/img/profile/user2.jpg", "position":"Vice President", "email":"[email protected]", "phone":"242-0007"}, {"name":"Jimmy Cricket", "profile":"/img/profile/user3.jpg", "position":"Vice Cricket", "email":"[email protected]", "phone":"242-wxyz"} ]; for (var i = 0; i < teammembers.length; i++) { document.getElementById("members").innerHTML = "<li>" + teammembers[i].name; + "</li>" } </script>
You need to append to the `innerHTML`, rather than set it. Instead of this: document.getElementById("members").innerHTML = "<li>" + teammembers[i].name; + "</li>" use this (the change is from using `=` to using `+=`): document.getElementById("members").innerHTML += "<li>" + teammembers[i].name; + "</li>"
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "javascript, json, for loop" }
Closing apps with no start bar I recently purchased a Lumia 550 and all is going well. I am struggling with closing apps as on a lot of the apps I have, the start bar is hidden and un-un-hidable within the app. How can I get back to the start screen from this without opening the notification centre and going to camera, then hitting the start button when it appears? Thanks.
You can swipe up from the bottom of the screen to open the navigation bar. The start bar you are referring to is popularly known as navigation bar. You can see the offical Microsoft document here which says, > On phones without built-in buttons, reveal the navigation bar by putting a finger below the screen and swiping up.
stackexchange-windowsphone
{ "answer_score": 2, "question_score": 3, "tags": "apps, windows 10 mobile, navigation key" }
Reading of the article “an” preceding quotations Speakers often add “quote” or “quote, unquote” before quotations. But when a quotation is preceded by the article “an”, how should that article be pronounced? As I understand, the choice between “a” and “an” is determined by what phonetically follows the article. When “quote” or “quote, unquote” is inserted between “an” and the quotation, the extra “-n” becomes unnecessary. So should I really pronounce “a” instead?
The morphology of articles is entirely a matter of phonology (i.e, **sound** ). It's very simple and completely general. The indefinite article allomorph _a_ is used before a consonant, and _an_ is used before a vowel; similarly, the definite article allomorph /ðə/ is used before a consonant, while /ði/ is used before a vowel. **Whatever** sound follows the article determines the allomorphy; never mind whether it's what the article modifies. And since consonants and vowels are the only two kinds of speech sound, this exhausts all possibilities. Parenthetical words therefore fall under the rules; **everything** falls under the rules. So, since _quote_ /kwot/ starts with a consonant /k/, an indefinite article preceding it should be _a_. > (The terms _"vowel"_ and _"consonant"_ , by the way, refer only to **spoken** vowels and consonants, **not** written ones; that's why _an hour_ and _a useful tool_ are correct, while * _a hour_ and * _an useful tool_ are incorrect.)
stackexchange-english
{ "answer_score": 2, "question_score": 1, "tags": "pronunciation, articles, quotations" }
Pandas get all columns without one In pandas, if I have a dataframe called `df`, I can get one column with df.column_one and, I can get some specific columns with df[['column_one', 'column_two']] how I can get all columns without one specific? Example: if I have a dataframe with n columns `col_1`, `col_2`, ... `col_n`, How I can get all columns without `col_n`?
try this: df.drop(['col_n'], axis=1) or df.loc[:, df.columns != 'col_n'] or df.loc[:, df.columns - ['col_n']] or as @IanS posted in the comment: df[df.columns.difference('col_n')] or using `filter()` function in junction with negative look ahead RegEx: df.filter(regex=r'^((?!col_n).*)$')
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 6, "tags": "python, pandas, dataframe" }
Does using ES6 modules improve intellisense on VS Code? One of my big complaints about working with JavaScript, at least the way I've done it until now (mainly because of libraries I've used which aren't ES6 modules), is that since you include all files in the HTML file, you don't really have a reference to other files you're using in the script, so when I work with VS Code's ESLint plugin, it highlights syntax errors just fine but I wish it could go the extra mile showing Intellisense suggestions for the other JS files. I was wondering, does using ES6 modules produce the result I want? And is there a way to have such behavior even when working with the "include everything in the HTML" approach?
Yes, using JavaScript module syntax means VSCode can find the things you're referring to in other files and provide IntelliSense for them. For instance, if you have `foo.js`: export class Foo { doSomething() { // ... } } and you have `bar.js`: import {Foo} from "./bar.js"; at that point, typing `const f = new` will make it offer you `Foo` (amongst other things). Once you've completed that line: const f = new Foo(); at that point, typing `f.` will show you `f.doSomething()` as an autocomplete suggestion.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "javascript, visual studio code, es6 modules" }
Flatten JSON read with JsonSlurper Trying to read and transform a JSON file where the input file has: { "id": “A9”, "roles": [ {"title": “A”, “type”: “alpha” }, {"title": “B”, “type”: “beta” }, ] }, { "id": “A10”, "roles": [ {"title": “D”, “type”: “delta” }, ] }, But requires transformation for a library which expects values at the same level : { "roles": [ {"id": “A9”, "title": “A”, “type”: “alpha” }, {"id": “A9”, "title": “B”, “type”: “beta” }, ] }, { "roles": [ {"id": “A10”, "title": “D”, “type”: “delta” }, ] }, I'm able to read the input with JsonSlurper, but stuck on how to denormalize it.
With this `data.json` (notice I had to clean up trailing commas as Groovy's JSON parser will not accept them): { "records":[{ "id": "A9", "roles": [ {"title": "A", "type": "alpha" }, {"title": "B", "type": "beta" } ] }, { "id": "A10", "roles": [ {"title": "D", "type": "delta" } ] }] } You can do it this way: def parsed = new groovy.json.JsonSlurper().parse(new File("data.json")) def records = parsed.records records.each { record -> record.roles.each { role -> role.id = record.id } record.remove('id') }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "groovy, jsonslurper" }
expectations on all instances on JMockit I was expecting JMockit to set expectations on _all_ instances. However, that does not work when I add a constructor expectation to the mix. class Foo { Foo(int i) {} void foo() {} } @Test public void expectationsOnAllInstances__Works(@Mocked Foo foo) { new Expectations() {{ foo.foo(); }}; new Foo(3).foo(); } @Test public void expectationsOnAllInstances__DoesntWork(@Mocked Foo foo) { new Expectations() {{ new Foo(3); // <==== this constructor expectation messes things up ... foo.foo(); }}; new Foo(3).foo(); } The second test fails with error: Missing 1 invocation to: Foo#foo() on mock instance: Foo@617faa95 instead got: Foo#foo() on mock instance: Foo@1e127982 JMockit 1.48 Thanks!
Well, the `expectationsOnAllInstances__DoesntWork` test is inconsistent between the expectations recorded and replayed... What you really want is one of these two other versions: @Test public void expectationsOnAllInstances_consistent1(@Mocked Foo foo) { new Expectations() {{ new Foo(3).foo(); }}; new Foo(3).foo(); } @Test public void expectationsOnAllInstances_consistent2(@Mocked Foo foo) { new Expectations() {{ new Foo(3); foo.foo(); }}; new Foo(3); foo.foo(); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jmockit" }
How to improve url in Laravel? I created my app on Homestead. Everything works fine there. But when I moved app to an external server I always have to include index.php after root path. Example: www.domain.com/index.php/contact **How to I get rid of index.php to make my URL prettier?** Application is located: /var/www/ Public directory is renamed to html: /var/www/html PS. I'm using apache2.
Assuming you already point your web server to public directory, your problem should be in your Apache conf. Laravel comes out with `.htaccess` in `public/.htaccess` but you need to enable the mod rewrite in Apache for it to work sudo a2enmod rewrite For the `.htaccess` to work, you need to set the `AllowOveride` directive in Apache conf <Directory "/var/www/public"> AllowOverride All </Directory>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "linux, apache, laravel, server" }
Vim find last occurrence of In a large buffer, I'd like to scroll down to the last occurrence of pattern _pattern_. If I am at the first occurrence, it is easy enough to search for the _pattern_ `/`, reverse the _move to next occurrence_ `n` with `N` and get to the last.. If I am in the middle of a sequence of occurrences.. is there a better way to jump?
An easy way to find the last occurrence is to jump to the end and search backwards: G?foo<CR> In fact, there's an even easier way if you were already searching for something. Just jump to the end and _search backwards for the thing you were just searching for_ : GN Simple as that. **Edit** : if your search occurred on the very last line, then `GN` would skip over it to the second last occurrence. Using `ggN` would solve this problem. (And `gg?foo<CR>` for similar reasons.)
stackexchange-stackoverflow
{ "answer_score": 89, "question_score": 44, "tags": "vim" }
Eclipse Hello world fail on mac , toolchain? Just started a beginner c++ tutorial which eclipse is used. I am using a mac, so when creating a new project i chose the toolchain 'macxxx" something. In the video a different one is used because it is done in windows. I tried running this super easy program : #include <iostream> using namespace std; int main() { cout <<'C++ is FUN'\n; return 0; } When i click on the hammer to build it, I just get 3 errors : > Symbol 'cout' could not be resolved firstprogram.cpp Semantic Error all similar to that. How can i fix that ?
Does following code produce errors aswell? #include <iostream> using namespace std; int main() { cout << "Hello World!"; } You can end current line with `<< endl` after `"Some text to display"`. So it would look like cout << "hello there " << endl;
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "c++, eclipse" }
Mod Rewrite - Additional Query String After Already Rewriting One Query String Appreciate the help in advance because I absolutely hate mod_rewrite and can't get my head around it! I currently have a rule in my .htaccess that converts two parameters in a query string to a pretty URL. RewriteRule ^projects/([^/]+)/([^/]+)/?$ single-project.php?id=$1&section=$2 [L] For example, this converts the URL **/single-project.php?id=5 &section=documents** into **/projects/5/documents/** What I want to do is have an additional query string (through a new rule) that would convert **/projects/5/documents/?subfolder=PDFs** into **/projects/5/documents/PDFs/** A few caveats: * This additional query string may not always be there * This query string would only need to work if the URL is **/projects/[ANY_ID]/documents/** I hope this makes sense and that you can help! Cheers
With your shown samples, please try following rules in your .htaccess file. Please make sure to clear your browser cache before testing URLs. Have added comments inside rule file for understanding. RewriteEngine ON ##Op's already present rules, added 1 more flag in it QSA. RewriteRule ^projects/([^/]+)/([^/]+)/?$ single-project.php?id=$1&section=$2 [NC,QSA,L] ##Newly added Rule to perform internal rewrite for project id here. RewriteRule ^(projects)/([^/]+)/([^/]+)/(.*)/?$ $1/$2/$3/?subfolder=$4 [NC,QSA,L]
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "regex, apache, .htaccess, mod rewrite" }
Looking for easy Instant Messaging protocol for own IM-server/service in in Java I am thinking of implementing an easy Instant Messaging server in Java, but I don't want to create yet another protocol, but instead use an already simple IM-protocol. But I don't know which protocol I should use. The reason Why I want to use an already existing IM-protocol, is that I would like my 'users' to be able to use their own clients, for example pidgin - which already offers a wide spread of protocols, such as XMPP, Simple, Bonjour, etc - and I don't have to develop any clients. I have looked a bit a XMPP but it since a lot of work embed that protocol into a new server. Maybe there are other protocols that are easier to use? My questions is, do you guys have any suggestions of protocols that are real basic and easy to use in Java? Pidgin supports a whole bunch of protocols, but which protocols are relevant for me?
XMPP is widely used and has standards backing behind it. It is pretty easy to use if you use an existing library - there are many client libraries for it in many languages. The google says there are many in java. An advantage of using XMPP is that your server can act as a gateway to all the other Xmpp/Jabber servers on the net, so your users can talk in & out of your network - like to people logged into GoogleTalk, using standard JID addresses, like [email protected]/desktop.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 3, "tags": "java, xmpp, instant messaging" }
angular and dropbox can(t get token with code flow i have this snippet: var req = { method: 'POST', url: ' headers: {'Content-Type': 'application/json'}, data: { 'code': authCode, 'grant_type': 'authorization_code', 'client_id': 'my_id', 'client_secret': 'my_secret', 'redirect_uri':' } }; return $http(req).then(function(response){ console.log(response.status); return response; }, function(err){ console.log(err); }); The can always ends up in a "bad request" because ""No auth function available for given request"" The same data works with tools to send REST requests... so I don't know what I'm missing here... Can some help?
The error message indicates that the API didn't receive the expected parameters, or at least not in a format it expected. The documentation for /1/oauth2/token say: > Calls to /oauth2/token need to be authenticated using the apps's key and secret. These can either be passed as POST parameters (see parameters below) or via HTTP basic authentication. If basic authentication is used, the app key should be provided as the username, and the app secret should be provided as the password. You seem to be attempting to supply the parameters as JSON though, according to your `Content-Type` header. Try sending them as POST parameters instead.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "angularjs, dropbox" }
Is there a way to sort a string that has numerics in R? I have a vector of strings in R that follow this format: `1:A`. So let's say I have a vector with strings x = c("1:A", "201:A", "2:A") I want to sort through this vector so it becomes ["1:A" "2:A" "201:A"] Is there a function that is capable of this in R? I have tried mixedsort(x, decreasing = FALSE) from the `gtools` library, but it still doesn't seem to completely work very well when this vector is scaled up to include the letter `B` as well. Any ideas?
One option is `mixedsort` library(gtools) mixedsort(x) #[1] "1:A" "2:A" "201:A" * * * Or remove the non-numeric characters with `gsub` and `order` x[order(as.numeric(gsub("\\D+", "", x)))] #[1] "1:A" "2:A" "201:A"
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "r, string, sorting" }
XNA Exclusively Lockable Input Handling I'm writing an XNA application which requires input directed to only one input event handler, which is the object that is currently locked, i.e. game, menu, console, etc. What is the best way to do this? I've thought about creating an `IInputReceiver` interface (with methods such as `HandleInput`) that attaches into a central input manager which only sends input events to the locked input receiver. Just wondering about what other people do with input handling.
The easiest way - and the way that XNA itself handles things - is making input global (using static classes). In your `Update` function for your Game/Menu/Console, simply query the input state. You probably shouldn't be calling `Update` on more than one of these objects at the same time. If you have to, for some reason, I recommend having a separate `InputUpdate` function on each that reads the input state. If you need "key-went-up/down" handling - which in XNA is generally done by storing the last state and the current state - I find it is also easiest to store these globally, and "pump" it at the start of your `Game.Update` function. This may not sound particularly fancy - but this is input for a game. It doesn't have to be fancy! I don't really understand what you mean by "lockable" - but I feel I should point out that XNA input (reads) must be done on the main thread.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, .net, input, xna" }
Android Studio "Search Everywhere" feature not searching in code files "Search everywhere" feature in Android Studio is not finding strings in code files. Why is it not able to find a string literal or a variable name? Irrefutable photographic evidence: !Irrefutable photographic evidence What am I doing wrong?
"Search Everywhere" is generally looking for the following things: * Class/Module names * Function names * File names * Database names * Configuration options named similarly It's not suitable for finding a string literal or a variable based in hundreds of lines of code which may have similar literals available to it. For that, I'd recommend either "Find in Path", or "Symbol", which is `CTRL` \+ `ALT` \+ `SHIFT` \+ `N` or `Command` \+ `Alt` \+ `O`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "android studio, intellij idea" }
How to break down a calculation so that it can be calculated in reverse. I have the following calculation, which will return a value between 0 and 7.99 Depending on the N. $$ f(n)=8-8*exp(-0.010*n) $$ Now I am trying to calculate what N would need to be to achieve f(n) = 5, but I am unsure how to break down the calculation in a way to do so. My original taught was to switch the initial 8 with a 5 instead and see if it exceeds 0, but this would still require prior knowledge of n $$ 5-8*exp(-0.010*n) $$ With that my question being, how can I break a calculation to determine what n should be to achieve a certain f(n)?
we haveb $$5=8-8e^{-\frac{1}{100}n}$$ then we get $$\frac{3}{8}=e^{-\frac{1}{100}n}$$ taking the logarithm on both sides we have $$\ln\left(\frac{3}{8}\right)=-\frac{1}{100}n$$ from here we get $$n=-100\ln\left(\frac{3}{8}\right)$$
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "algebra precalculus, functions" }
Javascript shorten GET values I am working on an app in which you can select numerous elements in a map by dragging a rectangle or polygon selection around them. After that the user can make some additional settings, presses a send button and gets to a result page. I want to send the request with GET so that the user can for example save the link. My problem is that the number of elements that are selected can be very large (around 1000) so if I base64_encode an array with all element IDs the URL becomes easily too large. It's not an option to send just the polygon or rectangle coordinates because the user is allowed to deselect single buoys manually. So my question is how can I efficiently compress an array of integers to a short string?
So the solution I used in the last place was using not GET but store everything after the #. For the hash string there are no size restrictions so even large amounts of data can be stored there.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript, arrays, compression" }
Can "listening" be countable? Can _listening_ be countable? Can I say _We will do a listening during today's lesson_?
You can treat pretty much any _-ing_ word as countable if you want to. Whether you want to or not depends on the effect you’re striving for. There is, for example, a children’s rhyme which includes ‘We / Are tired of scoldings and sendings to bed: / Now the grown-ups shall be punished instead.’ In other contexts, _sendings_ would sound strange, and _listenings_ would normally sound strange to me, too. Best avoided, I'd say.
stackexchange-english
{ "answer_score": 4, "question_score": 4, "tags": "uncountable nouns" }
Different multiplicity between derived classes that inherits the same base class ! Having 4 classes (A, B, C and D) Knowing that classes B & C inherits class A, is it a design flaw to have a different multiplicity from class D to class B and class D to class C?
No, this is definitely not a design flaw. The cardinality of the associations between B/D and between C/D are properties of the specializations B and C only. The base class A is not affected by these associations. An example could be a course (D) which has at most one teacher (B) and several students (C) which both are persons (A).
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "class, inheritance, uml, diagram" }
how to check the array contains different values or same values in Jquery An array can contains multiple values. I want to check whether all the values are same or different. > Example var a = [2, 4, 7, 2, 8]; // all values are not same var b = [2, 2, 2, 2, 2]; // all values are same How can I check it in jquery
You can try like this: var a = [2, 4, 7, 2, 8]; var b = [2, 2, 2, 2, 2]; function myFunc(arr){ var x= arr[0]; return arr.every(function(item){ return item=== x; }); } alert(myFunc(a)); alert(myFunc(b)); See the MDN for Array.prototype.every()
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 5, "tags": "javascript, jquery" }
WordPress display name string manipulation I have set the display name to show both first name and last name using the function below. How do I manipulate the LAST NAME to only pull the first letter of that string? Example, if you sign up as John Doe (First name= John, Last name= Doe), I want your display name to be John D. Thanks function force_pretty_displaynames($user_login, $user) { $outcome = trim(get_user_meta($user->ID, 'first_name', true) . " " . get_user_meta($user->ID, 'last_name', true)); if (!empty($outcome) && ($user->data->display_name!=$outcome)) { wp_update_user( array ('ID' => $user->ID, 'display_name' => $outcome)); } } add_action('wp_login','force_pretty_displaynames',10,2);
Use PHP's `substr()` function: $outcome = trim( get_user_meta( $user->ID, 'first_name', true ) . ' ' . substr( get_user_meta( $user->ID, 'last_name', true ), 0, 1 ) . '.' );
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "php, functions, profiles" }
Check whether enum in Swift belongs to a constant set Is there special syntax in Swift for checking whether an enum belongs into a constant set? What I have in mind is something like status in (.Active, .Matching)
I've concluded by now that (unfortunately) there is now special syntax for this case.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "swift, enums, logical operators" }
Going back to code while debugging in eclipse From the createSecureConnection method in my code , i came to exception block catch (Exception ex) { ex.printStackTrace(); } Please tell me is it possible to go back to the createSecureConnection from the catch block ?? please see the scren shot here .
you could add a finally block and call it again. but should happen if it fails again? EDIT: the finally block is always executed, also if the first call was successful. I'm not sure if this is a good approach, but if you want to do it like this, you have to simply use boolean flag like this: boolean success = false; try{ .... urlc = createSecureConnection(urlString); success = true; } catch() { ... } finally { if(!success) try{ createSecureConnection(urlString); } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "eclipse" }
Storing Data In a Game I'm coding a Java game and there are 26 levels so far. When the user completes a level, I want the space above the level to have a checkmark or something. However I don't know how to make it where when I close the game, the checkmark is still there from last time I played it and it doesn't reset the game from the beginning. How can I store data for a game and save the values of variables so the game doesn't restart every time I close out of it?
An embedded database like SQLite is an easy way to store information. You could have columns(levelNumber INT, completed INT) where completed is either a 1 or 0. When you complete a level, send an update to the database changing completed to 1 for the appropriate level number. Before each level is loaded, have a method that checks your database for the completed value: This tutorial is fairly straight forward. There might be a slight learning curve if you're unfamiliar with SQL but its good to know how to use it.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "java" }
How to get index of sublist from original list I have a list `A = [[1,3],[0,1,2],[0,2,4]]` and sublist of A which is tuple `B = ([1, 3], [0, 2, 4])`. I want to print length of `B` and index of each element of `B` in original List `A`. I am not sure how to return the indexes. The output should be: 2 0 2 Here is my try: A = [[1,3],[0,1,2],[0,2,4]] B = ([1, 3], [0, 2, 4]) print(len(B),'\n')
How about this: In [81]: A Out[81]: [[1, 3], [0, 1, 2], [0, 2, 4]] In [82]: B Out[82]: ([1, 3], [0, 2, 4]) In [83]: print(len(B)) ...: for item in B: ...: print(A.index(list(item)), end=' ') ...: **Output** 2 0 2 Based on your comment: print(str(len(B)) + '\n' + ' '.join([str(A.index(item)) for item in B])) **Output:** 2 0 2
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, list, indexing, tuples" }
REGEXP : find the first character after one specific other character this is my problem : I have a similar list of strings like that : 1) mytext-othertext-01-Onemore 2) mytext1-othertext1-02-Twomore 3) mytext2-othertext2-03-Fourmore 4) ... I'm tryng to get **ONLY** the **FIRST** character after the third **" -"** in my text so the result would be : 1) O => because mytext-othertext-01-Onemore 2) T => because mytext1-othertext1-02-Twomore 3) F => because mytext2-othertext2-03-Fourmore I'm pretty bad using regexp and i assume that is not probably a hard one but i'm stuck with this at the moment : \-(.*) Example of result **That will took the entire text after the first "-" as you can see** Help will be hardly appreciated to solve my problem.
^(?:[^-]*-){3}(.) `[^-]*-` matches a sequence (possibly empty) of non-hyphens followed by hyphen. `{3}` after that matches it 3 times, so it finds the 3rd hyphen, and `^` at the beginning makes it start matching from the beginning of the string. The capture group `(.)` captures the next character. DEMO
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "regex, ibm doors" }
C# upload CSV file to Netezza So my team is looking into connecting to Netezza with C# and we plan on **loading data into netezza, pulling data from netezza and writing update queries all in C#**. From my research, I see that it's possible to connect to netezza using C# and I'm wondering if you can do all that is bolded above using C# so that we can decide on whether or not we can do just about anything with Netezza using C#. We'd like to know before we commit to anything. The types of data we would be loading are CSV files. Are there any good resources on this? I haven't been able to find any. We also have Aginity client tools so maybe it's possible to incorporate Aginity to this (Not that I would want to but if it's easier I'd like to know about it)?
Retrieving data is straightforward and can be done through the usual channels ( _loop over a cursor to get results_ ) but loading can take a bit longer. Netezza is not a fan of multiple `INSERT` queries; loading a large number of records with individual `INSERT` queries, as it doesn't support multi-row inserts, will take a _long_ time. When loading multiple records most people usually write out their data to a ".csv" and use the external table syntax to perform the insert. When in a application we prefer to load/unload our data via a named pipe so that we don't have to write/read the data to disk prior.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, .net, netezza, aginity" }
Rails How to use join in this specific situation? I have three models, each connected as such: `Groups` which has many `Students` which has many `Absences`. `Absences` has a field called `created_on`. **I only have a _group id_ and would like to obtain all _students_ with an _absence_ of today.** I have created this method inside my `Student` model: # Inside student.rb def self.absent_today_in_group (group) #SQLITE find(:all, :joins => :absences, :conditions => ["STRFTIME('%d', created_on) = ? AND STRFTIME('%m', created_on) = ?", Date.today.day, Date.today.month]) #POSTGRES #find(:all, :joins => :absences, :conditions => ["EXTRACT(DAY FROM created_on) = ? AND EXTRACT(MONTH FROM created_on) = ?", Date.today.day, Date.today.month]) end Why would that query not return anything? And how could I then also check for group_id?
What version of rails are you using? You can do this in rails 3: def self.absent_today_in_group(group) joins(:absences, :group).where( 'absences.created_on' => (Time.now.beginning_of_day..Time.now.end_of_day), 'groups.id' => group.id ) end That would find all users which were absent for today for given group.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "ruby on rails, activerecord, join" }
Backing up my bitcoin wallet - is wallet.dat all I care about? I know that there are many duplicates of this but I'm hoping that the way in which I word this explains and helps not just me, but others as well. In any of the coin wallet bitcoin and the alt coins, when I run a backup I see a wallet.dat file being created. 1. Does this wallet contain all the necessary information like private keys etc... in order to say encrypt this file and store it on a google drive , dropbox etc.. ? 2. If my hard drive takes a dive etc.. , CAN I simply take that wallet.dat file , and on another computer decrypt it and restore my information based on my coin currency? 3. If I do the encryption within the wallet, is the wallet.dat called something else? I understand the exchanges , buying, trading , selling, mining... I'm just not versed in the backup with my information... private keys etc... thanks in advance.
1. Yes. 2. Yes. 3. No. Note that that the software's encryption encrypts only the private keys, not transaction and address book information, so to protect your privacy you may want to add encrypting the file itself.
stackexchange-bitcoin
{ "answer_score": 6, "question_score": 8, "tags": "bitcoin core, backup, encryption, wallet.dat" }
Why is it impossible to assign constant properties of JavaScript objects using the const keyword? First, I had asked is it possible: How to create Javascript constants as properties of objects using const keyword? Now, I gotta ask: why? The answer to me seems to be 'just because', but it would be so useful to do something like this: var App = {}; // want to be able to extend const App.goldenRatio= 1.6180339887 // throws Exception Why can constants set on an activation object work but not when set on they are set on any other? What sort of damage can be done if this were possible? What is the purpose of `const`, if not to prevent a public API from being altered?
Going to answer the question you meant to ask and say never use `const`. The interpreter doesn't do anything with it. All it does is mislead the developer into thinking s/he can assume that the value never changes, which is about as likely as if the `const` keyword weren't present.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "javascript, object, properties, constants, variable assignment" }
inserting into the back of std::list during range based for loop I came across " _Add elements to a vector during range-based loop c++11_ ", and wasn't surprised it's not allowed using `std::vector` because the append can invalidate iterators. However, inserting into `std::list` doesn't invalidate any of the iterators, so I was wondering if it would be allowed with `std::list` instead of `std::vector`. e.g. std::list<int> list({1}); for (int &cur : list) { std::cout << cur << " "; if (cur < 10) { list.push_back(cur + 1); } } It seems to compile fine, but I'm worried it's undefined behaviour.
Yes, inserting / removing elements of a `std::list` does not invalidate pointers, references, or iterators to elements, except for the removed element. Not even the end-iterator is changed or invalidated. Thus, it is safe. But as one has to carefully ponder about safety, it is still inadvisable.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 4, "tags": "c++, for loop, push back, stdlist, for range" }
Girls and boys ordering combinatorics I have the following combinatorics question but I don't know how to approach it: "10 girls and 4 boys are about to be photographed in a row, how many ordering options are there if between each 2 boys **at least** 1 girl has to stand?" I know the 4 boys can stand in any order, meaning 4!, but I don't know how to continue. Thanks!
There are $10!$ ways of arranging the girls. At this point, where can we put the boys, such that no $2$ boys are adjacent? GGGGGGGGGG The first boy can be put in $11$ different places ($1$st, last, or between any two girls). The second boy can be put in $10$ different places (we're excluding the place where we put the first boy), the third one in $9$, and the fourth one in $8$. So in total we have $10! \cdot 11 \cdot 10 \cdot 9 \cdot 8$ ways.
stackexchange-math
{ "answer_score": 4, "question_score": 0, "tags": "combinatorics" }
Any reason why Rails credentials wouldn't work in Initializers? Is there any reason why I couldn't use Rails.application.credentials[Rails.env.to_sym]['amazon']['client_id'] in config/initializers/omniauth.rb Currently when I do, I get: config/initializers/omniauth.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)
Any of those `[]` calls could be the culprit. It could be that `Rails.application.credentials` is nil. It could be that `Rails.application.credentials[Rails.env.to_sym]` is nil. It could be that `Rails.application.credentials[Rails.env.to_sym]['amazon']` is nil. This should all be easy enough to test which one it is. I'm going to guess it's because of using `amazon` as a string instead of a symbol. If your `config/credentials.yml.enc` looks like this... production: amazon: client_id: 12345 Then try using symbol keys. Though it is possible this is a hash with indifferent access. Rails.application.credentials[Rails.env.to_sym][:amazon][:client_id]
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "ruby on rails 5" }
A Maze of Characters I have a maze here with me. However, this maze is quite hard to see. w Q q # 2 ñ ÿ The bottom of the list of characters is the start of the maze. The top is the end. * * * Other puzzles in this series of mazes: * A Maze of Characters * A Mqze of Miszpeked Worfs
Converting these UTF-8 characters to binary gives the below 7x8 array of bits. Since the bottom is all ones, and you said start at the bottom, the intention must be that you can walk along ones while zeroes are walls. The solution is to stay in the third column from the left and head up, except to jog around a zero in the second row from the top. 01110111 01010001 01110001 00100011 00110010 11110001 11111111
stackexchange-puzzling
{ "answer_score": 11, "question_score": 11, "tags": "mazes, computer science" }
How to do `sort -V` in OSX? I wrote a script for a Linux bash shell. One line takes a list of filenames and sorts them. The list looks like this: char32.png char33.png [...] char127.png It goes from 32 to 127. The default sorting of `ls` of this list is like this char100.png char101.png [...] char32.png char33.png [...] char99.png Luckily, there is `sort`, which has the handy `-V` switch which sorts the list correctly (as in the first example). Now, I have to port this script to OSX and `sort` in OSX is lacking the `-V` switch. Do you have a clever idea of how to sort this list correctly?
Do they all start with a fixed string (`char` in your example)? If so: sort -k1.5 -n `-k1.5` means to sort on the first key (there’s only one key in your example) starting from the 5th character, which will be the first digit. `-n` means to sort numerically. This works on Linux too.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "linux, macos, bash, sorting, cross platform" }
GLM with logit link and Gaussian family to predict a continuous DV between 0 and 1 Can you run a GLM using a logit link with a continuous DV (between 0 and 1)? Generally it's suggested to use a binomial family with a logit link, but I'm guessing that is because the model assumes a binary DV. If we have a continuous DV would we want to use a Gaussian family instead of binomial? I apologize if this question doesn't make much sense: I have only a very basic knowledge of statistics, and am just trying to recalibrate a model specified by a colleague a number of years ago.
You seem to want to use a fractional logit, i.e. a quasi-likelihood model for a proportion. The key here is that it is a quasi-likelihood model, so the family refers to the variance function and nothing else. In quasi-likelihood that variance is a nuisance parameter, which does not have to be correctly specified in your model if your dataset is large enough. So I would stick with the usual family for a fractional logit model, and use the binomial family.
stackexchange-stats
{ "answer_score": 10, "question_score": 8, "tags": "logistic, generalized linear model, binary data, logit, continuous data" }
Composite of non Riemann integrable functions can be Riemann integrable? (1) Let $f,g$ be not Riemann integrable on $[a,b]$, and the range of $f$ is $[a,b]$ also. Can we find an example such that $g\circ f(x)=g(f(x))$ is Riemann integrable on $[a,b]$? (2) Let $f,g$ be Riemann integrable on $[a,b]$, and the range of $f$ is $[a,b]$ also. Can we show that $g\circ f$ is Riemann integrable on $[a,b]$ also?
For question 1, $$f(x)=g(x)= \left\\{ \begin{array}{ll} x, &x\in \mathbb{Q} \\\ 1-x,&x\notin \mathbb{Q} \\\ \end{array} \right. \\\$$and $[a,b]=[0,1]$. For question 2, see here. In order to change the range of $f$, alter it to $$ f(x) = \begin{cases} 1/q & \text{ for }x=p/q\text{ and $0\le x\le1/2$} \\\ 0 & \text{ for } x \notin \mathbb{Q}\text{ and $0\le x\le1/2$}\\\ 2x-1 & \text{others} \end{cases} $$ and the $g$ desired is the $f$ in my link.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "calculus, integration" }
Changing y-axis tick labels from standard form to the full number I made a scatterplot and the y-axis range runs from 0 to 800,000. How can I make the y-axis ticks show the numbers ("0", "200,000", "400,000", "600,000", "800,000") instead of their standard forms ("0e+00", "2e+05", "4e+05", "6e+05", "8e+05")?
See the **scipen** option in `?options`. Here is an example: set.seed(42) dat <- data.frame(x = runif(100, min = 0, max = 1000000), y = runif(100, min = 0, max = 1000000)) layout(matrix(1:2, ncol = 2)) plot(y ~ x, data = dat) opt <- options(scipen = 10) plot(y ~ x, data = dat) options(opt) layout(1) Which produces: !scipen_plot Other options include suppressing the axes with `axes = FALSE` in the `plot()` call and then use `axis()` to add your own axes with custom supplied labels using `format()`; see `?format` for details. This is the way to go if you really want the "," in the numbers separating the thousands.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "r" }
shell script works but drop error "line[8] expected argument [" I have shell script that works (does what i want to do,finds if listed user is online), but each time drop error "line[8] expected argument [". I've tried using == but same thing. There's my code: #!/bin/sh truth=0; until [ $truth -eq 1 ] do for i; do isthere=$(who is here | awk '{print $1}' | grep $i) if [ $isthere = $i ] #(8 line is here) then echo "found user: "$isthere". program now will close."; exit 0; fi done echo "user not found, retrying after 3sec..."; sleep 3; done Thank you for you help and time.
Looks like `$isthere` or `$i` is empty. You should quote them: `if [ "$isthere" = "$i" ]` In other news: most semicolons are useless; a semicolon it is not a statement _terminator_ , but a statement _separator_ , along with newline.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "shell, sh" }
Do you have to be the last editor for it to count against the editing badges? SEDE Query 1 SEDE Query 2 These two queries seem to imply that for an edit to count against the Strunk and White badge or the Copy Editor badge, one needs to be the _most recent_ editor. However, the badge descriptions, which are `Edited 100/600 entries`, imply that one only has to be _an_ editor, but not necessarily the most recent. Are the two queries correct, or do edited edits count?
Yeah your queries are not going to be accurate, the data dump does not contain Post History. We look at the Post History table for these badges.
stackexchange-meta
{ "answer_score": 8, "question_score": 8, "tags": "support, badges, edit badges" }
Is this technically an O(1) algorithm for "Hello World"? Would this be classified as an O(1) algorithm for "Hello, World!" ?? public class Hello1 { public static void Main() { DateTime TwentyYearsLater = new DateTime(2035,01,01); while ( DateTime.Now < TwentyYearsLater ) { System.Console.WriteLine("It's still not time to print the hello ..."); } System.Console.WriteLine("Hello, World!"); } } I'm thinking of using the DateTime TwentyYearsLater = new DateTime(2035,01,01); while ( DateTime.Now < TwentyYearsLater ) { // ... } snippet of code as a busy loop to put in as a joke whenever someone asks for an algorithm of a certain complexity. Would this be correct?
Big O notation in this context is being used to describe a relationship between the size of the input of a function and the number of operations that need to be performed to compute the result for that input. Your operation has no input that the output can be related to, so using Big O notation is nonsensical. The time that the operation takes is _independent_ of the inputs of the operation (which is...none). Since there _is_ no relationship between the input and the number of operations performed, you can't use Big O to describe that non-existent relationship
stackexchange-stackoverflow
{ "answer_score": 408, "question_score": 117, "tags": "c#, .net, algorithm, big o" }
Binding data to TextBox without showing text When binding text/data to a TextBox, it is done like @Html.TextAreaFor(model=> model.Question) but, when the PostBack happens, the text shows up in the TextBox. Is there a way to still bind the data to the textbox, but not display the text in the textbox? I have a search functionality on my website, and when someone searches I want the results page to have the textbox without the text (the searched word).
You've said Postback, so you're using Server side implementation, right? If that's the case, the simplest way is to add a script that runs every page load. For example, you have this search textbox: <input type="textbox" id="search"> In your javascript : <script type="text/javacript"> $(document).ready(function{ //get the attribute of the search textbox and clear the text $('#search').val(''); }); </script> If you're using Ajax implementation then just add a script when your form post succeeds.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "asp.net, asp.net mvc, asp.net mvc 4" }
Ionic Capacitor: Application says "Something went wrong" I have a webapp that was built with ReactJS that runs beautifully. I'm trying to convert this webapp into an Android app using Iconic Capacitor. I've gone through the steps to do so, imported things into Android Studio and tried to run things. When the app starts I can see the initial screen layout for a moment before the screen clears and it says "Something went wrong". I'm including a screen shot of what happened. ![Something went wrong]( I'm trying to understand this problem: What process is responsible for this message? Is it the Android emulator, Capacitor, ReactJS?
Turns out 2 problems: Had to add this to the configuration: "server": { "cleartext": true } There was also a CORS problem that had to be addressed at the server level
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": 0, "tags": "android, reactjs, ionic framework, capacitor" }
Laravel database migration Incorrect table definition public function up() { Schema::create('materials', function (Blueprint $table) { $table->increments('id'); $table->string('name',60); $table->integer('category_id',10); $table->integer('low_bulk',10); $table->integer('high_bulk',10); $table->integer('order_level',10); $table->decimal('unit_price',10,2); $table->string('description'); $table->timestamps(); }); } This schema gives me this following error SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key Can anyone tell me what should I change?
Try again like this. public function up() { Schema::create('materials', function (Blueprint $table) { $table->increments('id'); $table->string('name',60); $table->integer('category_id); $table->integer('low_bulk'); $table->integer('high_bulk'); $table->integer('order_level'); $table->decimal('unit_price',10,2); $table->string('description'); $table->timestamps(); }); } For more details, you can refer this.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "laravel, syntax, migration" }
Autonumber with alternating number and letters I want an auto-numbering class in c# which would generate numbers of 8 digit length in the following format i.e. **1A2B3C4D**.. **one number followed by one letter**.Any suggestions??
Pseudocode for generating such string: String result = ""; for ( int i = 0; i < 8 ; i++) { if ( i % 2 == 0) { // random(a,b) returns random value between or equal to a-b result.append(random(0,9).toString()); } else { result.append(random(65,90).toChar()); // Generating a random value between 65-90 (A-Z in ascii) } } Edit: Or as Sayse suggested: String result = ""; for (int i = 0; i< 4; i++) { result.append(random(0,9).toString()); result.append(random(65-90).toChar()); }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -3, "tags": "c#" }
Multiple Report Columns in Reporting Services 2008 I'm using SSRS 2008 to make something for label printing. I want to make use of all horizontal and vertical space on the page to fit as many labels as possible, so I'm thinking I probably want multiple Report Columns. This technet article would have you believe that you can set the number of Report Columns to make what they call "newsletter-style columns" in the Report Properties window. If I bring up the Report Designer in my Visual Studio 2008 installation and click on Report -> Report Properties from the top menu, I see this: !Hosted by imgur.com I can't find anything relating to columns, and no combination of the other settings on this page will make it change to multiple columns (yes, I'm rendering to PDF, not just checking the HTML preview.) Any ideas? Thanks for your help!
Okay, I figured it out - when they say Report Properties, they don't mean the Report Properties dialogue that you might think. click on a blank region of the report to select the Report object, then pop up the Properties pane and you'll see a "Columns" property which you can adjust. Whew!
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "ssrs 2008" }
Используют ли сейчас систему шаблонов Smarty? Читаю книгу "Создаем динамические веб-сайты с помощью PHP, MySQL и JavaScript" Робина Никсона. Там вкратце описана Smarty. Стоит самостоятельно углубиться, или сейчас применяют другие технологии в PHP для разделения кода и внешнего вида? Учу PHP just4fun пока, что. В будущем планирую добавить его на борт известных мне технологий :).
Если вы хотите стать хорошим программистом, советую самому разрабатывать подобные системы, если же лишь для решения какой то задачи, не требующей уникальности, то смысл есть. Решайте)
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, smarty" }
SQL Query- NOT exists Not working select * from text_mining where NOT EXISTS (select 1 from history where text_mining.Noun = history.Noun and text_mining.Adjective = history.Adjective) can someone tell me what is wrong with this this are my errors Thanks > Unrecognized keyword. (near "NOT" at position 35) > Unrecognized keyword. (near "EXISTS" at position 39) > Unexpected token. (near "(" at position 46)
SELECT * FROM history a WHERE !EXISTS (SELECT 1 FROM text_mining b WHERE a.Noun = b.Noun AND a.Adjective = b.Adjective) Used `!EXISTS` instead of `NOT EXISTS`
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": 0, "tags": "sql, mariadb, not exists" }
How to count a note which has 6 on above it? ![enter image description here]( It's on 2/4 meter. I know we all are much familiar with 3 on top of any note which is a triplet. Here I'm confuse today: What is 6? Please describe to me what the 6 is about and how to count those red boxed notes. I want help so that I can count the beat in the right way of this whole measure shown in above picture.
The "notes with a 6 above them" (sextuplet) is equivalent to two adjacent sets of sixteenth-note triplets. What is a sixteenth-note triplet? Well a "regular" (eighth-note) triplet is three notes over the span of one quarter note, and so a sixteenth-note triplet is three notes over the span of one eighth note. Here's how I would count the first bar of the pattern in your picture (with a plain eighth-note count below it): 1 trip let And trip let 2 And trip let | 1 And 2 And |
stackexchange-music
{ "answer_score": 4, "question_score": 4, "tags": "notation, rhythm, time signatures, beats, meter" }
Java Character in String to integer Everything seem correct until the number is being detected. the number 1 should remain as 1.it show be 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 9 0 A = 10 and B = 11 and so on How do i correct the follow bug ## Code String alpha = "ABCDEFG1234567890"; for (int i = 0; i < alpha.length(); i++) { char c = alpha.charAt(i); int w = (int)c; System.out.println(w-55); } ## Output 10 11 12 13 14 15 16 -6 -5 -4 -3 -2 -1 0 1 2 -7
You could try the method `Character.isDigit()`. Also note that you can cast a `char` to a `int` by using `(int)c`: public static void main(String[] args) throws IOException { String alpha = "ABCDEFG1234567890"; for (int i = 0; i < alpha.length(); i++) { char c = alpha.charAt(i); if (Character.isDigit((c))) { System.out.println(c); } else { System.out.println((int)c - 55); // Cast to 'int' } } } **Output:** 10 11 12 13 14 15 16 1 2 3 4 5 6 7 8 9 0
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "java" }
Insights needed for the following Lagrange Multipler problem Find the point of the paraboloid $z = \frac{x^2}{4} + \frac{y^2}{25}$ that is closest to the point $(3, 0, 0)$. So this seems like a pretty standard question of Lagrange multiplier, except I ran into some problems but cant figure out where I went wrong. Attempt: _I maximuse $D^2$ instead of D to remove the square-root_ 1.) Constraint equation : $\frac{x^2}{4} + \frac{y^2}{25} - z$ 2.) $D^2 = (x-3)^2 + y^2 + z^2$ 3.) _Do the usual Lagrange procedure_ 4.) $2z = -\lambda \\\ 25y = \lambda y \\\4(x-3) = \lambda x$ 5.) Assume $x \neq 0, y\neq0$, we get $z = -\frac{25}{2}$ 6.) This is where I got stuck, how can z be negative where is the sum of 2 positive number? Which part of my attempt did I commit a mistake, and how do I rectify it? Any insights and help is deeply appreciated.
if $y=0$ then $z = \frac{x^2}{4}$ so $\lambda = -\frac{x^2}{2}$ so $$ 4(x-3) = -\frac{x^3}{2} \\\ \implies x^3+8x-24 = 0 \\\ \implies(x-2)(x^2+2x+12)=0$$ so your solution is the point $(2,0,1)$
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "multivariable calculus, lagrange multiplier" }
Convert GeoPoint to Location I know this is a very noobish question -- but what is the best way to convert a `GeoPoint` to a `Location` on the Android platform.
double latitude = geoPoint.getLatitudeE6() / 1E6; double longitude = geoPoint.getLongitudeE6() / 1E6; location.setLatitude(latitude); location.setLongitude(longitude);
stackexchange-stackoverflow
{ "answer_score": 55, "question_score": 22, "tags": "android, google maps, geolocation" }
Более удобный синтаксис для динамического ключа Приложение для взаимодействия с SOAP и при разборе полученных данных столкнулся вот с таким некрасивым синтаксисом: $method = 'FindCompanyByCode'; $getResult = $method.'Result'; if($result->$getResult == 'Data not found') { // some code } Составной ключ приходится заранее объявлять в переменной, можно ли как-то сократить и избежать использования переменной?
Существует так называемый **сложный синтаксис** : if ($result->{$method . 'Result'}) {
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php" }
Comparison Theorem for Integral Calculus ![Question]( (source: gyazo.com) I have narrowed it down to C, E, and F, since we know that $1/x^{1/5}$ is always greater than the original function for all $x\geq 1$. However, the second set of conditions is more difficult to understand.
If $x \ge 1$, then $(x + e^{2x})^{\frac{1}{5}} \ge (e^{2x})^{\frac{1}{5}} = e^{\frac{2x}{5}}$. So $(x+e^{2x})^{-\frac{1}{5}}\le e^{-\frac{2x}{5}}$. $\displaystyle \int_1^{\infty} e^{-\frac{2x}{5}} dx = \frac{5}{2}e^{-\frac{2}{5}} < \infty$. So it's f).
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "calculus, limits, integration, infinity" }
How to switch a "split" comma to colons I think I am missing something easy here. I am trying to split the URL and then switch the commas to colons. Is there an easy way to do this. <div id="splitit"></div> <script> var mySplitResult = window.location.href.split('/'); document.getElementById('splitit').textContent = mySplitResult; </script> So the results of "mySplitResult" is value,value,value,value,value and I want value:value:value:value
`mySplitResult` actually contains an array of strings. window.location.href.split('/'); ["http:", "", "stackoverflow.com", "questions", "30086262", "how-to-switch-a-split-comma-to-colons"] Then `Array.prototype.toString` converts it to a comma delimited string. Instead use `Array.prototype.join` document.getElementById('splitit').textContent = window.location.href.split('/').join(':');
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, split, window.location" }
Duplicate App for over 1 million leads/contacts? We're about 4 months into our Salesforce integration but we're having a ton of problems with dupes. In our previous CRM, it would monitor the company name, email address, or phone number and ask if it was associated with a different account already in the system. I'm not seeing anything like that without an app for Salesforce. We have more than a million leads/contacts and the apps I've been seeing (for free) only deal with a limited amount of records. I see with the Spring 15 release, there is Data.com duplicate management...but does it work outside of Data.com? Really, what I'm looking for is something that will catch dupes in import or on lead/contact creation and is able to scrub our dataset and suggest possible dupes. If it isn't a free app, how much can we expect to spend to get this functionality?
It is available for free from Spring 15 release onwards for account,contact and lead. Details can be found in below links, < <
stackexchange-salesforce
{ "answer_score": 1, "question_score": 2, "tags": "duplicate management" }
Is there an easy way to tell which stacks in a battle have all their units? It is important to try to get through as many battles as possible without losing any units, but I find it tedious to constantly right-click every stack to see if they are at full strength, and I've gotten burned a couple times by forgetting to heal a stack before ending the battle when I could've easily done so. I don't care how many hit points the "top" creature has, I just want to make sure that no units are lost, so that when the battle ends I'm still at full strength. Are there any options or anything I can turn on to make this easier?
When you click on a healing spell and then mouse over a creature, it will tell you how much health that creature will be healed, as well as how many creatures will be resurrected and also the max amount that could be resurrected. This comes in the form of, for example, "100 7/13" This tells you that you'll be healing this unit for 100 health, which will resurrect 7 creatures, but this unit has lost 13 creatures total, meaning that after you heal it, it will still be missing 6 creatures. This is useful especially if you have a mass healing spell, as mousing over one creature will show this information for every creature on your side (that can be healed). A useful tip is on the turn that you could win on (or a turn or two before hand) pick your healing spell and just mouse over each unit you control to see if any are below their starting amount.
stackexchange-gaming
{ "answer_score": 5, "question_score": 9, "tags": "might and magic heroes 6" }
How can I revive a wilted Mexican feather grass? I bought a Mexican feather grass from the clearance section so I know it's been taken care of, it's just a little droopy so it was heavily discounted. Since I thought I'd like it, I'd love to be able to get it to perk up. Right now it looks like a pony tail that's partly green, partly tan. My friend thinks it looks like Lady Gaga buried feet first. Hopefully it's not too late. !enter image description here Any ideas on how I can revive it?
I'm assuming you mean Nassella tenuissima 'Ponytails' - you haven't said what you intend to do with it, but I'm assuming its going outside, so plant it somewhere that's free draining but doesn't constantly dry out completely. Keep it watered initially until its settled in. If you're not putting it outside, turn it out of its pot and check whether it needs a larger container. Needs free drainage, so a container with holes is essential and don't leave it sitting in an outer tray or pot in water. Either comb or pull out dead brown parts, or cut it right down and let it grow again. Can be cut in April, and again in Fall. Hopefully, this plant was in the clearance section only because it needs cutting back and may need repotting - if they cut it back, they're unlikely to get a buyer for it, so its not worth the effort to tidy it up. Either that or its one from last year that they've not tended this spring.
stackexchange-gardening
{ "answer_score": 3, "question_score": 2, "tags": "plant health, grass" }