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
3,922,249
This is a newbie question but I hope I can express my question as clearly as possible. I'm trying to do pattern matching in C++. I've downloaded the Win32 version of PCRE from [here](http://gnuwin32.sourceforge.net/packages/pcre.htm) and I've placed the downloaded pcre3.dll and pcreposix3.dll files into the folder o...
2010/10/13
[ "https://Stackoverflow.com/questions/3922249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/183467/" ]
If you specify the file for `#include` with angle brackets (`<>`), then the compiler will only look for that header in the locations for external libraries, in so far as the compiler is aware of them. If you instead use quotation marks (`""`), then the compiler will also look in the locations for the current project...
``` cout << “PCRE compilation failed with error: “ << re.error() << “\n”; ``` I just copied your code and tried to compile it. I got the same error as you reported. The problem is that string you put to cout is not properly started/ended. You should use real " instead of marks which looks like double quotes ...
46,699,256
I know this is not a coding service where I ask for something and you spit out a result. I am looking for the following help: say I have 2 unique text data that I can assign to a cell (via data validation or typing in each cell) on a row of 7 cells. Now say I want to allow the text to be assigned to only 3 of those 7...
2017/10/11
[ "https://Stackoverflow.com/questions/46699256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8762074/" ]
The valid value, use instead of `QUrl("local.registry")`: ``` QUrl("tcp://192.168.0.3:-1"); ``` The valid value, use instead of `QUrl("local.replica")`: ``` QUrl("tcp://192.168.0.3:9999"); ``` The IP address *192.168.0.3* - used for example (it value valid for my workstation in our office network) in your case I...
If Qt is indicating that 'the address is in use' then that is likely the source of the problem, literally the socket at IP:PORT is being used. You may check your development environment to see if you have multiple processes running of the same app - this is often the case and it leads to a collision of address spaces. ...
7,992,584
when i am print `System.currentTimeMillis()` give me : ``` 11-03 14:47:05.400: INFO/System.out(7579): date is :: 14475410111 ``` What is the correct procedure to get entire date with time.?
2011/11/03
[ "https://Stackoverflow.com/questions/7992584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/863257/" ]
To get current date and time in Android, You can use: ``` Calendar c = Calendar.getInstance(); System.out.println("Current time => "+c.getTime()); ``` Output: ------- Current time => Thu Nov 03 15:00:45 GMT+05:30 2011 FYI, once you have this time in 'c' object, you can use [SimpleDateFormat](http://developer.andro...
``` Date now = new Date(System.currentTimeMillis()); ``` By the way : `currentTimeMillis()` > > Returns the current system time in milliseconds since January 1, 1970 00:00:00 UTC. > > >
64,906,525
I currently have a windows laptop with an intel i5. I am looking to upgrade to an M1 mac. Emulation isn't a problem for me(Virtualization is slower on ARM). Can any early adopter let me know if it is fast enough for basic android development and some Xcode?
2020/11/19
[ "https://Stackoverflow.com/questions/64906525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14623895/" ]
It's definitely okay for *basic* Android development. I've had a few instances where it has randomly frozen on me and I've had to do a force quit. And it doesn't particularly feel like it is quicker than the 2015 MacBook Pro I was running it on before(!) It is, however, very quiet (no fan!) and hopefully now that Intel...
Is anyone else using NDK with the M1? I have two Android apps that I use Android Studio for. I tried both on my new M1 Mac mini. One, relatively simple and Java only, builds fine. The second has Java and C code (uses the NDK). Building it fails with a crash of Android Studio. As a result of this, I'm having to deve...
34,983,475
<http://cplusplus.com/reference/string/basic_string/operator[]> I understand that it's advantageous to have a second version which returns `const` to prevent warnings when a `const` result is required and to mitigate casting but if the function already provides a non-`const` method (method-- not result) then what is t...
2016/01/25
[ "https://Stackoverflow.com/questions/34983475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1762276/" ]
If you have a `const std::basic_string` you cannot call (non-const) `std::basic_string::operator[]`, as it is, well, not marked const.
If there wasn't a `const` version of the function, the function could not be invoked on a `const` instance. For example: ``` void func (const std::string &h) { if (h[0] == "hello") ... } ``` How would this work if there wasn't a `const` version of `operator[]`?
72,244,234
I am importing the data with this command ``` df = pd.read_excel('C:/Users/Me/Data.xlsx', sheet_name='Prices') ``` and this is the result: [![1](https://i.stack.imgur.com/gZmd4.png)](https://i.stack.imgur.com/gZmd4.png) The date is a common column and I want it like this: [![2](https://i.stack.imgur.com/fLrJu.png...
2022/05/14
[ "https://Stackoverflow.com/questions/72244234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19081887/" ]
I found the answer.Adding `parse_dates=True`, `index_col=0` to the import command like this: ``` df = pd.read_excel('C:/Users/Me/Data.xlsx', sheet_name='Prices', parse_dates=True, index_col=0) ``` The output is this: [![1](https://i.stack.imgur.com/GhA8p.png)](https://i.stack.imgur.com/GhA8p.png)
I found a better way to import them, because when I was trying to calculate the monthly returns it does not work. So I use this new code and the date were perfect. ``` df = pd.read_excel('C:/Users/Me/Data.xlsx', sheet_name='Prices') df.index = pd.to_datetime(df['Date']) df.drop(['Date'], axis = 'columns', inplace=True...
6,204,878
I am trying to check if a file is on the server with the C# code behind of my ASP.NET web page. I know the file does exist as I put it on the server in a piece of code before hand. Can anyone see why it is not finding the file. This is the code: ``` wordDocName = "~/specifications/" + Convert.ToInt32(ViewState["projec...
2011/06/01
[ "https://Stackoverflow.com/questions/6204878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/732352/" ]
`File.Exists()` and probably everything else you want to do with the file will need a real Path. Your `wordDocName` is a relative URL. Simply use ``` string fileName = Server.MapPath(wordDocName); ```
this might not work if the directory holding the file is referenced by a junction/symbolic link. I have this case in my own application and if I put the REAL path to the file, File.Exists() returns true. But if I use Server.MapPath but the folder is in fact a junction to the folder, it seems to fail. Anyone experienced...
22,982,741
I have that form ``` <form action="deletprofil.php" id="form_id" method="post"> <div data-role="controlgroup" data-filter="true" data-input="#filterControlgroup-input"> <button type="submit" name="submit" value="1" class="ui-btn ui-shadow ui-corner-all ui-icon-delete ui-btn-icon-right" data...
2014/04/10
[ "https://Stackoverflow.com/questions/22982741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1374234/" ]
***The NUMBER ONE error is having ANYTHING with the reserved word `submit` as `ID` or `NAME` in your form.*** If you plan to call `.submit()` on the form AND the form has `submit` as id or name on any form element, then you need to **rename that form element**, since the form’s submit method/handler is shadowed by the...
Some time you have to give all the form element into a same div. example:- If you are using ajax submit with modal. So all the elements are in modal body. Some time we put submit button in modal footer.
38,976
The [US Environmental Protection Authority (EPA) has restrictions on "Particulate Matter"](https://www.epa.gov/pm-pollution). [A recent Wall Street Journal op-ed piece](https://www.wsj.com/articles/a-step-toward-scientific-integrity-at-the-epa-1500326062) article claims it is based on a > > scientifically unsupport...
2017/07/18
[ "https://skeptics.stackexchange.com/questions/38976", "https://skeptics.stackexchange.com", "https://skeptics.stackexchange.com/users/36871/" ]
**It is justified with (recent) evidence.** Selectively quoting from [WP:Pariculates#Health\_problems](https://en.wikipedia.org/wiki/Particulates#Health_problems), emphasis of publication dates mine: > > Inhalation of PM2.5 – PM10 is associated with elevated risk of > adverse pregnancy outcomes, such as low birth w...
Odd. The CASAC also disagreed with the EPA on PM in 2006 - only they felt the restrictions were not protective enough of public health: > > "The CASAC recommended changes in the annual fine-particle standard > because there is clear and convincing scientific evidence that > significant adverse human-health effects ...
1,788,015
Is this pure coincidence or is this a special case of some well-known number-theoretic result? If the latter is true, is there some notable generalization? EDIT: Thanks to the interesting answers below, a follow-up question is now on MathOverflow: <https://mathoverflow.net/questions/239033/repdigit-numbers-which-are-...
2016/05/16
[ "https://math.stackexchange.com/questions/1788015", "https://math.stackexchange.com", "https://math.stackexchange.com/users/200455/" ]
It is probably coincidence. When considering sums of 16 or less consecutive squares, where the smallest is at most $200^2$, I found only one other such sum: $$71^2+72^2+73^2+74^2+75^2+76^2+77^2+78^2=44444$$
I've heard this kind of thing called a *curio*, or "curiosity." The kind of thing that makes you go, "Huh ... neat!" Piquito's answer is interesting. I wouldn't be so bold as to say it's *the* answer, because there are lots of other ways to dissect and reassemble things. For example: $$1111 = 555 + 555 + 1 = 10 \cdot...
105,239
I have a valid US visa on my Indian passport. I changed my nationality to HKSAR. Can my US visa be transferred to my HKSAR passport?
2017/11/14
[ "https://travel.stackexchange.com/questions/105239", "https://travel.stackexchange.com", "https://travel.stackexchange.com/users/70298/" ]
**No**. A US visa can not be transferred to any other passport. But if an expired passport contains it and there is a new passport the same visa **can be used** after meeting certain conditions listed below. > > **My old passport has already expired. My visa to travel to the United States is still valid but in my exp...
TL;DR: **you will need to get a new visa** As the other answer points out, you could use both passports if they had been issued by the same country and of the same type. But since you changed nationalities, this is not an option for you and you will need a new visa. Do take note of the passport number of your Indian ...
29,291,113
When I use the command: ``` pyinstaller.exe --icon=test.ico -F --noconsole test.py ``` All icons do not change to test.ico. Some icons remain as the pyinstaller's default icon. Why? All icon change in * windows 7 32bit * windows 7 64bit (make an exe file OS) Some remain default * windows 7 64bit (other PC)
2015/03/27
[ "https://Stackoverflow.com/questions/29291113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3683061/" ]
I know this is old and whatnot (and not exactly sure if it's a question), but after searching, I had success with this command for `--onefile`: ``` pyinstaller.exe --onefile --windowed --icon=app.ico app.py ``` Google led me to this page while I was searching for an answer on how to set an icon for my .exe, so maybe...
The solution for me was refresh the icon cache of the windows explorer for Windows 10: Enter "ie4uinit.exe -show" in Windows run Link: <https://superuser.com/questions/499078/refresh-icon-cache-without-rebooting>
1,458
As an old-school AD&D 2nd Edition player, I like most of the changes in 4e. One thing I can't come to grips with is the loot system. I *hate hate hate* that the treasure drops are tailored to such a high degree. It pushes the game into such a linear progression for equipping your characters. I'm thinking about sittin...
2010/08/27
[ "https://rpg.stackexchange.com/questions/1458", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/220/" ]
Take a look at the D&D essentials changes to magic items and loot. It takes a lot of steps in the right direction. Before these changes my group had a similar problem but went it a different direction then what you suggest. We: * removed the ability for a player to start with anything other than magic weapons, armors...
In my original Caldera setting, I'm basically getting rid of magic item "drops" and just letting characters purchase magic items. It's a saberpunk (high fantasy inspired by cyberpunk tropes) campaign, so magic replaces technology in this world. A PC can go buy just about any magic item he or she wants off the black m...
60,246,333
I am trying to join these two URIs ``` from urllib.parse import urljoin # baskslash is not a mistake r = urljoin(r"https:/\\corrlinks.blob.core.windows.net", r"videofaq") print(r) ``` I am getting ``` https:///videofaq ``` How can I get ``` https:/\\corrlinks.blob.core.windows.net/videofaq ``` This o...
2020/02/16
[ "https://Stackoverflow.com/questions/60246333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2352611/" ]
I have ended up with ``` url = url.replace("\\" , "/").replace("///", "//") ```
python treats backslash(\) as an escape character. using r'string' goes handy many times. r just means raw string. This is useful when we want to have a string that contains backslash and don’t want it to be treated as an escape character. In this case ``` from urllib.parse import urljoin r = urljoin(r"https://cor...
17,633,614
Look at the following code: <http://jsfiddle.net/B2wFZ/> If your resolution is 1366x768 you will see the input in line with the text, try zooming out, the input is no longer in line with the text. How to make sure that the div widens if necessary with min-width? Now if I replace: ``` width: 350px; ``` with ``` mi...
2013/07/13
[ "https://Stackoverflow.com/questions/17633614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2579059/" ]
`:=` is used in a *short variable declaration*; it both declares the variables on the left-hand-side, and assigns to them. (This is explained in [the "Short variable declarations" section of *The Go Programming Language Specification*](http://golang.org/ref/spec#Short_variable_declarations).) `=`, by contrast, merely ...
`:=` is for convenience. The important difference is that the `:=` does type inference, so as it declares and assigns the variable all one line, the variables type is inferred from the return value's type of the function. This makes your program easier to read in most cases but does mean someone will have to look up i...
165,146
I recently became enamored with the excellent app in Ubuntu GNU screen. I was really happy to see it installed on my Mac as well, but I can't split vertically... I guess I need to update it somehow. I tried mac ports, and brew, but I couldn't find anything. Has anyone done this successfully?
2010/07/19
[ "https://superuser.com/questions/165146", "https://superuser.com", "https://superuser.com/users/43256/" ]
Patch by Evan Meagher: <http://old.evanmeagher.net/2010/12/patching-screen-with-vertical-split-in-os> Using these instructions and patch to compile screen I now have screen with vertical splitting capability in Mac OS X
AFAIK you need at least screen-4.01. You can get it from their git repositories over at [gnus's savannah](http://savannah.gnu.org/git/?group=screen). One of the newer dowloads [here](http://ftp.gnu.org/gnu/screen/) might also work, but I haven't tried.
63,117
I have two very right-skewed datasets which I must study for difference in means. Given the skewness, I transformed using log 10 scale after adding 1 to be able to take the log. In other words: `xx = log10(x+1)`. `xx` is nicely normally distributed, which is good, but I have a neat spike at 0 (`x` is quite sparsed). ...
2013/07/02
[ "https://stats.stackexchange.com/questions/63117", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/27020/" ]
Let me try restating your situation. 1. You have very right skewed variables of interest, mostly positive but with marked spikes at zero, generically $x$. 2. To make the distributions easier to handle, you used the transformation log ($x + 1$). (The base of the logs, 10 or e or anything else, is immaterial here.) I ...
Nick Cox already gave some very good advice. I'll just make one additional comment: There is no need to guess whether or not the $t$-test is robust enough for your data. If you change the data such that the means are the same but otherwise the distribution of the variable remains unchanged, then you can just use the b...
24,043,706
I have this menu, that (when you hover over an icon) makes the icon bigger. What I tried to achieve is, to have it display correctly from both sizes, which doesn't quite work. It only works from the left side, because of the unordered list, but is there a way to make it work from both sides? (basically so the icon cove...
2014/06/04
[ "https://Stackoverflow.com/questions/24043706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3495013/" ]
Add the following to your CSS: ``` .icon{ position: relative; z-index: 10; } .icon:hover{ z-index: 100; } ``` By increasing the `z-index`, the hovered icon is moved up in the DOM-layer, and displayed above the other icons.
You may want to set all the images' `z-index` property to a negative value and when the image hovers, set it to a positive one. I don't know if this is a bug but that's how it behaves, take a look at [this fiddle](http://jsfiddle.net/4BWHs/): ``` #one { width: 100px; height: 40px; background: red; z-in...
7,451,144
So I know that google places API serves the place information (name, location, website, type ect) with JSON but I was wondering how to grab the data from the JSON? Basically I've got a site where users can use the google maps API Ive set up to search for their retail shops and Id like to store all that information in ...
2011/09/16
[ "https://Stackoverflow.com/questions/7451144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/712486/" ]
You should only use the google places api from the client. Google has a rate limit set pretty low, and it's based on IP address (at least for the google maps api). So if you're making too many requests from your web server, all of a sudden google cuts you off for the day. The way around this is to just do all the calls...
I thought of doing the same with Geocoder, i think it's worth looking at.http://railscasts.com/episodes/273-geocoder?view=comments
52,967,111
I'm currently trying to use the pg\_trgm operations `%` and `<->`. The GIN Indices on the columns are already available, but I can't find the sqlalchemy equivalent to the previously mentioned operators. What would be the best approach to solve this problem, except writing a pure text query. A simple example query wou...
2018/10/24
[ "https://Stackoverflow.com/questions/52967111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5464807/" ]
For people who are using Postgres, it's possible to use `similarity` to do so instead. NOTE: Do remember to install the `pg_trgm` extension in your Postgres first: `CREATE EXTENSION pg_trgm;` Here's an example in using SQLAlchemy: ```py # ... other imports from sqlalchemy import and_, func, or_ def search_store_pro...
If anyone is interested, I did some tests comparing the `%` method and the `similarity(...) > x` method and there is a significant speed up using `%`. Over 10x in some cases. ``` SELECT * FROM X WHERE name % 'foo'; ``` is way faster than ``` SELECT name FROM x WHERE similarity(name, 'foo') > 0.7; ``` So I recomme...
16,966,714
I have an xml file which I'm trying to minimise using a bash script. After removing any indentation, some part of the file looks like this: ``` <layer name ="dotted_line" align ="topleft" edge ="topleft" handcursor ="false" keep ="true" url ="%SWFPATH%/include/info_btn/dotted_line.png" z...
2013/06/06
[ "https://Stackoverflow.com/questions/16966714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1187707/" ]
`sed -i s/\ *=\ */=/g filename` Regards
You should first try to see if xmllint --format isn't already doing everything you need: ``` xmllint --format OLDFILE.xml > NEWFILE.xml ``` The big advantage of this approach: * it will strip down every "cosmetic" things (extra spaces, etc). Ie it will not only replace `name = value` with `name=value` but will get ...
90,425
someone formulated this argument: 1. Iff there's space, then God is omnipresent. 2. Iff there's universe, then there's space. 3. There was a state of affairs when there's no universe (There was a state of affairs in which God existed with no universe. [Creatio ex nihilo]), 4. There was a state of affairs when there's ...
2022/04/07
[ "https://philosophy.stackexchange.com/questions/90425", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/56931/" ]
What does 'omnipresent' mean? If you mean, "X is everywhere in space", that can be restated as "for every (piece of) space S, X is in S". Then when there is no space, (i.e. "space" is "empty"...), the universal quantifier is fulfilled, and X *is* omnipresent. For any X, in fact.
Imagine the following: a computer programmer creates a simulated universe, within which self-aware programs live. They might think, if there is RAM (computer memory, or however they name it, maybe they call it "space", because they have no conception about what the computer really is), then their creator is omnipresen...
53,622,292
I need to display HTML code to all user roles except "subscriber" in wordpress. Here is code that I can't get working. ``` <?php $current_user = wp_get_current_user(); ?> <?php if ( $current_user->role == 'subscriber' ) : ?> <span>here is my html</span> <?php endif; ?> ``` PS I'm not that good with php as yo...
2018/12/04
[ "https://Stackoverflow.com/questions/53622292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3915892/" ]
Try a package called pandas-dedupe. Uses fuzzy matching and machine learning. <https://pypi.org/project/pandas-dedupe/> I know your question is very old, but the above package may still be of assistance. Did you find a solution in the end?
I agree with @SCool. pandas-dedupe is a very good library that can do exactly this. Here is an example: ``` import pandas as pd import pandas_dedupe df = pd.DataFrame({'name': ['Franc', 'Frank', 'John', 'Michelle', 'Charlotte', 'Carlotte', 'Jonh', 'Filipp', 'Charles', 'Diana', 'Robert', 'Carles', 'Michele']}) dd = p...
9,294
I have a Nikon D7000 and I see there are a couple remote release options from Nikon: the (wired) MC-DC2 and the (wireless) ML-L3 which is also about 40% cheaper than the wired remote. Are there any good reasons one would choose the wired remote instead of the wireless, especially given the price difference?
2011/02/28
[ "https://photo.stackexchange.com/questions/9294", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/89/" ]
Infrared triggers can lose their minds when in the presence of sunlight or a strong IR source. The sun puts out *SO* much IR the receiver can't see the signal unless its window is in shade or very close to the transmitter. They do work really well indoors or at night though, and cost less than the radio triggers. And...
I have a wireless RF remote for my camera and now that I have wireless I would not do wired. The main reason is that there is less chance of tripping over the cable or having to worry about being tangled in it. Or if you are doing pictures with you in them you do not have to worry about hiding the cable. Having said t...
43,309,869
I want to convert a string to time using the parse method which is going to be inserted to database later. But I get: Incompatible Types: Java.util.date cannot be converted to Java.sql.Date. Any Solution? ``` String s = time.getText(); DateFormat sdf = new SimpleDateFormat("hh:mm:ss"); Date d = sdf.parse(s); ...
2017/04/09
[ "https://Stackoverflow.com/questions/43309869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7549737/" ]
You can use `Array.map` to transform your objects based on whether their `code` is in the `obj2` array: ```js var obj1 = [ { "code": "in_today", "text": "Today" }, { "code": "in_week", "text": "This week" }, { "code": "in_month", "text": "This month" }, { "code":...
You'll want to do something like this: ``` for (var i = 0; i < obj1.length; ++i) { if (obj2.indexOf(obj1[i].code) == -1) { obj1[i].selected = false; } else { obj1[i].selected = true; } } ``` Essentially, you just loop over obj1, then check if the value of `obj1.code` is present in obj2, then set `selec...
2,529,490
I'm trying to get the result of a COUNT as a column in my view. Please see the below query for a demo of the kind of thing I want (this is just for demo purposes) ``` SELECT ProductID, Name, Description, Price, (SELECT COUNT(*) FROM ord WHERE ord.ProductID = prod.ProductID) AS TotalNumberOfOrd...
2010/03/27
[ "https://Stackoverflow.com/questions/2529490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131809/" ]
If you are only interested in the products that have been ordered, you could simply substitute the LEFT OUTER JOIN operation with an INNER JOIN: ``` SELECT prod.ProductID, prod.Name, prod.Description, prod. Price, COUNT(*) AS TotalNumberOfOrders FROM tblProducts prod INNER JOIN tblOrders ord O...
This will work: ``` SELECT ProductID, Name, Description, Price, COUNT(ord.ProductId) AS TotalNumberOfOrders FROM tblProducts prod LEFT JOIN tblOrders ord ON prod.ProductID = ord.ProductID GROUP BY ProductID, Name, Description, Price ``` The "COUNT(ord.ProductId)" clause e...
111,838
Assume someone received some service (for example, had his hair cut) and had made the payment using his credit card. What if this transaction was declined later? Does he still owe the money that he was supposed to pay? From the shop's point of view, how can the shop charge this customer then, after he has left?
2019/07/25
[ "https://money.stackexchange.com/questions/111838", "https://money.stackexchange.com", "https://money.stackexchange.com/users/88476/" ]
If the service was provided, you must pay for it. A declined credit card is like a bounced check in this regard: the service provider is still owed payment. From the shop's point of view, they are probably out of luck. The amount is likely too small to bother to pursue in small claims court, and their only recourse is...
The purpose of running the card through the reader is to get authorization from the network. If the transaction is later denied, then that is a dispute that the business owner has to make with the network. This has to be a very rare situation, or the business owner would never accept a credit card/debit card. The fee...
35,775,564
Currently I have set up my storyboard that is optimised for landscape mode. At first I figured I would only allow landscape orientation. However along the way I decided it would be better to allow both options. What I've done now is created a new storyboard that holds the layout for the portrait orientation. I did it ...
2016/03/03
[ "https://Stackoverflow.com/questions/35775564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3025852/" ]
The built-in size classes allows you to build completely different UI on the same storyboard. The runtime will select the appropriate scene / controls for the current device/orientation (size class) and will layout automatically (leveraging AutoLayout). Review the size classes feature in your local Xcode help as it is ...
`Autolayout` can allow you to rearrange the view for different orientation. For different functionalitys and elements, you should use `Size Class`, Follow the tutorial @Blakusl linked, is very good.
4,200,025
Let $h$ be a continuous function on $\mathbb{R}$ such that $h(x) = o(|x|^{-\alpha})$ at $\infty$ for some $\alpha > 1$. Let also $(b\_k)\_{k\in\mathbb{Z}}$ an increasing sequence such that, $$\lim\_{k\to\infty} b\_k - b\_{k-1} > 0.$$ I consider the function $f$ on $\mathbb{R}$ defined as, $$\forall~ u\in\mathbb{R}, ~f...
2021/07/16
[ "https://math.stackexchange.com/questions/4200025", "https://math.stackexchange.com", "https://math.stackexchange.com/users/473729/" ]
Without loss of generality, I redefine $f$ as, $$f(u) = \sum\_{r=0}^{\infty}h(u-a\_r),$$ where $(a\_r)\_r$ is positive on $\mathbb{N}$. I will prove that $f$ is bounded (this proof can be generalized when $f$ is defined as in initial post). $h(x) =o\left(|x|^{-\alpha}\right) \implies h(x) =o\left((|x|+1)^{-\alpha}\ri...
Your way to use periodicity to prove boundedness is smart, but I couldn't generalize. My idea is to bound the series by the improper integral $\int\_{-\infty}^{+\infty}|h(\alpha x)|dx$. Let $\alpha:=\liminf\_{k\to \infty} b\_k-b\_{k-1} $ be $>0$. Suppose for one moment that we have $b\_k-b\_{k-1} \ge \alpha$ for all $...
63,446,295
Given a string in C++ containing ranges and single numbers of the kind: ``` "2,3,4,7-9" ``` I want to parse it into a vector of the form: ``` 2,3,4,7,8,9 ``` If the numbers are separated by a `-` then I want to push all of the numbers in the range. Otherwise I want to push a single number. I tried using this pie...
2020/08/17
[ "https://Stackoverflow.com/questions/63446295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7179370/" ]
Your problem consists of two separate problems: 1. splitting the string into multiple strings at `,` 2. adding either numbers or ranges of numbers to a vector when parsing each string If you first split the whole string at a comma, you won't have to worry about splitting it at a hyphen at the same time. This is what ...
All very nice solutions so far. Using modern C++ and regex, you can do an all-in-one solution with only very few lines of code. How? First, we define a regex that either matches an integer OR an integer range. It will look like this ``` ((\d+)-(\d+))|(\d+) ``` Really very simple. First the range. So, some digits, f...
41,330,736
My 4 fragments in **ViewPager** have one common button from parent activity that opens a dialog and should refresh **ListViews** in these 4 fragments. I tried using static adapters but that didn't work. Now I'm trying to use broadcast but still I won't see my adapter from outer **broadcast receiver**. Please help.
2016/12/26
[ "https://Stackoverflow.com/questions/41330736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5857576/" ]
I had same requirement i did following :- 1. Extend pagerAdapter with FragmentStatePagerAdapter 2. Implement below in your pagerAdapter class ``` @Override public int getItemPosition(Object object) { return POSITION_NONE; } ``` 3. then when ever you refresh just call - > > notifyDataSetChanged();...
add your 4 lists to a map with separate key(1,2,3,4). ``` if (viewPager.getCurrentItem() == 0){ // show list items with key 1 }else if(viewPager.getCurrentItem() == 1){ //show list items with key 2 }else if(....) ``` now put a listener and call it on button click.
16,465
The line for **Queen's Indian Defence** goes like this - ``` [FEN ""] 1. d4 Nf6 2. c4 e6 3. Nf3 b6 ``` Now, the most popular choice for white in this position is **g3** preparing to fianchetto its light squared Bishop. After this, if Black wants to develop its light squared Bishop, the two choices are either *...
2017/01/26
[ "https://chess.stackexchange.com/questions/16465", "https://chess.stackexchange.com", "https://chess.stackexchange.com/users/9620/" ]
There are 3 reasons why White fianchettos the light square bishop: 1. White's plan is to play e4 to gain space. The bishop on g2 supports this 2. Building from point 1), white could play e3, Bd3 then e4, but that is an extra tempo spent to play e4 3. White has latent pressure on the queen-side, and may be able to play...
> > Given that white's main light squares defender around the king (after white castles king side) is its Bishop on g2 which at some point in the game can be exchanged with Black's bishop on b7, isn't this line a bit more riskier? > > > If they get exchanged black will also lose his light squared bishop which coul...
27,048,302
I am building an app in Rails 4 and am using asset pipeline. For my workflow, I've split my css into 10+ separate sheets. Should I combine them for deployment or does it not matter as long as they're minified? I'm wondering how much performance will be affected with separate stylesheets.
2014/11/20
[ "https://Stackoverflow.com/questions/27048302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3689085/" ]
Another one: ``` var times = 1; $(function(){ $("#test").on('click',function(){ console.log(times); if(times >= 3 || times == 0){ times = -1 } times += 1; }); }); ``` ### Working fiddle: <http://jsfiddle.net/robertrozas/q1ywowm1/1/>
```js var times = 0, n; $('button').on('click',function(){ n = times++; if(times > 4){ n = 0; } $(this).text(n); console.log(n); }); ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button>incre...
59,786,659
I am finishing new version of swift application and I notice that loading from core data become very slow. Same code in last version of app works great but in new it's very slow. Code is below and it's 100% same like in last version but now I must wait for cache 5-6 seconds and cache data are also same when testing old...
2020/01/17
[ "https://Stackoverflow.com/questions/59786659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1187965/" ]
The main issue about the code you posted seems to be that you haven't put your functions in a namespace, that is required for user-defined functions; with some clean up to use type declarations (`as="sequence-type"`) and to use `xsl:sequence` to return strings and not text nodes your code becomes ``` <xsl:param name...
The simplest way to pad to width 8 on the right is ``` substring(concat(X, ' '), 1, 8) ``` and on the left: ``` substring(concat(' ', X), 8 - string-length(X)) ```
724,607
[![enter image description here](https://i.stack.imgur.com/SjJSE.png)](https://i.stack.imgur.com/SjJSE.png) In Michelson Interferometer, the mirror that lies in the middle (half-silvered mirror), can reflect and let through light. But the light after being reflected by the half-silvered mirror, only let light through....
2022/08/24
[ "https://physics.stackexchange.com/questions/724607", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/343348/" ]
If you want to avoid being lost in Newtonian mechanics, follow these steps: * Define clearly your system. In your example, you have the choice between A, B, and (A+B) * Identify all the **external** forces applied to your system. * Check if the mass of the system is constant. You cannot directly apply Newton's second ...
If the two bodies remain in contact they have a mass of 3kg with a 3N force applied. The joint system will therefore accelerate at 1m/s^2. The block A will experience the original force of 3N and an opposite reaction force of 2N from block B. The net force is therefore 1N and it will accelerate at 1 m/s^2 Block B wil...
30,555,832
``` <div data-id="123">123</div> <div data-id="120" data-parent="123">120</div> <div data-id="115" data-parent="123">115</div> <div data-id="240">240</div> <div data-id="245" data-parent="240">245</div> <div data-id="246" data-parent="240">246</div> <div data-id="247" data-parent="240">247</div> <div data-id="255" da...
2015/05/31
[ "https://Stackoverflow.com/questions/30555832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/747579/" ]
To elaborate on Omar's answer, The Android design support library introduced NavigationDrawer that is used together with DrawerLayout to provide means of implementing navigation etc. See here: [Android Design Support Library](http://android-developers.blogspot.com/2015/05/android-design-support-library.html) The Na...
Or else you can rename **insetForeground** in your **values/attr.xml** to **insetForeground2** or something
11,363,969
Can one create an array of calendar objects? If yes, how does one do so? This code surely gives error ``` Calendar cal[length]; //loop for initialising all the objects in cal[] array ``` If no, what other way is there for getting "n" number of calendar objects? I need this for a repeating alarm, set at differe...
2012/07/06
[ "https://Stackoverflow.com/questions/11363969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/965830/" ]
You can always do `Calendar[] cal = new Calendar[length];` You can use an ArrayList, too, such as: `List<Calendar> list = new ArrayList<Calendar>();` Then there's a lot of convenience methods, such as `add(Calendar calendar);` Then: You can use `for (int x = 0; x < list.size(); x++)` or `for (Calendar cal : list)...
The proper syntax for creating an array in Java is: Calendar[] cal = new Calander[length]; Then you can initialze the individual elements.
141,924
Are there any methods to store spells of 9th level at a location, preferably in a manner that can be triggered in a manner similar to *glyph of warding*? Magic items could be accepted as the answer as well. It needs to be a method that doesn’t require two 9th-level spell slots; using *glyph of warding* would require y...
2019/02/25
[ "https://rpg.stackexchange.com/questions/141924", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/49319/" ]
The [*Tome of the Stilled Tongue*](https://www.dndbeyond.com/magic-items/tome-of-the-stilled-tongue) (DMG, p. 208) allows this if you're a wizard attuned to it and use it as a spellbook. Once per day, you can cast any spell written in it as a bonus action: > > If you can attune to this item, you can use it as a spell...
Timing ====== If you start casting *Glyph of Warding* one half hour before you end a long rest, [you'll use up your 9th level spell slot immediately.](https://rpg.stackexchange.com/a/141304) Then, once you finish your long rest, you'll regain the spell slot you need. Then, once you finish casting the spell, you'll ins...
1,319,057
I am trying to define an algebric type: ``` data MyType t = MyType t ``` And make it an instance of Show: ``` instance Show (MyType t) where show (MyType x) = "MyType: " ++ (show x) ``` GHC complains becasue it cannot deduce that type 't' in 'Show (MyType t)' is actually an instance of Show, which is needed for...
2009/08/23
[ "https://Stackoverflow.com/questions/1319057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Add a type constraint on the type of `t`: ``` instance Show t => Show (MyType t) where show (MyType x) = "MyType: " ++ (show x) ```
You could also just: ``` data MyType t = MyType t deriving Show ``` if you want a regular show format.
25,761,405
I am developing a PHP application where I need to fetch 5 random email addresses from a CSV file and send to user. I already worked with CSV file many times but don't know how to fetch randomly in limit. ``` NOTE: CSV file have more than 200k emails. ``` Any one have a idea or suggestion then please send me.
2014/09/10
[ "https://Stackoverflow.com/questions/25761405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1498579/" ]
If CSV is too big and won't be saved in a DB -------------------------------------------- You'll have to loop through all of the rows in the CSV once to count them. You'll have to call a random-number generator function (`rand`, `mt_rand`, others...) and parametrize it to output numbers from `0` to `$count`, and call...
``` <?php $handle = fopen('test.csv', 'r'); $csv = fgetcsv($handle); function randomMail($key) { global $csv; $randomMail = $csv[$key]; return $randomMail; } $randomKey = array_rand($csv, 5); print_r(array_map('randomMail', $randomKey)); ``` This is small utility to achieve the thing you expect and chan...
54,981
In Mail, when I've selected a message, I would like to have a shortcut to copy the message\_id (see [my previous question](https://apple.stackexchange.com/a/54971/769)) to the clipboard. How do I manage that? Applescript, I presume?
2012/06/28
[ "https://apple.stackexchange.com/questions/54981", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/769/" ]
That's doable as well. Paste the text below into AppleScript Editor (find it simply with Spotlight by typing "`⌘``Space` AppleScriptEditor" and hitting the enter key when it's highlighted). ``` tell application "Mail" set theSelection to selection set theMessage to first item of theSelection set theUrl t...
The correct script is: ``` tell application "Mail" set theSelection to selection set theMessage to first item of theSelection set theUrl to "message:%3C" & message id of theMessage & "%3E" set the clipboard to theUrl end tell ```
8,982,420
In a java class I have a method that sometimes takes a long time for execution. Maybe it hangs in that method flow. What I want is if the method doesn't complete in specific time, the program should exit from that method and continue with the rest of flow. Please let me know is there any way to handle this situation.
2012/01/24
[ "https://Stackoverflow.com/questions/8982420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1121031/" ]
You must use threads in order to achieve this. Threads are not harmful :) Example below run a piece of code for 10 seconds and then ends it. ``` public class Test { public static void main(String args[]) throws InterruptedException { Thread thread = new Thread(new Runnable() { @Overrid...
Execute the method in a different thread, you can end a thread at anytime.
41,602,452
I am working on a proof-of-concept where I have a few custom views in a TableLayout. When one of the Views is clicked I want to animate the view expanding into a new Activity. The effect I want to achieve is similar to what is seen [here](https://medium.com/@bherbst/fragment-transitions-with-shared-elements-7c7d71d31cb...
2017/01/11
[ "https://Stackoverflow.com/questions/41602452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2056488/" ]
Just try with `postponeEnterTransition()` and `startPostponedEnterTransition()` in your `DetailActivity` `postponeEnterTransition()` used to temporarily delay the transition until the shared elements have been properly measured and laid out. `startPostponedEnterTransition()` Schedules the shared element transition to...
I don't think that your problem is that you have a custom view... I always make those transitions with my custom views and they work ok. I can see that this code: ``` ActivityOptions options = ActivityOptions .makeSceneTransitionAnimation(MainActivity.this, view1, "profile"); ...
688,432
> > Prove that $$1<\dfrac{1}{1001}+\dfrac{1}{1002}+\dfrac{1}{1003}+\dots+\dfrac{1}{3001}<\dfrac43 \, .$$ > > > My work: $$\begin{eqnarray\*} S&=&\bigg(\dfrac{1}{1001}+\dfrac{1}{3001}\bigg)+\bigg(\dfrac{1}{1002}+\dfrac{1}{3000}\bigg)+\ldots+\dfrac{1}{2001}\\ S&=&\dfrac{1}{4002}\bigg\{\bigg(\dfrac{1001+3001}{1001...
2014/02/24
[ "https://math.stackexchange.com/questions/688432", "https://math.stackexchange.com", "https://math.stackexchange.com/users/105577/" ]
Let $k$ be a fixed integer greater than $0$. It holds that $\frac{1}{1000+k}\leq \frac{1}{1000+x}$for any $x \in [k-1,k]$. Integrating for fixed $k \in [1,2001]$ yields $$\frac{1}{1000+k}\leq \int\_{k-1}^{k}\frac{1}{1000+x}dx$$ Hence $$\frac{1}{1001}+\frac{1}{1002}+\frac{1}{1003}+\ldots+\frac{1}{3001} \leq \int\_{0}...
For $k=0,1 \cdots 2000$ we have $$ \frac{1}{1001+k} < \frac{1}{1000}\left(1 - \frac{k}{3000}\right)$$ Explanation: let the left side be $f(k)$ and the right side $g(k)$. Then $f(0)=1/1001$, $g(0) = 1/1000$; while $f(2000)=1/3001$ and $g(2000) =1/3000$. Hence $f < g$ in the extreme points - and because $f$ is convex, ...
2,731,712
I am really trying to follow the DRY principle. I have a sub that looks like this? ``` Private Sub DoSupplyModel OutputLine("ITEM SUMMARIES") Dim ItemSumms As New SupplyModel.ItemSummaries(_currentSupplyModel, _excelRows) ItemSumms.FillRows() OutputLine("") OutputLine("NUMBERE...
2010/04/28
[ "https://Stackoverflow.com/questions/2731712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39478/" ]
you can refactor to take advantage of the fact that the share a common base and use polymorphism: (VB a bit rusty, you should get the idea) you could have a method: ``` Private Sub FillAndOutput(textToOutput as String, filler as DataBuilderBase) OutputLine(string) filler.FillRows() OutputLine("") ...
In this case I don't think that refactoring to a generic function is justifiable, even at the expense of repeating yourself. You would have two options: 1. Refactor your code so that it allows for parameterless constructors and create a function at a higher level of inheritance that allows you to specify the arguments...
10,370,143
My homepage has links to pages a.html and b.html. In the same directory with these 2 pages, I have pages **c.html** and **d.html** which **are not linked to by any other pages**. My question is **Do webcrawlers also index c.html and d.html** just because they are in the directory? Or do they only follow the links star...
2012/04/29
[ "https://Stackoverflow.com/questions/10370143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1210654/" ]
Sending this mDNS packet seems to work for my application which has a Raspberry Pi. I think the IP/ports are specific to ZeroConf/Bonjour, which seems to be widely used so it may work for those cameras. ``` public void sendDiscoveryQuery(string local_dhcp_ip_address) { // multicast UDP-based mDNS-packet for discov...
On some devices the MAC-Address is printed on a lable, maybe on the backside. As far as my understandig goes, they need to be in the arp cache at least once. But this cache only stores 5 (?) entries, so you may have to refresh it, or clear it before you connect the devices or run the config tool.
444,383
I am curious why can't we switch to a user's home director with either ``` $ cd ~"$USER" ``` or ``` $ cd ~${USER} ```
2018/05/17
[ "https://unix.stackexchange.com/questions/444383", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/286001/" ]
That very much depends on the shell and the order the expansions are done in those shells. `~$user` expands to the home directory of the user whose name is stored in `$user` in csh (where that `~user` feature comes from), AT&T ksh, zsh, fish. Note however these variations: ``` $ u=daemon/xxx csh -c 'echo ~$u' /usr/s...
Tilde expansion is a separate step in the processing of the command line. It happens just *before* variable expansion. If the tilde is followed by something other than a slash, it will expand to the home directory of the user whose name is following the tilde, as in, for example, `~otheruser`. Since `$USER` is not exp...
65,634,447
I'm trying to get values from JSON that looks like this: ``` { "id": 371, "city": "London", "name": "London Station", "trains": [ { "id": 375, "number": "1023", "numberOfCarriages": "21" } ] } ``` I want to get values from trains, like number an...
2021/01/08
[ "https://Stackoverflow.com/questions/65634447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14782668/" ]
Jazzy requires a build from the command line to generate the documentation. So you need a command similar to: ```sh jazzy --build-tool-arguments -workspace,ios.xcworkspace,-scheme,iosapp ``` From <https://github.com/realm/jazzy> > > *...try passing extra arguments to xcodebuild, for example `jazzy --build-tool-arg...
You can review the content of ``` log file: /var/folders/nd/t1rlxsp94kgbll0v834jnc0h0000gp/T/xcodebuild-84D58051-E84E-40D8-A4E7-E080B83D7117.log ``` for to obtain details the error
4,581
Using 8.1 I would like to implement some personalization on the top banner of a page. So, if the user matches Pattern Card A, they see banner A, if they match Pattern Card B, they see banner B, and so on. My problem is that if the match Pattern Card A first, they can never get to Pattern Card B because in the hierarch...
2017/02/23
[ "https://sitecore.stackexchange.com/questions/4581", "https://sitecore.stackexchange.com", "https://sitecore.stackexchange.com/users/341/" ]
The user can still be matched in Pattern Card A or B. Let us take the following scenario: Pattern Card A is assigned to users who are more involved in reading articles that concerns Exercises. Pattern Card B is assigned to users who are more involved in reading articles that concerns Swimming. So, if your user is ta...
I would suggest ordering the rules for personalization from most specific to least specific. In your example I would do this like: 1. Exercise and Swimming 2. Exercise only 3. Swimming only 4. Default The thresholds for Exercise and Swimming could also be something less than 100, so you can build upon the points in ...
159,534
If I right click and get "properties" on an [RSS](http://en.wikipedia.org/wiki/RSS) item in Outlook 2007 after I've created it, there doesn't seem any place that shows me the RSS feed [URL](http://en.wikipedia.org/wiki/Uniform_Resource_Locator) that it is using. How do I find it out? ![Enter image description here](ht...
2010/07/02
[ "https://superuser.com/questions/159534", "https://superuser.com", "https://superuser.com/users/1501/" ]
It's under menu **Tools** -> **Account Settings** -> **RSS Feeds**. Under the one you want, choose it and then click the **Change** button. The RSS URL is the **Location**.
It's annoying that you can't get to this in the properties. The easiest way to get to the URL would probably be to export the RSS feeds to an OPML file and you can find them all in there. I'm using 2010, but I think in 2007 you start from File > Import and Export (in 2010 it is now in File > Options > Advanced > Expor...
17,886,074
The following button provides the exact functionality I require, but it must be done programmatically as I will be making more than one based on some variables, but the latter I can figure out if I can just create the button below as a starter: ``` <asp:Button runat="server" OnCommand="Load_Items" CommandArgument="1" ...
2013/07/26
[ "https://Stackoverflow.com/questions/17886074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/835099/" ]
Here is how you create a Button with Command event. Once it is created, you need to find a way of displaying it. The following example uses `PlaceHolder`; you can also substitute with `Panel` if you want. ASPX ---- ``` <asp:PlaceHolder runat="server" ID="PlaceHolder1"></asp:PlaceHolder> ``` Code Behind ----------...
You need a container control on your page. Try an asp panel for example. Then in your codebehind you do panel.controls.add(btnSave); And don't forget to do it on every site load. <http://support.microsoft.com/kb/317515/en-us>
46,820,625
I'm using Kali dist so I have already installed Python 2.7, 3.5 and 3.6. Commands 'python' and 'pip' are associated with Python 2.7. But the 'python3' uses Python 3.6 while pip3 is installing packages for Python 3.5. When I tried to create an venv: ``` pip3 -p python3.6 virtualenv myenv ``` I've got an error: ``...
2017/10/18
[ "https://Stackoverflow.com/questions/46820625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You can explicitly run the `pip3` script with a particular Python version, by prefixing it with the appropriate `python3.`*x* command: ``` ldo@theon:~> pip3 --version pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6) ldo@theon:~> python3.5 $(which pip3) --version pip 9.0.1 from /usr/lib/python3/dist-packages ...
To install a package in the same version location that's associated with the version associated with python3, use the following: ``` python3 -m pip install [package] ``` to pick a specific version that you'd like your package to be associated with (so you're not guessing with the above): ``` python3.5 -m pip instal...
180,435
Is there an open source alternative (similar to ultraedit) to handle files with filesize >200 MBytes?
2008/10/07
[ "https://Stackoverflow.com/questions/180435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11723/" ]
Duplicate of [Best Free Text Editor Supporting *More Than* 4G Files?](https://stackoverflow.com/questions/102829/best-free-text-editor-supporting-more-than-4g-files "Best Free Text Editor Supporting *More Than* 4G Files?") and even [Editor to open big text files (XML export files)](https://stackoverflow.com/questions/1...
[textpad](http://www.textpad.com) will probably swallow it oops, just clocked the "open source" requirement. Typing before thinking.
40,423,753
I am new to c# and trying to insert a number from a textbox and I have adding a button to submit the number. I then want it to be added to the array and outputted onto the listbox. However, I am having the whole array outputted onto Thanksthe listbox instead. How do I only show the number being entered? ``` for (int ...
2016/11/04
[ "https://Stackoverflow.com/questions/40423753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5826303/" ]
You are not clearing your listbox first. The code below should do the job: ``` lstHoldValue.Items.Clear(); for (int i = 0; i <= MAX_ITEMS; i++) { if (i < index) lstHoldValue.Items.Add(numArray[i]);//show array in a listbox } ```
You can add : ``` lstHoldValue.Items.clear(); ``` before the loop to remove the elements of the List or juste replace the loop by : ``` listBox1.Items.Add(txtInitialise.Text); txtInitialise.Text = ""; ``` to add the elements one by one
3,171,467
I have drawn a rectangle. It is undreneath a horizontal scroll bar on screen. Now i want to zoom the rectangle. On zooming the height of rectangle increases, the location shifts up and horizontal scroll bar moves up. How to do this? I am writing this piece of code: ``` rect = new Rectangle(rect.Location.X, this.Height...
2010/07/03
[ "https://Stackoverflow.com/questions/3171467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/378805/" ]
If you simply want to scale the rectangle around the center of the rectangle then you need to increase the width and height of the rectangle and subtract half the increase from the location. This is not tested, but should give you the general idea ``` double newHeight = oldHeight * scale; double deltaY = (newHeight -...
Just add a txtZoom to your form: ``` using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.txtZoom.Text = "1"; t...
9,387,269
I'm using "acts\_as\_tree" plugin for my user messaging thread feature on my website. I have a method that makes deleting selected messages possible. The messages don't actually get deleted. Their sender\_status or recipient\_status columns get set to 1 depending on what user is the sender or recipient of the message. ...
2012/02/22
[ "https://Stackoverflow.com/questions/9387269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439688/" ]
Nowadays in Rails 4, you can do: ``` Model.where.not(attr: "something").delete_all ``` and ``` Model.where.not(attr: "something").destroy_all ``` And don't forget about difference: * destroy\_all: The associated objects are destroyed alongside this object by calling their `destroy` method. Instantiates all the r...
This worked for me in the end. ``` Message.where('id != ? AND parent_id = ?', parent_id, parent_id).where(:sender_status => 1, :recipient_status => 1).delete_all ``` Basically returns all messages of that particular conversation except the one where id == parent\_id. Whenever id == parent\_id this means it's a paren...
11,029,558
This statment is found in the graph api (https://developers.facebook.com/docs/reference/api/) > > Objects with location. The following will return information about > objects that have location information attached. In addition, the > returned objects will be those in which you or your friend have been > tagged, o...
2012/06/14
[ "https://Stackoverflow.com/questions/11029558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/410248/" ]
Well, identifying relationships and "more natural" keys can lower the need for JOINing. For example: ![enter image description here](https://i.stack.imgur.com/CqDEx.png) Since there is `Faxes.ProviderId`, you can directly JOIN `Faxes` and `Providers`. And since [InnoDB tables are clustered](http://www.ovaistariq.ne...
What you could do is make the provider-subsequent tables related to each other as [weak entities](http://en.wikipedia.org/wiki/Weak_entity) — where part of the identifying primary key of each table is dependent on another table (via a 1:N *identifying* relationship). You can model this like so: ``` providers ---------...
24,831,822
I am using asp.net 4 and c#. I have a gridview with a textbox that needs a unique value for the database. This value is to sort the data by precendence with in the database. All my other validators work but they only check the value in the one box. How do I validate that the integers are unique in that column. The ...
2014/07/18
[ "https://Stackoverflow.com/questions/24831822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3549282/" ]
The problem was: My Mac (I don't know how), changed the files charset when I copy the files to the new server. When I made the same process in a Ubuntu machine, worked very well. Thank's for the answers.
Hey i tested your nginx scenario without wordpress using my local installation and i dont have any issues with the file name. Could you double check the file location? You could try to create a simple setup without wordpress to debug your situation, and did you look at your access.log file? Enclosed is my testsetup. ...
6,075,628
![enter image description here](https://i.stack.imgur.com/hE2Xj.jpg) I am using a dual core **XP machine** with 4GB memory installed (but only **2.5GB** reported by the OS due to the 32bit fact). I am actively modifing an old JAVA application for at least a month by using lastest **Eclipse** (edit, build and run) and...
2011/05/20
[ "https://Stackoverflow.com/questions/6075628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/117039/" ]
Either use the task manager or process explorer from microsoft (http://technet.microsoft.com/en-us/sysinternals/bb896653) and check for memory hogs. If you have to reduce the amount of memory you are using, chances are it is because something else has taken it up. Also, I find the cap at 2.5GB a bit odd, as I thought t...
Can you see anything odd in the task manager? CPU utilization? The fact that you can't allocate as much memory as you used to sounds odd, but I have seen similar decrease in compilation times after an upgrade of the antivirus on one of my development machines. What happens if you disable antivirus while you do a comp...
9,619,092
I would like to process a text file (about 400 MB) in order to create a recursive parent-child-structure from the data given in each line. The data have to be prepared for a top down navigation (input: parent, output: all children and sub children). E.g. of lines to be read: (**child**,id1,id2,**parent**,id3) **132142...
2012/03/08
[ "https://Stackoverflow.com/questions/9619092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256982/" ]
From the "dirt-simple approach" side of things: Based on your problem statement, you don't need to keep id1, id2, or id3 around. Assuming that's the case, how about replacing your `HashMap<String, ArrayList<String>>` with a `HashMap<Integer, ArrayList<Integer>>`? You can use `Integer.parseInt()` to do the string-to-int...
You are really testing the boundaries of what one can doing with 1GB of memory. You could: 1. Increase Heap Space. 32 bit windows will limit you to ~1.5GB, but you still have a little more wiggle room it might be enough to put you over the top. 2. Build some type of pre-processor utility that Pre-partitions the file...
60,363
My two friends and I are going to spend quite a bit of time preparing a mega-game. It will be a weekend long gaming session with around 20 players, and the three of us as GMs. We are trying to figure out the best possible use of GM resources given the large number of players. Should we reach out for 'helpers' who aren'...
2015/04/29
[ "https://rpg.stackexchange.com/questions/60363", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/21795/" ]
Since you've specified this as system agnostic this is really just a logistics problem that boils down to "How do 3 people manage 20 people?" So we'll focus on minimizing downtime and maximizing engagement with a minimum of effort. As far as background I've run multiple con events that involved 100+ people in rotating ...
The answer by Skiptron pretty much hits all the high points. I'd like to add a couple of things to it though. **IRL Time Planning** Knowing that a break is coming will help prevent constant interruptions by players leaving the gaming area. It also gives the GM a chance to take a deep breath, gather their thoughts, a...
36,917,825
Sorry for weird title. Limited to 150 chars so couldn't use proper sentences. So let's say I've done the following to find out that something went wrong with my file stream: ``` std::ofstream ofs; do_stuff_with(ofs); // streams don't throw on error because C++ [edit: we can make them do so, but the .what()s aren't ve...
2016/04/28
[ "https://Stackoverflow.com/questions/36917825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5388586/" ]
You can always throw your own exceptions using `std::system_error`: ``` #include <cerrno> #include <fstream> #include <iostream> #include <system_error> int main() { try { std::ofstream foo{"/root/bar.baz"}; foo << "bla" << std::endl; foo.close(); if(!foo) throw st...
This is the best I could come up with. It's the "yuck" answer, but at least you can put the "yuck" in a single function and hide it away in some cpp file somewhere. std::ios covers boost streams as well, of course. Requires #ifdefs so it's a cheat. I believe Visual Studio #defines \_WIN32 by default, so at least you d...
35,488,000
I want to find the way to enter the optgroup label into the inserted search-choice item, when the user select a option. With the format `[optgroup]-[option]`. The problem is that by default there is no a clear way to do it. Any suggestions on how to achieve this behavior? Thank you in advance. This is the default be...
2016/02/18
[ "https://Stackoverflow.com/questions/35488000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2028267/" ]
**[Working fiddle](http://jsfiddle.net/PrHDH/260/)** You can achieve that by receiving a second parameter of `on()` method that contains an object with an attribute `selected` contains a `value` element if it exists or the `text` element (like the current case) : ``` $(".chosen-select").on('change', function (event,e...
This code works with multiple selects and also fixes the label when deselecting: ``` $('select').chosen().filter('[multiple]').on('change', function(event, el) { var value = el.selected ? el.selected : el.deselected; var option = $(this).find("option[value=" + value + "]"); var currentText = option.tex...
45,898,366
I am trying to capture the process number from this command ``` ps ax | grep catalina ``` to a variable in tcsh shell. So far, I am able to echo the process number to the screen using this script: ``` set pnum = `ps ax | grep catalina` echo $pnum | cut -d' ' -f1 ``` But when I try this to get the result of both...
2017/08/26
[ "https://Stackoverflow.com/questions/45898366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3618171/" ]
You can use lodash's [`_.at()`](https://lodash.com/docs/4.17.4#at) to get an array of the values in the order that you want: ```js var data = { tom: 1, jim: 2, jay: 3 }; var result1 = _.at(data, ['jim', 'tom', 'jay']); var result2 = _.at(data, ['jay', 'tom', 'jim']); console.log("['jim', 'tom', 'jay'] ...
``` function SortByKeyArray(obj, key_arr) { return key_arr.map(k => obj[k]); } ``` Or ``` let SortByKeyArray = (obj, keys) => keys.map(k => obj[k]); ``` Which is more friendly to me.
1,123,131
The number of ways in which we can form a 8 letter word from the letters of the word `DAUGHTER` such that all vowels are never occur together is My approach: As they are 5 consonants(DGHTR) and 3 vowels(AUE) we can arrange 5 consonants in `5!` ways. $$\*D\*G\*H\*T\*R\*$$ Now 6 empty slots can be filled with either al...
2015/01/28
[ "https://math.stackexchange.com/questions/1123131", "https://math.stackexchange.com", "https://math.stackexchange.com/users/125258/" ]
You haven't included the possibility of permuting e.g. the `U` and `E` in `UE` when they're together (and the same in the other two cases). When this is included, your method works: $$5! \times \left(\binom{6}{3} \times 3!+3 \times \binom{6}{2} \times 2! \times 2! \right)=36000.$$
You have forgotten to multiply by 2 in the last term because both the vowels that are together can be switched as well as the order of vowel placement. I think the better way to do this (As mentioned by Arthur) is to consider the complement i.e. think of (A,E,U) as a letter. Then the letters are (D,G,H,T,R,AEU) and th...
4,534,370
The time I used to develop applications on iPhone I was converting String to SHA1 with two combination: * Data * Key Now I am developing an Android application and I did not any example for how to calculate SHA1 With key. I am greatly appreciative of any guidance or help. --- *[The code that I currently use]* ```...
2010/12/26
[ "https://Stackoverflow.com/questions/4534370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/488434/" ]
Try something like that: ``` private String sha1(String s, String keyString) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException { SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(key); byte[] bytes = mac....
Another solution would be using apache commons codec library: ``` @Grapes( @Grab(group='commons-codec', module='commons-codec', version='1.10') ) import org.apache.commons.codec.digest.HmacUtils HmacUtils.hmacSha1Hex(key.bytes, message.bytes) ```
22,396
What is the Sanskrit term for a person who is a follower of the Buddha, i.e. a "Buddhist"? Things I tried: I searched online but couldn't find anything. I looked in the only Sanskrit I have access to, which is The Student's Sanskrit English Dictionary by Vaman Shivram Apte. It has a term in it, but the Devanagari is s...
2017/08/30
[ "https://buddhism.stackexchange.com/questions/22396", "https://buddhism.stackexchange.com", "https://buddhism.stackexchange.com/users/12009/" ]
The Sanskrit term for Buddhist is *bauddha*. This derivation is known as a "secondary derivation" (*taddhita-pratyaya*). An *-a* suffix is added, and the initial vowel is strengthened. It has the general sense of "of or relating to", and here the specific nuance of "one who follows the Buddha". Compare the more famil...
[In pāli canon](http://www.84000.org/tipitaka/pitaka_item/pali_seek.php?text=%CA%D2%C7%A1&book=1&bookZ=45), follower is sāvaka (su+ika=follower to hear dhamma from satthā [saha+attha=philosopher who has philosophy in his mind]). Sāvaka, in pāli, is **śrāvaka**, in sanskrit. This word use in every canon. You can put ...
24,154,917
I'm fairly new to JSON parsing, I'm using the Retrofit library of Square and ran into this problem. I'm trying to parse this JSON reponse: ``` [ { "id": 3, "username": "jezer", "regid": "oiqwueoiwqueoiwqueoiwq", "url": "http:\/\/192.168.63.175:3000\/users\/3.json" }, ...
2014/06/11
[ "https://Stackoverflow.com/questions/24154917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1426489/" ]
Convert it into a list. Below is the example: ``` BenchmarksListModel_v1[] benchmarksListModel = res.getBody().as(BenchmarksListModel_v1[].class); ```
Using **MPV**, in your Deserializer, put this ``` JsonObject obj = new JsonObject(); obj.add("data", json); JsonArray data = obj.getAsJsonObject().getAsJsonArray("data"); ```
64,494,948
I am trying to get a multimachine network of Hyperledger Fabric running. I encountered some errors. I was able to reproduce the same errors on a single machine in the [Fabcar example](https://hyperledger-fabric.readthedocs.io/en/release-2.1/write_first_app.html) of Fabric v2.1 by changing one line in `fabric-samples/fa...
2020/10/23
[ "https://Stackoverflow.com/questions/64494948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1280647/" ]
In the single machine case your client application is running on your local machine but the nodes (peers and orderers) are running in Docker containers on your local machine, and have hostnames like `peer0.org1.example.com`. Within the Docker network the nodes can talk to each other using their hostnames, e.g. `peer0....
For setting up the multiMachine network. The changes you have to make is on the config.json and connection.yaml ( basically connection profiles). ``` await gateway.connect(ccp, { wallet, identity: 'appUser', discovery: { enabled: true, asLocalhost: false } }); ``` The localhost Property should be set as "false" as y...
45,219
I have a PC and a laptop. my laptop is always updated, so for updating the PC I don't want to download the packages again for my PC. What I do is copying rpm files from `/var/cache/yum/i386/17/fedora/updates/packages` to the corresponding directory of the PC. Is there a better/faster way to do this? can I say yum conn...
2012/08/10
[ "https://unix.stackexchange.com/questions/45219", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/20188/" ]
What you can certainly do is create a Yum repository containing the packages from your laptop and then point your PC to use that repository for getting packages. You can create a repository by installing `createrepo` and then calling `createrepo --database /path/to/local/repository`. See [the RedHat documentation abou...
Do you really have no Internet access on the computer, or (more likely) do you just wish to avoid downloading packages twice? If the latter, one option is to use [IntelligentMirror](https://fedorahosted.org/intelligentmirror/) for your site. It will keep a copy of packages downloaded the first time, and the other comp...
19,139,066
I have the following code: ``` <html> <head> <style> div { padding:0px; } </style> <body> <div>testing123</div> <iframe src="page2.html"></iframe> </body> </html> ``` Is it possible to apply some js/css to page2.html that will change the `div { padding:0px; }` part of the parent?
2013/10/02
[ "https://Stackoverflow.com/questions/19139066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/407943/" ]
you can try to put jquery code into your `Iframe` load: ``` parent.$('body').find('div').css('padding', '10px'); ``` On your html page `page2.html` put code : ``` $(document).ready(function () { parent.$('body').find('div').css('padding', '10px'); }); ```
Yes but you have to add the codes to page2.html even if on the same domain.
3,470,900
I am developing an asp.net website using typed dataset as DAL , everything works fine until today I was about to add some new functionality to my website here is the abstract : get amount from amount\_field from user\_table and calculate something then update user\_table here is my sql query for getting amount\_field...
2010/08/12
[ "https://Stackoverflow.com/questions/3470900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/205463/" ]
Here is my version with async callback in node.js style <https://gist.github.com/4706967> ``` // tinyxhr by Shimon Doodkin - licanse: public doamin - https://gist.github.com/4706967 // // tinyxhr("site.com/ajaxaction",function (err,data,xhr){ if (err) console.log("goterr ",err,'status='+xhr.status); console.log(data)...
You can probably use omee. Its a single file containing many frequently used javascript functions like ajax request. <https://github.com/agaase/omee/blob/master/src/omee.js> to raise an ajax request you just call omee.raiseAjaxRequest with arguments params- parameters list e.g param1=param1value&param2=param2value...
2,237,803
If I have a class like this: ``` public class Whatever { public void aMethod(int aParam); } ``` is there any way to know that `aMethod` uses a parameter named `aParam`, that is of type `int`?
2010/02/10
[ "https://Stackoverflow.com/questions/2237803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
The Paranamer library was created to solve this same problem. It tries to determine method names in a few different ways. If the class was compiled with debugging it can extract the information by reading the bytecode of the class. Another way is for it to inject a private static member into the bytecode of the class...
if you use the eclipse, see the bellow image to allow the compiler to store the information about method parameters [![enter image description here](https://i.stack.imgur.com/RSLra.png)](https://i.stack.imgur.com/RSLra.png)
1,372,176
I would like to calculate the following limit: ${\lim \_{n \to \infty }}\sin \left( {2\pi \sqrt {{n^2} + n} } \right)$ I am not sure if this limit exists...
2015/07/24
[ "https://math.stackexchange.com/questions/1372176", "https://math.stackexchange.com", "https://math.stackexchange.com/users/50350/" ]
Hint: Note that $$\sqrt{n^2+n}-\left(n+\frac{1}{2}\right)=\frac{\left(\sqrt{n^2+n}-\left(n+\frac{1}{2}\right)\right)\left(\sqrt{n^2+n}+\left(n+\frac{1}{2}\right)\right)}{\sqrt{n^2+n}+\left(n+\frac{1}{2}\right)}=\frac{-1/4}{\sqrt{n^2+n}+\left(n+\frac{1}{2}\right)}.$$ Thus $$\sin\left(2\pi\sqrt{n^2+n}\right)=\sin\left(2\...
Hint: $2\pi \sqrt {n^2 +n} = 2\pi n\sqrt {1 +1/n}.$
345,762
I have the next circuit: [![enter image description here](https://i.stack.imgur.com/B4f6T.png)](https://i.stack.imgur.com/B4f6T.png) The textbook says that the capacitor is initially charged, but the current directions was selected as in schematic, why? If capacitor is charged and "+" is on upper node then the capaci...
2017/12/19
[ "https://electronics.stackexchange.com/questions/345762", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/107487/" ]
With the current directions shown, the capacitor equation *must* be set up assuming the capacitor is charging, thus: \$v=\small V\_{C0}+\frac{1}{C}\large \int\small i\_C\:dt\$ ... (1) For the resistor: \$\small v=R\:i\_R \$ and, since \$\small i\_R=-i\_C\$, we may write: \$\small v=-R\:i\_C \$ ... (2) Equating (1...
I am currently facing this same problem (im still holding my pen ), and none of the answers are satisfying to me (maybe im too dumb for those answers) so i tried different approach. I thought it in terms of physical process, i.e., current is going to decrease via resistor so, with below fig. as reference, i is going ...
4,099,432
I see these threads [UNIX socket implementation for Java?](https://stackoverflow.com/questions/170600/unix-socket-implementation-for-java) and <http://forums.sun.com/thread.jspa?threadID=713266>. The second link says that Java already supports UNIX Domain Socket. If that's true what class do I need to implement from ...
2010/11/04
[ "https://Stackoverflow.com/questions/4099432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/195457/" ]
Java cannot create or access Unix Domain Sockets without using a 3rd party (native) library. The last comment on the second link above mentions this. The first link has some good (and correct) information on it.
Netty also supports it since version 4.0.26: <https://github.com/netty/netty/pull/3344>
11,588,377
I'm running a query with joins and conflicting column names. IE: ``` results = TableA.joins(:table_b).select('table_a.id as table_a_id', 'table_b.id as table_b_id') ``` In my result, table\_a\_id and table\_b\_id are both strings. What can I do to make them integers? I feel like theres probably a way to get this to...
2012/07/21
[ "https://Stackoverflow.com/questions/11588377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/114855/" ]
Here's a tip: Don't. Use a real label, don't just dump the default text in the textbox. Besides, how does it save space? ``` <input type="text" name="name" value="Name*" /> Name*: <input type="text" name="name" /> ``` Doesn't make sense. --- If you must, just add `|| $name == "Name*"` in there.
As Kolink said, you can add `|| $name == "Name*"` to your `if` statement. Otherwise, this is more of a client side issue. If you are using JQuery, you could do something like this: ``` $('#name').attr("is_focused",0); $('#name').focus(function(){ if($(this).attr("is_focused")==0){ $(this).val(""); ...
16,015,656
``` #include <stdio.h> int a[100]; int main(){ printf("%d",a[5]); return 0; } ``` Does the above code always print '0' or is it compiler specific? I'm using gcc compiler and I got the output as '0'.
2013/04/15
[ "https://Stackoverflow.com/questions/16015656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2357362/" ]
"Global variables" are defined at *file scope*, outside any function. All variables that are defined at file scope and all variables that are declared with the keyword `static` have something called *static storage duration*. This means that they will be allocated in a separate part of the memory and exist throughout t...
File scope objects declared without explicit initializers are initialized by `0` by default (and to `NULL` for pointers). Non-static objects at block scope declared without explicit initializers are left uninitialized.
8,112,529
What's the difference between `NaN` and `Infinity`? When does `NaN` appear? What is it?
2011/11/13
[ "https://Stackoverflow.com/questions/8112529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754487/" ]
Usually happens when you divide 0 by 0. Read more here: <http://msdn.microsoft.com/en-us/library/system.double.nan.aspx>
NaN means "Not a number" and tells you that this variable of type double hasn't any value.
12,088,025
I'm using [EventMachine](https://github.com/eventmachine/eventmachine) and [Monetarily](https://github.com/eatenbyagrue/momentarily) to start e TCP server along with my rails application. This is started from `config/initializers/momentarily.rb`. My problem is that it starts also when I run rake tasks, like `db:migra...
2012/08/23
[ "https://Stackoverflow.com/questions/12088025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/105929/" ]
There's not a great way of doing this that I know of. You could copy [newrelic](https://github.com/newrelic/rpm)'s approach (check `discover_dispatcher` in [local\_environment.rb](https://github.com/newrelic/rpm/blob/master/lib/new_relic/local_environment.rb)) which basically has a list of heuristics used to detect if ...
``` unless File.basename($0) == "rake" && ARGV.include?("db:migrate") # you are not in rake db:migrate end ```
29,256,154
We have a web service with both WSE 3.0 endpoints and the newer WCF endpoints on .NET Framework 4.5. WCF is using `basicHttpBinding`. The problem is that the new **WCF bindings appear to be significantly slower (~3x)**. Does it use the same mechanism under the hood? I've read a lot about enabling WCF tracing. But wh...
2015/03/25
[ "https://Stackoverflow.com/questions/29256154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2425482/" ]
Your WCF service configuration file does not appear to have throttling values explicitly set. You may want to use performance monitor to track the WCF resources and/or adjust the default values to make sure you are not hitting the default throttle limit. Service throttling (`serviceThrottling`) allows you to even out ...
I would suggest to debug this in the following way: 1. temporarily remove all authentication and security logic from both services and see if the problem remains 2. temporarily disable any business logic and possibly simplify the schema to a single variable 3. when you say performance is slower, do you mean a single u...
139,824
Given an integer `n` as input, return a list containing `n`, repeated `n` times. For example, the program would take `5` and turn it into `[5,5,5,5,5]`. The elements need to be integers, not strings. No built-in functions that accomplish the task are allowed. This is [code-golf](/questions/tagged/code-golf "show quest...
2017/08/21
[ "https://codegolf.stackexchange.com/questions/139824", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/73598/" ]
TI Basic, 10 [bytes](http://tibasicdev.wikidot.com/one-byte-tokens) =================================================================== This assumes an empty list ``` Ans→dim(L₁:L₁+Ans ``` Here's the hex, along with the code to explain the byte count: ``` 72 04 B5 5D 00 3E 5D 00 70 71 Ans → dim( L₁ : L₁ ...
[V](https://github.com/DJMcMayhem/V), 5 bytes ============================================= ``` Du@"Ä ``` [Try it online!](https://tio.run/##K/v/36XUQelwy///pgA "V – Try It Online")
29,018,842
I've been using RStudio for years, and this has never happened to me before. For some reason, every time a function throws an error, RStudio goes into debug mode (I don't want it to). Even after using undebug() on a single function. ``` > undebug(http.get) Warning message: In undebug(fun) : argument is not being debug...
2015/03/12
[ "https://Stackoverflow.com/questions/29018842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2521469/" ]
Nothing worked for me: I had a function that when I run kept on debugging. The **solution** for me was (with caution pls): `Debug (menü) -> clear All Breakpoints ...`
I had the same issue in RStudio Cloud. It was solved by choosing a different version of R. I was using R3.6.0 and changed it to R3.5.3 (the option in in the upper right corner). It refreshed the console and the debugging stopped. And then R3.6.0 was again fine. Cheers.
2,007,666
Say a project contains several classes, each of which has a static initializer block. In what order do those blocks run? I know that within a class, such blocks are run in the order they appear in the code. I've read that it's the same across classes, but some sample code I wrote disagrees with that. I used this code: ...
2010/01/05
[ "https://Stackoverflow.com/questions/2007666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122607/" ]
See section 12.4 and 12.5 of the [JLS version 8](http://docs.oracle.com/javase/specs/jls/se8/html/jls-12.html#jls-12.4), they go into gory detail about all of this (12.4 for static and 12.5 for instance variables). For static initialization (section 12.4): A class or interface type T will be initialized immediately b...
``` class A { public A() { // 2 } } class B extends A{ static char x = 'x'; // 0 char y = 'y'; // 3 public B() { // 4 } public static void main(String[] args) { new B(); // 1 } } ``` Numbers in the comment indicate the evaluation order, the smaller, the earlier. As the example showed,...
4,132,963
Ok, here is the issue: Recently I hit an problem that I was not able to use Accelerator Keys ( a.k.a [HotKey](http://en.wikipedia.org/wiki/Hotkey)s ) on Buttons inside GroupBox. Just a minute ago I found out why, but now only problem is that this reason makes me even more puzzled than before, which is that Such *button...
2010/11/09
[ "https://Stackoverflow.com/questions/4132963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132296/" ]
Try deleting the handler from the .pas file from the declaration and the implementation sections (or copy somewhere if they contain code). Then try to recreate the handler for the button. Sometimes the IDE can get out of sync and all that can be done is to reset back to a known state. If that doesnt work see if you ca...
The components work differently in design and in runtime. Double clicking on a button in desgintime creates and adds an OnClick handler. That explains why the behavior is different. Hopefully I understand your question correctly. You have a component on your form, and you are not able to assign a correct eventhandler ...
21,919,815
I am trying to generate C# class using the JSON string from here <http://json2csharp.com/> this works fine. But I can't parse the JSON to the object generated by the website. Here is the JSON string ``` { "searchParameters":{ "key":"**********", "system":"urn:oid:.8" }, "message":" found one Person matc...
2014/02/20
[ "https://Stackoverflow.com/questions/21919815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/578739/" ]
I think you have some invalid characters in your JSON string. Run it through a validator and add the necessary escape characters. <http://jsonlint.com/>
The following function will convert JSON into a C# class where T is the class type. ``` public static T Deserialise<T>(string json) { T obj = Activator.CreateInstance<T>(); using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) { DataContractJsonSerializer serializer = new Data...
41,307,038
I'd like a function, `is_just_started`, which behaves like the following: ``` >>> def gen(): yield 0; yield 1 >>> a = gen() >>> is_just_started(a) True >>> next(a) 0 >>> is_just_started(a) False >>> next(a) 1 >>> is_just_started(a) False >>> next(a) Traceback (most recent call last): File "<stdin>", line 1, in <m...
2016/12/23
[ "https://Stackoverflow.com/questions/41307038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
This only works in Python 3.2+: ``` >>> def gen(): yield 0; yield 1 ... >>> a = gen() >>> import inspect >>> inspect.getgeneratorstate(a) 'GEN_CREATED' >>> next(a) 0 >>> inspect.getgeneratorstate(a) 'GEN_SUSPENDED' >>> next(a) 1 >>> inspect.getgeneratorstate(a) 'GEN_SUSPENDED' >>> next(a) Traceback (most recent call ...
You may create a iterator and set the flag as the instance property to iterator class as: ``` class gen(object): def __init__(self, n): self.n = n self.num, self.nums = 0, [] self.is_just_started = True # Your flag def __iter__(self): return self # Python 3 compatibility ...
61,348,127
I have functions in my react project that fire a axios call to change a users membershipType to daily, weekly or monthly in the database. They then have to manually be changed back to expired. Is there any way I can have a "timer" function to trigger another axios call to automatically change it back to Expired after a...
2020/04/21
[ "https://Stackoverflow.com/questions/61348127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12822154/" ]
`selection` is an array of [ImageAsset](https://docs.nativescript.org/api-reference/classes/_image_asset_.imageasset), so `selected.getImage()` is obviously `undefined`. It has only `getImageAsync(...)` but that returns native image data. To create [ImageSource](https://docs.nativescript.org/ns-framework-modules/imag...
this will do it ``` function onSelectSingleTap(args) { var context = imagepickerModule.create({ mode: "single" }); if (platformModule.device.os === "Android" && platformModule.device.sdkVersion >= 23) { permissions.requestPermission(android.Manifest.permission.READ_EXTERNAL_STOR...
27,273,853
I'm using List of Map in java but I get a trouble. I use : `Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); ArrayList<Map<String,AttributeValue>> maps = new ArrayList<Map<String,AttributeValue>>();` I use CSVReader to reading file and store values in ListOfMap ``` CSVReader reader = new CS...
2014/12/03
[ "https://Stackoverflow.com/questions/27273853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2845274/" ]
You are using same map to store all elements, but at start of each iteration you are calling `item.clear();` which removes previously stored elements inside map. What you should do is create new, separate map instead of reusing old one, so change ``` item.clear();//don't reuse previously filled map because it still is...
You keep using the same Map object. These are persistant objects. You'll have to instantiate a new HashMap() instead of calling clear() on the existing one. Otherwise you'll simply clear the HashMap inside of the List as well, because they refer to the same object.
28,363,467
I'm working with following document ``` { "_id" : 123344223, "firstName" : "gopal", "gopal" : [ { "uuid" : "123", "name" : "sugun", "sudeep" : [ { "uuid" : "add32", "name" : "ssss" }, { "uuid" : "fdg456",...
2015/02/06
[ "https://Stackoverflow.com/questions/28363467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4148923/" ]
`identity` just calls `eye` so there is no difference in how the arrays are constructed. Here's the code for [`identity`](https://github.com/numpy/numpy/blob/v1.9.1/numpy/core/numeric.py#L2125): ``` def identity(n, dtype=None): from numpy import eye return eye(n, dtype=dtype) ``` As you say, the main differ...
[`np.identity`](https://numpy.org/doc/stable/reference/generated/numpy.identity.html) returns a **square matrix** (special case of a 2D-array) which is an identity matrix with the main diagonal (i.e. 'k=0') as 1's and the other values as 0's. you can't change the diagonal `k` here. [`np.eye`](https://numpy.org/doc/sta...
49,518,438
There is an idiomatic approach to converting a `Pair` into a `List`: ``` Pair(a, b).toList() ``` No I am searching for the opposite process. My best approach looks like this: ``` Pair(list[0], list[1]) ``` My problem with this is that I need to make a `List` value in code first for this to work. I would love some...
2018/03/27
[ "https://Stackoverflow.com/questions/49518438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6509751/" ]
You can make this extension for yourself: ``` fun <T> List<T>.toPair(): Pair<T, T> { if (this.size != 2) { throw IllegalArgumentException("List is not of length 2!") } return Pair(this[0], this[1]) } ``` The error handling is up to you, you could also return a `Pair<T, T>?` with `null` being retu...
If you're looking for an option that is chainable (for example I came across this when mapping a list of strings that I turned into a pair by splitting), I find this pattern useful: ```kotlin yourList.let{ it[0] to it[1] } // this assumes yourList always has at least 2 values ``` Here it is in context: ```kotlin va...
33,955,634
I have measured some positions `pos`, e.g.: ``` library(dplyr) set.seed(8) data <- data.frame(id=LETTERS[1:5], pos=c(0,round(runif(4, 1, 10),0))) %>% arrange(pos) > data id pos 1 A 0 2 C 3 3 B 5 4 E 7 5 D 8 ``` How can I expand a data frame like `data` with every possible `pos` (0,...
2015/11/27
[ "https://Stackoverflow.com/questions/33955634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3375672/" ]
Probable reason - parent directive shares the same scope, that's why your event is propagated to all child directives. Solution - each directive should define its own scope, which prototypically inherits from parent. (`$root <-- parent <-- child`) ``` <!DOCTYPE html> <html ng-app="app"> <head> <script data-req...
When you braodcast data you are doing that to all child scopes. Posible solution could be this: ``` $scope.$broadcast('customEvent', { target: ['dir1', 'dir2'], someProp: 'Sending you an Object!' // send whatever you want }); ``` and then in directive one ``` $scope.$on('customEvent', function (event, dat...
17,409,755
So I have the following datasource ("/" represents tab delimited locales), and I want to get it into a JSON format. The data have no headers, and I'd like to be able to insert one for the name, the degree, the area (CEP), the phone number, the email, and the url. Not sure if this will be possible for the first column w...
2013/07/01
[ "https://Stackoverflow.com/questions/17409755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1849997/" ]
First make sure that delimiter is really what you think. You can check this by opening the file using openoffice or writing a python function to detect the delimiter using regular expressions (re module). Also make sure that lines are ending with "/n" or windows style (additional r). Header is nothing more than the fi...
There is probably an elegant, programming method to accomplish this, but the method I used was to open the .txt file in excel using 'tab' as the separator. After I opened the file, I just typed in the column headers into the first row. Piece of cake! :)
1,965,030
I have the following bash script, that lists the current number of httpd processes, and if it is over 60, it should email me. This works 80% of the time but for some reason sometimes it emails me anyways when it is not over 60. Any ideas? ``` #!/bin/bash lines=`ps -ef|grep httpd| wc -l` if [ "$lines" -gt "60" ] then ...
2009/12/27
[ "https://Stackoverflow.com/questions/1965030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56952/" ]
This probably doesn't solve your issue but you could simplify things by using `pgrep` instead.
you can do it this way too, reducing the use of grep and wc to just one awk. ``` ps -eo args|awk '!/awk/&&/httpd/{++c} END{ if (c>60){ cmd="mailx -s \047Over 60\047 root" cmd | getline } }' ```
9,529,327
I have two forms on an HTML5 page. Each form has a name and an id. The second form has an h1 element, which also has a name and an id. How do I change the text of this h1 element on the second form using plain JavaScript?
2012/03/02
[ "https://Stackoverflow.com/questions/9529327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1204236/" ]
Try: ``` document.getElementById("yourH1_element_Id").innerHTML = "yourTextHere"; ```
You can do it with regular JavaScript this way: ``` document.getElementById('h1_id').innerHTML = 'h1 content here'; ``` Here is the doc for [getElementById](https://developer.mozilla.org/fr/docs/Web/API/Document/getElementById) and the [innerHTML property](https://developer.mozilla.org/fr/docs/Web/API/Element/innert...
3,585,755
I just read this question: [Why are different case condition bodies not in different scope?](https://stackoverflow.com/questions/3585073/why-are-different-case-condition-bodies-not-in-different-scope) It's a Java question, but my question applies to both C# and Java (and any other language with this scope reducing fea...
2010/08/27
[ "https://Stackoverflow.com/questions/3585755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/160527/" ]
All it's doing is defining another scope, it's not translated into a method call. Remember that for locals, the CLR/JVM could decide not to use stack space for them at all, it could choose to utilise processor registers. In some cases, if you'll excuse the pun, it could decide to optimise out some of the locals by virt...
> > My question is, how does this work? Does it go up the stack as if it were a method call? > > > It works just like any other pair of {} used to create a new local scope. There's no difference scopewise between this: ``` void foo() { { int a = 123; } // a is gone here { // differ...
30,545,372
How can I hide both x and y axis in a bokeh plot ? I've checked and tried based on this : ``` p1= figure (... visible=None) p1.select({"type": "Axis", "visible": 0}) xaxis = Axis(plot=p1, visible = 0) ``` and like <http://docs.bokeh.org/en/latest/docs/user_guide/styling.html#axes>
2015/05/30
[ "https://Stackoverflow.com/questions/30545372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/592112/" ]
Create a figure object. So, in your example the figure object is `p1`, then `p1.axis.visible = False` If you want to specify a y or x axis, then use `p1.xaxis.visible = False` or `p1.yaxis.visible = False`
Set the axes parameters in the figure object: `p1 <- figure(xaxes = FALSE, yaxes = FALSE)` or if you also want to hide the grid lines: `p1 <- figure(xgrid = FALSE, ygrid = FALSE, xaxes = FALSE, yaxes = FALSE)` Details are here: <https://hafen.github.io/rbokeh/rd.html#ly_segments>
1,897,355
I have a loop that spawns a lot of threads. These threads contains, among other things, 2 (massive) StringBuilder objects. These threads then run and do their thing. However, I noticed that after a certain amount of threads, I get strange crashes. I know this is because of these StringBuilder, because when I reduce th...
2009/12/13
[ "https://Stackoverflow.com/questions/1897355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Consider using a `ThreadPoolExecutor`, and set the pool size to the number of CPUs on your machine. Creating more threads than CPUs is just adding overhead. ``` ExecutorService service = Executors.newFixedThreadPool(cpuCount)) ``` Also, you can reduce memory usage by writing your strings to files instead of keeping ...
As Gregory said, give the jvm, some options like -Xmx. Also consider using a ThreadPool or Executor to ensure that only a given amount of threads are running simultaneously. That way the amount of memory can be kept limited without slowdown (as your processor is not capable of running 550 threads at the same time anyw...
17,708,739
I've created app with "`phonegap create`" command. Then I switch to project dir and try to run it with "`phonegap local run android`" and I have next error message: > > Please install Android target 17 <...> > > > Android SDK is placed to C:\dev\sdk My PATH variable contains `C:\dev\sdk; C:\div\sdk\platforms\;C:\...
2013/07/17
[ "https://Stackoverflow.com/questions/17708739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2461168/" ]
It seems that for latest Cordova (3.0.6), ``` cordova platform add android ``` command only recognize Android 4.2.2(API17) SDK. After I install the API17 SDK, the error was gone. Not sure if there is a cordova command option that can specify SDK version.
I had the same problem and the very most simple way to resolve it is changing the target in project.properties to 16 and try.
2,396,529
I need to create a user configurable web spider/crawler, and I'm thinking about using Scrapy. But, I can't hard-code the domains and allowed URL regex:es -- this will instead be configurable in a GUI. How do I (as simple as possible) create a spider or a set of spiders with Scrapy where the domains and allowed URL reg...
2010/03/07
[ "https://Stackoverflow.com/questions/2396529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12534/" ]
**WARNING: This answer was for Scrapy v0.7, spider manager api changed a lot since then.** Override default SpiderManager class, load your custom rules from a database or somewhere else and instanciate a custom spider with your own rules/regexes and domain\_name in mybot/settings.py: ``` SPIDER_MANAGER_CLASS = 'mybo...
Now it is extremely easy to configure scrapy for these purposes: 1. About the first urls to visit, you can pass it as an attribute on the spider call with `-a`, and use the `start_requests` function to setup how to start the spider 2. You don't need to setup the `allowed_domains` variable for the spiders. If you don't...