INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Hi, I'm working on Power BI with some DAX, measures and tables to get last record with cumulative date due a range of dates here is the table I'm working on Power BI with some DAX, measures and tables to get last record with cumulative date due a date slicer, I need to get consideration about the rows to consider their data by the date slicer. ![Base Image]( And what I want to get as result is according the date slicer if the dates will include by item, if date is <= 26/06/2018 ![Data filtered by date and summarized by item]( And if date is <= 12/07/2018 looking for the latest date rows ![Data filtered by date and summarized by item]( Thanks so much for your help
Measures and slicers generally do not work well if you're trying to filter with a measure that is being filtered by a slicer. See this DAX measure: if(CALCULATE(max(table1[date]),ALLEXCEPT(Table1,Table1[Score],Table1[Percentage_By_Class]))=max(Table1[Date]),1,0) This measure will highlight the most recent records (of all time) with a 1 and every other record with a 0. You can use this measure in visual level filters to highlight the latest set of records. Unfortunately, it will not update as you change your filter with the slicer, making your table return empty. The only solution that I can recommend is to change your date slicer to different type which is better suited to finding the records you are looking for.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "powerbi, dax" }
Почему Individual User Account не активна в Asp.Net Core Web Api? Доброго времени суток, Стэковерфлоучане, при создании **ASP.NET Core** проекта пошаблону **WEB API** , при выборе способа аутенфикации пользователя "Individual User Accounts" не активна ? ![введите сюда описание изображения]( Пробовал переустновить **VS 2017** \- не помогло, все что удалось нагуглить так это то что сейчас "Individual User Accounts" не поддерживаются в шаблоне Web API, как быть тогда в такой ситуации ?
Это известное ограничение. Можно либо скопировать из обычного проекта, MVC версии, либо встроить в проект самостоятельно, туториалов полно. Вообще Identity для web.api избыточно, советую вам посмотреть в сторону OAuth 2.0 и JWT решений для аутентификации в сервисах и отказаться от схемы логин+пароль.
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "asp.net core" }
Is Iran in compliance with JCPOA? In a public Facebook post, Barack Obama wrote: > Fourth, Iran is complying with the JCPOA. That was not simply the view of my Administration. The United States intelligence community has continued to find that Iran is meeting its responsibilities under the deal, and has reported as much to Congress. So have our closest allies, and the international agency responsible for verifying Iranian compliance – the International Atomic Energy Agency (IAEA). Is this true, or has Iran violated the nuclear deal?
According to the IAEA: **Iran is compliant.** The IAEA issued this statement by its Director General Yukiya Amano on 2018-05-09: > The IAEA is closely following developments related to the Joint Comprehensive Plan of Action (JCPOA). As requested by the United Nations Security Council and authorised by the IAEA Board of Governors in 2015, the IAEA is verifying and monitoring Iran’s implementation of its nuclear-related commitments under the JCPOA. Iran is subject to the world’s most robust nuclear verification regime under the JCPOA, which is a significant verification gain. As of today, the IAEA can confirm that the nuclear-related commitments are being implemented by Iran. Also: _If_ the USA has proof of violations it should submit this proof to the IAEA and the UN security council (the JCPOA was endorsed by the UN Security Council).
stackexchange-skeptics
{ "answer_score": 29, "question_score": 15, "tags": "iran, jcpoa" }
Flutter http request works on emulator, but not on real android The method http.post **works on the emulator** , but when I run this on real android phone it doesn't work. **Android permission already added.** Main AndroidManifest.xml : <manifest xmlns:android=" package="com.example.niceapp"> <uses-permission android:name="android.permission.INTERNET"/>.. ... ... **What could be the problem?**
it may be because you are using localhost. check your url and the network you are in.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "flutter, http" }
Whats going on behind the scenes with method - public static long parseLong(String s,int radix) I need to generate a consistent unique Long based on the name of the package. Instead of using "Convert string to long" in Eclipse I think I can achieve the same task at run time by using method public static long parseLong(String s,int radix) ? I think I need to use something like - Long.parseLong("Hazelnut", 36) returns 1356099454469L Which I got from question - How to convert String to long in Java? Why do I need to set radix to 36 when converting a String that contains characters ?
Well, you're basically to treat it as a number in base 36. So for example, the string "012" would mean 2 + 1 * 36 + 0 * 362. When you run out of digits, you go to letters - so "ABC" would mean 12from 'C' \+ 11from 'B' * 36 + 10from 'A' * 362. If you understand how hex works, it's the same except using all the characters in the Latin alphabet. It'll fail for anything not in 0-9, A-Z, a-z though - and it'll also fail for reasonably long strings; `long` only works up to 263 which you'll get past reasonably quickly in base 36. "Hazelnut12345" fails, for example. Oh, and this is case-insensitive, so the value for "foo" is the same as for "FOO" - does that fail your uniqueness requirement? Fundamentally you've only got 264 `long` values to play with, so unless your package names are pretty restricted you're not going to work out a unique mapping.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "java, radix" }
What is time complexity when power involed? def f1(lst): i=3 while i<len(lst): print(lst[i]) i **= 3 What is the time complexity of this code? the answer says O(loglogn), why?
Take a look at how `i` grows with loop (`^` means power here) : i_0 = 3 i_1 = i_0^3 = 3^3 i_2 = i_1^3 = (3^3)^3 = 3^(3*3) i_3 = i_2^3 = (3^(3*3))^3 = 3^(3*3*3) ... i_n = 3^(3^n) This is called iterated powers but it is **not** Tetration. As you can see, it is a nested exponentation so the time complexity would be the inverse function : `O(log3(log3(n)))`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python 3.x, time complexity" }
After passing through immigration at the airport, is it possible to cancel the stamp and go back? If I stamped my passport for an international flight as we usually do before international departures and then I changed my mind for any reason, for example a family emergency reason. What's the process to cancel the stamp and leave the departure area?
The actual process would depend on your location and passport, but you can of course in principle be stamped back in. You'd have technically left the country which stamped you out. Not departing, for whatever reason, would require you to, technically, enter the country again, with all due consequences. You might have to purchase an (emergency?) visa on the spot. And I do suspect that some countries, notably countries that don't issue visas on the spot for passport holders of your country, might not have any procedure in place for an occurrence like you're describing. You might end up being forced to take your flight, be deported or be denied entry and be the next Terminal Man. :)
stackexchange-travel
{ "answer_score": 5, "question_score": 10, "tags": "customs and immigration, airports, airport security, emergencies, passport stamps" }
Cannot scandir() correct directory after htaccess rewrite On /portfolio.php (which is located on root of the site) I want to show all images from the directory /trabajos/tataviajes. foreach(scandir('./trabajos/tataviajes/', 1) as $filename){ echo '<img src="'.$filename.'"/>'; } The function open the images like this: /portfolio/123.jpg instead of /trabajos/tataviajes/123.jpg The htaccess code that I think it might interfere is: RewriteRule ^portfolio/(\w+)/?$ portfolio.php?i=$1 Was I clear? What is the issue? Thanks in advance!
`scandir` returns an array of **filenames** not _file paths_ see < You need to prefix the path to the filename. Consider something like: $directory = 'trabajos/tataviajes/'; foreach(scandir($directory, 1) as $filename){ echo '<img src="/'.$directory.$filename.'"/>'; } also, consider using `htmlentities` so special characters in the path will not mess up your markup: echo '<img src="'.htmlentities('/'.$directory.$filename).'"/>';
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, .htaccess, directory, scandir" }
Python: 4 words before a substring if they exsist I want to have 4 words a particular word. if there are only 3 wrords before I want the 3 words to be printed. Example: input: There is a bad CAT sitting on the wall output: is a bad line is having the sentance. if 'CAT' in line: print(line.split('CAT')[0].split()[len((line.split('CAT')[0]))-3): len(line.split('CAT')[0])]) Can you let me know if I am missing anything and if there is any other efficent way. Planning to do line.split(CAT)[0] to get all the data before cat. again on that I want to getoutput of [0] starting at len-3 to len. Its giving Error am I missing anything. also can I add a condition if there are only 2 words print only 2
You're on the right track. If you want to get the three words before `D` in a string `S`, defaulting to fewer words if there's less than three available, you can use this: S.split(D)[0].split()[-3:] Examples: >>> S = 'There is a bad CAT sitting on the wall' >>> S.split('CAT')[0].split()[-3:] ['is', 'a', 'bad'] >>> S = 'The bad CAT is sitting on the wall' >>> S.split('CAT')[0].split()[-3:] ['The', 'bad'] Of course, if you wish to join this back into a string, you can use: ' '.join(S.split(D)[0].split()[-3:]) This can also be accomplished using regular expressions, but I doubt it would offer much better performance.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python" }
Add class to every few random elements with jquery I have a sequence of elements, let's say: <div class="tile1"></div> <div class="tile2"></div> <div class="tile3"></div> <div class="tile4"></div> etc. How would I use Jquery to add the new class "color" to every few random elements with an increment varying between 2 and 6 like so: <div class="tile1"></div> <div class="tile2 color"></div> <div class="tile3"></div> <div class="tile4"></div> <div class="tile5 color"></div> <div class="tile6"></div> <div class="tile7 color"></div> <div class="tile8"></div> <div class="tile9"></div> <div class="tile10"></div> <div class="tile11"></div> <div class="tile12 color"></div> etc.
You'll need to mix JQuery with plain javascript: $("[class^=tile]").each(function(i,e){ ranNum = Math.floor(Math.random() * (6 - 2 + 1)) + 2; if((i + 1) % ranNum == 0){ $(e).addClass('color'); } }); Here we're looping through the tile divs and if the remainder of the tile's number divided by the random number is 0 we're assigning it the color class. **JSFIDDLE**
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, jquery, random, increment, sequential" }
Share a text with facebook messenger? Is there a way to share a text in facebook messenger using android and maybe facebook sdk as well? I want to make something like the whatsapp way, choose your text and open an intent to choose the guy you want to send to... Is there a way to do this with facebook messenger? It appears in the intent.choose dialog..but I only want to send to facebook messenger..
use this code onClick,, com.facebook.orca is the package name for fb messenger. Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent .putExtra(Intent.EXTRA_TEXT, "<---YOUR TEXT HERE--->."); sendIntent.setType("text/plain"); sendIntent.setPackage("com.facebook.orca"); try { startActivity(sendIntent); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(context,"Please Install Facebook Messenger", Toast.LENGTH_LONG).show(); }
stackexchange-stackoverflow
{ "answer_score": 41, "question_score": 24, "tags": "android, facebook messenger" }
A heuristic function for 3 Water Jug I've question to ask you guys. I'm a newbie in Artificial Intelligence. I want to solve water jug problem(3 jugs - 3 lt, 5lt, 9lt - Trying to get 7lt) using A* search. I need a heuristic function to implement the solution, but I can't find a good heuristic f(n) so that the algorithm will find the least steps to the solution.
So given your parameters the non-heuristic way of solving this problem is: 0) Fill the 9 liter jug 1) Pour the 9 liter jug into the 5 liter jug, this leaves 4 liters in the 9 liter 2) Fill the 3 liter jug 3) Pour the 3 liter jug into the 9 liter jug and the problem is solved So looking at this you will have a graph that has nodes that can be in one of two states: `Pour` or `Fill` . You then assign to each node a weight that represents the amount of liquid you will get from it, `1,2,3,etc` . There should be no division involved, you just need to make it "expensive" to use specific operations.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "artificial intelligence, graph algorithm, heuristics" }
How do programs that don't appear in the startup folder auto-execute on startup? Just out of curiosity I was wondering how this is done. I know you can probably manually make a program startup using windows scheduler, but for something download from the interwebs, such as Discord, how does it autonomously give itself the ability to run on startup without actually being in the startup folder?
I found the answer elsewhere on this site, here is the link and a quote < > Add a new startup application Open your registry and find the key [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]. > > For each program you want to start automatically create a new string value using a descriptive name, and set the value of the string to the program executable. > > For example, to automatically start Notepad, add a new entry of "Notepad"="c:\windows\notepad.exe".
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "windows, startup" }
How do I edit contacts in Android 4.4? On my Android 2.3 phone I've exported my contacts and imported them on my new Android 4.4 phone, a Motorola G. Unfortunately, I found no way to edit the contact. When I open the "phone" application from the main screen, I click "All contacts" (translated) to get the list of all contacts. But as soon as I click on one item, it dials. Click-and-hold does nothing - no context menu occurs. How to edit the contacts (name, phone number)?
Don't use the phone/dialer app to edit contacts: use the main **People** app (it's called **Contacts** on some non-Nexus phones). From that app, when you click the contact you want, it displays that contact, and you can click the pencil icon on the _action bar_ (at the top) to edit the contact. (The icon might look different on your phone, because most manufacturers replace the People app with their own variant.)
stackexchange-android
{ "answer_score": 8, "question_score": 8, "tags": "contacts, 4.4 kitkat" }
Am I missing out on anything by sticking by Windows XP? I've seen Vista come by, and while it looked cool, I assumed that it would run slower on my machine with the Aero theme. I also run my XP with animations, shadows and the like turned off, and also set to _Windows Classic_ theme. With Windows 7 on the horizon, is there any reason I should be thinking of upgrading? **Update** To clarify, I turned off the animations to get better performance. My computer is about 2 years old, and is running these specs: > Intel Core(TM) 2 CPU 6300 @ 1.86GHz; 1 GB of RAM **Update 2:** I now run Windows 7. :)
XP 64-bit isn't very "polished", with a lot of missing drivers, and a 64-bit OS is the only reasonable way to get more than 4Gb of addressable RAM.
stackexchange-superuser
{ "answer_score": 12, "question_score": 9, "tags": "windows xp" }
Are the column count and column decltypes invariant for the duration of the execution of a SQLite prepared statement? When I look at code other folks have written using the SQLite3 C API, I find `sqlite3_column_decltype` and `sqlite3_column_count` are called from the inner loop (once per result row). My _understanding_ of this database is that these values will never change even if the statement is re-compiled (see the bit about `sqlite3_prepare_v2`). So I should be able to call these once and cache them immediately after the call to `sqlite3_prepare`.
The columns' declared types can change, if you use the same statement in two transactions and the database schema is changed between them. In the same situation, the column count can change, if your query is also using `SELECT *`. However, a _single_ query execution is always inside a transaction (either a manual or an automatic one). So if you cache the values after the call to `sqlite3_prepare_v2()` and use them only until the next call to `sqlite3_reset()`/`sqlite3_finalize()`, everything is fine. You can cache them longer if you ensure that all uses are inside the same transaction.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c++, c, sqlite" }
How to express a version range for Github Action dependency In a GitHub workflow, I may use a versioned Github Action. The documentation states: > We strongly recommend that you include the version of the action you are using by specifying a Git ref, SHA, or Docker tag number. If you don't specify a version, it could break your workflows or cause unexpected behavior when the action owner publishes an update. As far I know, the version can be: a branch, ref, or a commit SHA1. Is it possible to express more constraints such as a version **range**? An imaginary syntax: jobs: my_job: steps: - name: My action uses: myAction@[1.1, 1.234] It would means "use MyAction with a version between 1.1 and 1.234". Is there a way to express that kind of version constraints?
I don't think it's possible as in theory looks not. In `github actions`, every customized action's syntax is `githubuser/repository`. It represents for a real github repo: E.g.`actions/setup-node` as ` The github actions engine surely need to download the source code from these repository, and use a git concept (Hash, commit, branch, tag) to find the correct source to run the action. If we allow a range, then really don't know which commit of action's source code should be used.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "github actions" }
Not able to load sass file Rails 3.1.3 I imported a css.sass file which in turn has : @import "mountable_engine/file.sass" But due to some weird reason some of the sass files are found and for some I get the following error : > **ActionView::Template::Error (File to import not found or unreadable: mountable_engine/file1.sass** How can I get rid of this error? * _EDIT : *_ This is happening within a mountable engine
It seems it was my own mistake. There was an issue with pre-compiling assets so somehow that file was left out by rails. After clearing the rails cache folder and re-running assets precompile my issue was solved.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "ruby on rails, ruby on rails 3.1, sass, rails engines" }
How to integrate $\int_0^{\pi/2} \frac{\sin(x)}{\sin(x+\frac{\pi}{4})}{\rm d}x$ using substitution $x = \frac{\pi}{2} - y$? I reached $$ \int_0^{\pi/2}\frac{\sin(x)}{\cos(x) + \sin(x)}{\rm d}x = \int_0^{\pi/2}\frac{\cos(y)}{\cos(y) + \sin(y)}{\rm d}y $$ by using the double angle formula and the substitution but not sure how the question wants me to "exploit the symmetry at the midpoint." Thanks in advance !
Let$$I:=\int_0^{\pi/2}\frac{\sin x{\rm d}x}{\sin(x+\pi/4)}=\int_0^{\pi/2}\frac{\sqrt{2}\sin x{\rm d}x}{\sin x+\cos x}=\int_0^{\pi/2}\frac{\sqrt{2}\cos y{\rm d}y}{\sin y+\cos y}$$ so, averaging the last two expressions,$$I=\frac{1}{\sqrt{2}}\int_0^{\pi/2}{\rm d}x=\frac{\pi}{\sqrt{8}}.$$
stackexchange-math
{ "answer_score": 5, "question_score": 0, "tags": "integration, trigonometry" }
If I want to create a top-down 2D game should I rotate the camera? Do I have to rotate the camera to top-down view if I want to crate a top-down 2D game or just disable gravity?
You can do _whatever you want_. * * * That said, it is worth considering _standards_. Picture your game space as a 2D grid. If you retain the default camera angle, you would be working along the _X_ and _Y_ axis. If you rotate your camera to a down-facing position, you would be working along the _X_ and _Z_ axis. _I_ would say "leave the camera the way it is"; it is far more conventional to refer to a position on a 2D plane as "X, Y". While you could easily portray coordinates as "X, Y" to the _user_ , you still have to work in "X, Z", _yourself_. Any built in methods that apply to two-dimensional coordinates will also _assume_ use of "X, Y", including the directional vectors housed in the `Vector2` class. Why add another layer of complexity to your project? Use the "X, Y" plane, and stick to 2D standards.
stackexchange-gamedev
{ "answer_score": 0, "question_score": 1, "tags": "unity, 2d, camera" }
How to display unicode chars in ielm I'm using emacs on MAC OSX ELISP> (emacs-version) "GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2019-09-06" ielm REPL echoes back the octal, hex and character representation when entering an integer less than or equal to 127: ELISP> 81 81 (#o121, #x51, ?Q) ELISP> ?a 97 (#o141, #x61, ?a) But when using unicode chars like for example lambda ('λ') I get only the number 955 ELISP> 955 955 (#o1673, #x3bb) ELISP> ?\N{Greek small letter Lamda} 955 (#o1673, #x3bb) ELISP> ?\u03bb 955 (#o1673, #x3bb) Since Emacs support full unicode, (you need to use Symbola or some similar font), it should be possible for ielm to echo back the actual glyph for the character: ELISP> (concat '(?I 32 955 32 ?\u2665 32) "Emacs") "I λ Emacs"
This behaviour is controlled by the `eval-expression-print-maximum-character` variable. eval-expression-print-maximum-character is a variable defined in `simple.el'. Its value is 2305843009213693951 Original value was 127 Probably introduced at or before Emacs version 26.1. Documentation: The largest integer that will be displayed as a character. This affects printing by `eval-expression' (via `eval-expression-print-format'). See Lisp-Eval for further details.
stackexchange-emacs
{ "answer_score": 1, "question_score": 0, "tags": "unicode, characters, ielm" }
Generating HTML programmatically In C#, I use XML/XSLT transformation to isolate markup from data. What's the equivalent in Objective C?
XML/XSLT isn't something that is specific to C#, and XSLT can be used with objective c. You might want to look at this question.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "iphone, objective c, cocoa, cocoa touch" }
How to connect to Azure Oracle 12c Database using sqlplus or sql developer cloud connection I have 2 VM in azure one is a DB server and the other is a web server. I can get remote desktop connection for both these servers and web server can connect to Database wih sqlplus user/password@internal_network_ip:port/sid But however I cannot connect to Cloud DB from my local system. I tried sqlplus user/password@internal_ip:8552/sid ORA-12170: TNS:Connect timeout occurred sqlplus user/[email protected]:8552/sid -- oracle port ORA-12170: TNS:Connect timeout occurred sqlplus user/[email protected]:54955/sid -- port for cloud system used when taking remote desktop connection ORA-12547: TNS:lost contact sqlplus user/password@server_hostname:8552/sid ORA-12154: TNS:could not resolve the connect identifier specified However I cannot connect to the Database Where am I going wrong?
You most likely need to open an endpoint on the cloud service into which your Oracle DB has been deployed. I would recommend you make the public port something other than the default Oracle port. See the Azure documentation site for instructions on how to create endpoint.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "database, azure, oracle sqldeveloper, sqlplus, oracle12c" }
Applescript working natively, but not in filemaker I'm trying to save a pdf as text. The following code works when I run it in scripteditor, but not when I run it in filemaker ( I've never had a problem before converting my applescripts to run in a filemaker step ). activate application "Adobe Reader" tell application "System Events" tell process "Adobe Reader" click menu item "Text..." of menu 1 of menu item "Save As" of menu 1 of menu bar item "File" of menu bar 1 end tell end tell
One possible source of error in this type of command is the 3 dots in the **"Text..."** menu item name. Some menu items actually use 3 periods while others use an ellipsis (you can type that with option-semicolon). I've used the wrong form before so please make sure you are using the correct form for your menu item. The only way to know for sure is to try both and see which works. Normally an ellipsis is used so it's best to try that form first.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "applescript, filemaker" }
How does MapRoute access the field names of an anonymous type? How does the implementation of MapRoute connect the `{id}` in the second parameter to `id =` in the third? routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); Is it as simple as reflecting on the passed in object?
Yes. It creates a `RouteValueDictionary` instance from the `defaults` parameter, which populates itself from the object's `PropertyDescriptor`s. You can see this in the source: if (values != null) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties(values); foreach (PropertyDescriptor prop in props) { object val = prop.GetValue(values); Add(prop.Name, val); } }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, asp.net mvc" }
Why did my SO reputation transfer to MSO? Why did my reputation from Stack Overflow transfer to Stack Meta Overflow? Was this supposed to happen? Are the reps linked together now, (If I loose reputation here will it affect me on SO)? Why didn't my badges transfer too then?
> Was this supposed to happen Yes > Are the reps linked together now Yes Meta StackOverflow where you can ask question related to StackOverflow feature-request/bugs etc. so this is meta site for the StackOverflow now. You can see on your meta stackoverflow there is no reputation tab there so here is no reputation now. If you have any question that related to complete stackexchange network site then you can ask here
stackexchange-meta_stackoverflow
{ "answer_score": 16, "question_score": 13, "tags": "discussion, reputation" }
capacities to do or capacities in doing? What is the best choice that can be used after "capacities": > Do people have capacities to do (I think this is right), or capacities in doing (as a good friend of mine insists)? For example, can we say that > Individuals have differential **capacities to invest** in acquiring these skills, depending on their social class. or > Individuals have differential **capacities in investing** in acquiring these skills, depending on their social class.
The second example combines two gerunds, making it an awkward presentation of thought. An editor would suggest it be changed to the first example construction ( _to invest in acquiring_ ). As to the notion of whether "in investing in" or "to invest in" is the preferred usage to follow "capacities," the intention of the noun should be considered. Given the two opposing examples, "capacities" should be followed by the infinitive verb which is followed by a gerund. However, if in the second example the second gerund is replaced by a noun of action construction (i.e., _the acquisition of_ ), then "in investing in" would be correct, but still awkward.
stackexchange-english
{ "answer_score": 0, "question_score": 0, "tags": "word choice, prepositions" }
Jenkins failing to clone Bitbucket links during Rspec Puppet unit tests I'm trying to set up a Jenkins build to clone a Bitbucket link and run unit tests I've written against some Puppet modules. I've got Jenkins set up with an SSH keypair and have verified that it can clone the Bitbucket repository initially, but when the unit tests run and clone separate modules as part of the test, I get an error that the public key does not work. Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. I've verified that the build is running under the Jenkins user and that the keys are in the .ssh directory, what else can I try to fix it?
I was able to fix it by logging into the Jenkins Docker instance and using the SSH keypair from there instead of the one on the Jenkins server hosting the instance. It worked completely after I did this.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jenkins, github, ssh, rspec, bitbucket" }
The way to find what URLs my computer is requesting For example, I enter google.com as the URL in browser. It "goes to resolve" the name. Another application may try to connect to a URL without I know. I need to track what's happening in my computer. For some reason, I need this. Is there a way? I tried WireShark, but it can't concentrate on an application and it gets work hard to find what I want between so many packets. The OS is Ubuntu 20.04.
Try TCPview for Linux. I haven't used it on Ubuntu, windows version is good. Give the linux version a try. The link is here. <
stackexchange-superuser
{ "answer_score": 0, "question_score": 0, "tags": "networking, ubuntu" }
Angular Drag and drop with filter I have an `Angular` application. which contains two drag and drop lists that are working fine. I want to add a filter to search for items inside the lists. The problem is when I filter items, the function `transferArrayItem` will use the wrong index and this is why it will move the wrong item. I have added a stackblitz code to show the problem. To reproduce the problem please follow the steps: 1. over the first list click search and type number 2 2. try to move the item to the second list, it will move the item 1. <
I finally found a way to solve the issue with the cleanest code. I am using id with cdkDropList to know the source list, then I am transferring the item manually instead of using the `transferArrayItem` function provided by cdkDragDrop. the full code is in <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "angular, angular material, drag and drop" }
Find maximum of the function $f(x)=\dfrac{e^{\frac{2x}{x+1}}-1}{x}$ Let $x\ge0$. Find maximum $$f(x)=\dfrac{e^{\frac{2x}{x+1}}-1}{x}$$ I think this maximum is $2$, I hope this problem have some nice solution,Thank you
$$f=\dfrac{e^{\frac{2x}{x+1}}-1}{x}$$ $$f'=\dfrac{{\Bigg(\frac{2x}{(1+x)^2}\cdot e^\left(\frac{2x}{1+x}\right)}\Bigg)-\Big(e^\left(\frac{2x}{1+x}\right) -1\Big)}{x^2}$$ $$f'=-\dfrac{(1+x^2)\cdot e^\left(\frac{2x}{1+x}\right) -(1+x)^2}{x^2(1+x)^2}$$ $$f'=\dfrac{-(1+x^2)\bigg(e^\frac{2x}{1+x}-1\bigg)+2x}{x^2(1+x)^2}\le0 \forall x\ge0$$ So, $f$ decreases for all $x\ge0$ because $f'\le0$, see this plot of $f'$ numerator. and $$\lim_{x\to 0}f=2;\ \text{ :use L-Hospitals' Rule}$$ And at $x=-1$ function goes undefined and $f=-\infty$ And after which graph is as shown. It rises till x=0 and then again steeps down. !enter image description here
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "calculus, optimization" }
php join query for multiple tables Can anyone tell me how i can get the value for project_title, project_id, level_of_want, and selection_id. When i submit this i get No database selected error. $query_Name = "SELECT u.Student_Surname, u.Student_Forename, p2.Project_Title, p2.Project_id, s.level_of_want, s.selection_id FROM users u INNER JOIN projects p2 ON u.id = p2.Project_Lecturer INNER JOIN selection s ON p2.Project_id = s.id_project INNER JOIN users u2 ON s.student_id = u2.id WHERE u2.Username = ".$_SESSION['MM_Username']." ORDER BY selection_id ASC" ; $Name = mysql_query($query_Name, $projectsite) or die(mysql_error()); $row_Name = mysql_fetch_assoc($Name); $totalRows_Name = mysql_num_rows($Name);
after connecting to mysql server base you should explicitly select database using mysql_select_db function
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, join" }
Change newtheorem numbering order in Arabic : from Right to Left Can i change the order of numbering using LuaLaTex \setcounter{section}{3} \setcounter{subsection}{2} \newtheorem{thm}{مبرهنة}[subsection] and the result should be looks like > مبرهنة 1.2.3 thanks in advance guys
You don't provide a MWE or say what packages you are using. In case it's `babel`, you may need the option `layout=counters`: \documentclass{article} \usepackage[bidi=basic, layout=counters]{babel} \babelprovide[import, main]{arabic} \babelfont{rm}{FreeSerif} \newtheorem{thm}{مبرهنة}[subsection] \begin{document} \setcounter{section}{3} \setcounter{subsection}{2} \begin{thm} ABC. \end{thm} \begin{thm} DEF. \end{thm} \end{document} ![enter image description here](
stackexchange-tex
{ "answer_score": 0, "question_score": 1, "tags": "luatex" }
AttributeError: module 'tensorflow' has no attribute 'streaming_accuracy' accuracy = tf.streaming_accuracy (y_pred,y_true,name='acc') recall = tf.streaming_recall (y_pred,y_true,name='acc') precision = tf.streaming_precision(y_pred,y_true,name='acc') confusion = tf.confuson_matrix(Labels, y_pred,num_classes=10,dtype=tf.float32,name='conf') For the above code, I have received the same error in past few days. Isn't the syntax same as it is in the API documentation for tensorflow?
try to use this instead (in a fresh python file, I would suggest create a `/tmp/temp.py` and run that) from tensorflow.contrib.metrics import streaming_accuracy and if this doesn't work then 1. either there is an installation problem (In which case reinstall) 2. or you are importing the wrong tensorflow module.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python 3.x, machine learning, tensorflow" }
Transferring large (8 GB) files over ssh I tried it with SCP, but it says "Negative file size". >scp matlab.iso xxx@xxx:/matlab.iso matlab.iso: Negative file size Also tried using SFTP, worked fine until 2 GB of the file had transferred, then stopped: sftp> put matlab.iso Uploading matlab.iso to /home/x/matlab.iso matlab.iso -298% 2021MB -16651.-8KB/s 00:5d o_upload: offset < 0 Any idea what could be wrong? Don't SCP and SFTP support files that are larger than 2 GB? If so, then how can I transfer bigger files over SSH? The destination file system is ext4. The Linux distribution is CentOS 6.5. The filesystem currently has (accessible) large files on it (up to 100 GB).
The original problem (based on reading all comments to the OP question) was that the `scp` executable on the 64-bit system was a 32-bit application. A 32-bit application that isn't compiled with "large-file support" ends up with seek pointers that are limited to `2^32 =~ 4GB`. You may tell if `scp` is 32-bit by using the `file` command: file `which scp` On most modern systems it will be 64-bit, so no file truncation would occur: $ file `which scp` /usr/bin/scp: ELF 64-bit LSB shared object, x86-64 ... A 32-application should still be able to support "large files" but it has to be compiled from source with large-file support which this case apparently wasn't. The recommended solution is perhaps to use a full standard 64-bit distribution where apps are compiled as 64-bit by default.
stackexchange-unix
{ "answer_score": 10, "question_score": 32, "tags": "scp, sftp, large files" }
Get value from msg.payload return from a mysql query Node-RED i am starting with using Node-RED. i have no JS experience. in 1 node for the mysql DB i have to query with msg.topic. the return msg looks like this. { "topic": "SELECT sum FROM log WHERE id = 2", "payload": [ { "sum": 15 } ], "_msgid": "c93094ee.36cf68" } How do i extract the number 15 in the example out msg.payload? thanks.
in function node following the query. var sum = msg.payload[0].sum; ... the `[]` in the payload signify and array of answers so the `[0]` says take the first element from the array.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "mysql, node.js, node red" }
split pandas column into many using delimiter from right to left The following code splits a column into two for example if I have the following string `"hi.this.is.an.example"` i will get separate columns for `"hi"` and `"this"`. This splits the string going from the left to right however, I want to go from right to left instead so would want `"example"` and `"an"` df['variable'].str.split('.', 2, expand=True)
Like in pure python, use `rsplit`: df = pd.DataFrame({'variable': ["hi.this.is.an.example"]}) df['variable'].str.rsplit('.', 2, expand=True) output: 0 1 2 0 hi.this.is an example
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, pandas" }
Encountered a retryable error. Will Retry with exponential backoff 413 Logstash keep encountering following error message that logs cannot be sent to AWS ElasticSearch. > [2021-04-28T16:01:28,253][ERROR][logstash.outputs.amazonelasticsearch] Encountered a retryable error. Will Retry with exponential backoff {:code=>413, :url=>" That's why I always need to restart logstash and cannot configure why it causes that issue. Regarding Logstash documentation I reduce `pipeline.batch.size` size to 100 but it didn't help. Please let me know how to resolve that issue. Thanks. pipeline.batch.size: 125 pipeline.batch.delay: 50
I've fixed issue that we need to adjust as to choose correct ES instance size based on `max_content_length`. <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "logstash, elastic stack, logstash configuration, elk, amazon elasticsearch" }
Using 9v 2000mA power supply for pedal using low current I have Mooer 9V 2000mA power supply and pedals, such as MXR Carbon Copy requiring 26mA at 9V or EHX Pog Nano requiring 25mA at 9VDC. Is it safe to use this power supply with these pedals? Is it safe to use this power supply with these power supplies simultaneously (fx using Mooer Daisy Chain)?
If the _voltage_ rating is correct, it is perfectly safe to use a power supply with a higher _current_ rating than you need. The pedals will only take as much current as they actually use. Of course an over-rated supply may be bigger, heavier, etc, which might make it less convenient to carry around, but it will work just fine.
stackexchange-music
{ "answer_score": 12, "question_score": 5, "tags": "effects pedal, effects" }
Xcode 4.5 Uploading a iPhone 5 app only i have a app built in Xcode 4.5 with 4 inch screen/View controllers i built this app just for iPhone 5 as i sent it off to iTunes connect. once it said upload received it showed "Missing Localized Screenshots" straight away. how can i fix this i have 5 screenshots for iPhone 5 and thats it, but if i was to put screenshots for 3.5 inch screens the message goes and my app will wait for review but the one problem is when i run it on my iPod all the images/buttons are I'ver off the screen or in a different places please help. are there any ways around this if so i really would appreciate it if you could let me known. or do you have to develop a applications for both devices iPhone 5 and iPhone 4 now? hope this all make sense and you guys understand what i mean thank you!
It isn't about the device, but the version of the OS. You can't target an app just at the iPhone 5. You can can target an app at iOS version 6 which includes 4 inch and 3.5 inch screens. **Edited to add** There are many resources about supporting multiple screen sizes in iOS6, one of which is, for example: How to develop or migrate apps for iPhone 5 screen resolution?
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios6, screenshot, app store connect, xcode4.5, iphone 5" }
how do i extract the part between the brackets in javascript regular expressions: answer_postal_address[address] how do i extract the part between the brackets in javascript regular expressions: answer_postal_address[address] I tried this: /^\w*/g which works but i wasn't sure if this was correct...
Matches `input` of value of any _word character_ followed by anything inside of bracket, i.e. answer_postal_address[address] var re = new RegExp("\w+\[([^\]]+)\]"); var m = re.exec(input); if (m == null) { alert("No match"); } else { alert("Matched: " + m[1]); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, regex" }
Problema al añadir columna a una tabla MySQL con PDO (Se añaden comillas en el nombre) Estoy tratando de **añadir nuevas columnas a una tabla de base de datos** , pero tengo un problema y es que al añadir la columna, se añaden con 'comillas simples' en el nombre. **Así:** | id | es | 'en' | La nueva columna sería `'en'`, y se crea tal cual se muestra _(con las comillas)_. **Código:** $stmt = $conn->prepare("ALTER TABLE `languages` ADD `:lang` LONGTEXT NULL DEFAULT NULL"); $stmt->bindParam(":lang", strtolower($_POST["lang"])); $stmt->execute(); **Valor de las variables (con var_dump()):** $_POST["lang"] // string(2) "EN" strtolower($_POST['lang']) // string(2) "en"
Pudieras dejarlo de este modo Asigna a una variable lo que te llega por `POST` $lenguaje = $_POST["lang"]; Posterior pasas de manera directa dicha variable a tu sentencia `ALTER` así dentro de las _backticks_ $stmt = $conn->prepare("ALTER TABLE `languages` ADD `$lenguaje` LONGTEXT NULL DEFAULT NULL"); Posterior remueves el uso de `bindParam()` y solo invocas al método `execute()` de este modo $stmt->execute();
stackexchange-es_stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, mysql, pdo" }
3DS Max: Multiple subtraction (boolean) - how to do it? I have a board full of inputs, and need holes in the box behind them. !enter image description here **How can I do these all at once instead of multiple boolean operations?**
It looks like the holes you need are evenly spaced. You could make one cylinder, create an array, group the cylinders together, then do the bolean operation with the group of cylinders and the board.
stackexchange-graphicdesign
{ "answer_score": 2, "question_score": 1, "tags": "3d, 3ds max" }
Inheritance and multiple files in C++ I have multiple classes that inherit from one base class, and each class is in a separate header. I want the user to be able to include just the base class header, but that would require me to include the other derived classes in the base header, which would lead to some sort of circular dependency, and I've read somewhere that circular dependency is a bad thing. My class is a socket class, and the derived classes are socket_udp, socket_tcp, socket_raw, and so on. How do I solve the circular dependency? Maybe the class design is bad, and I don't need different classes for different socket types? I'm a bit confused here. Thanks!
One option would be to create a new header file that includes all of the header files for the derived and base objects. Just including that single header would therefore include all the other header files. If you order the includes in this file so that you never include a class without first including all its parent classes, you can avoid circular dependencies.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "c++, class, inheritance, header files" }
Alternative to return Option<Box<[Box<[JsValue]>]>> from Rust fn to Wasm I am trying to return `std::boxed::Box<[std::boxed::Box<[wasm_bindgen::JsValue]>]>` in my Rust code to Wasm but getting this error. I understand the trait is not implemented, but is there a workaround to it? ## Raw Error #[wasm_bindgen] | ^^^^^^^^^^^^^^^ the trait `wasm_bindgen::convert::traits::OptionIntoWasmAbi` is not implemented for `std::boxed::Box<[std::boxed::Box<[wasm_bindgen::JsValue]>]>`
For those who are looking for an answer, I managed to return `Option<js_sys::Array>` to solve this. I know it is not exactly the same what I was looking for but it works for me.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "rust, webassembly, wasm bindgen" }
getting the offset of a record in mysql query I have some query on a table which can be sorted by any of several columns, and an id of a row in the resultset. How can I get the next or previous records (or the offset of the id in the complete resultset). ie. let's say I have the following table ID First_Col Second_Col Name 1 34 24 John 2 40 22 James 3 48 5 Hugh If sorting by first_col, and given id 2, the next record would be 3, but if sorting by Second_Col, the next record would be 1. Given the sortBy expression (which is passed to my function), and the id, how can I find the next record easily?
This should work: SELECT * FROM names WHERE Second_Col > (SELECT Second_Col FROM names WHERE ID = 2) ORDER BY Second_Col LIMIT 1 See
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "mysql" }
Read bytes of a USB mass storage device I have a USB mass storage device that I encrypt with **TrueCrypt**. When I connect it to Windows, it asks to format. Using TrueCrypt reveals its contents, as expected. !enter image description here How can I read the first 100 bytes of that device? I know the bytes will not make sense because they're encrypted but I want to read them in order to create a checksum.
Did this on the top of my head. But is should work. public static long getBytes(string letter) { ManagementObject disk = new ManagementObject(String.Format("win32_logicaldisk.deviceid=\"{0}:\"", letter)); disk.Get(); return long.Parse(disk["Size"].ToString()); } EDIT: Tested it and changed int to long. It works.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "c#, encryption, truecrypt" }
Как присвоить коллекции новое значение через Stream Api? У меня есть коллекция и значение, по которому я хочу ее отфильтровать, выглядит это так: StudyGroupPriorityQueue = StudyGroupPriorityQueue .stream() .filter(student -> student.getFormOfEducation() .equals(Enum.FormOfEducation.FULL_TIME_EDUCATION)) .collect(Collectors.toCollection(Queue<StudyGroup>)); IDE подчеркивает `collectionFactory`, а именно `Queue<StudyGroup>`, в чем моя ошибка?
`Queue<StudyGroup>` просто тип, а `Collectors.toCollection` принимает объект-фабрику, например, ссылку на конструктор. Судя по названию переменной вам нужна `PriorityQueue` Collectors.toCollection(PriorityQueue::new) Если объекты в StudyGroupPriorityQueue не реализуют интерфейс Comparable, то: Collectors.toCollection(() -> new PriorityQueue<>(/*Comparator или его реализация*/comparator))
stackexchange-ru_stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "java, java stream" }
What does $_POST actually return? Just a quick question. I am doing a small project with php and have now come at a point where I need to know what does the method $_POST in php actually return? Is it an array or some key/value pairs or what exactly? I am unable to the find exact information about the same. Please help me in understanding this stuff. Thanks in advance!
var_dump($_POST); Yes, it is an array. Try the Official documentation
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -2, "tags": "php, http, post" }
How to change axis labels in plotly 3d plots? X = np.random.randn(100, 90) import plotly.graph_objects as go fig = go.Figure(data=[go.Surface(z=X)]) fig.update_layout(title='something', autosize=False, width=500, height=500, margin=dict(l=65, r=50, b=65, t=90)) fig.show() Have tried various thing but the axis labels do not change. They just say "x" and "y".
You can change the axis labels inside the `scene` property. import numpy as np import plotly.graph_objects as go X = np.random.randn(100, 90) import plotly.graph_objects as go fig = go.Figure(data=[go.Surface(z=X)]) fig.update_layout( title='something', autosize=False, width=500, height=500, margin=dict(l=65, r=50, b=65, t=90), scene=dict( xaxis_title='X Axis Title', yaxis_title='Y Axis Title', zaxis_title='Z Axis Title', ), ) fig.show() ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 4, "tags": "plotly" }
How do you monitor the health of a mirrored disk in Windows? I have a Mirrored Dynamic disk on my Windows 2003 Server. How do you monitor the health of the volume? Is there a way to have the server send an email when there is an issue with the volume? Is there a way to have the server run S.M.A.R.T. tests? **EDIT:** Nothing says WTF like logging into a client server, running DISKPART LIST VOLUME and seeing this. Volume ### Ltr Label Fs Type Size Status Info ---------- --- ----------- ----- ---------- ------- --------- -------- Volume 0 X xDrive NTFS Mirror 233 GB Failed Rd Volume 1 C NTFS Simple 57 GB Healthy System Volume 2 D DVD-ROM 0 B Healthy Volume 3 F RAW Partition 466 GB Healthy Volume 4 E New Volume NTFS Partition 932 GB Healthy
I had the same question a while ago. The first thing I thought of was using WMI, but for some weird reason, WMI doesn't expose the health of a RAID volume through any of the normal Win32_* classes. I eventually stumbled across the script in this article and made a few modifications to suit my requirements. It parses the output of diskpart.exe's "LIST VOLUME" command. This may seem a little dirty and ugly, but right now its the best option I've seen. The script as it appears on the linked page is ready to be used with Nagios / NSClient++. If you know a bit of VBScript it's easy enough to modify this to send e-mail instead of printing status information. If you don't know VBScript, I'll gladly give you a modified version which will do whatever you want it to.
stackexchange-serverfault
{ "answer_score": 5, "question_score": 16, "tags": "windows server 2003, raid, monitoring, software raid, dynamic disk" }
Get record between two dates using mysql I want to get the data between a date. Am having some record with from and to date. Now i want to check that record using a date. Employee Leave_from_date Leave_to_date Leave_Type 001 06-10-2012 07-10-2012 Casual I want use the select statement like this Select * from leave_request where fldempid=001 as L on fldfromdate >= 06-10-2012 and fldtodate<='06-10-2012' if am using 07-10-2012 means the above record displayed again. Please help me to create this...
Reverse the usual position of values and columns in a `between` clause: select * from leave_request where fldempid = 001 and '06-10-2012' between fldfromdate and fldtodate
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -1, "tags": "mysql" }
Fastest way to output very large data to stdout in Java I want to print a lot of data to Stdout in the fastest possible way. One way is that I use a StringBuilder and keep appending the output to it and then print the stringbuffer. But sometimes this fails when the data to be printed is more than the maximum allowable size and gives Memory Limited Exceeded error. (for example in online judges). Is there some other better and faster way to print data?
You may try this: try { BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out)); //..... log.flush(); } Although writing to a file directly will be more efficient
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 4, "tags": "java" }
Does a discrete GPU help for non 3D tasks I'm looking for a new laptop and considering if I should get one with a discrete GPU, like the Dell XPS 15 or the Surface Book. I don't do much 3D stuff, but would love the fastest laptop possible for normal Windows tasks. So, does a discrete GPU speed up general Windows tasks like browsing, etc? I know that for example Chrome has hardware acceleration. So one would assume it does help? Or is this negligible for movies and browsing?
> So one would assume it does help? Most of the time: No, you will not notice much speedup. But... If you have a CPU with the GPU on the same die then disabling that GPU will mean less heat produced on that die. That means more thermal headroom for the CPU. So I expect a minor speed gain when the CPU is heavily used. If it is mostly idle it should have plenty headroom for an accosional turbo, in which case the boost should be minimal. Hence the "when the CPU is heavily used". And at that point you might be better off considering a desktop. > Or is this negligible for movies and browsing? I expect it to be measureable with benchmarks, but mostly negligible.
stackexchange-superuser
{ "answer_score": 2, "question_score": 1, "tags": "laptop, windows 10, graphics card, gpu" }
Relation between Electric Potential and Electric Field Intensity Suppose we have been given a curve y = V(x) where V(x) represents the Electric Potential at x. Now if for a range the curve is a horizontal straight line, can we say that the Electric field intensity in that range will be equal to 0 because $dV = \vec{E}\cdot \vec{dr}$
The equation you're looking for is: $$\vec{E}=-\vec{\nabla}V$$ If $V$ depends on $x$ only, the gradient becomes: $$\vec{E}=-V'(x)\vec{e}_x$$ so $\vec{E}$ is indeed zero in that interval.
stackexchange-physics
{ "answer_score": 0, "question_score": 0, "tags": "electromagnetism, electrostatics, potential" }
Multiple choice probability of passing > A student is given a test consisting of $30$ multiple-choice questions. For each question there are $5$ possible answers of which one is correct. To pass, the student must answer at least $25$ questions correctly. On the first $20$ he knows the answers and for the remaining questions he chooses an answer haphazardly and independently. Calculate the probability that he will pass the test. I solved this problem a few months ago but I forgot how I did it. Does anyone have a better suggestion than what I did? $$\sum _{i=0}^5\frac{10!}{\left(5-i\right)!\left(10-\left(5-i\right)\right)!}\left(\frac{1}{5}\right)^{5+i}\left(\frac{4}{5}\right)^{5-i}=0.03279$$
**HINT:** Use the Binomial Distribution. There are $10$ remaining question and the student needs at least $5$ to be guessed correctly. Each question has a fixed probability of success $0.2$. Therefore, we need to find $\mathbb{P}(X \ge 5)$ where $X$~Binomial$(10,0.2)$. This is the same as $1- \mathbb{P}(X < 5)$. To find this probability, you can use the Cumulative Distribution Function for the Binomial Distribution to complete the problem (or you can calculate the sum of the Probability Mass Function over the values $0$ to $4$ (since the inequality is up to, but not including, the number value $X=5$) .
stackexchange-math
{ "answer_score": 3, "question_score": 2, "tags": "probability, combinatorics, permutations, combinations, binomial distribution" }
Rotation of cube around x axis using clockwise I have drawn cube using c++. I need to rotate around the axis in clockwise rotation.I found the method for rotation only for anti clockwise in the net.I need to calculate new points for the cube after rotation.is there any formula to calculate the new point?
If you know the formula to rotate anti-clockwise then it should be pretty simple to rotate clockwise. If anticlock rotation is positive, then you just need to put negative theta in the equations to rotate clockwise. For example, if anticlockwise rotation equation is: x1 = x cos t - y sin t y1 = x sin t + y cos t Then clockwise rotation formula will be: x1 = x cos (-t) - y sin (-t) y1 = x sin (-t) + y cos (-t) Using `cos (-t) = cos t` and `sin (-t) = -sin t` x1 = x cos t + y sin t y1 = -x sin t + y cos t
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "algorithm, geometry" }
Responsive Design / What is an appropriate web component to choose a distance regarding user's geolocation? I own a responsive web application. I want to let user filter results (supposing a page listing some data) based on his geolocation and a chosen limit. For instance, **Bob wants to see all meetings that are within 10km only**. What would be an appropriate component, especially on mobile device? I found this (the first item), but it could be touchy to represent a large slider on narrow mobile device, and not easy to be accurate for people having large fingers. What do you think?
You can use a numeric stepper. The user may enter the value with the keyboard, or use the up/down arrows. The default value should be empty (no distance filter). EDIT : See comment by @FodderZone !mockup download bmml source - Wireframes created with Balsamiq Mockups
stackexchange-ux
{ "answer_score": 0, "question_score": 0, "tags": "usability, mobile, web app, responsive design, user expectation" }
Avoid escaping characters when converting from tabular data to json I have some problems converting tabular data to JSON using the FOR JSON PATH syntax: If i do a standard query: SELECT b.Name FROM dbo I get results of the form: 12/5-A-1. I need this converted to JSON data without escaping the backslash character. However, when i convert it to JSON: SELECT b.Name FROM dbo FOR JSON PATH, WITHOUT ARRAY_WRAPPER the result is of the form: `{"Name": "12\/5-A-1"}` How can i do this transformation without escaping the backslash character and get the result `{"Name": "12/5-A-1"}`?
One option is to use a common table expression to generate the json, and then simply use `replace` when selecting from the common table expression. First, create and populate sample data ( **Please** save us this step in your future questions): DECLARE @T AS TABLE ( [Name] nvarchar(10) ) INSERT INTO @T ([Name]) VALUES ('12/5-A-1'); The cte: WITH CTE(Escaped) AS ( SELECT [Name] FROM @T FOR JSON PATH, WITHOUT_ARRAY_WRAPPER ) The final select: SELECT REPLACE(Escaped, '\/','/') As Result FROM CTE Result: {"Name":"12/5-A-1"}
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "json, tsql" }
SQL How to Limit BOTTOM x rows (PostgreSQL) I have a query like: SELECT EXTRACT(WEEK FROM j.updated_at) as "week", count(j.id) FROM jobs WHERE EXTRACT(YEAR FROM j.updated_at)=2009 GROUP BY EXTRACT(WEEK FROM j.updated_at) ORDER BY week Which works fine, but I only want to show the last say 12 weeks, LIMIT 12 works, but only gives me the first twelve and I need the order to be in sequential week order (ie. not reversed) for charting purposes... Is there a equivalent statement in Postgresql such as Show BOTTOM x items?
SELECT * FROM ( SELECT EXTRACT(WEEK FROM j.updated_at) as "week", count(j.id) FROM jobs WHERE EXTRACT(YEAR FROM j.updated_at)=2009 GROUP BY EXTRACT(WEEK FROM j.updated_at) ORDER BY week DESC LIMIT 12 ) q ORDER BY week ASC Note that if you have an index on `updated_at`, you may rewrite this query a little so that it's more efficient: SELECT week, ( SELECT COUNT(j.id) FROM jobs WHERE updated_at >= start_week AND updated_at < end_week ) FROM ( SELECT week, '04.01.2009'::DATE - EXTRACT(DOW FROM '04.01.2009'::DATE)::INTEGER + week * 7 '04.01.2009'::DATE - EXTRACT(DOW FROM '04.01.2009'::DATE)::INTEGER + week * 7 + 7 FROM generate_series(42, 53) week ) q
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 3, "tags": "sql, postgresql" }
Construction of Kummer map for abelian variety Let $A$ be an abelian variety over the rational numbers $\mathbf{Q}$. Let $V=T_p A \otimes \mathbf{Q}_p$ be the $\mathbf{Q}_p$-Tate module of $A$. Let $G$ be the absolute Galois group of $\mathbf{Q}$. (added in edit) I keep seeing a natural map $A\to H^1(G,V)$. How is this map constructed? What does it have to do with "Kummer theory"? What is the image of this map? That is, how can one describe it? Does it have to do with Selmer groups? Sorry for the vagueness.
Does Silverman, The Arithmetic of Elliptic Curves, X.1 or Cornell-Silverman-Stevens, p. 33 help? Form the long exact sequence of $0 \to A[\ell^n] \to A \to A \to 0$ (analogue of the Kummer sequence if you replace $A$ by $\mathbf{G}_m$) and take the inverse limit. Relation to the Selmer group: $\mathrm{Sel}(A/K)_m \subseteq H^1(K,A[m])$ and I suspect $\mathrm{Sel}(A/K)_m = H^1(\mathrm{Spec}\,\mathcal{O}_K,\mathcal{A}[m])$ (disregarding the archimedean places).
stackexchange-mathoverflow_net_7z
{ "answer_score": 4, "question_score": 3, "tags": "ag.algebraic geometry, arithmetic geometry, nt.number theory, abelian varieties" }
How can I disable a stock app that has its Disable button greyed out? There is a pesky bloatware app (specificlly VUDU Version 1.0) that came preinstalled on my device. Whenever I boot my device, it starts up an app process, so every time I boot I have to open up the App Switcher and swipe it away. I went into the Settings app and tried to Force Stop and then Disable the app, but the Disable button is disabled ("greyed-out") itself. Some other apps also don't allow me to disable them. Is there any other way that I can enable the button or disable the app without rooting? I am running 4.4.2.
Sorry, but you have to root in order to do this. There is no other way. 1. Root 2. (optional) Install Titanium Backup and backup your phone. If you mess something up you can restore your phone using this 3. Now use an app called System App Remover to select the app you want to delete. You will have to grant superuser permission for it to work
stackexchange-android
{ "answer_score": 4, "question_score": 10, "tags": "4.4 kitkat, bloatware, disable app" }
Scale factor of a 3d robot model relative to the real measurements of a robot I have some measurements of a real life robot, and a 3d model of that robot (lets say in Unity) and I want to know the scale factor, plus I dont want to find the 3d models measurements and then divide with the real world ones to find the scale factor, in order not to get more confused with more mathematics than I am already. So, is there a methodology or will I have to do it as I mentioned?
You will have to do it as mentioned. However, if the 3D model is accurate, there is only one number you have to find. Choose any dimension you can measure on both the real robot and the 3D model. $Scale=\frac{RealDimension}{3Ddimension}$ Every matching real and 3D dimension will give you the same number for scale. So once you calculate scale once, you can apply it everywhere. If you know the Real dimension and want to calculate the 3D dimensions: $3Ddimension=\frac{RealDimension}{Scale}$ If you know the 3D dimension and want to know the real one: $RealDimension=Scale\times 3Ddimension$ This works for all dimensions. Note that angles don't change with scale. If something is 90 degrees at one scale, it will be 90 degrees at all other scales. If you are measuring a mesh, then extremes are easier to measure than axis centers. For instance, in the following drawing, the 840mm dimension is probably the easiest to measure in your 3D model. ![enter image description here](
stackexchange-robotics
{ "answer_score": 1, "question_score": 1, "tags": "3d model" }
How to access function in another JS file I added another JS file to my project : `test.js` and I have the code in `test.js`: var testObj = { hello : function(){ alert("hello world"); } } and I added this line to the main HTML file in my project: the script is under the same folder as HTML file. In the Java code, I call this function by: public static native void helloWorld()/*-{ testObj.hello(); }-*/; But when I run it, it tells me `testObj is undefined`. But in the browser console, when I do: `testObj.hello()` and it is working (so the JS file is loaded). How can I make it work?
Solved by myself. change the call to: public static native void helloWorld()/*-{ $wnd.testObj.hello(); }-*/; `$wnd` must be `$wnd`, `window`, `document`, `this` or `$doc` will not work.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "gwt" }
Jquery UI Download : which files to include? I understand that color animations are not natively supported by Jquery. So i have downloaded the Jquery UI zip. Which files inside the zip should i add below the jquery script to support color animations? Thanks in advance!
To get jQuery UI up and running, you should add `jquery-ui.min.js` under the jQuery script, and `jquery-ui.min.css` to your document's head. The ".min" means that the JavaScript and CSS is minified so it's more space-efficient for production use. If you want to be able to debug the jQuery UI code, use the non-minified versions. More details: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery ui" }
Batch program to Delete everything in txt after fifth slash I have multiple txt files with multiple links in it which have to be trimmed after five slashes. The batch file should delete everything in the line in the .txt file after the fifth slash, how could I do this? Example of a .txt file: Before: ` Afterwards: ` Thanks in advance! ^^
Given a file `sample.txt` in current diretory: This batch :: Q:\Test\2018\10\31\SO_53088499.cmd @Echo off For %%F in (*.txt) Do ( For /f "delims=?" %%A in (%%F) Do Echo:%%A ) will output: > SO_53088499.cmd This could easily be redirected to a new file.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "windows, cmd" }
Can the referee give a red card for an incident that happens after the end of a match? In football, if team A wins and a player from team A mocks team B for losing (call them a idiot team, non-fair-play attitude, etc.) can the referee give a red card to that player after the match ends?
Yes, definitely. Referees can take action as long as they are still on the pitch after the game has ended. This is covered in Law 5: The Referee > [The referee] has the authority to take disciplinary action from entering the field of play for the pre-match inspection **until leaving the field of play after the match ends** (including kicks from the penalty mark). If, before entering the field of play at the start of the match, a player commits a sending-off offence, the referee has the authority to prevent the player taking part in the match (see Law 3.6); the referee will report any other misconduct.
stackexchange-sports
{ "answer_score": 5, "question_score": 4, "tags": "rules, football, officiating, suspension" }
Mysql alter/write lock database I runned this in mysql: UPDATE db SET Insert_priv='Y', Create_priv='Y' WHERE Db='wordpress_fixed'; But this not preventing from inserting more data to database wordpress_fixed. Is it supposed to work that way?
If you manually update any mysql.X table regarding privileges will require a FLUSH PRIVILEGES to effect the change. Using GRANT is the better way of of ensuring privs exists (and doesn't require `FLUSH PRIVILEGES`).
stackexchange-dba
{ "answer_score": 1, "question_score": 0, "tags": "mysql 5.6" }
JSTL 2d Array Iteration I have a 2d array stored in a java bean and I'm trying to iterate through its contents to print a corresponding table on a JSP page. The array is a bean data member which I'm accessing through the EL code ${board.cells}. I tried to do this with a c:forEach tag, but it's only printing a single cell. I know the array contents are valid, as I can see them when I index them directly by ${board.cells[0][0]} Here's my loop code, embedded in the JSP. <c:forEach items="${board.cells}" var="row"> <tr> <c:forEach items="${row}" var="cell"> <td><img src=${cell} align="" alt="cell"></td> </c:forEach> </tr> </c:forEach> Any help is much appreciated!
As per the comments, JSTL core tags are simply not been interpreted/parsed. They are been sent plain to the HTML response. You need to declare the JSTL core taglib in top of your JSP to get them to run. <%@ taglib prefix="c" uri=" %> ### See also: * Our JSTL wiki page
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "java, jsp, jstl" }
return a list of running applications (not processes) in the command line, OSX I have a computer that I want to run in a kiosk-ish mode. The behavior that I want is to close applications that others might open. Here is the pseudocode #!/bin/sh # Get list of Open applications # Close anything not on a specified application white list Here's the hitch, I don't fully understand, nor do I want to wade through all the garbage that comes back when you run a query for processes such as "ps -aux" I really just want to get a list of the open applications that one would see when using cmd+tab and then process _that_ list. Any ideas?
Wouldn't it be easier to not let the users open those applications in the first place? In that case have a look at "parental control". Here's a link for Mavericks.
stackexchange-superuser
{ "answer_score": 2, "question_score": 0, "tags": "macos, command line, bash" }
Flavor of Linux which is ONLY command line (and super light-weight)? I'm looking to install an extremely light-weight flavour of linux on a USB stick. It also needs to be basically only CLI. Has anyone ever looked for something like this? Ever found something good?
To be particularly minimal, you could roll your own. Fair warning: this is an endeavor of many hours, but you'll better appreciate what goes into getting your OS pieced together. Linux From Scratch is a very actively maintained step-by-step guide on just that: <
stackexchange-superuser
{ "answer_score": 19, "question_score": 20, "tags": "linux, command line, usb" }
Reasoning about floor functions and exponents Let $a,t$ be integers such that: * $t > a \ge 0$ * $t > 1$ It seems to me that there exists integers $r,w$ such that: $a = \left\lfloor\dfrac{t^w}{r}\right\rfloor$ I'm having trouble coming up with the argument. Consider $a=4, t = 10$. There is no $r$ for $w = 1$. For $w = 2$, $$4 = \left\lfloor\dfrac{10^2}{25}\right\rfloor$$ Am I right in my assumption about the general case? If so, how can this be shown?
This is quite trivial. Make $w$ large enough so that: $$\frac{t^w}{a}-\frac{t^w}{a+1}>2$$ Then, there exists some integer $r$ in between $\frac{t^w}{a}$ and $\frac{t^w}{a+1}$. We then have: $$\frac{t^w}{a}>r>\frac{t^w}{a+1} \implies a<\frac{t^w}{r}<a+1$$ Which gives us: $$\bigg\lfloor \frac{t^w}{r} \bigg\rfloor=a$$ Solved!
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "elementary number theory, exponentiation, ceiling and floor functions" }
Rewrite nested ternary operators in functional way I have the following piece of code: String firstString = "sth"; String secondString = "sthElse"; String stringsSpecialConcat = String.format("%s<br>%s", firstString, secondString); boolean isFirstStringNotBlank = StringUtils.isNotBlank(firstString); boolean isSecondStringNotBlank = StringUtils.isNotBlank(secondString); return isFirstStringNotBlank ? (isSecondStringNotBlank ? stringsSpecialConcat : firstString) : (isSecondStringNotBlank ? secondString : "") Could you please help me simplify the above by means of the functional programming? I would like to use something similar to Stream.of(firstString, secondString).collect(joining(""))
Stream.of(firstString, secondString) .filter(StringUtils::isNotBlank) .collect(Collectors.joining("<br>")) `Collectors.joining` will only insert a delimiter if there are 2 or more elements. In your case, that's when both are non-empty. If both are empty, the result is `""` If first is empty, the result is `"second"` If second is empty, the result is `"first"` If both are non-empty, the result is `"first<br>second"`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, functional programming, java stream" }
BootstrapValidator validations with dynamically added forms (not fields!) I'm working on a page where a user can edit/delete or add addresses. For the form validation I use BootstrapValidatior and the form is saved via ajax call and if the data is saved another form is added to the DOM. Everything is working except if I'm working with newly added forms to the DOM (for example if I added an address and after that I want to edit the form doesn't validates). I know this thing is called event delegation and I know the right way to handle this situations is firing event like: $(document).on('click', '.deleteAddress', function () {}); But I don't know how to do this with BootstrapValidator.
You add the Bootstrap validation logic in the callback of the ajax call that adds the address form to the DOM. E.g. $(function() { $("#addFormButton").click(function() { $.getJSON("/dynamicform", function (data) { // Append form to the DOM $("#formDiv").append(data.dynamicForm); // Call Bootstrap Validator $("#formDiv form").bootstrapValidator(); }); }); }); Plnkr example here
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, jquery, html, ajax" }
Issus with building the java project using maven2 I am using maven2 to build the java project, when i issue the command `mvn clean install` i am getting the error `could not parse error message: (use -source 5 or higher to enable generics)`. In my eclipse environment i am using jdk 1.7 and the project is working fine. when i want to build the project i am unable to do that, think maven is taking java version 1.3 as default. Any one please help me how to set the jdk versio to 1.7 in maven, to build the project successfully.. Apart from the jars mentioned in pom.xml i want to add add my own jar, how can i specify that in pom xml? Thanks in advance..
In your pom.xml configure the maven-compiler-plugin to use 1.6: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build>
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "java, eclipse, maven" }
Counting Fields in Relation to their Column I am trying to find the correct SQL to perform my task. I am trying to find the count of all actors that all act in the same movie. For all the movies. My SQL statement to fetch the film title and the first and last name of each actor is. SELECT title, actor.first_name, actor.last_name, FROM film INNER JOIN film_actor ON film.film_id = film_actor.film_id INNER JOIN actor ON film_actor.actor_id = actor.actor_id ORDER BY film.title My database returns this : ![Return of SQL Query]( As you can see there are 10 actors belonging to the movie title ACADEMY DINOSAUR. What is the SQL that would provide me with a number of actors for each film?
Your SQL can be like this SELECT title, count(1) COUNT FROM film INNER JOIN film_actor ON film.film_id = film_actor.film_id INNER JOIN actor ON film_actor.actor_id = actor.actor_id GROUP BY title
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mysql, sql" }
Trim file extension UITableView I want to trim the file extension from text I have an `NSMutableArray` in table cells. NSMutableArray *theFiles = [NSMutableArray new]; NSFileManager *manager = [NSFileManager defaultManager]; NSArray *fileList = [manager directoryContentsAtPath:@"/Test"]; for (NSString *s in fileList){ [theFiles addObject:fileList]; } cell.textLabel.text = theFiles[indexPath.row]; return cell; This lists for example **"Xylophone.m4r"** I want to remove the **.m4r**.
Try `-[NSString stringByDeletingPathExtension]` (in NSPathUtilities.h).
stackexchange-stackoverflow
{ "answer_score": 38, "question_score": 9, "tags": "nsstring, nsmutablearray, trim" }
When using DTLS with UDP sockets on OpenSSL, how do you properly handle the connection and SSL session? With TCP it is pretty easy because is connection-based and once a connection is established you can set up the SSL object associated with that connection once and stream data...UDP however is connection-less, so does this mean I have to set up a new SSL object for each UDP packet I get from a client? Is there a way I could use the same SSL object for subsequent reads from the socket as long as I'm talking to the same client?
Even with UDP you can still "bind" and "connect" a socket. If you are using OpenSSL then use DTLSv1_listen() to await a connection from a new client. When one arrives, create a new socket which is connected to the client's address/port and use a new SSL object for that socket. All subsequent DTLS packets to/from that client can use the same SSL object.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sockets, ssl, openssl, network programming, udp" }
How to separate dictionary in data frame each in one column and only keep the value without the key I have a data frame contains columns of dictionaries has few items inside it, i wanat seperate each value in one column and keep only the value. right now like this dic --- {'_id': '1', 'value': 'apple'} {'_id': '2', 'value': 'car'} I want them to be like this first value | second value ---|--- 1 | apple 2 | car
Just apply `pandas.Series` on that column: >>> df = df['dic'].apply(pd.Series) >>> df _id value 0 1 apple 1 2 car Then change the column names if needed: >>> df.columns = ['first value', 'second value'] >>> df first value second value 0 1 apple 1 2 car Or, you can just pass the same index with a `lambda` function: >>> df['dic'].apply(lambda x:pd.Series(x.values(), ['first value', 'second value'])) first value second value 0 1 apple 1 2 car
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, dictionary" }
Relation between minimal polynomial and divisibility Let $A$ be a $n \times n$ matrix with rational elements and $p$ a prime number such that $A^p = I$ with $p<n$. If $\det(A-I)\neq0$ it is true that $p-1$ divides $n$? Here is what I've worked so far. $$A^p = I,$$ so $$(A-I)(A^{p-1}+A^{p-2}+\cdots+A+I) = 0.$$ Since $A-I$ is invertible we can multiply by its inverse and get that $$A^{p-1}+A^{p-2}+\cdots+A+I = 0.$$ We know that the minimal polynomial of $A$ divides this polynomial of degree $p-1$. I do not understand why this implies that $p-1$ divides $n$.
The minimal polynomial divides $x^{p-1}+x^{p-2}+\dots+x+1$. However this polynomial is irreducible over $\mathbf Q$ (it is the $p$-th cyclotomic polynomial), hence it _is_ the minimal polynomial. Now the characteristic polynomial has the same irreducible factors as the minimal polynomial, which implies it is a power of the minimal polynomial if the latter is irreducible, so that its degree $n$ is a multiple of the degree $p-1$ of the minimal polynomial.
stackexchange-math
{ "answer_score": 5, "question_score": 4, "tags": "matrices, eigenvalues eigenvectors, minimal polynomials" }
Downgrade embedded tomcat version in maven My Springboot application was build in tomcat 9.0 with java version of 1.8 and our server has tomcat 6 with java version of 1.7. I have already downgrade our java version in facet. How can i downgrade the embedded tomcat in maven? Do I need to generate a new initialize from springIO?
From the SpringBoot docs: > Spring Boot 2.1.1.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.3.RELEASE or above is also required. < So if you must stay on 1.7 and Tomcat 6, you'll need to move away from SpringBoot and back to your older solutions.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, maven, spring boot, tomcat" }
Concurrent ServerSocket connections Refer this post in Andrey Kozhanov' code. In Server.java, line 14, method run(): When I send a file "A" and during file transfer start another Client and send other file "B", this last transfer ("B") will block until "A" finishes. How can I implement a concurrent server receiver? Thanks.
You can create new Thread for every new client. public class Server extends Thread { ... @Override public void run() { try { ServerSocket serverSocket = new ServerSocket(PORT); while (true) { Socket s = serverSocket.accept(); (new FileSaver(s)).start(); } } catch (Exception e) { e.printStackTrace(); } } ... } public class FileSaver extends Thread { Socket socket; public FileSaver(Socket socket) { socket = socket; } public saveFile() { // save the file here }; public void run() { saveFile(); } }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -3, "tags": "java, file transfer, serversocket" }
Moving servers and IPs will change. Do SSL certificates need to be re-issued and installed? We are moving servers to another facility with different block of IP addresses. Will we need to get new SSL certificates issued and installed once the move has taken place? If so, is there any way to get prepared for this before the server is moved instead of waiting for it to boot up to then go through the process of requesting from IIS, going to certificate vendor, etc?
Most (I think ALL) SSL certificates are domain-name-based, so there should be no need to get a new certificate as long as the hostname of the server will be the same after the move. It will require a DNS change, timed with the move, however.
stackexchange-serverfault
{ "answer_score": 39, "question_score": 34, "tags": "ssl certificate" }
Permission Denied on httplib2 install I'm trying to install the httplib2 library for Python so I can use it to interact with the Twitter but I get the following error in the console when I try to install via 'python setup.py install'. This is a new MBA and I am the only user (and Admin) so I shouldn't get denied so rudely! error: could not create '/Library/Python/2.7/site-packages/httplib2': Permission denied Thoughts?
Use `sudo` to run `setup.py` as root: % sudo python setup.py install
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 3, "tags": "python, terminal, httplib2" }
Favicon causes mixed content warning over SSL I have the following favicon loading via header.php: <link rel="shortcut icon" type="image/x-icon" href="<?php echo esc_url( home_url( '/wp-content/themes/themename/img/favicon.ico' ) ); ?>"> My site has an SSL certificate installed. Google Chrome loads the each page over SSL perfectly, but Firefox flags a mixed content warning. I can see via the source (both in Chrome and Firefox), that the favicon is being served via http. I can't work out why this is happening.
After a little more reading via the WordPress Codex, I discovered that I was calling the favicon incorrectly. It should be called like this: <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico" /> Using `get_stylesheet_directory_uri()` checks for SSL.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 4, "tags": "ssl" }
Индекс за пределами диапазона.Формула числа перестановок с повторениями private void button6_Click(object sender, EventArgs e) { int temp, n, k; n = int.Parse(textBox1.Text); k = int.Parse(textBox2.Text); int sum = 0; for (int i = 0; i < dataGridView1.RowCount; i++) { sum += Convert.ToInt32(dataGridView1[k, i].Value); } temp = sum; listBox1.Items.Add(Fact(temp)/ 2); } ![введите сюда описание изображения]( Как реализовать формулу числа перестановок с повторениями. Я пытался посчитать сумму с 1 го столбца, но ошибка ![введите сюда описание изображения](
`ArgumentOutOfRangeException` \- название исключения говорит само за себя. Ваш аргумент (индекс `i`) выходит за допустимые пределы диапазона таблицы. У вас в скриншоте условие выхода из цикла `i < dataGridView1.RowCount + 1;`. На последней итерации цикла у вас `i = dataGridView1.RowCount`, а индексация в массиве в c# начинается с `0`. поэтому последний элемент массива строк будет иметь индекс `i = dataGridView1.RowCount - 1`. Поэтому условие выхода из цикла должно быть такое же, как у вас указано в коде вопроса, а именно: for (int i = 0; i < dataGridView1.RowCount; i++) { //... }
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#" }
como agregar un icono de Font Awesome por CSS Hola quería saber como puedo agregar un icono de Font...desde CSS y que archivos necesito vincular para que funcione. Solo por CSS se puede?
[Entra aquí][1] Pone esto en el HTML <link rel="stylesheet" href=" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous"> Pon un icono cualquiera con la etiqueta <i class="fab fa-accessible-icon"></i>
stackexchange-es_stackoverflow
{ "answer_score": 3, "question_score": -3, "tags": "html, css, html5, css3" }
Is running (git reset head~2) equivalent to running (git reset head^) twice? If I have two commits on the local branch, and I run `git reset head^` twice. Will it just undo the two commits, or will I run into problems?
Yes it's the same thing and you will just undo the two commits (but keeping the changes). Note that you could also run `git reset HEAD^^`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "git, git reset" }
A list of all Sharepoint-specific tags & attributes for PageLayout/MP use? I'm having trouble locating a url/document or a book, that describes extensively all the tags and attributes we can use within Page Layouts and Master Pages (2010) in order to change the way that HTML is rendered. For example: I know there's an attribute that changes the out of the box left navigation from Tables to Unordered lists. I'm doing front-end development and I'd like to get as much control of my html (and css of course) as possible. One other thing is for example removing tables from web part zones and web parts. Again, are there attributes that do that?
There is not attribute for changing the table-based rendering for Web Part Zones and Web Parts. The recommended strategy is the use of a Control Adapter. Here are a couple of blog posts with examples. <
stackexchange-sharepoint
{ "answer_score": 0, "question_score": 2, "tags": "sharepoint designer, page layout, html" }
Mlodinow. The Drunkard's Walk. An example from the book. This excerpt is from Leonard Mlodinow's book The Drunkard's Walk: > And although Fortune is fair in potentialities, she is not fair in outcomes. That means that if each of 10 Hollywood executives tosses 10 coins, although each has an equal chance of being the winner or the loser, in the end there will be winners and losers. In this example, the chances are 2 out of 3 that at least 1 of the executives will score 8 or more heads or tails. How can it be proved with math?
First let us look at the probability of one executive getting $8$ or more heads/tails when tossing a coin $10$ times. $$ P(\text{# of heads}\geq 8 \text{ or # of tails} \geq 8) = 2 \times \dfrac1{2^{10}} \left(\dbinom{10}8 + \dbinom{10}9 +\dbinom{10}{10} \right) = \dfrac7{64}$$ Hence, the probability that one executives will score $7$ or less heads/tails$ = 1 - \dfrac7{64} = \dfrac{57}{64}$. Hence, the probability that at-least one of the executives will score $8$ or more heads/tails is nothing but $\left(1 - \text{ the probability that all the executives will score $7$ or less heads or tails} \right)$. The probability that all executives will score $7$ or less heads or tails is $ \left(\dfrac{57}{64} \right)^{10}$. Hence, the desired probability is $$1 - \left(\dfrac{57}{64} \right)^{10} = 0.685986140417819036628477302741657695150934159755706787109375 \approx \dfrac23$$
stackexchange-math
{ "answer_score": 1, "question_score": 4, "tags": "probability, probability theory" }
How can I copy Growl output to the clipboard? Is there any way I can copy Growl notifications to the clipboard, or store them to a file? If I get a notification I'd like to be able to do something like right click it and choose "copy to clipboard" or maybe set up a log file that would contain the text that I could then copy. !Screen shot 2012-03-28 at 12.21.23 PM.png
The latest MAS version of Growl does support a history feature as well as rollup. The actual log files can be access from the history tab in Growl. Haven't tried copying to the clipboard but is possibly the closest you will get to this functionality. !Growl History I also found this article explaining how to enable a Growl log file to display using GeekTool: > touch ~/Library/Logs/Growl.log > defaults write com.Growl.GrowlHelperApp GrowlLoggingEnabled -bool YES > defaults write com.Growl.GrowlHelperApp GrowlLogType 1 > defaults write com.Growl.GrowlHelperApp "Custom log history 1" /Users/kent/Library/Logs/Growl.log
stackexchange-superuser
{ "answer_score": 1, "question_score": 1, "tags": "macos, mac, clipboard, growl" }
WinDirStat-like control in Delphi The program WinDirStats (written in C++, see < ) has at the top a control that combines a tree-like structure (The column "Name", first on the left) with other types of data (graphic bar in column "Subtree percentage") and other text columns. My question is, using Delphi 7, which control should I use to do something like that? It's the tree part that I find more difficult to get right.
The best control for this would most likely be Mike Lischkes Virtual Tree View. Developers Homepage | Google Code Page * It's free * It gives you a tree connected with a list view * It allows for custom drawing * It's incredibly flexible * It's lightning fast The only downside is that you have to learn a quite different paradigm than most Delphi controls have, but apart from that it is a teriffic control. I myself have used it in various projects quite successfully and never hit a real roadblock while using it.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "delphi, vcl" }
SQL Server Reporting Services Format Hours as Hours:Minutes I'm writing reports on SQL Server Reporting Server that have a number of hours grouped by, say, user, and a total calculated based on the sum of the values. Currently my query runs a stored proc that returns the hours as in HH:MM format, rather than decimal hours, as our users find that more intuitive. The problem occurs when I try and add up the column using an SSRS expression, because the SUM function isn't smart enough to handle adding up times in this format. Is there any way to: 1. Display a time interval (in minutes or hours) in HH:MM format while having it calculated in decimal form? 2. Or split up and calculate the total of the HH:MM text values to arrive at a total as an expression? I'd like to avoid having to write/run a second query just to get the total.
Answering my own #1: 1. Make your query return a number of minutes (denoted by `TimeSpent` below). 2. Set the format of your textbox to "General" if it isn't already 3. Use the following expression as the value: `=FLOOR(Fields!TimeSpent.Value / 60) & ":" & RIGHT("0" & (Fields!TimeSpent.Value MOD 60), 2)` 4. For the sum textbox, use the following expression: `=FLOOR(Sum(Fields!TimeSpent.Value) / 60) & ":" & RIGHT("0" & (Sum(Fields!TimeSpent.Value) MOD 60), 2)`
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "time, format, ssrs 2008" }
How can I use dial-up internet in ubuntu 12.04 I want to convert from windows to ubuntu. I use a dial-up internet connection. In windows, it is very easy to setup a dialup connection. But in ubuntu 12.04 (run from livecd) I found no option to setup a dialup internet connection. I read other tutorials but I couldn't understand them clearly. It would be very helpful for me if anyone can give me a step to step tutorial. It is holding me back from installing ubuntu because I work online most of the time. I'm also a noob so please use easy language :). Thanks in advance.
Its actually not at all hard once you're pointed in the right direction. Here is an article which should get you all the way there. <\- Click Here!! Hope this helps!
stackexchange-askubuntu
{ "answer_score": 0, "question_score": 0, "tags": "networking" }
Bootstrap Weld 2.1.0 from void main How can I start an application with CDI that uses Weld within a normal Java SE environment, that is simply started from the command line and has no Glassfish or Tomcat in the background? With Weld 1.x you could do something like public static void main(String[] args) { final WeldContainer weld = new Weld().initialize(); service = weld.instance().select(MyService.class).get(); } But in Weld 2.x the initialize() is missing. I can do something like this: @ApplicationScoped public class Main { @Inject Foo foo; public void main(@Observes ContainerInitialized event) { System.out.println("Starting application"); } } This will inject Foo, but I want to pack my whole Application into a jar to be used by an other application that does not need to wait for Weld to actually start running. So I basically want a way to initialize Weld properly.
Bootstrapping Weld SE has not changed between Weld 1.x and 2.x, see the reference manual. Just make sure to import `org.jboss.weld.environment.se.Weld`, not the new class `org.jboss.weld.Weld`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "java, dependency injection, cdi, bootstrapping, weld" }
Let $P(x)=a_0+a_1x+a_2 x^2+a_3x^3+.......+a_nx^n$ and $P(1)=4$ and $P(5)=136$ Let $P(x)$ be a polynomial such that, $$P(x)=a_0+a_1x+a_2 x^2+a_3x^3+.......+a_nx^n,~~(a_i,n\in{Z^{\geq 0}})$$ $$ P(1)=4, P(5)=136$$ We have to find $P(3)$ This problem is harder than it looks (at least for me) What I tried to do was $$P(1)=a_0+a_1+a_2+a_3+.......+a_n=4$$ and $$P(5)=a_0+5a_1+25a_2 +125a_3+.......+a_n5^n$$ Let $P(1)=S$, and we take $a_0$ to the side of $S$ and multiply $(S-a_0)$ by $5$ and some cancellations. Simply it leads nowhere Can I get some **Hints** on how to proceed?
The crucial observation comes from the fact the coefficients need to be in $\mathbb{Z}^{\geq 0}$. $P(5) = 136$ can only be written in the following ways using powers of 5: * $1 + (27)(5)$ * $1 + (22-5i)(5) + (i+1)(5^2)$ for $i = 0,1,2,3,4$ * $1 + (2)(5) + (1)(5^3)$ The only one that satisfies $P(1) = 4$ is the last one which is $P(x) = 1 + 2x + x^3$. Therefore, $P(3) = 34$
stackexchange-math
{ "answer_score": 5, "question_score": 3, "tags": "sequences and series, algebra precalculus, contest math" }
MSV08-C#: How do I stop two groupboxes from auto-parenting themselves when dragged on top of one another? IDE: Microsoft Visual Studio Professional 2008 Language: C# Background: I have one form and two groupboxes that are going to be used as preference catagory groupboxes. My problem is that everytime I drag one groupbox on top of the other (hide/show groupboxes upon listview catagory select), the base groupbox auto-parents the second groupbox I just dragged on top. Question: How do I stop the two groupboxes from auto-parenting themselves when dragged on top of one another? // Edit; Q) I assume you are trying to acheive a layout where you swap out the visible box? --Mitchel Sellers A) Yes I am. I know I could do it at runtime but I'd like to make that my last option in case there is a more appropriate solution.
You may consider resizing your second GroupBox into position over the first. Drag one side or one corner of the second group box until it covers the first GroupBox and continue to resize the second GroupBox until it is positioned as you desire. Also available, in the Layout Toolbar, are the alignment and sizing buttons. Select both of your GroupBoxes to enable these options. The GroupBox displaying white grab handles is the one that will remain stationary when you use the alignment and sizing buttons, which include options to "Make Same Size" and "Align Middle". Furthermore, don't forget the keyboard right in front of you. The arrow keys will move the selected controls. Try holding various combinations of `Ctrl`+`Alt`+`Shift` while using the arrow keys.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, .net" }
How does the word "cardinal" relate to "cardinal numbers" > Cardinal number) > > In linguistics, more precisely in traditional grammar, a cardinal number or cardinal numeral (or just cardinal) is a part of speech used to count, such as the English words one, two, three, but also compounds like three hundred and forty-two > cardinal (adj.) > > "chief, pivotal," early 14c., from Latin cardinalis "principal, chief, essential," from cardo (genitive cardinis) "that on which something turns or depends; pole of the sky," originally "door hinge," of unknown origin. What's the relation between the two?
Cardinals are quite simply the primary, most ‘basic’ form of numerals. Different languages have different categories of numbers (English has cardinals, ordinals, and a few repetitionals or multiplicatives [ _once_ , _twice_ ]; Latin has these as well as distributives; Irish has animatives; etc.), but if a given language has numerals at all, it will almost certainly have at least cardinals. The other types of numbers are given names for what they indicate _apart_ from numeric values: ordinals indicate an ordering, etc. Cardinals, being the primary type, indicates just the numeric value and nothing else.
stackexchange-english
{ "answer_score": 4, "question_score": 3, "tags": "etymology, meaning in context" }
Chromedriver fails when runs from Jenkins or linux console I have a problem with the last chromedriver. Fails every time with the following error: > Starting ChromeDriver 2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5) on port 2393 Only local connections are allowed. org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally The browser version is > Version 71.0.3578.98 (Official Build) (64-bit) When I run from eclipse everything works OK, does not fail. Fails only when I run from Jenkins or Linux console. The chromedriver process remains hanged on Linux. Is there a solution for this?
Try adding the `--no-sandbox` flag: ChromeOptions ChromeOptions = new ChromeOptions(); ChromeOptions.addArguments("--headless", "window-size=1024,768", "--no-sandbox"); driver = new ChromeDriver(ChromeOptions); Or, some were helped by `--single-process` option, as suggested here.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "linux, jenkins, selenium webdriver, selenium chromedriver" }
How would I calculate two given pixels to obtain its aspect ratio? I've looked online on how to get the aspect ratio to write proper media queries for a website I'm trying to make but some of these numbers don't make sense. What I'm trying to do is take two pixels, say, 667 x 325. I put those two numbers inside the website below, but result I'm getting is 667 : 325. I don't think that's correct, or is it? < I've also tried looking for a mathematical formula to get these so I can just manually do these but there are so many out there that don't fit into the context of what I'm trying to obtain. How can I get the aspect ratio of two given pixels?
Aspect ratio is width / height, e.g. 600 by 800 = 600/800 = 0.75. The calculator is correct because the "Ratio" by conventional meaning of the word is 600:800 or 0.75:1 or 0.75 (as we programmers use it)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "css, aspect ratio" }