INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Convert $.post to $.ajax I want to convert my `$.post` call to `$.ajax` call because I need to clean the cache for every call. My `$.post` call is as follows: $.post("test", function(data) { $("#test").html(data); initTest(); } ).success(function(){ $('.box1').hide("slide", {direction: "left"}, 1000); $('.box3').show("slide", {direction: "right"}, 1000); }); I tried this but it doesn't work... $.ajax({ type: "POST", url: "test", success: function (data) { $("#test").html(data); $('.box1').hide("slide", {direction: "left"}, 1000); $('.box3').show("slide", {direction: "right"}, 1000); }, dataType: "json", cache: false });
$.ajax({ method:"POST", url : "test.php", success : function(data) { $("#test").html(data); initTest(); $('.box1').hide("slide", {direction: "left"}, 1000); $('.box3').show("slide", {direction: "right"}, 1000); }, cache : false }); UPDATE I think you have problem in parsing data. In `$.post` by default is `html dataType`. In `$.ajax` call you changed it on "json". If no json is responsed so you have parse error and success handler dont call.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -4, "tags": "jquery, ajax, .post" }
Can Eclipse (Kepler) select between two installed MinGW distributions when setting a Toolchain? I was working with **Eclipse Kepler** and I was using one of many **MinGW** distributions that you can find in internet. So, yesterday I decide to install **QTCreator**. But when I finished the QTcreator's installation process I tryed to create a new project in **Eclipse** , and now I'm not able to select other **MinGW** toolchain than the installed by Qt SDK. Is like **MinGW** installation of **QtSDK** shadows my other **MinGW** installation. What I'm missing? Can Eclipse select between two installed MinGW distributions?
Yes it can!!! When a project is created and is set to use the MinGW toolchain you can modify the environment variables for the project. There is a env variable called `MINGW_HOME` oh, thats rings a bell. Right click on the project and select properties (or select the project and press `Alt`\+ `Enter`), follow the path: `C/C++ Build -> Environment` and then change the variable value to the installation path of the mingw distribution you want to use for your project. !Selecting a MinGW distribution for the project you can choose between `Append variables to native environment` or `Replace native environment with specified one`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c++, eclipse, mingw" }
Duplicate Symbol Error from C functions in Objective-C First off, I have only really used Objective-c methods in my programming. I decided to do a couple of quick math calculations as c functions and then ended up needing them for multiple classes. So then I stuck the c functions in a separate .h file. This works fine until I try and import the .h file into more than one class. Then I get this error: > Duplicate Symbol *_myFunction* blah blah blah Linker command failed with exit code 1 (use -v to see invocation) How can I use a c function in more than one class without this link error. I've tried just defining the functions in the classes I need them in, but it seems that even if they are different classes, I get this error if the function name is the same. I'm probably crazy here, but some help understanding would be great.
You should put declarations in the .h file, make them extern, and move definitions into a .c or .m file. From this myfunctions.h int max(int a, int b) { return a>b ? a : b; } Move to this: myfunctions.h extern int max(int a, int b); // declaration myfunctions.c int max(int a, int b) { return a>b ? a : b; }
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 9, "tags": "objective c, c, xcode, linker errors" }
Custom dropdown for specific relationship type When creating a new relationship is it possible to create a dropdown that only displays when you have selected a specific relationship type. For instance: Add custom relationship “Representation” Represented by [individual] Representative of [individual] Add custom dropdown “Representative Type” \- Publicist \- Manager \- Agent When you go to add a relationship currently the Representation dropdown displays on all relationship types. I.e. “child of” displays representative type, clearly unnecessary. Is it possible to only display that dropdown when Representation is selected from the relationship type dropdown? Thank you for your time and consideration, Tim
You can create custom group of fields for a specific relationship with your custom relationship type filter. This custom field will only be visible when you select relationship type from the drop down ![enter image description here]( Cheers Pradeep
stackexchange-civicrm
{ "answer_score": 5, "question_score": 2, "tags": "custom fields, relationships" }
Testing in the Hadoop platform When doing web development we can test our apps with tools and methodologies such as unit testing (jUnit, rspec, ...), TDD, BDD, cucumber, end-to-end/regression/integration tests, H2 (as in process database), ... But in the Hadoop and Big Data world, **How do you test a hadoop/hive/pig code?** By that I mean creating an automation for the situation that given I have a sample input, when I trigger some hive or pig script, then I verify the output is as expected. With more details, **Is there a way to get a quick feedback of these automated tests?** More specifically, how to run in-memory HDFS? In Java with SQL databases, we use H2 to get this quick feedback. Or more broadly, **what are the testing strategies that people use in the Hadoop platform?**
I'm working as part of a team to support a big data and analytics platform, and we also have this kind of issue. We've been searching for a while and we found two pretty promising tools: < < Hope it helps you =)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "testing, hadoop, hive, apache pig" }
Is it better to exclude non essential words in Google searches For example, if I had a question about iMovie, should I search Google: How to add transitions to multiple clips in iMovie Or something like: Add transitions multiple clips iMovie
As Moab mentioned, the Google algorithms are pretty smart, and will often bring up the same results, I would check out Google's own explanation if you want more details. When it comes to optimising search methods, its often best to use Advanced Search. Notice the "To do this in the search box" section on the right - learn these methods and you can perform your own advanced searches from any Google search box without using the Advanced Search page. The full list of symbols and operators can be found on the Search operators page.
stackexchange-webapps
{ "answer_score": 2, "question_score": 1, "tags": "google search" }
Remove rows from uni-dimensional data.frame and retain it as a data.frame For implementation reason in some cases I have a data.frame that only contains one colum df=as.data.frame(alpha=1:15) If I now use df[-1, ] it returns a vector, but I would like to keep it as a data.frame. Any suggestions? PS: The name of the column contains information and I must therefore keep it.
Try: df[-1, , drop=FALSE] Does this work for you?
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "r" }
PHP redirect page and Echo data for get string I have the following PHP code to redirect my page I need to echo a section that was drawn from previous page to assist with the redirecting //Sleep for five seconds. sleep(5); //Redirect using the Location header. header('Location: case_management.php?id=<? echo $rows['case_id']; ?>'); //Post reply drawn $sla_client = $_POST['sla_client']; $case_id = $_POST['case_id']; $status = $_POST['status']; It is giving me Unexpected case_id. This I presume is happening due to the echo side of my string. Any assistance would be appreciated The case_id is drawn from a previous page using POST and I am trying to use that information to redirect the page from the POST reply on this page. I know my above code is trying to look for a row in the database but this will not be found this way. Any suggestion to how to use the POST reply to use in the URL
You opened a php tag inside another already opened php tag. I corrected your code. //Sleep for five seconds. sleep(5); //Redirect using the Location header. header('Location: case_management.php?id=' . $rows['case_id']); //Post reply drawn $sla_client = $_POST['sla_client']; $case_id = $_POST['case_id']; $status = $_POST['status'];
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php" }
Как установить библиотеку с github? Есть у меня pymorphy2 0.8, но мне нужен pymorphy2 ветка master. Она лежит тут < . Как мне заменить их? Я понимаю что клонировать. Но куда клонировать с github, в какую папку. И чтобы потом нормально работало через терминал. Заранее спасибо.
Эта команда все сделает: pip install --upgrade git+
stackexchange-ru_stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "ubuntu, github, git clone" }
Sign a message in javascript I want to sign a message with my ethereum account in a javascript application. I do not want to work in a web-browser or with metamask. I want to build a stand alone javascript program. Is there a way to do that with ethereumjs-wallet for example ? I have searched for tutorials and i did not found anything. Thanks
You can sign a message using your private key to confirm your identity: data = "Hello bro"; privateKey = "YOUR-PRIVATE-KEY"; const Web3 = require("web3"); var web3 = new Web3(Web3.givenProvider); async function main() { console.log(await web3.eth.accounts.sign(data, privateKey)); } main(); Output: pam@g3:~/web3sign$ node main.js { message: 'Hello bro', messageHash: '0x24901329ae47c41fa608d792f3a292f777daeed7cf7c41743590cb00ae898efd', v: '0x1c', r: '0x2537f4ba476ea221ddfb091c14e763d9396a82ff482039086389d324c4099de0', s: '0x5f1c896355123c7d74c39e4ac4908bf6e4427b219e15a0b809c87b5240393f77', signature: '0x2537f4ba476ea221ddfb091c14e763d9396a82ff482039086389d324c4099de05f1c896355123c7d74c39e4ac4908bf6e4427b219e15a0b809c87b5240393f771c' } Referneced from web3 docs. I hope it helps.
stackexchange-ethereum
{ "answer_score": 0, "question_score": 0, "tags": "javascript, myetherwallet" }
How do I exit without saving a file in Python I am new to python and have until now written only a few programs to help with my job (I'm a sysadmin). I am writing this script now which will write the output of a MySQL query to a file. While in-between looping, I want to check for an extra condition and if the condition does not match, I want to close the file that I am writing to without saving what it has already written to the file. Like 'exit without saving'. I wrote this simple code to see if not closing the file with a close() will exit without saving, but it is creating the file with the content after I run and exit this code. So, is there a legal way in Python to exit a file without saving? #/usr/bin/python fo=open('tempfile.txt','a') fo.write('This content\n') P.S:- Python version is 2.4.3 (sorry, cannot upgrade)
Check for the condition before opening the file: #/usr/bin/python if condition(): fo=open('tempfile.txt','a') fo.write('This content\n')
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "python" }
Clear system Clipboard in RCP I'm using the clipboard in my RCP application for various functions. I have written some unit tests to test the functionality of these functions. They are very simple as they only copy and paste some data into and from the clipboard. The problem is, that these tests are failing occasionally. I think it is because there is some data left in the system clipboard which causes my tests to fail. So I tried to write a method to clear all contents of the system clipboard before executing a test: protected void clearClipboard() { Display display = Display.getCurrent(); Clipboard clipboard = new Clipboard(display); clipboard.clearContents(); clipboard.dispose(); } But apparently this doesn't change anything and the tests keep failing. Is this the right approach to clear the system clipboard?
Clearing the clipboard is only possible if the data to be cleared is _owned by the Clipboard through which you wish to clear said content_. If this is not the case (eg. because some other application put it there), nothing is done, according to the corresponding official JavaDoc). In short, if you didn't put it there, you may not clear it. Maybe try to set (=overwrite) the contents of the clipboard first and clear it afterwards, so it's more likely that you own the content (but beware the caveat about Clipboard tools grabbing ownership, as purported in above JavaDoc).
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "java, swt, eclipse rcp, clipboard" }
Cabal error: invalid preprocessing directive #-} $ cabal install arithmoi-0.4.0.3 results in multiple errors like: Math/NumberTheory/Moduli.hs:489:4: error: invalid preprocessing directive #-} ^ ## My System: OSX Mavericks Cabal version = 1.18.1.1 GHCI version = 7.6.3 Thanks in advance!
Possible workaround here. `xCode 5` comes with `clang` as c/c++/obj-c compiler. `Haskell Platform` is not ready for that. The next `ghc` release will fix that. Also see here.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 5, "tags": "haskell, gcc, cabal, haskell platform" }
Check for value in delimitted field via LINQ I have a Db table with a csv field called "Line". There are several values in the field separated by semicolons. I am trying to find a LINQ expression to check if there is any row where the second value in the "Line" field has a specific value. Something like: if (dbContext.Test.Any(t => Array.IndexOf(t.Line.Split(';'), value) = 1)) { Do something ... } Example: Line = "value1;apple;value3;value4" if (dbContext.Test.Any("second value in Line field equals 'apple'")) { Do something ... } What's the most straight-forward and concise way to do this?
Since you appear to be using a `DbContext` and there's no mechanism to translate splitting a string or searching by index you'll need to get more data than necessary, then filter in linq-to-objects. You could to an initial basic filter to limit the number of rows coming back, but you'll need to do the remaining filtering in-memory: var queryEF = dbContext.Test .Where(t => t.Line.Contains(";" + value" + ";"); var queryMemory = queryEF.AsEnumerable() // shift to Linq-to-Objects .Where((t => Array.IndexOf(t.Line.Split(';'), value) == 1); if (queryMemory.Any()) { //Do something ... }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "c#, linq, linq to sql" }
Issue exporting module NodeJS I have this directory structure: * app/router.js * app/oauth2-home-client/oauth2-client.js And the sources: **app/oauth2-home-client/oauth2-client.js** //SOME CODE exports.Bearer = { authenticate : passport.authenticate('bearer', { session : false }), initialize : passport.initialize() // session : passport.session() }; **app/router.js** var oauth2 = require('./oauth2-home-client/oauth2-client'); console.log(JSON.stringify(oauth2.Bearer)); //SOME CODE When I print `oauth2.Bearer` (and `oauth2`, too) content, I get `{}`. What am I doing wrong? Thanks.
Your code: exports.Bearer = { authenticate : passport.authenticate('bearer', { session : false }), initialize : passport.initialize() // session : passport.session() }; Will result in: exports.Bearer = { authenticate :undefined, initialize : undefined }; because both `passport.authenticate` and `passport.initialize` return `undefined`. And the _keys_ having the value `undefined` are omitted by `JSON.stringify`. > [...]If undefined, a function, or a symbol is encountered during conversion it is either omitted (when it is found in an object) or censored to null (when it is found in an array).[...]
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript, node.js" }
Automated sleep log I would like to create a device that will log when a person falls asleep. Of course, someone can't just open a software application and make an entry say "fall asleep, 10:13pm" and be asleep a few seconds later. Instead, I was thinking about hacking a blackberry to log whenever a person powers it on to check the current time. The specific algorithm is not important, but is it possible to write a piece of code be written to intercept the power on button and write the current time/date to a file? If so, how is it done? Also, if anyone has a simpler idea, please share.
I haven't tested it, but since you're asking for ideas: You have your application running in background (or even an app which doesn't extend `UIapplication`) and have a Task (using `Timer` and `TimerTask`) that repeatedly checks if `Backlight.isEnabled()` returns true. If it does - somebody is using the phone. You can even incorporate an `AlertListener` class to check when the user has been woken up ;) The downside of this solution (if it works) is that it is something of a 'busy waiting loop', so intercepting some event would be much better. As far as writing down the current time is concerned - it's possible and sample code snippets are everywhere, you can of course use the persistent store or an SQLite table to aggregate the results in an interesting way. Funny thing is I've been thinking about an app like this lately - it might be an good idea.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "blackberry" }
Intellij IDEA - how to find package usage in a project I am looking at a project's maven pom file with a lot of dependencies and trying to find out if a particular dependency is used or not. Is there a way in Intellij IDEA to find all import statements that import any class from a particular package?
I'm working with IntelliJ IDEA 14 UE. 1. switch to the view "Project" 2. in the tree view, go to the node "External Libraries" 3. search the particular library (=dependency) and open the node 4. select a package within this library 5. in the popup menu of this package, click "Find usages". Alternatively, press Alt+F7 (Windows)
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "java, maven, intellij idea" }
Conditional Correlation? Given: I have columns something like | Location | Year | A | B | |-----------|------|---|-----| | Delhi | 1980 | 4 | 3.4 | | Mumbai | 1986 | 3 | 3.9 | | Delhi | 1990 | 5 | 4.4 | | Bangalore | 1997 | 2 | 2.6 | | Delhi | 1998 | 4 | 3.8 | | Delhi | 1991 | 4 | 4.5 | | Bangalore | 1987 | 4 | 3.8 | | Mumbai | 1998 | 5 | 4.8 | And I want to perform correlation between column `A` and `B` under Delhi `Location` category. I want to perform correlation with only **Delhi** as `Location` | Location | A | B | |----------|---|-----| | Delhi | 4 | 3.4 | | Delhi | 5 | 4.4 | | Delhi | 4 | 3.8 | | Delhi | 4 | 4.5 | I tried `CORREL()` function but this will give correlation `A` and `B` for all location. I just want specific `Location` to correlated. Thank you for your time and consideration.
The solution is some basic array formula filtering. By making each correlation range dependent on whether A2:A9 is _Delphi_ , you create a conditional correlation. =CORREL(IF(A2:A9="Delhi", C2:C9), IF(A2:A9="Delhi", D2:D9)) This is an array style formula. As such, you need to uses Ctrl+Shift+Enter to finalize the formula; not just Enter. If you do this correctly, Excel will wrap the formula in maths braces; e.g. **{** and **}**. Using this method the answer to your sample data is 0.481869424652427.
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "microsoft excel, google spreadsheets" }
Creating names from URLs I am creating a NAME column in a DataFrame and set its value based on substrings contained in another column. Is there a more efficient way to do this? import pandas as pd df = pd.DataFrame([['www.pandas.org','low'], ['www.python.org','high']], columns=['URL','speed']) print(df.head()) df['Name'] = df['URL'] print(df.head()) #set Name based on substring in URL df.loc[df['Name'].str.contains("pandas", na=False), 'Name'] = "PANDAS" df.loc[df['Name'].str.contains("python|pitone", na=False), 'Name'] = "PYTHON" print(df.head())
Yes. Try to automate converting a URL to a name, instead of hardcoding the mapping. With only two URLs, your approach is doable, but as soon as you have to handle lots of different URLs, it will quickly become very painful. Also, avoid first copying a column and then replacing every item in it. Rather, construct the column with the right contents directly. Here is an example: df['Name'] = [url.split('.')[-2].upper() for url in df['URL']] This will fail for proper URLs like ` If you want to handle that automatically, you'll have to properly parse them, for example using `urllib.parse`.
stackexchange-codereview
{ "answer_score": 2, "question_score": 3, "tags": "python, pandas" }
how to check if value already exists in txt file I am writing UserID's to a text file seperated with `||` The var `$UserID` is an integer like 1, 2, 3 etc. If a user has ID 1; the value is stored in the txt file and looks after some time like this: `1||1||1||1||1||...` What i want to achieve: if an ID is already stored in the txt file, do not store it again. this is what i have sofar; $UserIdtxt = $UserID."||"; $ID = explode("||", file_get_contents("user_id.txt")); foreach($ID as $IDS) { // here must come the check if the ID already is stored in the txt file if($IDS != $UserID) { file_put_contents("user_id.txt", $UserIdtxt, FILE_APPEND); } } How can i make that check?
All you need to do is test if the new ID is aleady in the exploded array using `in_array()` $UserIdtxt = $UserID."||"; $all_ids = explode("||", file_get_contents("user_id.txt")); if ( ! in_array($UserID, $all_ids) ) { file_put_contents("user_id.txt", $UserIdtxt, FILE_APPEND); } > But this is an awful way of storing this kind of information
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "php, file get contents" }
Вывод суммы значений обьектов Функция `f13` должна вывести сумму значений массива `a13` но для начала нужно проверить сам массив на наличие чисел и потом выводить их суму.Помогите найти решение и исправить ошибки. let a13 = { 'prim': 'hello', 'one': 4, 'testt': 'vodoley', 'ivan': 6 }; function f13() { let c = '' let b = document.querySelector('.out-13'); for (let key in a13) { if (a13[key] === number) { c += a[key] + a[key]; } } b.innerHTML = c; } document.querySelector('.b-13').onclick = f13;
`typeof` забыли подставить для проверки на number. "number" в кавычках должен быть. И вот эта запись в таком виде должна быть `c += a13[key]` let a13 = { 'prim': 'hello', 'one': 4, 'testt': 'vodoley', 'ivan': 6 }; function f13() { let c = 0 let b = document.querySelector('.out-13'); for (let key in a13) { if (typeof(a13[key]) === 'number') { c += a13[key] } } b.innerHTML = c; } document.querySelector('.b-13').onclick = f13;
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript, html, css" }
PHP 7: Unicode escape syntax doesn't work on single quotes Whenever strings are set with single quotes the unicode doesn't get decoded but the unicode does get decoded when set with double quotes. How do I get the strings set by single quotes also to be decoded? PHP $poo = '\u{1F6BB}'; echo $poo; $poo = "\u{1F6BB}"; echo $poo; OUTPUT \u{1F6BB} Example <
The point of single-quoted strings is that they _don't_ support escape characters. The documentation says this very clearly: > All other instances of backslash will be treated as a literal backslash: this means that the other escape sequences you might be used to, such as \r or \n, will be output literally as specified rather than having any special meaning.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -2, "tags": "php, string, unicode, php 7" }
Using the same github account from multiple PCs I have my github account and I want to access it from my two workstations, an Ubuntu workstation and a Windows one. I'm a beginner on SSH and git as well, I followed all the instructions to setup my account with an SSH key on my ubuntu laptop, and everything works, but now if I want to use my git account from my windows laptop, I need to generate another ssh key or I can use the one generated from my ubuntu laptop? Maybe I need to generate another ssh key from my windows laptop and then register it with my github account along with the one I generated from my ubuntu laptop and use each one from respective machine? What is the best way to do? Is there a best practice? If I can use the same SSH key on both, how I can import the key I already use in the other machine?
It is best practice to use separate SSH keys on each machine, to limit the pain in the event of a compromise (you only have to rekey the compromised machine, and not all of them). To add another public key to your Github account, login to Github and then visit < (or click the "Account Settings" link in your dashboard), then click "SSH Public Keys" and then "Add another public key". Give the new key a title (usually the machine's name is best) and then paste the key data itself into the large textbox. From then on, you should be able to access Github repositories over SSH from either machine.
stackexchange-serverfault
{ "answer_score": 5, "question_score": 4, "tags": "ssh, git, github" }
the results of these two print are absolutely different n = 10 s = [True] * (n) a = [] def dfs(m): if m == 0: print(s) #(1) if s not in a: print(s) #(2) a.append(s) return for x in range(0, n, 2): s[x] = not s[x] dfs(m - 1) for x in range(0, n, 2): s[x] = not s[x] for x in range(1, n, 2): s[x] = not s[x] dfs(m - 1) for x in range(1, n, 2): s[x] = not s[x] for x in range(0, n, 3): s[x] = not s[x] dfs(m - 1) for x in range(0, n, 3): s[x] = not s[x] dfs(10) why the first print(s) has many kinds of different s, but the second print(s) only have the initial s. I can't understand.How can I avoid this problem when I use recursion when I use python
When s gets appended to a the first time m is equal to zero, it is NOT appending a copy of the list s to a. It is appending a reference to s, so each time s changes, the contents of a change along with it. Your print #2 is only ever done once and `if not s in a` is only True the very first time. Try this in a Python console to see a simpler example of this: >>> a = [1,2,3,4] >>> b = [] >>> b.append(a) >>> a[2] = 7 >>> b [[1, 2, 7, 4]]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "python" }
How to cast resultset in rowmapper to an enum? I have my rowmapper like: private static final class UserRowMapper implements RowMapper<User> { User user = new User(); user.setId(rs.getInt("id")); user.setUserType( (UserType)rs.getInt("userType")); // ????? return user; } So I am trying to cast the integer value in the db for userType to the enumeration UserType. Why doesn't this work?
Cast it? No, can't be done. You can call valueOf to get the Enum value from the String, as long as the String is valid.
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 9, "tags": "java, spring, jdbc, jdbctemplate" }
Creating Legends for QGIS 2.0 Feature Blend Mode Outputs I am working on visualizing ~4100 buffered point features. The shading of the buffers is keyed to a field in the data. Because the buffers overlap, I turned on multiply in the new feature blend mode options. I like the visual result, but what seems to be missing is an ability to generate a meaningful legend for the resulting image. Are there any workarounds for this? Is the only alternative to venture down the path of polygon intersects and symmetrical difference operations? !buffered points with multiply feature blend mode
If you understand the theory of the feature blending mode "multiply" you are able to create a legend by self-assigning the colors and the corresponding value. The formula for the "multiply" blending mode color is as follows: (color value of r, g or b)^n/256^n-1 where n = number of overlapping layers. Example: r = 165; n = 3; "multipy" blending mode r color = 165^3/256^2 = 68.5 See this pdf for more information on "Understanding RGB Blending Modes"
stackexchange-gis
{ "answer_score": 1, "question_score": 3, "tags": "qgis, cartography" }
Activerecord - how to made this? Everyday, I need to run the a script and send all of my users an 'exam' or set of questions. I have modelled as class 'Exam' which subclasses ActiveRecord::Base. Now, how do I send user's instances of Exam? What I was thinking was create a new class called 'ExamInstance' which would have a reference to 'Exam' and the user. I am new to SQL and ActiveRecord so if someone can help me better model this so I can avoid problems later on or just give me some insight, that would be great. Thanks
I'll suggest just use `has_many :through` create a model `UserExam` for many to many relation between `exam` and `user` class User < ActiveRecord::Base   has_many :users_exams   has_many :exams, :through => :users_exams end   class UserExam < ActiveRecord::Base   belongs_to :users   belongs_to :exams end   class Exam < ActiveRecord::Base   has_many :users_exams   has_many :users, :through => :users_exams end For more information on `has_many :through`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "mysql, ruby, activerecord" }
Error while Getting data from an xml file I have written the following code to understand how php can be used to get and write data to xml files: <?php if (file_exists('/requests.xml')) { $xml = simplexml_load_file('requests.xml'); foreach($xml->data->requests->request as $req) { print "Loop entered"; print $req->ip; print $req->timelast; } } ?> The xml file requests.xml follows: <?xml version="1.0" encoding="utf-8"?> <data> <requests> <request> <ip>6.6.6.6</ip> <timelast>2014-05-30 11:38:23</timelast> </request> </requests> </data> The problem is that when the script is run, it does not display anything in the browser. In fact it does not enter the loop. I'm definitely missing something basic.
`$xml` will take your default node auto so no need to fetch result with data try foreach($xml->requests->request as $req) also change if (file_exists('/requests.xml')) { to if (file_exists('requests.xml')) { // if same dir i have tried like:- $xml ='<?xml version="1.0" encoding="utf-8"?> <data> <requests> <request> <ip>6.6.6.6</ip> <timelast>2014-05-30 11:38:23</timelast> </request> </requests> </data>'; $xml = simplexml_load_string($xml); foreach($xml->requests->request as $req) { print "Loop entered"; print $req->ip; print $req->timelast; } output :- `Loop entered6.6.6.62014-05-30 11:38:23`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, xml" }
Delete numbers, special characters and text containing special characters in notepad++ I have few text files from which : > I need to delete all numbers(0 to 9), special characters(they are "{" and "[") and all the words containing a "#" ( for eg, good#boy, very#good#boy a#very#good#boy) How can I do this with Notepad++? Thanks.
With the help of regular expressions it's easy. Go to `Search` > `Replace` menu (shortcut `CTRL`+`H`) and do the following: 1. Find what: [0-9\{\}\[\]]|[a-zA-Z]+\#[a-zA-Z\#]+ 2. Replace with: [leave empty!] 3. Select radio button "Regular Expression" 4. Then press "Replace All" You can test it at regex101.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "regex, notepad++" }
CSS Debuggin for IE I'm seeing some really strange css float behavior in IE and I'm trying to diagnose the issue. Is there an equivelent to Firebug or Chrome's "Inspect Element" in IE? How do you typically debug CSS positioning issues in IE?
There are a couple of options available, IE8 has a decent developer toolbar built in, you can access it by pressing F12 or if not going into the options menu and using developer tools, it doesn't work as well as firebug, but once you are able to select an element, you can easily change the styles. Firebug lite is another option though I havent used it in IE.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "css, debugging, internet explorer" }
What is the derivative of $f (\mathrm X) = \mathrm X^3$? Let $E = M_{3}(\mathbb{R})$ and $f: E \rightarrow E$ which $f(X) = X^3$ is $f^{'}(X)H = 3X^2 H$ the derivative for this function? I tried to prove that $r(H) \rightarrow 0$ where $r(H) = -X^3 + (X+H)^3 - 3X^2 H$ but i dont get in anywhere.
The directional derivative of $f (\mathrm X) = \mathrm X^3$ in the direction of $\mathrm V$ is $$\lim_{t \to 0} \frac{1}{t} \left( f (\mathrm X + t \mathrm V) - f (\mathrm X) \right) = \lim_{t \to 0} \frac{1}{t}\left( (\mathrm X + t \mathrm V)^3 - \mathrm X^3 \right)$$ Since $$(\mathrm X+ t \mathrm V)^3 = \mathrm X^3 + t (\mathrm X^2 \mathrm V + \mathrm X \mathrm V \mathrm X + \mathrm V \mathrm X^2) + t^2 (\mathrm X \mathrm V^2 + \mathrm V \mathrm X \mathrm V + \mathrm V^2 \mathrm X) + t^3 \mathrm V^3$$ we obtain $$\lim_{t \to 0} \frac{1}{t} \left( f (\mathrm X + t \mathrm V) - f (\mathrm X) \right) = \mathrm X^2 \mathrm V + \mathrm X \mathrm V \mathrm X + \mathrm V \mathrm X^2$$ If $\mathrm X$ and $\mathrm V$ commute, then $\mathrm X^2 \mathrm V + \mathrm X \mathrm V \mathrm X + \mathrm V \mathrm X^2 = 3 \mathrm X^2 \mathrm V$.
stackexchange-math
{ "answer_score": 8, "question_score": 3, "tags": "matrices, analysis, derivatives, matrix calculus" }
Snotty made a joke I don't understand I have always had a nagging question about the transporter scene in SpaceBalls. After Skroob has been "transported", to his then asinine state, we see Snotty "try and reverse the beam". > Snotty: Hold on, sir. We'll try and reverse the beam. Could be the interlocking system. > > SKROOB scratches his leg. > > Snotty: (flipping switches) Lock 1, Lock 2, Lock 3, **Lock lone**. I have highlighted the part I was not sure about. In the case of "lock lone" is there a joke or technical reference there? I don't understand that and wanted to know if I was missing something. The following youtube video contains the scene in question. You can also just skip to the section I have quoted above. ![Good ol Snotty](
Given that the character is a Scottish stereotype, I suspect he's saying "Loch Lomond", which features in the title and verses of the famous Scottish song The Bonnie Banks o' Loch Lomond (which many will recognize from the verse "you take the high road and I'll take the low road"): I double checked on the blu-ray, which has an "English for the deaf and hard of hearing" subtitles option in "setup" on the menu, and the subtitles read "Lock one. Lock two. Lock three. Loch Lomond!"
stackexchange-scifi
{ "answer_score": 64, "question_score": 43, "tags": "humor, spaceballs" }
python 2.7: reading a file only up to a known line If I wanted to read starting from a given line I can do: with open(myfile) as f: for x in range(from_here): next(f) for line in f: do stuff How can I do the opposite: reading only up to a given line? I was thinking about a for loop: is there another way?
The obvious answer is to use a loop that just counts: with open(myfile) as f: for i in xrange(number_of_wanted_lines): line = next(f) # do stuff with line Regarding the second part of your question, you can also read in the full file into a list of lines, then use slices: with open(myfile) as f: lines = f.readlines()[start_line_number:end_line_number+1] for line in lines: # do stuff with line If you don't want to load the whole file into memory, you can also use `islice` (from `itertools`) instead of list slices: import itertools with open(myfile) as f: for line in itertools.islice(f, start_line_number, end_line_number + 1): # do stuff with line
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python 2.7, file io" }
Different Output for b=+1 in java I executed the below program int b = 0; b=+1; System.out.println(b); b=+1; System.out.println(b); b=+1; System.out.println(b); and got output like 1 always. Why is the value of b incrementing in the first increment and why its not incrementing in the second and third incrementing operation?
Reverse the `=` and `+` symbols. Unary `+` isn't what you want. b+=1; or b++; or ++b; Unary plus is `b = (+1);` or just `b = 1`.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "java, post increment, pre increment" }
Geometry problem with rectangular isosceles triangles We have a triangle $\triangle ABC$ in which angles $B$ and $C$ are greater than $45^\circ$. We construct two rectangular isosceles triangles $\triangle BAN$ and $\triangle CAM$ out of $\triangle ABC$ with angles $\angle CAM = \angle BAN = 90^\circ$. Then we draw a rectangular isosceles triangle in the triangle $ABC$ with angle $P$ equal to $90$ degrees. Prove that $\triangle MPN$ is rectangular isosceles. **My Attempt:** I cannot do any thing useful because it is a very very hard question. Please answer me as soon as possible.
I assume that you mean $\triangle BPC$ is a rectangular isosceles triangle with $\angle BPC=90^\circ$. Suppose $AB=c$, $BC=a$, $CA=b$, $\angle ABC=B$, $\angle BCA=C$, $\angle CAB=A$. It is easy to see that $\angle PBN=B$, $\angle PCM=C$, $\angle MAN=180^\circ-A$. Hence, we have $$PM^2=(a/\sqrt2)^2+(\sqrt2b)^2-2ab\cos C=b^2+c^2-(a^2/2),$$ and similarly $$PN^2=(a/\sqrt2)^2+(\sqrt2c)^2-2ca\cos B=b^2+c^2-(a^2/2).$$ Finally, $$MN^2=b^2+c^2-2bc\cos(180^\circ-A)=2(b^2+c^2)-a^2.$$ We conclude that $\triangle MPN$ is also a rectangular isosceles triangle.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "geometry" }
Check word against very large list If I have a list of 10,000 words, what's an optimized way to check if a word is in that list that won't slow the app down to a crawl? Should I load the words in from a file and check against that? def check_for_word(word): HUGE_LIST = [...] # 10,000 Words if word in HUGE_LIST: return True else: return False
Convert a list to set - strings are hashable so set can be easily created. Look-up in set is O(1), where for list it's O(n), where n is a length of list. HUGE_SET = set(HUGE_LIST) # or frozenset, if it's constant and words won't be added to it return word in HUGE_SET Also, consider moving creation of huge list and huge set outside of function body. Right now list is recreated every time function is called. **List timings:** $ python -m timeit -s "words = list(map(str, xrange(10000)))" -n 10000 "'5000' in words" 10000 loops, best of 3: 58.2 usec per loop **Frozenset timings:** $ python -m timeit -s "words = frozenset(map(str, xrange(10000)))" -n 10000 "'5000' in words" 10000 loops, best of 3: 0.0504 usec per loop
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "python, python 2.7, python 3.x" }
How do I reference a field name which includes a slash in Power Query In Excel 2016 Get & Transform ("Power Query") it appears to be totally valid to have a field (column) name containing a slash character. However, when I try to reference this column, I can't find any way to escape the slash to make the reference work. How can I do this? Specifically, the following code is accepted: Table.AddColumn(#"Capitalize", "ABC Table", each Table.FromColumns({Text.Split([ABC], ",")})) ...but the following is not: Table.AddColumn(#"Capitalize", "ABC Table", each Table.FromColumns({Text.Split([ABC / DEF], ",")})) ...presumably because of the slash in `[ABC / DEF]`. How can I escape this slash?
Try using `[#"ABC / DEF"]` instead of `[ABC / DEF]`.
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 8, "tags": "powerquery" }
Django: removing non-used files Is the any automated way to remove (or at least mark) unused non-used (non-referenced) files located in `/static/` folder and its sub-folders in Django project?
This is not neccessery since django will pick only the updated files, and the whole idea of collectstatic is that you don't have to manually manage the static files. However, if the old files do take a lot of space, once in while you can delete all the files and directories in the static directory, and then run `collectstatic` again. Then the /static/ dir will include only the updated files. Before you run this, check how much time does it take, and prepare for maintenance. Note: Delete and re-create all files may still require reload of these files by the client browsers or a CDN. It depends on your specific configuration: CDN, caching headers that use the file creation dates, etc.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "python, django, refactoring" }
Gitlab public runner won't run bower because run in sudo How can I run bower command without sudo using gitlab public runner? This is my script image: node:7 before_script: - npm install -g bower - bower install ... This is the result I got from the test. ... npm info ok $ bower install bower ESUDO Cannot be run with sudo Additional error details: Since bower is a user command, there is no need to execute it with superuser permissions. If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs. You can however run a command with sudo using --allow-root option ERROR: Build failed: exit code 1 Thank you.
You should add `--allow-root` after your bower command. See : <
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "gitlab, bower, gitlab ci, bower install, gitlab ci runner" }
Как извлечь временную составляющую из DateTime? При выводе на консоль объекта типа `DateTime` выводится и дата и время. DateTime dt = DateTime.Now; Console.WriteLine(dt); > > 10/19/2016 7:25:40 PM > Как можно сделать так, чтобы выводилось только время?
Есть два способа. С помощью форматов, в строку: DateTime dt = DateTime.Now; string time_str = dt.ToString("HH:mm"); С помощью свойства `TimeOfDay`.aspx) в `TimeSpan`: DateTime dt = DateTime.Now; TimeSpan span = dt.TimeOfDay;
stackexchange-ru_stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "c#" }
Call controller action from non controller class Is there a way to invoke a controller action from a regular C# class, that is not a controller? All I found so far uses redirectToAction, but this is controller exclusive.
A controller is a class like any other, which means you can do this: `var homeController = new HomeController();` (assuming you have your project references setup, I'm not including namespaces in my example, as I don't know what yours are) Thus you can then execute the methods of that controller via the `homeController` variable. But, as has been pointed out in the comments, this is not a good design at all. I would strongly recommend you don't do this. A controller should be called from other controllers, or web requests.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "c#, asp.net mvc" }
Selecting date from Datetime field access It may seems like stupid question but I cannot find any solution for it I have column with StartDateTime `dd.mm.yyyy hh.mm.ss` I need to select only `dd.mm.yyyy` because its access SQL Server `CAST` doesn't work. Is there any function in MS Access which I can use for selecting only `dd.mm.yyyy`?
It's been a while, but would the DateValue function work?
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, ms access, select" }
Creating a fantasy footbaall App angular js So basically I am making a fantasy Web app using Angular JS. I have created a pretty standard list of players by describing them in my controller in a $scope.players array. The user can also select players (which is then pushed into an empty array called $scope.history). But I fear i might have started out in the wrong way. Considering: 1\. each user will have to have their choices saved, and 2.depending on the performance of each player (goals and Assists) per match, they would also have to have their stats updated Is it better to have all players saved in a JSON file on my wampserver and using $http.get to get the data?
You would **not** want to store all the data as JSON in your JavaScript code. It would make much more sense to store it in a JSON file on your server and retrieve the data using `$resource`. You could also consider building a RESTful API with endpoints designed for the AngularJS application to consume data from and retrieve the data via `$http`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, angularjs, web applications, wampserver, netbeans 8" }
Upload spreadsheet to List Sharepoint I have an input box with a submit button on my site. I would like the person who uses my site to input a spreadsheet into this - click submit - and the data from the spreadsheet turns into a list. Is this possible? of is there a better way of doing it? I know you can get lists from spreadsheets by going 'behind the scenes' but I want my user to just go through the main page.
There is no exposed API for this purpose. You can use this codeplex feature to do this. Check the license before making any modification to source code: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "sharepoint" }
How to capture screen and detect the screen info I'm fairly new to android and xamarin, but I'm making an app for a school project in Xamarin which is about **visible light messaging**. That's a kind of messaging with a code-language like morse, but with light. My phone has to see that light and recognise the flickering of that light. Therefor I made an app with an in-built camera like the snapchat app. Now I have to **recognise what's going on on my screen** when the camera is open, but i have no idea how to capture the screen. Is there anyone with any experience on things like this (like face-recognition,...) Thanks in advance!
I am not familiar with the camera detector. But I would like to give you some ideas about your app. 1. Achieve your camera preview. `Textureview` is a good choice. 2. Get the single frame of your camera. Try to use Emgu CV or some other tools. 3. Detect the light of your frame. This is a challenge, create a model for your light detect the model in the frame. For example: your light must be white color you can create a model for your light: Class MyLight { byte[] myColor= new byte[] { 0xFF, 0xFF, 0xFF };//RGB } Get the All pixels of your frame and detect the write color by traversing your pixel array. MyLight object will not be such simple many situations need to be considered. Good Luck.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android, xamarin, xamarin.android" }
How to get today's date as quarterly divided Today's date will be given and January, April, July, October = 1 February, May, August, November = 2 March, June, September, December = 3 should be printed. Example: december is 3rd month of quarter so answer will be 3. Is there any better solution for this? public int getValue() { switch (LocalDate.now().getMonthValue()) { case 1: case 4: case 7: case 10: return 1; case 2: case 5: case 8: case 11: return 2; case 3: case 6: case 9: case 12: return 3; default: throw new IllegalStateException("Unexpected value"); }
public int getValue(int month) { return month % 3 == 0 ? 3 : month % 3; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "java, localdate" }
PowerShell: Restrict variable values I have the following variable: $UPNSuffixChange = $True In my script there's an if statement that will only run if this is true: If ($UPNSuffixChange) {} The idea being that the variable can be set to `$False` resulting in this section being skipped. How can I restrict the value of this variable to only `$True` or `$False` to avoid mistyped values?
Strongly-type it is as a `boolean`: [bool]$UPNSuffixChange = $True * * * If an attempt is made assign anything other than `$true`/`$false` (or the equivalents `1`/`0`) to this variable, PowerShell will through the following error: > Cannot convert value "System.String" to type "System.Boolean". Boolean parameters accept only Boolean values and numbers, such as $True, $False, 1 or 0. I used a `System.String` as an example; it is the same for other types.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "powershell" }
Query for date part of date_time field. yyyy-mm-dd I'm trying to find if there is a post from the same date. @selected_date = Date.new(params["post"]["date(1i)"].to_i,params["post"]["date(2i)"].to_i,params["post"]["date(3i)"].to_i) @existing_post = Post.where(user_id: current_user.id, date: @selected_date).first My `@selected_date` contains only the date **2021-03-19** , but my date db field contains time as well `date: "2021-03-19 17:43:50.640258000 +0000"` In the Query how can I point only date section to compare? When I do `, date: @selected_date)` its trying to compare without time, so it fails.
You can do this using the `all_day` helper which creates a range covering the whole day. Post.find_by(user_id: current_user.id, date: @selected_date.all_day)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql, ruby on rails, date, ruby on rails 6" }
How can I convert a 2-D table into a grid in Excel or MS Access I have 3 tables: Room A Room B Room C 8:00 9:00 10:00 11:00 Kathy Room A 9:00 John Room C 8:00 DaVon Room C 10:00 Janelly Room A 10:00 I want to create a grid using Table A for Rows and Table B for Columns, like so: 8:00 9:00 10:00 11:00 Room A Kathy Janelly Room B Room C John DaVon I'd prefer using the query designer if possible.
Consider for Access: Query1: This is a CROSSTAB query TRANSFORM First(Schedule.Person) AS FirstOfPerson SELECT Schedule.Room FROM Hours LEFT JOIN Schedule ON Hours.Hr = Schedule.Hr GROUP BY Schedule.Room PIVOT Hours.Hr; Query2: SELECT Rooms.Room, Query1.* FROM Query1 RIGHT JOIN Rooms ON Query1.Room = Rooms.Room;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "excel, ms access" }
Combining data frames with unequal number of columns Suppose I have two data frames, Dat1 and Dat2, Dat1 Col1 Col2 Col3 A1 56 89 and Dat2 Col1 Col2 Col4 Col5 A2 49 84 F11 Finally I want to have a combined data frame which looks like Col1 Col2 Col3 Col4 Col5 A1 56 89 NA NA A2 49 NA 84 F11 Is it possible to achieve this in R?
There's also `rbind.fill` from `plyr` or `Stack`. library(plyr) rbind.fill(Dat1, Dat2) ## Col1 Col2 Col3 Col4 Col5 ## 1 A1 56 89 NA <NA> ## 2 A2 49 NA 84 F11 library(Stack) Stack(Dat1, Dat2) ## Col1 Col2 Col3 Col4 Col5 ## 1 A1 56 89 NA <NA> ## 2 A2 49 NA 84 F11
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 3, "tags": "r" }
How to select parent child till end using root parent id in sql? Below the table : I need to get without `recursion`, but use any other `join` and `union`. Id ParentId 1 0 2 1 3 2 4 2 5 4 6 5 7 6 8 7 9 8 N N Without `recursion` use any other `join` queries
DECLARE @Nvalue INT = 10 SELECT NUMBER AS ID,NUMBER-1 AS ParentID FROM ( SELECT DISTINCT NUMBER FROM master..spt_values WHERE number BETWEEN 1 AND @Nvalue )T
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "sql, sql server" }
How to use jQuery insted of Update panel? How to use the jQuery ajax instead of update panel in Asp.net? I've heard it's lighter that the normal update panel. Also, does it need a script manager?
Yea, There will be less overhead on network if you use jQuery instead of UpdatePanel.. however you need to write lot of js code for handling data returned by `GET` and `POST` requests using jquery `$.ajax()` function. On the other side asp.net ajax will handle DOM updates etc. automatically check this tutorial JQuery: Building tomorrow's Web apps today
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, asp.net" }
discord v12 Hello, why does user.presence.status return offline even if the user is online? why does user.presence.status return offline even if the user is online? const user = mess.mentions.users.first() || mess.author; const status = user.presence.status
This is because you did not enable the `PRESENCE` intent in the settings of your application. Go to < then click on your application, go to the "BOT" page and enable both intents. Restart your bot, and the user presence should be the right one!
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, discord, discord.js" }
Is there a word for motion that a bull makes when it kicks back with his legs before charging? Is there a word for motion that a bull makes when it kicks back with his legs before charging? Kind of like at 22s in the following video < Even if it's not an English word!
The entry for paw in the AHDL includes: > **2.** To strike or scrape with a beating motion: _The bull pawed the ground before charging._ From an article on a UCB site by a professor of veterinary medicine titled, Why and how to read a cow or bull: > The direct threat is head-on with head lowered and shoulders hunched and neck curved to the side toward the potential object of the aggression (Photo 2). **Pawing with the forefeet** , sending dirt flying behind or over the back, as well as rubbing or horning the ground are often **components of the threat display** (Photo 3).
stackexchange-english
{ "answer_score": 12, "question_score": 4, "tags": "word choice" }
The name Amihud is found in different tribes – why was it a popular name? In the sedra of Masei, two nesi'im are mentioned whose father is Amihud. 1] 34 (20) וּלְמַטֵּה֨ בְּנֵ֣י שִׁמְע֔וֹן שְׁמוּאֵ֖ל בֶּן־עַמִּיהֽוּד: 2] 34 (28) וּלְמַטֵּ֥ה בְנֵֽי־נַפְתָּלִ֖י נָשִׂ֑יא פְּדַהְאֵ֖ל בֶּן־עַמִּיהֽוּד: I see apparently different Amihuds mentioned in 3] Bamidbor 1 (10) לְאֶפְרַ֕יִם אֱלִֽישָׁמָ֖ע בֶּן־עַמִּיה֑וּד 4] II Shmuel 13 (37) וְאַבְשָׁל֣וֹם בָּרַ֔ח וַיֵּ֛לֶךְ אֶל־תַּלְמַ֥י בֶּן־עַמִּיה֖וּד 5] I Chronicles 9 (4) עוּתַ֨י בֶּן־עַמִּיה֚וּד בֶּן־עָמְרִי֙ בֶּן־אִמְרִ֣י בֶן־בָּנִ֔י מִן (כתיב בָּנִ֔ימִן־) בְּנֵי־פֶ֖רֶץ בֶּן־יְהוּדָֽה: The Amihuds of refs 1, 2, 3 and 5 belonged to different tribes. Is it right to conclude that Amihud was a popular name and if so why?
I haven’t seen an explanation written explicitly, but maybe you’ll accept a humble suggestion. The Midrash Tanchuma, Parshas Nasso, 28 says, “Rabbi Meir and Rabbi Yehoshua ben Karcha expounded on people’s names. Elishama - Eli Shama - (Hashem said) ‘He listened to me and not to his mistress’. Amihud - imi haya hodo - ‘His splendor was with Me (and not with the Egyptian woman)’. This is in reference to Yosef Hatzaddik who was his grandfather who was faithful and did not commit a sin with Potiphar’s wife. (See earlier in the Midrash text and Rabbeinu Bachaye.) Chazal in many places point to several things by which the (entire) Jewish People merited the exodus from Mitzrayim, one of which is that they guarded themselves from immoral relations (with the Egyptians). The Midrash Bamidbar Rabba, 9, 12, says that this was actually the chief merit they had. As such, it makes sense that these names which refer to that merit were popular in those times.
stackexchange-judaism
{ "answer_score": 7, "question_score": 7, "tags": "parshanut torah comment, names, masei" }
Tell Ruby Program to Wait some amount of time How do you tell a Ruby program to wait an arbitrary amount of time before moving on to the next line of code?
Like this: sleep(num_secs) The `num_secs` value can be an integer or float. Also, if you're writing this within a Rails app, or have included the ActiveSupport library in your project, you can construct longer intervals using the following convenience syntax: sleep(4.minutes) # or, even longer... sleep(2.hours); sleep(3.days) # etc., etc. # or shorter sleep(0.5) # half a second
stackexchange-stackoverflow
{ "answer_score": 771, "question_score": 473, "tags": "ruby, sleep" }
Substituting variable names with other variable names I don't know if this is possible, and if it is I don't know what it's called so I'm not sure what to search for online, but I am curious to know if it is possible (I won't actually be using this code, I would just like to know if it can be done) Say we have 3 variables: $var_1 = "A"; $var_2 = "B"; $var_3 = "C"; Would it be possible to do something like this(I know this particular code doesn't work, I've tried): $arr = array(); for ($i = 1; $i <= 3; $i++) { $arr[] = $var_{$i}; } var_dump($arr); So that `{$i}` becomes part of the variable name?
Of course! $arr[] = ${"var_$i"}; Output Array ( [0] => A [1] => B [2] => C ) **Fiddle** And oh, this concept is called **_Variable Variables_**
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "php" }
Visual Studio 2015 - uwp app changes take effect only when i deploy app first I work on a uwp app with visual studio 2015. Normally I can debug the app by pressing F5. When I did some code changes in the uwp app, I have to right click on the project and select deploy. Then I can debug the app, otherwise my code changes, are not considered in the debugged version. Also the breakpoints will not be affected. Can someone explain this strange behaviour and how I can avoid it? I would like to debug the uwp app (by pressing F5) without having to deploying it every time.
It could because your application is not automatically deployed after the build. You can check this by using the "configuration manager" from the "build" menu and check that your app is selected to be deployed. ![Configuration manager](
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 1, "tags": "visual studio, win universal app" }
remove dash in phone number within razor I need to call a JavaScript method and am using razor to print the parameters... getNumber(@Html.DisplayFor(model => model.phone1)"> However, JavaScript treats a dash in the phone number as a subtraction operator. I tried a regular expression to remove the dash, but I can't figure out the right syntax. This still performs the subtraction operation and gives me the JavaScript error [subtration result].replace is not a function getNumber((@Html.DisplayFor(model => model.phone1)).replace(/[^0-9.]/g, ''))">
You should treat phone numbers as strings, to do this make sure JavaScript also knows the number is a string by enclosing it in quotes: getNumber('@Html.DisplayFor(model => model.phone1') This should get rendered something like this: getNumber('1-800-CALL-ME')
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "javascript, razor" }
change url zend `class ContactusController extends Zend_Controller_Action` it result `url/contactus`.I like to change `url/contact-us` . How can i add "-" in url. Please help me to find-out the solution
You can do by adding a route with Zend_Router . $router = $this->_front->getRouter(); $router->addRoute('contactus', new Zend_Controller_Router_Route('contact-us', array( 'controller' => 'contactus', 'action' => 'index', 'category' => null ) ); ); Can read more about it from <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "zend framework, url, url rewriting, url routing" }
Mongodb connection error ECONNRESET When I tried to connect to mangolab, I get Err ECONNRESET var mongo = require("mongodb").MongoClient; var assert = require('assert'); var url = "mongodb://username:password@urlForServer:port/databaseName"; mongo.connect(url, function(err, db) { console.log(err); }); I have put right info in connection url. please help. !ECONNRESET Error Thanks in advance.
I had a similar issue and it was due to corporate network restrictions which could be your case also Your network may not allow this type of connection to this external address and port
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "node.js, mongodb, database connection" }
Finding longest consecutive duration of an episode in multiple rows What I have ID | t | event A | 1 | 0 A | 2 | 1 A | 3 | 1 A | 4 | 0 A | 5 | 1 A | 6 | 1 A | 7 | 1 A | 8 | 1 A | 9 | 0 B | 1 | 1 B | 2 | 1 B | 3 | 1 B | 4 | 0 B | 5 | 1 B | 6 | 0 B | 7 | 1 B | 8 | 1 B | 9 | 0 What I want ID | maximum duration of event A | 4 B | 3 A is 4 because the longest event duration was from t5 till t8. B is 3 because the longest event duration was from t1 till t3. I was thinking about numbering consecutive events in a new variable, restarting at 0 when there is a new ID, and then selection the maximum of that new variable grouped by ID. But I couldn't figure out a way to do that. Any maybe it's not even the best approach.
The faster and easier to read version of Ananda's answer is: library(data.table) setDT(mydf) # convert to data.table in place mydf[, max(rle(event)$lengths), by = ID] # ID V1 #1: A 4 #2: B 3
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "r" }
Using single else statement for multiple if conditions I am coding for an arduino project and i came across this problem, can anyone help me out! if(condition1){ //my codes here } if(condition2){ //my codes here } if(condition3){ //my codes here } ...... if(condition100){ //my codes here } else{ my codes here } I want to check all my if conditions, and execute the codes if the conditions are true, and run the else statement only if none of the if condition become true. Note that i cant use `else if` because i want to check all the if conditions, and if none are true i want to run the else If conditions are not dependent on each other
You can use a Boolean flag which is set in any of your `if`s. bool noPathTaken = true; if ( condition1 ) { noPathTaken = false; // ... } if ( condition2 ) { noPathTaken = false; // ... } // ... if ( noPathTaken ) { // this would be your "else" // ... }
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": -5, "tags": "if statement, arduino" }
Why array in $scope doesn't updated using array concat method? When I use concat method, my $scope is not updated var anotherList = ["2", "3", "4"]; $scope.list = []; $scope.list.concat(anotherList); But using array push method in a loop, my $scope gets updated
Your syntax is wrong. You need to assign the return value of `.concat()` to your scoped array. $scope.list = $scope.list.concat(anotherList); Alternatively, if you used `call()` you could bind the result directly to the scoped array without the need to "reassign" since it would be done under the hood for you. $scope.list.concat.call(anotherList); See the documentation.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "arrays, angularjs, angularjs scope, angularjs ng repeat" }
Command to Activate New Data Screen linked to Current Screen I have a List-And-Details screen with a button in the details section. When I click on the button, I want to navigate to a New Data Screen to create an order but have that order tied to the customer displayed in the details screen where the button was clicked. What is the best way to do this?
From what I understand you have two screens: a Customer List screen, and a New Order screen. What I would suggest are the following steps: 1. Create a customerId property on the New Order screen 2. Mark the customerId property as a screen parameter 3. When you click the button and navigate to the New Order screen (ShowNewOrderScreen), pass the id of the selected Customer 4. On the created event of the New Order screen, process the customerId property. 5. You can load the customer object, then instantiate and add a new order to it.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "visual studio lightswitch" }
Unfamiliar notation. (actuarial science) I am a math instructor self studying for the actuarial exam and I am trying to understand the following notation that I have encountered today. $$E[X \land d]$$ The explanation in the book told me that this means $$E[\min\\{X,d\\}]$$ which is another unfamiliar notation to me. Just guessing from what I have learned I want to say that this is related to reimbursements with deductibles with $X$ being the loss which I learned it as $$E[Y]$$ while $$Y = \begin{cases} 0, & x<d\\\ x-d, & x\ge d \end{cases}$$ Am I in the right ball park or does it mean something completely different? It would be great if you could guide me to where I can learn about this a bit more because I do not even know how it is read.
This notation isn't particular to actuaries (see here). $\wedge$ means the minimum. Dually, $\vee$ would mean maximum. $E(f(x))=\int f(x)p(x) \mathrm{d}x$ by definition. Thus you get $E(\min(X,d)) = \int \min(x,d)p(x) \mathrm{d}x$ $\min(X,d)$ means "take $X$ if $X < d$, otherwise take $d$." Another notation you may come across (particularly for max) is $(S_T - K)^+ = \max(S_T-K,0)$ which is the payoff of a call option.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "notation, actuarial science" }
How to make shadow gradient out of the div only in the left and right side? I want to replace Demo image by code css3 or somthing else. I have a blue image on the image I have a white background, on the side of the image and white background, in the right and left sides I have a gradient shadow . Can I do this shadow only on the sides using css3 or otherwise without the picture? I try to do it here jsfiddle Demo Thx.
Do you want something like this? < If you only want shadow at the right and left side: <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "css, gradient, shadow" }
SSRS - Post Publishing Tasks As part of the publishing "best practices" I came up with my own, I tend to archive report groups and republish the "updated" reports. However, with this stratedgy, I lose users associated with each report or have to rehide reports. Is there an automated process I can use to hide reports or add users, after deploying form Visual Studio?
Paul Stovell posted some examples of Reporting Services automation that might get you going. EDIT: The link to the Subversion repository has been updated and is now working
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "reporting services, automation" }
store nearby url and insert into tooltip with jQuery I have some jQuery that makes these images expand on hover and a tooltip with the image title appears. < (It's two separate plugins; yes, I'm sure there's a more efficient ideal way. But that's not my question.) Is there an easy way to insert a "More Info" link into this tooltip that matches the "More Info" link already under the thumbnail? I think it will end up looking something like this: $(".tooltip").append(' '<a href="' + thelink + '">More Info</a>' '); but I'm so bad with variables I need help storing the link from one location (at ul>li>a ) and then re-using it in the append.
Yes, something like this would do. var thelink; thelink = $(this).find("a").attr("href"); $(".tooltip").append('<a href="' + thelink + '">More Info</a>'); I don't think there's need to use the tooltip plugin, you got it almost right in your code (the commented part) just do a little research on variables in javascript and how to use them. edit: i down't know what happens when the tooltip gets created after the hover fired, i guess it won't work then, i would suggest to use something like the code below on hover to create the tooltip. var title, tooltip, thelink, moreinfo; thelink = $(this).find("a").attr("href"); moreinfo = $('<a href="' + thelink + '">More Info</a>'); title = $(this).find("img").attr("title"); tooltip = $("<div class='tooltip'>" + title + "</div>"); tooltip.append(moreinfo); $(this).append(tooltip);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, tooltip" }
How to pull image only from specify namespace by using ACR basic I working on AKS shared cluster, where have multiple teams are working on the same cluster and have their own ACR for each team. I want to find ways to allow ACR to pull from specified namespace only. Currently that I have though is an expensive way by * Using ACR premium tier to enable the scope-map feature, and create the token for authentication on pull secret. Or someone did know how to pull an image from the service principal with the AcrPull role. please tell me. thank you.
I have found the solution without changing the ACR pricing tier, by using only the service principal to access the target ACR. **Solution** 1. Create the `service principal` and assign `AcrPull` role. 2. After that, Create kubernetes secret into your namespace to pull image by `ImagePullSecrets` kubectl create secret docker-registry <secret-name> \ --namespace <namespace> \ --docker-server=<container-registry-name>.azurecr.io \ --docker-username=<service-principal-ID> \ --docker-password=<service-principal-password> reference
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "azure, azure aks, azure container registry" }
The Heaviside functions in the following? For $(\mu_{i})_{i=\overline{1,n}}$ are real positive parameters, we have $H$ is the Heaviside function, i.e $$\forall i = \overline{1,n}, ~~~~H(u-\mu_i)=\left\\{\begin{array}{ll} 1 & \quad \mbox{if }\ u>\mu_i \\\\[0.1cm] 0 & \quad \mbox{if }\ u<\mu_i . \end{array} \right.$$ **Please I would appreciate the feedback.**
Suppose that $\mu_1<\mu_2<\cdots<\mu_n$. Then if $u<\mu_1$, then $S=0$. If $u\in(\mu_i,\mu_{i+1})$, then $S=i$. If $u>\mu_n$, then $S=n$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "calculus, analysis, summation" }
joomla 2.5 database query result returns every value as string datatype I was trying to get some database and trying to encode it in json format, the db table contains values of both int and varchar types $db = $this->getDBO(); $query = "SELECT * FROM ".mt_table." WHERE user_id=".$userid; $db->setQuery($query); $resulr= $db->loadObjectList(); var_dump($result); I used a `loadAssocList()` first and encoded it to json string but every value was taken as string, `var_dump()` also shows string type. How can I get result from database with datatype as it is in database, basically not convert everything into string maybe.... or do I need to explicitly make changes to int before I insert it into array using `array1['key']=(int)myValue;`?
I dont really know if there is any other way ..But what I did was to add (int) before storing every int values from database like $intVar = (int)var_from_db;
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, mysql, joomla2.5" }
C# - Combobox index change after editing A moment ago someone answered my question on how to edit the combobox loaded with a text file, and how to save the recently edited line. C#: Real-time combobox updating The problem now is that I can only change one letter before it updates, and then the selectedindex changes to -1, so I have to select the line I was editing again in the dropdown list. Hopefully someone knows why it's changing index, and how to stop it from doing that.
private int currentIndex; public Form1() { InitializeComponent(); comboBox1.SelectedIndexChanged += RememberSelectedIndex; comboBox1.KeyDown += UpdateList; } private void RememberSelectedIndex(object sender, EventArgs e) { currentIndex = comboBox1.SelectedIndex; } private void UpdateList(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter && currentIndex >= 0) { comboBox1.Items[currentIndex] = comboBox1.Text; } }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c#, combobox, indexing, editing, textchanged" }
Is this (not) an answer? I flagged this as not an answer. Question: > Is there a way to setup EF so that it recognizes the Parent/Child relationship so I can effectively have a subordinates collection? "Answer": > The problem with EntityFrameworkWithHierarchyId that is not official by EntityFramework team currently, it is a fork To me, this clearly is a comment on the answer already given, but, as so often, entered as an answer by a <50 rep user. But my flag was declined. Did a mod press the wrong button? (After all, they're human beings). Or is there something I have to learn about NAA?
It's _not_ an answer. It's a comment that provides no solution information whatsoever. The flag should have been accepted.
stackexchange-meta_stackoverflow
{ "answer_score": 7, "question_score": 6, "tags": "discussion, declined flags, not an answer" }
insert a value into an integer column without updating it, but adding it's contents ActiveRecord::Base.connection.execute "UPDATE ventas SET costo_de_compra = #{@nuevo_costo} WHERE id = #{@vid};" but this updates that column value every time it's recursed, what i want is just to insert that value to the already stablished values in that column... in proper instance i want to add the values to an integer column. Thanks in advance
I don't know Rails, but I guess something like this: ActiveRecord::Base.connection.execute _ "UPDATE ventas SET costo_de_compra = costo_de_compra + #{@nuevo_costo} _ WHERE id = #{@vid};"
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "sql, ruby on rails, ruby, activerecord, sum" }
When I Change My Frame Rate from 24 the 60 fps the particles go ultra fast and are not normal speed anymore I have been using blender for a while. I just tried a youtube video on using bubble to match with music and realized my frame rate was 24 so I changed it to 60fps nd my animation was ultra fast and was ruined. thankful it was easy to redo so I tried he whole old map and new map trick and got nowhere. it just broke the animation. Any help on how to make this run at a normal speed but be in 60 fps instead of 24 or 30. I am using cycles by the way. ![]( . When I changed the thing around that you guys recommended they go from bouncing to flat.![enter image description here]( This Is How It Is Suppose To Look. ![enter image description here]( Note that the frame rate is back at 24 and the map is set back to 100.
Ok, I see what's happening now. The reason it's going wonky is because you need to bake the particles first: Just to make sure it's right, do it _before_ you change the framerate. ![enter image description here]( After it's completed baking (it could take a minute depending on your processor speed), set the end frame and framerate settings as shown below: ![enter image description here]( Here's the final, notice the fps in the upper left hand corner: ![enter image description here](
stackexchange-blender
{ "answer_score": 2, "question_score": 3, "tags": "cycles render engine, rendering, animation, particles" }
what's the usage of 'bind' in bash I found something in a `.bashrc` file like: bind '"\C-j": menu-complete' bind 'set completion-ignore-case on' if I remove the 'bind',the result seems no different, so what's the usage of the 'bind' here?
`bind` is used for `readline` library. If you remove the first one, `Ctrl-j` will not do auto completion for you. If you remove the second one, auto completion for file name is case-sensitive. * * * You can use `help` command to view `builtin` command's manual. $ type bind bind is a shell builtin $ help bind bind: bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command] Set Readline key bindings and variables. ...SKIPPED...
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "bash" }
How to store input from echo in arrays in C If I were to type in `echo "1001" | ./test` in the terminal. and `test` takes "1001" and stores it into a array, how would I do that? In `test.c`: #include <stdio.h> main() { int c, i, j; int a[4]; while(c = (getchar() != EOF)) { a[i++] = c; } for(j = 0; j < 5; j++ { printf("%d", a[j]); } } but it's not working.
I find that this program works: #include <stdio.h> int main(int argc, char** argv) { int c, i = 0, j; int a[4]; while((c = getchar()) != EOF && i < 4) { a[i++] = c; } for(j = 0; j < 4; j++) { printf("%c", a[j]); } printf("\n"); // Be nice to non-windows users :) return 0; } There are a couple of changes from your original program. Initialisation of `i`, putting a limit on the number of characters read, outputting only 4 characters (`j < 4`) and fixing a bit of your syntax (missing brackets and `int main(int argc, char** argv)`). Oh, and `(c = getchar()) != EOF` since your first want to store your character and then do the comparison. I also changed `%d` to `%c` so that the characters are printed, you could change this back if you want, it depends what you actually want the program to produce.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c" }
How can I import some functions and classes from modules into test file? How can I import _NestedValueError_ class & _validate_item_ function from modules into test.py ? Should I use conftest.py as a mediator between modules and tests file or something? # /modules/errors.py class EmptyValueError(Exception): pass * * * #/modules/validate_item.py def validate_item(): pass * * * #/tests/test.py import pytest def test_item_validate_exception_nested_value(): with pytest.raises(EmptyValueError): validate_item({})
Simple: from modules.errors import EmptyValueError from modules.validate_item import validate_item But be sure to run pytest in `/`, with the following command: python3 -m pytest test/ From pytest documentation (linked above): > This is almost equivalent to invoking the command line script `pytest [...]` directly, except that calling via `python` will also add the current directory to `sys.path`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, python 3.x, pytest" }
Explain the verb tense in "I wish I never woke up this morning" This is from a song by Police, _Darkness_: > "I can dream up schemes when I'm sitting in my seat > I don't see any flaws 'til I get to my feet > I wish I never woke up this morning > Life was easy when it was boring" Shouldn't it be, according to www.eslbase.com, "I wish I ~~havn't~~ hadn't woken up this morning"? (though I agree the latter flows worse)
Strictly speaking, by the rules of grammar, it should be > I wish I'd never woken up this morning. But if you Google "I wish I never" you find that lots of people use constructions like > I wish I never woke up this morning. For example: > I wish I never told you, > I wish I never met you, > I wish I never ever got drunk that night. So, while strictly speaking this should probably be called bad grammar, it is nevertheless a quite common usage.
stackexchange-english
{ "answer_score": 2, "question_score": 2, "tags": "verbs, tenses, modal verbs" }
Create subdomain upon user registration I have a website where I want users that sign up to get their own subdomain. This subdomain is virtual, and every subdomain uses the same web server files. I use PHP and Apache, and I know about Virtual Hosts, but I'm wondering where I need to put the vhosts code. First, I don't have access to httpd.conf. Second, I want this to be done automatically upon registration. I've read about virtual hosts, but didn't find anything that answers my questions. Is there anyone who can explain me how all this works together, or know where I can find my answers?
Can you tell apache to read an extra .conf file? (traditionally you store your vhosts in httpd-vhosts.conf) if so, add something like the following and restart your webserver NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /abs/path/to/webroot ServerName domainname.com ServerAlias *.domainname.com <Directory /abs/path/to/webroot> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> then in php, you can see which subdomain the user is requesting by inspecting: $_SERVER['HTTP_HOST'] ie. if the user requests < $_SERVER['HTTP_HOST'] will have user1.domainname.com you can then explode('.', $_SERVER['HTTP_HOST']) to inspect each segment.. etc.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 6, "tags": "php, apache, virtualhost" }
Элементы выше главной диагонали прямоугольной матрицы Мы все знаем, как найти элементы выше главной диагонали в квадратной матрице. А что если матрица не квадратная, а просто прямоугольная и как найти в ней все элементы выше главной диагонали? Обычным `if (i <= j)` не обойдешься. Допустим есть такой код, который делает все элементы выше диагонали 0, остальные - рандомные: int n = 10; int m = 16; int** arr = (int**)malloc(sizeof(int*)*m); for (int i = 0; i < m; i++) { arr[i] = (int*)malloc(sizeof(int)*n); } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { arr[i][j] = rand() % 9 + 1; if (i <= j) //Какое-то корректное условие вместо данного { arr[i][j] = 0; } printf("%d ", arr[i][j]); } printf("\n"); } Как правильно решить такую задачу?
Если понимать искомую разделительную линию здесь, как диагональ прямоугольника, то можно предложить следующий подход: if (i * n < j * m) arr[i][j] = 2; //выше диагонали else if (i * n == j * m) arr[i][j] = 1; //точно на диагонали, таких элементов будет всего НОД(n,m) else arr[i][j] = 0; //ниже диагонали для 6x6: 1 2 2 2 2 2 0 1 2 2 2 2 0 0 1 2 2 2 0 0 0 1 2 2 0 0 0 0 1 2 0 0 0 0 0 1 для 6x9: 1 2 2 2 2 2 0 2 2 2 2 2 0 0 2 2 2 2 0 0 1 2 2 2 0 0 0 2 2 2 0 0 0 0 2 2 0 0 0 0 1 2 0 0 0 0 0 2 0 0 0 0 0 0
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c, алгоритм, матрицы" }
How to add text(uilabel)in MPMoviePlayerController I'm doing one application in that,i'm playing two videos one after another using MPMoviePlayerController.After the first video played in the middle of the second video it shows blank screen(white screen).At the time i want to display some text it simply says Loading...by using UILabel.Instead of white screen i want to display the text . How can i do this. Any ideas please.. Thank You
The MPMoviePlayerController has a property `view`. Just add your UILabel as a subview of that view. You'd also want to listen for the appropriate notifications to know when the second movie started to play so you could remove your UILabel. See the documentation for details.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "iphone, mpmovieplayercontroller, uilabel" }
How to hide values in iOS-charts PieCharts? I'm trying to change a PieChartView to not show the values on the Chart. Indeed I'm looking to a similar function to `pieChartView.drawSliceTextEnabled = false` but just for the values. I would be very thankful for some help :)
in data set, disable `drawValueEnabled` like `set.drawValuesEnabled = false`
stackexchange-stackoverflow
{ "answer_score": 20, "question_score": 11, "tags": "ios, swift, ios charts" }
If a prime $p\mid b$ and $a^2=b^3$, then $p^3\mid a$ I have an exercise that I don't know how to solve. I tried to solve it in many ways, but I didn't get any progress in proving or disproving this... The exercise is: > Prove or disprove: if $p$ is a prime number, if $a$ and $b$ are native numbers and $$ a^2 = b^3 $$ and if $p \mid b$, then $$ p^3 \mid a .$$ If someone has a proof to this exercise I would really appreciate it. Thanks!
Let the highest powers of $p$ in $a,b$ be $A(\ge0),B(\ge1)$ respectively, So, we have $2A=3B\implies \dfrac{2A}3=B\implies 3|2A\implies 3|A\implies A\ge3$
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "elementary number theory, prime numbers, divisibility" }
Wordpress json encode permalink and image I'm making a query to encode in JSON a bunch of wordpress post data in this way: $query = new WP_Query( $args ); $posts = $query->get_posts(); foreach( $posts as $post ) { $output[] = array( 'id' => $post->ID, 'title' => $post->post_title, 'count' => $post->custom_total_hits, 'soundcloud_url' => $post->soundcloud_song, 'soundcloud_id' => $post->soundcloud_ids); } echo json_encode($output); But how can I add to my JSON also the permalink of the $post->ID and the url of the attached image? In order to have something like: { "id":28197, "title":"Hazel English - More Like You", "count":"000000421", "soundcloud_url":"https:\/\/soundcloud.com\/hazelenglish\/hazel-english-more-like-you-2", "soundcloud_id":"317317206", "link":" ", "image_url":" " }
Look here: Permalink and Attached media $query = new WP_Query( $args ); $posts = $query->get_posts(); foreach( $posts as $post ) { $output[] = array( 'id' => $post->ID, 'title' => $post->post_title, 'count' => $post->custom_total_hits, 'soundcloud_url' => $post->soundcloud_song, 'soundcloud_id' => $post->soundcloud_ids, 'link' => get_permalink($post), 'images' => get_attached_media('image', $post->ID) ); } echo json_encode($output); As you can see in documentation, function get_attached_media return an array with all data of type selected from indicated post.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "php, json, wordpress" }
Pandas Python - Extract rows based on multiple conditions. data example included I am trying to extract row from dataframe1 to dataframe2 based on condition, but I am struggling, Anyone could help me? It would be so awesome. dataframe1 : df1 = pd.DataFrame([[1001, 'democrat',0.23],[1001, 'republican',0.7],[1001, 'others',0.07],[1003, 'democrat',0.33],[1003, 'republican',0.44],[1003, 'others',0.23]], columns=['Fips_code', 'Partisan', 'Vote_Pct']) dataframe2 : df2 = pd.DataFrame([[1001],[1003], [1005]], columns=['Fips_code']) I want to add three columns into dataframe2 as below ('democrat_vote_pct','republican_vote_pct','others_vote_pct') based on fips code condition. Desired out : df2 = pd.DataFrame([[1001,0.23,0.7,0.07],[1003,0.33,0.44,0.23], [1005, NA, NA, NA]], columns=['Fips_code','democrat_vote_pct','republican_vote_pct','others_vote_pct']) Please help me..
You can try something like this: _df2 = df1.pivot_table(values='Vote_Pct', index='Fips_code', columns='Partisan') And then: result = df2.merge(_df2, on='Fips_code', how='left') Which gives you what you want: Fips_code democrat others republican 0 1001 0.23 0.07 0.70 1 1003 0.33 0.23 0.44 2 1005 NaN NaN NaN If you want the columns to have different names, just give it a `.rename()` new_cols = {'democrat': 'democrat_pct_votes', 'others': 'others_pct_votes', 'republican': 'republican_pct_votes'} df2.rename(new_cols, axis=1, inplace=True)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, dataframe" }
Get partner (including its children) invoices I'm trying to get the first and last invoices for a partner including its children. Is there any method to get all partner invoices including its children? Otherwise, how can I get it using SQL query?
You can use the `child_of` domain operator. So if `partner_id` is the partner you want all invoices of including all invoices of its children, your search domain should look like: [('partner_id', 'child_of', partner_id)]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "odoo, odoo 10, odoo 9" }
Python unpack problem I have: a, b, c, d, e, f[50], g = unpack('BBBBH50cH', data) The problem is f[50] (too many values to unpack) How do I do what I want?
I think by `f[50]` you are trying to denote "a list of 50 elements"? In Python 3.x you can do `a, b, c, d, e, *f, g` to indicate that you want `f` to contain all the values that don't fit anywhere else (see this PEP). In Python 2.x, you will need to write it out explicitly: x = unpack(...) a, b, c, d, e = x[:5] f = x[5:55] <etc>
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 9, "tags": "python" }
How To Hide Filters On Specific Categories with WooCommerce Products Filter(WOOF) I am trying to put filters on products categories and I tried WOOF-WooCommerce Products Filter on wordpress and I saw that the filters that I created on a specific category are sticked and on the other categories which I want to have different filters. Do you know how can I fix that with this plugin or can you recommend me a plugin that supports that feature or if it is possible in any way? Thank you
Try to use my plugin WOOF by Category. It was developed exactly for this task.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "plugins, woocommerce offtopic, e commerce" }
To take advantage of - vs. - make use of I am writing a manuscript in scientific context and stumbled over the question if "taken advantage of" or "made use of" is the better way to express the following sentence because I have seen these formulation so far only in casual context. At the moment it is formulated as follows: "Therefore, it is taken advantage of the in Sec. X described motion that lets a point undergo... (further details about the motion)" I want to express, that I make use of / take advantage of the known properties of the motion to add additional constraints to an algorithm. Which formulation would you suggest in this context? Thank you.
Given your context, I would prefer "make use of", for 3 reasons. 1. To "take advantage of" something means to make _good_ use of that thing (see the definition below), so I'd keep its use to a minimum, so that when it is actually used, it is more impactful, perhaps at a climactic moment along your narrative. I'd use it for something that you really made good use of, not something that you maybe made incidental use of. 2. "take advantage of" also has another meaning (the first meaning in the dictionary search results below), with negative connotations, so I'd prefer "make use of" for simplicity and clarity, lack of ambiguity. 3. Stylistically speaking, scientific papers tend to be more objective, and more level-headed than some other writings (say, some kinds of fiction). So in keeping with this style, go with "make use of" unless you made exceptionally good use of something. ![Definitions of "take advantage of"](
stackexchange-english
{ "answer_score": 0, "question_score": 0, "tags": "meaning, differences" }
GCJ and Java Home I am trying to install a software on CentOS and the doc says something like this... > If you are using a Linux distribution that installs GCJ by default (which includes all of the most popular distros), then before you begin installation you must remove, disable, or circumvent GCJ. If you cannot remove it, you can simply ensure that your JAVA_HOME variable is properly set, and add the Java Runtime Environment's /bin/ directory to the beginning of your PATH variable in ~/.bashrc or /etc/environment, then relog before continuing. I will like to know the exact commands I need to execute to that effect. (Java Newbie)
After you've installed for example the Oracle JDK then you can use the following command: `alternatives --config java`. This command has to be performed as root user.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "java, centos" }
How can I stop executing the rest of a method at some point inside the method? I was wondering if there is a command which would have the same function as `exit`. So, for instance: if (Average < 35) { MessageBox.Show("you failed"); **EXIT** } if (Average >= 75) { lblOutput.Text += Name +" " + Surname + ", " + "your average was: " + Average + ", you shall recieve a bursary!"; } else lblOutput.Text += Name +" " + Surname + ", " + "your average was: " + Average + ", you shall not revieve a bursary!"; Even if the average is lower than 35, the script will carry on going and the `lblOutput` will still say `You shall not receive a bursary.` while it should just show the `MessageBox` and not do anything with the label. Could someone explain how to do this?
You can use `return;` to stop the execution path.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "c#" }
where is "PS_META_DESCRIPTION" and "PS_META_KEYWORDS" and how can i change it? in classes/Meta.php i found this lines in "completeMetaTags" function: if (empty($meta_tags['meta_description'])) { $meta_tags['meta_description'] = Configuration::get('PS_META_DESCRIPTION', $context->language->id) ? Configuration::get('PS_META_DESCRIPTION', $context->language->id) : ''; } if (empty($meta_tags['meta_keywords'])) { $meta_tags['meta_keywords'] = Configuration::get('PS_META_KEYWORDS', $context->language->id) ? Configuration::get('PS_META_KEYWORDS', $context->language->id) : ''; } it seems, when a page doesn't have any keywords or description, it tries to set "PS_META_KEYWORDS" and "PS_META_DESCRIPTION" to those. but the value of "PS_META_DESCRIPTION" and "PS_META_KEYWORDS" are empty for me and i don't know where can i change these values ? i searched "configuration" table but i can't find "PS_META_DESCRIPTION" and "PS_META_KEYWORDS" values.
I cannot find what you are searching for in the whole raw Prestashop 1.6 repository, except the legacy code you are talking about. A way to set this could be to make a simple module with these fields to custom, you can find an helper here : < Anyway it's not possible with the actual version, it surely was in the past.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "prestashop, prestashop 1.6" }
ASP.NET MVC 4, multiple models in one view? I'm working on a little project in which we have a table of engineers, a table of projects, and a table of elements. engineers are assigned multiple elements, and elements can have multiple projects. I was just wondering how I would go about showing all the elements a engineer is apart of. Currently, I have a table created that associates a engineer with a element. it looks a little like this: [Engineer Elements] [Engineer ID][Element ID] [1] [2] [1] [4] [2] [2] [2] [8] So I do have a way to link the two tables. Could push me into the right direction on learning a bit more on linking these tables together using MVC?
If you don't already have a view model to represent this, just create one: public class MyViewModel { public Engineer Engineer { get; set; } public List<Element> Elements { get; set; } } Populate a set of view models in the controller public ActionResult MyAction() { var viewModels = (from e in db.Engineers select new MyViewModel { Engineer = e, Elements = e.Elements, }) .ToList(); return View(viewModels); } And in your view just specify that you're using a collection of view models: @model List<MyViewModel> @foreach(var vm in Model) { <h1>Projects for engineer: @vm.Engineer.Name</ha> <ul> @foreach(var ele in vm.Elements) { <li>@ele.Name</li> } </ul> }
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "mysql, asp.net, asp.net mvc, vb.net, asp.net mvc 4" }
How much do i need to learn in order to get an entry level asp.net job? > **Possible Duplicate:** > If you develop with ASP.NET, which other technologies do you use? I'm currently learning C#, but I've noticed that there is a lot of demand for ASP.NET developers. I purchased the book 'Beginning ASP.NET 4: in C#' by Wrox. I will start with that book and finish the web project provided in the book after I've learned C# fully. I wanted to know how much C#, SQL, CSS, XHTML, Javascript and/or jQuery I need to learn in order to have a chance of getting an entry level ASP.NET job.
Here is a good litmus test: * Can you build a **_cookbook application_**? At its core, a cookbook application is a CRUD application. This means it includes web pages which: * **C** reate data. * **R** ead data. * **U** pdate data. * **D** elete data. To do this (without an out-of-the-box CMS of course ;), you must implement a fair amount of C#, SQL, XHTML, and CSS. This would be a good start. Once you can build a cookbook application, reflect a little bit more. Can you build an _attractive_ cookbook application? That is, can you build an application which is both aesthetically pleasing and very usable? To do _this_ , you must implement a fair amount of javascript and/or jQuery. If you can do _this_ , then you are most certainly ready to interview for an entry-level ASP.NET position. And when preparing for the interview, be ready to discuss your experience putting together the "cookbook application".
stackexchange-softwareengineering
{ "answer_score": 20, "question_score": 0, "tags": "web development, learning, c#, asp.net" }
Seemingly wrong CSS is being given priority I'm having an issue where my CSS for td tag seems to be given priorty over more specific CSS class I've included, blue_link. The blue_link class appears at the bottom of the style sheet and I've confirmed the priority issue in Chrome's element inspector. Any suggestions would be greatly appreciated. CSS that is being given priority: td a:link, td a:visited { color: #333; text-decoration: none; } Desired class: a.blue_link { color: #5299c3; !important text-decoration: none; } HTML: <td><a class="blue_link" href="profile/edit/<?php echo $profile_item['profile_id'] ?>">edit</a></td>
a.blue_link, a.blue_link:link, a.blue_link:visited { color: #5299c3; text-decoration: none; }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "css" }
Crashalytics not working for xcode 10, iOS12 Crashlytics does not report crash event to Fabric for Xcode 10 or higher and iOS 12 or higher.
To report crash to Fabric from Xcode 10 and iOS 12 or higher Step 1: 1. Go to Build Settings 2. Search "Debug Information Format" 3. Change value of "Debug" from "DWARF" to "DWARF with dSYM File" 4. Build your project again. ![Debug Information Format]( Step 2: Set absolute path of Info.plist in "Input Files" \- Add/Change "Input Files" value in Run Script added for Fabric under "Build Phases" \- From "$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)" To new path* "/Info.plist" *new path: You can also get Info.plist path from Build Settings -> Packaging -> Info.plist File ![Plist Path](
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "ios, xcode, crashlytics" }
Weird positioning of elements when div contains text I have this problem where I have some containers that need to be aligned in a parent container, but for some reason that does not happen. This is how it looks like: < This is what happens if I remove the labels from top and bottom (removing this pieces of code `<div class="eticheta">top</div>` and `<div class="eticheta">bottom</div>`) < As you can see the div with class l34 is positioned correctly in the second example, but I need to have the labels inside it too. Any advice would be great!
its because you are using `inline-block;` in class that why element is not aligning properly just add `vertical-align:top;` in `.134 class` it will fix it <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "css, css position" }
Strange error when assigning a byte array byte[] frame_to_send= new byte[6]; // code frame_to_send = { 0x68, 0x04, 0x83, 0x00, 0x00, 0x00}; `//Array edit` Error: > Invalid expression term '{' > ; expected
You can only do this at construction time initialization: byte[] frame_to_send = { 0x68, 0x04, 0x83, 0x00, 0x00, 0x00}; At any later time you can only do it like that: frame_to_send = new byte[]{ 0x68, 0x04, 0x83, 0x00, 0x00, 0x00}; _Note_ that in the code you show you at first create a byte array with all values set to 0, and then (try to) create a new one, discarding the formerly created completely. So your initial assignment is totally redundant.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": -1, "tags": "c#, arrays" }