INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How can we control the resolution in experiments (collider, accelerator, etc.)? Consider for example we perform the electron-proton scattering experiment. If we accelerate the incident electron with a certain energy, then it means that we can control the center-of-mass energy of this process. In terms of Mendelstam variables, we know the value of $s$. But, I wonder how can we control (or measure) the momentum transfer, $Q^2$, which stands for the resolution. If we want to investigate the internal structure of the proton deeply, we need a high $Q^2$ value. Since $s$ and $t$ are independent variables, it seems that we can change $s$ and $t$ independently. How can we do that in experiments? Thank you.
We can't control $t$. We can only measure it, from the energy and direction of the scattered electron. It's not like $s$ which we can choose by arranging an appropriate accelerator and target. So to study high $Q^2$ we set up an experiment which will measure the (relatively few) large-angle scatters and not get swamped by the more numerous small-angle scatters. From the measured scattered electron momentum $\vec p'$ (and $E'=\sqrt{m_e^2+p'^2}\approx p'$) one has $t=(E-E')^2-(\vec p - \vec p')^2$. So we know it for the events we select and measure, but we don't force the electrons to scatter at any particular angle.
stackexchange-physics
{ "answer_score": 3, "question_score": 1, "tags": "particle physics, experimental physics, large hadron collider" }
How to click a image form my dialog insert to ckeditor I using ckeditor to post news and article in my website I create a plugin function on post page (eg. post_news.php) that plugin will foreach many images in a JQ dialog. I want click one image will insert a image to ckeditor mouse cursor postion < img src"abc.png"> Q1. How to... click a image in a dialog(not ck plugin) to insert a image html code to ckeditor mouse cursor postion Q2. can I complete this action in the WYSIWYG mode? Thanks a lot.
Use `editor.insertHtml( string )` to insert HTML at the position of the caret: CKEDITOR.instances.editor1.insertHtml( '<img src="...">' ); And this question is where you'll find how to get the outer HTML of your image.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, jquery, dialog, ckeditor" }
Macbook hangs at startup I've been having problems occasionally starting my Macbook Pro Retina. It just hangs on the gray screen with the activity indicator. When I launch in verbose mode it stops at this line. AppleUSBMultitouchDriver::checkStatus - received Status Packet, Payload 2: device was reinitialized How do I determine what's causing the issue?
I finally found a solution. This happened to me again and I could not even get my computer to startup. I found this website for repairing your disk in single user mode. < The solution is to run `/sbin/fsck -fy` in single user mode.
stackexchange-apple
{ "answer_score": 1, "question_score": 4, "tags": "macbook pro, startup" }
Unable to access the value against a specific key that has a special character I was trying to extract relevant data from a given JSON file. The JSON has the following format. [ { "partyResponse" : { "ns2:Address1" : "10 test Way", "ns2:Address2" : null, ... } }, { ... } ... ] I'm trying to get the value for Address1 but the following just prints out the whole JSON in an odd manner. jq .[].partyResponse["ns2:Address1"] random_file_20180220.json I'm trying to access it like this because the key name has a colon. I just want to list out the address as follows. "10 test Way" "10 test Way" "10 test Way" ...
Found the solution. The shell strips the quotes. So, it is good practice to put the expression within single-quotes. jq '.[].partyResponse["ns2:Address1"]' random_file_20180220.json The above gives the desired result. "10 test Way" "10 test Way" "10 test Way" "10 test Way" "10 test Way" "10 test Way" "3030 test Freeway" "3030 test Freeway" This only works on Linux systems though (I'm using Ubuntu).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "json, jq" }
Analyzing Ryuichi Sakamoto's "Ballet Mécanique" ![enter image description here]( What is that Abadd9/C , Bbm add9/Db on the intro ? is it just a modal interchange chord bIIIM7 and iv from the parallel minor key ? If it is, then whats with that inversion ? does it have any other particular intend behind it ?
**My interpretation of it would be the same as what you said** , yes. The key of F's parallel minor F minor has the chords A and Bm, as you noted. Therefore, I believe it's modal interchange, and the 9ths are there for colour. It sounds nice and pretty! These would then be in first inversion, as the chords have their 3rds under them. As for why the chords are inverted? I believe that's **to create the smooth bassline** that appears in the phrase at the start of the A section (the bass notes are A, B, C, C, C, D), and in the intro the chords are inverted so as to match the inversion of the following chords. * * * As a side note, the Bmaj7 chord written in ink doesn't have a fifth, replacing it with the sixth (the notes are B-A-D-G), but I think that that G is just a consequence of the melody, and they chose to leave out the fifth of the chord.
stackexchange-music
{ "answer_score": 1, "question_score": 0, "tags": "theory, chords, chord theory, chord progressions, chord inversions" }
Time Stamp into sentences Would like to have a tool to take a time stamp and turn it into a half sentence. Sample Time Stamp: > 03/25/2016 11:33:16 AM Sample Output: > at 11:33 AM on 3/25. Additionally, how would can I account for 2 possible time stamps. Sample2 ./TimeStampTool.sh 03/25/2016 11:32:05 AM 03/25/2016 11:33:16 AM Sample2 Output: > between 11:32 and 11:33 AM on 3/25. Script so far #!/bin/bash <br/> if [ -n $4 ] <br/> echo "between '$2 $3' and '$5 $6' on '$1'." <br/> elif <br/> echo "at '$2 $3' on '$1'." <br/> exit
stamp to different format, single line bash script date -d "$1" +'at %T on %m/%d' "between" script $ sh tst.sh '03/25/2016 11:32:05 AM' '03/25/2016 11:33:16 AM' between 11:32:05 and 11:33:16 on on 03/25 $ more tst.sh t1=`date -d "$1" +'%T'` t2=`date -d "$2" +'%T'` day=`date -d "$1" +'on %m/%d'` echo "between $t1 and $t2 on $day" Note the script assumes the days of the timestamps are the same and does not detect which stamp is first
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "linux, bash" }
curl -i and curl -I returning different results My understanding was that `curl -i` and `curl -I` would return virtually the same results except that `curl -i` would return the standard output **along with** the header and `curl -I` would **only** return the header -- the header of both being the same. We've been doing some gzip and un-gzipped testing with Varnish and stumbled upon the oddity that `curl -i` shows `X-Cache: HIT` but `curl -I` returns `X-Cache: MISS`! How this is possible, I am unsure and that is precisely my question in this post. Here are some more details that may or may not make a difference: 1. The URL is usually SSL enforced (https) but both HTTP and HTTPS have been tested to receive same results 2. The results are consistent 3. Is Varnish Running site says "Yes! Sort of"
curl sends different HTTP requests to the server (or Varnish in this case) when you use the `-I` option. Normally, curl will send a GET request, but when you specify `-I`, it sends HEAD instead (essentially telling the server to just send the header, not the actual content). I'm not particularly familiar with Varnish, but it appears to normally cache both GET and HEAD requests -- but in your case it might be configured to do something different, or the backend server may be triggering a difference... In any case, I'm pretty sure it's GET vs. HEAD that's making the cache respond differently with `-i` vs. `-I`.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "macos, caching, curl, ssl, varnish" }
Table is bad for layout, but what's about CSS table-cell We all now using table for layout is bad thing. But what's about using table-cell? E.g. i need two blocks one is 200px width and other is 100% - 200px (ye, i know about float hack and also about CSS3 calc).
It's an ugly hack, but I don't think there's any problem with it. The table is discouraged for design because it should hold tabular data - it's semantically wrong to put eg. menu and article in table cells.
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": -1, "tags": "html, css, layout" }
How can quickly merge strings in Python I have strings like this: strA = "Today is hot. My dog love hot dog, milk, and candy." strB = "hot dog and bread" I hope the output string like: "Today is hot. My dog love hot dog and bread, milk, and candy." not "Today is hot dog and bread. My dog love hot dog, milk, and candy." I tried to use `str.find()` but it's not suitable. if strA.find(strB) != -1: x = strA.find(strB) listA = list(strA) listA.insert(x, strB) output = ''.join(listA)
You can do a reverse lookup and return the best matched result. strA = "Today is hot. My dog love hot dog, milk, and candy." strB = "hot dog and bread" def replace_method(string_a,string_b): s = string_b.split() for i in reversed(range(len(s)+1)): if " ".join(s[:i]) in string_a: return string_a.replace(" ".join(s[:i]),string_b) print (replace_method(strA,strB)) Result: Today is hot. My dog love hot dog and bread and cheese, milk, and candy.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python" }
navigation hover effect cover up the box shadow from content i will on my navigation with the hover effect to cover up the box shadow from content. here my testsite: < And this is what i want: !enter image description here How can to solve this ? With CSS or jQuery ?
Remove the box-shadow from your `<div id="content">` and change the box-shadow to this: box-shadow: 0px -7px 16px -6px rgba(70, 48, 25, 0.7), inset 0px -7px 16px -6px rgba(70, 48, 25, 0.7); to `<div id="navigation">`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -3, "tags": "jquery, navigation, css" }
Windows 2008 R2 VPN. How do I issue IPs based on username? I have 2 subnets that my VPN server has access to. I want to set it up do that if one username gets access to one subnet and another user gets access to a separate subnet? Can this be done with one server? Thansk
You can assign static IP address using Active Directory Users and Computers - see the following Knowledge Base article (it does not list Windows Server 2012 or Windows Server 2008 R2 but the article does apply). <
stackexchange-superuser
{ "answer_score": 0, "question_score": 1, "tags": "routing, windows server 2008 r2" }
How to make a login frame display in the center of the window when the button is clicked? Just like what happens when you click _Sign in with OpenID_ on < I want my login frame displays in the center of the window, and only when some link is clicked. But now I have difficult to center a div, I have written CSS as following but it doesn't work #logindiv { position: relative; overflow: auto; margin: 0 auto; }
The position/styling of the div can be emulated with: #overlay_div { position: absolute; top: 0; bottom: 0; left: 0; right: 0; background-color: #000; } #overlay_div #logindiv { position: absolute; top: 50%; left:50%; height: 20em; width: 40em; margin: -10em 0 0 -20em; background-color: #fff; } The top left corner of the `#logindiv` is positioned absolutely at a point 50% across the width of the window and 50% of the height of the window (from the top-left origin). This is then altered by the `margin`s, moving it 50% of its height up the page, and 50% of its width back across the page. Changing the width/height of the `#logindiv` will require different negative margins for positioning centrally.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "javascript, html, css" }
Some three-digit (incl. minus sign) vote count still doesn't display properly > **Related:** > Vote counts with exactly three digits don't display properly on the Stack Exchange Android app As the title says... !Worse Than Failure The Android app version is 0.1.58. Here is my experimental results: * ~~Vote counts >= 200 that I've tried seems to be fine~~ * Vote count == 241 has problem, 242 doesn't * Vote counts which matches `/^1[012345689][0-9]$/` seems to be having problem (may be overgeneralized) * Vote count == -36 definitely has problem Note that this is not a tablet, but a 4-inch mdpi phone, of 480x854px.
Thanks for the report. This has been fixed for version 0.1.60 coming out later tonight, I checked it against your very helpful use cases and some other ones I thought of after I saw what the root cause was.
stackexchange-meta
{ "answer_score": 2, "question_score": 10, "tags": "bug, status completed, android app" }
In QT5, how to open new window on click event on sub-menu item? I am new to QT programming & UI designing. I want to open a new window when the user clicks on submenu or menu item. I can successfully open a new window when the user clicks on a button. Below the image of my main window. I want to open new window when the user click on 'password' menu item ![]( When the user clicks on test button, New window opens successfully. Any help would be highly appreciated.
Create a slot: public slots: void slot(); Connect the signal `triggered()` with this slot connect({your QAction}, SIGNAL(triggered()), this, SLOT(slot())); Open the window from the slot. void {your QMainWindow}::slot(){ //open yout window here }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c++, qt, qt5, qmenu, qaction" }
android studio not found device My device is ASUS K00z. I connect it's to my PC for develop android app but in android studio not found device. I set debugging mode to on. In device manager show yellow exclamation of "Android" under "Other devices" root. How to solve it's PS. I use win7 64-bit
Try downloading the drivers from ASUS. I didn't find any 'k00z' on there, but it sounds like it may be the Fonepad 7 - they'll likely have different model numbers, so you'll need to know the specifics of your device and download the appropriate driver.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android studio, adb" }
Constructing a bitmap from code; what steps are necessary? I'm building a System.Drawing.Bitmap in code from a byte array, and i'm not sure what properties and such need to be set so that it will properly save as a .BMP file. I have `Bitmap b = new Bitmap(width, height, PixelFormat.Format32bppArgb);` as my constructor and for (int i = 1; i < data.Length; i += 2;) { Color c = new Color(); c.A = data[i]; c.R = data[i]; c.G = data[i]; c.B = data[i]; int x = (i + 1) / 2; int y = x / width; x %= width; b.SetPixel(x, y, c); } as the code that sets the bitmap data (it's reading from a byte array containing 16 bit little'endian values and converting them to grayscale pixels). What else should be done to make this bitmap saveable?
Nothing else needs to be done, you can save the bitmap right after setting it's image data. Also note that the `SetPixel` method used in a loop is utterly slow, see this link for more information.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, .net, image processing" }
OpenLayers 3: Basic Authentication Is it possible to do basic authentication with OpenLayers 3? I found answers that you need to do an ajax-Call and use the token in a "Authentication"-Header. I wonder if it's possible to tell OpenLayers which header to use because for all my other http-Request I need another Authentication-Header. Any ideas on this?
I didn't find a better solution than doing the following: $("<iframe src=' function () { createMap(); } If I create the map outside the iframe, I get asked for each tile for a password (because the tiles are loaded asynchronously and don't have the authentication header yet). So now I send the first request -> get the log-in prompt and the header as a response -> then when I create the map and the tiles are requested they already contain the header.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript, jquery, basic authentication, openlayers 3" }
Regex take everything after word and before character in PHP I'm trying to get regex to work to take everything after "test" and before "@" in an email so "[email protected] would become 12345. I've got this far to get it to return everything before the "@" symbol. (Working in PHP) !(\d+)@!
Either you can use capturing groups and use the regex test-(\d+)@ and use `$1` or use lookaheads and behinds like `(?<=test-)\d+(?=@)` which will just match `12345`
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "php, regex" }
Will reading in dim light damage my eyes? People keep saying that it is important to have adequate light when reading, because reading in dim light will damage your eyes. Is this true and why?
**Short answer** The consensus is that sub-optimal lighting does not permanently damage the eye. **Background** Sub-optimal lighting can create a sensation of having difficulty in focusing. It also decreases the rate of blinking and this possibly to discomfort from dry eyes. These complaints **do not persist**. The majority consensus in ophthalmology is that reading in dim light does not damage your eyes; **it is a myth**. Although it can cause eye strain with multiple temporary negative effects, it is unlikely to cause a permanent change to the function or structure of the eyes (Vreeman & Caroll, 2007). If you Google your question many credible sources outside the scientific literature seem to agree that it is a myth busted, including WebMD, ABC and Wall Street Journal. **Reference** **-** Vreeman & Caroll, _BMJ_ (2007); **335**
stackexchange-health
{ "answer_score": 8, "question_score": 7, "tags": "light, pathophysiology" }
Flex LinkButton selectable Is it possible to make a `LinkButton` selectable? That is, the text from the LinkButton can be selected and then copied. LinkButton does not have the `selectable` property.
It is probably easier to create your own `LinkButton` by extending a `Text` control. Just style it to look like the `LinkButton` (blue, underlined) and set the following properties: buttonMode = true; useHandCursor = true; Then just handle the MouseEvent.CLICK event as you would with any `Button`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "apache flex, flash, copy paste" }
Flutter get reference after navigation pop I would like to get a reference to the screen I am going to show. With this code: Navigator.of(context).pop() I actually going back to the previous screen but I would like to access that reference to do some work. How can I do that? With my iOS background working in Swift I would have done something like that: var newScreen = Navigator.of(context).pop();
You cannot create a reference because when you pop the current "route" all the data will be disposed. But you can return a pop result to the awaiting parent as explained by official docs. Something like: //When you will dispose the pushed page/route you can pass your result to pop method Navigator.pop(context, 'This is my new page result'); //In the parent page you will await for the result final result = await Navigator.push( context, MaterialPageRoute(builder: (context) => MyPushedPage()), ); print(result) //--> This is my new page result
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "flutter, dart, flutter navigation" }
How to extract specific rows in R? I would like to extract specific rows from a dataframe into a new dataframe using R. I have two columns: `City` and `Household`. In order to detect move, I want a new dataframe with the households who have not the same city. For example, if a household appears 3 times with at least one city differents from the others, I keep it. Otherwise, I delete the 3 rows of this household. City Household Paris A Paris A Nice A Limoge B Limoge B Toulouse C Paris C Here, I want to keep only Household `A` and Household `C`.
A dplyr solution : compute the length of unique cities for each household and keep only those with length > 1 library(dplyr) df <- data.frame(city=c("Paris","Paris","Nice","Limoge","Limoge","Toulouse","Paris"), household =c(rep("A",3),rep("B",2),rep("C",2))) new_df <- df %>% group_by(household) %>% filter(n_distinct(city) > 1) Source: local data frame [5 x 2] Groups: household city household 1 Paris A 2 Paris A 3 Nice A 4 Toulouse C 5 Paris C Edit : added @shadow and @davidarenburg suggestions from the comments
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 5, "tags": "r" }
Limit of $f(x)=x^2\left(1+2+\cdots+\left\lfloor \frac1{|x|} \right\rfloor\right) $ Suppose $f$ a function defined on $\left[\dfrac{-1}{2};\dfrac{1}{2}\right]$ as $f(x)=x^2\left(1+2+\cdots+\left\lfloor \dfrac{1}{|x|} \right\rfloor\right) $. * How can I prove that $f$ has a finite limite on $0$? * Calculate for $k \in \mathbb{N}^*$ : $\displaystyle \lim_{x\to0+}\left(x\left(\left\lfloor \dfrac{1}{x} \right\rfloor+\left\lfloor \dfrac{2}{x} \right\rfloor+\cdots+\left\lfloor \dfrac{k}{x} \right\rfloor\right)\right)$.
For the second question, note that if $x=\frac1n$, then $$x\left(\left\lfloor\frac1x\right\rfloor+\left\lfloor\frac2x\right\rfloor+\ldots+\left\lfloor\frac{k}x\right\rfloor\right)=\frac1n(n+2n+\ldots+kn)=\frac12k(k+1)\;,$$ which tells you what the limit has to be. Moreover, if $\frac1{n+1}<x<\frac1n$, then $n<\frac1x<n+1$, so $$\frac1{n+1}\sum_{m=1}^kmn\le x\left(\left\lfloor\frac1x\right\rfloor+\left\lfloor\frac2x\right\rfloor+\ldots+\left\lfloor\frac{k}x\right\rfloor\right)<\frac1n\sum_{m=1}^km(n+1)\;,$$ and a little more work shows that it really **is** the limit.
stackexchange-math
{ "answer_score": 4, "question_score": 2, "tags": "limits, ceiling and floor functions" }
MongoDB request with the condition do not display "bookName": "I've been discovered", "bookGenre": { "0": "Classics", "1": "Fantasy", "2": "Romance" } "bookName": "Doctor Who", "bookGenre": { "0": "Classics", "1": "Biography" } "bookName": "I don't want to tread carefully", "bookGenre": { "0": "Classics", "1": "Fantasy", "2": "History" } I want to get all the books in the genre Classics, but excluding the genre Fantasy and History. $genre = array("Classics"); $genreNot = array("Fantasy", "History"); $q = find(array("bookGenre" => array('$in' => $genre), "bookGenre" => array('$nin' => $genreNot))); In this query, I get all my books, and the exception is not bringing the genre Fantasy and History does not work. How to make a request to the excluded genre work?
Hmm you have got a fundamental problem with your arrays here: $q = find(array("bookGenre" => array('$in' => $genre), "bookGenre" => array('$nin' => $genreNot))); You have duplicate keys for the same object so actually the only clause in this query that goes through is `"bookGenre" => array('$nin' => $genreNot)`. I believe instead you can combine the `$in` and `$nin`: $q = find(array( "bookGenre" => array('$in' => $genre, '$nin' => $genreNot) )); Like so.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, mongodb" }
What is the R function in the tidyverse package which allows you add some characters to the start/end a string? (Please note that I am new to coding/r programming so I'm finding this a bit difficult.) For example, I have a simple dataset of students and their respective weights. Class <- c("Tom", "Ana", "John", "Sara") Weight <- c(50, 45, 52, 47) df <- data.frame(Class, Weight) How can I add the "kg" unit to the end of each weight in the "Weight" variable, without having to manually type it in? (I think this can be done using the stringr package but I'm not sure.) Many thanks, Karima
You can use `paste0` from base R (nice if you don't want dependencies), or `stringr::str_c` (fits in well if you're using lots of other `stringr` functions). While some `stringr` functions offer advantages over their base counterparts, this pair is essentially identical. df %>% mutate(Weight = str_c(Weight, "kg")) For reference, you can see this is equivalent to `paste0`: assertthat::are_equal( df %>% mutate(Weight = str_c(Weight, "kg")), df %>% mutate(Weight = paste0(Weight, "kg")) ) # TRUE
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "r, stringr" }
What should the tag for the new Windows 8 runtime be? At present, Microsoft seems to be calling the API for creating Metro style apps on Windows 8, “Windows Run Time”; it is also being called WinRt. We already have two tags for this: windows-runtime and winrt. We only need one!
My vote is for winrt. This is what Google says, and what everyone appears to be calling it.
stackexchange-meta
{ "answer_score": 18, "question_score": 5, "tags": "discussion, stack overflow, tags" }
use a string to create an object I have the following object creation line in PHP: $countryTargetSearchParameter = new CountryTargetSearchParameter(array(new CountryTarget('JP'))); I am trying to replace it with: $countryTargetSearchParameter = new CountryTargetSearchParameter(array($LocArray)); where $LocArray is equal to new CountryTarget('JP'). However, I am not able to get this to work. Can I get some help please. Thank you Jai
class CountryTargetSearchParameter { public function __construct(array $array_with_string) { $this->new_object = new CountryTarget($array_with_string[0]); } } $array_with_string = array('JP'); $test = new CountryTargetSearchParameter($array_with_string); Or, much cleaner, and using a string for the class: class CountryTargetSearchParameter { public function __construct($name_of_class, $parameter) { $this->new_object = new $name_of_class($parameter); } } $test = new CountryTargetSearchParameter('CountryTarget', 'JP');
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, object" }
Finding $\lim\limits_{x \to \infty} (\sqrt{9x^2+x} - 3x)$ I am trying to find the limit and I know that I have to do something to get a denominator but I can't make it work. There is a specific thing I have to do to this problem to make it work but I am not sure what that is. I know what I am doing is not wrong mathematically, it just doesn't help me get the answer. $$\lim_{x \to \infty} (\sqrt{9x^2+x} - 3x)$$ Not sure where to go with this, multiply it all by the conjugate? I tried that but I know that won't help because I have to rationalize the denominator. I know I can't multiply by anything really until I get rid of the sqrt and I don't know how.
$$\lim_{x\to\infty}(\sqrt{9x^2+x}-3x)$$ $$=\lim_{x\to\infty}\frac{x}{\sqrt{9x^2+x}+3x}.$$ Divide numerator and denominator by $x$, $$=\lim_{x\to\infty}\frac{1}{\frac{1}{x}\sqrt{9x^2+x}+3}$$ note $\frac{1}{x}\sqrt{9x^2+x}=\sqrt{\frac{9x^2+x}{x^2}}=\sqrt{9+\frac{1}{x}}$ so this reduces to $$=\lim_{x\to\infty}\frac{1}{\sqrt{9+\frac{1}{x}}+3}$$ $$=\frac{1}{\sqrt{9}+3}=\frac{1}{6}.$$ And just FYI this ground was ( _more or less_ ) covered in this question.
stackexchange-math
{ "answer_score": 4, "question_score": 2, "tags": "calculus, limits, radicals" }
The maximum number of users who have logged in to the Oracle Database Is there any variable or view in the Oracle Database 12 that stores the maximum number of users who have logged in at the same time (for example since the last restart)?
You can check system view `V$RESOURCE_LIMIT` for the `MAX_UTILIZATION` of resource called `SESSIONS`: SELECT MAX_UTILIZATION FROM V$RESOURCE_LIMIT WHERE RESOURCE_NAME = 'SESSIONS' From the documentation: > `SESSIONS` specifies the maximum number of sessions that can be created in the system. Because every login requires a session, this parameter effectively determines the maximum number of concurrent users in the system. `MAX_UTILIZATION` is like a high-water mark that shows the maximum value that the parameter reached. It is reset everytime the instance restarts.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql, database, oracle" }
Using Windows Azure to use as a TCP Server I'm looking into Windows Azure now and wondering if one can implement a TCP/IP server using Worker Roles - i.e, when a request comes in on a socket - a worker role (and not a web role) will accept it, treat it well and then return an answer on that same socket request. Another question is - should I do it, or maybe just implement my own non-blocking server using .NET and put it in one worker role or a VM? Thanks!
There's a full worked example of a telnet server on Maaten Balliauw's blog - see < On your second question, most answers seem to recommend using worker roles for code instead of using VMs - worker roles in general are "architecturally preferred" for Azure, and VMs are there mainly for when you need to support existing (legacy) code.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "azure" }
What is the purpose of making a preferment for yeast doughs? I have found a number of bread recipes that call to prepare first a preferment - a very simple dough with half the flour, water, sometimes sugar, and the yeast to be used. This is left to rise for an hour or two and afterwards it is mixed with a dough made with the rest of the ingredients including fats, additional sugars, and eggs. This second dough is then left to rise again and later split into the loafs and baked. What is the purpose of the preferment and why is sponge made with such basic ingredients?
In addition to allowing fermentation to begin before the addition of fermentation inhibiting other ingredients, as @J.A.I.L. said in his answer, according to Bread Secrets, after explaining the benefits to flavor of a long, slow fermentation: > A quick, warm fermentation will allow time for the yeast to produce enough carbon dioxide to raise the dough, but not enough time for the enzymes to work or for the development of the other flavour compounds. If we ferment our dough for too long, however, the gluten becomes too weak to hold the shape of the loaf. So artisan bakers generally use a preferment (pre-ferment, not prefer-ment!) as part of their dough. This allows the bread to gain flavour from the longer fermentation, but still maintain a strong gluten network for a good rise.
stackexchange-cooking
{ "answer_score": 7, "question_score": 5, "tags": "bread, yeast" }
Bash script: Looping through directories over SSH and downloading them to local machine I'm trying to write a bash script that: * Loops through all the directories in a folder over an SSH server * Downloads a file (titled say, "foo") inside each of these folders to a local machine. At the moment, I have: ssh username@server "for dir in ~/directoryname/*; (... something here!); done" I don't think I can use scp while I'm accessing the SSH server, however. Is there a way I can loop through and download everything here?
running `scp` remotely would work only if the remote server has access to your own system. let's assume it doesn't. you could do it in two steps: ssh username@server "... some script that just echos the paths ..." > log for line in $(<log); do scp username@server:$line ./dir/$line; done or you could investigate `rsync` which is extremely powerful. it has `--include` and `--exclude` options which would allow you to do something like: rsync -av username@server:~/somepath/ ./somepath/ [--exclude/--include flags]
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "linux, bash, ssh, scp" }
Android RMI with UI Thread I am trying to remote invoke method form other apk. Everything is working except fact that invoking method has to do some operations on UI and must be run from UI Thread. Method which was invoked with Method.invoke() are running in separate thread and has no access to UI. Is AsyncTask is a proper way to solve this problem? Or maybe exists a better solution.
There are handlers and runOnUIThread() methods specially for situations like this.. you can use them.. you can use handler like this.. new Handler().post(new Runnable(){ public void run(){ //UI operation... } }); if you are inside an Activity.. then.. runOnUIThread(new Runnable(){ public void run(){ //UI operation... } });
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android" }
Procedurally generated cave in Unreal Engine 4 I am making a procedurally generated cave in UE. I have a question regarding what's the most optimised way to do it. I already have a function that creates the verticies and triangles for a cave section from point a A to point B (The final cave consisting of multiple cave sections). My question is, should the entire cave consist of: * A single procedural mesh component that contains all the cave sections in a single Mesh Section * A single procedural mesh component that has a different Mesh Section for every cave section * Multiple procedural mesh components, each for a cave section * Multiple child actors, each representing a cave section Thank you in advance.
I would advise against using a single large mesh for the following reasons: * Entire mesh needs to reside in GPU memory any time part of it is visible. * UV, texture, normal and shadow mapping resolution is reduced. * LOD is impractical. I would split each cave section into its own actor depending on poly count and visibility.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "unreal engine4, procedural generation" }
Printing a public string variable to a page in ASP.NET Overlooking something basic here but I am trying to set a variable and have it print in several places on the page. code behind: public string myVariable { get {return "40"; } } page: <link rel="stylesheet" type="text/css" href="/css/main.css?v=<%=myVariable%>" /> output: <link rel="stylesheet" type="text/css" href="/css/main.css?v=&lt;%=myVariable %>" /> It seems to have something to do with the quotes as this works when I take it outside of the href. I find that it works fine if I place a string in the code segement. This works, but isn't what I want: <link rel="stylesheet" type="text/css" href="/css/main.css?v=<%="40"%>" /> What is the logic behind this behavior and what do I need to do to make it work? I would also settle for a more elegant method of doing this.
You need to single quote the html attribute like so: <link rel="stylesheet" type="text/css" href='/css/main.css?v=<%=myVariable%>' /> I use this all the time especially within repeaters when I want to create anchor tags <a href='PageToLinkTo.aspx?id=<%# DataBinder.Eval(Container.DataItem, "Id")%>'>Link Text</a> This will only work in the body of your aspx page. If you have the link tag in the head section of your aspx page then check out this question for more info: Problem in Expression tag to bind string variable
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "c#, asp.net" }
Multiple sub-domain in google app engine I have created an app on app engine and associated it with a domain using Google Apps.It also had one sub-domain running on it. Today I added two more sub-domains with the "ghs.googlehosted.com" as the CNAME for the domains. I did a nslookup on the subdomain `nslookup -q=cname test.example.com` and got the following response Server:127.0.0.1 Address: 127.0.0.1#53 Non-authoritative answer: test.example.com canonical name = ghs.googlehosted.com. Its already been more than 6hours and I am still getting the following error The requested URL / was not found on this server. That’s all we know. In the logs, I do not see any request coming to appengine.
You probably forgot to add the subdomains in your appengine application settings.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "google app engine, dns" }
Is ok for implementations of IEnumerator.MoveNext() to include a long running process? Are implementations of `IEnumerator.MoveNext()` expected to be relatively quick? Or is it ok if _"moving to the next item"_ includes disk IO, web requests, or other potentially long running operations? For example I'm working on a project which processes documents, and want to abstract the access to the documents as an `IDocumentSource`. Some implementations of `IDocumentSource` may simply pull the documents from the local file system, where other's may download the documents from a webserver to a temp location before opening them. In this case `MoveNext()` would close and delete the previous temp file, and then download and open the next file to process.
There are no guidelines about the expected performance of `MoveNext()`, unlike the ones that exist for property getters, for example. You approach looks reasonable. Still, it would be wise to include a note about the behavior in the class/method docs.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "ienumerator" }
R : Percentile 90% with tapply I am trying to apply the quantile function to a column (y) of my data (tab) considering the groups (column x): z <- with (tab, tapply (y, x, quantile)) tab       x y 1 1 0.11 2 1 0.07 3 0.04 4 2 0.39 5 2 0.12 6 3 0.21 7 3 0.06 8 3 0.00 9 3 0.12 10 3 0.36 11 4 0.08 12 4 0.15 13 4 0.09 14 4 0.30 15 4 0.12 16 4 0.13 17 4 0.07 My question: how to get only the 90% percentile? (not all quantiles 0% 25% 50% 75% 100%)
Add an additional argument `p=0.9`: tapply(tab$y, tab$x, quantile, p=0.9)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "r, quantile, percentile, tapply" }
Check if all values were successfully read from std::istream Let's say I have a file that has 100 text If I try reading 2 numbers using ifstream, it would fail because `text` is not a number. Using fscanf I'll know it failed by checking its return code: if (2 != fscanf(f, "%d %d", &a, &b)) printf("failed"); But when using iostream instead of stdio, how do I know it failed?
Its actually as (if not more) simple: ifstream ifs(filename); int a, b; if (!(ifs >> a >> b)) cerr << "failed"; Get used to that format, by the way. as it comes in _very_ handy (even more-so for continuing _positive_ progression through loops).
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 11, "tags": "c++, iostream" }
Can defrosting chicken make it slimy? I bought chicken drumsticks on January 11th and froze them on the 11th. They had a best before date of January 13th. I put them in the fridge yesterday to defrost and am cooking them now but they were slimy. They didn't smell though. Does frozen chicken go slimy when defrosted? Safe to eat? Thanks!
Chicken naturally contains a lot of water, it also absorbs some more from the cleaning process (up to 8% reportedly). Some manufacturers also "tumble" the raw chicken with brine to increase flavour and, of course, weight and thus profit. The freezing process will damage cells in the meat as the water expands, so when the chicken is defrosted some of this water/protein mixture will escape from these ruptured cells. When cooking you may see this as a white gunge forming in the pan. It can feel quite slimy once defrosted, but this is just the raw "juices" coming out. I buy chicken in bulk and vacuum seal/freeze it into portion sizes. Good quality meat and drying the chicken before freezing can help. Flash freezing is preferred, but this is not practical at home. I believe food safety is OT here, but it should not be an issue as long as you follow all the recommended guidelines for storage temperature and times.
stackexchange-cooking
{ "answer_score": 3, "question_score": 0, "tags": "food safety, chicken, freezing, defrosting" }
Discord.net get the list of roles for a user I'm trying to get the list of roles for a user inside `MessageReceived` by writing `(message.Author as SocketGuildUser).Roles`. However, the cast always returns null. I also tried using `Context.User` instead, but that returns null too. What am I missing here? This is the exception I get when I put a breakpoint at the casting line: `System.InvalidCastException: Unable to cast object of type 'Discord.WebSocket.SocketGlobalUser' to type 'Discord.WebSocket.SocketGuildUser'`
I am dumb. I was trying to get the role list inside a DM context when roles only belong to a specific server. The code itself is fine when run in a non-DM context.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "c#, discord, discord.net" }
Just if else show dialog box String statuss = LoginActivty.review_status; Toast.makeText(MainActivity.this, "noman :"+ statuss, Toast.LENGTH_SHORT).show(); Toast.makeText(MainActivity.this, "shah:"+ LoginActivty.review_status , Toast.LENGTH_SHORT).show(); if(statuss != "Reviewed"){ ratingDialog(); // Toast.makeText(MainActivity.this, "Well come back", Toast.LENGTH_SHORT).show(); }else if(statuss == "Not_Review") { Toast.makeText(MainActivity.this, "Well come back", Toast.LENGTH_SHORT).show(); } } When I statically pass `status` it works perfectly but when I pass `LoginActivty.review_status` dynamically it's not working. Why?
You should use **equals()** instead of **==** if(!statuss.equals("Reviewed")) { ratingDialog(); // Toast.makeText(MainActivity.this, "Well come back", Toast.LENGTH_SHORT).show(); }else if(statuss.equals("Not_Review")) { Toast.makeText(MainActivity.this, "Well come back", Toast.LENGTH_SHORT).show(); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android" }
How to access "frequency count" in WordNet in any Java WordNet interface I have been searching for some Java library which can give me information about "Frequency count" of the synset. I checked JWNL and JWI and they don't provide such information. Does anybody know other Java WordNet APIs?
each Synset has a frequency indicator, based on corpora. JAWS - < offers Synset#getTagCount Not sure about JWNL and JWI, but look for synset apis in these libraries. Note: (personal opinion)do not trust this frequency indicator, it is seriously misleading.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "java, nlp, wordnet" }
prove that $\{ a_n \}$ is convergent. for $n\geq1$, $|a_n| < 2$ and $|a_{n+2} - a_{n+1}| \leq \frac{1}{8}|a_{n+1}^2 - a_n^2|$. prove that $\\{ a_n \\}$ is convergent.
For all $n \geq 1$, we have $$\left\lvert a_{n +2} -a_{n +1} \right\rvert \leq \frac{1}{8} \left\lvert a_{n +1} +a_{n} \right\rvert \left\lvert a_{n +1} -a_{n} \right\rvert \leq \frac{1}{8} \left( \left\lvert a_{n +1} \right\rvert +\left\lvert a_{n} \right\rvert \right) \left\lvert a_{n +1} -a_{n} \right\rvert \leq \frac{1}{2} \left\lvert a_{n +1} -a_{n} \right\rvert \, \text{.}$$ It follows that $$\left\lvert a_{n +1} -a_{n} \right\rvert \leq \frac{1}{2^{n -1}} \left\lvert a_{2} -a_{1} \right\rvert \leq \frac{1}{2^{n -1}} \left( \left\lvert a_{2} \right\rvert +\left\lvert a_{1} \right\rvert \right) \leq \frac{1}{2^{n -3}}$$ for all $n \geq 1$. Therefore, for all $q > p \geq 1$, we have $$\left\lvert a_{q} -a_{p} \right\rvert \leq \sum_{k = p}^{q -1} \left\lvert a_{k +1} -a_{k} \right\rvert \leq \sum_{k = p}^{q -1} \frac{1}{2^{k -3}} \leq \frac{1}{2^{p -2}} \, \text{.}$$ This proves that the sequence $\left( a_{n} \right)_{n \geq 1}$ is Cauchy and hence converges.
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "real analysis, sequences and series, analysis" }
Drupal upgrading procedure: What are 'core files'? I received an email about new security patch that says I must apply this security patch. But in the instruction there is paragraph that says. "Remove all old core files and directories, except for the 'sites' directory and any custom files you added elsewhere". What are 'core files'?
Drupal core files are those included when downloading drupal core from its project page. At GitHub you can see a convenient overview.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "drupal" }
Not able to close tab in chrome browser using JavaScript I'm not able to close tab in chrome browser using JavaScript last line in below code `js.executeScript("window.close()");` is not working. Can any one please help on the issue? package TestCode; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class Chrome { public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub System.setProperty("webdriver.chrome.driver","C:\\Akash\\Drivers\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get(" JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("window.open(' Thread.sleep(5000); js.executeScript("window.close()"); } }
By invoking `js.executeScript("window.close()");` you are trying to close the main window, not which you have just opened. To close popup window you need to locate it somehow or save the reference to it in the `JavascriptExecutor` context. Note, that global variables there should be preserved: > Note that local variables will not be available once the script has finished executing, though global variables will persist. So you could try to do the following: JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("popup_window = window.open(' Thread.sleep(5000); js.executeScript("popup_window.close()");
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "javascript, java, selenium, selenium webdriver, selenium chromedriver" }
How does the voicing for "Ma vie de Courgette" work in British and American English? Ma vie de Courgette is a Swiss/French animation that was nominated for an Oscar this year. In the UK it's titled "My Life as a Courgette", while in America it's called "My Life as a Zucchini" (as that's what Americans call the vegetable). But when I look at the cast list I only see the original French cast and the American cast (Nick Offerman, Ellen Page, etc). How does this work with respect to the voicing and script for the UK version? The main character is nicknamed Courgette/Zucchini so it must be in the script. Did the American actors record two versions, one with "Courgette" and one with "Zucchini"? Or is there a separate British cast that's not listed?
I got this on DVD a while back and I can confirm that the American cast did record multiple versions. In my British English version the boy is called "Courgette" and there is no separate cast, the same American actors provide the voices. There are also separate trailers for the British English 'Courgette' and American English 'Zucchini' versions (not available when I asked the question) which show the alternate dialogue.
stackexchange-movies
{ "answer_score": 3, "question_score": 3, "tags": "translation, voice acting, my life as a courgette" }
c# regexp pattern to <id> .... </id> I wrote the following pattern: @"<([0-9]+)>(.*?) < /$1>" but it doesn't work. how could i refer to the first group? source text: "Method()<0>int x = 0; while(x < 10)<1>echo(x)< /1>< /0>"
That would be `\1`, and watch for spaces. See also: .Net Regex Backreferencing
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c#, regex" }
MySQL, Get users rank I have a mysql table like below: id name points 1 john 4635 3 tom 7364 4 bob 234 6 harry 9857 I basically want to get an individual user rank without selecting all of the users. I only want to select a single user by id and get the users rank which is determined by the number of points they have. For example, get back tom with the rank 2 selecting by the id 3. Cheers Eef
SELECT uo.*, ( SELECT COUNT(*) FROM users ui WHERE (ui.points, ui.id) >= (uo.points, uo.id) ) AS rank FROM users uo WHERE id = @id Dense rank: SELECT uo.*, ( SELECT COUNT(DISTINCT ui.points) FROM users ui WHERE ui.points >= uo.points ) AS rank FROM users uo WHERE id = @id
stackexchange-stackoverflow
{ "answer_score": 19, "question_score": 11, "tags": "sql, mysql, rank" }
Inter module call Is it possible to call a function residing in another module without using an extra jump?
Short answer: yes. Intermodular calls can be made via relative calls, of course you need to adjust the relativity at runtime. I've done this many times for runtime dynamic patching.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "assembly" }
Is this a correct way of initializing struct sockaddr_in.sin_zero[8] as 0? I am doing this right now but struct sockaddr_in my_addr; my_addr.sin_family = AF_INET; my_addr.sin_port = htons(MYPORT); inet_aton("10.12.110.57", &(my_addr.sin_addr)); memset(&(my_addr.sin_zero), '\0', 8); can I do this? Will this also zero the rest of the struct? i.e.`sin_zero[8]` struct sockaddr_in my_addr = {AF_INET, htons(MYPORT), 0}; // Or struct sockaddr_in my_addr = {AF_INET, htons(MYPORT), {0} };
Yes, it is correct. Of course you could just write `0` which is less verbose than `'\0'`. Also you could replace `8` by `sizeof my_addr.sin_zero` to make sure you are setting the right number of bytes. A tidier way is: struct sockaddr_in my_addr = { 0 }; my_addr.sin_family = AF_INET; my_addr.sin_port = htons(MYPORT); If you want to use a brace-enclosed initializer for the whole thing then I'd suggest using designated initializers for readability. Also this may or may not be possible, as in some situations braced initializers have to be constant expressions and it's not clear whether MYPORT is a variable or not.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "c++, c, struct, memset" }
Ruby 1.9.3 and OS X In bash if I run `ruby -v` it reports I am using `1.9.3p194`. However, I'm using CodeKit to compile a Compass project, and it keeps returning this error: Compass was unable to compile one or more files in the project: LoadError on line 31 of /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb: no such file to load -- toolkit Run with --trace to see the full backtrace I have CodeKit correctly configured to run Sass 3.2 and Compass 0.13, so I'm not sure why it keeps looking for Ruby in the directory above. Any ideas? I'm also using RVM. Here are my configuration paths in .bash_profile: PATH="/usr/local/bin:$PATH" PATH="$PATH:$HOME/bin" [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" and bashrc: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I ended up using Compass.app over CodeKit. As it stands at the moment, CodeKit just seems to run buggy with Sass 3.2. I'm not running into any issues using Compass.app.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby, rvm, sass" }
How to see history of snap packages updates? Is there way to see which snap packages were updated, and when ? Something like `snap list` but ordered by last updated packages with specific dates.
`snap changes` will list recent changes, and `snap tasks` will list the steps involved in a change. It gets garbage-collected after some time (1 day for changes that succeeded, 7 for failures), or after a certain size (500 changes), both of which are currently hardcoded, but it's the commmand you want. I'll update lp:1771714 to reflect this.
stackexchange-askubuntu
{ "answer_score": 20, "question_score": 20, "tags": "updates, snap, update history" }
How to automatically pick last 3 years from MySQL database column? I have a MySQL database in which I count and select the 3 last years to display statistics. I do this statically for each passing year like this: $sql = $db->query("SELECT SQL_CALC_FOUND_ROWS * FROM column WHERE category = 'something' AND YEAR(date) = '2015'"); $res = $db->query('SELECT FOUND_ROWS()'); $result= (int) $res->fetchColumn(); What I would like to do is insert a code that automatically picks the last 3 years of data from the database and displays it. I don't have enough data in the DB to test3 years back in time, but searching around gave me this clue: SELECT SQL_CALC_FOUND_ROWS * FROM column WHERE category = 'something' AND MyDate > date_sub(now(), interval 3 year Any thoughts, tips?
You can use something like this SELECT SQL_CALC_FOUND_ROWS * FROM column WHERE category = 'something' where YEAR(`date`) = YEAR(DATE_SUB(CURDATE(), INTERVAL 3 YEAR));
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, jquery, mysql, date" }
Freedom fighters vs Freedom fighters Freedom fighters fight **for** freedom. Fire fighters fight **against** fire. I want to write an article comparing people who fight for freedom versus people who fight **against** freedom. Would _"Freedom fighters vs Freedom fighters"_ be a wrong title ?
_Freedom Fighters vs Freedom Fighters_ is an excellent title. The auto-antonymous property of the phrase _Freedom Fighter_ , whether obvious or not, immediately arrests the interest of the reader, urging them to read on.
stackexchange-english
{ "answer_score": 3, "question_score": 8, "tags": "word choice" }
Using $\displaystyle \mathbb{C}[G]\cong \bigoplus_{irreducible \ \rho}\rho^{\dim \rho}$ for $S_3$ > Let $G=S_3$. > > $$\chi_{\mathbb{C}[G]}=(6,0,0)=1 (1,1,1)+1(1,1,-1)+2(2,-1,0)=1\chi_{\mathbb{I}}+1 \chi_{\xi}+2\chi_{\triangle} $$ > > since $\displaystyle \mathbb{C}[G]\cong \bigoplus_{irreducible \ \rho}\rho^{\dim \rho}$ I dont understand the "since $\displaystyle \mathbb{C}[G]\cong \bigoplus_{irreducible \ \rho}\rho^{\dim \rho}$" bit. I know that $tr \rho_1 \oplus \rho_2=tr\rho_1 \oplus tr\rho_2$ but I cannot see how to deal with the power.
$\rho^{\dim\rho}$ just means $\bigoplus_{i=1}^{\dim\rho}\rho$, so the character of the regular representation is the sum of the two linear characters with twice the character of the 2-dimensional representation.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "abstract algebra, group theory, representation theory" }
A little abbreviated response This is a short riddle which has a short answer. I look like I have no memory, but I am fine, but turn me around and I may knock you down.
I think the answer is > OK I look like I have no memory > OK looks like 0K (zero kilobytes) but I am fine, > OK is synonymous with fine. but turn me around and I may knock you down. > OK backwards is KO (an acronym for knock out)
stackexchange-puzzling
{ "answer_score": 44, "question_score": 33, "tags": "riddle, wordplay" }
iOS: Search on a main word(noun), not its pronoun I am writing a TableView app where people can search for a word in a foreign language. In this language, the article is important as it tells the word's gender. A reasonable english example is "The Book". I want to search for "Book", not "The". Any ideas on the best way to do this? Many thanks
Are you talking about looking something up in a database, eg? SQLite can be built with Full Text Search extensions that allow you to search for individual words in text. Even without the FTS extensions you can use a LIKE match in SQLite to find a word in a phrase, though the FTS extensions are much faster and more flexible. You can also implement your own poor-man's Key Word In Context (KWIC) scheme -- basically just enter each item in the database N times for an N-word phrase, each time rotated one word. And there are variations on the KWIC scheme that work for large numbers of phrases with less duplication -- using a tree structure to access the data. With such approaches it's practical to implement a search without need for a keyboard, just by successively refining the table contents.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "search, ios4" }
Javascript: Regular Expression to match 8 digits, one character and one hypen in any sequence How do I write a pattern to match any sequence of 8 digits, one character and one hyphen. I am not very good at writing regex I have tried `/([0-9]{8}([-]{1})([a-zA-Z]{1}))` this but it matches only specific sequence also tried like `^(([0-9]{8})([a-zA-Z]{1})([-]{1}))$` but it doesn't work. So please help me to write the regex Thanks in advance :)
If the digits, letter and hyphen can appear mixed together in any order (like `1234k56-78`, use a regex like this: (?=.*[A-Za-z])(?=.*-)(?=(?:.*\d){8}).{10} If the digits need to all be consecutive, then use a regex like this: (?=.*[A-Za-z])(?=.*-)(?=.*\d{8}).{10}
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -3, "tags": "javascript, regex" }
Android DIP size wrong This one is bedeviling me. What am I overlooking? I want a button exactly one inch wide, on any density screen. I declare it in the layout like this: <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="160dip" android:text="How wide?" /> What I get is a button that is exactly 7/8ths of an inch wide on all screens, not the expected 1 inch. Is the difference maybe the margin or padding around the button? If so, how to set that to zero?
dip are based on virtual densities, not actual physical densities. For instance, on a T-Mobile G1, the device's display physical density is around 180dpi, but we treat it as a 160dpi display. Android currently uses 3 "density buckets," 120, 160 and 240. Each device uses whatever is most appropriate. If you want accurate physical measurements, use physical units like in, mm, etc.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "android, size, density independent pixel" }
Aggregate operation in ElasticSearch I have a problem statement where I have data of a vehicle in a Es, having fields time in secs, time in milliseconds and velocity. Now I want to fetch the data and plot speed vs time graph in frontend. But the problem is there are lot of data points as for one sec there are 30-40 milliseconds entries and corresponding speed as well. Now to reduce the datapoints I want to get the average of velocities for one second so that I will have only one datapoint for one sec. How can I achieve that in Es.
Considering that your mapping looks like - { "properties": { "ms": { "type": "integer" }, "seconds": { "type": "integer" }, "velocity": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": "256" } } } } } The below nested aggregation will work - You will get your datapoints in field "averageMsInSecond". { "size": 0, "aggs": { "seconds_buckets": { "terms": { "field": "seconds" }, "aggs": { "averageMsInSecond": { "avg": { "field": "ms" } } } } } } In order to get average value for a second, you need to read key in seconds_buckets aggs and use it along with averageMsInSecond. Hope it helps.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "elasticsearch, elastic stack" }
Mass Update NoSQL Documents: Bad Practice? I'm storing two collections in a MongoDB database: ==Websites== `id nickname url ` ==Checks== `id website_id status ` I want to display a list of check statuses with the appropriate website nickname. For example: [Google, 200] << (basically a join in SQL-world) I have thousands of checks and only a few websites. Which is more efficient? 1. Store the nickname of the website within the "check" directly. This means if the nickname is ever changed, I'll have to perform a mass update of thousands of documents. 2. Return a multidimensional array where the site ID is the key and the nickname is the value. This is to be used when iterating through the list of checks. I've read that #1 isn't too bad (in the NoSQL) world and may, in fact, be preferred? True?
If it's only a few websites I'd go with option 1 - not as clean and normalized as in the relational/SQL world but it works and much less painful than trying to emulate joins with MongoDB. The thing to remember with MongoDB or any other NoSQL database is that you are generally making some kind of trade off - nothing is for free. I personally really value the schema-less document oriented data design and for the applications I use it for I readily make the trade-offs (like no joins and transactions). That said, this is a trade-off - so one thing to always be asking yourself in this situation is why am I using MongoDB or some other NoSQL database? Yes, it's trendy and "hot", but I'd make certain that what you are doing makes sense for a NoSQL approach. If you are spending a lot of time working around the lack of joins and foreign keys, no transactions and other things you're used to in the SQL world I'd think seriously about whether this is the best fit for your problem.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mongodb, nosql" }
Relationship between view and model in Backbone.js In Backbone.js, how does a view know what model it represents? Is it necessary for the view to be named Model_NameView? Because I can't find any other View property or function for setting the model (like collection has the model property, to define what models this collection is of)
As you can see at < there is a `model` property for each view. In other words, you do not have to name the view and model anything in particular.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "backbone.js" }
View Thumbnails of images in a Document Library - SharePoint 2007 I know that in SharePoint 2007, every image inside a [Picture Library] can have a thumbnail by adding the (_t) folder and the _extension.jpg to the file name. What about if my images are stored inside a [Document Library]? is there a way to display thumbnails of those images (of course without having to download them all :)) I am working on a thumbnail view application and my images are all stored inside a Document Library.
If I recall correctly, this isn't possible. The picture library has additional code that allows for the thumbnail preview.
stackexchange-sharepoint
{ "answer_score": 2, "question_score": 3, "tags": "picture library, document library" }
Newton's Law of Cooling on a calorimeter with two systems Having the previous calorimeter with adiabatic walls, we've proven, based on Newton's law of cooling, that the equations are... ![adiabatic calorimeter]( (source: gyazo.com) $m_{b} \times C _{pb} \frac{\mathrm{d T_{b}} }{\mathrm{d} t} = k_{t}(T_{c} - T_{b})$ $m_{c} \times C _{pc} \frac{\mathrm{d T_{c}} }{\mathrm{d} t} = k_{t}(T_{b} - T_{c})$ How would it be affected if instead of a single system, it uses two bodies $c1$ and $c2$ that never get in touch where $c1$ has a temperature bigger than the water and $c2$ has a temperature that is smaller than the water. !adiabatic calorimeter with two bodies
Just apply the energy balance once again to the water. The rate of accumulation of energy in the water is equal to the rate of heat gain from c1 minus the rate of heat loss to c2: $$m_wC_{pw} \frac{dT_w}{dt} = hA\left ( T_{c_1} - T_w \right ) - hA\left ( T_w - T_{c_2} \right )$$ Notice I have introduced the area $A$, since $h\Delta T$ is a flux, or heat transfer per unit area.
stackexchange-physics
{ "answer_score": 0, "question_score": 1, "tags": "thermodynamics, cooling" }
tar file number limitation Does gzip has file limitation Thanks ER
`gzip` only takes one file. If you need to compress more, create an archive with `tar` (or another archiving tool) and `gzip` it (usually resulting in a _.tar.gz_ or _.tgz_ file). _EDIT_ ALso, there is no 4 GB limit on gzip any more for almost a decade.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "linux, gzip, tar" }
pandas cut multiple columns I am looking to apply a bin across a number of columns. a = [1, 2, 9, 1, 5, 3] b = [9, 8, 7, 8, 9, 1] c = [a, b] print(pd.cut(c, 3, labels=False)) which works great and creates: [[0 0 2 0 1 0] [2 2 2 2 2 0]] However, i would like to apply the 'cut' to create a dataframe with number and bin it as below. Values bin 0 1 0 1 2 0 2 9 2 3 1 0 4 5 1 5 3 0 Values bin 0 9 2 1 8 2 2 7 2 3 8 2 4 9 2 5 1 0 This is a simple example of what im looking to do. In reality i 63 separate dataframes and a & b are examples of a column from each dataframe.
Use `zip` with a list comp to build a list of dataframes - c = [a, b] r = pd.cut(c, 3, labels=False) df_list = [pd.DataFrame({'Values' : v, 'Labels' : l}) for v, l in zip(c, r)] df_list [ Labels Values 0 0 1 1 0 2 2 2 9 3 0 1 4 1 5 5 0 3, Labels Values 0 2 9 1 2 8 2 2 7 3 2 8 4 2 9 5 0 1]
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 7, "tags": "python, pandas" }
How to compress json to get it with `bodyParser.json` I want to send to my server a compressed json. I prefer to compress the data in browser.(explainer) and get it to bodyParser.json middleware. client side function something like this: export function compressGzip(input) { const stream = new Response(input).body.pipeThrough( new CompressionStream('gzip') ) return new Response(stream) } my request in react.js: return fetch(url, { headers: { 'Content-Type':'application/json', 'content-encoding': 'gzip' }, method: 'POST', body: bodyContent }).then(res => res.blob()) node.js: app.use( bodyParser.json({ limit: "10mb" }) ); What is the way to do the compression according to this data and does it make sense? Thank in advance!
Got it with blob, it works perfectly :) The code: client side: export function compressGzip(input) { const stream = new Response(input).body.pipeThrough( new CompressionStream('gzip') ) return new Response(stream).blob() } const bodyContent = await compressGzip(JSON.stringify({data: data}) return fetch(url, { headers: { 'Content-Type':'application/json', 'content-encoding': 'gzip' }, method: 'POST', body: bodyContent }).then(res => res.blob()) server side - node.js: app.use( bodyParser.json({ limit: "10mb" }) );
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "node.js, json, reactjs, compression" }
I don't understand difference between semaphore and lock I do not understand some things. For example binary Semaphore and lock are the same? When using lock and when semaphore,or both?
The difference between a lock and a binary semaphore is only a apparent when there are multiple processes trying to access the same resource. A "process" is defined here as an instance of a program or application that may contain one or more threads. Both allow only one thread to access a resource at a given time. However, locks can only limit access within a **single** process while binary semaphores can limit access across **multiple** processes. Therefore, within a **single process** , the behavior of a lock and a binary semaphore are the same. Both allow only one thread to access a resource a given time. Across **multiple processes** , the behavior is different. A binary semaphore will allow only one process to access a given resource at a time, but a lock will give multiple processes to access to a resource a time (but only a single thread in each process will have access at a given time).
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "multithreading, concurrency, locking, semaphore" }
В чем разница между `short int` и `int16_t`? Смотрел курс по `C++` на **Coursera** и там рассказали, что можно подключить библиотеку `cstdlib` и использовать типы данных типа: `int16_t, uint16_t, int64_t, uint64_t` и т.д. Недавно узнал что в плюсах также как же писать просто `short int, long int` и т.д. Вопрос собственно в том, что есть ли разница между ними или это одно и то же?
В зависимости от компилятора и системы, под которую вы компилируете, размер встроенных типов (`short`, `int`, `long`, и т.д., в противоположность `intXX_t`, `uintXX_t`) может отличаться. В стандарте (или еще где-то) можете почитать, в каких пределах могут меняться размеры этих типов, но на практике обычно `short` \- 2 байта, `int` \- 4, `long` \- 4 или 8, `long long` \- 8. А у `intXX_t` и `uintXX_t`, очевидно, размер всегда одинаковый.
stackexchange-ru_stackoverflow
{ "answer_score": 9, "question_score": 3, "tags": "c++" }
How to add video to html page ? I have a 15mb video file I want to be played on my website. I wonder if I use video html5 tag will this file be downloaded before playing or will it stream? What is the best way to serve videos nowadays - without putting it into youtube or installing own media server like wowza?
<video width="320" height="240" controls> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support the video tag. </video> Here is a quick help -> < And Yes html5 player will work for you
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "html, video streaming, html5 video" }
Аналог DataGrid в ASP.NET Есть простое веб приложение в котором нужно вывести несколько таблиц. Есть ли в `ASP.NET` или `ASP.NET MVC 5` аналоги `DataGrid` из `WPF` или `DataGridView` из форм ? Как удобнее и правильней вывести таблицу ?
`ASP.NET MVC` не имеет встроенных элементов управления привязкой данных,таких как `GridView,DetailsView`.`WebGrid` предоставляет аналогичные функции, такие как **привязки данных,сортировка,подкачка,упорядочение,форматирование столбцов**.В основном `WebGrid` используется для отображения данных на веб-странице с использованием элементов таблицы `HTML`. Он отображает данные в табличном формате, а также поддерживает настраиваемое форматирование столбцов, пейджинга, сортировки и асинхронных обновлений через `AJAX`. Вот вам полная статья
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, asp.net" }
How to get an HTML file using Python? I am not very familiar with Python. I am trying to extract the artist names (for a start :)) from the following page: < How do I retrieve the page? My two main concerns are; what functions to use and how to filter out useless links from the page?
Example using urlib and lxml.html: import urllib from lxml import html url = " page = html.fromstring(urllib.urlopen(url).read()) for link in page.xpath("//a"): print "Name", link.text, "URL", link.get("href") output >> [('Aathma Liyanage', 'athma.html'), ('Abewardhana Balasuriya', 'abewardhana.html'), ('Aelian Thilakeratne', 'aelian_thi.html'), ('Ahamed Mohideen', 'ahamed.html'), ]
stackexchange-stackoverflow
{ "answer_score": 24, "question_score": 18, "tags": "python, html, webclient" }
AccountManagement is Principal GroupPrincipal? How do I take a principal and see if it is a group? or that it has members? using(var ctx = new PrincipalContext(ContextType.Domain, "some.domain.com", "DC=some,DC=domain,DC=com")) { var group = GroupPrincipal.FindByIdentity(ctx, IdentityType.DistinguishedName, "some long distinguishedname"); if(group != null) { var subgroups = group.GetMembers().Where(m => m.[IS A GROUP]) foreach (var principal in group.GetMembers()) { Console.WriteLine(principal.DistinguishedName); } } }
You can "convert" the `Principal` using the `as` keyword - if it works, if that object really is a `GroupPrincipal`, you'll get a valid value, otherwise `null`: var group = GroupPrincipal.FindByIdentity(ctx, IdentityType.DistinguishedName, "some long dn") as GroupPrincipal; ****************** if (group != null) { // now you *know* that it *IS* in fact a "GroupPrincipal" ..... }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c#, active directory, principal, account management" }
Monitor thread synchronization in python Is there any way to use monitor thread synchronization like java methods synchronization,in python class to ensure thread safety and avoid race condition? I want a monitor like synchronization mechanism that allows only one method call in my class or object
You might want to have a look at python threading interface. For simple mutual exclusion functionality you might use a `Lock` object. You can easily do this using the `with` statement like: ... lock = Lock() ... with (lock): # This code will only be executed by one single thread at a time # the lock is released when the thread exits the 'with' block ... See also here for an overview of different thread synchronization mechanisms in python. There is no python language construct for Java's `synchronized` (but I guess it could be built using decorators)
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "python, synchronization" }
Installing iOS 4.0.2 SDK over 4.0.0 You know how installing iOS SDK 4 meant that you lost the ability to set the Base SDK to 3.1.x and lower (You have to use the deployment target etc). Does the same happen when installing 4.0.2 over the top of 4.0? Will I have to set my Base SDK to `4.0.2` and use the Deployment Target for a lower version (4.x or lower)? Or can I still set my Base SDK to 4.0?
No. The base SDKs that Xcode lets you choose are more major .x releases, not bugfix .x.y releases. 4.0 is still supported as a base SDK, and I imagine it will be for a while. The only reason for the new SDK is to support any testing devices that you may have upgraded to 4.0.2 (or 3.2.2 for the iPad). It appears that Apple removed 3.x as a base SDK to force people to use it when building applications for submission in order to make sure that all new applications and updates would have support for multitasking (which you get effectively for free when building against 4.0). Apple no longer even accepts applications not using 4.0 as a base SDK for the App Store.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "iphone, xcode, ios4, ios" }
Issues in the Rust reference book < struct SetVec { set: HashSet<u32>, vec: Vec<u32> } impl SetVec { fn populate(&mut self) { let vec = &mut self.vec; self.set.iter().for_each(|&n| { vec.push(n); }) } } > If, instead, the closure were to use self.vec directly, then it would attempt to capture self by mutable reference. But since self.set is already borrowed to iterate over, the code would not compile. The reference book says **the code would not compile.** , but the code can be compiled. So why
This was true in the past, but has changed since and the reference was not updated. Since edition 2021, closures capture disjoint fields. See reference issue #1066.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "rust" }
Update ASP.NET web.config while still in process of client request What happen if web.config gets updated while ASP (ASP.NET 2.0) server still process client request? \- Will the process be killed? \- If not, will the process read the updates in web.config. thanks for any input
The new `web.config` is effectively a copy, so an ongoing request will finish unaffected -- it will not pick up the changes. When the request is complete, the new `web.config` will be written over the old one and subsequent requests will work from the updated values (in a new application domain).
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 8, "tags": "asp.net, web config" }
Realizations of Circle I really don't know how to prove without brute force that: $\mathbb{R}/{\sim}\cong[0,1]/{\sim}$ I know already that: $[0,1]/{\sim}\cong\mathbb{S}^1$ ( _simply use closed map lemma and uniqueness of quotient spaces_ ) The point is that I cannot apply the closed map lemma on wrapping real line around circle to deduce that this is indeed a quotient map...
Define the map $i: [0,1]/{\sim} \rightarrow \mathbb{R}/{\sim}$ by $i([x]) = [x]$, where $[x]$ denotes the class of $x$ in the respective quotient. Now as every point $x \in \mathbb{R}$ has a representative in $[0,1]$, namely $x - \lfloor x \rfloor$, the map $i$ is onto. And this map is clearly continuous: $i \circ q$, where $q$ is the standard quotient map from $[0,1]$ onto $[0,1]/{\sim}$ is just the map sending $x \in [0,1]$ to $[x]$ in $\mathbb{R}/{\sim}$, so just the restriction of the other quotient map between $\mathbb{R}$ and $\mathbb{R}/{\sim}$. Continuity now follows from the standard universal property for quotients. So your quotient $\mathbb{R}/{\sim}$ is compact and you _can_ apply this theorem again.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "general topology, quotient spaces" }
Resize and align a picture within a div How can I resize and align a picture within a div? I need to show resized images on a 50x50px div. I also want them to be centralized on the div. I've made this image below to show exactly what i want to do. !enter image description here The problem in that the CSS needs to work when the image is larger on width, and when it's larger on height. I've found this solution using max-width or max-height, but it only works for one option (larger width, or larger height): div.img-crop-thumb { width: 50px; height: 50px; position: relative; overflow: hidden; } .img-crop-thumb img { position: absolute; top: 0px; left: -50%; max-width: 30px; height: auto; }
Use CSS3 `background-size: cover`. Here's a working example: < And you can read the documentation here.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "html, css, image, dynamic resizing" }
Integration by parts when a function is not continuous? Define a semigroup $\\{T(t)\\}$ on $L$ to be measurable if $T(\cdot)f$ is measurable as a function on $0,\infty),\mathcal{B}[0,\infty))$ for each $f\in L$. We define the full generator $\hat{A}$ of a measurable contraction semigroup $\\{T(t)\\}$ on $L$ by $$\hat{A}=\\{(f,g)\in L\times L: T9t)f-f=\int_0^t T(s)gds, t\ge 0\\}.$$ Now let $L=B(\mathbb{R})$ with the sup norm.Below is a part of the proof of Proposition 5.1 from Ethier and Kurtz' Markov Processes. I don't understand the second equality here. I think the authors used integration by parts, but I don't understand how the integration by parts can be used when we don't assume $T(t)g$ to be continuous, so that it has an antiderivative. I would greatly appreciate it if anyone could explain how this works here. [![enter image description here](
You need that if $T(t)g$ is $L^1_{\mathrm{loc}}$ then $\int_0^t T(s)g\,ds$ is a continuous almost everywhere differentiable function with differential being equal to $T(t)g$ almost everywhere. The differential need not be continuous. In such a setting you can use partial integration, let $A,B$ be continuous and almost everywhere differentiable then you've got: $$\int_0^x (\partial_t A(t))B(t)\,dt = \int_0^x\partial_t(A(t)B(t))\,dt-\int_0^xA(t)\partial_tB(t)\,dt\\\ =(A(x)B(x)-A(0)B(0))-\int_0^xA(t)\partial_tB(t)\,dt$$ Doing this with $\int_0^\infty e^{-\lambda t}T(t)g\,dt$ ($A=\int_0^tT(s)g\,ds$, $B=e^{-\lambda t}$) gives you: $$\lim_{x\to\infty} e^{-\lambda x}\int_0^xT(s)g\,ds -\lim_{x\to\infty}\int_0^x(-\lambda)e^{-\lambda t}\int_0^tT(s)g\,ds\,dt$$
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "real analysis, integration, functional analysis, analysis, markov process" }
Grails controllers repeated code for all actions Imagine this controller: class exampleController{ def action1 = {} def action2 = {} def action3 = {} def action4 = {} def action5 = {} } I want to be able to return in all the action in this controller the same params. Imagining this: def user = session.user [user: user] Is there any way of doing this, besides writing all the same code on all the actions? The session.user return params is just an example. I don't wanna really return it.
A simple solution is to put this code in a method and call it from each action class exampleController{ def action1 = {getModel()} def action2 = {getModel()} def action3 = {getModel()} def action4 = {getModel()} def action5 = {getModel()} private getModel() { def user = session.user [user: user] } } While this does involve some amount of repetition (invocation of the same method), it's a lot more obvious what's happening here. When debugging/testing a controller it's easy to forget about filters and interceptors, which can often lead to questions like > what the @**% is going on here?
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "grails, controller, action" }
pick value from listbox and use in sql query as column name.query dynamically pick column name from variable I have VB.net app that when run you select from listbox values that should then be used in select query.Then click save command button. see vb code snippet below transport = lsttrans.SelectedItem leave = lstleave.SelectedItem then query like below.Note transport and leave are dummy columns not on existing employee table. select employeeid,'' as transport_allowance,'' as leave from employees i wish to somehow create new query to be something close to the below using my selected values in listbox. select employeeid,transport,leave from employees
Use **String.Format()**. Here is the example assuming transport and leave variables are already declared: Dim myQueryTemplate As String = "SELECT employeeid, {0}, {1} FROM employees" Dim myFinalQuery as String = String.Format(myQueryTemplate, transport, leave) If you will debug that, the value of myFinalQuery will be: "SELECT employeeid, transport, leave FROM employees" Add more if needed. From my given example, the next parameter will be {2} and so on.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, vb.net, variables, select" }
Is there a formula to build parameter messages to be passed to smart contract entrypoints? When calling a smart contract entrypoint, it is required to pass the needed entrypoint parameters. This is done through a message that must be sent in JSON/Pairs format. My doubt is: Is there a formula to build these parameter messages to be passed to smart contract entrypoints? For example, when calling the addCustomer entrypoint from SmartPy Explorer: ![enter image description here]( ![enter image description here]( It generates the correspondent Michelson message: (Left (Left (Pair (Pair 8000000 "0001") (Pair Älice"99999897)))) Is there a formula to calculate programmatically the number of LEFTs and RIGHTs, maybe according to the number of entrypoints or even parameters? ![enter image description here]( Any information will be much appreciated. Thanks in advance.
There are two ways to indicate which entrypoint you want to call: * call it by its name using the `--entrypoint` command-line argument of `tezos-client transfer` or the `entrypoint` optional parameter of the corresponding RPCs. If you do this, you can simply pass the argument of the expected entrypoint type without the leading `Left`s and `Right`s. * call it by its position in the `parameter` type of the smart contract: the parameter type can be seen as a binary tree whose nodes are labeled by `or`, you can indicate an entrypoint by a giving the path composed of `Left`s and `Right`s from the root of this tree. An example is given in the Michelson documentation.
stackexchange-tezos
{ "answer_score": 1, "question_score": 2, "tags": "smart contracts, michelson, smartpy, micheline, json" }
How would the customer edit the website you've sold to him? I am pretty sure that in one month, I can create a website semi to professional with really good design, functionality and security. I have made quite a few researches and I have found websites where I can advertise my own website and sell it. However, I still have some hesitation: ## What risk do I take selling a website? Related to the first question, I've got a second question: ## How would the customer edit the website you've sold to him? As I sold a website and not a CMS, the customer will have to edit the code if he want to do some updates. How could I make it easy for him to add the content he wants to the website?
There's two ways to go here that I'm aware of: Option #1: Build CMS functionality into the site, so if a header needs to be updated, provide a control for doing that. Option #2: You provide maintenance and do the updates for a fee.
stackexchange-softwareengineering
{ "answer_score": 1, "question_score": -2, "tags": "web development, customer relations" }
Raise Event from store procedure to Windows Service Is it possible to trigger an action in Windows Service, or is it possible to raise an event that can be caught in a Service from a stored procedure. If you imagine a service runs every 5 minutes thats performs some action. What if something happens in a database or a stored procedure is executed and I want to trigger this action earlier than the 5 minutes. Does anybody have any ideas? Thanks Ed
Following on from Mehrdad's comments, I was able to solve the problem using the SqlDependancy Class in the .NET framework. This Class allows you to register a SQL query and connection with it, when the result of that query changes an event is raised to indicate a change in the data. This allowed me to catch data changes almost instantaneously and deal with appropriately. In order to use this Class you will need to Enable Query Notifications on the database you wish to query see: Enabling Query Notifications.aspx) A good example of how to use this class in a Windows Application is found here.aspx).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "c#, sql server, clr" }
Javascript onkeyup delayed function call I want to make a Javascript function that fires `onkeyup` event and its task is to call a main resolver function but only if no keys are fired for at least x milliseconds where `x` is the functions parameter. For instance: We have html code: <body> <input type="text" id="suggestion" onkeyup="callMe(200);"/> </body> and Javascript something like: <script type="text/javascript"> function callMe(ms) { //wait at least x ms then call main logic function // e.g. doMain(); alert("I've been called after timeout"); //for testing purposes } </script> So while I'm typing the alert won't be called until you don't type anything for at least x ms.
You can use a timer, you also need to clear the previous timer each time. To achieve this, better use "wrapper" function: <input type="text" id="suggestion" onkeyup="DelayedCallMe(200);"/> And the JavaScript: var _timer = 0; function DelayedCallMe(num) { if (_timer) window.clearTimeout(_timer); _timer = window.setTimeout(function() { callMe(num); }, 500); } This will execute the function 500 milliseconds after the last key up event. Live test case.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 3, "tags": "javascript, events, timer, dom events" }
Is there any way to create reliable recurring notificatons on every Android device? What I want to create: An offline app that sends a text notification to user from the database (Room) once every 5 days at a random time. I test the app on my real device Redmi Note 7 (MIUI). So I tried to use Alarm Manager and Work Manager for repeating task but it only worked right (even app is killed) **if I enabled autorun and disabled buttery optimization** for my application. Then I found out that many manufacturers like Xiaomi, Oppo, Huawei and similar restrict background work for apps. I have 2 questions: 1. What should I use to write reliable recurring notifications (not with foreground service) on every android device without requesting users to enable autorun and similar app settings? 2. How apps like Twitter and Telegram sends notifications without enabling extra settings, although they use the internet unlike my app
So, I found out that there is no way to send reliable recurring notifications offline via Alarm Manager or Work Manager on every android device. I use FCM and everything works great
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "android, push notification, notifications, android notifications, android workmanager" }
Conditional Javascript based on WP Version How would I go about creating a conditional statement in PHP to load a javascript file dependent on the active version of the WP installation? i.e. if using Wordpress 3.8 load javascript file A, if using Wordpress 3.9 load javascript file B.
You can do this with the function `get_bloginfo()`. There is a special paramater called `version` that retrieves the wordpress version from the `$wp_version` variable set in wp-includes/version.php. So you could do something like this function register_jquery_wp_version() { global $wp_version; if ( $wp_version >= 3.8 ) { // register and enqueue jquery A }elseif( $wp_version >= 3.9 ) { // register and enqueue jquery B } } add_action( 'wp_enqueue_scripts', 'register_jquery_wp_version' );
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "php, wp enqueue script, wordpress version" }
Compare list item with a dictionary key and print out the value of the key if the item exists in the dictionary Example code: my_dict = {'ABC':'Apple','DEF':'Mango','GHI':'Pear','JKL':'Orange','MNO':'Plum'} lst_x = ['DEF','GHI'] Expected result: ['Mango', 'Pear']
One approach would be to use a `list comprehension` to construct the requested list. Essentially we iterate through the `list` in the outer loop, and through the `dictionary` in the inner loop and then we compare the `list` value with the `key`from the `dictionary`, and should we have a match, then we save the value of the associated `key` in the new output list. This code snippet below works as described above: my_dict = {'ABC':'Apple','DEF':'Mango','GHI':'Pear','JKL':'Orange','MNO':'Plum'} lst_x = ['DEF','GHI'] out = [value for element in lst_x for key, value in my_dict.items() if element == key] print(out) When run it prints: ['Mango', 'Pear']
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "python" }
Ruby equivalent of this curl command curl -s -XPOST localhost:9200/_bulk --data-binary @filename.json I am looking at RestClient gem and cant figure out how to do this. I need this for making a bulk request to elasticsearch.
Using `rest-client` RestClient.post 'localhost:9200/_bulk', File.new("filename.json", 'rb'), 'Content-type' => 'application/x-www-form-urlencoded' not sure if `rest-client` automatically set `content-type`, just check without it.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "ruby on rails, ruby, ruby on rails 3, curl, rest client" }
What is the syntax My variable (`$tax_terms`) contain this information: Array ( [5] => stdClass Object ( [term_id] => 120 [name] => work [slug] => work ) ) I want to display the name. what would be the php syntax to display the name.
You can use: $tax_terms[5]->name;
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -4, "tags": "php" }
Why do cats sometimes sleep in plant pots? My grandparent’s cats slept in their plant pot when it had nothing in, they only did it often in summer. I wonder why they would want their pelts to be dirty with grit and dirt and weeds.
Same reason they sleep in other locations - warmth and comfort. Plant pots containing soil warm up in the daytime in summer, the soil and pot retaining that heat (especially if they're terracotta pots). It seems natural that a cat would find a plant pot an attractive place to stay. Being round allows the feline to curl up comfortably as well. They don't especially want dirt and grit on their coats, but that's something they can deal with afterwards (most of the time they'll probably shrug the dirt right off).
stackexchange-pets
{ "answer_score": 6, "question_score": 1, "tags": "cats, behavior, psychology, sleep" }
Hide exim4 version from email headers I've setup exim4 on a ubuntu 12.04 server. When an email is sent, the current "Received" header has the following content: Received: from user by example.com with local (Exim 4.76) (envelope-from <[email protected]>) id 1VmqiC-0005b0-PG for [email protected]; Sat, 30 Nov 2013 15:30:20 00:00 How can I hide the Exim version (4.76) currently being used by the server? Should I be concerned about security if the Exim version is known?
You can define you own Received: header using `received_header_text` option. Looks like Ubuntu is using default one, so you can copy example from docs and just remove `$version_number` from it. You should be concerned about security independently from showing version - there was security issues with exim of course. If you have patched system then this is matter of taste. If you hide it then you will be a bit more secure, but debugging of problem with mail from you on remote side will be maybe a bit harder.
stackexchange-superuser
{ "answer_score": 2, "question_score": 0, "tags": "ubuntu 12.04, exim" }
Overlapping routes in react-router I've got number of nested routes and would want them to be displayed one at time. The top route is, let's say, '/sports' <> <Route exact path={`${match.path}/favs`} component={LiveFavs} /> <Route exact path={`${match.path}/:sportId`} render={props => <Live {...props.match.params} />} /> <Route exact path={`${match.path}/:sportId/:eventId`} render={props => <LiveEvent {...props.match.params} />} /> </> Navigating to `/sports/favs` should display first route ONLY, but currently it's mixed with route no. 2 (`:sportId`)
You need to import the `Switch` component from `react-router-dom` and wrap it around your Routes. Essentially, it goes through your routes and renders only the first route who's path is satisfied by the URL being navigated to. Try this: <Switch> <Route exact path={`${match.path}/favs`} component={LiveFavs} /> <Route exact path={`${match.path}/:sportId`} render={props => <Live {...props.match.params} />} /> <Route exact path={`${match.path}/:sportId/:eventId`} render={props => <LiveEvent {...props.match.params} />} /> </Switch>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "reactjs, react router" }
ターミナル起動時に発生するエラーについて (eval):1: parse error near `()' macOS Big Sur 11.2.3 Python
pyenvzshrc`eval "$(pyenv init -)"`
stackexchange-ja_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "macos, zsh" }
How to grant another user Cloud deployment privileges for my FatFractal domain? Is there a way to grant other FatFractal users Cloud deployment privileges on one of my domains? The domain/application are registered under my FatFractal account, and my partner is receiving 400 Errors (permission denied) from his FF local runtime engine when attempting to deploy an updated version of the app. Also, is it possible to limit the scope of deployment privileges to a specific domain/application combo as opposed to the entire domain?
If you go to the FatFractal Console and then click on "Invitations" in the menu, you can give other users read-only or read/write privileges to domains and applications.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "custom backend" }
Disable automatic iTunes launch when iPhone is plugged in via USB How do I disable automatic iTunes launch when iPhone is plugged in via USB (for charging)? In fact, I would like to disable automatic launch of anything when an iPhone is plugged in (including photo sync).
* ### iTunes Open iTunes, select your device, go to the Summary tab and unselect either **Open iTunes when this iPhone is connected** , or **Automatically sync when this iPhone is connected** depending on your version of iTunes. Also, you might wish to disable iTunes Helper. Go to System Preferences → Users & Groups → Login Items and delete iTunes Helper from the list. * ### iPhoto Open iPhoto, open Preferences (iPhoto → Preferences or ⌘,). Select General tab and set **Connecting camera opens** to **No application**. * ### Photos (new version of iPhoto) Let Photos open when you connect your device, select the "Import" tab and untick the box for "Open Photos for this device"
stackexchange-apple
{ "answer_score": 95, "question_score": 69, "tags": "iphone, itunes, macos" }
Are 'Ar-Rabb', 'Rabbi n-nas', and 'Rabbil Aalamin' considered different names for Allah? We know Ar-Rabb is one of the name of Allah. In surah An-Nas, Allah used to call him 'Rabbi n-nas'. In surah Fatiha Allah used 'Rabbil Aalamin'. My question is: Should we consider each of these as a different name of Allah? Or just extensions of the name Ar-Rabb?
It is one name, (Rab), but it is mostly mentioned added to his creatures: Ar-Rabb >> The Rab Rabbi n-nas >> The Rab of people (Lord of people) Rabbil Aalamin >> The Rab of the world (lord of world) Rab Al-Malaekah >> The Rab of Angels (Lord of angels) and others.... They all has the same indication that he is the Lord and owner of all his creatures and the one who can manipulate and control them.
stackexchange-islam
{ "answer_score": 0, "question_score": 1, "tags": "allah, asma ul husna, aqidah" }
Conversion from Minutes To Hours:Minutes:Seconds I want to convert `Minutes` as "Hours:Minutes:Seconds". How can this achieved using c#. I have tried this driveHours = (totalHours.balanceDriveMinutes / 60).ToString("00") + " Hrs. " + (totalHours.balanceDriveMinutes % 60 ).ToString("00") + " Min." + (totalHours.balanceDriveMinutes /3600).ToString("00") + " Sec."; But it doesn't seem to be correct.
try this driveHours = TimeSpan.FromMinutes(totalHours.balanceDriveMinutes).ToString(@"hh\:mm\:ss");
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "c#, minute" }