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
30,003,986
When I use the class `col-lg-6` on a `panel` in bootstrap, the `panel-heading` does not fill the width of the panel. How can this be fixed? ``` <div class="container"> <div class="row"> <div class="panel panel-default col-lg-6"> <div class="panel-heading">Panel heading without title</div> <div class="panel-body"> Pan...
2015/05/02
[ "https://Stackoverflow.com/questions/30003986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4824107/" ]
Easy fix. Move the col-lg-6 to a div tag that surrounds the panel as such: ``` <div class="row"> <div class="col-lg-6"> <div class="panel panel-default"> <div class="panel-heading">Panel heading without title</div> <div class="panel-body"> Panel content <...
By giving `col-lg-6` you are giving the panel the width specified in `col-lg-6`.Instead put the panel markup inside the div containing `col-lg-6`. Here is the [live working demo](http://jsfiddle.net/abhighosh18/6un4yftz/). I am not sure if you want [this](http://jsfiddle.net/abhighosh18/6un4yftz/1/) too or not.
150,779
Problem 12 of section B of [this PDF file](http://univ.tifr.res.in/gs2015/Files/GS2013_QP_BIO.pdf) reads > > Two springs with spring constant k1 and k2 are attached to a body of mass (m) in two different > configurations in 2 cases (A and B) as shown. > > > ![springs](https://i.stack.imgur.com/FaLI5.png) > > > ...
2014/12/06
[ "https://physics.stackexchange.com/questions/150779", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/65482/" ]
You actually do not need to solve the equation at all in order to determine that, whatever the answer, it must be the same for A and B. The only difference between A and B is the direction of k1. However if you look at $F=-kx$ is always a restoring force whose magnitude is proportional to the magnitude of the displac...
Since both springs are connected effectively in parallel, the both cases will have a same equation of motion. The equation of motion: $ma = F$ $$ \tag{1} m \frac{d^2x}{dt^2} = -2kx - f\_d. $$ The variable $x$ is the displacement for the oscillator displacement from its equilibrium position, $m$ the mass, $f\_d$ is t...
84,810
I'm thinking of installing Ubuntu (for the first time) on my internal hard drive to run as a primary OS on my Acer Aspire. Want to format my hard drive altogether and either run Ubuntu solely or alongside freshly reinstalled Windows 7 (it's that time again - windows is all bugged down). Got a few questions though. **...
2011/12/03
[ "https://askubuntu.com/questions/84810", "https://askubuntu.com", "https://askubuntu.com/users/36441/" ]
> > I've read that on installation of Ubuntu we get an option of "use entire disk" - will this erase all the info on my hard drive (like > formatting in DOS)? > > > Yes. > > My Windows installation files are pre-loaded on my hard drive. If i decide to go back to Windows (can't think of a reason why, but just in...
1. Yes, to the best of my knowledge (I almost never use these options), using the entire disk will, effectively, use the entire disk. This will entail re-partitioning the disk, so the data will probably be lost. Note however that the partitioner Ubuntu uses does not, in fact, wipe all the data off the drive (like Windo...
10,993,182
Why does this work: ``` using namespace System; using namespace System::Windows::Forms; ... if( MessageBox::Show("Really do it?", "Are you sure?", System::Windows::Forms::MessageBoxButtons::YesNo) == System::Windows::Forms::DialogResult::Yes ) { Console::WriteLine("Do it!"); } ``` ..when this fails: ``` using n...
2012/06/12
[ "https://Stackoverflow.com/questions/10993182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15369/" ]
It's valid, but you'll find that one bean is overridden by the other. You'll see this in the logs as ```none Overriding bean definition for... ``` This behaviour allows you to override previously supplied bean definitions. It affects the static assembly of your app, and doesn't relate to threading/clustering as sugg...
This is valid and useful especially when you try to change the implementation of a third party bean (I mean, where you are not allowed to change the implementation of a bean) and Where you need to provide/configure some extra (merge) properties for the bean. The overriding of the bean depends upon the order of the xm...
69,090,111
I want to show data from a database that is about a specific user. I have a table when I fetch data from db. I can add user on my admin panel, but I want for each user to show specific data. I`m building a CRM. And users send data to MYSQL db. Now I fetch this data and based on username I want to create and user wi...
2021/09/07
[ "https://Stackoverflow.com/questions/69090111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16508951/" ]
Try this, You can use the functional way instead. ```js const inAscOrder = arr => arr.slice(1).every((elem,i) => elem > arr[i]); console.log(inAscOrder([1,2,5])); ```
For every element in the array, return true if it's the first element or it's greater than the previous element. ```js const isAscending = (arr) => arr.every((el, i, arr) => i === 0 || el > arr[i - 1]); console.log(isAscending([1, 2, 4, 7, 19])); console.log(isAscending([1, 2, 3, 4, 5])); console.log(isAscending([1, ...
70,329,045
So, when I request my webservice for getting download a zip file, it downloads the file content secretely and all of a sudden, the file appears in the download task bar but already downloaded full (100%) Using the following angular method: ```js const endpoint = "http://localhost:8080/download/zip" this.http.get<Blo...
2021/12/13
[ "https://Stackoverflow.com/questions/70329045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3552082/" ]
For download you have 2 ways: 1. http.get + msSaveOrOpenBlob (if its defined)/createObjectURL * you have full control over request, process and errors. E.g. u can cancel request, add additional headers, etc. * download remains in your app flow, e.g. F5 will cancel it. 2. create hidden download link and click it prog...
You can simply use this package ``` npm i ngx-filesaver ``` and ``` constructor(private _http: Http, private _FileSaverService: FileSaverService) { } onSave() { this._http.get('yourfile.png', { responseType: ResponseContentType.Blob // This must be a Blob type }).subscribe(res => { this._FileSaverServi...
72,433,152
While trying to read and write some `unsinged long long int` values to and from a file i encountered a problem when deserializing the values. The boiled down problem can be reproduced with the following code. Only sometimes bitshifting more than 32 bit result in value with leading ones. Why is that? ``` int main() { ...
2022/05/30
[ "https://Stackoverflow.com/questions/72433152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7815139/" ]
First, you need to get value of `p` ``` let countVal = document.getElementById('wordCount'); ``` Then, make an array from it by using split(separator) ``` let countArr = countVal.split(" ") ``` Finally, display it in your js ``` document.getElementById('someId').textContent = countArr.length; ```
you have same value for class and id in html , change it if possible like this ``` <span class="Word" id="word">Words Number</span> <p class="Any" id="any">Here have some text which I want to count</p> ``` Then use this jQuery code ``` $(document).ready(function(){ var myString = $("#any").text(); var countWord =...
34,313,391
I have a blogger blog and I have already successfully had the domain set to a subdomain of my website e.g <http://blog.jthink.net> But how do I actually embed the blog onto my website so that it has same header and footer as my main website ( <http://www.jthink.net> ) so it's more like the way they have done it [here]...
2015/12/16
[ "https://Stackoverflow.com/questions/34313391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1480018/" ]
I'm a bit late to the party but If you want an alternative to straight out embedding your blog you could use the the [Blogger api](https://developers.google.com/blogger/)? To my mind that would be the best solution.
iframes are best for this. Most browsers support them. Maybe you could use adobe business catalyst page templates?
105,065
I have two eyes and one mouth, both my eyes are hallowed out. My mouth won't let me talk, yet my eyes will have you shocked. For though air is what's inside, I'm one reason why many died. What am I, that causes doom? Here's a hint, *I'm in your room.*
2020/11/21
[ "https://puzzling.stackexchange.com/questions/105065", "https://puzzling.stackexchange.com", "https://puzzling.stackexchange.com/users/70545/" ]
> > Are you referring to a plug socket? > > > I have two eyes and one mouth, > > A plug socket has three holes at least in some places. Up side down it looks like two eyes and a mouth > > > both my eyes are hallowed out. > > They are the two holes at the bottom > > > My mouth won't let me talk, yet ...
Is the answer: > > An electric socket > > > my eyes will have you shocked. > > its speaking of literal current shock and not the feeling / emotion. > > > I'm one reason why many died. What am I, that causes doom? Here's a hint, I'm in your room. > > Electric shock is fairly common reason of death and...
1,852,299
I wanna print the value of b[FFFC] like below, ``` short var = 0xFFFC; printf("%d\n", b[var]); ``` But it actually print the value of b[FFFF FFFC]. Why does it happen ? My computer is operated by Windows XP in 32-bit architecture.
2009/12/05
[ "https://Stackoverflow.com/questions/1852299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225413/" ]
`short` is a signed type. It's 16 bits on your implementation. 0xFFFC represents the integer constant 65,532, but when converted to a 16 bit signed value, this is resulting in -4. So, your line `short var = 0xFFFC;` sets var to -4 (on your implementation). 0xFFFFFFFC is a 32 bit representation of -4. All that's happe...
use **%hx** or %hd instead to indicate that you have a short variable, e.g: ``` printf("short hex: %hx\n", var); /* tell printf that var is short and print out as hex */ ``` **EDIT**: Uups, I got the question wrong. It was not about printf() as I thought. So this answer might be a little bit OT. **New**: Beca...
42,874,927
I use Thymeleaf 3.0.3 with Spring Boot 1.5.1 and STS Bundle 3.8.1. My Hungarian non-ASCII characters are not shown properly. I have the following configuration in the application.properties file: ``` spring.thymeleaf.cache=false spring.thymeleaf.mode=HTML5 spring.thymeleaf.encoding=utf-8 ``` These are anyway the def...
2017/03/18
[ "https://Stackoverflow.com/questions/42874927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6184153/" ]
I had same problem. I have found solution, that workerd for me: You need to save the file as Encode in UTF-8 without BOM. It works for me. Steps: 1. Edit the file in notepad++ and have a copy of these content in one more file. 2. Go to menu Encoding and choose Encode in UTF-8 without BOM. 3. If your file shows som...
You need to set encoding in the viewResolver ``` @Bean public ThymeleafViewResolver thymeleafViewResolver(){ ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); viewResolver.setTemplateEngine(templateEngine()); viewResolver.setCharacterEncoding("UTF-8"); return viewResolver; } ```
4,604,247
We are using a website with some forms that have Javascript layover images over its radio buttons and checkboxes. These work well on IE7 upwards and Firefox, Safari etc. on Windows and Mac. The images layover the radio buttons/checkboxes using special javascript from Prototype and a plugin called "Protocheck" which we ...
2011/01/05
[ "https://Stackoverflow.com/questions/4604247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/545697/" ]
You can download Xcode, which comes with an iPhone and iPad simulator. You could then run the simulator and load your website in Safari on either of the devices to test your customer issues. Xcode Download: <http://developer.apple.com/technologies/xcode.html>
I have found the solution for this. Posting so everyone will know. In Iphone and I pad you will need to have an "OnClick" event even if you do not need one. Because otherwise if you are using something like I have described above (protocheck) it will not take that elemet as a clickeble one. So solutin is having a fake ...
7,670,227
I used to work on MonoDevelop 2.6 with MonoTouch 4.2. It's cool and everything is fine. Later, when MD 2.8 came out, I installed it with MD 2.6 side by side (just renamed MD 2.6 as MonoDevelop 2.6). But I can not load iOS projects. And, there is no iOS project templates showing up in new solution window. I tried to u...
2011/10/06
[ "https://Stackoverflow.com/questions/7670227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/620138/" ]
Using the `shape` and `size` works well when you define a two dimension array, but when you define a simple array, these methods do not work For example : ``` K = np.array([0,2,0]) ``` `K.shape[1]` and `numpy.size(K,1)` produce an error in python : ``` Traceback (most recent call last): File "<ipython-input-46-e...
![enter image description here](https://i.stack.imgur.com/czNKt.png) this is a simple example, and you can follow it.By the way,the last statement should be corrected as "print b.shape[0]"
35,664,473
I'm trying to add adverts to my UWP app so I thought I'd follow up the walkthrough provided by Microsoft i.e. [Windows 10 Advertising SDK Walkthrough](https://msdn.microsoft.com/library/mt125365(v=msads.100).aspx), but I can't get it to work. I've followed the steps i.e. 1. Added a reference to `Microsoft Advertising...
2016/02/27
[ "https://Stackoverflow.com/questions/35664473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/815847/" ]
For UWP app, please install Microsoft Universal Ad Client SDK(<https://visualstudiogallery.msdn.microsoft.com/401703a0-263e-4949-8f0f-738305d6ef4b>) and use AdMediatorControl. References: * [Install the Universal Ad Client SDK](https://msdn.microsoft.com/en-us/windows/uwp/monetize/install-the-microsoft-universal-ad-c...
It says on the walkthrough that it's a preview document, probably not official sdk release. Try this one [New advertising features and walkthrough of using Microsoft ads and mediation](https://blogs.windows.com/buildingapps/2015/10/08/new-advertising-features-and-walkthrough-of-using-microsoft-ads-and-mediation/)
56,906,685
I test the app on a physical device (Samsung Galaxy J4+). I open it and enter data (destined for *SharedPreferences*). Then ... *SharedPreferences* **do not load** when tapping the app icon after having made the app UI disappear using the "<" button at the bottom of my Samsung screen, but they **do load** when tapping...
2019/07/05
[ "https://Stackoverflow.com/questions/56906685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1841607/" ]
If I'm not wrong, what is going on is that at the moment you are importing work func from bar.py, the default argument is executed, and doesn't matter if you change the value later, because the default argument was already "declared" on the import, since the default arguments are evaluated just once
I think when the the compiler sees this: ``` def work(val=global_val[0]) ``` the default value of val will be what global\_val[0] were at that time. Setting it to something different later on will not change the function definition, i.e. set the val variable to 0 (which is the first element of global\_val) if no arg...
21,095,366
I'm to post to a table in my localhosted MySQL database, but when i run the script the page stays white but there is nothing posted in the table. I'll add my code for clarification. Im using USBWebserver to host the apache and MySQL server on. ``` <?php //connectie leggen met input data //$con = //variablen inpu...
2014/01/13
[ "https://Stackoverflow.com/questions/21095366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2960417/" ]
Your columns and values do not match. You are attempting to insert 8 values into 9 columns. Specifically, it appears you are missing a `calendarid`. Second, your strings need to be wrapped in quotes. Finally, you are vulnerable to SQL injections. Consider using [prepared](http://www.php.net/manual/en/mysqli.prepare...
You need to use quotation for values. You have 9 attributes and 8 values. You have missed one value in your query.Set another value in your query and **Try this:** ``` <?php //connectie leggen met input data //$con = //variablen input invullen (bijv $gebruikeragenda = $_POST['gebruikeragenda']; $...
34,428,891
A very quick question - does it matter at all for the optimal performance whether the type of the script is specified before or after the source path? ``` <script type="text/javascript" src="/myjavascript.js"></script> ``` vs ``` <script src="/myjavascript.js" type="text/javascript"></script> ``` Similarl...
2015/12/23
[ "https://Stackoverflow.com/questions/34428891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4330769/" ]
it doesn't matter which comes first and which comes last. what matters is that the src attribute links to the correct location of the script source. for formality (and because i grew with it) i always add a type = "text/javascript": ``` <script type = "text/javascript" src = "{link-to-js-file}"></script> ``` but a...
It doesn't matter. But for HTML5, we don't require to specify type="text/javascript"
196,105
Reading the comments to this [answer](https://softwareengineering.stackexchange.com/a/196028/16898), specifically: > > Just because you can't write a test doesn't mean it's not broken. Undefined behaviour which usually happens to work as expected (C and C++ are full of that), race conditions, potential reordering due...
2013/04/25
[ "https://softwareengineering.stackexchange.com/questions/196105", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/16898/" ]
After having been in this crazy business since about 1978, having spent almost all of that time in embedded real-time computing, working multitasking, multithreaded, multi-whatever systems, sometimes with multiple physical processors, having chased more than my fair share of race conditions, my considered opinion is th...
The best tool I know for these sort of problems is an extension of Valgrind called [Helgrind](http://valgrind.org/docs/manual/hg-manual.html). Basically Valgrind simulates a virtual processor and runs your binary (unmodified) on top of it, so it can check every single access to memory. Using that framework, Helgrind w...
10,963,710
**Problem:** I am stuck in figuring out how to add a string in a variable to a number of different strings using PHP. **Variable:** ``` $insert = 'icon-white'; ``` **Strings are in a variable called $hyperlink:** ``` $hyperlink = '<i class="icon-home"></i>'; ``` **Desired output:** ``` <i class="icon-home icon...
2012/06/09
[ "https://Stackoverflow.com/questions/10963710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1045160/" ]
This is how to use `preg_replace()` php function to fit your needs : ``` $ php -a Interactive shell php > $oldvar = '<i class="icon-home"></i>'; php > $newvar = preg_replace('/(.*?".*?)"(.*)/', '\1 icon-white"\2 ', $oldvar); php > echo $newvar; <i class="icon-home icon-white"></i> ```
When rendering the output, you could do; ``` <i class="icon-home <?= $insert ?>"></i> ``` if you don't want it to be conditional. If you have a variable; ``` $i = '<i class="icon-home"></i>'; ``` you can do; ``` $i = '<i class="icon-home ${insert}"></i>'; ```
14
Is there any written proof/documentation that Robin Hood ever existed? Did he ever get arrested and got his name written in the prison books or something like that?
2011/10/11
[ "https://history.stackexchange.com/questions/14", "https://history.stackexchange.com", "https://history.stackexchange.com/users/16/" ]
* The surname 'Hood' implied where the individual was from. For all purposes, there were many people with the last name. The name Robin Hood is accounted as not an uncommon name in the middle ages. * There is a corpus of [evidence](http://www.bbc.co.uk/history/british/middle_ages/robin_01.shtml) that there were outlaw ...
A good source on the historical Robin Hood is James Clarke Holt's book [Robin Hood](https://www.amazon.co.uk/Robin-Hood-J-C-Holt/dp/0500275416). Within, you will learn that there was no single one Robin Hood, but a corpus of ballads and stories that may have some basis in reality.
6,102,190
I have the below code which prints out lines of text as long as the lines aren't empty: ``` $textChunk = wordwrap($value, 35, "\n"); foreach(explode("\n", $textChunk) as $textLine) { if ($textLine!=='') { $page->drawText(strip_tags(ltrim($textLine)), 75, $line, 'UTF-8'); ...
2011/05/23
[ "https://Stackoverflow.com/questions/6102190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239768/" ]
Use [substr](http://php.net/substr) to check the first two characters: ``` if ($textLine !== '' && substr($textline, 0, 2) !== 'T:') ```
``` $textChunk = wordwrap($value, 35, "\n"); foreach(array_filter(explode("\n", $textChunk)) as $textLine) { if (strncmp('T:', $textLine,2) !== 0) { $page->drawText(strip_tags(ltrim($textLine)), 75, $line, 'UTF-8'); $line -=14; } } ``` At all `strncmp()` is slightly faster than `substr()`.
400,918
I have an Apache Proxy setup in front of an HTTP daemon process that serves a Sinatra web application with the following Directives (which work great) ``` ProxyPass / http://ip-ad-dr-ess:8080/ ProxyPassReverse / http://ip-ad-dr-ess:8080/ ``` This allows me to browse <http://example.com> and served the content from t...
2012/06/21
[ "https://serverfault.com/questions/400918", "https://serverfault.com", "https://serverfault.com/users/107757/" ]
You should try adding a trailing slash the path "/blog" like this ``` ProxyPass /blog/ http://blog.example.com/ ProxyPassReverse /blog/ http://blog.example.com/ ```
I was able to solve this issue. The root cause was that the I setup a proxy from one virtualhost to another on the same ip and the same port. I changed the `blog.example.com` to listen on a different port, updated the proxy values in `http://example.com` which resolved the problem
42,137,529
If I have a series that has either NULL or some non-null value. How can I find the 1st row where the value is not NULL so I can report back the datatype to the user. If the value is non-null all values are the same datatype in that series.
2017/02/09
[ "https://Stackoverflow.com/questions/42137529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1087908/" ]
You can use [`first_valid_index`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.first_valid_index.html) with select by `loc`: ``` s = pd.Series([np.nan,2,np.nan]) print (s) 0 NaN 1 2.0 2 NaN dtype: float64 print (s.first_valid_index()) 1 print (s.loc[s.first_valid_index()]) 2.0 # If y...
You can also use `get` method instead ``` (Pdb) type(audio_col) <class 'pandas.core.series.Series'> (Pdb) audio_col.first_valid_index() 19 (Pdb) audio_col.get(first_audio_idx) 'first-not-nan-value.ogg' ```
651
I've always wondered why refrigerators don't have some of their parts located outdoors like an air conditioner. In warm weather, it seems like it would make sense to have the condenser outside like an AC unit to avoid heating the room. In cold weather, it seems like it would be much more efficient to have the condense...
2015/02/14
[ "https://engineering.stackexchange.com/questions/651", "https://engineering.stackexchange.com", "https://engineering.stackexchange.com/users/161/" ]
The cost of installing and maintaining a split refrigeration system for cabinet style refrigerators would swamp the cost of the refrigerator itself. For large refrigerated rooms, or whole house cooling systems, the cost of the entire system is greater than the cost of the labor and maintenance. Given mass manufacturi...
Modern materials would make separation an easy thing to do. Homes could be built with ducting to accommodate such a system. Right now a length of tubing is already used for the water supply for an ice maker. The connections can be designed to fit together without venting problems requiring re/filling the system. Many r...
437,046
I'm coding an enum strategy pattern where one of the strategies makes use of an `ScheduledExecutor`: ``` class ControllerImpl { //... boolean applyStrat(StratParam param) { getStrat().apply(param); } //... private enum Strats { NOOP (NoopStrategyImpl.class), REAL (RealtimeSt...
2022/02/28
[ "https://softwareengineering.stackexchange.com/questions/437046", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/248892/" ]
I think you are on the right track. You want the `Player` object to allow autonomous movement, but without putting too much knowledge about the "outer game mechanics" into it. A "grabbed" state inside the player does not fit to this design, and you are perfectly right: introducing such attributes which are only useful ...
If you update positions of your characters iteratively based on their properties you could add some extra conditions that are outside the scope of the object itself. This would nicely reflect the powerless nature of a grabbed character. Say some boss grabs your player, rather than flagging the player as grabbed you co...
5,988,246
When testing in python shell, I always have to type some import like: ``` Python 2.5.4 (r254:67916, Jun 24 2010, 15:23:27) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>import sys >>>import datetime ``` Can someone help me to automatically finish these? It means I ...
2011/05/13
[ "https://Stackoverflow.com/questions/5988246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/371973/" ]
Try: ``` python -i -c "import sys; import datetime;" ``` More info: ``` -i : inspect interactively after running script; forces a prompt even if stdin does not appear to be a terminal; also PYTHONINSPECT=x ``` & ``` -c cmd : program passed in as string (terminates option list) ```
Create a file with the commands you want to execute during startup, and set the environment variable `PYTHONSTARTUP` to the location of that file. The interactive interpreter will then load and execute that file. See <http://docs.python.org/tutorial/interpreter.html#the-interactive-startup-file> On a sidenote, you mig...
45,761,270
I am trying to manually add an additional attribute to parameters in the controller after completing a form. The params seem to be wrapped in , which seems to be preventing me to from changing the params. **Controller:** ``` class ActualsController < SignedInController ... def update respond_to do |format| fac...
2017/08/18
[ "https://Stackoverflow.com/questions/45761270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2452324/" ]
Try something like ``` private def post_params params.require(:post).permit(:some_attribute).merge(user_id: current_user.id) end ```
Try to whitelist the params instead of using .except Also try to use .permit() to whitelist the required params
1,565,724
If I have a `list<object*>>* queue` and want to pop the first object in the list and hand it over to another part of the program, is it correct to use (sketchy code): ``` object* objPtr = queue->first(); queue->pop_first(); return objPtr; // is this a pointer to a valid memory address now? ``` ? According to the d...
2009/10/14
[ "https://Stackoverflow.com/questions/1565724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189793/" ]
Yes, it is a valid pointer. List will not release the memory allocated by you. List will destroy its internal not the user object.
**Yes `objPtr` contains pointer to a valid memory.** When you insert an element into a `std::list`, `list` makes a copy of it. In your case the element is an address (a pointer) so list makes a copy of the address and stores it. ``` object * optr = queue->pop_front(); ``` optr now points to the object ``` queue->p...
2,385,022
Is it possible to write any rational number (say 1 or 2 or .15) using a number system that was base pi instead of a number system that used a rational number as its base?
2017/08/06
[ "https://math.stackexchange.com/questions/2385022", "https://math.stackexchange.com", "https://math.stackexchange.com/users/462242/" ]
EDIT : The issue : The general setup for a given base $b$ is to write a given Real number $a$ as $a\_0 b^0 + a\_1b^1+....+a\_k b^k$ with $a\_k$ an integer less than the floor of $b$. EDIT 2: STILL needs some work, which I am doing right now. Will be back soon to rewrite, or, if necessary, delete. Comments are welcome...
We can write rational numbers in irrational bases; easily shown by $100$ base $\sqrt 2$ is 2. There are in fact problems and papers that I have seen that use base phi, $\frac{\sqrt 5 + 1}{2}$. However, because pi is transcendental, it is not the solution of any polynomial with rational coefficients. This means that n...
1,619
For this site to succeed, we need enough "experts" (meaning, for example, graduate students, academic economists, or professional economists) around to provide high quality answers. I am interested to hear from experts about their views of various types of question we get on the site. What kind of questions do you mos...
2016/09/15
[ "https://economics.meta.stackexchange.com/questions/1619", "https://economics.meta.stackexchange.com", "https://economics.meta.stackexchange.com/users/108/" ]
**Vote up if you agree with the following:** I like to see/answer questions in which laymen ask economists to explain phenomena they observe (such as why celebrities are paid so much). * Putting economics to work to explain such phenomena is an interesting challenge or good practice for doing research. * This helps me...
**Vote up if you agree with the following:** I like to see/answer homework style questions on this site (provided effort is showin in accordance with site policy). * If a student has put in some effort and needs a few pointers then I don't mind helping. * A key role for this site should be to support the education of ...
57,193,502
Suppose I use python zeep to execute a query against a server like this: ``` from zeep import Client wsdl_url = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL" client = Client(wsdl_url) result = client.service.ListOfContinentsByCode() ``` I would like to see the raw XML that c...
2019/07/25
[ "https://Stackoverflow.com/questions/57193502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/699285/" ]
I think what you are looking for is the history plugin. ```py from zeep.plugins import HistoryPlugin from zeep import Client from lxml import etree wsdl_url = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL" history = HistoryPlugin() client = Client(wsdl_url, plugins=[history]) c...
Here (requests [takes care](https://2.python-requests.org//en/master/user/quickstart/#binary-response-content) of the gzip) ``` import requests r = equests.get('http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL') if r.status_code == 200: print(r.content) ```
93,979
Personally, I never saw the smartphone coming, but maybe science-fiction did. Basically, I'm looking for the first science fiction story (if one exists) where people commonly have a device which can perform the general tasks of a smartphone today, namely: * Being able to communicate, both personally and to the communi...
2015/06/28
[ "https://scifi.stackexchange.com/questions/93979", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/22917/" ]
Seems like Jerry Pournelle and Larry Niven beat Clarke by a couple of years with "The Mote in God's Eye" from 1974. In that book, people are constantly using pocket computers. They contain large amounts of personal data, have calendars, can connect with other computers to call up even more information and are used to ...
While numerous stories have anticipated such device, I want to make a note that, in some broad sense, you're asking about the commercially successful product and its function, and not of a technology. And it also seems that 60's videophones are pretty far from the commercial products of these days, so here's a lot of b...
2,524,292
How can we prove for $a$, $b$ and $c$ positive integers that if $$\gcd(a,b)=\gcd(b,c)=\gcd(a,c)=d$$ then $$\gcd(a,b,c)=d$$ For $a$ and $b$ co-prime numbers, $\gcd(a,b)=1$, means that the pairs $(b,c)$ and $(a,c)$ are also co-prime numbers, then from the $\gcd$ commutativity and associativity: $$\gcd(a,b,c)=\gcd(\gc...
2017/11/17
[ "https://math.stackexchange.com/questions/2524292", "https://math.stackexchange.com", "https://math.stackexchange.com/users/503678/" ]
Let us merely assume that $\gcd(a,b)=d$ and that $d$ divides $c.$ Clearly, $d$ is a common divisor of $a,b,$ and $c.$ Let $e$ be any other common divisor of $a,b,$ and $c.$ Since $e$ is a common divisor of $a$ and $b,$ it follows that $e$ divides $\gcd(a,b)=d.$ Hence $d$ is the greatest common divisor of $a,b,$ and $c....
If $gcd(a,b)=d\Rightarrow a=md,b=nd$ with $ m,n\in\mathbb{N}$ and so $gcd(m,n)=1$. If $gcd(m,n)=1$, then $gcd(n,m,k)=1$ for any $k\in\mathbb{N}$. Can you work out from here?
49,992,423
I am creating a React app using `Next.js` and am trying to use components provided by `reactstrap`. The issue I seem to be running into seems to involve importing the CSS file named `bootstrap/dist/css/bootstrap.min.css` as the `reactstrap` guide says to do. The error I am seeing is `Error in bootstrap/dist/css/boots...
2018/04/24
[ "https://Stackoverflow.com/questions/49992423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3723821/" ]
**EDIT: As of Next.js 7**, all you have to do to support importing .css files is to register the [withCSS](https://github.com/zeit/next-plugins/tree/master/packages/next-css) plugin in your next.config.js. Start by installing the plugin: ``` npm install --save @zeit/next-css ``` Then create the `next.config.js` file...
If you are still getting the error: ``` Unexpected token (6:3) You may need an appropriate loader to handle this file type. ``` try this in your next.config.js: ``` // next.config.js const withCSS = require('@zeit/next-css') module.exports = withCSS({ cssLoaderOptions: { url: false } }) ``` 3. Now you ...
605,110
I have a flat file containing columns of data representing fields from a table. I get the file from an outside source and want to insert the data into a table in my database. Unfortunately, the file I receive is missing a field in a specific column (new field that was added). Since I have no control of what is being se...
2020/08/18
[ "https://unix.stackexchange.com/questions/605110", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/428811/" ]
You can use a counted RE. For example, `x{12}` will match 12 `x` characters, and `y{1,3}` would match 1, 2, or 3 `y` characters. Here we're going to use `.{30}` to match 30 character wildcards (i.e. 30 of any character). The `\1` in the result string matches the bracketed reference in the pattern match ``` sed -r 's#^...
You can also try it with `awk` ``` awk '{sub(/^.{30}/,"&213 ")}1' file ``` This will append `213` to the pattern consisting of the first 30 characters of the line, no matter what they are. The syntax is as follows: * The `sub()` function is used to substitute *the first* occurence of the specified regular express...
330,997
What I am trying to do is to digitally send a signal through a cat5 cable. I wan't to send it digitally so people can't just come along and put a voltage on the wires to activate the circuit. I would like the signal to come from the main control board. Thanks.
2017/09/24
[ "https://electronics.stackexchange.com/questions/330997", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/-1/" ]
Depending on your skills, budget and time schedule, then anything we suggest might be too complicated, expensive or time consuming etc. for you to use in your design. However I'll mention one technology which fits your stated desire to "send some bytes" through the cable, to operate the lamp attached to the "Main Box"....
You don't want to actually use Ethernet signalling, just use the cable (unless you have some other requirement for Ethernet signalling) Some simple serial scheme between minimal microcontrollers would work. Annoyingly propriety laptop supplies sometimes do this. Note that short of a cryptographic scheme it can be rev...
34,702
Because my C: drive is just a 40gig SSD and space is an issue with it, I tend to keep games from saving files, DLC and screenshots there. I've changed my 'Documents' target on Windows 7 to target a folder on my D: drive. However, Sims 3 doesn't seem to care about this and keeps creating files at Username\My Documents...
2011/11/09
[ "https://gaming.stackexchange.com/questions/34702", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/13898/" ]
I'm guessing the game has been hard coded to use C:\ instead of checking where the documents directory is, you could use a [NTFS Symbolic Link](http://en.wikipedia.org/wiki/NTFS_symbolic_link) to workaround it. This will essentially create a shortcut, that programs will actually follow it properly. To create one you w...
Try uninstalling it then when you re-install it, use the custom download option and set it where you want it to save, unless that's what you mean when you said, "I've changed my 'Documents' target on Windows 7 to target a folder on my D: drive."
27,137,486
I have a list of line number for a given file. Now I want to insert a specific line before each of these lines in the file. How is it possible to do using C++ file operations. I know that `tellg()` would give location of character in file, but how do I get the line and print just before that line.
2014/11/25
[ "https://Stackoverflow.com/questions/27137486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2277510/" ]
1. Create the class with `main()` method: ```java public class Test1 { public static void main(String[] args) { System.out.println("hello1"); } } ``` 2. Hit `ctrl``shift``F10` (or `ctrl``shift``R` for Mac) It will compile, assemble and print `hello1`
Solution: 1. Execute run \* \* main() with coverage; 2. Modify gradle.xml under. Idea < GradleProjectSettings> Add a row under the label node < option name=”delegatedBuild” value=”false” /> <https://programmerah.com/tag/android/page/2/>
467,255
I currently rely on anchor tags to perform AJAX requests on my web application (using jQuery). For example: ``` <script type="text/javascript"> $(document).ready(function() { $("#test").click(function() { // Perform AJAX call and manipulate the DOM }); }); <a id="test" href="">...
2009/01/21
[ "https://Stackoverflow.com/questions/467255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
One option (for which I'm sure I'll get downvoted), is to not bother with people who have javascript off. Display a message in a `<noscript>` tag informing the user that your site requires Javascript. It'll affect two groups of people: those who have knowingly disabled javascript and presumably know how to turn it bac...
Your best bet for no-JS would probably be to have a form with a submit button, and point the form's action to your URL. You can style the button to look like a link (or like anything else): ``` <button class="linkstyle" type="submit">Foo</button> <style type="text/css"> button.linkstyle { border:none; background:none...
47,081,354
Hello I have two tables Let's called them table schedule and table appointments **Schedule table:** ``` +----+ | id | +----+ | 3 | | 42 | +----+ ``` **Appointment table:** ``` +----+-------------+ | id | schedule_id | +----+-------------+ | 1 | 0 | | 2 | 42 | +----+-------------+ ``` I ha...
2017/11/02
[ "https://Stackoverflow.com/questions/47081354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/978970/" ]
Character constant `'2'` in the ASCII table has code 50. So using the format specifier `%d` the character is displayed as an integer that is its value 50 is displayed. As for this expression ``` a[1] - '0' ``` then as it has been said `a[1]` that represents the character `'2'` stores the ASCII value `50`. The chara...
C specifies that the codes for characters `'0'`, `'1'`, `'2'`, ... `'9'` are sequential. `'0' + 3` must equal `'3'`. This applies for any character set: the common [ASCII](https://en.wikipedia.org/wiki/ASCII) or others. Subtraction from `'0'` yields the numeric difference. ``` printf("%d",'2' - '0'); // must pr...
502,835
Is there a relay that will work with 12V / 300ma input to close a Normally Open output? I've been trying to make it work with Ardouino board and a HiLetgo 12V 1 Channel Relay Module With Optocoupler Isolation Support High or Low Level Trigger, but have not been able to get it to work. Seems like there should be a simpl...
2020/05/30
[ "https://electronics.stackexchange.com/questions/502835", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/253982/" ]
Here's the end product - worked as expected [![enter image description here](https://i.stack.imgur.com/oI463.png)](https://i.stack.imgur.com/oI463.png)
Just use a 12V relay - most small 12V relays will have 200 ohm or more coil resistance and thus use much less than 300mA to operate. - for 300mA coil resistance as low as 40 ohms would work. Add a diode parralel to the relay coil to prevent back-emf problems.
18,088,795
Why does the following code throw an exception? Note that the file is a `/proc/pid/stat` file so it could be interfered by the kernel. ``` // Checked that file does exist try { std::ifstream file(path.c_str()); // Shouldn't even be necessary because it's the default but it doesn't // make any difference. file...
2013/08/06
[ "https://Stackoverflow.com/questions/18088795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118863/" ]
Update 2 -------- I've even tried to force an error by manually setting tiny or huge buffer sizes: ``` std::filebuf fb; // set tiny input buffer char buf[8]; // or huge: 64*1024 fb.pubsetbuf(buf, sizeof(buf)); fb.open(path.c_str(), std::ios::in); std::istream file(&fb); ``` I've verified th...
I consistently get this error on g++ 4.5 when I attempt to read from a file corresponding to an exited process (so the file no longer exists). Here's a test case: ``` #include <iostream> #include <fstream> int main(int argc, char** argv) { if(argc!=2) { std::cerr << "Usage: " << argv[0] << " /proc/PID...
37,620,072
I need to get a list of unique email addresses across 2 table. For example I have the selects: ``` select distinct email from contacts order by email select distinct email from customers order by email ``` If I only needed one of those, piece of cake. If I wanted them as 2 columns side...
2016/06/03
[ "https://Stackoverflow.com/questions/37620072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/509627/" ]
**Clear Data** will clear everything, Shared Preference, Cache, DB. If you really want to clear only shared preference (some/all) you can do it programmatically by iterating over Shared Preferences like this: ``` Map<String, ?> allEntries = prefA.getAll(); for (Map.Entry<String, ?> entry : allEntries.entrySet()) { ...
There is an option to put a database in apk [directly](https://github.com/jgilfelt/android-sqlite-asset-helper). Of course if you use already completed database in your case
312,180
tl;dr ----- We rolled out some improvements for how you track the topics you are interested in for your favorite Q&A sites. This feature used to be called Favorite Tags. We are renaming it Tag Watching. Naming is hard, but we think this better captures the value of the feature. There were a number of confusing element...
2018/07/05
[ "https://meta.stackexchange.com/questions/312180", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/354333/" ]
**Please de-emphasize the Unwatch button** The unwatch button in really inviting and asks to be pressed as 'main' action in the tag-section. This is OK if you accidentally added the tag, but for a normal workflow this is not what a user wants to do. See this image: [![enter image description here](https://i.stack.im...
### Font size of "edit" is too big [![enter image description here](https://i.stack.imgur.com/DAhXt.png)](https://i.stack.imgur.com/DAhXt.png) The font size of "edit" should not be bigger than the tags below. This would be consistent with the "edit" links for questions and answers which are also set in a smaller font...
52,283,528
``` var array = []; document.querySelectorAll("a").forEach(array.push); //Uncaught TypeError: Cannot convert undefined or null to object ``` Why does this fail? what does this error mean? It seems perfectly reasonable to pass an array method as a function, what am I not understanding/seeing?
2018/09/11
[ "https://Stackoverflow.com/questions/52283528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9464185/" ]
`array.push` loses context (its `this`), so you need to pass a function with context captured. But, even if what you wanted worked - you still would not get the result you want, since `NodeList:forEach` passes 3 arguments to the callback function, so you would fill your `array` with elements, indexes and the list of n...
I'm not 100% sure what you're trying to do, but I'm going to guess that you'd like to push the elements returned by querySelectorAll into 'array'. In which case, you can't just pass the function push to forEach, you must call push on array with each element as the argument, like so: ``` document.querySelectorAll("a")....
21,482,103
In Eclipse the auto complete is very very strict. Is there a way to have it slightly looser? For instance: ``` getData() setData() ``` I want to type "data", and have the two functions above be found but because both functions have "get" or "set" at the start, it doesn't suggest these functions, I have to type `get`...
2014/01/31
[ "https://Stackoverflow.com/questions/21482103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387015/" ]
Unfortunately there is no preferences setting to enable or change that. There are several ways to tweak the behavior of Content Assist under **Preferences** > **Java** > **Editor** > **Content Assist**, such as enabling "camel caps" matching (eg, typing `gD` will find`getData()`), but I see nothing about sub-string mat...
Even better with [Eclipse 4.17 July 2020](https://www.eclipse.org/eclipse/news/4.17/jdt.php#content-assist-substring-types): > > Substring/Subword matches for types > ----------------------------------- > > > > > Content Assist now fully supports both substring and subword matches for types: > > > [![https:/...
7,945,756
If I defined a char buffer like below ``` char buffer[20] = "foo"; ``` then ``` buffer[0] == 'f'; buffer[1] == 'o'; buffer[2] == 'o'; buffer[3] == 0; ``` What does the standard say about **buffer[4]** to **buffer[19]**. Are they guaranteed to be intialized to zero as well ?
2011/10/30
[ "https://Stackoverflow.com/questions/7945756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/764882/" ]
All remaining elements guaranteed to be intialized to zero. Reference: **C++03 Standard section 6.7.8 para 21:** > > If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than t...
A lot of compilers will initialize the content of buffer[20] to 0. It is especially true if you initialize it with {} You can check your compiler's behaviour using something like this: ``` #include <stdio.h> int main() { char buf1[20] = "foo"; char buf2[20] = {}; int i; for(i = 0; i ...
21,126,287
I'm trying to add a click bind to the `icon-next` class if the `td` element doesn't have the `ui-disabled` class without using if statements if possible (no pun). ``` $(".icon-next:not(.ui-disabled)").bind('click',function(){}); ```
2014/01/14
[ "https://Stackoverflow.com/questions/21126287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/962449/" ]
You want to do it like this: ``` $("td:not(.ui-disabled) .icon-next").bind("click",function(){}); ``` As [Johannes](https://stackoverflow.com/a/21126391/1879895) said, it would be a better idea to use [`.on()`](http://api.jquery.com/on/) in order to delegate the event in case the `.ui-disabled` class is removed. ``...
[Billy](https://stackoverflow.com/a/21126313/573634) was spot on with his code, though I would suggest you use [`.on()`](http://api.jquery.com/on/) instead and use a delegated event so that events are properly bound/unbound. ``` $('body').on("click", "td:not(.ui-disabled) .icon-next", function(){}); ```
24,718,567
"Free theorems" in the sense of Wadler's paper "Theorems for Free!" are equations about certain values are derived based only on their type. So that, for example, ``` f : {A : Set} → List A → List A ``` automatically satisfies ``` f . map g = map g . f ``` Can I get my hands on an Agda term, then, of the followin...
2014/07/13
[ "https://Stackoverflow.com/questions/24718567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/812053/" ]
No, the type theory on which Agda is build is not strong enough to prove this. This would require a feature called "internalized parametricity", see the work by Guilhem: * Jean-Philippe Bernardy and Guilhem Moulin: [*A Computational Interpretation of Parametricity*](http://publications.lib.chalmers.se/records/fulltext...
Chantal Keller and Marc Lasson developped a tactic for Coq generating the parametricity relation corresponding to a (closed) type and proving that this type's inhabitants satisfy the generated relation. You can find more details about this work on [Keller's website](http://cs.au.dk/~chkeller/Recherche/coqparam.html). ...
13,756,474
I have a problem that's been giving me grief for weeks now. I forgot about it for a while when I was updating to the new Facebook SDK, but now it's back to haunt my dreams. I'm making basically a Facebook feed reader. It gets the JSON data from an API call and uses that to populate a ListView. Each time the custom ada...
2012/12/07
[ "https://Stackoverflow.com/questions/13756474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1754999/" ]
please be specific during using and dealing with the image loader class. If possible, don't create more instance of the same class. Instead of use the same instance in different way. See below adapter class and try to integrate same in your case. which will help you. ``` private class OrderAdapter extends ArrayAdap...
I had same issue with view holder pattern and universal image loader. I was checking my url before i call universal loader display image and if url was null i dit not download image just set imageview background drawable my no image drawable. On Listview scroll my listview images were mixed. Then i tried to do not ...
27,666,020
I'm just wondering why the color of my border radius isn't changing, can someone please answer my question? Code: ``` * { font-family: 'lucida grande',tahoma,verdana,arial,sans-serif; border: 0px; padding: 0px; background-image: url('http://clubpenguincode.com/other/background.png'); } .header { backgrou...
2014/12/27
[ "https://Stackoverflow.com/questions/27666020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4397514/" ]
You need to add a border width: ``` border-width: 1px; ```
try adding `-webkit-` just before the border radius.
27,795,496
[ts-guide](http://docs.racket-lang.org/ts-guide/more.html#%28part._.Annotating_.Definitions%29) said: > > In addition to the `:` form, almost all binding forms from racket have counterparts which allow the specification of types. > > > But it does not say when to use which one. And [ts-reference](http://docs.rac...
2015/01/06
[ "https://Stackoverflow.com/questions/27795496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/222893/" ]
Do you need to preserve the history of both projects A & B, as much as possible? If not, I would suggest the following approach: * create a repo, and an initial empty commit. * in addition to master, create two branches off the initial commit: A and B * Put a snapshot of projects A and B into each respective branch. ...
It sounds like your initial commit to the repository is a copy of project A, which you've then branched from and on the branch replaced with B. Did you try making the parent commit just an empty commit? I think this would give git a better chance of correctly merging, as it's not then assuming that all the changes in p...
2,183,368
I want to do partial fraction expansion on $$\frac{1}{x^4+1}.$$ But how to I factor the denominator so that I get a product of two factors?
2017/03/12
[ "https://math.stackexchange.com/questions/2183368", "https://math.stackexchange.com", "https://math.stackexchange.com/users/377157/" ]
**hint** $x^4+1=(x^2+1)^2-2x^2$ $=(x^2+1+x\sqrt{2})(x^2+1-x\sqrt{2})$
Every quartic polynomial factors as the product of two quadratic ones. As both the coefficients of $x^4$ and $x^0$ are $1$, the factorization must be of the form $$(x^2+ax+1)(x^2+bx+1).$$ Developing, you get $$x^4+(a+b)x^3+(ab+2)x^2+(a+b)x+1.$$ Clearly, $a=-b=\pm\sqrt2$.
8,582,417
I want to make a directory list page for my site. The page show all my site articles. And these articles groupe by the title's first letter. Must I run 26 times mysql query like ``` mysql query like "SELECT * FROM articles Where title like 'a%'" mysql query like "SELECT * FROM articles Where title like 'b%'" mysql qu...
2011/12/20
[ "https://Stackoverflow.com/questions/8582417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/783396/" ]
No. Make a single query, and order them alphabetically, like so: ``` SELECT * FROM articles ORDER BY title ASC ``` Then, as you loop through them to show them, keep track of the last article you showed. If the first letter of the current article is different than the last's, put your separation. ``` $prevFirstLette...
You could select everything, in one query, and order by title name. Then, in your PHP code, you need some logic to break over the recordset whenever you encounter a change in the first letter.
65,730,513
QUESTION: Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to match str2, otherwise returns false. Notes: Only lower case letters will be used (a-z). No punctuation or digits will be included. Performance needs to be considered ``` MY CODE: s1 = 'rkqodlw'...
2021/01/15
[ "https://Stackoverflow.com/questions/65730513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15001512/" ]
You just need to make sure the letters in str2 are all present in str1 in sufficient quantities ```py def scramble(str1,str2): d1 = {} for c in str1: if not c in d1: d1[c] = 0 d1[c] += 1 for c in str2: if not c in d1 or d1[c] < 1: return False d1[c] -=...
Alternative: ``` s1 = 'rkqodlw' s2 = 'world' def scramble(s1, s2): s1_list = list(s1) for char in s2: if char in s1_list: s1_list.pop(s1_list.index(char)) else: return False return True print(scramble(s1,s2)) ``` Here's how it works: You run through the loop for each letter in s2, and if ...
6,813,948
I'm working on REST web-service written with jersey and I'm trying to output some XML with CDATA sections in it. I understand [the reference implementation of JAXB doesn't support that](https://stackoverflow.com/questions/3136375/how-to-generate-cdata-block-using-jaxb/3153660#3153660), so I've downloaded EclipseLink's ...
2011/07/25
[ "https://Stackoverflow.com/questions/6813948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6069/" ]
Looks like the problem was my application server: I am running this with **WebLogic 10.3.5** in development mode, which comes with a lot of common libraries pre-installed that in the default configuration take precedence over those deployed in the webapp `WEB-INF/lib` folder. To fix this a weblogic specific applicati...
Please download Jaxb Extension: This is Eclipselink open source extension for Jaxb. Get jar file: eclipselink.jar copy into Project lib. ``` http://www.eclipse.org/eclipselink/downloads/ EclipseLink 2.4.1 Installer Zip (37 MB) ``` And see example at: <http://theopentutorials.com/tutorials/java/jaxb/jaxb-marshall...
13,410,507
I'm doing this... ``` <?php $term = ucfirst($_GET['term']);?> ``` And doing this multiple times on the page: ``` <?php if (empty($term)) echo 'X'; else echo $term; ?> ``` Is there a better way to go about this?
2012/11/16
[ "https://Stackoverflow.com/questions/13410507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1373779/" ]
You can specify the placeholder value when you first assign the value: ``` <?php $term = ucfirst($_GET['term']) or $term = "X"; ?> ``` (Works because the OR has lower precedence than the assignment.) Then just print that variable henceforth: ``` <?= $term ?> ``` It will contain either the input value, or you...
``` <?php $term = isset($_GET['term']) ? ucfirst($_GET['term']) : 'X'; echo $term; //... ?> ``` If you don't need it anywhere else than you could make it even shorter :-) ``` echo (isset($_GET['term']) ? ucfirst($_GET['term']) : 'X'); ```
10,713
I'm interested in running a promotion ... I'd like to make a product free if the customer's cart total is $10. I was able to do that with this module: <http://drupal.org/project/uc_discounts_alt> Everything is working great, but I don't want my customer to be able to add the product to their cart unless they are buy...
2011/09/06
[ "https://drupal.stackexchange.com/questions/10713", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/1813/" ]
To prevent your customers to add the product to their cart if it's $10 with regular products, You can use ubercart [hook\_add\_to\_cart](http://drupalcontrib.org/api/drupal/contributions!ubercart!docs!hooks.php/function/hook_add_to_cart/6) . for example: ``` function MODULENAME_add_to_cart($nid, $qty, $data) { $con...
Rules can be the better solution to it as you don't want to restrict the user every time but just on some special products. Here is a general flow of what you can do. 1. Add a cck/ubercart class to the products that you want to add to the promotion 2. Then create a rule, and in there, add a condition to check whether ...
3,895,954
I need a clarification regarding the difference between the NSString and NSMutableString. Can any one expand briefly?
2010/10/09
[ "https://Stackoverflow.com/questions/3895954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/466377/" ]
An NSString instance cannot be modified once it's initialized - it is "immutable." No NSString methods can modify the string's value. NSMutableString on the other hand can be modified after it's initialized.
Just to expand on Andy White's answer, there may be performance benefits to using NSString instead of NSMutableString in your code (as always, test using Apple's performance tools to make sure this is truly where your performance bottleneck is). In the situation where you want to change the value of an NSString, one op...
8,042,065
I am creating a file based on the another. So if the original is called doc.txt and is in myDocs I want to have it called docv2.txt and also saved in myDocs. All I need is to define the new files path I can do the rest. Please help me determine what that path would be.
2011/11/07
[ "https://Stackoverflow.com/questions/8042065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1011477/" ]
Use a queue instead of a list. Enqueue the dequeued item for each step. Another alternative is to use a circular buffer. Just keep the array as is and have a pointer to the first element, move the pointer on each step. Read the array in two phases. 1. From the pointer to the end. 2. From the beginning to the pointer. ...
You just want to rotate the array? ``` // Rotate left int temp = a[0]; for (int i = 0; i < a.Length-1; ++i) a[i] = a[i+1]; a[a.Length-1] = temp; // Rotate right int temp = a[a.Length-1]; for (int i = a.Length-1; i > 0; --i) a[i] = a[i-1]; a[0] = temp; ```
1,294,901
$$12-\sin(\theta)=\cos(2\theta)$$ What's the correct answer on the $[0,2\pi]$? I started with $12-\sin(\theta)=1-2\sin^2(\theta)$ and then i cant get anything sensible as i end up with $12=\sin(\theta)+2\sin^2(\theta)$
2015/05/23
[ "https://math.stackexchange.com/questions/1294901", "https://math.stackexchange.com", "https://math.stackexchange.com/users/242803/" ]
you are almost there. $$2\sin^2 \theta + \sin \theta - 12=0 $$ so $$\sin \theta = \frac{-1 \pm \sqrt{49}}{4} = -2, \frac32$$ neither of them leads to a solution for $\theta.$ we should have seen this from the equation itself. reason is $$1 \ge |\cos 2\theta| = |12 - \sin \theta | \ge 11$$ a contradiction.
From > > $$12-\sin(\theta)=\cos(2\theta)$$ > > > you get $$12-\sin(\theta)=\cos^2(\theta)-\sin^2(\theta),$$ this is $$12-\sin(\theta)=1-2\sin^2(\theta).$$ Hence $$2\sin^2(\theta)-\sin(\theta)+11=0$$ and $$\sin(\theta)=\frac{1\pm\sqrt{1-4\cdot2\cdot11}}{4}=\frac{1\pm\sqrt{-87}}{4}.$$ So, no real solution for $\sin...
8,600,657
What should be straight forward is not here and I couldnt find a way yet in spite of reading a lot. I have a button which executes a time consuming function. So on clicking the button should show time elapsed in milliseconds in a label with an interval of 500 ms. And when the desired result is achieved I want the time...
2011/12/22
[ "https://Stackoverflow.com/questions/8600657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/661933/" ]
The problem is that your long-running task is also running on the UI thread. So the timer can't fire and update the UI, since the thread is busy handling the long-running task. Instead, you should use a [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) to handle th...
Your time consuming function is blocking the main thread. You can use `BackgroundWorker` or below trick: ``` public Form1() { InitializeComponent(); t.Tick +=new EventHandler(t_Tick); t.Interval = 500; } int timeElapsed = 0; System.Windows.Forms.Timer t = new System.Windows...
16,146,401
I have this db table ``` CREATE TABLE IF NOT EXISTS `category` ( `id` int(11) NOT NULL AUTO_INCREMENT, `parent_id` int(11) NOT NULL, `name` varchar(100) NOT NULL, `inherit` enum('Y','N') NOT NULL DEFAULT 'N', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; -- -- Dumping data f...
2013/04/22
[ "https://Stackoverflow.com/questions/16146401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1421214/" ]
To get all categories with one query in mysql you will need as many self-joins as there are levels of depth in your category tree. This is obviously impossible if your depth level is not limited. However you can use a stored procedure to do id. Assuming you have a table with categories for a user like: ``` CREATE TAB...
In SQL Server: ``` ;with CTE as ( select id,name from category where id in(1,5) union all select c.id,c.name from category c join CTE ct on c.parent_id=ct.id and c.inherit='Y' ) select * from CTE ```
2,757,195
For any square matrix $C$ with real entries, denote by $\rho(C)$ its spectral radius, i.e. the maximum magnitude of its eigenvalues. For symmetric matrices $A$ and $B$ with $AB=BA$ show that $$\rho(AB)\le \rho(A)\rho(B)$$ I think simultaneous diagonalization of $A$ and $B$ is to be used here, but couldn't find my way ...
2018/04/28
[ "https://math.stackexchange.com/questions/2757195", "https://math.stackexchange.com", "https://math.stackexchange.com/users/91884/" ]
Since both matricea are simultaneously diagonalizable you can also simultaneously diagonlize $AB$ and find a link between its eigenvalues and the eigenvalues of $A$ and $B$. A further hint: Calculate $P^{-1}AP\cdot P^{-1}BP$
If $A$ and $B$ are symmetric with $AB = BA$, you have the following even simpler proof : $$\|AB\|\_2 = \sqrt{\rho((AB)^TAB)} = \sqrt{\rho((AB)^2)} = \rho(AB)$$ so that by sub-multiplicativity of the spectral norm, $\rho(AB) \leq \|A\|\_2 \cdot \|B\|\_2$ and the result follows by symmetry of $A$ and $B$ for which $\|\cd...
68,242,451
I have a code ``` char str1[15]; char str2[15]; memcpy(str1,"abcdef",6); memcpy(str2,"abcdef",6); ``` so str1 should have null termination at index 7. but when I do `printf("--%d--",strlen(str1));` it prints `--9--` which is why its making me think that `memcpy` is not considering null termination when copy into `st...
2021/07/04
[ "https://Stackoverflow.com/questions/68242451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4808760/" ]
Give searchbar `z-index:50` and `z-index:10` to sidebar. This way searchbar will stay beneath the sidebar.
navbar : position:'sticky' main: z-index:100
34,154,324
I'm interested in reordering a list in such a manner as to maximize the sum of the squares of the differences between adjacent elements (cyclic). Here is a piece of Python code that brute-forces the solution in factorial time, so you can see what I mean: ``` def maximal_difference_reorder(input): from itertools im...
2015/12/08
[ "https://Stackoverflow.com/questions/34154324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/465750/" ]
Your problem is a slightly disguised instance of the [Traveling Salesman Problem](https://en.wikipedia.org/wiki/Travelling_salesman_problem). Call the input list `c` (for "cities"). Pick any `M` which is an upper bound on `(c[i]-c[j])**2` This is easily done in linear time since the min and the max of the list can be ...
I think we can have an O(n) solution The key to solve this problem is to generate the first seed for the cyclic group. Considering we should be pairing the elements wherein the pairwise square difference sum is maximum which is possible if we pair an element with its farthest neighbor. Which means if hi is the ith hi...
27,693,332
I am trying to do an off-canvas sidebar and I am using the `.toggleClass` function to make it active or not. When it is active I would like the button (.btn) to say "hide" and when it is not say "show". I have already tried to do an if statement and it has failed. I have also looked at other stackoverflow questions wit...
2014/12/29
[ "https://Stackoverflow.com/questions/27693332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3582087/" ]
You should have another way to select your objects, for example by id, as follows: ``` $("#myid")... ``` Then you can use the hasClass function (<http://api.jquery.com/hasclass/>) to verify if the class has already been added to the object. ``` $("#myid").hasClass("xxx") ```
I think you are looking for something like this. You just need to add an if/else statement to check the class ``` $(document).ready(function () { $('[data-toggle="offcanvas"]').click(function () { $('.row-offcanvas').toggleClass('active'); if ($('.row-offcanvas').hasClass('active')){ $('.btn').html("HIDE"); ...
21,660,346
I am learning about recursion in python and I have this code: ``` def search(l,key): """ locates key in list l. if present, returns location as an index; else returns False. PRE: l is a list. POST: l is unchanged; returns i such that l[i] == key; False otherwise. """ if l: # checks if ...
2014/02/09
[ "https://Stackoverflow.com/questions/21660346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3267920/" ]
It recursively calls the `search` function, with the sliced data from `l`. `l[1:]` means all the data excluding the elements till the index `1`. For example, ``` data = [1, 2, 3, 4, 5] print data[1:] # [2, 3, 4, 5] print data[2:] # [3, 4, 5] ``` You can use the slicing notation to get values be...
Cool. This is where the recursion happens (as you noted), by calling the function itself given the same `key` but a subset of the list `l` (the first element isn't included). Basically, it will keep doing this until the `key` is found in the list. If so, `True` will be returned. Otherwise, the entire list will be gone...
21,447,554
Hi There so I have a project that basically finds all numbers i have and multiplies them by 2. I have it like 90% done but for the other 10% certain inputs don't work. So my code finds all the numbers in a user input and multiplies them by 2. (eg. 123woah becomes 246woah and woah888 becomes woah1776) Can anyone find m...
2014/01/30
[ "https://Stackoverflow.com/questions/21447554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3201634/" ]
In a Little Endian architecture, the integer value 0x1 will be written out in memory like ``` 0x1 0x0 0x0 .... ``` so that function will return 1 Conversely, in a Big Endian architecture, the order of bytes will be ``` 0x0 0x0 ... 0x1 ``` however many bytes are in an int (greater or equal to 2 for it to work), ...
You may use System.getProperty("sun.cpu.endian"). Alternately, you may use SIGAR (<https://github.com/hyperic/sigar>), Java native access, JNI etc. to get this information.
45,012,289
When I use call getFromLocationName I get an IOException with description "grpc failed". Code that's ran ``` @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; try { Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault()); List<Address> listAdresse...
2017/07/10
[ "https://Stackoverflow.com/questions/45012289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8283581/" ]
AOA! turn the accuracy **Mode of device Gps to (only gps)** instant of other option and then try...... worked for me[settings are like this , i am postie you can also find them on emulators](https://i.stack.imgur.com/gueGa.jpg)
It works for me if introduce Geocoder as singleton for application rather than create it every time. Make sure to call Geocoder.getFromLocationName() from worker thread. For example: ``` class Application { private val geoCoder = Geocoder(context, Locale.getDefault()) ... } class SomeClass { @WorkerThre...
8,957,559
I need to create a music sequencer for the iPad but have no experience yet on this platform. I have several questions about this subject, hopefully I can find some answers here. * OpenFrameworks seems to be the way to go for this kind of things. I want my application to be able to play both synth sounds and samples. A...
2012/01/21
[ "https://Stackoverflow.com/questions/8957559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
> > OpenFrameworks seems to be the way to go for this kind of things. I want my application to be able to play both synth sounds and samples. Are both of those things possible with oF? Any suggestions/alternatives? > > > As of iOS 5, you can use MusicSequence and MusicPlayer APIs for MIDI. Then you can use AUSampl...
I can't help with frameworks, but you can freely mix objective-C and c/c++.
60,775,983
I have ``` df<-data.frame(time=c("one", "two", "three", "four", "five"), A=c(1,2,3,4,5), B=c(5,1,2,3,4), C=c(4,5,1,2,3), D=c(3,4,5,1,2), E=c(2,3,4,5,1), EF=c(1,2,3,4,5)) ``` I would like to select for example df[df$time=="one,] and order the columns in descending order (if possible in `base R` and `dplyr`), and outp...
2020/03/20
[ "https://Stackoverflow.com/questions/60775983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/906592/" ]
I re-installed python. This fixed the problem. The code in the example worked perfectly. The "w" replaces contents of the file. <https://docs.python.org/3/library/functions.html#open>
Use this: ``` f = open("test.txt", "w") f.write("this is a test") f.close() f2 = open("test.txt", "w") f2.write("this is also a test") f2.close() ``` I think the issue is you're trying to work with another instance of the same file without closing it, that being said writing this should also work: ``` f2.close() ...
35,354,923
I'm trying to create a MySQL `UPDATE` statement with an `IF` condition. I would like to update the user's particulars if the email and username are not duplicate or found in database. I'm stuck with this code: ``` <?php include "connection.php"; $user = $_REQUEST['user']; $em = $_REQUEST['email']; $id = $...
2016/02/12
[ "https://Stackoverflow.com/questions/35354923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4570451/" ]
The following PHP script will check for * IF the user's updated email and updated username are the same * IF the user's new email and username is already in use by another user * IF both conditions are not met, the user's details will be updated **PHP code:** ``` <?php include "connection.php"; $user = $_REQUEST[...
> > If specifying column related message is not the concern, > > > ``` <?php include "connection.php"; $user = $_REQUEST['user']; $em = $_REQUEST['email']; $id = $_REQUEST['id_user']; $data_us_em = mysqli_query($con,"select count(email) as count from user where id_user='".$id."' OR em='".$em."' OR ...
59,326,351
I am using the ReactiveElasticsearchClient from spring-data-elasticsearch 3.2.3 with spring-boot 2.2.0. When upgrading to spring-boot 2.2.2 i have got org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144. It's indicated to fixe that to use spring.codec.max-in-mem...
2019/12/13
[ "https://Stackoverflow.com/questions/59326351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11867433/" ]
Using the plain reaction `WebClient` I ran into the same issue (going from 2.1.9 to 2.2.1.) I had no luck setting `spring.codec.max-in-memory-size` and later found a hint that this wasn't the way to go anyway: > > … On the client side, the limit can be changed in WebClient.Builder. > > > ([source](https://github.c...
or: ``` final Consumer<ClientCodecConfigurer> consumer = configurer -> { final ClientCodecConfigurer.ClientDefaultCodecs codecs = configurer.defaultCodecs(); codecs.maxInMemorySize(maxBufferMb * 1024 * 1024); }; WebClient.builder().codecs(consumer).build(); ```
6,922,866
I have the following text as an example: `\n\t\t\t\t\t3 comments` Can anyone help me to construct PHP regex formula for extracting the number? (in this case `number = 3`) The number can be prefixed by any text, but after the number there should be a `<space>` followed by `comments`. Thanks.
2011/08/03
[ "https://Stackoverflow.com/questions/6922866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/861112/" ]
``` preg_match('/\d+(?= comments)/', $text, $match); ```
``` $str = "\n\t\t\t\t\t3 comments"; preg_match('/\.*(\d+)\scomments/',$str,$m); var_dump($m[1]); ```
13,789,436
I am using Raspbian, a Debian distro for the Raspberry Pi. I tried using the task manager but was unable to change the process priority (I was trying to decrease Python's priority). After decreasing the priority and checking again it remained at zero (no change). Is this because of me not being a superuser? If so how d...
2012/12/09
[ "https://Stackoverflow.com/questions/13789436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1850751/" ]
You should consider to use Terminal: ``` sudo top ``` this will show you the processes with pid ``` renice {priority} pid ``` this will change the priority (niceness) of the process. The nicer the process is, the lower priority it will have. It's nicer because leave its time-slot to other processes ;-) {priority...
Find the process id (using ps aux|grep 'your\_process') Use `renice` command ``` $sudo renice -n <nice_value> -p <PID> ```
5,245,430
Can anybody try to take a look at the code please, i am new in jQuery. Thank you, guys. ``` <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8...
2011/03/09
[ "https://Stackoverflow.com/questions/5245430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/612222/" ]
I think you have two errors, neither of them related to calling after(). 1. Your regular expression has a syntax error. Instead of `[w-.]`, say `[w.-]`. 2. You've mixed up the variable names for the birthday: month,days,years in one place, month,day,year in the other. If I fix these then clicking the submit button do...
I would just use one div which display all the errors. Also, the documentation says HTML String. Have you tried some paragraph tags? I know it should not matter but worth a shot. Can you elaborate on the results you are getting?
30,526,707
When I tried jbosseap6.3 install as service. I got below error. Anyone have any idea on the below error. Any one shed light means it is very helpful for me. ``` java.lang.IllegalArgumentException: Failed to instantiate class "org.jboss.logmanager.handlers.PeriodicRotatingFileHandler" for handler "FILE" at org.jbos...
2015/05/29
[ "https://Stackoverflow.com/questions/30526707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4863157/" ]
Right click the installation directory of Jboss EA (mine is C:\program files\EAP6.1, then Properties, Security tab. Given everyone permissions on this folder (all users you can see just give full control). This should then be able to create logs etc files within the required folder. This is just a workaround though on...
I got the same exception Try changing the path from c to another destination, that solved my issue and I am able to start the server
64,127,408
I am trying to use ngForm by following an online tutorial for building the full-stack application but save button isn't triggered, I am totally new to angular 8 I had followed each step kidly help me to get rid of this thanks in advance **My form code adduer.component.html** ``` <h1>Add User</h1> <form #recievedUser=...
2020/09/29
[ "https://Stackoverflow.com/questions/64127408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4384793/" ]
Go to Laravel folder ``` /public ``` open ``` index.php ``` Look for the comment block ``` |--------------------- | Run The Application |--------------------- ``` **Under** that block just place ``` phpinfo(); ``` Then start Laravel application with ``` php artisan serve ``` And open the application in b...
If you want a separate Info file for debugging purpose only Go to project root folder `cd public` `nano phpinfo.php` ```php <?php // Show all information, defaults to INFO_ALL phpinfo(); ?> ``` **Run Laravel :** `php artisan serve` **VIEW YOUR PHPINFO PAGE** To view your php info page, open a browser and go t...
29,617,206
Using Ruby 2.1.3 and Rails 4.1.6. I have been using .titleize to clean up some user input such as ``` 'new york'.titleize => "New York" ``` However, titleize can also break correct user input by downcasing when not desired: ``` 'New York, NY'.titleize => "New York, Ny" ``` Is there a clean way to titleize wit...
2015/04/14
[ "https://Stackoverflow.com/questions/29617206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2917386/" ]
If you expect mix case words and want to keep them mix cased I would something like this: ``` def titleize_without_downcasing(string) string.gsub(/(\w|')(\w*)/) { $1.upcase + $2 } end titleize_without_downcasing('new york, NY, UsA') #=> 'New York, NY, UsA' titleize_without_downcasing("doctor's") #=> "Doctor's" ``...
``` def titlize(str) r = str.split.map { |word| word.size > 2 ? word.titleize : word.capitalize } r.join(" ") end ```
1,054,076
How can I generate a random hexadecimal number with a length of my choice using C#?
2009/06/28
[ "https://Stackoverflow.com/questions/1054076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/124550/" ]
Depends on how random you want it, but here are 3 alternatives: 1. I usually just use Guid.NewGuid and pick a portion of it (dep. on how large number I want). 2. System.Random (see other replies) is good if you just want 'random enough'. 3. System.Security.Cryptography.RNGCryptoServiceProvider
.... with LINQ ``` private static readonly Random _RND = new Random(); public static string GenerateHexString(int digits) { return string.Concat(Enumerable.Range(0, digits).Select(_ => _RND.Next(16).ToString("X"))); } ```
5,404,257
how to check entered value in text box have B as first letter using c#
2011/03/23
[ "https://Stackoverflow.com/questions/5404257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672875/" ]
``` if(myTextBox.Text.StartsWith("B")) .... ```
You can use the string `StartsWith()` method. ``` if("Bar".StartsWith("B")) // .... if(Textbox.Text.StartsWith("B")) // .... ```
12,836,966
I have to modify the PHPTAL template below by adding another field, "location" ``` <tal:block tal:repeat="contact Model/contactList"> <div class="contactCell"> Name: <span content="contact/name">contact name</span><br/> Number: <span content="contacy/number">2374687234</span><br/> <-- THIS NE...
2012/10/11
[ "https://Stackoverflow.com/questions/12836966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/297440/" ]
You can get pretty far with: ``` <pre tal:content="php:print_r(object, true)"/> ``` if the object is a plain array or a `stdClass` object. However, PHPTAL can also read object's methods and invokes magic `__get()` methods, so if the object is from some fancy ORM it may not be possible to list all properties that w...
You can use var\_dump inside PHPTAL as well: ``` <pre tal:content="php:var_dump(object)"/> ```
51,494,829
I have been trying to figure out an issue with spring boot and as i am new to spring I thought of getting some help here. I have a spring boot based java application which runs as a daemon and makes some GET request to a remote server. (Acts only as a client). But my spring boot application internally starts an embed...
2018/07/24
[ "https://Stackoverflow.com/questions/51494829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2218666/" ]
Here is the most simple solution for me, make spring boot application just a restful api consumer. Replace the dependence ``` implementation("org.springframework.boot:spring-boot-starter-web") ``` with ``` implementation("org.springframework.boot:spring-boot-starter-json") ``` `RestTemplate` and `jackson` are av...
Answering your questions: 1) embedded by defaut - not needed for clients HTTP requests; 2) You can use CommandLineRunner for spring boot applications without any web: ``` @SpringBootApplication public class SpringBootConsoleApplication implements CommandLineRunner { public static void main(String[] args) { ...
24,822,262
Here is the xml ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="${relativePackage}.${activityClass}" > <Button ...
2014/07/18
[ "https://Stackoverflow.com/questions/24822262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3842868/" ]
wrap both buttons around LinearLayout and set their width to fill\_parent as well as same layout weight ``` <LinearLayout layout_width="fill_parent" ... > <Button layout_width="fill_parent" layout_weight="1" ... /> <Button layout_width="fill_parent" layout_weight="1" ... /> </LinearLayout> ``` Buttons will be assi...
``` Try this code it will help you in every device <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="${relativePackage}.${activ...
50,399,320
I want to have a layout like: [![enter image description here](https://i.stack.imgur.com/XTqBG.png)](https://i.stack.imgur.com/XTqBG.png) But is not working, the layout appears like <https://jsfiddle.net/0knckvfh/1/>. Do you know where is the issue? HTML: ``` <div class="container"> <div class="row"> <h6 clas...
2018/05/17
[ "https://Stackoverflow.com/questions/50399320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9548602/" ]
Your layout is displaying incorrectly because you have forgotten to wrap your content within one of Bootstrap's `.col-*-*` classes. Without that wrapper everything defaults to `flex-wrap: wrap` as defined by the `row`. If you're just learning Bootstrap this would be an opportune moment to read the documentation on its...
``` <div class="container"> <div class="row"> <div class="column"> <h6 class="font-weight-bold">Title</h6> <p><strong>Name:</strong> John</p> <p><strong>Email:</strong> emailtest...</p> <h6 class="font-weight-bold">User 1</h6> <p><strong>Name:</strong> John</p> <p><strong>Surname:</strong...
143,043
This might be an easy question but currently I'm fighting over it with our TA who gave it in the final exam. Let $X, Y$ random variables and define $Z= \max \{X, Y\}$ what is the distribution of $Z \mid \{X > Y\}$? Should be $Z\mid \{X>Y\}\sim X$, right?! Thank you all.
2012/05/09
[ "https://math.stackexchange.com/questions/143043", "https://math.stackexchange.com", "https://math.stackexchange.com/users/30968/" ]
Let rephrase the question this way: What is the conditional distribution of $X$, given that $X>Y$? Suppose $\displaystyle X\sim\left.\begin{cases} 1 & \text{with probability }p, \\ 0 & \text{with probability }1-p \end{cases}\right\}$, and $Y$ is an independent copy of $X$. What is the conditional probability distribu...
The conditional PDF of $Z$ conditionally on $[X\gt Y]$ is the only function $g$ such that, for every bounded measurable function $u$, $$ \int u(z)g(z)\mathrm dz=\mathrm E(u(Z)\mid X\gt Y)\propto\mathrm E(u(X); X\gt Y), $$ where $\propto$ means that a factor independent of $u$ was omitted. **Let us assume that $X$ and $...
1,936,462
I have used [`LinkedHashMap`](http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedHashMap.html) because it is important the order in which keys entered in the map. But now I want to get the value of key in the first place (the first entered entry) or the last. Should there be a method like `first()` and `last()` ...
2009/12/20
[ "https://Stackoverflow.com/questions/1936462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/178132/" ]
`LinkedHashMap` current implementation (Java 8) keeps track of its tail. If performance is a concern and/or the map is large in size, you could access that field via reflection. Because the implementation may change it is probably a good idea to have a fallback strategy too. You may want to log something if an excepti...
Though linkedHashMap doesn't provide any method to get first, last or any specific object. But its pretty trivial to get : ``` Map<Integer,String> orderMap = new LinkedHashMap<Integer,String>(); Set<Integer> al = orderMap.keySet(); ``` now using iterator on `al` object ; you can get any object.
68,444,222
I have the following jinja2 template ``` [ {% for items in hosts %} { "name":"{{ items.name }}", "display_name":"{{ items.display_name }}", "services": {{ host_group | from_json | json_query('[*].services[0]') | to_json }}, } {% endfor %} ] ``` i need to replace **services[0]** by a variable **{{ loop.in...
2021/07/19
[ "https://Stackoverflow.com/questions/68444222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4686080/" ]
There are two things to keep in mind when working with Jinja: 1. You never nest the `{{...}}` template markers. 2. If you put something in quotes, it's a literal string. So when you write: ``` json_query('[*].services[loop.index0]') ``` You are passing `json_query` the *literal string* `[*].services[loop.index0]`,...
Using Ansible `2.9.23`. For the string placeholders `{}` and `%s` I had to use backticks, otherwise it wouldn't work: ``` json_query('results[?name==`{}`].version'.format(query)) json_query('results[?name==`%s`].version' % (query)) ``` Given the example json: ``` { (...) "results": [ { ...
43,230,731
I have a variable that has few lines. I would like to remove the last line from the contents of the variable. I searched the internet but all the links talk about removing the last line from a file. Here is the content of my variable ``` $echo $var $select key from table_test UNION ALL select fob from table_test UNION...
2017/04/05
[ "https://Stackoverflow.com/questions/43230731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5658836/" ]
`sed` can do it the same way it would do it from a file : ``` > echo "$var" | sed '$d' ``` EDIT : `$` represents the last line of the file, and `d` deletes it. See [here](http://sed.sourceforge.net/sedfaq3.html#s3.1) for details
Try this: ``` last_line=`echo "${str##*$'\n'}"` # "${str##*$'\n'}" value gives the last line for 'str' str=${str%$last_line} # subtract last line from 'str' echo "${str}" ```
14,582,661
I'm developing Spring MVC application. In my application I have two profiles, test and production. Test is enable when I deploy my app to test envirionemnt, Production on production environment. I need to get current profile in jsp file. Is it possible ? I don't want to send additional variable to get this informatio...
2013/01/29
[ "https://Stackoverflow.com/questions/14582661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1958008/" ]
You can use something like the following: ``` ServletContext sc = request.getSession().getServletContext(); WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(sc); String[] profiles = applicationContext.getEnvironment().getActiveProfiles(); ```
For a more elegant way, you can create a custom JSP tag. Here is a tutorial you can use to achieve this: <http://blog.florianlopes.io/access-spring-profiles-with-custom-jsp-tag/> With this custom tag, you will be able to restrict an area based on the active Spring profile. This idea is to extend the Spring ***Request...
32,637,368
I purchased a new macbook and I am now working on getting my apps to run on a 64bit mac. However I haven't been able to remove the default menubar. Is there anyway to change my app name from Electron to something else within Electron via app.js so I don't see Electron in Finder (revert to screenshot for better unde...
2015/09/17
[ "https://Stackoverflow.com/questions/32637368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/710887/" ]
I got same problem here with my electron app I tried `mainWindow.setMenu(null);` but it didn't work but I noticed that when app is running, there was an electron icon show in the dock which is your app I think maybe this is the point to cause the problem here just give it a try ``` app.dock.hide(); ``` **Notice:...
The name Electron is in the `Info.plist` file inside Electron.app, change it to what you want.
20,203,363
Looking through a [fundamental C++ type reference](http://en.cppreference.com/w/cpp/language/types), you see that on LP64, `long` is 64 bits, just like `long long` on the same platform. Does that mean that these two types are identical on an LP64 platform?
2013/11/25
[ "https://Stackoverflow.com/questions/20203363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/916907/" ]
No, it doesn't. It only means that they are equally wide.
No, take for instance: ``` void foo(long); void bar() { foo(5L); } void foo(long long val) { std::cout << val; } ``` This fails to link.
2,044
My 2.5 year old has recently developed what can be best described as a stutter. It only seems to occur with us, and mostly when asking a question ("Wh, wh, wh, wh, what's that Daddy?). It's especially pronounced if he is tired. It doesn't concern us greatly yet, he's happy and sociable. In fact it doesn't tend to occ...
2011/06/20
[ "https://parenting.stackexchange.com/questions/2044", "https://parenting.stackexchange.com", "https://parenting.stackexchange.com/users/43/" ]
It depends. Certain things should be treated right away with therapy but stuttering of certain types, switching vowels or consonants, and many other "issues" may be completely normal speech progression, especially in a 2.5 year old. We got my son's speech checked out for a similar reason and the professional determined...
I wouldn't worry about it. Our son did the same thing when his vocabulary was expanding, sometime starting around two years old. He grew out of it after a 2-6 months, he is 5 now and doesn't exhibit any of the stuttering behaviors. *There is enough things to spend energy on when it comes to parenting (modeling and tea...
154,052
In content type setting in drupal, we have tab comment setting .The comment setting on future content of this type will default to: * **Hidden:** No comments are allowed, and past comments are hidden. * Closed: No comments are allowed, but any past comments remain visible. * Open: Any future content of this type is op...
2015/04/06
[ "https://drupal.stackexchange.com/questions/154052", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/45872/" ]
I found this link, it is very simple. <http://bonify.io/blog/2014/09/limit-quantity-when-adding-product-cart> 1. Events * Before saving a commerce line item 2. condition * Entity is of bundle data selector: commerce-line-item, value: product * Data comparison Data to compare : commerce-line-item:commerce-prod...
October 2022: Running Commerce Core on Drupal 7 So I struggled with this. On my website we sell digital products so the quantity never needed to be larger than one. I tried using spinners to prevent double clicking on the "Add to Cart" buttons but somehow users still found ways to double click. I still don't know how ...
53,651,598
Consider I have multiple lists ``` A = [1, 2, 3] B = [1, 4] ``` and I want to generate a Pandas DataFrame in long format as follows: ``` type | value ------------ A | 1 A | 2 A | 3 B | 1 B | 4 ``` What is the easiest way to achieve this? The way over the wide format and melt is not possible(?) beca...
2018/12/06
[ "https://Stackoverflow.com/questions/53651598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2080295/" ]
Here's a NumPy-based solution using a dictionary input: ``` d = {'A': [1, 2, 3], 'B': [1, 4]} keys, values = zip(*d.items()) res = pd.DataFrame({'type': np.repeat(keys, list(map(len, values))), 'value': np.concatenate(values)}) print(res) type value 0 A 1 1 A 2 2 A ...
Check this, this borrows the idea from dplyr, tidyr, R programming languages' 3rd libs, the following code is just for demo, so I created two df: df1, df2, you can dynamically create dfs and concat them: ``` import pandas as pd def gather(df, key, value, cols): id_vars = [col for col in df.columns if col not in c...
44,743,904
I use FlatList with large number of items. I get following alert from Expo XDE. > > VirtualizedList: You have a large list that is slow to update - make > sure your renderItem function renders components that follow React > performance best practices like PureComponent, shouldComponentUpdate, > etc. {"dt":13861,"p...
2017/06/25
[ "https://Stackoverflow.com/questions/44743904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2631871/" ]
I noticed that the answer to this question dosen't proffer solution for those using functional component and hooks. I encountered this problem and i was able to get rid of it by using the hook "useMemo()" ``` <FlatList keyExtractor={keyExtractor} data={productsState.products} ...
I figured it out, why this bug is happened. The main problem is, when your onEndReached event is happened, im sure you are loading something from server, which means, you need to wait until your loading is finished from server, so after that you can call onEndReached event. But in your case there is multilple calling ...
273,344
I am trying to include an `.eps` figure in a document and build with pdflatex: ``` \documentclass[12pt,a4paper]{report} \usepackage{graphicx} \usepackage{epstopdf} \begin{document} \includegraphics{figure} \end{document} ``` The error I get is: ``` sh: epstopdf: command not found Package pdftex.def Error: File...
2015/10/16
[ "https://tex.stackexchange.com/questions/273344", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/90022/" ]
With TeXLive 2015, `eps` files should be converted to `pdf` automatically when using pdflatex. There is no need to load the `epstopdf` package. The error you are getting suggests that the system is looking for the `epstopdf` script in the wrong place. According to [the user manual](http://texstudio.sourceforge.net/manu...
You can basically remove the `\usepackage{epstopdf}` and just leave the code as it is. So you will have: ``` \documentclass[12pt,a4paper]{report} \usepackage{graphicx} \begin{document} \includegraphics{figure} \end{document} ``` Of course you have to be sure that the file `figure.eps` is in the same folder of t...
188,004
I suggest that SO uses low votes per view as a reason to to raise questions for review. Each time someone views a question, there is a chance they will vote it up, or vote it down. Someone that searches for questions on a particular subject and is lead to a question that is *irrelevant* to what they are interested are...
2013/07/09
[ "https://meta.stackexchange.com/questions/188004", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/170084/" ]
The problem with this suggestion is that there is a class of questions that is not likely to be downvoted or upvoted yet is high quality: Questions about specialized or difficult subjects. They won't be downvoted because they look like effort posts. But, they won't be upvoted because the viewer doesn't have enough kn...
I like this feature request because I did some [research about these questions especially on SO](https://meta.stackexchange.com/a/274590/270345) and my impression is that most of these questions are indeed close worthy, but some of them also may profit a lot from improvement. Being in a review queue should be a good th...
21,478,461
We have two divs: How to select all the input field as an array with name="divText" that are inside "div2". //Body of div1 ``` <div id="div1> <input type="text" name="divText" value="v1" /> <input type="text" name="divText" value="v2"/> <input type="text" name="divText" value="v3"/> </div> ``` //Body of div2 ``` ...
2014/01/31
[ "https://Stackoverflow.com/questions/21478461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2043769/" ]
Use [Attribute Equals Selector [name="value"]](http://api.jquery.com/attribute-equals-selector/) along with [ID Selector (“#id”)](http://api.jquery.com/id-selector/). There is error in your html the closing quote of div `id` `div1` and `div2` is missing as well. **[Live Demo](http://jsfiddle.net/9cMqa/1/)** ``` $('#d...
Another way : ``` $("#div2 input[type=text]") ```