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
31,692,136
I have a `DataFrame` and running a `flatMap` on it. Inside the map function i am trying to append a new field to the given row. How can I do that? ``` def mapper(row): value = 0 #some computation here row.append(newvalue = value) #??? something like that return row data = sqlContext.jsonFile("data.json")...
2015/07/29
[ "https://Stackoverflow.com/questions/31692136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3568427/" ]
Following your lead I created something more flexible, and I hope it helps: ``` from pyspark.sql import Row def addRowColumn(row, **kwargs): rowData = row.asDict() for column in kwargs: rowData[column] = kwargs[column] return Row(**rowData) ``` And to use it on a single row, just call like this:...
Figured it out, but i am not sure if it is the correct way. ``` def mapper(row): from pyspark.sql import Row value = 0 #some computation here data = row.asDict() data["newvalue"] = value return Row(**data) ```
65,553,557
I'm facing the error `failed to run custom build command for openssl-sys v0.9.60` while trying to build my rust program. Here are the `main.rs` and the `Cargo.toml` files. main.rs ```rust extern crate reqwest; fn main() { let mut resp = reqwest::get("http://www.governo.mg.gov.br/Institucional/Equipe").unwrap(); ...
2021/01/03
[ "https://Stackoverflow.com/questions/65553557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9381966/" ]
I have no experience with installing this myself but may be able to give some pointers. First of all about your effort to install OpenSSL. After cloning the repository, you do not select any particular branch before configuring and making. This means that you are building the `master` branch, which is an evolving vers...
I used the following commands on Ubuntu on Windows: ``` sudo apt install libudev-dev sudo apt install libssl-dev ```
29,552,699
I have a directory of files who's main purpose is to store php variables for inclusion into other files in the site. Each file contains the same set of variables, but with different values. for example: event1.php ``` <?php $eventActive = 'true'; $eventName = My First Event; $eventDate = 01/15; ?> ``` even...
2015/04/10
[ "https://Stackoverflow.com/questions/29552699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1675078/" ]
Take a look at the API for what you're doing. <http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#hasNextInt()> Specifically, Scanner.hasNextInt(). "Returns true if the next token in this scanner's input can be interpreted as an int value in the default radix using the nextInt() method. The scanner doe...
A easy way to do this is read all the data from file in a way that you prefer (line by line for example) and if you need to take tokens, you can use split function (String.split see Java doc) or StringTokenizer for each line of String that you are reading using a loop, in order to create tokens with a specific delimite...
6,127,670
Alright, so, I haven't programmed anything useful in ages - last time I did was a year ago and as you can imagine my knowledge of programming is seriously rusty. (last thing I 'programmed' was a ren'py game over the weekend. One can imagine the limited uses of this. The most advanced C program I wrote was a tic-tac-toe...
2011/05/25
[ "https://Stackoverflow.com/questions/6127670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769944/" ]
Export the two files to .csv format and write a script to process the two files. For example, in PHP, you have built in csv read/write capabilities.
If you absolutely have to do this on xls/xlsx file from a process, you probably need a copy of Excel controlled by COM automation. You can do this in BV/VBA/C#/C++ whatever, some easier than others. Google for 'Excel automation'. Rgds, Martin
8,626,139
Hai I would like to use Birt with Struts 2. But I am getting the following error. > > HTTP Status 404 - There is no Action mapped for namespace / and action name frameset. > > > What could be the cause for this? Where this frameset comes from? `<birt:viewer id="birt_id" format="pdf" reportDesign="new_report.rp...
2011/12/24
[ "https://Stackoverflow.com/questions/8626139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1032477/" ]
The [add()](http://es.php.net/manual/en/datetime.add.php) method requires PHP/5.3.0 or greater. Chances are that your host is using an older version. Alternative code for PHP/5.2: ``` $tempDate->modify('+1 month'); ```
When I upgraded to PHP 5.3, I had notices all over the place related to the use of the `date()` function because I hadn't set a default timezone, try setting one. <http://php.net/manual/en/function.date-default-timezone-set.php> It might not be related, but it's worth trying. Example: ``` date_default_timezone_set('...
24,383,162
How to write a breeze query with 2 'where' conditions? the following doesn't work: ``` var query = breeze.EntityQuery.from("Boilers") .where('boilerMakeID', '==', $rootScope.boilerMakeID) .and('actueel', '==', true); ```
2014/06/24
[ "https://Stackoverflow.com/questions/24383162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1913629/" ]
Use Predicates... <http://www.breezejs.com/sites/all/apidocs/classes/Predicate.html> ``` var pred1 = Predicate.create("boilerMakeID", "==", $rootScope.boilerMakeID); var pred2 = Predicate.create("actueel", "==", true); var newPred = pred1.and(pred2); var query = breeze.EntityQuery.from("Boilers").where(newPred) ```
Another way to use predicates... ``` var p1=new breeze.Predicate("boilerMakeId","==",$rootScope.boilerMakeID); var p2=new breeze.Predicate("actueel","==",true); var predicate=p1.and(p2); var query=breeze.EntityQuery.from("Boilers").where(predicate); ```
122,033
We have very quickly out-grown our Small Business Server 2008 current hardware and have decided to purchase a complete new server. What is the best and easiest way to move the server to new hardware? It is one complete box, we do not have any SAN's or any complicated setup. We do have a couple of SQL databases runn...
2010/03/12
[ "https://serverfault.com/questions/122033", "https://serverfault.com", "https://serverfault.com/users/27916/" ]
Microsoft publishes a guide called "Migrating to Windows Small Business Server 2008 from Windows Small Business Server 2008" which describes the process of setting up an answer file and performing a migrate-install on the new hardware. You can find it here: <http://www.microsoft.com/downloads/details.aspx?FamilyID=31C...
Have you considered moving to virtualization? This would be a great time, because you're changing hardware, but you want to keep the actual installation. Any of the p2v (physical to virtual) converters should be able to handle that.
57,462,562
I am reframing my last question, which is unanswered, and I have rewritten the problem following [Google's BasicLocation](https://github.com/googlesamples/android-play-location/tree/master/BasicLocationSample). My main activity is defined as: ``` public class MainActivity extends AppCompatActivity implements ...
2019/08/12
[ "https://Stackoverflow.com/questions/57462562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2005559/" ]
I found something wrong about your code (I may be wrong): 1. Why fields of `latlang` are `static`? It doesn't looks like they should. 2. At `SunFragment.onCreate()` you are reading `location` if `savedInstanceState != null`. `savedInstanceState` is not null only if activity that holds this fragment was restored from s...
By looking at the code, it seems you do not need a very accurate location, you will be fine with last known location. This value might be null in some cases, like you have already experienced. Simple answer to your question is no, you cannot get not null location before creating `SunFragment`. Following steps is to loa...
193,563
Let me start with an example. Let $$\mathbf{A}=\begin{bmatrix}3&1\\2&3\\1&5\end{bmatrix},$$ and let $Q=\{\mathbf{q}\vert\mathbf{q}\in\Bbb R^3\_+ \land \sum\_i^n q\_i=1\}$ and $\alpha=\bigl(\frac{1}{2},\frac{1}{2},\frac{1}{2}\bigr)$. Abusing notation, let $\mathbf{q}^{\frac{1}{\alpha}}=\bigl(q\_1^{\frac{1}{\alpha\_1}}...
2019/03/19
[ "https://mathematica.stackexchange.com/questions/193563", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/60362/" ]
If I understand your problem correctly, I think you can derive the envelope using calculus. Basically you have a function `n` (your `needs`) of two variables `q1` and `q2` (`q3 == 1 - q1 - q2` since you write that the `q's` sum to one). ``` n[q1_, q2_] := Transpose[A].{q1^2, q2^2, (1 - q1 - q2)^2} ``` First, replica...
This is a full revamp of my previous answer (see the edit history for the old version.) Let ``` mat = {{3, 1}, {2, 3}, {1, 5}}; α = 1/2; ``` The idea is to construct a parametrization of $\mathbf q$ that automatically satisfies the constraints $\mathbf{q}\in\Bbb R^3\_+$ and $\|\mathbf q\|\_1=1$. An immediate choice...
11,797,570
im tying to make these two items inline with each other, each list item has an image and button, the button should be underneath each image: i.e ``` <div id="cocktails"> <ul> <li> <img src ="http://bokertov.typepad.com/.a/6a00d83451bc4a69e2014e8a8f894b970d-800wi" width="100px" height="100px"> ...
2012/08/03
[ "https://Stackoverflow.com/questions/11797570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1551482/" ]
enclose buttons in li tags : ``` <div id="cocktails"> <ul> <li> <img src ="http://bokertov.typepad.com/.a/6a00d83451bc4a69e2014e8a8f894b970d-800wi" width="100px" height="100px"> </li> <li> <button>Select</button> </li> <li> <img src ="http://bokertov.typepad.com/.a/6a00d83451b...
This did the trick for me. ``` #cocktails ul{margin:0;padding:0} #cocktails ul li{list-style-type:none; width:150px; float:left; margin:10px;} #cocktails ul li img{width:150px;height:150px; } #cocktails ul li button{ margin-left:50px; width:50px} ```
3,914,970
Does anyone (please) know how to do this? I thought that there would be an easy way to achieve this but can't find anything about saving the contents of WebBrowser HTML.
2010/10/12
[ "https://Stackoverflow.com/questions/3914970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/471784/" ]
You might try something like this: (Assuming C# 4 and WPF 4) ``` dynamic doc = webBrowser.Document; var htmlText = doc.documentElement.InnerHtml; ``` Works for me...
Yous should use HttpWebRequest and HttpWebResponse objects. Simple sample (found in web, tested, working): ``` HttpWebRequest myWebRequest = (HttpWebRequest)HttpWebRequest.Create(@"http://www.[pagename].com"); myWebRequest.Method = "GET"; HttpWebResponse myWebResponse = (HttpWebResponse)myWebRequest.GetResponse(); S...
23,363,484
I have TextView with spans of type ClickableStringSpan defined as below: ``` public class ClickableStringSpan extends ClickableSpan { private View.OnClickListener mListener; int color; public ClickableStringSpan(View.OnClickListener listener,int color) { mListener = listener; this.color = c...
2014/04/29
[ "https://Stackoverflow.com/questions/23363484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1080355/" ]
You need to set the TextView's/EditText's movement method to LinkMovementMethod to be able to get clicked links. Unfortunately that disables the ability to select text which works only if you set the movement method to ArrowKeyMovementMethod. <http://developer.android.com/reference/android/text/method/LinkMovementMetho...
The following code example should work for you, I have also tested and it gives you click events of `ClickableSpanString` May be you have forgot to add `setMovementMethod` ``` EditText spanEditText = (EditText)rootView.findViewById(R.id.edtEmailId); // this is the text we'll be operating on SpannableSt...
39,391,552
[I am unsure how to implement a sliding imageview like the one in the top of this screenshot.](http://i.stack.imgur.com/b45OG.jpg) I am using Eureka forms and I'm trying to include this sliding imageview as a header. At the moment I am using a custom view and this [Library](https://github.com/zvonicek/ImageSlideshow...
2016/09/08
[ "https://Stackoverflow.com/questions/39391552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6809177/" ]
Try this: ``` SET @partHello = SUBSTRING(@helloworld,CHARINDEX('=',@helloworld,0)+1,CHARINDEX('&',@helloworld,0)-(CHARINDEX('=',@helloworld,0))-1) PRINT @partHello ```
There is the solution : ``` DECLARE @helloworld NVARCHAR(100),@partHello NVARCHAR(10) SET @helloworld='HelloWorld=320&HelloSQL=20' SET @partHello = SUBSTRING(@helloworld,CHARINDEX('=',@helloworld,0)+1,CHARINDEX('&',@helloworld,0) -(CHARINDEX('=',@helloworld,0)+1)) PRINT @partHello ```
25,829
Recently there was a question that incidentally included an ungrammatical example: “¿[Puedo tener un vaso de agua](https://spanish.stackexchange.com/questions/25806/how-do-you-use-se-puede)?”, obviously a literal translation from English “¿May I have a glass of water?”. This wasn't the subject of the question but I thi...
2018/04/13
[ "https://spanish.stackexchange.com/questions/25829", "https://spanish.stackexchange.com", "https://spanish.stackexchange.com/users/14627/" ]
I think the crux of the matter is to learn which verbs are used to talk about eating and drinking. In English, when we eat or drink something, we use "to have." Some examples: > > Could we have chicken soup for lunch? > > > I'd like to have lunch before I hit the road. > > > In France people usually have a glass...
* ¿Puedo tomar un vaso de agua? * ¿Puedo tomar agua? * ¿Puedo tomar algo de agua? `¿Puedo tener un vaso de agua?` sounds like you are asking for confirmation whether you are capable or not of doing so. This does not mean you're thirsty and want some water. This may be correct in formal Spanish: ¿Puedo tomar un vaso ...
3,429,791
Question. Given a positive semi-definite matrix $B$ does there exist a non-zero vector $z$ with all components non-negative such that all components of $Bz$ are non-negative? Here are some details (which you probably do not need, if you understand what is asked above). I posted an answer to the following question ...
2019/11/10
[ "https://math.stackexchange.com/questions/3429791", "https://math.stackexchange.com", "https://math.stackexchange.com/users/188367/" ]
When talking about a real function $f(x) = y$ all extremes of the function are either critical points, boundary points or points which diverge to infinity, so all you need to do is to look at the value of the function at these points to determine the maximum and the minimum of the function. Here you need to consider $$...
To find out if a critical point is an extreme point, check the sign of the first derivative near that point -- that is, find out the value of the first derivative at points close to the point in question on either side. What do you check for -- a change of sign, either from $+$ to $-$ or vice versa. This is necessary ...
9,653,621
in a flash application i have to build i would like to find out what the target of the context menu is, which gets displayed when i ctrl-click. the reason for that: i created a custom context menu, which only displays over a certain area of the Sprite it belongs to. so there seems to be something "blocking the way". a...
2012/03/11
[ "https://Stackoverflow.com/questions/9653621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1039806/" ]
No, it is not possible. You can not make call from one simulator to another. Hope this helps.
Unfortunately it's impossible. You have to use a real devices if you want to test some stuff.
29,333
In the sentence, > > I asked her if she was going shopping and could get me some toothpaste > > > Is *shopping* a noun,verb or a gerund? Can we put two verbs together like this: “I am going swimming this, Friday.”
2014/07/16
[ "https://ell.stackexchange.com/questions/29333", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/8787/" ]
In this particular case, "to go shopping" is part of a broader pattern of "to go X-ing". Other examples include "I'm going bowling", "I'm going fishing", "I'm going running", etc. I would classify *shopping* in this case as a gerund. To answer your second question, most verbs that can be used in this pattern are leisu...
Some grammar books don't use the specialised term 'gerund'. Michael Swan, in 'Practical English Usage' (3rd ed, 2005, section 293 and following), calls it the '-ing form'. He writes: > > We can use *-ing* forms (e.g. *smoking*, *walking*) not only as verbs, > but also like adjectives or nouns. Compare: > > > *You...
7,556,060
> > **Possible Duplicate:** > > [string split in java](https://stackoverflow.com/questions/3481828/string-split-in-java) > > > I have this `Key - Value` , and I want to separate them from each other and get return like below: ``` String a = "Key" String b = "Value" ``` so whats the easiest way to do it ?
2011/09/26
[ "https://Stackoverflow.com/questions/7556060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/879131/" ]
``` String[] tok = "Key - Value".split(" - ", 2); // TODO: check that tok.length==2 (if it isn't, the input string was malformed) String a = tok[0]; String b = tok[1]; ``` The `" - "` is a regular expression; it can be tweaked if you need to be more flexible about what constitutes a valid separator (e.g. to make the ...
``` String[] parts = str.split("\\s*-\\s*"); String a = parts[0]; String b = parts[1]; ```
2,558
How can you automatically mute the audio in Windows every time you shut down?
2009/07/15
[ "https://superuser.com/questions/2558", "https://superuser.com", "https://superuser.com/users/1480/" ]
[AutoMute](http://www.karpolan.com/software/auto-mute/) - a little portable program designed specifically for this. Automatically mutes on logoff, shutdown, so the next start up is quiet. Also enables a keyboard shortcut for quick quieting down. ![alt text](https://i.stack.imgur.com/MhGkV.jpg)
This has been answered, and I'm sure the solution works. Still, I'm posting because this possible solution which does not require any third party application. It is a bit drastic in that it shuts down the audio subsystem (driver) completely, not just muting the mixer. Run a command prompt as administrator, and type th...
41,092,129
My app crashes when I invoke alert dialogue within a list item. My app lists cars, every item has 2 buttons, each button calls alertdialog for yes/no answer. the app crashes with "You need to use a Theme.AppCompat theme (or descendant) with this activity." everytime I press the button. App code is as follows: AndroidM...
2016/12/11
[ "https://Stackoverflow.com/questions/41092129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3091252/" ]
``` fields: () => ({ field: {/*etc.*/} }) ``` is a function that implicitly returns an object (literal). Without using `()` JavaScript interpreter interprets the `{}` as a wrapper for the function body and not as an object. Without using parens: `()`, the `field: ...` statement is treated as a `label` statement an...
It's for clarity's sake for the compiler as well as for the reader. The `field:` syntax in your example appears to be an unambiguous giveaway that this is an object literal, but take this code for instance: ```js let f = () => { field: 'value' } console.log(f()) //=> undefined ``` You would expect this to log a...
44,305,232
This is my site **<https://www.reportsbuyer.com/Home>** I want to remove Home in that url using htaccess. I given like this `RewriteRule ^(Home(/index)?|index(\.php)?)/?$ / [L,R=301]` but it will return <https://www.reportsbuyer.com/?/Home> like this. Please give me a solution. Thanks
2017/06/01
[ "https://Stackoverflow.com/questions/44305232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6333745/" ]
Here's the answer to new update: In API 33 we need runtime permission for push notification: Full documentation is available [here](https://developer.android.com/about/versions/13/changes/notification-permission) but you can simply use like below : in app level: ``` <uses-permission android:name="android.permission.P...
Try this: In your Activity class, add the below code: ``` private static final int NOTIFICATION_PERMISSION_CODE = 123; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.your_activity); requestNotificationPermission(); // Some ...
1,268,665
People arrive to the ER of a hospital following a poisson process with $\lambda=2.1$ patients/hour. One of each 28 who arrives under this condition, dies. Calculate the probability of: (a) At least one of the patients that arrive today, dies. (b) The maximum of patients that die today, is 4. If I let $N(t)$ be the...
2015/05/05
[ "https://math.stackexchange.com/questions/1268665", "https://math.stackexchange.com", "https://math.stackexchange.com/users/237971/" ]
How does $\{a\}$ differ from $\{\{a\}\}$? Well, Omnomnomnom and vadim123 have pointed out the key differences, but perhaps a small elaboration will help. Is $a\in\{a\}$? Yes. Is $a\in\{\{a\}\}$? Well, $a\neq\{a\}$ so the answer is a resounding no. Ah, but do you know what it means for a set to be a subset of another ...
The set $\{\{a\}\}$ is the set whose only object is the set $\{a\}$. $\{a\}$, in turn, is a set whose only object is $a$. It might help to consider the set $$ \{a,\{a\},\{b\}\} $$ whose objects are $a$, the set $\{a\}$, and the set $\{b\}$. Note that this set is quite different from $\{a,b\}$.
597,426
Treating light as a wave, we define its frequency. We see that light with different frequency have different colour. But, why? In wave, what property or physical meaning does frequency provide?
2020/12/01
[ "https://physics.stackexchange.com/questions/597426", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/271983/" ]
Let us take the classical electromagnetic picture in which our 3d space is permeated by an electromagnetic field. This basically means that at any point in space we may define a field strength and direction $\mathbf{E}$ of the electric field, and also an associated magnetic field strength and direction $\mathbf{B}$. Le...
> > What is the physical meaning of frequency in wave concept? > > > A wave doesn't necessarily have *a* frequency though periodic waves will have a [fundamental frequency](https://en.wikipedia.org/wiki/Fundamental_frequency). But not all waves are periodic. [For example](https://en.wikipedia.org/wiki/Wave_packet#...
16,979,793
I have a ratchet chat server file ``` use Ratchet\Server\IoServer; use Ratchet\WebSocket\WsServer; use MyAppChat\Chat; require dirname(__DIR__) . '/vendor/autoload.php'; $server = IoServer::factory( new WsServer( new Chat() ) , 26666 ); $server->run(); ``` I using Websocket to connect with `ws` and...
2013/06/07
[ "https://Stackoverflow.com/questions/16979793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1451383/" ]
A few days ago I was looking for the answer of this question and I found this in the Github Ratchet issues: <https://github.com/ratchetphp/Ratchet/issues/489> The last answer, answered by [heidji](https://github.com/heidji), says this: > > I only added this comment for newbies like me who need a quick instruction ho...
I was trying to do this for a subdomain. Ex: Redirect realtime.domain.org to localhost:8080 from apache. Here's how it worked. You can create a virtual host and proxy pass that. ``` <VirtualHost *:80> ServerName realtime.domain.org RewriteEngine On RewriteCond %{HTTP:Connection} Upgrade [NC] RewriteC...
10,867,390
I'm doing a fairly complex NHibernate transaction in a financial system, creating a payment, recording the ledger entries, checking to see if the payment is the total amount of an invoice, if so marking the invoice as paid in full, etc... lots of fun stuff. Naturally it has to happen inside a single transaction. When ...
2012/06/03
[ "https://Stackoverflow.com/questions/10867390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/610217/" ]
In my case it was a missing Identity Specification on the SQL-Server. Simple object: ``` public class Employee { public virtual int ID { get; set; } } ``` Mapping: ``` public class EmployeeMap : ClassMapping<Employee> { public EmployeeMap() { Id(x => x.ID, map => { map.Generator(Generators.Iden...
In my case, the exception was accurately identifying the property that was the cause of the error. I had a many-to-one property that was lacking a `cascade` definition. `"save-update"` prevents the error: ``` <many-to-one name="FocusType" cascade="save-update" class="MyInfrastructure.FocusType, MyInfrastructure"> ...
42,993,456
How can I sum the below: ``` > result.vol3 [,1] [1,] 272225 [2,] 523750 [3,] 20211 [4,] 316165 [5,] 9941469 [6,] 193755 [7,] 40663 [8,] 236746 [9,] 25902 [10,] 79943 [11,] 585326 [12,] 129376 ... till [100,] ``` Its a matrix, but within the matrix its a data.fram...
2017/03/24
[ "https://Stackoverflow.com/questions/42993456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7609563/" ]
For me, the issue happens, when I use UPPERCASE UUID, instead of lowercase one: ``` // does not work: $ rvictl -s F320D3ED185C4CD28FC96E48119D6E39 // works: $ rvictl -s f320d3ed185c4cd28fc96e48119d6e39 ```
here is what worked for me: Make sure that all letters are lower case, took me a min to figure this out. ``` za:news za$ rvictl -s 8adca3ef84c9d647d32644a30cc448185ae39108 Starting device 8adca3ef84c9n647d32644a30cc448185de39108 [SUCCEEDED] with interface rvi0 ``` The new interface is now added, this one rvi0: ...
30,724,566
I am new to uiautomator.In a screen i want to select an element with its resource id.But there is so many elements have the same resource id(for example in Instagram app profile all videos and images having the same resource id ).Is there any way so that i can get a list of all these elements with same resource id ?Onl...
2015/06/09
[ "https://Stackoverflow.com/questions/30724566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4277129/" ]
I got its solution.I just edit my.csproj file by hand and remove the 'CodesignEntitlements' key. I found this solution from [here](http://forums.xamarin.com/discussion/39534/cant-build-ios-in-xamarin-studio-5-7-1-through-5-9) and thank you Gerald Versluis for helping me through facing this problem.
The details from Gerald Versluis were helpful for me. The got me 90% of the way through the task. I was getting the same build error on Visual Studio 2015 with Mac Mini build host. The solution for me was to go back to Certificates, Identifiers & Profiles in <https://developer.apple.com/account/ios/profile/create> and ...
290,780
I ended up in situation with a TCP port in listen mode with no process assigned to it. Is there a way to close this port without restarting server? Checking port status: ``` me> netstat -tan | grep 8888 tcp 0 0 :::8888 :::* LISTEN ``` Looking for process responsible: ...
2011/07/15
[ "https://serverfault.com/questions/290780", "https://serverfault.com", "https://serverfault.com/users/87790/" ]
Try `netstat -ltpn | grep 8888`
You are describing an impossible scenario. I believe what the previous posters are missing is the fact that you are trying to map a port to a process which you do not own. Therefore your `lsof` returns nothing since those tools do not have permission view the `/proc` entries that would facilitate that port -> PID mapp...
25,285,717
Refer to <https://stackoverflow.com/a/387733/418439>, ``` // Define a class like this function Person(name, gender){ // Add object properties like this this.name = name; this.gender = gender; } // Add methods like this. All Person objects will be able to invoke this Person.prototype.speak = function(){ ...
2014/08/13
[ "https://Stackoverflow.com/questions/25285717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/418439/" ]
Check this ref:- [here](https://stackoverflow.com/questions/881515/javascript-namespace-declaration) ``` var yourNamespace = { foo: function() { }, bar: function() { } }; ... yourNamespace.foo(); ```
I once made an example file (for my own use), so I'll share that here, maybe you will find it useful (warning: it contains more than just namespaces): ``` //http://www.crockford.com/javascript/private.html //http://www.dustindiaz.com/namespace-your-javascript/ //http://appendto.com/2010/10/how-good-c-habits-can-encour...
19,746,563
At first, I parsed an array `JSON` file with a loop using [jshon](http://kmkeen.com/jshon/), but it takes too long. To speed things up, I thought I could return every value of `id` from every index, repeat with `word` another type, put these into variables, and finally join them together before echo-ing. I've done som...
2013/11/02
[ "https://Stackoverflow.com/questions/19746563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/908703/" ]
you can use the [json](/questions/tagged/json "show questions tagged 'json'") parser `jq`: ``` jq '.[] | "\(.id) \(.word)"' jsonfile ``` It yields: ``` "1 wordA" "2 wordB" "3 wordC" ``` If you want to get rid of double quotes, pipe the output to [sed](/questions/tagged/sed "show questions tagged 'sed'"): ``` jq ...
The paste solution you're thinking of is this: ``` paste <(jshon -a -e id -u < foo.json) <(jshon -a -e word -u < foo.json) ``` Of course, you're processing the file twice. You could also use a language with a JSON library, for example ruby: ``` ruby -rjson -le ' JSON.parse(File.read(ARGV.shift)).each {|h| print h...
45,664,251
I have seen a post similar to this but one answer used ajax and the other form/post. I can't figure why this won't work. Grateful for any explanation - Cheers. ``` <script > <select name="region" id="region" tags="region"> <?php echo $regionList; ?> </select> function getQuote(){ e = document.getElementById("reg...
2017/08/13
[ "https://Stackoverflow.com/questions/45664251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8458905/" ]
Try this: ``` class TextEdit : public QTextEdit{ public: TextEdit(QWidget *parent = 0): QTextEdit(parent) {} protected: void insertFromMimeData(const QMimeData *source){ if(source->hasText()){ setHtml(source->text()); } else{ QTextEdit::insertFromMime...
You cannot paste html code directly with indented spaces. Try to copy it on MS word first and then from there, paste it anywhere else.
875
I’ve heard this phrase used a lot by [Evildea](https://www.youtube.com/user/Evildela), and also in writing in various places (Reddit, Telegram, etc.). If I’m assuming correctly, this is a pretty straightforward word-for-word translation of the English “what the f?ck” (even though *fek* is not the same word). However, I...
2016/09/19
[ "https://esperanto.stackexchange.com/questions/875", "https://esperanto.stackexchange.com", "https://esperanto.stackexchange.com/users/124/" ]
Kio la fek’! – Ĉu havas ian sencon diskuti pri "gramatika ĝusteco", kiam iu eligas ekkrion de konsterno, surprizo, malŝato, naŭzo aŭ feliĉo aŭ ŝerco aŭ simple volas ŝoki? Ŝajnas esti interesa vortigo por aldoni emocian forton al ia ajn frazo. Se oni volas trovi ion gramatikan, oni povas laŭ sia plaĉo aldoni vortojn el...
I would say it is, and it started popularity as a joke, like many elements of living language usage. I wouldn't worry too much about it. There is a whole subgenre of this kind of jokes that some Esperantists on the internet decided to call "salamandri", in the range of reptile words of krokodili and aligatori, which m...
172,886
The words "nitpicking" and "pedantic" actually define this phenomenon of pointing out others' minor mistakes. I have only this urge to do the nitpicking; I don't necessarily point out that petty mistake but I really have this urge to do the nitpicking and give a damn care to the exasperated sighs. So, is there a good...
2014/05/25
[ "https://english.stackexchange.com/questions/172886", "https://english.stackexchange.com", "https://english.stackexchange.com/users/77085/" ]
*Perfectionist* may be a interesting word, but does not infer the meaning of "correcting *other's* mistakes", but that may be repaired with some context. Example: > > Larry is a perfectionist, he always organises the sheets of paper on my desk. > > >
Consider *exacting* and [exactingness](http://www.merriam-webster.com/thesaurus/exactingness). > > Use the adjective [exacting](http://www.vocabulary.com/dictionary/exacting) to describe something or someone very precise or strict in its requirements. If you teacher has exacting standards about spelling and punctuati...
45,849,831
Well, I've been building a web application for a couple weeks now, and everything good. I got to the part that I had to test in Internet Explorer, and of all of the things that came up (all fixed except for one), Object.entries() is not supported. I've been doing some research and try to come up with a simple alternat...
2017/08/23
[ "https://Stackoverflow.com/questions/45849831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5025361/" ]
The usual first item to research when you want to use a newer API in an older browser is whether there is a simple polyfill. And, sure enough there is a pretty simple polyfill for `Object.entries()` shown on the [MDN doc site](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entri...
Use shim/polyfill like this one: <https://github.com/es-shims/Object.entries>
31,303,281
I want to add some C++ source files to my Android Studio project that are not in the project tree. I'm new to Gradle, and tried to research this as much as possible. From what I read, the following build.gradle file should work, but it doesn't. The bit about `jni.sourceDirs` came from this post: <http://www.shaneenishr...
2015/07/08
[ "https://Stackoverflow.com/questions/31303281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484943/" ]
Have a look at my article about this: <http://www.sureshjoshi.com/mobile/android-ndk-in-android-studio-with-swig/> > > There are two things you need to know here. By default, if you have > external libs that you want loaded into the Android application, they > are looked for in the (module)/src/main/jniLibs. You ca...
Here, you get the idea: ``` android.ndk { moduleName = "mydemo" //Specify a library relative to this project path CFlags.add('-I' + String.valueOf(project.buildDir) + '/../my/inc/path') //or CPP cppFlags.add('-I' + String.valueOf(project.buildDir) + '/../my/inc/path') //Linker works the same...
550,379
A man is in a room, with $n$ passages leading out. For passage $i$, $i = 1,...,n$, there is probability $p\_i$ of escaping, $q\_i$ of being killed and $r\_i$ of returning to the room, where $p\_i + q\_i + r\_i = 1$. In which order should the man try the passages so as to maximise his chances of eventual escape? I am t...
2013/11/03
[ "https://math.stackexchange.com/questions/550379", "https://math.stackexchange.com", "https://math.stackexchange.com/users/103584/" ]
If you only have two passages, your chance of escape is $p\_a+r\_ap\_b$ or $p\_b+r\_bp\_a$. Use $r\_a=1-p\_a-q\_a$, this is $p\_a+p\_b-q\_ap\_b-p\_ap\_b$ or $p\_a+p\_b-p\_ap\_b-q\_bp\_a$. So choose passage $A$ if $q\_ap\_b<p\_aq\_b$, or $p\_a/q\_a>p\_b/q\_b$. This means that you should choose in decreasing ord...
Make best use of your resources. Or, in other words minimize cost. You only fail to escape if you die, but you have greater chance of dying if you fail to escape: because you must risk your life again. Try that passage which has greatest positive difference between increase in probability of escape if going by anothe...
59,125,299
I have a string: ``` Your dog is running up the tree. ``` I want to be able to split it on every kth space but have overlap. For example on every other space: ``` Your dog is running up the tree. out = ['Your dog', 'dog is', 'is running', 'running up', 'up the', 'the tree'] ``` On every second space: ``` Your do...
2019/12/01
[ "https://Stackoverflow.com/questions/59125299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7572374/" ]
I suggest splitting at every whitespace first and then joining the desired amount of words back together while iterating over the list ```py s = 'Your dog is running up the tree.' lst = s.split() def k_with_overlap(lst, k): return [' '.join(lst[i:i+k]) for i in range(len(lst) - k + 1)] k_with_overlap(lst, 2) ['...
I tried the following, the answer seem to be what you might be expecting. ``` def split(sentence, space_num): sent_array = sentence.split(' ') length = len(sent_array) output = [] for i in range(length+1-space_num): list_comp = sent_array[i:i+space_num] output.append(' '.join(list_comp)...
43,375,664
I have project that reads 100 text file with 5000 words in it. I insert the words into a list. I have a second list that contains english stop words. I compare the two lists and delete the stop words from first list. It takes 1 hour to run the application. I want to be parallelize it. How can I do that? Heres my co...
2017/04/12
[ "https://Stackoverflow.com/questions/43375664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3903589/" ]
I fixed many things up with your code. I don't think you need multi-threading: ``` private void RemoveStopWords() { HashSet<string> stopWords = new HashSet<string>(); using (var stopWordReader = new StreamReader("stopword.txt")) { string line2; while ((line2 = s...
One issue I see here that can help improve performance is `listt1.ConvertAll()` will run in O(n) on the list. You are already looping to add the items to the list, why not convert them to lower case there. Also why not store the words in a hash set, so you can do look up and insertion in O(1). You could store the list ...
9,842,137
I've a page like this: ``` <html> <head> <style type="text/css"> #mainDiv{ height: 100%; } #myDiv{ overflow: auto; width: 400px; } </style> </head> <body> <div id="mainDiv"> <div id="myDiv">content</div> </div> </body> </html> ``` I wish `mainDiv` was entirely contained in the screen (without sc...
2012/03/23
[ "https://Stackoverflow.com/questions/9842137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/688916/" ]
The "smaller half" of `int x` is `x/2`. The "bigger half" is `x/2 + x%2` or `x - x/2`. Note that "smaller" and "bigger" refer to the absolute value, so in the case of negative `x`, `bigger < smaller`. Of course, if `x` is always odd and positive, then `x%2` will be `1` and the bigger half can also be computed as `x/2...
This would be my recommended way: ``` int low = floor(x / 2.0f); int high = ceil(x / 2.0f); ``` I find it to be more concise than the `x/2 + x%2` version. This version also benefits from the fact that the output will be correct if you happen to run it using an even number. EDIT: People seemed to complain about me ...
31,646
the code block I copy outside emacs, which is not auto-indent when yanking in org type `org-return-indent` -> yank code block -> indent manually: ``` *** headline | v *** headline { code block } v *** headline { code block } ``` expecting the yank and indent in a one step
2017/03/23
[ "https://emacs.stackexchange.com/questions/31646", "https://emacs.stackexchange.com", "https://emacs.stackexchange.com/users/14750/" ]
Here is a elisp function that should do what you want ``` (defun yank-with-indent () (interactive) (let ((indent (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) (message indent) (yank) (narrow-to-region (mark t) (point)) (pop-to-mark-command) (replace-s...
Here is a different approach, maybe someone will find this useful. This is a minor mode that patches `get-text-property` to fake the property `'yank-handler`, which indicates which function to use for inserting. Then I use `insert-rectangle` for that. That way, this also works with `helm-ring`. ``` (defvar my/is-recta...
123,195
You are in a toilet and someone knocks on the door. What do you say to him so that he won't enter? Is there a formal and an informal phrase?
2017/03/21
[ "https://ell.stackexchange.com/questions/123195", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/51453/" ]
You can say almost anything you like, but obvious choices are things like "Occupied!" (to describe the state of the bathroom stall, which is occupied by you) or "Don't come in!" (the basic imperative). Or you can simply make some obvious noise to signal your presence, like grunting.
I personally would say, "I won't be long." In the event that I had severe bowel problems I might say, "I'm sorry, I could be some time." The advantage of this is that it gives the person knocking an indication of how long they will have to wait - they may need the facility urgently!
62,732,038
I am reading Web Scraping with Python 2nd Ed, and wanted to use Scrapy module to crawl information from webpage. I got following information from documentation: <https://docs.scrapy.org/en/latest/topics/request-response.html> > > callback (callable) – the function that will be called with the > response of this requ...
2020/07/04
[ "https://Stackoverflow.com/questions/62732038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3849539/" ]
Your solution is using localstorage: ``` var sec = 0; tmpSec = localStorage.getItem('secs') if (tmpSec != null) { sec = parseInt(tmpSec,10); } function pad ( val ) { return val > 9 ? val : "0" + val; } setInterval( function(){ ++sec localStorage.setItem('secs...
``` var sec = 0; ``` that is going to reset your timer each time it is run. But instead code it this way: ``` sessionStorage.sec = "0"; // only execute this when you want to reset your counter. setInterval( function(){ var sec = parseInt(sessionStorage.sec); sec++; sessionStorage.sec = sec.toString(); doc...
58,940
I'm using SQL Server 2005, and I would like to know how to access different result sets from within transact-sql. The following stored procedure returns two result sets, how do I access them from, for example, another stored procedure? ``` CREATE PROCEDURE getOrder (@orderId as numeric) AS BEGIN select order_ad...
2008/09/12
[ "https://Stackoverflow.com/questions/58940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1836/" ]
The short answer is: you can't do it. From T-SQL there is no way to access multiple results of a nested stored procedure call, without changing the stored procedure as others have suggested. To be complete, if the procedure were returning a single result, you could insert it into a temp table or table variable with t...
Note that there's an extra, undocumented limitation to the INSERT INTO ... EXEC statement: it cannot be nested. That is, the stored proc that the EXEC calls (or any that it calls in turn) cannot itself do an INSERT INTO ... EXEC. It appears that there's a single scratchpad per process that accumulates the result, and i...
4,174,780
Im trying to start to use Unity but i got stock in a point. I have a Context class and a Repository class being resolved by the container. My Repository class take a Context ctor parameter as a Dependency. My Config file: container: ``` <register type="IGeneralContext" mapTo="Data.EF.EFContext, Data.EF"> <lif...
2010/11/13
[ "https://Stackoverflow.com/questions/4174780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/506967/" ]
After analysing better James suggestion, I found a good alternative. There is a new way to delegate the instantiations to a factory: ``` container.RegisterType<IMyInterface, MyConcrete>(new InjectionFactory(c => MyFactoryClass.GetInstance())); ``` And also it is possible to extend the configuration file to ...
You might want to take a step back and look at your design. I found out that most of the time I thought I needed some complex DI configuration, the problem was actually in my design. Here are a few options you could consider: 1) Use a factory for creating repositories and supply the context to that factory: ``` var r...
946
Near the end of The Artist, George Valentin is looking at his own reflection superimposed on a tuxedo in a shop window (the scene used in the trailer) when a cop comes strolling around the corner. George notices him and his smile fades. The cop approaches George with a seemingly friendly manner and speaks to him but th...
2012/01/18
[ "https://movies.stackexchange.com/questions/946", "https://movies.stackexchange.com", "https://movies.stackexchange.com/users/314/" ]
Artist in the first layer, gives a very strong story about a period of time in film history that some main actors of silent era fall from their popularity, the other good example of this kind of caters is Sunset Blvd. In this scene Valentin sees himself in the reflection of the mens furnishing shop, first to remember...
I would offer this: What nationality were cops portrayed as back then? The answer: IRISH. I would bet that both the cop and all the other "mouths talking" had accents, thus amplifying George's own predicament.
33,192,732
I am able to make queries to my `images` table and correctly pull my records, but I'm looking to modify my query to include the `body` field from my foreign table that is connected to my primary table via the `description_id`. I have created the relationship within my database, but wasn't sure if changes were needed to...
2015/10/17
[ "https://Stackoverflow.com/questions/33192732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1061892/" ]
``` public static void swapPairs(int[] arr){ int length = arr.length%2 == 0? arr.length : arr.length-1; for(int i=0; i<length; i=i+2) { int temp = arr[i]; arr[i] = arr[i+1]; arr[i+1] = temp; } // print the array for(int i=0;i<arr.length;i++){ System.out.print(arr...
``` final int[] number = new int[] { 1, 2, 3, 4, 5, 6, 7 }; int temp; for (int i = 0; i < number.length; i = i + 2) { if (i > number.length - 2) { break; } temp = number[i]; number[i] = number[i + 1]; number[i + 1] = temp; } for (int j = 0; j < number....
44,770,882
I am trying to install create a new app in Ruby on Rails and I cannot get passed this error: ``` $ gem install pg ``` > > ERROR: While executing gem ... (Errno::EACCES) > Permission denied @ rb\_sysopen - /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/pg-0.21.0/.gemtest > > >
2017/06/27
[ "https://Stackoverflow.com/questions/44770882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7448253/" ]
Its a permissions issue. You could fix it with this: ``` sudo chown -R $(whoami) /Library/Ruby/Gems/* ``` or possibly in your case ``` sudo chown -R $(whoami) /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/* ``` **What does this do:** This is telling the system to change the files to change the ownershi...
please run: ``` sudo gem install pg ```
9,992,893
I have an Excel file which has a column formatted as date in the format `dd-mm-YYYY`. I need to convert that field to text. If I change the field type excel converts it to a strange value (like `40603`). I tried the text function but it gives me Error 508. Any help?
2012/04/03
[ "https://Stackoverflow.com/questions/9992893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/407468/" ]
You don't need to convert the original entry - you can use TEXT function in the concatenation formula, e.g. with date in A1 use a formula like this `="Today is "&TEXT(A1,"dd-mm-yyyy")` You can change the "dd-mm-yyyy" part as required
If that is one table and have nothing to do with this - the simplest solution can be copy&paste to notepad then copy&paste back to excel :P
109,000
I came across this phrase/these words while reading a novel. What does it mean? Like If I say : > > 1. I cried myself. > 2. I wanted to cry myself. > > > Does it mean crying over oneself? I mean crying over something wrong one has done? Here is the quote where I read it: > > A queer look came over John Arable'...
2016/11/10
[ "https://ell.stackexchange.com/questions/109000", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/43257/" ]
> > I cried myself > > > is equivalent to > > I cried myself **(as well).** > > > Where "myself" indicates that some other person (--self) probably cried initially. Another possible usage is to mean that person X responded by doing Y, but the speaker cried. That would typically be written better as > > *...
In the context you are using it, it basically means "as well", so in your examples: > > 1. I cried **as well**. > 2. I wanted to cry **as well**. > > > in other words someone else is already crying. The other context as already mentioned is something additional like: > > I cried myself **to sleep**. > > > ...
58,470,268
I'm finishing an app that needs user data entry fields. I modeled it with a small number of data elements to streamline the development. Today I attempted to add additional elements and was astounded to find that I could only add 10 views to a view. So I tried the simplest of designs (below). If I added 11 "things" to ...
2019/10/20
[ "https://Stackoverflow.com/questions/58470268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2698617/" ]
Use `Group {...}` <https://developer.apple.com/documentation/swiftui/group> ``` var body: some View { NavigationView { VStack { //extract the VStack and create a separate struct ListCell(tfString: textField1) Group { VStack { Text("...
`ViewBuilder`s in SwiftUI take between 0 and 10 elements into their initializer anything more than that and you have to start grouping them using `Group`, `VStack`, `HStack`, `List`, `ForEach` and so on. The best approach is to start extracting a few elements that belong together into separate Views, for example: ```...
6,632,971
What is the difference between `std::array` and `std::vector`? When do you use one over other? I have always used and considered `std:vector` as an C++ way of using C arrays, so what is the difference?
2011/07/09
[ "https://Stackoverflow.com/questions/6632971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/452307/" ]
`std::array` is just a class version of the classic C array. That means its size is fixed at compile time and it will be allocated as a single chunk (e.g. taking space on the stack). The advantage it has is slightly better performance because there is no indirection between the object and the arrayed data. `std::vecto...
I use my own personal hand coded `Array<>` template class, which has a simpler API compared with `std::array` or `std::vector`. For example: To use a dynamic Array: ``` Array<> myDynamicArray; // Note array size is not given at compile time myDynamicArray.resize(N); // N is a run time value ... ``` To use a stat...
25,463,279
I'm using the below boilerplate PyQt4 code with the goal of capturing all the HTML generated by javascript on a page: ``` import sys from PyQt4.QtGui import * from PyQt4.QtCore import * from PyQt4.QtWebKit import * class Render(QWebPage): def __init__(self, url): self.app = QApplication(sys.arg...
2014/08/23
[ "https://Stackoverflow.com/questions/25463279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438637/" ]
I have the solution! I added: averagevalue=total/MarkListView.getChildCount(); which is the number of childs. ``` void addNumberFromText() { double total=0; double averagevalue=0; for(int i=0;i<MarkListView.getChildCount();i++) { View wantedView = MarkListView.getChildAt(i); markresult ...
From your code, it seems that you haven't calculated the average like you say. You calculated the total but forgot to calculate the average by dividing the total by your total list items. Hope it helps.
10,022,524
I'm going through a Ruby tutorial and I can't grasp the += statement. Google isn't helping, "Ruby +=" only searches for "Ruby". Help is appreciated. Sample: ``` num = -10 num += -1 if num < 0 puts num #=> -11 ```
2012/04/05
[ "https://Stackoverflow.com/questions/10022524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1123584/" ]
``` num += -1 ``` is an equivalent of ``` num = num + -1 ``` or, for this example ``` num = num - 1 ``` which, in turn, can be written as ``` num -= 1 ```
The segment `a += b` is just the short form for `a = a + b`. So your statement: ``` num += -1 if num < 0 ``` will simply subtract one (by adding `-1` which is ... quaint, that's probably as polite as I can be) from `num` if it is already negative (if `num < 0`)..
43,195,729
HashMap vs ConcurrentHashMap, when the value is AtomicInteger or LongAdder, is there any harm in using HashMap in a multithreaded environment ?
2017/04/03
[ "https://Stackoverflow.com/questions/43195729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7811214/" ]
Yes, there is. An object being of type `AtomicInteger` or `LongAdder` just means that the object itself is safe in a concurrent modification operation (i.e. if two threads try to modify it, they will do so one after the other). However, if the map containing the objects itself is of type 'HashMap', then concurrent mo...
You cannot use a HashMap in a multithreaded environment. The reason is as follows: If multiple threads operate on a simple HashMap they can **damage the internal structure of the HashMap** which is an array of linked lists. The links can go missing or go in circles. The result will be that the HashMap will be totally ...
12,389,948
I'm using Bootstrap 2.1.1 and jQuery 1.8.1 and trying to use Typeahead's functionality. I try to display a **label** and use an **id** like a standard `<select />` Here is my typeahead initialization: ``` $(':input.autocomplete').typeahead({ source: function (query, process) { $('#autocompleteForm .query...
2012/09/12
[ "https://Stackoverflow.com/questions/12389948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305189/" ]
The problem I have seen with some of these solutions, is that the `source` function is called repeatedly on every keyup event of the input box. Meaning, the arrays are being built and looped over on every keyup event. This is not necessary. Using a closure, you can process the data only once, and maintain a reference ...
The selected answer doesn't deal with non unique labels (e.g. a person's name). I'm using the following which keeps the default highlighter formatting: ``` var callback = function(id) { console.log(id); }; $('.typeahead',this.el).typeahead({ source: ...
48,327,221
I want to add my `items` values on the existing `f['ECPM_medio']` column I made some modifications on the `items values` to have `0.8 to 0.9`values of each numbers. the problem is when I try to add these new numbers to the existing column... I paste the same number on all rows! ``` import pandas as pd jf = pd.read_cs...
2018/01/18
[ "https://Stackoverflow.com/questions/48327221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8717507/" ]
You should create a function and then apply it with lambda. Example: ``` def myfunc(item): item = float(item) if item <= 0.5: item = item * 0.8 else: item = item * 0.9 item = float("{0:.2f}".format(item)) return item f['ECPM_medio'] = f['ECPM_medio'].apply(lambda x: myfunc(x)) ``...
You can do this using Pandas vectorized operations, ``` df['ECPM_medio'] = np.where(df['ECPM_medio'] <= 0.5, df['ECPM_medio'] * 0.8, df['ECPM_medio']* 0.9) ```
78,903
Is it possible to iterate over a Map in an aura:iteration. It doesn't give me a compile or runtime error but it doesn't appear to work. My thought is that it works similarly to $.each in jquery. ``` <aura:attribute type="Map" name="myMap" default="{key1: 'item1', key2: 'item2'}" /> <aura:iteration items="{!m...
2015/06/05
[ "https://salesforce.stackexchange.com/questions/78903", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/21077/" ]
I came across this question and was a little discouraged, but looks like things might have changed since some of these answers were provided. I found [this page](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_attr_types_collection.htm) in the Lightning Components documentation. All the ...
Not a straight Yes to the original question. The Maps can not go in directly, but we can use some thing like this. Maps or list, all the collections are same for lightning components as it considers all these variables as json. Try the following: Component: ``` <aura:component > <aura:attribute name="colerc...
65,982,187
When i run this code, it should render ``` Hello World! ``` But it render, ``` Loading... ``` Here is my code: ``` import React, { Component } from 'react'; class GroupsHomePage extends Component { constructor() { super() this.state={ groupInfo:[] } } componentDid...
2021/01/31
[ "https://Stackoverflow.com/questions/65982187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13348041/" ]
So firstly your default groupInfo state should be an empty object in constructor like this groupInfo:{} And to check length your 'if' condition would be this ``` if(Object.keys(this.state.groupInfo).length > 0) ``` This condition is used for JSON object keys different from Array
Try this. `console.log(typeof(this.state.groupInfo))` I think groupInfo is of object type. So in console if you see the output of above line object then change the if condition to ``` if(this.state.groupInfo){ ``` --- Also you should not use ``` if(this.state.groupInfo.length){ ``` if you have groupIn...
44,736,967
I found below function which copy data from csv to Postgres, it also creates table dynamically from csv, I want similar function but it should do for text files. I am not from development background and I have to load a txt file to Postgres table dynamically. is it possible to make below function to work with txt fi...
2017/06/24
[ "https://Stackoverflow.com/questions/44736967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3845299/" ]
You can round the seconds to the nearest multiple of 30, and then add the difference between the rounded and the original value to the date: ``` extension Date { func nearestThirtySeconds() -> Date { let cal = Calendar.current let seconds = cal.component(.second, from: self) // Compute nea...
I used the answer by Martin R to write a more generic version to round by any time period. **Answer is outdated and only works with time, check gist for the latest version.** <https://gist.github.com/casperzandbergenyaacomm/83c6a585073fd7da2e1fbb97c9bcd38a> ``` extension Date { func rounded(on amount: Int, _ co...
1,941,589
I came accross this problem and was confuse why P(E|Fi) = 1/6 when i = 2,3,4,5,6 Shouldn't P(E|Fi) = 1/5 since i = 1 cannot complete a sum of 8 with any given Fi?, Find the probability of rolls an 8 with a fair pair of dice using law of total probability. ``` Fi = {1st fie equals i} , i = 1 , ... , 6 ``` and `P(E|F...
2016/09/26
[ "https://math.stackexchange.com/questions/1941589", "https://math.stackexchange.com", "https://math.stackexchange.com/users/70716/" ]
The meaning of $P(E | F\_i)$ is the probability that $E$ occurs given that $F\_i$ occurs. Now I can see your reasoning as follows: You are saying that $ 1 = P(E | F\_1) + P(E | F\_2) + \ldots + P(E | F\_6)$. You probably think this is because *one of the* $F\_i$ *has to happen*, and therefore if $E$ has happened, then...
Suppose you have already rolled the first die. If it is a $1$, then there is no chance of rolling the second die to get a sum of $8$. Otherwise, there is a $1/6$ chance that when you roll the second die, your sum will be $8$. That is why it is $1/6$ instead of $1/5$.
53,243,766
This is a function I defined in order to find the smallest value in a list using recursion.However,I called the function twice within itself, which I think it's a bit weird. Is there a way around the function `append()`?. We haven't studied it yet so I'm asking whether there could be a simpler way to get the same solu...
2018/11/10
[ "https://Stackoverflow.com/questions/53243766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I guess you could do this to avoid append: ``` def minimum(lst): if len(lst)==1: return lst[0] if lst[0] < lst[1]: return minimum(lst[0:1]+ lst[2:]) else: return minimum(lst[1:]) ``` but i think this one is better with only one call to minimum: ``` def minimum(lst): ...
Use an additional variable? ``` def minimum(lst, current_min=None): if not lst: return current_min if current_min is None: current_min = lst[0] elif lst[0] < current_min: current_min = lst[0] return minimum(lst[1:], current_min) ```
5,157,176
I want to debug a Windows service but it pops an error message saying > > Cannot start service from the command > line or a debugger. A windows service > must be installed using > installutil.exe and then started with > the Server explorer, windows services > Administrative tools or the NET start > command. > ...
2011/03/01
[ "https://Stackoverflow.com/questions/5157176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536426/" ]
To prevent this error occurring and allow the service to run outside of the usual service controller you can check the `Environment.UserInteractive` flag. If it is set you can run the service with output to the console instead of letting it run to the ServiceBase code that returns that error. Add this to the start of ...
There is a nuget package made to solve this problem: `install-package WindowsService.Gui` [![Image of the runner GUI](https://i.stack.imgur.com/KLjYU.png)](https://i.stack.imgur.com/KLjYU.png) **What does the package do?** It helps by creating a Play/Stop/Pause UI when running with a debugger attached, but also allo...
652,375
I would like to convert the ZFS output of "10.9T" to actual bytes, using something in a line or two, rather than run generic math functions, and if conditions for `T`, `G`, `M`, etc.. Is there an efficient way to do this? For now, I have something like this: ``` MINFREE="50G" POOLSIZE=`zpool list $POOLNAME -o size` #...
2021/06/01
[ "https://unix.stackexchange.com/questions/652375", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/111873/" ]
There is no good way to convert `zfs`'s human-readable numbers to actual bytes. The human-readable numbers are rounded off and therefore inexact. If you want exact numbers, use the `-p` option (machine parseable), and the output will be in bytes, which you can parse and format however you wish. ``` $ zfs list tank/va...
`zpool list` can provide the numbers in bytes. e.g. listing three pools (15T, 29T, and 416G) on my main zfs server. First, without `-H` and `-p`: ```none $ zpool list -o name,size,alloc,free,capacity NAME SIZE ALLOC FREE CAP backup 14.5T 6.15T 8.40T 42% export 29T 17.8T 11.2T 61% ganesh 416G...
6,086,912
Is the following singleton implementation data-race free? ``` static std::atomic<Tp *> m_instance; ... static Tp & instance() { if (!m_instance.load(std::memory_order_relaxed)) { std::lock_guard<std::mutex> lock(m_mutex); if (!m_instance.load(std::memory_order_acquire)) { T...
2011/05/22
[ "https://Stackoverflow.com/questions/6086912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19630/" ]
That implementation is **not** race-free. The atomic store of the singleton, while it uses release semantics, will only synchronize with the matching acquire operation—that is, the load operation that is already guarded by the mutex. It's possible that the outer relaxed load would read a non-null pointer before the lo...
See also [call\_once](http://en.cppreference.com/w/cpp/thread/call_once). Where you'd previously use a singleton to do something, but not actually use the returned object for anything, call\_once may be the better solution. For a regular singleton you *could* do call\_once to set a (global?) variable and then return t...
37,797,992
I need to count the characters from a to z in an array. For example I have an array like this: ``` ["max","mona"] ``` The desired result would be something like this: a=2, m=2, n=1, o=1, x=1 It would be great, if anyone could help me :)
2016/06/13
[ "https://Stackoverflow.com/questions/37797992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5464200/" ]
You can use two `forEach` loops and return object ```js var ar = ["max", "mona"], o = {} ar.forEach(function(w) { w.split('').forEach(function(e) { return o[e] = (o[e] || 0) + 1; }); }); console.log(o) ``` Or with ES6 you can use arrow function ```js var ar = ["max","mona"], o = {} ar.forEach(w => ...
The solution using `Array.join`, `Array.sort` and `String.split` functions: ``` var arr = ["max","mona"], counts = {}; arr = arr.join("").split(""); // transforms the initial array into array of single characters arr.sort(); arr.forEach((v) => (counts[v] = (counts[v])? ++counts[v] : 1)); console.log(counts); //...
167,542
$$ \frac{|x|-|y|}{1+|xy|} $$ How can I reduce the amount of code without losing quality? What are your tips? Your comments on the structure, logic, in general, everything. How to make the type of data entered by the user determined automatically? ``` using System; class taskTwo { static void Main() { int x, y...
2017/07/06
[ "https://codereview.stackexchange.com/questions/167542", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/142832/" ]
You really should improve your code formatting. Code which is formatted well (indentation, concise brackets) is easier to read and understand. I'd also suggest you to improve your variable naming a bit. For example `z` isn't too descriptive. Instead I'd name it `numerator` and name `w` `result`. You don't need to decl...
> > How can I reduce the amount of code without losing quality? > > > Well... there is no quality yet ;-) and actually you are going to gain some code if you want to improve it. I won't try to prove whether there are numbers that can break this fraction in any way but for the sake of the review let's assume the d...
10,852
I have been asked to come up with an interface for a website that stores information about certifications and companies who hold those certifications. From the search logs I know users mostly search for a type of certificate but also will search for a particular company to see what certificates they hold. The problem ...
2011/09/05
[ "https://ux.stackexchange.com/questions/10852", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/4701/" ]
I don't think you're missing anything. This sounds like you have two users groups with different objectives and they should be treated as such: IMO you should have two different search forms and two different result pages. Having one form and result page only sound good in theory (less pages, less to learn, one page f...
A follow-on to @Phil's answer is that if you cannot easily distinguish queries for the two types of cases, you might consider generating a separate tab for each type of result and let the user select the one they want. (if you have a good guess as to the type of query, you can pre-select the corresponding tab.) This mi...
46,675,819
I'm trying to use multer to process a profile photp upload on the frontend to the backend but keep getting this error: ``` { [Error: Unexpected field] code: 'LIMIT_UNEXPECTED_FILE', field: 'file', storageErrors: [] } ``` Below is my code: register.ejs: ``` <div class="form-group"> <input class="form-control" t...
2017/10/10
[ "https://Stackoverflow.com/questions/46675819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5091363/" ]
It says on `multer` [docs](https://www.npmjs.com/package/multer) that you should pass `enctype="multipart/form-data"` attribute to your `<form>` element. I'm not really familiar with `ajax`, but I think you may have to set `contentType:` in `ajax.js` to `"multipart/form-data"`. I also had a similar error, but it was c...
I have also face the same issue, instead of using > > var upload = multer({ storage : storage}).single('image'); > > > use the fields() method which allow to handle multiple files at once > > app.use(multer({ storage : storage}).fields([{name:'image',maxCount:1}])); > > > file data store in req.files , then...
12,122,021
I am looking for a Python implementation of an algorithm which performs the following task: **Given two directed graphs, that may contain cycles, and their roots, produce a score to the two graphs' similarity.** (The way that Python's `difflib` can perform for two sequences) Hopefully, such an implementation exists...
2012/08/25
[ "https://Stackoverflow.com/questions/12122021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1614978/" ]
Another method is to use what is called *Eigenvector Similarity*. Basically, you calculate the Laplacian eigenvalues for the adjacency matrices of each of the graphs. For each graph, find the smallest *k* such that the sum of the *k* largest eigenvalues constitutes at least 90% of the sum of all of the eigenvalues. If ...
I think the way you define similarity is not very standard, so it is probably easier to find the implementations for the isomorphism check, graph edit distance and maximum common subgraph and then combine those yourself. One should understand, however, that calculating such a similarity measure might be costly, so if ...
9,591,023
I have two problems. One is that it is only pulling one row and sending it to ms fax when there are a few hundred to be sent. The other is that it doesn't pull any more after that first and it throws an error. I thought I was closing out my connections. I don't understand what the problem is. I have included the code a...
2012/03/06
[ "https://Stackoverflow.com/questions/9591023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1046434/" ]
I think you should refactor a bit. I explained a little in a comment above, but here's how I would change it (I added some comments for you too): ``` public static void Tick(object source, ElapsedEventArgs e) { // Prevent another Tick from happening if this takes longer than 10 minutes (source as Timer).Enable...
You should not be using a timer. A timer fires at regular intervals, and does not care if the previous event has completed or not. Look at using a [Background Worker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) to send your faxes, having it loop over the queue, and then pause ...
3,004,752
$(x^2 + 2 + \frac{1}{x} )^7$ Find the coefficient of $x^8$ Ive tried to combine the $x$ terms and then use the general term of the binomial theorem twice but this does seem to be working. Does anyone have a method of solving this questions and others similar efficiently? Thanks.
2018/11/19
[ "https://math.stackexchange.com/questions/3004752", "https://math.stackexchange.com", "https://math.stackexchange.com/users/594817/" ]
In order to get $x^8$ in the product you have to have either $$x^2 x^2 x^2 x^2 \times 2^3$$ or$$ x^2 x^2 x^2 x^2 x^2 (1/x)(1/x)$$ There are $\binom 7 4 $ of the first type and $ \binom 7 5$ of the second type. Thus the coefficient of $x^8$ is $8(35)+21 = 301$
The answer is 301. Just trust your plan of the twofold use of the binomial formula: First step $$\left((x^2+2)+\frac{1}{x}\right)^7=\sum \_{k=0}^7 \binom{7}{k} \left(x^2+2\right)^k x^{k-7}$$ Second step $$\left(x^2+2\right)^k=\sum \_{m=0}^k 2^{k-m} x^{2 m} \binom{k}{m}$$ Hence you get a double sum in which the po...
105,923
In high-school level books (for example the german standard text: "Dorn-Bader") I have often seen an explanation of the Lorentz force as on the following picture: ![enter image description here](https://i.stack.imgur.com/eHiQk.gif) The textbooks consider the superposition of the circular field of the wire and the hom...
2014/03/31
[ "https://physics.stackexchange.com/questions/105923", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/6581/" ]
While the field is $\vec F = q\vec v \times \vec B$, it is not a terribly intuitive process. The closest one comes to a vector-product in the real world is the Coralis force, where the wind goes clockwise around a low, and anticlockwise around a high. A moving charge sets up a circular magnetic field, which is one di...
The deflection of a current-carrying wire, the deflection of the electron and also the Hall effects are all based on the same principle. One can break down both the Lorentz force and the Hall effects to the movement of an electron in the magnetic field as the easiest process to analyze. It has been pointed out many ti...
56,190,339
This is my code I have successfully sorted and got my final result to be what I wanted. Now I want to also sort so that the object name that contains the key word "newitem" will always get sorted to the bottom. ``` var testgogo = { "newitemwrewt": { "brand": { "gdhshd": true }, ...
2019/05/17
[ "https://Stackoverflow.com/questions/56190339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11165692/" ]
Javascript objects can't be ordered. If you need that data to be in an order you should make it an array.
You could sort the [entries](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) of the object based on whether the key [`includes`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/includes) the string `"newitem"`. Then use [`Object.fromEntr...
17,114,317
I've added a user selected theme option to my app. Each relevant element (mostly UIViews) conditionally change their appearance dependent on the state of an NSUserDefaults BOOL. This worked fine when I was setting the state using a #define followed by Build and Run. But, I need the UI to "refresh" when the user flips ...
2013/06/14
[ "https://Stackoverflow.com/questions/17114317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1168863/" ]
Make the interested views listen to a notification. When data change, send a notification and let all the views update themselves. In general, it's better to have such functionality decentralized.
That depends on how you actually apply the color change. Did you subclass each UIView object that you are using to ensure that it fetches its color from whereever and changes it accoringly before drawing itself? Such as overwriting drawRect like this: ``` - (void) drawRect:... { if (somehowFetchTheUserDefaultsBool...
2,399,112
Consider this Python code for printing a list of comma separated values ``` for element in list: print element + ",", ``` What is the preferred method for printing such that a comma does not appear if `element` is the final element in the list. ex ``` a = [1, 2, 3] for element in a print str(element) +",", ...
2010/03/08
[ "https://Stackoverflow.com/questions/2399112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357024/" ]
It's very easy: ``` print(*a, sep=',') ``` [Print lists in Python (4 Different Ways)](https://www.geeksforgeeks.org/print-lists-in-python-4-different-ways/)
That's what [`join`](http://docs.python.org/library/stdtypes.html#str.join) is for. ``` ','.join([str(elem) for elem in a]) ```
29,406,902
I recently migrated my app to Material Design and I stumbled upon this problem with my Alert Dialogs: ![dialog appears to be having two backgrounds and I don't know how to get rid of the outer background](https://i.stack.imgur.com/G9KqO.png) I'm applying the dialog style like this: `<item name="android:alertDialog...
2015/04/02
[ "https://Stackoverflow.com/questions/29406902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1102276/" ]
The point is here: ``` <style name="Theme.AlertDialog" parent="Base.V14.Theme.AppCompat.Dialog"> ... <item name="colorPrimary">@color/theme_primary</item> <item name="colorPrimaryDark">@color/theme_primary_dark</item> <item name="colorAccent">@color/theme_accent_dark</item> ... <item name="andr...
As [ironman](https://stackoverflow.com/users/6343685/ironman) told me [here](https://stackoverflow.com/questions/40738437/weird-behavior-when-applying-theme-to-dialog-under-api-21), be sure that you import the right class. Right : `import android.support.v7.app.AlertDialog;` Wrong : `import android.app.AlertDialog;`
37,311,443
I'm currently trying to create a responsive menu button for my navigation bar, and it does not seem to be responding to a mouse click. ```js $("span.nav-btn").click(function() $("ul.nav-toggle").slidetoggle(); }) ``` [Fiddle](https://jsfiddle.net/dh86ea79/6/)
2016/05/18
[ "https://Stackoverflow.com/questions/37311443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6353427/" ]
Your line is building a formula but passing a range into it instead of just the address of the range, use `.Address(ReferenceStyle:=xlR1C1`. Once that is there, remove the square parenthesis:- ``` Worksheets(" Branded").Range("A1").Formula = "=COUNTIFS(" & r.Address(ReferenceStyle:=xlR1C1) & ":" & r2.Address(Reference...
I realized that I had made a mistake in the full line. With the above answer I figured out that it needs to be. ``` Worksheets(" Branded").Range("A1").Formula = "=COUNTIFS(" & r.Address(ReferenceStyle:=xlR1C1) & ",RC2, " & r2.Address(ReferenceStyle:=xlR1C1) & ",R2C)" ```
24,389,491
I have a simple pair of client and server programs. Client connects to server and when it does connect, the server replies with a "Hello there" message. How should I modify the program if I want the client and server programs to run on different systems? Here is the code for the client side.. ``` package practice; i...
2014/06/24
[ "https://Stackoverflow.com/questions/24389491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3760100/" ]
just change "127.0.0.1" on the client with the server's IP and make sure the port 4242 is open.
``` Socket incoming = new Socket("127.0.0.1",4242); ``` This is creating a socket listening to the server at the address `127.0.0.1` on port `4242`. If you change the server to another address, for example of a different pc, then change the ip address that your socket is listening to. It is also worth noting...
2,277,175
Since there aren no respositories for value objects. **How can I load all value objects?** Suppose we are modeling a blog application and we have this classes: * Post (Entity) * Comment (Value object) * Tag (Value object) * PostsRespository (Respository) I Know that when I save a new post, its tags are saved with it...
2010/02/16
[ "https://Stackoverflow.com/questions/2277175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/187762/" ]
I am currently working through a similar example. Once you need to uniquely refer to tags they are no long simple value objects and may continue to grow in complexity. I decided to make them their own entities and create a separate repository to retrieve them. In most scenarios they are loaded or saved with the post bu...
Here is my take in how I might solve this type of problem in the way that I'm currently practicing DDD. If you are editing something that requires tags to be added and removed from such as a Post then tags may be entities but perhaps they could be value objects and are loaded and saved along with the post either way. ...
41,384
Let me explain: I'm writing a game where the Earth gets a massive biological attack from an alien race in the close future, and only a small part of the planet's life survived (few dozens of humans and animals). The explanations for those events are discovered by the player during the game, and are: 1. The alien race...
2019/01/17
[ "https://writers.stackexchange.com/questions/41384", "https://writers.stackexchange.com", "https://writers.stackexchange.com/users/36152/" ]
As somebody that likes to play role playing games, I love it when the game gives me the **option** to read up on the lore. Some games do this very well, like the books you can read in the Elder Scrolls games. They're completely optional, so anybody that wants to read them can, but anyone that just wants to play the gam...
Let me point out a different risk of providing a too detailed description of how the aliens learned about it: The risk of unnecessarily contradicting established science, and thus losing exactly those who would otherwise be most likely to enjoy detailed descriptions. In this particular case, it is clear to me (a physi...
29,873,023
I run my code then I put in an integer, press enter, then I get an extra input space. In the extra input space I put in a number then I get the input space I want where it says "Write A Line". It only adds the numbers I put in the first input space and the extra input space. Please help. (P.S Sorry for code's format) ...
2015/04/26
[ "https://Stackoverflow.com/questions/29873023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4833262/" ]
The extra space you're getting is from a logical error in first `if` statement. If `input.hasNextInt()` is true, then it will skip over `else` but call the `Scanner` directly below because it is not grouped with the `else` statement. Also, this only allows for two attempts for `input1` and one for `input2`. Therefore, ...
> > Use single instance for > Scanner and make sure close the scanner input after operation > > > Refer code below > > > ``` public static void main(String eth[]) { System.out.println("Write An Integer"); Scanner input = new Scanner(System.in); if (input.hasNextInt()) { } else System...
38,019,336
Question :- Write a program to take five numbers by user and search a number is found or not. My attempt :- ``` #include<stdio.h> #include<conio.h> void main () { int a=2,b;char directory[5];int i; printf("enter a number you want to find"); scanf("%d",&a); for(i=0;i<5;i++) { scanf("%d",&dir...
2016/06/24
[ "https://Stackoverflow.com/questions/38019336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6510116/" ]
`%d` is expecting an `int` but `char directory[5]` is `char` values. This should be called as ``` int directory[5]; ``` Also you are only looking at the value of `i` which at the end of the for loop previously would be 5 in the array in the line: ``` if(a=directory[i]); ``` You should instead have a for loop say...
And you didnt initialize .It's logic fault ``` int directory[5] ```
3,908
I've been offered one of my dream internships for this next summer. I'll be working as a "Program Manager" for a top notch software company. For some examples of what I mean by PM, take a look at [Joel's article](http://www.joelonsoftware.com/items/2009/03/09.html) as well as [Microsoft's PM internship description](htt...
2011/11/19
[ "https://pm.stackexchange.com/questions/3908", "https://pm.stackexchange.com", "https://pm.stackexchange.com/users/1448/" ]
I would add another item to your "reading list" and that is [Zapp! the Lightning of Empowerment](http://rads.stackoverflow.com/amzn/click/0449002829). In my opinion as, as a Program Manager your most powerful day to day tool will be in the form of written and verbal communication. You will be talking with customers, t...
The PMI's [Practice Standard for Program Management](http://www.pmi.org/PMBOK-Guide-and-Standards/Standards-Library-of-PMI-Global-Standards.aspx) is a wealth of information on the general components of program management and the various moving pieces involved. Like all standards, it is not a methodology, but an inven...
10,117,334
I have problem with activation of graphical layout. I want to see what I have done in XML, but graphical layout doesn't show any thing. Also in res/layout, I right clicked on each XML files then went to "Open with/Legacy android drawable editor". Still nothing! How can I activate it? Thanks ![enter image descriptio...
2012/04/12
[ "https://Stackoverflow.com/questions/10117334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/513413/" ]
CONTEXT: editable HTML of <https://code.google.com/apis/ajax/playground/?type=visualization#line_chart> (using Firefox or Chorme). Instructions for help you in the problem: * suppose you need a box with width=500px and height=400px. * check Javascript at new google.visualization.LineChart(), if the width and height i...
Using : ``` <script src="https://www.google.com/jsapi"></script> <script> google.load("visualization", "1", {packages:["corechart"]}); var data = new google.visualization.DataTable(); //init your data var options = { width: "100%", height: "100%", //other options } var chart = new google.visualization.L...
11,063,054
I have created a wix installer project which is working fine. It installs my application on system easily. whenever if there is any change in any file or service, i uninstall msi from controk panel and installs new msi on system. But whenever i install new msi, application's all setting change after new installation, ...
2012/06/16
[ "https://Stackoverflow.com/questions/11063054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1298386/" ]
You cannot use the same ProductId to do upgrades, you need to change it. The best way is to set ProductId="\*" and this will change it for every build. You will also need to increase the version number and this best done by using the main exe assembly version number. See <http://wix.sourceforge.net/manual-wix3/major_up...
You can use the same `ProductCode` to update an installed MSI. Basically you increment the `ProductVersion`, rebuild the MSI (with new `PackageCode`) and do a minor update with a command line such as: ``` msiexec /i <path to new msi> REINSTALL=ALL REINSTALLMODE=vomus. ``` In my experience this not commonly used bec...
5,142,842
How do I export a graph to an .eps format file? I typically export my graphs to a .pdf file (using the 'pdf' function), and it works quite well. However, now I have to export to .eps files.
2011/02/28
[ "https://Stackoverflow.com/questions/5142842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459179/" ]
The easiest way I've found to create postscripts is the following, using the `setEPS()` command: ``` setEPS() postscript("whatever.eps") plot(rnorm(100), main="Hey Some Data") dev.off() ```
Another way is to use Cairographics-based SVG, PDF and PostScript Graphics Devices. This way you don't need to `setEPS()` ``` cairo_ps("image.eps") plot(1, 10) dev.off() ```
9,460,153
Can someone give me a good reason why ViewState isn't stored on the server by default? Why not send a small session token in place of ViewState, which can then be mapped to whatever ViewState info is needed on the server, to prevent the whole ViewState being posted back and forwards multiple times. Am I missing somet...
2012/02/27
[ "https://Stackoverflow.com/questions/9460153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/692456/" ]
Scalability - imagine how much server resources would be needed if a complex WebForms page was viewed by 1M users. Server would need to hold ViewState for at least the duration of the session timeout. Automatic server side cleanup of viewstate would also be problematic - user may be viewing several pages at once so Vie...
The root cause is using client side view state is that server doesn't know the current state of the page. If a user is anxious, does multiple (partial) postback on the page, without waiting the response, browser will send out multiple partial postback requests, that each request create a new view state on server side,...
7,810,288
I'm running all my apps to make sure it's not just one app, and in every app I have, when I run on the iOS5 simulator or device, the `viewWillAppear` method gets called twice on every view. I have a simple `NSLog(@"1");`, and this appears twice in my console every time. Is this just me, or is something going on? (It on...
2011/10/18
[ "https://Stackoverflow.com/questions/7810288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/458960/" ]
Because you are displaying the view twice. First time by adding the view as a subview of the current view: ``` [self.view addSubview:closeVC.view]; ``` Second time by pushing the view's controller on top of current view's controller: ``` [self presentModalViewController:closeVC animated:NO]; ``` I'm not sure why...
If you want to restore the old (iOS 4) behavior in your view controller you should implement the following method: ``` - (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers { return NO; } ```
5,303,799
I have a table in Oracle that records events for a user. This user may have many events. From these events I am calculating a reputation with a formula. My question is, what is this best approach to do this in calculating and returning the data. Using a view and using SQL, doing it in code by grabbing all the events an...
2011/03/14
[ "https://Stackoverflow.com/questions/5303799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/280602/" ]
I have a tool to "dump" an entire SQL Compact file as SQL script, that you can then run against a SQLite db - <http://exportsqlce.codeplex.com>
1. Export CSV file(s) from SQL CE, import into SQLite, or 2. Use ODBC to connect to both databases and move data from one to the other
4,009,505
I'm trying to get the following code to work, but I can't find good-enough documentation on how C++ handles public vs. private inheritance to allow me to do what I want. If someone could explain why I can't access `Parent::setSize(int)` or `Parent::size` using private inheritance or `Parent::size` using public inherita...
2010/10/24
[ "https://Stackoverflow.com/questions/4009505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267493/" ]
Change Parent to: ``` protected: int size; ``` If you want to access the `size` member from a derived class, but not from outside the class, then you want `protected`. Change Child to: ``` class Child: public Parent ``` When you say `class Child: private Parent`, you are saying it should be a secret that Child i...
When you use private inheritance, all public and protected members of the base class become private in the derived class. In your example, `setSize` becomes private in `Child`, so you can't call it from `main`. Also, `size` is already private in `Parent`. Once declared private, a member always remains private to the b...
3,931,351
I went through this before posting: *[How can I echo HTML in PHP?](https://stackoverflow.com/questions/1100354/easiest-way-to-echo-html-in-php)* And I still couldn't make it work. I'm trying to echo this: ``` <div> <h3><a href="#">First</a></h3> <div>Lorem ipsum dolor sit amet.</div> </div> <div> ``` ...
2010/10/14
[ "https://Stackoverflow.com/questions/3931351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/463065/" ]
Try the *heredoc*-based solution: ``` echo <<<HTML <div> <h3><a href="#">First</a></h3> <div>Lorem ipsum dolor sit amet.</div> </div> <div> HTML; ```
There isn't any need to use echo, sir. Just use the tag <plaintext>: ``` <plaintext> <div> <h3><a href="#">First</a></h3> <div>Lorem ipsum dolor sit amet.</div> </div> ```
328,649
I believe C is a good language to learn the principles behind programming. What do you stand to learn in lower level languages that are "magicked" away from high level ones, such as Ruby?
2016/08/17
[ "https://softwareengineering.stackexchange.com/questions/328649", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/242560/" ]
> > I know C is a good language to learn the principles behind programming. > > > I disagree. C is absent too many features to learn principles behind programming. C's features for creating abstractions are terrible, and abstraction is one of the key principles behind programming. If you want to learn how hardwa...
C and the (Abstract) Machine ============================ Most programming languages are described in terms of abstract machines. Then, [they are implemented using sets of tools like compilers, linkers, assemblers, interpreters, static analyzers, intermediate languages, and hardware](https://softwareengineering.stacke...
1,430,987
I have looked this up on the net but I am asking this to make sure I haven't missed out on something. Is there a built-in function to convert HashSets to Lists in C#? I need to avoid duplicity of elements but I need to return a List.
2009/09/16
[ "https://Stackoverflow.com/questions/1430987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65488/" ]
Two equivalent options: ``` HashSet<string> stringSet = new HashSet<string> { "a", "b", "c" }; // LINQ's ToList extension method List<string> stringList1 = stringSet.ToList(); // Or just a constructor List<string> stringList2 = new List<string>(stringSet); ``` Personally I'd prefer calling `ToList` is it means you d...
There is the Linq extension method `ToList<T>()` which will do that (It is defined on `IEnumerable<T>` which is implemented by `HashSet<T>`). Just make sure you are `using System.Linq;` As you are obviously aware the `HashSet` will ensure you have no duplicates, and this function will allow you to return it as an `IL...
160,196
The mad scientist community is...mad, to put it kiddie-appropriately. Their logic has the tendency to make 0% sense 100% of the time (provided, of course, that they ever bring it up.) So you can imagine a field scientist's confusion when the community tasked him to imagine a hybrid between a wild bison (they never spe...
2019/11/06
[ "https://worldbuilding.stackexchange.com/questions/160196", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/10274/" ]
They are fairly easy to tell apart from just bones. --------------------------------------------------- From the bones there are several obvious differences. Well start from the most obvious and work down. the shape of the skull is an easy one and the first thing you look at in mammals. bison skulls are much wider/s...
The most obvious difference in the skeleton along the "hump". As you can see from L.Dutch's image the bison has a more pronounced hump over the shoulders. While that is primarily muscle, it has a skeletal structure that is significantly more pronounced in the bison than the aurochs.
18,263,097
I have asked a similar question earlier but I have narrowed it down and would like to start a new question. The following script inserts a To and From dates into a DB record. I want to add the option of skipping every other week. The following is very close however, it skips the first week which I don't want it to do....
2013/08/15
[ "https://Stackoverflow.com/questions/18263097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2687614/" ]
Instead of putting all your options tags in the array, you can just put the numbers and use PHP to create the tags for you: ``` $miltimes = array('0000', '0030', '0100', '0130', '0200', '0230', '0300', '0330', '0400', '0430', '0500', '0530', '0600', '0630', '0700', '0730', '0800', '0830', '0900', '0930', '1000', '1030...
If you are trying to set a time based on the values and if your time values are strings then ``` $matchtime = "1000"; $defaulttime = "0500" foreach($miltimes as $miltime) { $timematched = ($miltime == $matchtime) ? $miltime : $defaulttime; echo $timematched; } ``` Although it is better to have **only** t...
157,888
Not [Git](https://en.wikipedia.org/wiki/Git), but [GitHub](https://en.wikipedia.org/wiki/GitHub)... single or multiple repositories, GitHub-style documentation, etc.
2012/12/07
[ "https://meta.stackexchange.com/questions/157888", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/116/" ]
Generally, Stack Overflow is fine, but as random pointed out in his comment, it depends what is being asked: <https://stackoverflow.com/questions/tagged/github> GitHub is certainly a tool commonly used by programmers, per the FAQ. I like to think one of the best ways to decide what to ask is to first observe what is ...
And it turns out the GitHub guys concur with Jeff! From [the announcement](https://groups.google.com/forum/?fromgroups=#!topic/github/TbbbBkAm-jk) where they shut down their Google Groups group: > > After three glorious years, we're shutting down this Google Group next > Monday, May 9th, 2011. > > > You can always...
19,457,479
I am new to the site and I am having trouble with a scalable website I am creating. The problem appears when downsizing the screen to below 650px. For some reason the background for my menu is disappearing. I've gone over the code numerous times and cannot find my error. Please help! Here is the link to my page: <http...
2013/10/18
[ "https://Stackoverflow.com/questions/19457479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2079047/" ]
You changed the positioning context ``` @media screen and (max-width: 650px) #main-nav { position: static; } ``` If you remove `static` the bg color returns...then it's just a matter of tweaking the position values.
The problem is in your media queries which are responsible for changing the layout on different screen sizes: go ahead and add this: ``` @media screen and (max-width: 650px) #main-nav { bottom: inherit; } ```
18,654,386
Can any explain what this section of code does: `_num = (_num & ~(1L << 63));` I've have been reading up on RNGCryptoServiceProvider and came across <http://codethinktank.blogspot.co.uk/2013/04/cryptographically-secure-pseudo-random.html> with the code, I can follow most the code except for the section above. I under...
2013/09/06
[ "https://Stackoverflow.com/questions/18654386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2608448/" ]
This is purely the watch window that is showing you the `char byte` value and the actual `char string` vaule. So, from [ASCII Table](http://www.asciitable.com/) you can see that `48 is '0'` and `49 is '1'`
As per the C# Reference, each char from char array shows the Decimal value of it
10,348,778
I have a table that has the following columns ``` table: route columns: id, location, order_id ``` and it has values such as ``` id, location, order_id 1, London, 12 2, Amsterdam, 102 3, Berlin, 90 5, Paris, 19 ``` Is it possible to do a sql select statement in postgres that will return each row along with the id...
2012/04/27
[ "https://Stackoverflow.com/questions/10348778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/610171/" ]
``` select id, location, order_id, lag(id) over (order by order_id desc) as next_id from your_table ```
Creating testbed first: ``` CREATE TABLE route (id int4, location varchar(20), order_id int4); INSERT INTO route VALUES (1,'London',12),(2,'Amsterdam',102), (3,'Berlin',90),(5,'Paris',19); ``` The query: ``` WITH ranked AS ( SELECT id,location,order_id,rank() OVER (ORDER BY order_id) FROM route) S...
20,211,896
Is it possible to integrate JSHint into Jenkins without using the Checkstyle or JSLint reporter? The reason why I want to do this is because both reporters by default also show *non-errors*, which is not what I want (see also [JSHint shows non-errors for checkstyle reporter](https://stackoverflow.com/questions/2019468...
2013/11/26
[ "https://Stackoverflow.com/questions/20211896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1333873/" ]
I had similar problem last week, but I use grunt to run jshint. I simply override jshint options, here is example code: ``` jshint: { options: { jshintrc: '../config/.jshintrc', }, src1: [ 'file1.js', 'file2.js' ], src2: [ 'source/file3.js', 'source/file4.js...
I would like to point out that jsHint will now work with the Report Violations, but you must set the report type to `jslint-xml`. Here is a sample for the Ant task: ``` <jshint dir="${js.dir}"> options="${jshint.options}"> <include name="**/*.js"/> <exclude name="**/*.min.js"/> <report type="jslint...