INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Most optimal way to find the sum of 2 numbers represented as linked lists I was trying to write a program for the problem I mentioned above, the numbers (i.e the lists) can be of unequal length, I was not able to figure out a way to do this other than the most commonly thought of approach i.e 1. reverse list-1 2. reverse list-2 3. find the sum and store it in a new list represented by list-3 4. reverse the list. The complexity of this should be of the O(n+m). Is there anyway to reduce it, or do it better?
Ideally the first thing I would do is store the numbers in **reverse** digit order, so 43,712 is stored as: 2 -> 1 -> 7 -> 3 -> 4 It makes arithmetic operations **much** easier. Displaying a number can be done either iteratively or more simply with a recursive algorithm. **Note:** all this assumes singly-linked lists. **Edit:** But you've since stated you have no choice in the storage format. As such, your best bet is to reverse both the lists, do the addition and then reverse the result.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c++, c, data structures, linked list" }
Find the perfect square! Your task is to turn a square root like this: √12 into a form like this: 2√3 For our purpose, we only need to output the left number here: 2 ## Test cases 4 -> 2 9 -> 3 12 -> 2 13 -> 1 108-> 6 ## Specifications * You may assume for the input that \$n>0\$. \$n\$ has to be as large as possible. * If the number is already a perfect square, do this: √4 = 2√1 -> 2 * If the number doesn't contain perfect squares, do this: √13 = 1√13 -> 1
# Japt `-mx`, ~~4~~ 3 bytes _Crossed out &nbsp4;  is no longer 4 :)_ ²vN My first Japt answer. :) Port of my first 5-byter 05AB1E answer, but with smart use of Japt's flags for the range and sum. -1 byte thanks to _@Shaggy_ thanks to the shortcuts list: `p)`/`p␠` to `²` Try it online. **Explanation:** -m # Convert the (implicit) input-integer to a ranged list [0, input) ² # Square each value in the list, and implicitly close the function vN # Check which values are divisible by the input (1 if truthy; 0 if falsey) -x # After which the sum is calculated of the resulting list # (before the result is output implicitly)
stackexchange-codegolf
{ "answer_score": 6, "question_score": 19, "tags": "code golf, math" }
creating a map from two vectors If I have two stl vectors vect1, vect2 and I want to produce from them a map, so first element from vect1 will correspond to first element in vect2 and so on. How can I do that in the most simple way?
std::vector<int> a, b; // fill vectors here... std::map<int, int> m; assert(a.size() == b.size()); for (size_t i = 0; i < a.size(); ++i) m[a[i]] = b[i];
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 12, "tags": "c++, stl, vector, dictionary" }
APEX set item value & session state with javascript I am trying to set the value and the session state with Javascript in oracle apex. Here my function that I call: function setItemValue(node) { $s('P2020_SELECTED', node); apex.server.process ('MY_PROCESS', { p_arg_name: 'P2020_SELECTED', p_arg_value: node }); } The display value (Line 2) will be set but the session state not. I get this error on page load in apex. Error: SyntaxError: Unexpected token P in JSON at position 0
Try this: function setItemValue(node) { $s('P2020_SELECTED', node); apex.server.process('MY_PROCESS',{ pageItems: '#P2020_SELECTED' },{dataType: "text"}); }
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "javascript, oracle, oracle apex" }
Load two dropdowns with the same values Is there any problem with loading the same set of values in 2 different HTML form dropdowns? My code looks like this: var dr1=document.getElementById("dr1"); var dr2=document.getElementById("dr2"); for (nombre in elements) { var opcion=document.createElement('OPTION'); var cam=elements[nombre]; opcion.value=nombre; opcion.text=cam["nombreCompleto"]; //Añadimos a los 2 dropdowns dr2.add(opcion, null); dr1.add(opcion, null); } dr1.selectedIndex=0; dr2.selectedIndex=0; This load the same set of values to two different dropdowns. However, when executed, it only loads whatever dropdown appears last in the code; in the above example, it would have been "dr1" (and if I put the "dr2.add(option.null)" line last, it loads that one). If I load only one dropdown (commenting out the other one) it works fine. All of this is on Firefox 3.6.10.
Yes, your OPTION objects will first be added to dr2, then to dr1. There won't be created copies when calling add, but the object you just created will be moved from _nowhere_ to _dr2_ , then to _dr1_. The general idea is that you can't have a DOM object in two different places at the same time. You may want to take a look into JavaScript object cloning. See here for some useful information: What is the most efficient way to deep clone an object in JavaScript? . If you just need to clone DOM element objects you can use `cloneNode()`. See here for a complete list of available members and methods: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, html, dom" }
Forcing Dovecot to use SSL I set up a mail server on an Ubuntu 11.04 distribution using the dovecot-postfix package. sudo apt-get install dovecot-postfix For some reason, I can't seem to disable non-SSL access through dovcecot. I have made the following edits to the configuration file in an attempt to accomplish this. /etc/dovecot/dovecot.conf ... protocols= imaps ... disable_plaintext_auth = yes ... ssl = required ssl_cert_file = /etc/ssl/certs/dovecot.pem ssl_key_file = /etc/ssl/private/dovecot.pem A telnet connection to port 143, however, reveals that dovecot is still accepting non-ssl connections. Where have I gone wrong?
You should be able to establish TLS connections, which connect on Port 143 and start in plain text, even though SSL is "required". If you want to disable TLS (which is more advanced than SSL) you'll need to rewrite the software or block the port (there might also be a way to disable to port, though I can't remember).
stackexchange-serverfault
{ "answer_score": 5, "question_score": 6, "tags": "linux, ubuntu, postfix, dovecot" }
Java Play! 2 - Cache.remove < Atm i can't find the Cache.remove method. I guess it's not implemented yet? Then I would need to use a 3rd party library cache solution such as memcached for now. // 2.0 final Cache.set("item.key", null, 0) // later Cache.remove("item.key")
Although it's totally unclear it can be read as: Since `Play 2.0 final` to remove cache entry use: Cache.set("item.key", null, 0); (it will set cache for `item.key` with `null` value, which will expire after 0 seconds) 'later' means that somebody forgot to add this method and it will be added later ;) **Edit:** This issue is already addressed in Play's Lighthouse
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 7, "tags": "java, playframework 2.0, ehcache" }
How to add listener on alert dialog box with customised radio button in android I am trying to add customised radio button in alert dialog box. Now I want to add listener on that. I have tried to add listener using Radio group but it shows null pointer exception. This is my code. Please how to add listener whereby I want to dismiss the dialog box on clicking any of the radio buttons final AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); LayoutInflater eulaInflater = LayoutInflater.from(this); View eulaLayout = eulaInflater.inflate(R.layout.alertdialogcustom, null); alt_bld.setView(eulaLayout); RadioGroup rgroup = (RadioGroup)findViewById(R.id.group1); Thanks Astha
I got it myself using Dialog dialog.setContentView(R.layout.alertdialogcustom); dialog.setTitle("This is my custom dialog box"); dialog.setCancelable(true); final RadioGroup rgroup = (RadioGroup)dialog.findViewById(R.id.group1); final RadioButton rbutton_series = (RadioButton) dialog.findViewById(R.id.option1); final RadioButton rbutton_overlay = (RadioButton) dialog.findViewById(R.id.option2); rgroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "android, radio button, android alertdialog" }
Get build specifications list and other Properties I am facing some challenge to read Project's build specification list and some properties of build specs (Ex. Destination Path). Is there a good way to do this, VI scripting? Please have a look on picture below: ![enter image description here](
If you use some internal VIs from Application Builder, I believe you can accomplish your goal. I used my VIKit tool VIQueryBuildSpecs as a starting point to show how: ![VIQueryBuildSpecs.vi]( The internal Application Builder VIs are located here: `vi.lib\AppBuilder\AB_API\Build`: * Open Build.vi * Get Primary Destination Path.vi * Close.vi While this works for most output target types, the only way I see to get this information for a zip file target is using `Preview.vi` instead of `Get Primary Destination Path.vi`, but it takes much longer since a preview is generated.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "labview" }
Plotting a Transcendental Function How would I plot $m_{2}$ as a function of $m_{1}$ for $0.5< m_{1} < 10$, for the following equation: $$\frac{\sin(m_{2})}{(m_{1}+m_{2})^{2}} = \alpha,$$ where $\alpha$ is a non-zero constant? I cannot solve for $m_{2}$ in terms of $m_{1}$. Any suggestion would be appreciate it. Thanks
Mathematica, follwing @Alan's advice. ($x$ is going left to right, $y$ is going bottom to top, like usual). !enter image description here
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "graphing functions, transcendental equations" }
Is this proof of the following integrals fine $\int_{0}^{1} \frac{\ln(1+x)}{x} dx$? $$\int_{0}^{1} \frac{\ln(1+x)}{x} dx = \int_{0}^{1} \frac1x\cdot (x-x^2/2 + x^3/3 -x^4/4 \ldots)dx = \int_{0}^{1}(1 - x/2 + x^2/3 - x^4/4 \dots)dx = 1-\frac1{2^2} + \frac1{3^3} - \frac{1}{4^4} \dots = \frac{\pi^2}{12}$$ Also, $$\int_{0}^{1} \frac{\ln(1-x)}{x}dx = -\int_{0}^{1}\frac1x \cdot (x+x^2/2 +x^3/3 \ldots)dx =- \int_{0}^{1}(1+x/2+x^2/3 \dots )dx = -( 1 + \frac1{2^2} + \frac1{3^3} \dots) = -\frac{\pi^2}{6}$$ Using these integral, I evaluate $$ \int_{0}^{1} \frac{\ln(x)}{1-x} $$ by letting $1-x=t$ $$ \int_{0}^{1} \frac{\ln(x)}{1-x} =\int_{0}^{1} \frac{\ln(1-t)}{t} dx = -\frac{\pi^2}{6}$$ However, I'm facing problem while integrating $$\int_{0}^{1} \frac{\ln(x)}{1+x}$$ using the same above way.
Hint: integrate by parts. Let $u = \ln(x)\implies u' = \dfrac1x$ and $v' = \dfrac1{1 + x}\implies v = \ln(1 + x)$. Therefore, $$\int\dfrac{\ln(x)}{1 + x}\,\mathrm dx = \ln(x)\ln(1 + x) - \int\dfrac{\ln(1 + x)}x\,\mathrm dx$$
stackexchange-math
{ "answer_score": 5, "question_score": 2, "tags": "integration, proof verification, improper integrals" }
Applying a function for calculating AUC for each subject I want to calculate the area under the curve(AUC) of concentration-TIME profiles for many subjects (~200 subjects). I am using the package MESS where: AUC = auc(data$TIME,data$CONC, type = "spline") How can I apply it to each unique ID in the data set? and retain the results in R by adding a new "AUC" column in the original data set? The data has the following columns: ID TIME CONC 1 0 0 1 2 4 1 3 7 2 0 0 2 1 NA 2 3 5 2 4 10
One way would be like this. foo is your data. library(MESS) library(dplyr) foo %>% group_by(ID) %>% summarize(AUC = auc(TIME,CONC, type = "spline")) # ID AUC #1 1 9.12500 #2 2 12.08335 If you want to keep all data, you could do this. foo %>% group_by(ID) %>% mutate(AUC = auc(TIME,CONC, type = "spline")) # ID TIME CONC AUC #1 1 0 0 9.12500 #2 1 2 4 9.12500 #3 1 3 7 9.12500 #4 2 0 0 12.08335 #5 2 1 NA 12.08335 #6 2 3 5 12.08335 #7 2 4 10 12.08335
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "r" }
matching regex not working properly in zsh I am finding some wrong results here in bash. I dont know why can some one help to understand whats happening $ [[ example.com/something =~ .*\.mp4\?.* ]] && echo matched2 matched2 My regex is `^.*\.mp4\?.*` should only match something like `example.com/file.mp4?size=large` but how come its matching without any such pattern here. I am using zsh $ zsh --version zsh 5.7.1 (x86_64-pc-linux-gnu)
The backslashes aren't part of the regular expression; the shell performs quote removal to generate the regular expression `.*.mp4?.*`, which matches any string containing 1 or more arbitrary characters, followed by `mp` and an optional 4. You need to escape the backslashes as well. [[ example.com/something =~ .*\\.mp4\\?.* ]] && echo matched2 This will produces the desired regular expression `.*\.mp4\?.*`. (Note that regular expression aren't anchored to the beginning or end of the input string, so `\\.mp4\\?` or `'\.mp4\?'` would suffice.)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "regex, shell, zsh" }
Why does Ruby "script/generate" return "No such file or directory"? I am having trouble using `script/generate`. I am following the tree based navigation tutorial, which says to use `script/plugin install git://github.com/rails/acts_as_tree.git` or `script/generate nifty_layout`. I keep getting: > No such file or directory -- script/plugin I've tried these variations: script/generate nifty_layout rails generate nifty_layout ruby script/generate nifty_layout ruby generate nifty_layout and they all tell me: > -bash: script/generate: No such file or directory Am I missing something? Total ruby nuby here and I just can't seem to find an answer. **edit** : rails 3 on Mac OS X 10.6
Rails 3 is your problem (or rather the cause of). Since rails 3 all of the "script/whatever" commands have been replaced with "rails whatever". So now you want "rails generate ..." or "rails server" instead. Be sure to watch version numbers or post dates when looking at tutorials :) linkage: Missing script/generate in Rails 3
stackexchange-stackoverflow
{ "answer_score": 60, "question_score": 23, "tags": "ruby on rails, ruby, scriptgenerate" }
Searching within objects inside mongo collections I'm playing around with MongoDB with mongoose and come to a slight roadblock atm trying to implement searching within objects in a collection. So I have a schema that is as follows: var schema = mongoose.Schema({ form_id: Number, author: Number, data: String, files: String, date: { type: Date, default: Date.now }, }); The `data` is just a JSON object of key/values. An example entry of a record: { "form_id" : 5, "author" : 1, "data" : " {\"staff\":\"Joe Blow\", \"date\":\"25th Jan 2013\"}", "_id" : ObjectId("5101fd4ee6ca550000000003"), "date" : ISODate("2013-01-25T03:34:38.377Z"), "__v" : 0 } How do I search for a specific value inside the data object? I'm trying to do something like the following but not having any luck :( db.forms.find({form_id: 5, data: '/Joe/i'});
If you omit the single quotes around the regular expression it should work: db.forms.find({form_id: 5, data: /Joe/i}); But are you sure you want `data` to contain a JSON string instead of an object? An object would give you so much more flexibility.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "node.js, mongodb, mongoose" }
add_lvalue_reference/add_rvalue_reference and cv-qualified type cppreference.com about `std::add_lvalue_reference`/`std::add_rvalue_reference`: > If T is an object type or a function type that **has no cv- or ref- qualifier** , provides a member typedef type which is T&&, **otherwise type is T**. Does it mean that if T is _const_ or _volatile_ than T is not converted to reference? If no, then what does it mean _"has no cv-qualifier"_.
It's trying to say that the result is respectively `T&` or `T&&` if either: * `T` is an object type, or * `T` is a function type that does not have any cv-qualifiers and does not have a ref-qualifier. The restriction "has no cv- or ref-qualifier" does not apply to object types. It applies to function types because if a function type has a cv- or ref-qualifier, then it is not possible to create the referenced type. See Abominable Function Types for some discussion.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 4, "tags": "c++, c++ standard library" }
How to work with the python sqlite output data? I need a help with Python3.7 sqlite3 database. I have created it, inserted some data in it but I am not able to work with these data then. E. g. test = db.execute("SELECT MESSAGE from TEST") for row in test: print(row[0]) This is the only thing I’ve found. But what if I want to work with the data? What if I now want to make something like: if (row[0] == 1): ... I could not do it that way. It does not work. Can you help me? Thank you.
The database queries returned as array of the rows. And each row is array of received column values. More correctly `test` is tuple or tuples, but let's keep it simple. In your example could be many rows, each with a single column of data. To access first row: test[0] To access data in the second row: test[1][0] Your example: if (test[0][0] == 1): ... I hope that helped.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, database" }
Hiding .Rproj.user when building packages developed in RStudio A package's `.Rbuildignore` looks like this: ^.*[.]Rproj.*$ ^\.Rproj\.user$ ^.Rhistory$ [~] Yet `R CMD check mypackage --as-cran` returns: * checking for hidden files and directories ... NOTE Found the following hidden files and directories: .Rproj.user From reading around, it looks like this is a "feature not a bug". But how do I just prevent `.Rproj.user` from appearing in the package file in the first place? Or do I have a problem with my regex?
.Rbuildignore is used to ignore files when building the package. If you build the package, the files that were ignored will not be in it. I think you are probably trying to check the source instead of checking the build. Try this R CMD build mypackage R CMD check mypackage_1.0.tar.gz --as-cran Writing R Extensions says: > It is strongly recommended that the final checks are run on a tar archive prepared by R CMD build.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "r, package" }
How to get the key, value and index in a Dictionary loop? I have a dictionary and I want to loop it and get the key, value and it's index as `Int`, but with my loop, I'm just only getting the key and value, how can I get the index? This is my code for getting its key and value: var myDict:[String: String]? func getKeyValueIndex() { if let myDict = myDict { for (key, value) in myDict { print(key, value) } } } My expected result was to print the index too `print(key, value, index)`
Dictionaries are unordered, so all you can do is to enumerate through the dictionary, like this: func getKeyValueIndex() { if let myDict = myDict { for (index, dict) in myDict.enumerated() { print(index, dict.key, dict.value) } } }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "ios, swift, dictionary" }
Visibility not changing on hover I'm working on a simple nav bar with a drop-down menu on hover using the visibility property. But when I hover, the condition does not take effect. What is the logic behind this? <
You are trying to make the subitems visible with ul li:hover ul{ visibility: visible; } but the subitems `ul` is not nested inside an `li`, so `ul li ul` does not match the subitems. Therefore, change your html to something like <ul> <li>Menu Item 1 <ul> <li>Sub-Menu1 Item 1</li> <li>Sub-Menu1 Item 2</li> <li>Sub-Menu1 Item 3</li> </ul> </li> … </ul> please also see my forked fiddle.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "css, hover" }
como fazer passagem por valor em JavaScript Tenho a seguint situação: let a=[{nome:"oi"},{nome:"xau"}] let b=Object.assign([], a) b[0].nome=5 console.log(b) //[{nome:5},{nome:xau}] console.log(a) //[{nome:5},{nome:xau}] a pouco tempo atras perguntei aqui como passar valores sem ser por referencia, me falaram para usar o Object.assing, mas ainda assim nao esta dando certo, alguem pode me ajudar como faria para alterar o b[0].nome sem alterar o a?
O método `assign` faz uma cópia rasa, ou seja, copia os valores de atributos que são do objeto, mas o que for referência ele copia o valor da referência. No seu exemplo `a` contém duas referências e por isso não está funcionando. A sugestão que eu achei que poderia ajudar seria usar: var b = JSON.parse(JSON.stringify(a))
stackexchange-pt_stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "javascript, referência" }
How do I perform this special operation with a calculated field in Access? I have a Microsoft Access table called `calc1` with fields: * `calc_ID` (primary key, number) * `calc` (text) I have another table called `res1` with: * `res_ID` (primary key) * `calc_ID` (number) * `dimensionbefore` (number) * `dimensionafter` (number) * `result` (calculated) There is a relation, one `calc1` to many `res1`, linking with `calc_ID`. Is it possible to make the `result` field take its formula from the `calc` field in the `calc1` table? Example: For elongation the field `calc` is ([dimensionafter] - [dimensionbefore]) / ([dimensionbefore] * 100) and `calc_ID` is 1. In the `res1` table if the `calc_ID` is 1 then the result field would take the text from `calc` and make it its formula and return the result.
Create a query like this: SELECT res1.res_ID, res1.calc_ID, res1.dimensionbefore, res1.dimensionafter, Eval(Replace(Replace([calc1].[calc],"[dimensionafter]",[dimensionafter]),"[dimensionbefore]",[dimensionbefore])) AS result FROM res1 INNER JOIN calc1 ON res1.calc_ID = calc1.calc_ID; The `result` field will return the right calculation result.
stackexchange-superuser
{ "answer_score": 0, "question_score": 1, "tags": "microsoft access" }
NuGet feeds vs. NuGet Server vs. NuGet Gallery we are a small developer team and we want to start using our Libraries as NuGet packages. Now I have seen that we can create a NuGet feed or a NuGet Server or a NuGet Gallery. Now we are not sure what's the difference and what's the rights decision for our small team. Can someone please explain us that? Thank you in forward! Regards Matthias
Quick breakdown: Feed: Preferable if you want your packages to only be available to your team. You can choose your audience. Server: Packages are available to public through http protocall. Gallery: Packages are hosted on an Internet server using the NuGet Gallery Project (github.com). NuGet Gallery provides user management and features such as an extensive web UI that allows searching and exploring packages from within the browser, similar to nuget.org. Please read more here
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "c#, .net, nuget" }
What did Penelope say to the police chief in The Brothers Bloom? What did Penelope (Rachel Weisz) say to the police chief in The Brothers Bloom after she was caught in the castle in Prague so that he let her go? Or was this ever explained in the movie?
From the script: CHIEF OF POLICE (in Czech) It has been a privilege, madame, to behold even briefly such a strong, beautiful flower. PENELOPE (in Czech) Thank you sir, I will not soon forget your kindness.
stackexchange-movies
{ "answer_score": 8, "question_score": 9, "tags": "plot explanation, brothers bloom" }
Difference between null terminated char (\0) and `^@` My codes are like this: #include <iostream> using std::cout; using std::endl; int main(int argc, char *argv[]) { cout << (int)('\0') << endl; cout << (char)(0) << endl; return 0; } I expected to see in terminal like this: $ test-program 0 $ However, what I saw is like this: $ test-program 0 ^@ $ What makes me confusing is that I think `'\0'` can be converted to `0`. And `0` can also be casted into `\0`. I expected to see a null char followed with a `endl`, but the result is something weird like `^@`. Does anyone have ideas about this?
`^@` is just how your terminal emulator renders `'\0'`.
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 4, "tags": "c++, c, arrays, string, char" }
Can a mask stick to a shape in the motion tracker? I have some video footage of a flat surface (for this example, let's say it's a binder or a book), and I want to digitally replace the cover of the book using a plane in Blender. So, I set up my tracking scene and align the plane and stuff and it attaches to the book. The problem is, someone picks up the book, so their hand is now covering part of it. Is it possible to draw a mask that will conform to the shape of the hand, or something similar? Maybe like a lasso tool (like they have in photoshop) or something similar? Or will I have to adjust the mask frame-by-frame? Thanks. :)
The mask control points can be controlled by trackers. So track the hand (or the edges where the hand moves over the book cover) and parent those trackers to the mask. To do that select the mask's control point, then shift-select the tracker to control it and press `Ctrl``P`. Now the control points will follow the tracker automatically.
stackexchange-blender
{ "answer_score": 11, "question_score": 7, "tags": "tracking" }
How to count specific word in Google Sheets without matching parts of words I am trying to count the occurrences of the word "desk" in the text of A1 cell for example. All the text is in lowercase, it contains "desk" many times, the word sometimes has punctuation marks at the end, and there are also overlapping words "desktop" and "desks". I've tried two formulas: =(LEN(JOIN(" ",A1))-LEN(SUBSTITUTE(JOIN(" ",A1),"desk","")))/LEN("desk") Unfortunately this formula counts absolutely all occurrences of "desk", including overlaps in "desktop" and "desks". =COUNTIF(SPLIT(JOIN(" ", A1), " -."&CHAR(10)), "desk") This formula is able to count individual words, but it seems it cannot count words with some punctuation marks at the end - the number of words is always less than it actually is.
try: =LEN(REGEXREPLACE(REGEXREPLACE(A1, "\bdesk\b", ""), "[^]", )) ![enter image description here]( or: =INDEX(QUERY(FLATTEN(SPLIT(REGEXREPLACE(A1, "[""\.,?!:]", ), " ")), "select count(Col1) where Col1 = 'desk'"), 2) ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "google sheets" }
Why does my code run just fine but in the end of it it always print "None" There is my code: towel_num = int(input(print("How many towels did he buy? - "))) my code run just fine but at the end of it always prints "None" Why?
The problem is using print in your input statement: < You don't need print, you can just supply the string directly: towel_num = int(input("your message here")) Addendum: For future reference, in this case, the print function returns None because it has no return of its own. The input function will display whatever value is provided to it, which in this case is the None returned from print. If print is used on its own, None does not invoke any response from the Python interpreter.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python" }
Voltage regulator current and heating Many texts I read take (Vin - Vout)*Iload i.e the current Iload is I3 in the below figure when calculating temperature of a regulator: ![enter image description here]( But I3 is not exactly same with I1 there is something called "quiescent current". Check out my previous question: Voltage regulator and Kirchhoff current law So would you take I1 or I3 if you were to calculate the temperature of a regulator?
A 7805 has a quiescent current of about 5mA so with an input voltage of say 15V this is a power of 75 mW and enough to scorch (a little bit) most 0603 size resistors. But the 7805 is a T0-220 package and so it might get a little warmer but this small temperature rise is insignificant compared with the 10 volts dropped at maybe 500 mA load current i.e. 5 watts. 75 mW is 1.5% of 5 watts.
stackexchange-electronics
{ "answer_score": 2, "question_score": -1, "tags": "voltage, voltage regulator, temperature" }
Integration Testing for a Web App I want to do full integration testing for a web application. I want to test many things like AJAX, positioning and presence of certain phrases and HTML elements **using several browsers**. I'm seeking a tool to do such automated testing. On the other hand; this is my first time using integration testing. Are there any specific recommendations when doing such testing? Any tutorial as well? _(As a note: My backend code is done using Perl, Python and Django.)_ Thanks!
If you need to do full testing including exploiting browser features like AJAX then I would recomend Selenium. Selenium launches a browser and controls it to run the tests. It supports all the major platforms and browsers. Selenium itself is implemented in Java but that is not really an issue if it is being used to test a web application through its user interface. Selenium tests are a sequence of commands in an HTML table, the supported commands are in well documented. There is also an IDE implemented as a Firefox plugin that can be used to record and run tests. However the test scripts created in the IDE can be used to drive tests against any of the supported browsers.
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 10, "tags": "python, ruby, perl, automated tests, integration testing" }
what's the meaning of ordinates of a Gaussian distribution? In a Gaussian distribution, what's the meaning of the height (ordinate) at $x$? according to [[1]]( the funtion is called the probability distribution function of a Gaussian distribution, according to [[2]]( it calculates the height of a Gaussian distribution. Does this function mean the probability at $[-\inftyx]$, or the height (ordinate)? TIA.
The function you mentioned (better to write in with MathJax) is NOT the probability distribution, it is the pdf: probability Density function (the ordinate, as you said). $$ \bbox[5px,border:2px solid black] { f(x|\mu\;\sigma^2)=\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{1}{2\sigma^2}(x-\mu)^2} \qquad } $$ The probability distribution is its integral function $$\mathbb{P}[X\leq x]=\int_{-\infty}^x f(t)dt$$
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "probability distributions, gaussian" }
Setting up Programm-o locally After reading the installation guide for program-o < I was wondering how I would go about doing step 2 locally and installing it without hosting an online server?
Just put your code in **htdocs** directory (inside xampp instalation directory). Then You will be able to execute your code by typing 'localhost' in your browser. Or if you want to use other domain instead of localhost, You have to edit your hosts file. In Windows7 hosts file is located in: > %systemroot%\system32\drivers\etc My hosts file for example: 127.0.0.1 domain.com I can access my code by typing for example 'domain.com' instead of 'localhost'
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "apache, xampp, server" }
IP Camera (RTSP) and QR codes I am working on a project that would enable my application to connect to one or more IP cameras (RTSP, H264) and detect any QR codes. The library I want to use for the QR Code detection is the ZXing Project. One I can capture the frame from the camera and decode it to an Bitmap, the QR code detection is easy. I am struggling to find a library or two to connect to the IP camera, and take still images at a given internal. Real-time would be nice. I have tried EMGU (OpenCV) port for C#. It kinda works, but its very slow and will hang one or two minutes into it. The camera I am using is 720p. I am working with the net7mma library now, but I am having trouble decoding the H264 frame to a bitmap. Any suggestions would be appreciated!
It seems that others have found success using openRTSP: < Note the -m option for outputting single frames: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, opencv, rtsp, ip camera, rtsp client" }
Core Data attribute crawling as nil after renaming, even after I changed the name back I foolishly renamed some Core Data entity attributes and ran the app, then realised files I opened were crashing because they did not have the same attribute, so I changed the name back. However, the attributes I renamed are still crawling as nil even after I changed the name back. Is there any easy fix to this without migration? I'm 99% sure renaming them was the problem as the non-renamed attributes aren't nil. Files made after this also don't throw this error when I load them. If it helps, I have an unedited copy of the older file, is there any way to swap it out with the current one? Would that work?
If you don't want to add migration, just remove and install the App. But if you want to rename a property in already published App than you need to add lightweight migration.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, core data" }
Why does WP rename similar "term name"-slugs in separate taxonomies? I have several custom taxonomies and within two of those ( Company Categories and Photographer Categories ) I have a term that is similar. The Company Category called Boudoir and the Photographer category called Boudoir Photographers. When I created the Boudoir Photographer term in the Photographer Categories it renamed the Boudoir term in the Company Categories to Boudoir Photography. Why did this happen? The number of posts for either taxonomy term doe snot change, only its name and the slug. Thanx in advance!
They are all in your `{wpdb->prefix}_terms` table and therefore need to be unique. Else you could only get them via ID.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "custom taxonomy, slug, terms" }
Standard for modelling JSON data in IOS I have some JSON data I'm pulling into an IOS app. Now coming from a .Net background I would normally create a 'Model' for the data like so. public class MyData{ public IEnumerable<SubData> ActualData {get;set;} public string SomeValue {get;set; } public class SubData { public string Name {get;set;} } Now using, ObjectiveC - whats the recommended method? I've seen lots of uses Dictionary style objects and not yet seen an example of actual class based models. I'm fully aware I could use the model based approach but I don't want to 'go against the grain', I'm using NSJSONSerialization to parse the JSON if that makes a difference. I've done some mapping to simple JSON objects using [result objectForKey:@"Key"]; But now I need to deal with more complex JSON (With X number of elements) data the strings no longer seem to cut it.
Rather opinion based, but I guess most people use `NSDictionary` and `NSArray` if the storage is just temporary. If the storage is longer term then you might move the data into core data, which is easy to do with KVC from the dictionary and array structure, or using a library like RestKit. A similar approach can be used for custom `NSObject` subclasses. I think the important thing is to be clear about what you're doing and to make the implementation clear (or well documented).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "ios, json" }
Adding custom OAuth to Xenforo 1.5 We need the ability to log in to Xenforo 1.5 using our own OAuth which is developed already. I didn't find any proper documentation on how to do that. Any help much appreciated. I know they have options to use FB, Google and Twitter. There should be a way to add custom connected accounts too. Thank you!
OK, so there's no documentation on that for Xenforo 1.5 What I did is just downloaded an add-on that does it for some social networks and looking at the code to see how it's done.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "php, oauth, xenforo" }
Ninject StandardKernel System.ArgumentNullException: value cannot be null. Parameter name: path1 I am a learning `Xamarin` and I wanted to use `Ninject` for `IoC` containers and dependency injection. I added `Ninject 3.3.4` using `NuGet` package on `Visual studio 2017` community. I receive error on the following line of code in my App.Xaml.cs: Kernel = new StandardKernel(new TripLogCoreModule(), new TripLogNavModule(mainPage.Navigation)); I receive following error: > Ninject StandardKernel System.ArgumentNullException: value cannot be null. Parameter name: path1 I spent about 2 hours on the internet and couldn't find a solution to my problem. Finally, I found the oversight that I made, so I thought to post this question and answer my own question, in case someone else (newbie like me) make this mistake.
The oversight that I made was that I installed the wrong package. I should have installed `Portable.Ninject`. In order to fix this, I uninstalled the `Ninject3.3.4` from all my projects and then installed `Portable.Ninject 3.3.1` (latest stable version at the time of writing) via NuGet package. I hope this helps and saves time for those people who may make similar mistake!
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 5, "tags": "xamarin, ninject" }
How to inclide tspecials(<," etc.) in URL for HttpServer? I have implemented simple com.sun.net.httpserver.HttpServer application using one of examples in the internet. Server get request as expected except for one exception: if url contains tspecials: " or '<' "/" request doesn't reach the server at all. Using simple java.net.ServerSocket all works great and request received where all tspesials are encoded, which is great for me, but i prefer use HttpServer. for example request: id="1">value</xml> works for ServerSocket and not working for HttpServer. Any help will be appreciated.
You need to encode your urls on the client side, using the % notation: < On the server side, you should use URI.getRawQuery() in case the query contains & characters, and décode parameter values with URLDecoder.decode.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, http" }
Autodesk Forge Viewer - show markups all the time We are using the Forge viewer to show both 2D and 3D models. For the 2D models, we would like to be able to show markups all the time, like you can with the viewer inside BIM360. I tried the solution mentioned here: Forge Viewer: Show bottom toolbar and markups at the same time \- but I have not been able to get that to work. It seems like when I call: Autodesk.Viewing.Extensions.Markups.Core.Utils.showLmvToolsAndPanels(viewer) It hides the markups. How is this done in BIM360? - are they using a custom viewer, where this has been enabled somehow?
Unfortunately I was able to get it to work with: Autodesk.Viewing.Extensions.Markups.Core.Utils.showLmvToolsAndPanels(viewer) See live sample here: ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "autodesk forge, autodesk viewer, autodesk bim360" }
How to invalid HttpSession in Vaadin Atm, my project using Vaadin 7. And i'm creating a login form. I need to invalid session before log in user so user will get new session id each time. Currently, i try to get VaadinSession, then get WrappedSession, and finally invalid that WrappedSession. VaadinSession.getCurrent().getSession().invalidate(); This did invalidate my HttpSession and generate new session id ( Which calling close() from VaadinSession can't do it ). But after i invalidate my session, UI hang without any error. So is it correct to invalid HttpSession this way? Or there some better way to invalid session ? Thank you for your help!
Ok so after a while checking class reference, this is the correct way to handle it in Vaadin 7: VaadinService.reinitializeSession(VaadinService.getCurrentRequest()); They changed class which hold this method, making me have a hard time finding it.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "httpsession, vaadin7" }
Customizing Iphone Keyboard Is there a way to customize the iphone keyboard? Say I want the number pad with a comma button and a period button added to it.
What you are looking for is a custom IME (Input Method) which is not directly supported in iOS (true custom IMEs have been developed, but require jailbreak). You can create a custom view, but just for your application.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "iphone" }
Validating items inside an array - Symfony 2.1 I'm using the Symfony 2.1 validation module to validate data for my REST API, it works correctly but I'm wondering if there is any easy way to validate items inside an array. For example, one of my fields is an array of dates, I want to ensure that each item inside is correctly formatted date. I am using YAML as follows to set constraints, `array_of_dates` is the field I'd like to be able to validate each item inside that array to be a valid date. # src/Acme/DemoBundle/Resources/config/validation.yml Acme\DemoBundle\Entity\Demo: properties: start: - NotBlank: ~ - Date: ~ end: - NotBlank: ~ - Date: ~ array_of_dates: - Type: type: array
Apply All constraint validator. > This constraint allows you to apply a collection of constraints to each element of the array
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 7, "tags": "symfony, symfony 2.1" }
Linq query or Lambda expression? I'm using Entity Framework in my ASP.NET, C#, Web Application. If I need to select a record from DataBase (in Data Access Layer), which method should I use? Linq query or a Lambda Expression? Eg:- //Linq var result = from a in db.myTable.Take(1) where a.Id == varId select a; return result.First(); //Lambda return db.myTable.FirstOrDefault(a => a.Id == varId); Is there any preferred way in this scenario or any advantage over the other?
Query Expression compiles into Method Expression (Lambda expression), so there shouldn't be any difference, In your code though you are accessing `First` and `FirstOrDefault` which would behave differently. See: Query Syntax and Method Syntax in LINQ (C#) and LINQ Query Expressions (C# Programming Guide).aspx) > At compile time, query expressions are converted to Standard Query Operator method calls according to the rules set forth in the C# specification. Any query that can be expressed by using query syntax can also be expressed by using method syntax. However, in most cases query syntax is more readable and concise.
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 9, "tags": "c#, linq, lambda" }
CSS: how to align text content horizontally-centered and vertically-centered? how can i align text content inside div horizonally-centered and vertically-centered? <div style="height: 300px;"> <p>Envision various details for your big day with help from our photo catalog, which features images filtered by category. See actual works from suppliers to help you make decisions.</p> </div>
You need to use `display: table-cell;` and `vertical-align: middle;` properties with `text-align: center;` as well to align the text vertically and horizontally centered **Demo** div { border: 1px solid #f00; display: table-cell; text-align: center; vertical-align: middle }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "html, css, vertical alignment, alignment" }
How to get complete row when using max(points) AS in mysql? I'm using this code. $query = "SELECT max(Points) AS Points,City FROM Table_name WHERE Gender='Female' && Country='England' GROUP BY City"; I want it to give the complete row, not just Points and City. In my database the order is ID, City, Points, Name, Gender, Country. When I run this line of code it only gives me Points and City. > I have tried * but doesn't work.
I guess you want the whole row with the max points value, i.e. rows with Female/England/city where there are no one with higher points: SELECT * FROM Table_name t1 WHERE Gender='Female' AND Country='England' AND NOT EXISTS (select 1 from Table_name t2 WHERE t2.Gender='Female' AND t2.Country='England' AND t2.city = t1.city AND t2.points > t1.points) Will show both rows if it's a tie. To return only one row / city, just add an < id condition in the `EXISTS`: SELECT * FROM Table_name t1 WHERE Gender='Female' AND Country='England' AND NOT EXISTS (select 1 from Table_name t2 WHERE t2.Gender='Female' AND t2.Country='England' AND t2.city = t1.city AND t2.points > t1.points AND t2.id < t1.id)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, mysql, sql" }
sharepoint calendar security How can I display a calendar in SharePoint that behaves like my Outlook calendar? I know I can link the calendar to outlook, but anyone can make changes to my calendar in Sharepoint. How can the Sharepoint calendar enforce security on the calendar so that nobody can override my changes?
In SharePoint 2007, there is an option to configure item-level permissions if you go to your **List Settings -> Advanced Settings** page. In the **Item-Level Permissions** section, under **Edit access: Specify which items users can edit** , select "Only their own". That should take care of it for you.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "security, sharepoint, calendar" }
How to massage redux data into props in react I am trying to massage some redux data into the props of a child component. The issue is that I am not sure how to do so with this type of data. I would just like to grab the first exchange there is from the data returned in redux.
You can just take the first element of the Object.keys array & use it as a key. this.props.exchangeMarketsData[Object.keys(this.props.exchangeMarketsData)[0]]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, reactjs, react native, redux, react redux" }
A Secret Riddle > I can be many colors. > Or just red, maybe brown. > > I'll tell you where things went wrong, > Unless I'm out on the town. > > I can be assembled, broken > Or even on fire! > > You could find me in a d-ring > Or policing new hires. > > At the bar, you can read me. > And monkeys know me well indeed! What am I?
Is it > Code? I can be many colors. Or just red, maybe brown. > Colour code, Code red and Code brown I'll tell you where things went wrong, Unless I'm out on the town. > Error code and Post code I can be assembled, broken Or even on fire! > You can break a code, (Thanks Rubio!) an assembly code and (Thanks @Sconibulus) Fire Code You could find me in a d-ring Or policing new hires. > A (Thanks @Deusovi) decoding ring and (Thanks @Rubio) code of conduct At the bar, you can read me. And monkeys know me well indeed! > A bar-code and (Thanks @Sconibulus) Code Monkey And, of course, the title: 'A secret riddle' > Talking in code
stackexchange-puzzling
{ "answer_score": 4, "question_score": 5, "tags": "riddle, rhyme" }
How to access third Nested ListView properties Good Morning I want to know how to get the ListView Control in this scenario: <asp:ListView ID="lv1" runat="server" OnItemDataBound="lv1_ItemDataBound"> <asp:ListView ID="lv2" runat="server"> <asp:ListView ID="lv3" runat="server"> </asp:ListView> </asp:ListView> </asp:ListView> in Codebehind: protected void lv1_ItemDataBound(object sender, ListViewItemEventArgs e) { ListView lv2 = (ListView)e.Item.FindControl("lv2"); // Accessed ListView lv3 = (ListView)e.Item.FindControl("lv3"); // Not Accessed (NULL) } I'm trying to access the nested last one from the parent ListView. Any advice please. ??
Try using the ItemDataBound event of lv2 to get lv3 protected void lv2_ItemDataBound(object sender, ListViewItemEventArgs e) { ListView lv3 = (ListView)e.Item.FindControl("lv3"); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "c#, asp.net" }
Como fazer uma consulta por período dia, semana, mês no MySQL Como fazer uma consulta por período dia, semana, mês no MySQL? por exemplo gostaria de exibir dados filtrados por períodos exemplo exibir dados ontem, semana passada, duas semanas, três semanas, um mês atras e assim por diante com a data no formato date **2017-06-21 09:26:31**
Há muitas formas de fazer isso, veja a documentação do Mysql para Datas:MYSQL Date and Time Functions. **_Exemplos:_** _Ontem:_ Select * minhaTabela where Date(Data) = DATE_SUB(CURDATE(),INTERVAL 1 DAY); ou Select * minhaTabela where Date(DATE_ADD(Data,INTERVAL 1 DAY)) = CURDATE(); _Semana passada:_ Select * from minhaTabela where Week(data)+1 = Week(curdate()); ...Na documentação tem várias funções e exemplos.
stackexchange-pt_stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "mysql, banco de dados, select, data, tabela banco de dados" }
Render components from an array of object I have an array of object, containing another array of object like this : [{label: "Commons", path: "commons", component: Commons, subroutes: [ { label: "Commons doc", path: "commons/doc", component: CommonsDoc, }] }] Then I pass it as a prop to a component, and map the prop to render in React the first level component "Commons" with this in another bloc : <StyledRouter> {routes.map((route, index) => ( <route.component path={route.path} key={index} /> ))} </StyledRouter> I'm using Reach Router for React, and now I'm trying to render the second level component at subroutes, using a second map function right under the first `<route.component path={route.path} key={index} />` But I can't get it work like this `{route.subroutes.map(...)}` to render the `CommonsDoc` component in my second array of object
Something like this should help you: const composeRoutes = (routes) => { allRoutes = routes.map((route, index) => { if (route.subroutes.length > 0) { let withSubRoutes = []; withSubRoutes = composeRoutes(route.subroutes); withSubRoutes.append(<route.component path={route.path} key={index} />); return withSubRoutes; } return <route.component path={route.path} key={index} />; }) return _.flatten(allRoutes); }; <StyledRouter> {composeRoutes(routes)} </StyledRouter>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, reactjs, react router" }
Unable to decrypt EFS files with cipher command I tried to decrypt a EFS file with the built-in cipher command: `cipher -d "D:\sample.txt"`, and here's the output: Listing C:\Windows\System32\ New files added to this directory will not be encrypted. Listing D:\ New files added to this directory will not be encrypted. E sample.txt Here's the screenshot. After the command was executed, I rebooted my computer and found the target file is still protected by EFS. How can I get the cipher command to work? The system is Windows 10. Thanks! Update: Here's what I got when run the command `cipher "D:\*"`: Listing D:\ New files added to this directory will not be encrypted. E sample.txt
> I tried to decrypt a EFS file with the built-in cipher command: **cipher -d "D:\sample.txt"** Your syntax isn’t correct. The correct command is **cipher /d /f "D:\sample.txt"** Cipher
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "encryption, efs, decrypt" }
SQL server Update Dynamic Column for Some row I have following Data ---------------------------------------------- Program | GN | GNF | SC |SCF ---------------------------------------------- P01 | 10 | 2 | 5 | 2 P02 | 10 | 2 | 5 | 2 I want: User execute stored procedure setQuota with parameters @PROGRAM say P02, and some @category say GNF . Result should be: Decrease value of Program for that category by one. that is, for P02 GNF would be 1 I have following Code DECLARE @SEATCAT NVARCHAR(MAX) = N'GEN' DECLARE @PROG NVARCHAR(MAX) = N'U03' declare @sql1 nvarchar(max) begin declare @sql nvarchar(max) set @sql = 'Update SHEAT SET [' + @SEATCAT + '] = [' + @SEATCAT + ']-1 Where PROGRAM='' + P01 +'''; exec sp_executesql @sql end Select GEN FROM SHEAT Where PROGRAM=@PROG;` I am getting errors:
You are missing a quote and also are using `P01` like a variable but it isn't defined. Did you mean to write `@PROG` so it would be like Where PROGRAM=''' + @PROG + '''; As a further note: If either of these variables are coming from user input (eg someone types them in) then you should really look into SQL Injection attacks as you may be allowing arbitrary code to be run through this procedure.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, sql server" }
Gradle build failed, keystore.properties not found I tried to open this GitHub project with Android Studio < But sync failed because the system cannot find keystore.properties file. I tried some solutions I found at other threads by commenting out release line in build.gradle, but it didnt work. signingConfigs { // release { // keyAlias keystoreProperties['keyAlias'] // keyPassword keystoreProperties['keyPassword'] // storeFile file(keystoreProperties['storeFile']) // storePassword keystoreProperties['storePassword'] } } I could be commenting out the wrong parts or there are other reasons. Please advise.
If you want to use the same script, you have to create a `keystore.properties` in the root of your project with your values: storePassword=123456 keyPassword=abcdef keyAlias=myAlias storeFile=../keystore.jks You can find some tips here. Otherwise you can have many options to configure the signing configs. For example: signingConfigs { release { storeFile file("release.keystore") storePassword "******" keyAlias "******" keyPassword "******" } } Other info in the official doc.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "android, android studio" }
To find the Value of $\tan A + \cot A$, if the value of $\sin A + \cos A$ is given To Find - $$\tan A + \cot A$$ Given, $$\sin A + \cos A = \sqrt2$$ My progress as far - 1st way- $$\Rightarrow \sin A = \sqrt2 - \cos A$$ $$\Rightarrow \tan A = \frac{\sqrt2 - \cos A}{\cos A}$$ $$\Rightarrow \tan A = \frac{ \sqrt 2 }{\cos A } - 1$$ $$\Rightarrow \tan A + \cot A =\frac{ \sqrt 2 }{\cos A} -1 + \cot A $$ and the 2nd way as - $$(\sin A + \cos A)^2 = 2$$ $$\sin ^2 A + \cos ^2 A + 2\sin A\cos A = 2 $$ $$\Rightarrow 2\sin A\cos A=1$$ $$\Rightarrow \sin A\cos A=\frac12$$ As we can see the first way is unable to give an answer in absolute Real Number, and the second way doesn't go even near to what is required to proof. I know few trigonometry identities as per my textbook, those are * $\sin^2 A + \cos^2 A = 1$ * $1 + \cot^2 A = \csc^2 A$ * $\tan^2A + 1 = \sec^2 A$
$$\tan{A}+\cot{A}=\frac{1}{\sin{A}\cos{A}}=\frac{2}{(\sin{A}+\cos{A})^2-1}=2$$
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "trigonometry, proof verification" }
Select threshold (cut-off point )for binary classification by desired fpr persentage value I want to recreate `catboost.utils.select_threshold`(desc) method for `CalibratedClassifierCV` model. In Catboost I can select desired fpr value, **to return the boundary at which the given FPR value is reached**. My goal is to the same logic after computing fpr, tpr and boundaries from `sklearn.metrics.roc_curve` I have the following code prob_pred = model.predict_proba(X[features_list])[:, 1] fpr, tpr, thresholds = metrics.roc_curve(X['target'], prob_pred) optimal_idx = np.argmax(tpr - fpr) # here I need to use FPR=0.1 boundary = thresholds[optimal_idx] binary_pred = [1 if i >= boundary else 0 for i in prob_pred] I guess it should be simple formula but I am not sure how to place 0.1 value here to adjust threshold.
I've done my research and testing and it's that simple: def select_treshold(proba, target, fpr_max = 0.1 ): # calculate roc curves fpr, tpr, thresholds = roc_curve(target, proba) # get the best threshold with fpr <=0.1 best_treshold = thresholds[fpr <= fpr_max][-1] return best_treshold
stackexchange-datascience
{ "answer_score": 1, "question_score": 1, "tags": "classification, scikit learn, metric, binary classification, catboost" }
How to check default first radio button in angular material Trying to checked the first radio button as default. But I do not know how to do it. If any one knows please help to find the solution. app.component.html: <div class="input"> <mat-radio-group class="radio-group"> <mat-radio-button class="radio-button" *ngFor="let bus of buses" [value]="bus" > {{ bus }} </mat-radio-button> </mat-radio-group> </div> Demo: <
You can add the index to `*ngFor` and set `checked` when index is equal to zero. <div class="input"> <mat-radio-group class="radio-group"> <mat-radio-button class="radio-button" *ngFor="let bus of buses; index as i" [value]="bus" [checked]="i === 0" > {{ bus }} </mat-radio-button> </mat-radio-group> </div> Stackblitz: <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "angular, angular material, angular8" }
Configuring nginx to prevent timeouts in Cloudbees I have a long process in my cloudbees (roo + spring mvc) app that results in a timeout. According to this previous question a solution would be to change the configuration of nginx (in particular the send_timeout directive ). My problem is that I´m not sure how can I change this given the fact that I´m not self-hosting the application but using CloudBees for that. Is this something that I can somehow indicate in the cloudbees-web.xml configuration file? (I haven´t been able to find a complete list of configuration parameters I can include in this file eihter)
Yes you can do this. You need to change your applications setting to have proxyBuffering=false when you deploy. This will allow long running connections. You only need to do this once when you deploy. eg bees app:deploy (etc) proxyBuffering=false you can also use app:update to change an existing apps config (only need to do this once, it will remember it) using the BeesSDK \- look for the section on app:deploy and app:update
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "nginx, cloudbees" }
Script for deleting files starting with texts listed in a file I have a strings.txt file that contains a list of strings like this: 0100101 0100102 0100103 0100104 ... I need to create a script that deletes all the files in a directory, starting with each of the strings contained in the previous file. If there are files with these names in the directory, they should be deleted: 0100101.jpg 0100101-01.jpg 0100101A1.jpg If there are files with these names in the directory, they should not be deleted: 40100101.jpg 570100102.jpg 340100104-02.jpg Can you help me?
You can use a combination of cat and xargs to achieve this cat strings.txt | xargs -t -I{} sh -c 'rm {}*' More Info on xargs: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "bash" }
What do you call the prongs of an electrical plug? I speak German on a daily basis and I don't know what to call the prongs of an electrical plug. This makes me so uncomfortable that I have to ask in English about it. I have searched the internet to find out, but couldn't find a schematic showing the name of the prongs in German. Are they "Zinken", "Zacken", "Sporne" or even something else? Who's the electrician to tell me? ![an electrical plug showing the prongs prominently]( and the original image link, although I don't expect it to last for a very long time:
These are called # _Stifte_ (singular: _der Stift_ ) or _Kontaktstifte_. There are _Rundstifte_ like in continental Europe and _Flachstifte_ like in the UK and the US.
stackexchange-german
{ "answer_score": 23, "question_score": 8, "tags": "single word request" }
Bundle ActivSync 4.5 With Visual Studio 2005 Setup Project How do you bundle ActivSync with your C#.NET application? I have an installer and it works fine for the SQL Server 2005 Express and .NET 2.0 Framework when I selected them as prerequisites. I'd also like to setup ActivSync as a pre-requisite as well.
If you want ActiveSync to appear in your Visual Studio setup project's list of available prerequisites then you will need to create a custom bootstrapper package. Here is a very thorough blog post on the subject: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "c#, .net, visual studio 2005, installation" }
How to 'talk' to USB modem in Linux? I have a USB modem that is identified in Linux (Ubuntu 12.04) with `lsusb` as Bus 001 Device 003: ID 0572:1329 Conexant Systems (Rockwell), Inc. How to talk to that device (e.g. with microcom etc?)? What `dev` device should I use? There is no `/dev/ttyUSBXXX` available and just one `/dev/ttyACM0`.
If by talk you mean send AT commands in the form echo "ATi" > /dev/usbDev try this: <
stackexchange-askubuntu
{ "answer_score": 3, "question_score": 7, "tags": "12.04, usb, modem" }
use LIKE with array in laravel I am trying to get a list of registered users that are on the contact list of a user. Since many users save phone numbers without the international prefix so I can't use `whereIn`. I am using the last 7 digits of the user's contact phone numbers to compare with phone numbers of users in the database to return registered users on a user's contact. my code looks like this public function getUserContact($userNumbers){ $numbers = array($userNumbers); $regUsers = User::where(function($query) use($numbers){ foreach($numbers as $userNumber){ $query->orWhere('phone_number', 'LIKE', '%'.$userNumber.'%'); } }); return $regUsers->get(); } My `$numbers` array looks like this "data": Array [ "060738,3952483,953333,5953333,3879009" ], but I keep getting an empty array as response. What am I doing wrong
You're `$numbers` variable is an array with one string of comma delimited numbers, you should be exploding them, not wrapping in an array, try this instead: public function getUserContact($userNumbers) { $numbers = explode(",", $userNumbers); $regUsers = User::where(function($query) use ($numbers) { foreach($numbers as $userNumber) { $query->orWhere('phone_number', 'LIKE', '%'.$userNumber.'%'); } }); return $regUsers->get(); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, laravel" }
Sending image (.jpg) byte data to an iOS device from a .NET web service, then on the iOS device, encoding it to its respective file type (.jpg) I have a web service that sends image byte data (`.jpg`) to an iOS device. The iOS device saves that data to the `.jpg` that it is, and once it's saved to the local file system, the file cannot be opened due to a "corrupt file" message we get when trying to open it on the iOS device. The specifics of this message are irrelevant. I am a .NET developer developing the web service. I don't know anything about Objective C - we have another developer handling that. **QUESTION** : What I need to know is if the iOS device expects the byte data to be encoded a certain way, whether it has to be a Base64 string, etc. I'm not sure what the convention is for sending a file via byte data over to an iOS device. Any help would be appreciated.
Been there, but on the iOS end. What we did to solve this problem was to have the .NET server send the image as a base64 encoded string, just as you said. In the iOS end, the dev must then use a base64 decoding class (there are plenty on the internet, this one for example: < transform that into NSData and then create the image with that data. Should look something like this: NSString *b64string = @"string to decode"; NSData *imgData = [DecoderClass decodeBase64FromString:b64String]; UIImage *image = [UIImage imageWithData:imgData]; If the data is correct, it should work. UIImage is a high-level class and should handle image types (jpg, png, etc) automatically, as long as the data is consistent.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c#, ios, web services, encoding, asmx" }
Circular ViewPager Indicator like Galaxy Tab2 Hii i want to make a circular `ViewPager` Indicator same exartly like `Samsung Galaxy Tab2`,I have 5 `Frgments` in my `Viewpager` you can navigate in a circular way like this **1->2->3->4->5->1 so on .** is anybody has any idea how to achieve this.
Yes i solved my question by using setting indicator images dynamically based on the pages of viewpagers with out using any external library..
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "android, android fragments, android viewpager" }
How to get filename of custom filetype file that was loaded into my application from windows explorer? In my application I have my own custom filetype. I set it up so my application opens up files of this type when they are clicked outside of my application. Now my question is: How can I get the SafeFileName of the file being opened? I know that that variable S is my filename, although I want to get just the actual files name without the location. If (Environment.GetCommandLineArgs.Length > 1) Then Dim s As String = Environment.GetCommandLineArgs(1) ' Open file s End If I know if I was using the filename it would be OpenFileDialog.SafeFileName, and that would give me test123.txt instead of C:\Files\Test123.txt How could I do the same in this situation.
It depends on what the string that is being returned looks like and if it is a valid path, if it is like your example you can use Path.GetFileName Method of the System.IO Namespace. Dim s As String = "C:\Files\Test123.txt" Dim myFile As String = Path.GetFileName(s)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": ".net, vb.net, visual studio 2010, deployment, file type" }
Formulaa Convert Date format DD/MM/YYYY to MM/DD/YYYY in Google Sheets I'm having an issue with `Datevalue` function cause it's not reading DD/MM/YYYY date format. It's giving `Error DATEVALUE parameter cannot be parsed to date/time.` I tried changing the number format but the date should be reflecting DD/MM/YYYY cause it's from Australia. Is there a formula that can change this date format? Please help.
The only way is to change the Locale File > Spreadsheet settings > Locale Google Help
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "google sheets" }
Passing function as parameter to jQuery template I'm trying to send a function as parameter to a jQuery template and display the first element returned by the function. In the following example, data variable is a function and I'm trying to append first element returned. It's not a solution to store data into a variable because there are many cases when data is an array, not a function. var template= ' {{each things}}{{if $index == 0}}<span>${this.Name}</span>{{/if}}{{/each}}'; $('.dropdownText').text(jq.tmpl(template, data));
I am not sure if i got the question rigt but if the problem is data can be a function or array you probably just have to do this var selectedTemplate = ' {{each things}}{{if $index == 0}}<span>${this.Name}</span>{{/if}}{{/each}}'; function getData(data) { if (Array.isArray(data)) return data; if (typeof data === 'function') return data(); } $('.dropdownText').text(UMT_jq.tmpl(selectedTemplate, getData(data)));
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, function, parameters, jquery templates" }
Copy past from ms word to WordPress with content style and color scheme When I copy content from an MS Word file to the WordPress editor, colour schemes are not being pasted. is there any way to achieve it? **Content on word as shown** ![red, blue, black text in Word]( **Content on WordPress editor** ![black text in a different font]( That's how it paste on WordPress classical editor How can I achieve it
Save as a web page and then copy from that into WordPress.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "wordpress, ms word, copy paste" }
How to use copyfile when there are spaces in the directory name? I am trying to perform a simple file copy task under Windows and I am having some problems. My first attempt was to use import shutils source = 'C:\Documents and Settings\Some directory\My file.txt' destination = 'C:\Documents and Settings\Some other directory\Copy.txt' shutil.copyfile(source, destination) `copyfile` can't find the source and/or can't create the destination. My second guess was to use shutil.copyfile('"' + source + '"', '"' + destination + '"') But it's failing again. Any hint? * * * **Edit** The resulting code is IOError: [Errno 22] Invalid argument: '"C:\Documents and Settings\Some directory\My file.txt"'
I don't think spaces are to blame. You have to escape backslashes in paths, like this: source = 'C:\\Documents and Settings\\Some directory\\My file.txt' or, even better, use the `r` prefix: source = r'C:\Documents and Settings\Some directory\My file.txt'
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 8, "tags": "python, windows, file copying" }
Event Listeners in Spring boot I have a `TestController` scoped session. It's handling `MyEvent`. @Controller @Scope("session") @RequestMapping(value = "/test") @Slf4j public class TestController { private String phone = getPhone(); private String getPhone() { String phone = RandomGenerator.generateNumeric(4); log.info("Phone is: {}", phone); return phone; } @EventListener public void listen(MyEvent event) { log.info("Event in {} ({})", this, RandomGenerator.generateNumeric()); } } But when I publish the event, only one of instances of the TestController class are getting this. But I want to handle an event in all of the instances. Could you help me?
You are declaring the `@Controller` with `@Scope("session")`, so you get a new controller bean for each session. Then, in an undisclosed part of the code you publish an event, so it is reasonable that only the controllers within the same session as the publisher receive the event, because the other controllers are on other sessions. Therefore, since you have **one** controller per session, the event is only consumed **once**. The solution is to change the scope from `session` to `singleton` (default) and not to store state in the controller (that phone number).
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "java, spring, events, event handling" }
Suggestion regarding user control I am working on an app named E-Diary in WPF. Now I have to implement the the real diary input, means when i write in a box then i go to the 2nd box and so on. It is like a real diary. As in the image !enter image description here Now I need suggestions regarding implementation of above given description that whether i use text boxes in the list box **or** I make a user control which contains text boxes and labels as in image and use it in the wpf according to the number of boxes. I also have to save data in the database, If I use a button with each user control then how it could be managed to save the specific data? This might be not a real question in terms of the FAQ rules of stackoverflow but I have been thinking for a long time but cant find the right way. Thanks in advance
In WPF you don't have to make UserControls quite as often as in WinForms to get a good design. And this is IMHO true for your problem too. Go on and use a Listbox or ItemsControl but use DataTemplates to display and edit the dataitems just as you want to. Here is a nice tuturial how to do this: Data Templates and make sure to have a look at the MSDN Documentation on Data Templating too.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c#, wpf, user controls, listbox" }
EmailAddress field length in database > **Possible Duplicate:** > What is the optimal length for an email address in a database? What would you put as the length of an email address field? In the db I look after we have nvarchar(60) but this seems arbitrary. Is there a maximum length I can allow for or are email address lengths unbounded? EDIT this is a dupe of What is the optimal length for an email address in a database? please close
The maximum length of an email address is 254 characters. Every email address is composed of two parts. The local part that comes before the '@' sign, and the domain part that follows it. In "[email protected]", the local part is "user", and the domain part is "example.com". The local part must not exceed 64 characters and the domain part cannot be longer than 255 characters. The combined length of the local + @ + domain parts of an email address must not exceed 254 characters. As described in RFC3696 Errata ID 1690. What is the optimal length for an email address in a database?
stackexchange-stackoverflow
{ "answer_score": 16, "question_score": 1, "tags": "database design" }
Viewing Flash Socket I have a flash (ActionScript 3.0) which uses socket connection to send data to the server. Is there any way to view the sent socket data? (like http-requests in firebug)
Consider Fiddler2 if your data is HTTP(S). Or "pcap" is an option for the raw packet data.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "flash, sockets" }
How to give Jupyterhub access to hive tables through spark in EMR The default installation of JupytherHub in EMR has no access to the Hive context in Spark. How can I fix this?
To grant spark access to the Hive context, you need to edit the livy.conf file (/etc/livy/conf.dist/livy.conf) like this livy.repl.enableHiveContext = true and then restart your notebook and the livy service, following the instructions here, basically: sudo stop livy-server sudo start livy-server An easy way to check if it's working, is to check for the databases on your spark notebook: spark.sql("show databases").show Yo may want to configure this on the EMR booting time, by using the standard configuration features of the EMR, <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "apache spark, hive, jupyter, amazon emr, jupyterhub" }
headers_sent() return false, but headers were sent My code is simple: <!DOCTYPE html> <html> <head> ... <?php var_dump(headers_sent()); ?> It returns false. Shouldn't the headers be sent immediately after something is printed? Like just after the first `<` character.
It depends if your `output_buffering` directive in `php.ini` file. If it is `Off` `output_buffering = Off` then `echo headers_sent()` should output `1` In other cases, `headers_sent()` won't output any results because it will be FALSE. The headers won't be sent because the output is buffered. If you want to get around this and force-send headers, you can use `flush()`. Hope this helps!
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 5, "tags": "php, html, http headers" }
Series $\sum(-1)^{a(n)}\frac1{a(n)}$ converging to infinity with $a:\mathbb N\to\mathbb N$ a bijection I'd love to get a hint or direction on this and figure out a solution myself: Construct a bijection: $$\: f:\mathbb{N} \rightarrow \mathbb{N} $$ such that: $$ \sum_{n=0}^{\infty} -1^{f(n)}\frac{1}{f(n)} = \infty $$ I thought of something like below to eliminate all series elements that are negative: $$ f(n):= \left \\{ \begin{array}{ll} n^{odd} \rightarrow n-1 \\\ n^{even} \rightarrow n\\\ \end{array} \right. $$ But then $f(n)$ cannot be a bijection. Another way would be to transform the fraction $\frac{1}{f(n)}$ into something that is divergent, but I don't see how that would be possible in an $\mathbb{N} \rightarrow \mathbb{N}$ map. * * * **EDIT:** Deleted the suggestion that the resulting series would be a harmonic or geometric series. * * *
The even positive integers can be partitioned into consecutive blocks $E_1 < E_2 < E_3 < \cdots $ such that $$\sum_{n\in E_k} 1/n > 2\,\,\,\text{for each } k.$$ Now think of listing $\mathbb N$ as $E_1$ followed by $1,$ then $E_2$ followed by $3,$ then $E_3$ followed by $5,$ etc. This defines a bijection $f$ of $\mathbb N$ onto $\mathbb N$ for which $$\sum_{n=1}^{\infty} (-1)^{f(n)}\frac{1}{f(n)} \ge 1+1+\cdots = \infty.$$
stackexchange-math
{ "answer_score": 4, "question_score": 1, "tags": "real analysis, sequences and series" }
Different output than expected I just started programming and right now I'm stuck with a problem. I'm wondering how if functions really work. a = [ 20.0, 8.0, 2.5 ] b = 4 if b > len(a): r = 2*b r = b I expected the output of 8, but the actual output is 4. How come? Because 4 > 3 and that should execute the if statement right?
The problem is that you do not have an `else` statement which should be executed if your condition `if b > len(a)` is not `True`. So in your code, the `if` statement is first executed, the value of `r` becomes twice of `b` (`r` becomes 8) but then you come out of the `if` statement and **again** reassign `b` to `r` which is why your `r` becomes 4 again. I hope the concept is clear now. The correct way would be a = [ 20.0, 8.0, 2.5 ] b = 4 if b > len(a): r = 2*b else: r = b
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python" }
PHP/JavaScript Debugging Is there a PHP-enabled webserver, that is tailor-made for debugging? I want to be able to step thru code, both php and javascript. There has to be something that makes web development less painful, but it does not seem to be mainstream, or maby my google-fu is failing me. Any help appritiated.
If you're on a windows machine, WampServer should does the job. It has XDebug which is really helpful. Regrading _JavaScript_ Firebug and Chrome Dev-Tools are great. Except the web-server itself or PHP extensions like XDebug, a powerful IDE can help you a lot as well. Within your source-code, _Exception Handling_ could be extremely useful -- `echo`, `print_r`, `var_dump` and `die` are the other useful options, but not as powerful as _Exceptions_ when it comes to get rid of a bug. `console.log` comes really handy in JavaScript as well.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, php, debugging" }
navigateToUrl AS3 is not opening a web browser I have a textField on my stage named 'adBuy', which when clicked I want to open up my browser with the defined in URL request. However when I click on the 'adBuy' textField on my SWF it opens Coda, the piece of software I'm using to write this small piece of code? I am puzzled. Here is my code: adBuy.defaultTextFormat = adFormat; adBuy.textColor = 0xFF65CB; adBuy.x = 640; adBuy.y = 455; adBuy.text = "Buy Now"; parent.addChild(adBuy); adBuy.addEventListener(MouseEvent.CLICK, buyAdvert); var request:URLRequest = new URLRequest(" function buyAdvert(event:MouseEvent):void { navigateToURL(request, "_blank"); trace("link clicked"); } Is there an error in my code, or is this a common problem for which there is an answer?
Sorry, I have solved my problem. It appears the reason it was not opening a web browser with the URL it because I was running the SWF through 'Test Movie' in Flash. This appears to have been stopping the code working. It did however work fine when I ran it in Flash Player.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "actionscript 3, navigatetourl" }
In ASP.Net (C#), HTML Table does not have 'COLUMN' attribute, what to do? Basically I was doing HTML table to CSV Export in C#, So needed count of all ROWS & COLUMNS I could get the count of Rows by Table1.Rows.Count, but cannot get the count of Columns by Table1.Columns.Count. Any Ideas how do I get the number of columns ? StringBuilder sb = new StringBuilder(); for (int i = 0; i < Table1.Rows.Count; i++) { for (int k = 0; k < **Table1.Column.Count**; k++) { //adding separator sb.Append(Table1.Rows[i].Cells[k].Text + ','); } //appending new line sb.Append("\r\n"); }
`Tables.Rows[i].Cells.Count` would give you the total number of cells in a row. Which would be like columns, but may change where cell(column) spanning is different.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "c#, asp.net" }
How do I make plain text act as a button on click? I was wondering what is the simplest way of making just plain text act as a button (with minimal html). Text: `<li class="indiv-nav" ><a target="_blank" href="/">About</a></li>` I need the text about to perform that of: `<div id="button"><input type="submit" value="Press me please!" /></div>` Sorry if this is a "stupid" question but, I'm still learning and I find it crazy how theres no "simpler" solution than those I found from googling.
try <a href="javascript: void(0)" id="button">Submit</a> jQuery $(function(){ $("#button").bind("click",function(){ $("#idOfYourForm").submit(); // consider idOfYourForm `id` of your form which you are going to submit }); }); JavaScript document.getElementById("button").onclick = function(){ document.getElementById("idOfYourForm").submit(); };
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "javascript, html, button" }
How to count days between date range with a specifific day? How to count days between date range with a specific day? **Example:** START_DT = January 1, 2014; END_DT = January 31, 2014; Day = :SampleDay **Sample Result:** Monday = 4, Tuesday = 4, Wednesday = 5 Please help. :|
Are you looking for something like this, WITH t(date1, date2) AS ( SELECT to_date('01/01/2014', 'dd/mm/yyyy'), to_date('31/01/2014','dd/mm/yyyy')+1 -- Adding 1 to calculate the last day too. FROM DUAL ) SELECT count(days) day_count, day DAY FROM( SELECT date1 + LEVEL -1 days, to_char(date1 + LEVEL -1, 'FmDay') DAY, --Use `FmDay`, this will remove the Embedded spaces. to_char(date1 + LEVEL -1, 'D') DAY# FROM t CONNECT BY LEVEL <= date2 - date1 ) WHERE day = 'Monday' --Filter with day, if you want to get the count for a specific day. GROUP BY DAY, day# ORDER BY day#;
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "oracle11g" }
How do I enable icon setting in Chrome browser? How do I enable this inspect element in Google Chrome? The part that is enclosed in red box. ![expected-result]( Because right now, by default, this is what I see with my inspect element. ![actual-result]( Do I need to install something or this is within settings?
Your screenshots are from different browser dev tools. If m not wrong, the top one is on Firefox where the bottom one is Chrome. * The **Inspector** tab is similar to the **Elements** tab in Chrome * The **Debugger** tab is similar to the **Sources** tab in Chrome
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "google chrome, browser" }
Why can't I access a shared folder from within my Virtualbox machine? I have Ubuntu 14.04 as my host system, and then on Virtualbox, I have Lubuntu 14.04. I am trying to share a folder on my host system so that my guest system can write files to it. I've followed instructions as best I can, installed the Virtualbox guest additions. I've got to the point where I've added the shared folder in the Devices interface: !shared folder However, even after rebooting, I can't find the folder anywhere in my guest system. How do I get my shared folder to actually show up in my guest Lubuntu machine?
You have to mount your folder on your VM. First you need to install Guest Additions (although I already did this during the installation). 1. Start your VM 2. `Devices` > `Insert Guest Additions CD image...` 3. I had to manually mount the CD: `sudo mount /dev/cdrom /media/cdrom` 4. Install the necessary packages: `sudo apt-get install make gcc linux-headers-$(uname -r)` 5. Install the Guest Additions: `sudo /media/cdrom/VBoxLinuxAdditions.run` Now you can mount your share using: mkdir ~/new sudo mount -t vboxsf New ~/new Where `New` is the name of your shared folder. Now you can access the shared folder at `~/new`. * * * **Note:** this is not permanent. To permanently mount your folder you should add the following line to `/etc/fstab` (`sudo nano /etc/fstab`): New /home/user/new vboxsf defaults 0 0 Obviously you should replace `user` in `/home/user/new` by your own username.
stackexchange-askubuntu
{ "answer_score": 125, "question_score": 98, "tags": "virtualbox" }
admin pages loading but not site itself, strange error I installed Craft CMS and all seemed great! But the pages are not loading.. So bascially /admin loads but /index.php genrates an error. In dutch: "Interne Serverfout Craft\EntryModel en zijn behaviors hebben geen method of closure met naam "heading"." Which translated is something like: "Craft\EntryModel and its behaviours have no method or closure with the name heading" Any idea what's wrong? Can be server-level.. I run it on a mac mini server, but mysql, php and apache (plus php-modules) are installed, and again, admin works nicely.. best, Bart
Apparently this is a bug in the latest release. Oops! The default homepage template on a fresh install is referencing an `entry.heading` that no longer exists. Fixed it for the next release, but in the meantime, you can change line 23 of `craft/templates/index.html` from: <h1>{{ entry.heading }}</h1> to: <h1>{{ entry.title }}</h1>
stackexchange-craftcms
{ "answer_score": 2, "question_score": 3, "tags": "error message" }
php preg_replace trailing minus sign I try to remove a trialing minus sign of a string. I've got the following code: $name = preg_replace("/\-$/ismU", "", trim($name)); I also tried: $name = preg_replace("/\\\-$/ismU", "", trim($name)); and: $name = preg_replace("/-$/ismU", "", trim($name)); But that does not seem to work, any ideas what I do wrong? That's should be simple issue but somehow I can't get it to work.
just use rtrim to get any trailing minus signs $name = rtrim(trim($name), "-"); for multiline you can do preg_replace but make sure to account for the trailing spaces $name = preg_replace('/- *$/ismU', "", trim($name));
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, preg replace" }
PHP: Require path does not work for cron job? I have a cron job that needs to include this file: require '../includes/common.php'; however, when it is run via the cron job (and not my local testing), the relative path does not work. the cron job runs the following file (on the live server): /home/username123/public_html/cron/mycronjob.php and here's the error: Fatal error: require(): Failed opening required '../includes/common.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username123/public_html/cron/mycronjob.php on line 2 using the same absolute format as the cron job, `common.php` would be located at /home/username123/public_html/includes/common.php does that mean i have to replace my line 2 with: require '/home/username123/public_html/includes/common.php'; ? thanks!
Technically seen the php script is run where cron is located; ex. If cron was in /bin/cron, then this statement would look for common.php in /bin/includes/common.php. So yeah, you'll probably have to use fullpaths or use set_include_path set_include_path('/home/username123/public_html/includes/'); require 'common.php';
stackexchange-stackoverflow
{ "answer_score": 33, "question_score": 31, "tags": "php, include, cron, require, absolute path" }
Put link into php i want to put link into a sentence that are stored in variable.. how to put the link? because i try use echo..but it did not work.. here is my code: if($_POST['rb_elt_accommodation']=="Yes") $accomodation_val .= "Participants must deal directly with the hotel. Please call the hotel direct at +xxxxxx. Details on accomodation booking are available"echo '<a href="
if ($_POST['rb_elt_accommodation'] == "Yes") { $accomodation_val .= 'Participants must deal directly with the hotel. Please call the hotel direct at +xxxxxx. Details on accomodation booking are available <a href=" } Note how I changed your echo quote char from `"` to `'` This was to allow for `"` inside your html string.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "php" }
How can I reuse an old user name? After upgrading from Windows 7 to Windows 10 Home my (local) user profile seems to be broken. So I want to create a new local profile but using the old user name. Therefore, I renamed the existing user profile (appended `_Win7`), renamed the user directory and changed the `ProfileImagePath` in the registry (`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList`). The profile seems to run fine under the new name (despite the things that were already broken before the renaming). Now the problem: **Windows doesn't let me create a new local user profile using the old profile's name**. The error message is (translated from German): Enter a different user name. How can I create a new profile using a former profile's name?
Thanks to LPChips comment, I found out that the user account wasn't _really_ renamed using Windows 10 Home's system control panel. It was basically jsut the display name which was changed. So I used `wmic useraccount where name='<OLDNAME>' rename <NEWNAME>` (found here) to really rename the account and then I could create a new user with the old account name.
stackexchange-superuser
{ "answer_score": 2, "question_score": 2, "tags": "windows 7, windows, windows 10, user profiles" }
Not sure where my argument breaks down: Let $A \subset \mathbb{R}$ be a countable set. Prove that $\mathbb{R} \setminus A$ is uncountable. $\textit{Proof.}$ Since A is countable, we know it has the same cardinality as $\mathbb{N}$, or $\mid A \mid = \mid \mathbb{N} \mid$. Additionally, since $\mathbb{N} \subset \mathbb{R}$, it is enough to prove that $\mathbb{R} \setminus \mathbb{N}$ has the same cardinality as $\mathbb{R}$, an uncountable set. We will use the Schroeder - Bernstein Theorem: $f: \mathbb{R} \setminus \mathbb{N} \to \mathbb{R}$, $f(x) = x$ $g:\mathbb{R} \to \mathbb{R} \setminus \mathbb{N}$, $g(x) = \frac{1}{e^{x} + 2}$ As we have defined two injections, by the Schroeder-Bernstein theorem there exists a bijection between $\mathbb{R} \setminus \mathbb{N}$ and $\mathbb{R}$. Thus, $\mid \mathbb{R} \setminus \mathbb{N} \mid = \mid \mathbb{R} \mid$, so $\mathbb{R} \setminus \mathbb{N}$ is uncountable. Thus, $R \setminus A$ is uncountable. $\square$
If the complement was countable then the set of reals would be the union of two countable sets, hence countable, a contradiction.
stackexchange-math
{ "answer_score": 6, "question_score": 0, "tags": "functions, elementary set theory, solution verification" }
SVG with interaction I know that animations/transforms can be done in SVG. I want to do this interactively, e.g. if (in SVG) I show a simple sum "2 + 2 = ?", I want the "?" to be an image over the answer, and when the "?" is clicked/touched it fades to reveal the answer underneath. This questions shows how animations can be done, so using this as an example : How to fade in and out color of svg <svg> <rect width="100%" height="100%"> <animate attributeName="fill" values="red;blue;red" dur="10s" repeatCount="indefinite" /> </rect> </svg> How can the fades by triggered by clicks on the rectangle?
Just add begin="click" like so... <svg> <rect width="100%" height="100%"> <animate attributeName="fill" values="red;blue;red" dur="10s" begin="click" repeatCount="indefinite" /> </rect> </svg>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "svg, interactive, svg animate" }
What is the 'opposite' of ekphrasis? Given that ekphrasis means, according to the Poetry Foundation, "an ekphrastic poem is a vivid description of a scene or, more commonly, a work of art", is there a term to describe the 'opposite' where a visual artist depicts a work of verbal art?
Since the Greek word **έκφραση** means _expression_ (see here , the antonym would be _impression_. However, that is not the kind of antonym you're looking for, it seems. The trick lies in the expression _ekphrastic poem_ , which, freely translated, would be a poem that _expresses_ (a scene or a work of art). You do not want a _poem_ that does the opposite, but rather a _painting_ that does a similar thing, which could be called an _ekphrastic_ painting.
stackexchange-english
{ "answer_score": 0, "question_score": 2, "tags": "antonyms, poetry" }
A good way to insert data to DB $query = $this->db->prepare("INSERT INTO `images` (`anunt`, `image_location`) VALUES(?, ?)"); $query->bindValue(1, $iddd); $query->bindValue(2, $image_location); try{ $query->execute(); or this $ret = sql_query("INSERT INTO images (anunt, image_location) VALUES ('" .$iddd. "', '" .$image_location. "')"); Or another way maybe? What advantages are with the bind one? I read something that it's hard to sql inject.
### Databse pre-optimzations When you initialize a prepared statement, the DBMS actually pre-optimizes the database and compiles your query. This would be useful if you plan to make multiple bound queries with the same prepared statement. ### SQL Injection prevention The PHP SQL drivers will escape any literals inside a bound value, to prevent SQL injection.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, mysql" }
how to display google like current location icon in android? friends, i want to add google like circular current location icon in my application as given in example any one guide me how to achieve this? is this simple image or what? any help would be appreciated.!enter image description here
You should create an ItemizedOverlay, if you are speaking about google maps on Android. You can check this stackoverflow question and see the code and links in the posts.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "android, google maps" }
Change default naming-behavior for operation_id If I generate a Java client based on the following endpoint: api_users = APIRouter(prefix='/api/users', tags=['users']) class User(BaseModel): name: str @api_users.get( path='', response_model=List[User], ) async def get_users(): return [User(name='test')] The method name inside the `UserApi.java` file for it will be `getUsersApiUsersGet()` instead of `getUsers()`. I have to set the `operation_id` to something like `get_users` as in @api_users.get( path='', response_model=List[User], operation_id='get_users' ) but this is tedious. Why isn't it just grabbing the method name itself, and uses this as default value instead? So, is there a way I can change that behavior?
It's a bit weird that this is not standard behavior but we can achieve this by running this: def use_route_names_as_operation_ids(application: FastAPI) -> None: """ Simplify operation IDs so that generated API clients have simpler function names. Should be called only after all routes have been added. """ for route in application.routes: if isinstance(route, APIRoute): route: APIRoute = route route.operation_id = route.name app = FastAPI() controller.initialize(app) use_route_names_as_operation_ids(app) # Call after controller were initialized
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "fastapi" }
Python RegEx, match words in string and get count I want to match a list of words with an string and get how many of the words are matched. Now I have this: import re words = ["red", "blue"] exactMatch = re.compile(r'\b%s\b' % '\\b|\\b'.join(words), flags=re.IGNORECASE) print exactMatch.search("my blue cat") print exactMatch.search("my red car") print exactMatch.search("my red and blue monkey") print exactMatch.search("my yellow dog") My current regex will match the first 3, but I would like to find out how many of the words in the list `words` that matches the string passed to `search`. Is this possible **without** making a new `re.compile` for each word in the list? Or is there another way to achieve the same thing? The reason I want to keep the number of `re.compile` to a minimum is **speed** , since in my application I have multiple word lists and about 3500 strings to search against.
If you use `findall` instead of `search`, then you get a tuple as result containing all the matched words. print exactMatch.findall("my blue cat") print exactMatch.findall("my red car") print exactMatch.findall("my red and blue monkey") print exactMatch.findall("my yellow dog") will result in > ['blue'] > ['red'] > ['red', 'blue'] > [] If you need to get the amount of matches you get them using `len()` print len(exactMatch.findall("my blue cat")) print len(exactMatch.findall("my red car")) print len(exactMatch.findall("my red and blue monkey")) print len(exactMatch.findall("my yellow dog")) will result in > 1 > 1 > 2 > 0
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 2, "tags": "python, regex" }
LPT ports in C# I'd like to send some instructions while one of pins of LPT port is on. I was trying to do something like this: When LPT port 379 (889 dec) is different from dec 120 then stop doing part of code. while ((PortAccess.Output(889,120)) I don't know how to do it. I was trying to do something with construction: while ((PortAccess.Equals()) but you need to compare 2 objects.. I suppose it must be very simple solution for this problem.. :)
I think you will need PortAccess.Input: while (PortAccess.Input(889) == 120) { // do stuff } This assumes that "PortAccess" is a wrapper around the native inpout32.dll such as described in this tutorial.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "c#, lpt" }
Create React Native App Command Not Found I am trying to create a react native app using `create-react-native-app`. I have npm install. I have install create react native by adding the following command to my terminal (on mac). sudo npm install -g create-react-native-app When I try and create a create react native app by running the following command I get told that the command is not found. > create-react-native-app myNativeApp > > bash: create-react-native-app: command not found Is there any way I can fix this or am I doing something wrong? I am new to create react native app.
You are running wrong command : To install react native run : > npm install -g react-native-cli And then for creating project run : > react-native init AwesomeProject Here is documentation.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "node.js, reactjs, react native, npm" }