qid
int64
10
74.7M
question
stringlengths
15
26.2k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
27
28.1k
response_k
stringlengths
23
26.8k
10,858,570
Okay, I need a div to `fadeIn` on click, but only if a video is not playing, so I thought an if statement was the way to go. I want it so that the fade only happens if a video isn't playing. I'm not sure how to set it up. I tried ``` if($("#myVid") != "playing") { $("#MyT").fadeIn(0); } ``` I'm p...
2012/06/01
[ "https://Stackoverflow.com/questions/10858570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1316405/" ]
Assuming you are using the HTML5 `<video>` tag, you can use the following code to determine if the video is currently playing: ``` var elem = $('#myVid')[0]; // get the DOM element if(!elem.ended && !elem.paused) { alert('playing'); } ``` See <https://developer.mozilla.org/en/DOM/HTMLMediaElement> for a descript...
try this: ``` var myvid = document.getElementById('myVid'); if (myvid.error) { switch (myvid.error.code) { case MEDIA_ERR_ABORTED: alert("You stopped the video."); break; case MEDIA_ERR_NETWORK: alert("Network error - please try again later."); break; case MEDIA_ERR_DECODE: aler...
2,829,046
How to calculate this integral $$\int\_0^1 \frac{1-x}{(x^2-x+1)\log(x)}\;dx$$ In WolframAlpha, I found it equal to $$\log \left[ \frac{\sqrt{\pi}\;\Gamma\left(\frac23\right)}{\Gamma\left(\frac16\right)} \right]$$ I tried using the relation$\quad\int\_0^1 x^t\,dt = \frac{x-1}{\log x}\quad$ then dividing both sides by $...
2018/06/23
[ "https://math.stackexchange.com/questions/2829046", "https://math.stackexchange.com", "https://math.stackexchange.com/users/488070/" ]
Multiply both the numerator and denominator by $1+x$ so the denominator now turns into the nicely looking $1+x^3$ factor instead of that hideous quadratic factor! Calling the integral $I$ gives$$I\stackrel{\text{def}}{=}\int\limits\_0^1dx\,\frac {1-x^2}{\log x(1+x^3)}$$ This resulting integral is actually very trivial ...
Before you introduce the parameter, multiply the numerator and denominator by $1+x$. The integral you end up with can be expressed in terms of the Digamma Function.
19,812
I have to prove or disprove the implications in these two situations 1. $L^\* = \emptyset$ $\rightarrow$ $L$ is infinite 2. $L^+ = \emptyset$ $\rightarrow$ $L$ is infinite Here are my thoughts. 1. I would say Kleene star operation (\*) is union of $\qquad L^0 \cup L^1 \cup L^2 \cup \dots$ and since $\\_^0 = \{\ep...
2014/01/18
[ "https://cs.stackexchange.com/questions/19812", "https://cs.stackexchange.com", "https://cs.stackexchange.com/users/12947/" ]
1) You need to take a look at [this page](http://en.wikipedia.org/wiki/Vacuous_truth). Remember that there is an *implication* to be proved true or false. 2) Consider the fact $L \subseteq L^{+}$ and apply it to the case $L^{+} = \emptyset$.
You have to *prove or disprove*. L\* *always* contains the empty string and is therefore not empty. "L\* is empty" is a false statement. Anything follows from a false statement. So yes, if L\* is empty (which it cannot be) then L is infinite. L is also finite. And empty. And anything else, and all at the same time. L...
73,891,626
I made a small container that runs a single shell script. Its Dockerfile is as follows: ``` FROM centos:centos7.9.2009 RUN mkdir -p /var/lib/test COPY ./ /var/lib/test/ RUN yum -y localinstall /var/lib/test/*.rpm ENTRYPOINT ["sh /var/lib/test/test.sh"] ``` However, when I run the image, it returns the error: ``` ...
2022/09/29
[ "https://Stackoverflow.com/questions/73891626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12129644/" ]
***1st solution:*** Within single GNU `awk` you could try following code. Written and tested with shown samples only. Simple explanation would be, setting RS(record separator) as `\\${[^}]*}` and then in main program substituting values like `${` and `}` from RT and printing only required values as per requirement. ``...
> > > ``` > echo 'text${v1}text${v2}etc' | > > mawk 'gsub(OFS"+", __, $!(NF = NF)) + \ > gsub("^"(__) "|"(__)"$", _)^_ + gsub(__," /\f\b\b/ ")' \ > __='\300' \ > FS='(^[^$}{]*)?[$][{]|[}][^}{$]*|[\301]+' OFS='\301' > > ``` > > ...
28,311,307
I was trying to upload my project to GitHub on Android-Studio. Pushing to GitHub master... process never ends and Version Control Console gives this Error: ``` GitHub --credentials get: github: command not found 'C:\Users\SA'EED~1\AppData\Local\Temp\git-askpass-2722525787662236837.bat" "Username' is not recognized a...
2015/02/04
[ "https://Stackoverflow.com/questions/28311307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4526402/" ]
Evidently, `sleep_for` is not precise at all. The working solution for this issue is to enter a while loop until the desired duration is reached. This make the application "sleep" for precisely 2000 microseconds. ``` bool sleep = true; while(sleep) { auto now = std::chrono::system_clock::now(); auto elapsed = ...
Quoted from cppreference (see [sleep\_for](http://en.cppreference.com/w/cpp/thread/sleep_for)): > > This function may block for longer than sleep\_duration due to scheduling or resource contention delays. > > > I think that is the most likely explanation. The details will depend on your environment, especially yo...
110,623
I have a table with a username as unique & primary key. I ran this Query to order them in ascending order ``` ALTER TABLE `table` ORDER BY `Username` ; ``` So the rows are ordered like this ``` +-----------+----------+ | Username | Password | +-----------+----------+ | soho16793 | test1 | | soho4595 | test...
2015/08/11
[ "https://dba.stackexchange.com/questions/110623", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/72527/" ]
I created a table called "billy". ``` mysql> SELECT * FROM billy ORDER BY f1; +----------+-------+ | f1 | f2 | +----------+-------+ | soho10 | test5 | | soho12 | test1 | | soho123 | test2 | | soho1234 | test4 | | soho222 | test3 | +----------+-------+ 5 rows in set (0.00 sec) ``` which doesn't give th...
Following @oNare's throwing down of the SQL gauntlet, verily I resolved to take up the challenge to my SQL-hood and thus, in this the year of our Lord two thousand and fifteen, I thusly formulated the following palimpsest. I offered incantations to the SQL muses, received inspiration from the SQL daemons, had it carved...
21,707,347
I have some mobile numbers stored in a Oracle DB. I have a stored procedure that carries out some checks around a variety of validations. The stored procedure is launched by a front end Windows application. One basic validation example is ensuring the mobile field is not null. I'd like to add validation for: check the...
2014/02/11
[ "https://Stackoverflow.com/questions/21707347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/600423/" ]
You can use `replace` function. E.g., ``` select replace('188 123 4567',' ','') from dual; ``` result: ``` 1881234567 ``` Oracle Database SQL Reference for `replace` <http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm> See also "Using Regular Expressions in Oracle Database" <http://docs.oracl...
Very straight forward code to check the length removing all spaces could be: `select length(replace('1881234 567',' ','')) from dual`
39,704,525
In a blank page on chrome console I type: ``` var o={}; o.toString() == false // false o.toString() == true // false ``` I'm expecting o.toString to be evaluated as an empty string and so falsy... What is happening?
2016/09/26
[ "https://Stackoverflow.com/questions/39704525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5381289/" ]
> > I'm expecting o.toString to be evaluated as an empty string and so falsy... > > > That expectation is at odds with the [specified behavior of `Object.prototype.toString`](http://www.ecma-international.org/ecma-262/7.0/index.html#sec-object.prototype.tostring) (which is what `({}).toString` is), which is to out...
It's because `o={}` and function `toString` return you `"[object Object]"` If you need to get `true` / `false` if object is empty use something like: **ES5** ``` var o1 = {}; if(Object.getOwnPropertyNames(o).length !== 0) console.log('true'); else console.log('false'); ``` **JQUERY:** Check this: <http://api.jque...
5,452,207
What would be the best way to acces the google calendar on android right now? I found the following ways: [google-api-java-client](http://samples.google-api-java-client.googlecode.com/hg/calendar-v2-atom-android-sample/instructions.html?r=default) - It's only an alpha. Authenticating, getting calendar list works, but...
2011/03/27
[ "https://Stackoverflow.com/questions/5452207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373248/" ]
I recently used [SignPost](http://code.google.com/p/oauth-signpost/) for this. It handles OAuth, and you can use it to sign your HTTP requests to get or post data to your calendars. I had trouble getting Google's Java API to work with Android since I think it relies on Java APIs that are not necessarily present in Andr...
Have you looked at the [Data API Developer's Guide: Java](http://code.google.com/apis/calendar/data/2.0/developers_guide_java.html)? You can also work directly with [HTTP request/response](http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html), if things you want/need aren't supported in the Java...
69,425,787
Why and how did the program give the output? ``` #include <stdio.h> int sum(int a ,int b , int c ){ return a , b ,c; } int main() { int a=10, b=100 , c=1000 ; int x = sum(a , b ,c); printf("%d %d %d" ,x); return 0; } ``` Output : 1000 1000 100
2021/10/03
[ "https://Stackoverflow.com/questions/69425787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14105722/" ]
Short answer: no, you cannot return multiple values (at least, not as you did). Good news, you do have some ways to return multiple values from a function: --- ### Method 1: use a `struct` ```c typedef struct result { int a; int b; int c; } result_t; result_t foo(int a, int b, int c) { return (result_t) { a...
One way to achieve with structs, ``` #include <stdio.h> struct Values { int a; int b; int c; } values; struct Values sum(int a ,int b , int c ){ return (struct Values){ a, b, c}; } int main() { int a=10, b=100 , c=1000 ; struct Values x = sum(a...
34,569,271
I have a Bootstrap Modal in ASP.Net with MVC 5 which I use to edit an entry on a FullCalendar javascript plugin. \_Edit.cshtml: ``` @model Models.CalendarEntry <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title" id="m...
2016/01/02
[ "https://Stackoverflow.com/questions/34569271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1160367/" ]
turns out, that I needed to set options for the datetimepicker, more specifically, a default value it would seem like: ``` <script> $(document).ready(function () { $("#datetimepicker").datetimepicker( { defaultDate: '@Model.EntryDateTime', ...
Another quick solution is to also format the date like this in your javascript: ``` defaultDate: '@Model.EntryDateTime.ToString("yyyy-MM-dd HH:mm")' ``` The solution of using the [DisplayFormat] as an attribute is just as valid if not a better solution.
38,968,441
I have one `ObservableCollection<M> fooBar {get;set;}`. The class `M.cs` looks like this: ``` public class M{ private int _ID; public int ID { get {return this._ID;} set {this._ID = value;} } private string _number; public int Number { get {return this._number;} set...
2016/08/16
[ "https://Stackoverflow.com/questions/38968441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5576680/" ]
You have to define your variable `gettopic` outside the `click` event ``` var gettopic; $(".buttons").click(function(){ if (gettopic) { gettopic.abort(); } gettopic=$.post("topic.php", {id: topicId}, function(result){ // codes for handling returned result }); }) ```
``` var xhr = []; $('.methods a').click(function(){ var target = $(this).attr('href'); //if user clicks fb_method buttons if($(this).hasClass('fb_method')){ //do ajax request (add the post handle to the xhr array) xhr.push( $.post("/ajax/get_fb_albums.php", function(msg) { ...
54,212,561
Not a real question, rather a suggestion if anyone has faced the same needs. Suppose to have a github repository with many contributors making PR. What are the best tools to automatic merge PR with the following condition: * in there is no activity for a while (e.g. 10 days) close the PR without merging it IF the aut...
2019/01/16
[ "https://Stackoverflow.com/questions/54212561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2509085/" ]
> > In some ways I think that a synergy between APPs and other tools can solve the problem > > > As other tools, don't forget [GitHub Actions](https://github.com/features/actions), like (for [those regarding PR](https://github.com/sdras/awesome-actions#pull-requests)): * [`actions/stale`](https://github.com/actio...
Jenkins can be used for this exact thing and more, and it doesn't necessarily need to be a GitHub repository, any git repo works the same. For example, in my company we use it to scan BitBucket PR comments and perform complex commands according to the comments, allowing for validations, automation testing and more bef...
281,222
I'm learning about oscillators, but I can't seem to get the tank to oscillate. I have built a very simple circuit using the 555 timer and a LC tank (sorry for the bad circuit layout, this was my first drawing): [![enter image description here](https://i.stack.imgur.com/gYj7Z.png)](https://i.stack.imgur.com/gYj7Z.png) ...
2017/01/19
[ "https://electronics.stackexchange.com/questions/281222", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/121002/" ]
You need a high impedance source to drive a parallel LC tank circuit with minimal damping. Think about what this tank circuit wants to do when it oscillates, it wants to slosh the energy between the capacitor and inductor and not interact with the "outside" world. Thus ideally, when this resonates it will appear as a...
Ideally you need to feed the tank circuit from a current source and not a voltage source. The output from your 555 is a voltage source so try feeding the tank through a 1 kohm resistor (a compromise between a voltage and current source). You could even feed the tank via a small capacitor (such as 10 nF) to get voltage ...
31,780,830
In C, We can use char \* to point at a string. Just like ``` char *s = "Hello"; ``` . As it be seen, Neither the variable is located dynamically on heap because there is no any dynamical functions like malloc, nor it is defined to point a certain other variable. So my question is, **Where is the literal string whi...
2015/08/03
[ "https://Stackoverflow.com/questions/31780830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4493512/" ]
The variable `char* s` is stored on the stack, assuming it's declared in a function body. If it is declared in a class, then it is stored wherever the object for the class is stored. If it is declared as a global, then it is stored in global memory. In fact, any non-`static` and non-`thread_local` variable you declare...
String literals have *static storage duration*. That means they exist for the whole lifetime of your program. They may be stored in a non-writable area, and they may overlap with other string literals. Two different instances of the same literal may or may not coincide. It is up to your implementation (compiler/linker...
13,670,298
Currently everyone talks of two solutions: 1. jQuery UI plugin --> not feasible, because it uses too much space 2. jQuery Color (http://api.jquery.com/animate/) --> not feasible because I can't actually get a link to the plugin to download So my question is, what is the smallest plugin I can use to allow this effect ...
2012/12/02
[ "https://Stackoverflow.com/questions/13670298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/146366/" ]
You can get the [`jQuery Color`](https://github.com/jquery/jquery-color/) plugin from its GitHub repository. ``` span.value { background-color: #0f0; } ``` ``` $("span.value").animate({ backgroundColor: "transparent" }, 'slow'); ``` [See a live example using jQuery Color.](http://jsfiddle.net/KVFZM/) --- You...
you can do this by animate try ``` $('span').animate({'backgroundColor' : '#ffff99'}); ``` or try ``` $("span").fadeOut("slow").css("background-color", "#ffff99"); ```
477,229
For some reason this problem which seemed fairly easy on the surface has given me a lot of trouble. I have a square who's side length changes based on an independent variable. The square's upper left corner is at the origin, and the square's lower right corner is at $(l\_f,-l\_f)$, where $l\_f$ is the length of the squ...
2013/08/27
[ "https://math.stackexchange.com/questions/477229", "https://math.stackexchange.com", "https://math.stackexchange.com/users/87662/" ]
If I'm understanding everything correctly, here's what I think you're looking for: \begin{align\*} y\_i &= \dfrac{-l\_i}{2} - \dfrac{l\_f}{2} \\ y\_f &= \dfrac{-l\_i}{2} + \dfrac{l\_f}{2} \\ x\_i &= \dfrac{l\_i}{2} - \dfrac{\frac{1280}{720}l\_f}{2} \\ x\_f &= \dfrac{l\_i}{2} + \dfrac{\frac{1280}{720}l\_f}{2} \\ \end{al...
From the answers you gave to my comments, I figured you mixed up the $y$-direction in your question. You say that the rectangle is centered at $(l\_f/2, -l\_f/2)$, but in your calculation you use $(l\_f/2, l\_f/2)$ to obtain the $y$-boundaries of your rectangle. (Note that you get $y\_f=l\_f$ for $d=1$ instead of $y\_f...
17,830,806
I am using bottle for a POC restful service project. would someone kindly let me know what is the best way to decide if the caller wants me to send the response in JSON, XML, or HTML? I have seen some examples of this using request.mimetypes.best\_match, but that needs me to import flask. is there a way to do this in b...
2013/07/24
[ "https://Stackoverflow.com/questions/17830806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/554421/" ]
You ajax request is asynchronous, so you must do it with callbacks, or (not recommended) add async: false: ``` $.ajax({ type: "get", url: href, async: false ``` One more detail, declare result variable in CheckAjax method and assign value to it when request completes and then return this variable.
on alerting only the 'returndata' you able to see "true" or "false"? ,try quoting them in your condition and give e.preventDefault a shot instead of return false
25,692,262
In my HTML, I have 2 lines that have the same class. I want to be able to target just the first element, but can't seem to figure it out. I am able to target both elements, but when I change the CSS to select the first child, it doesn't return anything. Here is the CSS and the duplicate classes ![enter image descript...
2014/09/05
[ "https://Stackoverflow.com/questions/25692262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3072086/" ]
So, for your question why "its not returning any elements with that CSS". According to the definition > > The :nth-child(n) selector matches every element that is the nth > child, **regardless of type**, of its parent. > > > With this selector and your html, > > svg g.highcharts-axis-labels:nth-child(1) > > ...
`.highcharts-axis-labels:nth-of-type(1)` should select the first element.
53,636
I am planning to visit Iran for 13 days and want to get a visa on arrival (I'm a national of an eligible country). Does anyone have recent experience regarding VoA, and/or know the documentation required? On the [website of Iran's foreign ministry](http://en.mfa.ir/) I cannot find anything (it says "under constructio...
2015/08/26
[ "https://travel.stackexchange.com/questions/53636", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/33276/" ]
Oh, I did this last month! A lot of websites and forums have mentioned problems in the past with others failing to get visa on arrival, and being rejected (even Aussies and Kiwis, which for me as a Kiwi is pretty unusual, most places think we're harmless). However by the time I'd heard this, I was already on the road...
[Timatic](https://www.timaticweb.com/cgi-bin/tim_website_client.cgi?FullText=1&COUNTRY=ir&SECTION=vi&SUBSECTION=is&user=KLMB2C&subuser=KLMB2C) used to state a passport photo and an authorisation code is required. None of that applies anymore. All you need is an eligible passport and health insurance. Unless you can pr...
6,346,119
How can I get the date of next Tuesday? In PHP, it's as simple as `strtotime('next tuesday');`. How can I achieve something similar in .NET
2011/06/14
[ "https://Stackoverflow.com/questions/6346119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/589909/" ]
``` DateTime nextTuesday = DateTime.Today.AddDays(((int)DateTime.Today.DayOfWeek - (int)DayOfWeek.Tuesday) + 7); ```
Now in oneliner flavor - in case you need to pass it as parameter into some mechanism. ``` DateTime.Now.AddDays(((int)yourDate.DayOfWeek - (int)DateTime.Now.DayOfWeek + 7) % 7).Day ``` In this specific case: ``` DateTime.Now.AddDays(((int)DayOfWeek.Tuesday - (int)DateTime.Now.DayOfWeek + 7) % 7).Day ```
13,061,251
I am building a simple notes application and I want to add a static bar at the bottom of the TableView. For example, I want to add a help button. How can I do this to just my TableView? So far: I have added a toolbar through storyboard, but that makes it stick at the end of the last made tableView cell. I want it st...
2012/10/25
[ "https://Stackoverflow.com/questions/13061251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can use a standard UITableViewController with a storyboard. In "simulated metrics", go to the Bottom Bar menu and select "Toolbar". The toolbar appears. You can then add button items to it.
You can use the toolbar that is included in all UITableViews by default, and add UIBarButtonItems to it. Despite the name, UIBarButtonItems can be customized to be any kind of view. Then you add them to the property self.toolbarItems, which is available to UITableViews by default. e.g. ``` UIBarButtonItem * textItem...
58,393,311
inside the While-loop , why the first print statement ( which asks the user to enter a number ) is skipped in the first time? I think It's because I don't understand how hasNextInt() method works , I tried though and read about It but really didn't go far. the easiest solution is to put one print statement outside the...
2019/10/15
[ "https://Stackoverflow.com/questions/58393311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10653593/" ]
You can comment out resources temporary in the module which you want to destroy, uncomment resources on recreation and you can follow the below steps to avoid the error. Remove the provider from the module and Pass provider in the module explicitly, ``` module "pass_provider" { source = "../module" providers = {...
If you commented out/removed a module and you see this error then another option is `terraform state rm` to esentially forget about it. [Terraform state rm](https://www.terraform.io/docs/cli/commands/state/rm.html) You definately want to destroy the resource, `terraform destroy -target=module.mymodule` but in some cas...
4,778,365
Coming from a C# background, I was more or less puzzled by the seemly weird behavior of returning method handling in C++. My concern now is for a method in C++, returning by reference is not a very useful technique, this is because-- unlike C#--any variable declared inside a method body will go out of scope once the th...
2011/01/24
[ "https://Stackoverflow.com/questions/4778365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
> > The only time where returning by reference is useful is when you are returning a reference to an existing data member in a class, or you are returning a reference to an element inside a parameter of the method. > > > Loosely speaking, true. The variable might not be "owned" by the class (as in tied to its life...
It is correct that this doesn't work for returning a reference to something allocated on the stack. That simply can't work. However returning by reference can still be extremely useful - for example, a collection's indexing operator can return a value by reference, thus enabling you to assign to that element in the co...
1,980,756
I am looking to use/buy a OCR solution for my next iPhone app. Searching through the answers on this site didn't really help me a lot. Did anybody ever use ABBYY Mobile OCR Engine for iPhone? What interests me is how good is it (recognition) and how much does it cost? Thank you.
2009/12/30
[ "https://Stackoverflow.com/questions/1980756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32188/" ]
For anyone else who ends up at this thread looking for a general iPhone OCR solution (I realize this thread was originally ABBYY specific), there's a good Tesseract proof of concept app here: <http://github.com/rcarlsen/Pocket-OCR>
I had the same idea, and contacted them to ask for prices. 1000$ per year for the basic engine, another 1000$ if you want to use their business card module + up to 50% of each sale!!! very cheap, isnt it? dont think about using the engine if you are not quite sure to sell at least 10.000 apps a year...
315,188
If a method takes an object of class A as parameter and analyzes its properties somehow, performs calculations etc. to verify this object, is it okay for class A to have a `boolean valid` field? After the method of class B completes verification of this object it sets the boolean flag accordingly. The verification pro...
2016/04/08
[ "https://softwareengineering.stackexchange.com/questions/315188", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/222736/" ]
In your case, the object itself is not "valid". It is "valid in some context". This context is defined as "additional info" you described. As such, it should be obvious in which context the object is valid. I would say putting `IsValid` flag in the object doesn't make much sense in this case. Only case it would make s...
Ideally, you shouldn't need to store this information explicitly at all. It should follow implicitly from the control flow of your program. ``` *;; Very easy to read* **ROUTINE** ProcessItem(*item*) **BEGIN** **IF** IsValidItem(*item*) **THEN** ProcessValidItem(*item*) **ELSE** ProcessInvalid...
2,554,934
Is there a way to figure out where in an array a pointer is? Lets say we have done this: ``` int nNums[10] = {'11','51','23', ... }; // Some random sequence int* pInt = &nNums[4]; // Some index in the sequence. ... pInt++; // Assuming we have lost track of the index by this stage. ... `...
2010/03/31
[ "https://Stackoverflow.com/questions/2554934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
Yes: ``` ptrdiff_t index = pInt - nNums; ``` When pointers to elements of an array are subtracted, it is the same as subtracting the subscripts. The type `ptrdiff_t` is defined in `<stddef.h>` (in C++ it should be `std::ptrdiff_t` and `<cstddef>` should be used).
Yeah. You take the value of: ``` pInt - nNums ```
16,663,649
I have a requirement where I need to check for multiple values in sqlite where clause. The query goes like this. ``` String sql = "SELECT * FROM _jobcard_table as t1 " + " left join _customer_table as t2 on (t1._custid=t2._custid) " + " left join _make_table as t3 on (t1._job_make=t3._makeid) " + " lef...
2013/05/21
[ "https://Stackoverflow.com/questions/16663649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2150969/" ]
First, You can not have translation `3x3` matrix for `3D` space. You have to use homogeneous `4x4` matrices. After that create a separate matrix for each transformation (translation, rotation, scale) and multiply them to get the final transformation matrix (multiplying `4x4` matrix will give you `4x4` matrix)
Lets clear some points: Your object consists of 3D points which are basically 3 by 1 matrices. You need a 3 by 3 rotation matrix to rotate your object: R but if you also add translation terms, transformation matrix will be 4 by 4: ``` [R11, R12, R13 tx] [R21, R22, R23 ty] [R31, R32, R33 tz] [0, 0, 0, 1] ``` ...
51,461,156
I have some script for workers and everytime I try to execute one specific worker, it executed all script workers I have instead. this is how I run the script worker: ``` val stockTakingSync = PeriodicWorkRequest.Builder( UploadStockTakingSyncWorker::class.java, interval, TimeUnit....
2018/07/22
[ "https://Stackoverflow.com/questions/51461156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4190539/" ]
I have been looking at different SO questions to solve this issue and none of them helped. My problem was using BrowserRouter in multiple different components. Same as [here](https://github.com/ReactTraining/react-router/issues/4975#issuecomment-344449879).
For me, the issue was that my entire app was wrapped with a `<Router>`, because that was how the boilerplate code was set up. Then I was copying snips from BrowserRouter docs, and did not remove the `<BrowserRouter>` wrapper around the code. Nested routers won't work properly.
27,189,024
I have these codes in my project: ``` @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { int intPos = getArguments().getInt(ARG_SECTION_NUMBER); View rootView; rootView = inflater.inflate(R.layout.fragment_main, con...
2014/11/28
[ "https://Stackoverflow.com/questions/27189024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2740930/" ]
There are mainly two ways with that you can solve it. 1. **getActivity() method:-** Use getActivity() method where you use context or this keyword. 2. If `you can not access getActivity out of your onCreateView method`, then make your **View variable global and use its context,** eg, if your **`View itemView. itemView...
``` ProgressDialog pDialog; pDialog = new ProgressDialog((Main)context); pDialog.setMessage("Loading"); pDialog.show(); ```
27,955,230
I am returning an array of objects to a page that renders a slideshow based on a photo album. I fetch my pictures from the database. Before I return this array as a result, I would like to tack on a "Thumbnail" url property. This property does not exist on the AlbumPicture, but I want it in the response. This illust...
2015/01/15
[ "https://Stackoverflow.com/questions/27955230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/409020/" ]
The answer conanak99 provided is in my opinion the correct way to do this. Extensions like these are usually hidden in your core utilities anyway, and thus the reusable nature of his answer. If you are sure you will only use it for this purpose, you can refactor it to ``` public static dynamic AppendProperty<T>(this ...
Not directly an answer to your question, but it seems to me that you are using something like the Entity Framework to handle your database connection with a "database first" approach. Now you don't want to add the "Thumbnail" property in the database, but also don't want to alter the dynamically created models. Now I ...
5,295,936
I have some whitespace at the begining of a paragraph in a text field in MySQL. Using `trim($var_text_field)` in PHP or `TRIM(text_field)` in MySQL statements does absolutely nothing. What could this whitespace be and how do I remove it by code? If I go into the database and backspace it out, it saves properly. It's ...
2011/03/14
[ "https://Stackoverflow.com/questions/5295936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36545/" ]
If the problem is with UTF-8 NBSP, another simple option is: ``` REPLACE(the_field, UNHEX('C2A0'), ' ') ```
Try using the MySQL `ORD()` function on the `text_field` to check the character code of the left-most character. It can be a non-whitespace characters that *appears* like whitespace.
67,869,209
I'm learning Clojure. I found some exercises which require finding indexes for values in an array which are, for example, lower than next value. In Java I'd write ```java for (int i = 1; ...) if (a[i-1] < a[i]) {result.add(i-1)} ``` in Clojure I found keep-indexed useful: ```clj (defn with-keep-index...
2021/06/07
[ "https://Stackoverflow.com/questions/67869209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13069466/" ]
The logic of forming pairs of numbers and comparing each number to the next number in the sequence can be factored out in a [transducer](https://clojure.org/reference/transducers) that *does not care* about whether you want your result in the form of a vector with all indices or just the last index. Forming pairs can b...
There are many ways to solve a problem. Here are two alternatives, including a unit test using [my favorite template project](https://github.com/io-tupelo/clj-template). The first one uses a loop over the first (N-1) indexes in an imperative style not so different than what you'd write in Java: ``` (ns tst.demo.core ...
62,138,428
I have two columns that are datetime64[ns] objects. I am trying to determine the number of months between them. The columns are: ``` city_clean['last_trip_date'] city_clean['signup_date'] ``` Format is YYYY-MM-DD I tried ``` from dateutil.relativedelta import relativedelta city_clean['months_active'] = relativ...
2020/06/01
[ "https://Stackoverflow.com/questions/62138428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10308255/" ]
This is Pandas, right? Try it like this: ``` # calculate the difference between two dates df['diff_months'] = df['End_date'] - df['Start_date'] # converts the difference in terms of Months (timedelta64(1,’M’)- capital M indicates Months) df['diff_months']=df['diff_months']/np.timedelta64(1,'M') ``` Or, if you hav...
You need to extract the property you want from the `relativedelta`, in this case, `.months`: ``` from dateutil.relativedelta import relativedelta rel = relativedelta(city_clean['signup_date'], city_clean['last_trip_date']) city_clean['months_active'] = rel.years * 12 + rel.months ```
3,089,457
How do I go from this: ``` "01","35004","AL","ACMAR",86.51557,33.584132,6055,0.001499 ``` to this: ``` ACMAR, AL ```
2010/06/22
[ "https://Stackoverflow.com/questions/3089457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/372685/" ]
I'm not quite sure why you'd want to parse a CSV file with a `Regexp` instead of a CSV parser. It makes your life *so* much easier: ``` require 'csv' CSV.open('/path/to/output.csv', 'wt') do |csv| CSV.foreach('/path/to/output.csv') do |_, _, state, city| csv << [state, city] end end ```
If it is an array — `[…].grep(/^[A-Z]+$/)`, if string — `"…".scan(/[A-Z]+/)`
13,066,756
Suppose I have a calculator class that implements the Strategy Pattern using `std::function` objects as follows (see Scott Meyers, Effective C++: 55 Specific Ways to Improve Your Programs and Designs): ``` class Calculator { public: ... std::vector<double> Calculate(double x, double y) { std::vector<double>...
2012/10/25
[ "https://Stackoverflow.com/questions/13066756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/418875/" ]
Why create your own class? There's no need for you to fail to re-create the interface of `unordered_map`. This functionality can be added as a re-usable algorithm based on `std::function` and `std::unordered_map`. It's been a while since I worked with variadic templates, but I hope you get the idea. ``` template<typen...
Before optimizing - measure. Then if you really perform many calculations with same value - then create this cache object. I'd like to hide cache checking and updating in `CacheFG::get(x, y)` and use it like `const auto value = cache->get(x,y)`.
19,677,052
I know that I can just say: ``` radians = degrees * Math.PI/180 ``` However I expect there to be a built in framework method, as it is such a common requirement, however I cannot find one. Am I not looking hard enough or is it missing from the .net framework. *(Please don’t insult me by telling me how to write my ...
2013/10/30
[ "https://Stackoverflow.com/questions/19677052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
I believe there is no such method. > > The angle, a, must be in radians. Multiply by Math.PI/180 to convert > degrees to radians. > > > Above quote taken from [Math.Sin](http://msdn.microsoft.com/en-us/library/system.math.sin.aspx) remarks section. If there is one method in .Net framework, documentation would...
AFAIK there is no built in functionality in the Framework (did the same research myself some time ago). I'e gone with your solution.
13,285,213
I'm talking about ones encoded in the format in which the twitter API returns its dates, like... `"Tue Jan 12 21:33:28 +0000 2010"` The best thing I thought of was to try to slice it up with regexes to become something more like... `20100112213328`, but there's *got* to be a better way.
2012/11/08
[ "https://Stackoverflow.com/questions/13285213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1597180/" ]
You can just make a new Date object using a string like `"Tue Jan 12 21:33:28 +0000 2010"`. ``` var dateString = "Tue Jan 12 21:33:28 +0000 2010"; var twitterDate = new Date(dateString); ``` Then, you can simply use < and > to make comparisons. ``` var now = new Date(); if (now < twitterDate) { // the date is ...
As far as the ECMAScript specification 5.1 goes (see 15.9.1.15), the only supported string interchange format for date-times is `YYYY-MM-DDTHH:mm:ss.sssZ` (along with shorter forms). Otherwise (15.9.4.2): > > If the String does not conform to that format the function may fall back to any implementation-specific heur...
33,679,670
I'm using NetBeans, and I am factoring out common classes into a library. I want to refer to classes in the library. I can do this easily enough by telling NetBeans that one project is dependent on another, the latter being a Java Library project. The library project is called "ReVueLib". I have a folder there called...
2015/11/12
[ "https://Stackoverflow.com/questions/33679670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/929668/" ]
The proper name of a class in a package includes full name of the package. The `import` statement lets you avoid writing the prefix, but that is a compile-time trick. That is why your program prints the fully qualified name `Stream.StreamClient`, even though your program referred to the class by its short name `StreamC...
You cannot refer to a class API without importing it (by either import or explicity fully qualified reference). Ever. Thats set in stone. I think your misconception is that you could just write "Stream.class" somewhere and depending on whats on the classpath it will work. Thats true only to a very limited extent. Whil...
120,242
The launchpad search field suddenly no longer accepts text input for me. ![enter image description here](https://i.stack.imgur.com/7k12F.png) Any idea how to get this to accept text again? Searching for an app was so very useful.
2014/02/07
[ "https://apple.stackexchange.com/questions/120242", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/6759/" ]
I had the same problem today. On the Apple forums, I found a tip to delete the contents of `~/Library/Application Support/Dock` and to restart the Dock using `killall Dock` afterwards. This causes Launchpad to rebuild its database and supposedly should reactivate the search field. I tried this and it did not work for ...
In the Launchpad, press `Cmd` + `Shift` + `esc`. The pad will fade and zoom, and when you hit it again it works so you can type again.
173,612
Context ======= I'm looking for a new job and I've recognized a pattern at some of my previous places that I'd like to correct. I usually don't gain enough trust to influence process in a positive and lasting way. I've found most companies are very focused on business priorities, and for good reason. Many of these iss...
2021/06/13
[ "https://workplace.stackexchange.com/questions/173612", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/126752/" ]
Okay, there's a lot to unpack in your question. **First up, you're conflating two separate things here:** > > How do you gain trust in a new environment? I've seen other developers > do it by working extra hard for the first couple of months to deliver > things faster or fix languishing issues other developers haven...
I feel like you're relating two unrelated things. But they're each quite easily answered independently. Trust ----- You gain trust by being good at your job, delivering results on time and in budget, and by, when asked for your opinion on something, being right. This can be done quickly or slowly depending on your ro...
152,837
How can I write an insert statement which includes the & character? For example, if I wanted to insert "J&J Construction" into a column in the database. I'm not sure if it makes a difference, but I'm using Oracle 9i.
2008/09/30
[ "https://Stackoverflow.com/questions/152837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/466/" ]
I keep on forgetting this and coming back to it again! I think the best answer is a combination of the responses provided so far. Firstly, & is the variable prefix in sqlplus/sqldeveloper, hence the problem - when it appears, it is expected to be part of a variable name. SET DEFINE OFF will stop sqlplus interpreting ...
``` INSERT INTO TEST_TABLE VALUES('Jonhy''s Sport &'||' Fitness') ``` This query's output : **Jonhy's Sport & Fitness**
8,257,599
In Google Map API v3, as the title, I only saw 2 types of animation in google map api, but I saw in some places the map marker animate like grow big when mouse over it? How to implement this?
2011/11/24
[ "https://Stackoverflow.com/questions/8257599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437808/" ]
Use marker's mouseover event handler and `setIcon()` method. You can use [dynamic icons](http://code.google.com/apis/chart/infographics/docs/dynamic_icons.html) from google chart api for this purpose, and change the `chld` attribute to make the icon grow: ![enter image description here](https://i.stack.imgur.com/U54Y6...
You could use your own image as a marker, then make use of the `scaledSize` property for the marker image to make it bigger when the `mouseover` event fires. I don't know of a way to do this without doing some more complicated stuff like this.
37,701,159
I am working on `Rails application` where I am trying to fetch date of particular week but week start from not 1 January of year but some fixed date. Like, `my week start from 8 july 2016 (08-07-2016)` so now i want to fetch start date and end date of any week. ``` Means week 1 start date -> 08-07-2016 and end date -...
2016/06/08
[ "https://Stackoverflow.com/questions/37701159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1498579/" ]
There is no simple way to pick a "random" key from a map. I assume that "random" here means to pick it uniformly at random among the keys of the map. For that, you need to pick a random number in the range `0`..`map.length - 1`. Then you need to get the corresponding key. Since `Map.key` is an iterable, you can't assu...
I guess this is not what you're looking for, but actually it's a line shorter ;-) ``` void main() { var map = {'a' :1, 'b':2, 'c':3}; final _random = new Random(); var values = map.values.toList(); var element = values[_random.nextInt(values.length)]; print(element); } ``` [**DartPad example**](h...
17,295,086
I want to do join the current directory path and a relative directory path `goal_dir` somewhere up in the directory tree, so I get the absolute path to the `goal_dir`. This is my attempt: ``` import os goal_dir = os.path.join(os.getcwd(), "../../my_dir") ``` Now, if the current directory is `C:/here/I/am/`, it joins...
2013/06/25
[ "https://Stackoverflow.com/questions/17295086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1422477/" ]
You can use [normpath](http://docs.python.org/2/library/os.path.html#os.path.normpath), [realpath](http://docs.python.org/2/library/os.path.html#os.path.realpath) or [abspath](http://docs.python.org/2/library/os.path.html#os.path.abspath): ``` import os goal_dir = os.path.join(os.getcwd(), "../../my_dir") print goal_d...
consider to use `os.path.abspath` this will evaluate the absolute path or One can use `os.path.normpath` this will return the normalized path (Normalize path, eliminating double slashes, etc.) One should pick one of these functions depending on requirements In the case of `abspath` In Your example, You don't need to...
39,150,816
I want to create Extension methods for dynamic type, but for some or the other reason i get error while compiling the code. below is my code sample The method which i am using is ``` public List<State> getStates() { return new List<State>(){ new State{StateID="1",StateName="Tamil Nadu"}, new Sta...
2016/08/25
[ "https://Stackoverflow.com/questions/39150816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2711059/" ]
Ideally data should be filtered before rendering however you can also create a [variable in liquid](https://shopify.github.io/liquid/tags/variable/) to hold the number of stuff rendered ``` {% assign rendered = 0 %} {% for study in site.data.studies %} {% if study.category contains "foo" %} <div class="col-sm...
Presuming that your `category` is a string, not an array, you can do : ``` {% assign selected = site.data.studies | where: 'category','foo' %} {% for study in selected limit:4 %} <div class="col-sm-3"> <h3>{{ study.title }}</h3> <div class="list-of-attributes"> <h6>Attributes: </h6> {{ study.attr...
11,768,153
How to get html like this: ``` <div id="generalContainer"> <div id="subContainer"> <div id="content"> </div> </div> </div> ``` from original html like this: ``` <div id="generalContainer"> <div id="content"> </div> </div> ``` Thanks
2012/08/01
[ "https://Stackoverflow.com/questions/11768153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/144140/" ]
``` $("#content").wrap('<div id="subContainer">'); ​​​​​​​​​​ ```
``` <div id="generalContainer"> <div id="content">blabla</div> </div> <script> var ct = $('#generalContainer').html(); $('#generalContainer').html('<div id="subContainer">'+ct+'</div>'); </script> ```
3,541,353
Problem 14 on p. 92 in Kolmogorov and Fomin Introductory real analysis defines a completely regular space by Def. A $T\_{1}$ space T is completely regular iff. given any closed set $F \subseteq T$ and any point $x\_{0} \in T \setminus F$ there exists continuous real function $f$ such that $0 \leq f(x) \leq 1$ and $f(x...
2020/02/10
[ "https://math.stackexchange.com/questions/3541353", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
Here is an example (simpler than the one I mentioned in the comments) of a space which is completely regular but not normal. The Sorgenfrey line is the space $\Bbb R\_\ell=(\Bbb R,\tau)$ where a basis for $\tau$ is given by $\{[a,b)\mid a,b\in\Bbb R\}$, this is a completely regular space (actually it is completely no...
There are a few classical examples that are often used in text books: 1. The [Niemytszki plane](https://en.wikipedia.org/wiki/Moore_plane) (aka the Moore plane, in the US). Quite elementary. Preferred example of Engelking's book. 2. The [(deleted) Tychonoff plank](https://en.wikipedia.org/wiki/Tychonoff_plank) (but th...
18,428,004
Is it possible with javascript/jQuery to create objects on page load (or (document).ready) and then later use them, for example on keyup on an input. If so, how?
2013/08/25
[ "https://Stackoverflow.com/questions/18428004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/263091/" ]
If you put all code in `$(document).ready{all code here}` then your variables won't go out of scope. ``` $(document).ready(function(){ var someObject={}; $("selector").click(function(e){ console.log(someObject); }); }); ``` If you're using onclick in html then I'd advice you to change that and move all JS ...
Below find a example usage. ``` <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> TODO write content <div id="MytextID">My text </div> <input type="text" id="inputId"...
8,727,984
My English issnt so good sorry for that. i have a array: ``` Array ( [name] => Array ( [0] => Sorry the name is missing! [1] => Sorry the name is to short! ) ) ``` Now I want to test with in\_array for eg "name". ``` if (...
2012/01/04
[ "https://Stackoverflow.com/questions/8727984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/933153/" ]
Try array\_key\_exists(): [link](http://www.php.net/array_key_exists) ``` if(array_key_exists('name', $false['name'])) { echo $false['name'][0]; // or [1] .. or whatever you want to echo } ```
`in_array()` does not work with multi-dimensional arrays, so it is not possible to use `in_array()` here. When you are searching "name" in `in_array()` it searches in the first array and finds a key of the array named "name". Better to use [array\_key\_exists](http://php.net/manual/en/function.array-key-exists.php) f...
9,543
One of the current members of our group joined a little later than everyone else. His character's history wasn't developed too well, so I am running a one-off session so that the group can play out his history and get a better sense of the big picture. I solicited a brief history from the player, and a major part of h...
2011/08/19
[ "https://rpg.stackexchange.com/questions/9543", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/1069/" ]
Put the players into story telling mode. A situation with a fixed outcome is not fun to game, but it can be fun to story tell. I had a similar situation two sessions ago. We're fast forwarding through the levels because the game is coming to a close soon. The players had about a thousand miles of travel ahead of them....
First. Make sure everyone in your group understands that this is a no win situation. I feel like if they know they cannot win from the outset they will not be too disappointed whenever what they try does not work, at least to the full extent they were hoping it would. This does not have to be stated out right, it can b...
21,396,928
Let's say that I have an image that can be a variable width (min:`100px`, max:`100%` [760px]). I also have a `<p>` element that is to be shown right below the image. I'd like the `<p>` to end up with the same width as the `<img>`, but I can't seem to find an answer. Here is the code involved in such a scenario [jsfidd...
2014/01/28
[ "https://Stackoverflow.com/questions/21396928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2694234/" ]
You can use `display: table` on the `figure` and set a small width on it. Because it's a table layout it'll then become as wide as the content, in this case the image. ``` figure { display: table; width: 1%; } ``` **[Demo](http://jsfiddle.net/a9rEh/6/)**
It is inheriting from `#page` div. not from the image. Please see the same fiddle updated. But, You can control individual elements. You have to specify how you wish it to look like.
28,911,634
I'm receiving the following warning from mongodb about THP ``` 2015-03-06T21:01:15.526-0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2015-03-06T21:01:15.526-0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' ``` But I did manage to turned ...
2015/03/07
[ "https://Stackoverflow.com/questions/28911634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2487227/" ]
MongoDB have updated their recommendation to use an **init.d** script now: <http://docs.mongodb.org/master/tutorial/transparent-huge-pages/>
Verified that the defrag is examined without regard to the enabled: ``` $ cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never] $ cat /sys/kernel/mm/transparent_hugepage/defrag [always] madvise never $ service mongod start ... (in log) WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always' $ ...
57,466
I'm looking to replace my water heater. I currently have a 15 year old 40 gallon gas water heater, and it's time to go. I had several quotes from local plumbers, and choked at the prices. I'm going to go with a 50 gallon Rheem from Home Depot, and am going to do it myself, and I want to do it legally, to code, and insp...
2015/01/08
[ "https://diy.stackexchange.com/questions/57466", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/31481/" ]
You should make two phone calls. The first to your local building department, which should be able to answer all your code related questions. They may even have a handout or other documentation, that outlines the requirements of replacing a water heater. The second call should be to a local Rheem dealer, or directly ...
Stay away from wireless. Security and cross talk with other 2.4ghz devices being some of the problems. Hard wiring is more effort but worth it. Its rare you will see water pressure to high. But its good to know what your pressure is regardless.
1,670,397
I have a large (600 odd) set of search and replace terms that I need to run as a sed script over some files. The problem is that the search terms are NOT orthogonal... but I think I can get away with it by sorting by line length (i.e. pull out the longest matches first, and then alphabetically within each length. So gi...
2009/11/03
[ "https://Stackoverflow.com/questions/1670397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35961/" ]
You can do this in a one-line Perl script: ``` perl -e 'print sort { length $b<=>length $a || $b cmp $a } <>' input ```
``` $ awk '{print length($1),$1}' file |sort -rn 4 abba 4 aaba 3 bab 3 aba 2 ab 2 aa ``` i leave you to try getting rid of the first column yourself
1,312,438
I'm currently trying to get a script to submit a form to a page that is external to my site but will also e-mail the answers given by the customer to me. The mail() function has worked fine for the mail... but how do I then take these values and also submit them to the external page? Thanks for your help!
2009/08/21
[ "https://Stackoverflow.com/questions/1312438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/140024/" ]
You could send a custom HTTP POST request from the script that you're using to send the email. Try [fsockopen](http://nl2.php.net/fsockopen) to establish the connection and then send your own HTTP request containing the data you just received from the form. Edit: A bit more specific. There's [this](http://netevil.org...
For POST, you'll need to set the external page as the processing action: ``` <form action="http://external-page.com/processor.php" method="POST"> <!-- Form fields go here ---> </form> ``` If it's GET, you can either change the form method to GET, or create a custom query string: ``` <a href="http://external-pag...
7,231,532
I am trying to iterate over this data structure: ``` $deconstructed->{data}->{workspaces}[0]->{workspace}->{facts}[0]->{code} ``` where `fact[0]` is increasing. It's several files I am processing so the number of `{facts}[x]` varies. I thought this might work but it doesn't seem to be stepping up the `$iter` var: ...
2011/08/29
[ "https://Stackoverflow.com/questions/7231532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/488188/" ]
$iter is being set to the content of each item in the array *not* the index. e.g. ``` my $a = [ 'a', 'b', 'c' ]; for my $i (@$a) { print "$i\n"; } ``` ...prints: ``` a b c ``` Try: ``` foreach $iter (@{$deconstructed->{data}->{workspaces}[0]->{workspace}->{facts}}){ print $iter->{code}."\n"; } ```
`$iter` is not going to be an index that you can subscript the array with, it is rather the current element of the array. So I guess you should be fine with: ``` $iter->{code} ```
4,080,667
This is similar to [How to keep the order of elements in hashtable](https://stackoverflow.com/questions/1419708/how-to-keep-the-order-of-elements-in-hashtable), except for .NET. Is there any `Hashtable` or `Dictionary` in .NET that allows you to access it's `.Index` property for the entry in the order in which it was ...
2010/11/02
[ "https://Stackoverflow.com/questions/4080667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/149573/" ]
A `NameValueCollection` can retrieve elements by index (but you cannot ask for the index of a specific key or element). So, ``` var coll = new NameValueCollection(); coll.Add("Z", "1"); coll.Add("A", "2"); Console.WriteLine("{0} = {1}", coll.GetKey(0), coll[0]); // prints "Z = 1" ``` However, it behaves oddly (compa...
> > Is there any Hashtable or Dictionary in .NET that allows you to access it's .Index property for the entry in the order in which it was added to the collection? > > > No. You can enumerate over all the items in a Hastable or Dictionary, but these are not guaranteed to be in any sort of order (most likely they a...
53,143,669
I am using Yoast plugin in my WordPress website for SEO. If I uninstall it after implementing SEO, will its features be removed from my website? Features like title, meta descriptions etc. I want to uninstall to make my website faster to load.
2018/11/04
[ "https://Stackoverflow.com/questions/53143669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6396887/" ]
Yes, those features wil be removed (or rather: not be present anymore): They are added dynamically by the plugin when a page is loaded. So if the plugin is gone, that won't happen anymore. If your website is static, you could copy the relevant HTML meta tags for SEO from the header while the plugin is active, insert t...
First be sure that it is the Yoast plugin that is making your website slow. * You can do this by deactivating all plugin then activating one by one until you find the plugin causing the problem. * You can also view ways to make your website faster using this guide: [The Ultimate Guide to Boost WordPress Speed & Per...
16,553,606
In most OOP books and articles, we read something like this about constructors: > > A constructor is a specialized method in a class, its name is identical > to the class name, and it has no return type. > > > So our constructor is of this form: ``` class MyClass { public: /* no return type */ MyClass(); } ...
2013/05/14
[ "https://Stackoverflow.com/questions/16553606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/645167/" ]
Operator `new` does two things: 1. Allocates memory for a new object (and the pointer to that piece of memory is assigned to obj in your example). 2. Calls the constructor which initializes the object with default values. So, in that sense, constructor doesn't return anything. It's the `new` operator that returns the...
Who cares what descriptions of constructors are used in books? Why bother with the semantics? The single purpose of constructors is to construct and instatiate an object, and there's no OOP without an object. Constructors do something and don't retrun a value so that's why they are labeled by many books as "specialize...
358,373
I [see](https://i.stack.imgur.com/nX6bX.png) the following warning for Sierra wireless (cellular) modems: > > Do not operate the Sierra Wireless modem in any aircraft, whether the aircraft is on the ground or in flight. In aircraft, the Sierra Wireless modem **MUST BE POWERED OFF**. When operating, the Sierra Wireles...
2018/02/26
[ "https://electronics.stackexchange.com/questions/358373", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/4645/" ]
Problem with SMPS is the pulse current rating is usually not much more than the average current rating, so you'll end up paying for a very powerful supply that you will only use when pushing the buttons on your pinball. Unlike a SMPS, a transformer can be overloaded without trouble, as long as duty cycle remains low. ...
A transformer is probably the simplest option. It doesn't need to be exactly "110 in 50 out". Transformers are ratiometric, so you just need about 2:1. I would get a 110 to 230v transformer and run it in reverse. 110 \* (110/230) = 52.6v. I saw some cheap, high power transformers that fit the bill on ebay. You almost ...
37,290,527
I have a scene with two cubes, and I would like to be able to only scale one cube. Basically, what I want to do is when I press the S uppercase key, the cube will continue to become larger as longer as I continue to press uppercase S, and when I press lowercase s I want to be able to make the cube smaller as long as lo...
2016/05/18
[ "https://Stackoverflow.com/questions/37290527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4129683/" ]
Best way to avoid unneccessary event handling is to bind the body click inside the menu click, like so: ``` //persist your current menu state var open = false; function clickOn() { //force open the menu rather than toggle //so you are in control of the state $(".startBtn").fadeOut(200); $("#startMnu"...
```js $(".startBtn").click(function() { $(".startBtn").fadeToggle(200); $("#startMnu").toggle(200); }); $("body").click(function(event) { if(!$(event.target).closest('#startMnu').length && !$(event.target).closest('.startBtn').length) { $(".startBtn").fadeToggle(200); $("#startMnu")...
36,922,921
I've written a function with recursive approach to get the values from nested Array. The problem is, I can't reset the global variable after each call. Here after every call the results are being appended to previous result instead of giving new result. I know, Global variable isn't being reset, so data will always app...
2016/04/28
[ "https://Stackoverflow.com/questions/36922921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4533505/" ]
> > But I can't define the variable inside the function as its recursive > call. > > > You can define the result variable inside the function but you need to properly deal with the return values of your recursive calls: ``` function getData(arr) { var res = []; if (Array.isArray(arr)) { for (var...
Landed up with another solution using closure, it might help someone. ``` function getData(arr) { var res = []; return innerGetData(arr); function innerGetData(arr) { if(!Array.isArray(arr)) { res.push(arr); return res; } for(var i = 0; i < arr.length; i++) { innerGetData(arr[i]); ...
7,730
In the opening of Fullmetal Alchemist, it says... > > Human kind cannot obtain anything without first giving something in > return To obtain, something of equal value must be lost That is > alchemy's first law of equivalent exchange. In those days, we really > believed that to be that world's one and only truth. >...
2014/02/27
[ "https://anime.stackexchange.com/questions/7730", "https://anime.stackexchange.com", "https://anime.stackexchange.com/users/3650/" ]
Okay, so, there's a couple things in play here you need to be aware of. Keep in mind that some of this is slightly speculative. First, it is *only in the dub* that Alphonse states it to be the "one and only" truth. The original commentary states, > > その頃【ころ】、ぼくらは、それが世界【せかい】の真実【しんじつ】だと信じて【しんじて】いた。 > > > "When we we...
Alchemy in the real world is recognized as a protoscience that contributed to the development of modern chemistry and medicine. Both Ed and Al say that Alchemy is a science and that the input must be equal to their output, equivalent exchange is this because for what you give up (your input) you will recive something...
780,617
A DFA that accepts a language in which every odd position of a string is a 1 with inputs as {0,1}
2014/05/04
[ "https://math.stackexchange.com/questions/780617", "https://math.stackexchange.com", "https://math.stackexchange.com/users/147724/" ]
You can do this in 2 states - `WAIT` and `OK`. You start in the `WAIT` state and hope to get to the `OK` state, which accepts. Here are the rules: $$ \mathrm{WAIT} \overset{1}{\rightarrow} \mathrm{OK} $$ $$ \mathrm{OK} \overset{0}{\rightarrow} \mathrm{WAIT} $$ $$ \mathrm{OK} \overset{1}{\rightarrow} \mathrm{WAIT} $$
![State Machine](https://i.stack.imgur.com/pzR2z.jpg) All state machines have a starting point. The top right state represents the "never going to accept" state. The bottom left state is the necessary accepting state. The other state is the "seen an even number of inputs and so far so good" state.
5,599,391
I know how to obtain which modifier key was pressed in C# but I don't know how I can actually check if any modifier key was pressed. I need to check it in `KeyUp` event, is it possible any other way than doing something like `if(e.KeyCode != Keys.Control && e.KeyCode != Keys.Alt && ...)` ? Thanks.
2011/04/08
[ "https://Stackoverflow.com/questions/5599391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/678377/" ]
``` if ((Control.ModifierKeys & Keys.Shift) != 0) ``` will help you detect whether a modifier key (e.g. `ctrl` or `shift`) was pressed. Check the Post below for reference: [How to detect the currently pressed key?](https://stackoverflow.com/questions/1100285/c-how-to-detect-the-currently-pressed-key/1100374#1100374...
The [KeyEventArgs](http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.aspx) class has properties that you can check. For example, to see if the Alt key was pressed, you can write: ``` if (e.Alt) { // Alt key was pressed } ```
48,155,787
I have the following dataframe `df`: ``` id lat lon year month day 0 381 53.30660 -0.54649 2004 1 2 1 381 53.30660 -0.54649 2004 1 3 2 381 53.30660 -0.54649 2004 1 4 ``` and I want to create a new column `df['...
2018/01/08
[ "https://Stackoverflow.com/questions/48155787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5110870/" ]
One solution would be to convert these columns to string, concatenate using `agg` + `str.join`, and then convert to `datetime`. ``` df['Date'] = pd.to_datetime( df[['year', 'month', 'day']].astype(str).agg('-'.join, axis=1)) df id lat lon year month day Date 0 381 53.3066 -0.54649 2004 ...
To fix your code ``` df['Date']=pd.to_datetime(df.year*10000+df.month*100+df.day,format='%Y%m%d') df Out[57]: id lat lon year month day Date 0 381 53.3066 -0.54649 2004 1 2 2004-01-02 1 381 53.3066 -0.54649 2004 1 3 2004-01-03 2 381 53.3066 -0.54649 2004 1 4 20...
9,660
So, I tend to run 700x23c or 700x25c tires on my commuter bike. Sometimes I'm lazy and forget to check the air pressure and inevitably get a pinch flat when I hit some stationary object, pothole, or big curb. When I get a snakebike type of pinch flat (2 holes somewhat separated, usually on opposite sides of a ridge in...
2012/05/31
[ "https://bicycles.stackexchange.com/questions/9660", "https://bicycles.stackexchange.com", "https://bicycles.stackexchange.com/users/2997/" ]
1. Use the thinnest conventional (tube-of-glue type) patches you can find. They should be the type with feathered edges. A little overlap is OK, but trim the edges if there will be a lot. 2. Better still, swap in your spare tube. 3. Better still, don't let your tires go flat. (Avoid using large patches as they won't e...
I've had good luck with the Park GP-2's being extremely durable, lasting as long as the tube. Back when I was using them frequently, I think I was running somewhere in the 70-90 PSI range.
5,790,837
I have an application which i am going to install on Linux touch system. The touch system is not giving me the touch sound so i decided to have that feature on my application. What is the best way to do it ? I dont want to go through each and every buttons and other components and write the codes there. Is there any gl...
2011/04/26
[ "https://Stackoverflow.com/questions/5790837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/402610/" ]
Take this answer: [How can I play sound in Java?](https://stackoverflow.com/questions/26305/how-can-i-play-sound-in-java) ... and trigger the playback in the mouse click event.
Assuming that you are using the JFC/Swing toolkit, you might want to read a bit about using the [Multiplexing Look & Feel](http://java.sun.com/products/jfc/tsc/articles/multiplexing/). Even though I don't know of any ready-to-use auxiliary look and feel(s) that might fit your needs, it should be possible to write your ...
87,860
We have an Intel Pro 1000 PT Dual Port Server Adapter running on a WIN2K8 box housed in an offsite colo. I recently learned that the auto-negotiated link speed is 100Mbps. When I run the diagnostic test provided by the Device Manager > [Card] > Properties window, it says that the Network Adapter is set to auto negoti...
2009/11/24
[ "https://serverfault.com/questions/87860", "https://serverfault.com", "https://serverfault.com/users/26793/" ]
Step 1: Ensure that the switch you're plugged into is really gigabit. Step 2: Be prepared to travel to the colo to fix this should it go dark. My guess is that the switch port is not allowing gigabit.
Do you have the latest driver for the NIC? Is it the Intel provided driver or a Windows driver?
42,265,063
When i am adding multiple fragments to a FragmentTransaction and commiting after that only last fragment is added. ``` getFragmentManager().beginTransaction().add(R.id.main_container,PropertyListFragment.newInstance()).addToBackStack(null) .add(R.id.main_container, BlankFragment.newInstance("df...
2017/02/16
[ "https://Stackoverflow.com/questions/42265063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3069261/" ]
You can't use fragment in this way you need to use just one fragment per container. check this: [How do I properly add multiple fragments to a fragment transition?](https://stackoverflow.com/questions/12444205/how-do-i-properly-add-multiple-fragments-to-a-fragment-transition)
Above answer is right. You can't use fragment in this way you need to use just one fragment per container but I gave you a little help here. You need to define at the `XML` `FrameLayout` for each `Fragment` something like this. ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="h...
5,187,607
I wish to be able to write tests like this: ```none Background: Given a user signs up for a 30 day account Scenario: access before expiry When they login in 29 days Then they will be let in Scenario: access after expiry When they login in 31 days Then they will be asked to renew Scenario: access after aco...
2011/03/03
[ "https://Stackoverflow.com/questions/5187607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
``` > how can the same step definitions cope with both "31 days" and "2 years time" ``` If your rules need no special handling for workingday, xmas, weekend, ... you can modify @Nitro52-s answer to: ``` [When(@"they login in (\d+) days")] public void WhenTheyLoginInDays(int daysRemaining) { Account.Regristration...
Try using [Moles](http://research.microsoft.com/en-us/projects/moles/) and stub the DateTime.Now to return the same date everytime. One of the best features of Moles is the ability to turn dang near anything into a runtime delegate that you can isolate. The only drawback is that it may run slower depending on the imple...
51,593
Every time I open Windows Explorer it is not maximized so I have to double click on the window header. Is there some way to have it open maximized by default?
2009/10/06
[ "https://superuser.com/questions/51593", "https://superuser.com", "https://superuser.com/users/13336/" ]
Eusing's **[Auto Window Manager](http://www.eusing.com/WindowManager/WindowManager.htm)** will do that (and a lot more useful things) for you. > > **Automatically maximize** or minimize or normal **all new windows you > specify**. > > > Automatically minimize all new windows > you specify to system tray. > > > ...
A VBscript that will do the tip #3 of @joe automatically (Windows 8+) ``` Dim WshShell Set WshShell = createObject("Wscript.Shell") WshShell.Run "explorer.exe" Wscript.Sleep 2000 WshShell.AppActivate "File explorer" WshShell.Sleep 2000 WshShell.SendKeys "+%{F4}" Set WshShell = Nothing ``` Set `WshShell.AppActivate` ...
51,608,549
I have a list: ``` list1=[[2,3],[4,5],[6,7]] ``` I want to add a single value "one" to all sublist in the list at index 2 final output should be: ``` list2=[[2,3,"one"],[4,5,"one"],[6,7,"one"]] ``` tried with: ``` for list2 in list1: print list2.insert(2,"one") ``` But its showing error as `None`.
2018/07/31
[ "https://Stackoverflow.com/questions/51608549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7482017/" ]
`list.insert` is an [in-place operation](https://stackoverflow.com/questions/1516889/python-insert-not-getting-desired-results) and returns `None`. Instead, you can use a list comprehension: ``` L = [[2,3],[4,5],[6,7]] res = [[i, j, 'one'] for i, j in L] print(res) [[2, 3, 'one'], [4, 5, 'one'], [6, 7, 'one']] ```
Change your code as below : ``` list1=[[2,3],[4,5],[6,7]] for subList in list1: subList.append("one") print list1 ``` Output is : ``` [[2, 3, 'one'], [4, 5, 'one'], [6, 7, 'one']] ```
8,548,387
I'm a C++ learner.I'm trying to code a basic C++ project. It's basic automation system . It has a navigation menu. ``` Choose an option : 1 ) Add a new customer 2 ) List all customers ... ``` There will be a `nav`variable, which containing user's choice. This is my source code : ``` #include <stdio.h> #inc...
2011/12/17
[ "https://Stackoverflow.com/questions/8548387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556169/" ]
You should declare `navigasyon` before `main`.
Place 'navigasyon' above main. C++ demands that functions are declared before they are used. This can done by placing the whole function before the usage or by forward declaration, where you only have the signature before.
22,859,494
I have got the following trouble: I have installed SonarQube and Android Plugin with "Android Lint" Quality Profile. When I execute my *build.gradle* script with "Android Lint" profile, sonar-runner plugin works good, but in SonarQube I can see no matching issues found, just zero. Nevertheless, when I include another...
2014/04/04
[ "https://Stackoverflow.com/questions/22859494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2016020/" ]
Your `sonar.sources` property should point to the root of **AndroidManifest.xml** file. E.g. if your **AndroidManifest.xml** file is located in `src/main` then your `build.gradle` file should contain: ``` sonarRunner { sonarProperties { ... property "sonar.sources", "src/main" property "son...
**change your sonar properties like this:** ``` apply plugin: "org.sonarqube" sonarqube { properties { property "sonar.projectName", "appa" property "sonar.projectKey", "appa_app" property "sonar.projectVersion", "1.0" property "sonar.analysis.mode", "publish" property "sonar.language", "jav...
236,710
I've been wondering for some time what the best way to pass a 2d array to functions is. I know that arrays, passed to functions, decay into pointers, so `int arr[25]` would become `int *arr` inside a function. The problem is with 2d arrays, `int arr[5][5]` would not become `int **arr`. Instead I've been taught to pass ...
2020/02/05
[ "https://codereview.stackexchange.com/questions/236710", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/212777/" ]
Type-wise, it is ok to go from void pointers to array pointers and back. As long as the "effective type" is an int array of the specified size. Void pointers do however have non-existent type safety, so they should be avoided for that reason. The best way is rather to use an array and let the compiler "adjust" it to a...
One suggestion will be to put your parameters on a dedicated struct ``` struct my_array { void *data; size_t rows; size_t cols; } ``` So your functions will only have one parameter as input.
44,201,164
I have searched the site for an answer to my question, however the solutions have been unable to solve my problem. My Problem is: I have tried to add a php echo element inside of an html tag. However it is throwing off an error as seen in the screenshot. I have tried various ways to adjust this code unsuccessfully. I...
2017/05/26
[ "https://Stackoverflow.com/questions/44201164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7972524/" ]
You can't separate your string like that: ``` echo 'Image' 'img src='...; ^ ``` If you want to concatenate everything, use `.` or just put it all on the same string: ``` echo 'Image <img src="'. $yourVariable.'"/>'; ... ```
Your ' and " were in the wrong spots. Also, not that it's related to your PHP erorr but you were also missing the < /> around your image. ``` echo 'Image: <img src="' . $page->image . '" alt=""/></br>'; ```
29,171,854
This is a simple question regarding Wordpress API /wp-json. I am querying some data filtered with certain category in Wordpress. My questions is how can I control amount of result that gets returned from my Get request... The default returns seems to return around 11 most recent results. Is there any way I can make it ...
2015/03/20
[ "https://Stackoverflow.com/questions/29171854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1363876/" ]
If you're using v2 of the WordPress REST API, it looks like the current method of controlling the number of results returned is: ``` website.com/wp-json/wp/v2/posts/?per_page=100 ``` Replace 100 with the desired count. If you're using a custom post type, replace posts with the custom post type. Also make sure to se...
My recommendation above is no longer correct. Now you'll want to use: ``` website.com/wp-json/wp/v2/posts/?filter[posts_per_page]=100 ``` Change the number to retrieve more or fewer posts. Change "posts" to your custom post type if necessary and make sure to set `'show_in_rest' => true` when registering the custom p...
14,145,336
With jquery, I'm attempting to pull information from a .php file and run it in another html page. To try this out I attempted to use this example: <http://www.tutorialspoint.com/jquery/ajax-jquery-get.htm> The .php file would include: ``` <?php if( $_REQUEST["name"] ) { $name = $_REQUEST['name'...
2013/01/03
[ "https://Stackoverflow.com/questions/14145336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1899371/" ]
> > The files are hosted from a folder on my computer > > > This gives you two problems: 1. Browsers put pretty strict restrictions on what webpages loaded from the filesystem can do, loading other files via XMLHttpRequest is forbidden 2. PHP is a server side technology, it needs a server to work (in this context...
Use jquery.ajax instead. Here is your HTML code ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Sandbox</title> <meta http-equiv="Content-Type" content="t...
58,802,826
I have an html table and I want to draw an arrow from one cell to an other cell. For example like this: [![arrow-above-html-table](https://i.stack.imgur.com/rbJzg.png)](https://i.stack.imgur.com/rbJzg.png) How could this be done? Example HTML: ``` <html> <body> <table> <tr><td>0</td><td>1</td><td>2</td><td>3</t...
2019/11/11
[ "https://Stackoverflow.com/questions/58802826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/633961/" ]
With a bit of JavasSript and CSS you can achieve this without canvas or SVG. Here is an example: ```js function getPosition(el) { return { x: el.offsetLeft + el.offsetWidth / 2, y: el.offsetTop + el.offsetHeight / 2 }; } function getDistance(a, b) { const from = getPosition(a); const t...
You can use my solution not complete draw arrow yet, let create a canvas and draw a line from two points, based on calculate of start and end point. ``` Example running: https://jsfiddle.net/tabvn/uk7hsj3a ``` ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title></title> </head> <b...
63,771,879
*Edit: Still have this issue.* Visual Studio Code throws the following error: `User model imported from django.contrib.models` The error appears in line 2 of the following script (`models.py`). The code is from a Django tutorial and works fine. But it is annoying that Visual Studio Code (**Pylint**) throws an error ...
2020/09/07
[ "https://Stackoverflow.com/questions/63771879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9838670/" ]
This is late but you can always run the following in your terminal `pip install pylint-django` and add this to settings.json file found in .vscode folder (assuming you're using vscode) ``` "python.linting.pylintArgs": [ "--load-plugins", "pylint_django", "--errors-only", "--load-plugins pylint_djang...
An alternative (when not using the User model in the models module but in other modules) is to use `from django.contrib.auth import get_user_model` and use `get_user_model()` where you are now using User, this will probably give errors while you do this in the models.py module, because django isn't ready getting the u...
34,348,162
I have a dropdown that gets its items from database. The default value to be selected in this dropdown is retrieved from a cookie. The problem is, 1. there is an empty option tag as the first option and also, 2. the default value is not selected. There is no issue at all when I use `v1.3.16`. This happens whe...
2015/12/18
[ "https://Stackoverflow.com/questions/34348162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3813371/" ]
router.php ``` <?=file_get_contents('php://input'); ``` Start embedded server ```sh php -S 127.0.0.0:8080 ./router.php ``` Test cURL: ``` <?php $ch = curl_init("http://127.0.0.1:8080/"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_RETURNTRANSFER...
Try this function: ``` function url_get_contents ($Url) { if (!function_exists('curl_init')){ die('CURL is not installed!'); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); curl_close($ch); retu...
4,776,786
I have a field in which all data needs to be 13 characters in length. I would like to show a check mark image if the file name that was placed in the database is the correct number of characters (13) or show an exclamation mark image if the file name is not equal to 13 characters in length. This is what I have so far, ...
2011/01/23
[ "https://Stackoverflow.com/questions/4776786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/328310/" ]
Use [strlen()](http://php.net/manual/en/function.strlen.php). count\_chars() is for counting the number of occurances of each character in the alphabet in a string.
``` <?php $val1 = 13; if (strlen($image_id) == ($val1)) { echo '<img src="images/icons/check.gif" />'; } else { echo '<img src="images/icons/exclamation.gif" />'; } ?> ```
3,139,480
Suppose I have two systems $A$ and $B$ that produces the numbered tiles. System $A$ produces tiles 1, 2, 3, 4, and 5 with the probabilities: ``` P(1) = 0.5 P(2) = 0.2 P(3) = 0.2 P(4) = 0.07 P(5) = 0.03 ``` System $B$ produces tiles 10, 11, 12, ... 100 with the probabilities: ``` P(10) = 0.08 P(11) = 0.05 P(12) = 0....
2019/03/07
[ "https://math.stackexchange.com/questions/3139480", "https://math.stackexchange.com", "https://math.stackexchange.com/users/121142/" ]
Your `ud` definition does not match the idea behind the `ud` in the Steiner/Simons-analyses - perhaps from a correction of this you'll get some clarification. Assume the `u` one step (on odd numbers) $a\_{k+1}=(3a\_k+1)/2$ then $a\_{k+1}$ is obviously larger than $a\_k$ and thus we may call it `u`-step because it is ...
Here is an excerpt of the original work of Simons/de Weger in 2005 (pg 55). $K$ means here the number of odd steps $(3x+1)/2$ , $L$ the number of even steps $x/2$ . Perhaps this is more enlighting what "m-cycles" or "k-cycles" and "68-cycle" and "72-cycle" could mean: [![image](https://i.stack.imgur.com/h8aQL.png)](ht...
13,713,528
This question looks quite similar to [this one](https://stackoverflow.com/questions/11786023/how-to-disable-double-click-zoom-for-d3-behavior-zoom), but I am still not able to figure out whether it is possible to use d3.behavior.zoom but without the pan ability. In other words I just want to zoom-in/out using the wheel...
2012/12/04
[ "https://Stackoverflow.com/questions/13713528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/623492/" ]
I guess it would be good sharing the workaround I found to deal with this problem. What I did is to use the listener on the start of the brush to "deactivate" the zoom: ``` zoom.on("zoom",null); selection.call(zoom); ``` and activate it again on the *brushend* event. There is one more trick to take into account an...
One solution that I found was to stick a rect element in front of the zoom-enabled element (they must be siblings) and set its fill to 'transparent', when I wanted to disable zoom interaction or to 'none', when I wanted to enable zoom interaction. It looked something like this: ``` if (chart._disableZoom) { var ro...
21,290,841
I need to automate adding images to some existing posts via Craigslist API. The documentation at <http://www.craigslist.org/about/bulk_posting_interface> states: ***Note: If you submit a posting item with the same rdf:about as an existing posting item, the existing posting item will not be updated. Presently the ...
2014/01/22
[ "https://Stackoverflow.com/questions/21290841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2540450/" ]
If we go through the different points you mentioned: * ***I am working a problem where multiple applications need to share classes loaded by each other:*** put the classes in a common classloader at the server level, and remove them from the WARs WEB-INF/libs to avoid that WAR classes hide server classes. For example ...
If you are trying to share libs within multiple web apps you need to let these libs inside JBOSS's shared library folder. JBOSS will load then at startup. See this: [Where to put a shared library in JBoss AS 5?](https://stackoverflow.com/questions/2108975/where-to-put-a-shared-library-in-jboss-as-5) It's not possibl...
71,581,892
**How can I improve this matrix inverse calculator** I made this matrix inverse calculator and it works fine but i want to know how can this program be made shorter.Thanks ``` from numpy import * #inverse calculator print(array([['a,b,c'],['d,e,f'],['g,h,i']])) a = int(input("a: ")) b = int(input("b: ")) c = ...
2022/03/23
[ "https://Stackoverflow.com/questions/71581892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17761196/" ]
Do something like: ``` public void RemoveLastRowOf5() { for(int i=1; i<=5 && textboxes.Count>0; i++) { textboxes.Pop().Dispose(); } } ``` > > may i know after i save it in the database. how to clear the dynamic > textboxes user input? > > > This is a disadvantage to using the `Stack`. You'd have...
``` public void RemoveLast() { int count = 0; while (textboxes.Count > 0 && count < 5) // the count of TextBox that you want to delete { TextBox tb = textboxes.Pop(); this.Controls.Remove(tb); tb.Dispose(); count++; // my mistake.. I modified. } } ``` I think you w...
25,754,099
In PHP, I have a class that takes in a function object and calls that function in a thread: [see the answer to this question](https://stackoverflow.com/questions/25186885/thread-wrapper-class-for-a-function-with-variable-arguments-in-php/25575182#25575182). It works well with anonymous functions, however, I want to us...
2014/09/09
[ "https://Stackoverflow.com/questions/25754099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2386432/" ]
In PHP you would usually use a [callback](http://php.net/manual/de/language.types.callable.php) for this: ``` $callback = array('ClassName', 'methodName'); $thThread = new FunctionThreader($callback, $aParams); ``` --- If `FunctionThreader::__construct()` does only accept a `Closure` and you have no influence on it...
You could define a lambda function which calls your static function. Or simply store function name as a string in that variable. You would also have to implement a handler code for the class that calls a function from variable. Resources: <http://php.net/manual/en/function.forward-static-call-array.php> <http://ee1.p...
32,634,489
I am wondering if there is a way to setup a static IP address to a virtual machine (VirtualBox) hosted on a GCE VM instance (as a VM host). I want to run two VirtualBox VMs on my GCE VM instance and I want to access them publicly.
2015/09/17
[ "https://Stackoverflow.com/questions/32634489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4974383/" ]
Yes, you can do this, but you should also consider whether you want the additional overhead of running one virtual machine (VirtualBox) inside of another virtual machine (GCE VM). Running directly on GCE VMs would be more efficient and you can easily create/destroy/control these VMs via Google Cloud Platform APIs. In ...
I solved that issue to in 2 steps: First delete the current possible ephimeral ip configuration: ============================================================= ``` gcloud compute instances delete-access-config <instance> --access-config-name "External NAT" ``` Where `<instance>` is the name of the instance you want ...
3,827
[Shadowing](http://www.foreignlanguageexpertise.com/foreign_language_study.html#svd) is a technique for improving pronunciation popularised by the polyglot [Alexander Arguelles](http://www.foreignlanguageexpertise.com/about.html). There are many YouTube videos about the technique; most of them don't demonstrate shadowi...
2018/10/01
[ "https://languagelearning.stackexchange.com/questions/3827", "https://languagelearning.stackexchange.com", "https://languagelearning.stackexchange.com/users/800/" ]
I think shadowing is definitely not just for interpreters trainees. My source is the [video](https://www.youtube.com/watch?v=130bOvRpt24) that Professor Alexander Arguelles made. He clearly intends it to be used by beginners for the purpose of learning a language from scratch, and talks about Shadowing generally for th...
The article [1], from 1997, states that although shadowing is still occasionally used, it is not considered a good method. In the book [2], from 2003, it is briefly mentioned that > > The move away from prescriptivism in interpreter training has led to the inclusion of activities such as the use of shadowing in train...
3,609,918
I am trying to set the [Template](http://msdn.microsoft.com/en-us/library/aa372070(v=VS.85).aspx) property in the Summary Information Stram but whatever I do, it fails. I can read the property from the handle but can't write it back. I want to generate multilingual copies of the MSI which is built (candled and light) ...
2010/08/31
[ "https://Stackoverflow.com/questions/3609918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/219323/" ]
Get rid of the MsiInterop that you are using and use the interop found in WiX's DTF. The Microsoft.Deploymnet.WindowsInstaller namespace has a SummaryInformation Class that exposes a read/write string Template property. Way better object model and interop without worrying about all the P/Invoke details that your curren...
``` Database msidb = objInstaller.OpenDatabase(MSIFileNameWithPath,MsiOpenDatabaseMode.msiOpenDatabaseModeTransact); SummaryInfo info = msidb.get_SummaryInformation(1); info.set_Property(2, (object)("sample title")); info.Persist(); msidb.Commit(); ``` The best reference to answer this is in detail is <https://learn...
2,677,903
I have to strip a file path and get the parent folder. Say my path is ``` \\ServerA\FolderA\FolderB\File.jpg ``` I need to get 1. File Name = File.jog 2. Folder it resides in = FolderB 3. And parent folder = FolderA I always have to go 2 levels up from where the file resides. Is there an easier way or is a regu...
2010/04/20
[ "https://Stackoverflow.com/questions/2677903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/321628/" ]
``` string fileName = System.IO.Path.GetFileName(path); string parent = System.IO.Path.GetDirectoryName(path); string parentParent = System.IO.Directory.GetParent(parent); ```
Check out the Directory class (better choice than DirectoryInfo in this case). It does everything you need. You should not use a regex or any other parsing technique.
7,617,639
I have a PHP array of numbers, which I would like to prefix with a minus (-). I think through the use of explode and implode it would be possible but my knowledge of php is not possible to actually do it. Any help would be appreciated. Essentially I would like to go from this: ``` $array = [1, 2, 3, 4, 5]; ``` to t...
2011/10/01
[ "https://Stackoverflow.com/questions/7617639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/903346/" ]
An elegant way to prefix array values (PHP 5.3+): ``` $prefixed_array = preg_filter('/^/', 'prefix_', $array); ``` Additionally, this is more than three times faster than a `foreach`.
I had the same situation before. ### Adding a prefix to each array value ``` function addPrefixToArray(array $array, string $prefix) { return array_map(function ($arrayValues) use ($prefix) { return $prefix . $arrayValues; }, $array); } ``` ### Adding a suffix to each array value ``` function addSu...
434,024
In R I've typed the following code to get my scatterplots but the plots are all very bunched up: [![enter image description here](https://i.stack.imgur.com/L6QuT.png)](https://i.stack.imgur.com/L6QuT.png) ``` par(mfrow=c(1,2),mai=c(0.8,0.8,2,0.8)); plot(x,y,"",cex.lab=0.5,cex.axis=0.5) plot(log(x),y,cex.lab=0.5,cex...
2019/10/31
[ "https://stats.stackexchange.com/questions/434024", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/243542/" ]
The `hexbin` package: my quick and painless go-to for visualizing overplotted data sets. ``` library(hexbin) set.seed(4321) x.axis <- c(rnorm(2000), rnorm(2000, 4, 2)) y.axis <- c(rnorm(2000), rnorm(2000, 2, 3)) point.map <- cbind(x.axis, y.axis) # Square plot region par(pty = "s") # Standard R plot plot(point.map)...
**One way to better visualize bivariate relationships is shown below. I will use `iris` data an example** [![enter image description here](https://i.stack.imgur.com/sK9rc.png)](https://i.stack.imgur.com/sK9rc.png) ``` # install.packages("PerformanceAnalytics") library("PerformanceAnalytics") my_data <- iris[, c(1,3,...
54,167,792
I need to achieve something similar to: [Checking if values in List is part of String](https://stackoverflow.com/questions/16046146/checking-if-values-in-list-is-part-of-string) in spark. I.e. there is a dataframe of: ``` abcd_some long strings goo bar baz ``` and an Array of desired words like `["some", "bar"]`. A...
2019/01/13
[ "https://Stackoverflow.com/questions/54167792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2587904/" ]
You have the right idea, but I think you want to use `||` not `or`. Something like: ``` def orFilterGeneratorMultiContains(filterPredicates:Seq[String], column:String): Column = { val coi = col(column) filterPredicates.map(coi.contains).reduce(_ || _) } ```
Wouldn't [rlike](https://spark.apache.org/docs/1.4.0/api/java/org/apache/spark/sql/Column.html#rlike(java.lang.String)) work in this case? ``` df.filter(col("foo").rlike(interestingThings.mkString("|")) ```
41,274,067
I have a class that is derived from two identical bases: ``` class Vector3d {...}; class Position:public Vector3d {...}; class Velocity:public Vector3d {...}; class Trajectory:public Position, public Velocity { Vector3d &GetPosition(void); Vector3d &GetVelocity(void); }; ``` I would like to have a member fu...
2016/12/22
[ "https://Stackoverflow.com/questions/41274067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7328061/" ]
You might do ``` class Trajectory:public Position, public Velocity { public: Vector3d &GetPosition() { return static_cast<Position&>(*this); } Vector3d &GetVelocity() { return static_cast<Velocity&>(*this); } }; ``` [Demo](http://ideone.com/uSzgAp) but using composition instead of inheritance seems more app...
I understand velocity is a vector (v1, v2, v3), also position is a point in 3d space (p1, p2, p3). Now in a trajectory, a point can have both velocity and position, velocity and position are both needed. For one thing you can not use virtual inheritance. I think composition makes more sense. ``` class Trajectory { ...
479,618
I am using WCF to a soap endpoint using security mode "TransportWithMessageCredential". The WCF client/server uses SCT (Security Context Token) to maintain a secure connection, and it is working as intended in the general case. However, after a period of inactivity, the SCT will be expired and the next method call wi...
2009/01/26
[ "https://Stackoverflow.com/questions/479618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42272/" ]
You could resolve your issues by using delegates. This will allow to safely invoke the action and, if fails, catch the exception, construct a new service instance and perform the action again. ``` using System; using System.ServiceModel; using System.ServiceModel.Security; public static class Service { private st...
You might be able to use the decorater pattern to handle exceptions with WCF proxies. If this path is open to you, you can consider something like this set-up which will handle the proxy faulting and re-initialise it for callers. Subsequent exceptions will be thrown up to the caller. ``` //Proxy implements this inter...
71,121,323
This is a old question, I know [Yocto: why is a package included?](https://stackoverflow.com/questions/26238210/yocto-why-is-a-package-included) [Why is package included in Yocto rootfs?](https://stackoverflow.com/questions/67785619/why-is-package-included-in-yocto-rootfs) but there is not satisfactory answer. I ge...
2022/02/15
[ "https://Stackoverflow.com/questions/71121323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7793992/" ]
One way you can do this is like so using `CustomPainter`. ``` class SampleExample extends StatelessWidget { @override Widget build(BuildContext context) { return const Scaffold( backgroundColor: Colors.red, body: Align( alignment: Alignment.bottomCenter, child: CustomPaint( ...
``` @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: ClipPath( clipper: CurveClipper(), child: Container( color: Colors.lightGreen, height: 250.0, child: Center( ...
6,451,441
I need to get the RGB value of a color given it's name in C#. I am trying to use the predefined KnownColors enum, but can't figure out how to get the value. Any help? Thank you.
2011/06/23
[ "https://Stackoverflow.com/questions/6451441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/331785/" ]
Use [`FromKnownColor`](http://msdn.microsoft.com/en-us/library/system.drawing.color.fromknowncolor.aspx): ``` Color blue = Color.FromKnownColor(KnownColor.Blue); ``` Then `blue.R`, `blue.G` and `blue.B` for the RGB values. --- Or, if you just want the `int` value for the RGB color, you can do: ``` int blueRgb = C...
``` Color clr = FromKnownColor(System.Drawing.KnownColor.Blue); string.Format("R:{0}, G:{1}, B:{2}" clr.R, clr.G, clr.B); ``` Check this [Out](https://stackoverflow.com/questions/225953/c-color-constant-r-g-b-values)