INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Can curve25519 keys be used with ed25519 keys? Can curve25519 keys be used with ed25519? I'd prefer to use ed25519, but there isn't a fast java version. For my application, I'd like to use curve25519 until I can get a faster ed25519 for java. At the very least can the curve25519 keys be restricted if some can be converted ed25519?
Trevor Perrin wrote a library doing exactly that. Explanation can be found on in the curves mailing list archives. To convert a Curve25519 public key $x_C$ into an Ed25519 public key $y_E$, with a Ed25519 sign bit of $0$: $$y_E = \frac{x_C - 1}{x_C + 1} \mod 2^{255}-19$$ The Ed25519 private key may need to be adjusted to match the sign bit of $0$: if multiplying the Curve25519 private key by the Ed25519 base point yields a “negative” Ed25519 x-coordinate, then the private key must be negated modulo the order of the base point: $a_E = q - a_C$. See Trevor Perrin's email and the ensuing thread for a security analysis.
stackexchange-crypto
{ "answer_score": 13, "question_score": 11, "tags": "elliptic curves, keys, ed25519" }
html and css identifying elements How can I use CSS and html to place a picture on the left and right with the div tag? Or is there a better way? For instance I have: HTML: <img src ="..." .... ... /> <!--Picture 1--> <img src = "..." .... .... /> <!--Picture 2--> CSS: img { align:left } This will align both images to the left. How can I "identify" both image elements and then align one left, and the other right. Both images are aligned with respect to a centered java applet.
you can identify with "class" tags <img src ="..." class="img1" /> <!--Picture 1--> <img src = "..."class="img2" /> <!--Picture 2--> .img1 { ... } .img2 { ... }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "html, css, image, identify" }
Upgrading an ASP.NET 2.0 to ASP.NET 3.5 We've got an older ASP.NET app written in VS 2005. I'd like to upgrade it to VS 2008, but still leave the old one around, in case I need to do development in it. It is also in Visual SourceSafe. So, would I just get into VS 2008, do an Open Website from Source Control (or whatever the string is) and put it into a new website under wwwroot?
open the application in VS 2008. VS will automatically detect the app is VS 2005 and offer to upgrade, with a backup. Do that. _Usually_ there aren't issues with an upgrade.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "asp.net, visual sourcesafe" }
Finding a closed form for $\sum_{k=1}^{\infty}\frac{1}{(2k)^5-(2k)^3}$ I'm looking for a closed form for the expression $$ \sum_{k=1}^{\infty}\frac{1}{(2k)^5-(2k)^3} $$ I know that Ramanujan gave the following closed form for a similar expression $$ \sum_{k=1}^{\infty}\frac{1}{(2k)^3-2k}= \ln(2)-\frac{1}{2} $$ I wonder if it is possible to find such a similarly simple and nice closed form for the above case. Thanks.
$$ \frac{1}{(2k)^5 - (2k)^3} + \frac{1}{(2k)^3} = \frac{1 + (2k)^2 - 1}{(2k)^5 - (2k)^3} = \frac{1}{(2k)^3 -2k}$$ So by Ramanujan's result: $$\sum_{k=1}^{\infty} \frac{1}{(2k)^5 - (2k)^3} = \ln(2) - \frac{1}{2} - \frac{1}{8}\zeta(3)$$
stackexchange-mathoverflow_net_7z
{ "answer_score": 28, "question_score": 12, "tags": "sequences and series" }
Sleep until file exists/created for reference I have looked at Is there a way to check if a file is in use? and How to wait until File.Exists? but I want to avoid using SystemWatcher as it seems kind of overdoing. My application is calling cmd prompt to create a file and as there is no ways for my application to know when it is finished I was thinking of using Sleep() as long as the file does not exist. string filename = @"PathToFile\file.exe"; int counter = 0; while(!File.Exists(filename)) { System.Threading.Thread.Sleep(1000); if(++counter == 60000) { Logger("Application timeout; app_boxed could not be created; try again"); System.Environment.Exit(0); } } Somehow this code of mine does not seem to work. What could be the cause?
Not sure what part isn't working. Did you realize that your loop will run for 60,000 seconds (16.67 hours)? You are incrementing it once per second and waiting for it to reach 60000. Try something like this: const string filename = @"D:\Public\Temp\temp.txt"; // Set timeout to the time you want to quit (one minute from now) var timeout = DateTime.Now.Add(TimeSpan.FromMinutes(1)); while (!File.Exists(filename)) { if (DateTime.Now > timeout) { Logger("Application timeout; app_boxed could not be created; try again"); Environment.Exit(0); } Thread.Sleep(TimeSpan.FromSeconds(1)); }
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "c#, sleep" }
Converting Posix Regex to PCRE in PHP I have a cms that on the front-end grabs pages by id, as shown here: $pageid = ereg_replace("[^0-9]", "", $_GET['pid']); This is some old code I am trying to update since POSIX is deprecated, however my efforts to convert (using preg_replace) have been unsuccessful. If anyone could convert that line for me, I would greatly appreciate it. **Add code from comments** My first guess was something along the lines of $pageid = preg_replace("/[^0-9]/","",$_GET['pid']; Which gave errors, so I further reduced it to $pageid = preg_replace("/^0-9/","",$_GET['pid'] Forgive me, my understanding of regex is rather limited.
Let's explain what the posix pattern does. `[^0-9]` `[` is the start of a character class and `]` is the end. When the character class starts with a `^` it means it's inverted (= matches everything but what is listed). `0-9` is all digits. So globally `[^0-9]` matches everything which is **NOT** a digit. The same pattern is also available in PCRE so this will work: $page_id = preg_replace('/[^0-9]/', '', $_GET['pid']); PCRE has some nice shortcuts to express things. For example `[0-9]` can be replaced with `\d` (d stands for digits) Also `\D` (using a capital letter) is the inverse and thus equivalent to `[^0-9]`. Which leads to the following: $page_id = preg_replace('/\D/', '', $_GET['pid']);
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "php, regex" }
Apply same style to all tr and td of multiple table having same parent CSS class I am trying to merge the following two css classes: .addActivityTable table tr { border: none; } .addActivityTable table td { border: none; } as .addActivityTable table tr, table td { border: none; } It is not taking any effect, also I have tried: .addActivityTable table tr, td { border: none; } This also doesn't work. Is there any way to merge these? If someone point me a good article or blog on these kind of css selectors, it would be helpful to me to learn.
You need: .addActivityTable table tr, .addActivityTable table td { border: none; } or .addActivityTable tr, .addActivityTable td { border: none; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "css, css selectors" }
Working with TTabSet in TestComplete scripts I am attempting to click a TTabSet tab for our Delphi application via VBScript (used in test automation) but am having difficulty doing so without using page coordinates. Does anyone have experience using this tab class? Using TestComplete's Object Spy, I can view the RTTI - TabIndex of each tab but I cannot seem to pass it into a clicktab method to select it (TestComplete reports the error that it cannot find the tab and that 0 items exists). I have asked the people who created TestComplete and they said that TTabSet is not a supported tab control but it was suggested that perhaps I can use some of TTabSet's native methods to get it working for me. Any ideas?
`TabIndex` is read-write, so you can do: tabSetObj.TabIndex = 2 ' Select tab with index 2 As per the docs, the effect should be the same as if you actually clicked on that tab: > When a value is assigned to TabIndex, the OnClick event for the tab set occurs, followed by the OnChange event, just as if the user had clicked on a new tab.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "delphi, automated tests, testcomplete" }
Are there valid implementations of the Sync trait apart from the Rust standard library? `Sync` and `Send` are part of the language. `Arc` and `Mutex` are part of the standard library and both implement `Send` and `Sync`. Are there structures apart from the standard library (`std::sync`) (e.g in some crates) that do something like `unsafe impl Sync for SomeStruct {}` for valid reasons? In my humble understanding no developer will ever need implementations of `Sync` except the ones developing the standard library.
Yes, `crossbeam`, a crate which provides "tools for concurrent programming in Rust", for example has an `unsafe impl Sync for AtomicCell`.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "rust" }
Laravel : Eloquent Skip records How did i get my users but start only at a certain position ? I get the 50 first with : $users = User::orderBy('xp', 'DESC')->take(50)->get(); But now I want the 50 after this, so the 50th to 100th records. Thanks
You can use `skip()` Laravel eloqunt provides nice way to achieve this. $users = User::orderBy('xp', 'DESC')->skip(50)->take(50)->get(); Hope this helps.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 2, "tags": "php, laravel, eloquent" }
Can't get plot using the Evaluate function I am trying to plot a series of five curves using a `loglogplot` command and then labeling the curves with a value. This is the program I am trying to run. aa={5 10^-1, 5 10^-2,5 10^-3, 5 10^-4, 5 10^-5} n[k,a]=a k (3+6 k+4 k^2+2 a k^3+a^2 k^4)/((1+a k) (1+a^2 k^4+2 a k (2+3 k+2 k^2))) lst=Table[n[k,a],{a,aa}] LogLogPLot[ {Evaluate[lst]},{k,0.1,100}, PlotRange {{0.1,100},{0.001,1}}, AxesOrigin {0.001,0.001}, Epilog {Text["a=5 10^-1",{.005,0.3},{1,0}], Text["a=5 10^-2",{0.5,0.25},{1,0}], Text["a=5 10^-3",{1.0,0.25},{1,0}], Text["a=5 10^-4",{3.0,0.25},{1,0}], Text["a=5 10^-5",{7.0,0.3},{1,0}]}, Gridlines Automatic, Frame True, Framelabel {"k","n"}, ImageSize 600 ] No plots occur. I don't understand the error.
Multiple formatting errors consisting of missing `->`, incorrect capitalization and function definition. Take a look at `LogLogPlot` and `Defining Functions`. I also used `PlotLabels` to automatically associate labels with individual curves as opposed to the more manual method of `Epilog`. aa = {5*^-1, 5*^-2, 5*^-3, 5*^-4, 5*^-5}; n[k_, a_] := a k (3 + 6 k + 4 k^2 + 2 a k^3 + a^2 k^4)/((1 + a k) (1 + a^2 k^4 + 2 a k (2 + 3 k + 2 k^2))) LogLogPlot[Evaluate[ Table[n[k, aa[[a]]], {a, 1, 5}]], {k, 0.1, 100}, AxesOrigin->{1, 0.1},AxesLabel->{"k", "n"}, GridLines->Automatic, Frame->True, ImageSize->600, PlotLabels -> Placed[Text["a = " <> ToString[#]] & /@ N[aa], Left] (*Epilog ->{ Text["a=5 10^-1",{-2,-1}], Text["a=5 10^-2",{-2,-3}], Text["a=5 10^-3",{-2,-5}], Text["a=5 10^-4",{-2,-7}], Text["a=5 10^-5",{-2,-9}]}*) ] ![enter image description here](
stackexchange-mathematica
{ "answer_score": 5, "question_score": -5, "tags": "plotting, warning messages, broken code" }
What are the file places after you package a python program? I am wanting to package my program that uses over files to store user data locally, but I don't know what directory I should put in all the `json.load` and `json.dump`. So right now, I have the directory equal to `json.dump(somelist,open('/home/username/filename','w'))` but when someone downloads it, the program won't work since it is a different directory. I am trying to PyInstaller but maybe PyInstaller will do it for me. I was just wondering and I couldn't find anything on google but if there is something, please link it to me. Thanks in advance!!
Use the following to get the user's home directory: from os.path import expanduser home = expanduser("~") with open(os.path.join(home, 'file'), 'w') as sr: json.dump(somelist, sr)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, json, file, pyinstaller, software packaging" }
How to find actual hosting provider for website that are connected to cloudflare.com I am trying to find hosting provider for a website that is connected to cloudflare. On Whois Lookup, I get Name Server(s) NOAH.NS.CLOUDFLARE.COM UMA.NS.CLOUDFLARE.COM When I use this website < I get Attempt to get a DNS server for 104.XX.1xx.3x failed: I know that cloudflare is not a hosting provider. How can I dig deep and find the actual hosting provider?
If you have some type of abuse related issue with the website in question you'll need to file a complete abuse report at cloudflare.com/abuse In most cases there isn't an obvious way to identify the underlying hosting provider for a website behind CloudFlare. With a valid and complete abuse report they can put you in touch with the hosting provider's abuse team though.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "dns, cloudflare, whois" }
Internet Explorer button CSS I am using a gradient for my button background color, and this only works in non IE browsers. I am trying to set a solid background color for IE. When I place the background style before the background gradients in the stylesheet, it simply doesn't show up. When I place it after, it overrides the gradient in all browsers. Without it, my button is completely transparent. Can someone help me figure out how to give a background color only to IE? (versions 8 and 9) Or even better.. to set a gradient? Here is the CSS which works in browsers except IE. The solid background color doesn't show up at all though: button { background: #3485bf; background: -moz-linear-gradient( top, #59a3d4 0%, #3485bf); background: -webkit-gradient( linear, left top, left bottom, from(#59a3d4), to(#3485bf)); }
try to use Filters. Something like filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#59a3d4', endColorstr='#3485bf'); should do the job for you. See Transitions and Filters
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "css, internet explorer, button, internet explorer 8, background color" }
How can I interrupt a calculation without aborting it? Before version 10.0, there was a menu item, Evaluation → Interrupt Evaluation..., which could be used to interrupt a calculation without aborting it. It would bring up this window: ![enter image description here]( It was possible to enter a subsession, examine the kernel state, then resume the calculation using `Return[]`. How do I access this functionality in version 10.0 or later?
The menu item is gone, but the functionality is still there in version 11.0. It can be accessed by a keyboard shortcut: * Command-Option-`.` on OS X * Alt-`,` on Windows and Linux The front end token is called * `"EvaluatorInterrupt"` It can be used e.g through a palette button. Alternatively, use Evaluation → Evaluate in Subsession for similar functionality. E.g., Table[Pause[1]; i, {i, 30}] Now enter `i` and evaluate it using the above menu item before the `Table` has finished running. You will see the current value of `i`.
stackexchange-mathematica
{ "answer_score": 19, "question_score": 16, "tags": "evaluation, debugging" }
how can I Update top 100 records in sql server I want to update the top 100 records in SQL Server. I have a table `T1` with fields `F1` and `F2`. `T1` has 200 records. I want to update the `F1` field in the top 100 records. How can I update based on `TOP 100` in SQL Server?
Note, the parentheses are required for `UPDATE` statements: update top (100) table1 set field1 = 1
stackexchange-stackoverflow
{ "answer_score": 805, "question_score": 485, "tags": "sql, sql server, tsql, sql update" }
Creating Custom Class for loading Gridview Every time I load a grid view, I need a `Datasource` and I have to bind the data with the source `DataBind()`. I want to skip this so I made a function. Which is working. But when I create the class, `Gridview`, I get a `System.Web.UI.WebControls` not found Exception. Can you explain the problem to me and a potential fix? I have added the `System.web` namespace. protected void LoadToGv(GridView GV, string qry) { DataTable dt = DC.GetDataTable(qry); if (dt != null) { GV.DataSource = dt; GV.DataBind(); } } And while making it a public method of a class library it's giving the error `Reference Not found`. Is there any other way to accomplish it.
I have to use `System.Web.Extensions` as reference. And That's solve the problem
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, asp.net" }
Signing into a different Apple ID for Media and Purchases I'm signed in to two Apple IDs on my iPhone. I'm signed into iCloud with my personal ID, but my media and purchases for App store use my mom's apple ID. Any apps I download also come up on my mom's phone, and our Apple music seems to be synced as well I want to sign out of my mom's ID on App store and media and sign in with mine. Does anyone know if I would lose the apps that I've downloaded on my phone if I do this? I know the purchases cannot be transferred to a different ID, but that's not a problem for me.
You will not lose the apps already installed on your device. These apps will stay installed and registered to the previous ID. You may need to enter the Apple ID used to first install the app after a while when you come to update them and automatic updates will stop working for these apps. You will be prompted for this at the point of updating if this applies — you don't need to remember nor sign out and back in.
stackexchange-apple
{ "answer_score": 1, "question_score": 1, "tags": "ios appstore, apple id" }
Is it good to rewrite your old db migration for unused column in your table? Removing unused code is a good practice. But is DB migrations script file an exception in this practice? I have to maintain a Laravel application and I'm in the process of cleaning up unused code and I found out I have lots migrations scripts. My migration includes adding and dropping table columns. Anyone who have encountered the same situation? Thanks!
If the migration does not affect anything on the database, then it is fine to remove them. But, if they affect, even a little part like adding/removing (same or different) columns, changing types ... then look up current data carefully if your in **PRODUCTION** ; otherwise, refactoring before production is good.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, laravel, migration, database migration" }
R data frame timestamp manipulation I have the following data.frame > head(k) begin end type total_replies rpm 1 03/22/15 00:00:00 03/22/15 00:05:00 178.19 0.50 0.10 2 <NA> <NA> 178.19.6 0.50 0.10 3 03/22/15 00:05:00 03/22/15 00:10:00 178.1963 0.50 0.10 4 <NA> <NA> 178.19.75 0.50 0.10 5 <NA> <NA> 12.221.253 0.75 0.15 6 03/22/15 00:10:00 03/22/15 00:15:00 101.254 1.50 0.30 The NA values correspond to the timestamp above them respectively, meaning the timestamps in row 2 should be the same as row 1 and so on How do I fill the NA values to match the timestamp above them ?
Basically, you have to do the following: replace <- function(dataFrame, forField){ for (i in c(1:nrow(dataFrame))){ if (is.na(dataFrame[i,forField])){ dataFrame[i,forField] <- dataFrame[i-1,forField] } } return (dataFrame) } and call the function by replace(yourDataFrame, "begin") to replace all begin fields. The same goes for end. Update output: !enter image description here
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "r, timestamp, dataframe" }
How to clear variables created using eval? I have a thousands of variables stores in .mat files. I am loading them in a loop one at a time. I then assign the loaded variable the workspace variable `x` using `eval`. Then, I clear the loaded variable. The problem is that matlab gives `The current workspace already has too many variables` error after around 60,000 iterations. But, on checking the workspace, it appears that only 5-10 variables are present. for i = 1:m load(sprintf('feat_%s.mat', ids{i}), sprintf('feat_%s', ids{i})); eval(sprintf('x = feat_%s;', ids{i})); clear(sprintf('feat_%s', ids{i})); end I think this has got to do with the `eval` command. I am guessing that `eval` is creating multiple copies of `x`. Any idea on wow to clear variables created using `eval`.
It is best not to use `eval`. You can `load` into a variable: for ii=1:m nm = sprintf('feat_%s', ids{ii} ); ld = load( [nm,'.mat'], nm ); x = ld.(nm); % access loaded variable WITHOUT eval clear ld; % clear the loaded variable end PS, It is best not to use `i` as a variable name in Matlab.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "matlab" }
Finding MongoDB documents with duplicate `_id` I am running in to a duplicate `_id` issue while trying to restore the DB dump. Failed: bulk write error: [{[{can't have multiple _id fields in one document}]}, And want to find out which document it is so I can remove it. I have tried `aggregate` with: db.collection.aggregate([ {"$group" : { "_id": "$_id", "count": { "$sum": 1 } } }, {"$match": {"_id" :{ "$ne" : null } , "count" : {"$gt": 1} } } ]); The `_id` is of the form { "_id" : { "$oid" : "55ad085569702d6a820007b3" } But the aggregate is not giving any result and I am not sure if the statement has an error. Is it not possible to aggregate on the `_id` itself? Thank you.
The error "can't have multiple _id fields in one document" is not indicating a duplicate key error where multiple documents have the same value for _id. It is indicating that a single document has more than one field named _id. You might try using the `bsondump` utility to extract the bson files from the dump directory to examine the documents directly.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "mongodb" }
How to simplify a fraction like this one? $$\frac{x^2-3x+1}{x-3}$$ Is there a rule for factorizing polynomials in the numerator?
"Simplification" may depend on each one, but $$\frac{x^2-3x+1}{x-3}=\frac{x(x-3)+1}{x-3}=x+\frac1{x-3}$$ We did "not" simplify by factoring since the factoring of the numerator isn't nice at all in regards with this problem, as the numerator's roots are $\;\frac12\left(3\pm\sqrt5\right)\;$, yet for some use the rightmost expression could probably called "simpler" than the original one. For example, to differentiate the expression or to find the limit when $\;x\to\infty\;$ , etc.
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "factoring" }
Prove: if $|x-1|<\frac{1}{10}$ so $\frac{|x^2-1|}{|x+3|}<\frac{1}{13}$ > Prove: $$|x-1|<\frac{1}{10} \rightarrow \frac{|x^2-1|}{|x+3|}<\frac{1}{13}$$ $$|x-1|<\frac{1}{10}$$ $$ -\frac{1}{10}<x-1<\frac{1}{10}$$ $$ \frac{19}{10}<x+1<\frac{21}{10}$$ $$|x+1|<\frac{19}{10}$$ Adding 4 to both sides of $$ -\frac{1}{10}<x-1<\frac{1}{10}$$ gives: $$\frac{39}{10}<x+3<\frac{41}{10}$$ $$|x+3|<\frac{39}{10}$$ Plugging those results in $$\frac{|x-1|*|x+1|}{|x+3|}<\frac{1}{13}$$ We get: $$\frac{\frac{1}{10}*\frac{19}{10}}{\frac{39}{10}}<\frac{1}{13}$$ $$\frac{19}{390}<\frac{1}{13}$$ Which is true, is this proof is valid as I took the smallest intervals, like $|x+3|<\frac{39}{10}$ and not $|x+3|<\frac{41}{10}$?
Your method (what you are trying to do) is correct, but you have a few errors. > $$ \frac{19}{10}<x+1<\frac{21}{10}$$ > > $$|x+1|<\frac{19}{10}$$ This is wrong. It should be $$|x+1|\lt \frac{21}{10}$$ > $$\frac{39}{10}<x+3<\frac{41}{10}$$ > > $$|x+3|<\frac{39}{10}$$ This is wrong. It should be $$|x+3|\lt\frac{41}{10}$$ but we use $$|x+3|\color{red}{\gt} \frac{39}{10}\iff \frac{1}{|x+3|}\lt \frac{10}{39}$$ since $|x+3|$ is in the denominator. Therefore, we get $$\frac{|x^2-1|}{|x+3|}\lt\frac{1}{10}\cdot\frac{21}{10}\cdot\frac{10}{39}=\frac{7}{130}\lt \frac{10}{130}=\frac{1}{13}$$
stackexchange-math
{ "answer_score": 5, "question_score": 2, "tags": "algebra precalculus, inequality, proof verification" }
How can I know if the right oil has been added to the vehicle? Considering that the car recommends Mobil 1 Synthetic oil as per the logo on the oil cap, how can I be sure the garage that did the oil change poured the recommended oil and not another low cost oil to save money?
My first suggestion would be to ask whoever did the change. If you are seriously in doubt, provide the oil to somebody to redo the change, or simply do it yourself. If you are able to do the change yourself, I would suggest learning to do so (just keep the receipts so you can provide them as maintenance records in the event you wish you sell the vehicle). All in all, if you aren't certain the right oil was used the first time, redoing a $40 oil change with the correct oil will be way cheaper than any damage the wrong oil might inflict on your vehicle over time.
stackexchange-mechanics
{ "answer_score": 7, "question_score": 9, "tags": "oil" }
Delphi XE2, how to keep form ON TOP after changing VCL styles I encountered a weird issue with XE2: I'm using HWND_TOPMOST with SetWindowPos to set my form on top, but if I switch VCL styles at runtime, the window isn't topmost anymore, and unsetting/re-setting it doesn't fix it either. Any way to fix this?
Your problem is that the form is being recreated because of a style change and loosing its top most style since the VCL have no knowledge of this. Either use: FormStyle := fsStayOnTop; or override `CreateWindowHandle` so that `SetWindowPos` is called each time the form is recreated: type TForm1 = class(TForm) .. protected procedure CreateWindowHandle(const Params: TCreateParams); override; .. procedure TForm1.CreateWindowHandle(const Params: TCreateParams); begin inherited; SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE); end; BTW, I couldn't duplicate _"unsetting/re-setting doesn't fix it"_. With my tests, calling `SetWindowPos` again fixed it.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "delphi, delphi xe2, vcl styles" }
Find $\int_0^2 \int_0^{\sqrt{3}x} f(\sqrt{x^2+y^2})dydx$ in polar coordinates. I need to find: $$\int_0^2 \int_0^{\sqrt{3}x} f(\sqrt{x^2+y^2})dydx$$ in polar coordinates. Since $x=r\cos(\theta)$ and $y=r\sin(\theta)$, I got: $y=\sqrt{3}x \iff r\sin(\theta)=\sqrt{3}r\cos(\theta)\iff \tan(\theta)=\sqrt{3}\iff \theta=\arctan(\sqrt{3})$ From this I conclude that $0 \leq \theta \leq \arctan(\sqrt{3})$. My problem is I'm not sure where the radius is, I thought about from $0$ to $2\sqrt{3}$ (from graphing $y=\sqrt{3}$) but I think it is wrong. Is there something I'm missing in order to get the $r$ interval?
Since $x\in[0,\,2]$ while $y\in[0,\,x\sqrt{3}]$, $r\in[0,\,2x]\subseteq[0,\,4]$. The integration region is $0\le r\le4,\,0\le\theta\le\pi/3$ (you'd already worked out the second part), so the integral is $\int_0^{\pi/3}d\theta\int_0^4rf(r)dr=\tfrac{\pi}{3}\int_0^4rf(r)dr$.
stackexchange-math
{ "answer_score": 4, "question_score": 3, "tags": "multivariable calculus, multiple integral" }
Cannot schema bind function Function because it references system object 'sys.extended_properties' I want to create an `Indexed View` in which I have used a Function named `GetBranchId`. As far as I know, for creating an `Indexed View` we have to create the used functions with `SchemaBinding` as well. But the problem is when I want to Alter my function I get this error: > Cannot schema bind function 'dbo.GetBranchId' because it references system object 'sys.extended_properties' **This is my Function:** ALTER FUNCTION [dbo].[GetBranchId] ( ) RETURNS smallint with schemabinding AS BEGIN RETURN (SELECT TOP 1 CAST(value as smallint) FROM sys.extended_properties Where class = 0 and name = 'BranchId') END
So, say you have an indexed view (not "index view") like this: CREATE VIEW dbo.IndexedView WITH SCHEMABINDING AS SELECT ... GO CREATE UNIQUE CLUSTERED INDEX x ON dbo.IndexedView(...); GO If you want to add a column to that view that represents this function, which pulls data from a catalog view, you can't use `SCHEMABINDING`, as you already know. So just create a different view, e.g.: CREATE VIEW dbo.NonIndexedView AS SELECT iv.col1, iv.col2, BranchId = dbo.GetBranchId() FROM dbo.IndexedView; However, as I mentioned in the comments, I fail to see the point. Since this is going to return a single value for every single row in the view, why not just get the value once, store it in a variable, and return it in the eventual query that queries the view?
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "sql, sql server" }
I want to send html type in email body with gmail sender i want to send email using html code. plzz help GMailSender m = new GMailSender("", ""); String[] toArr = {""}; m.setTo(toArr); // load array to setTo function m.setFrom("[email protected]"); // who is sending the email m.setSubject("Registration"); m.setBody("Thanks for registration with us."); i want to send ### +username+ this code in m.setBody(). how can i do this??
You can use this: m.setBody(Html.fromHtml("<h1>Title</h1><br>Username "+ username +" and password")); You can also create html tables or any other html elements If the example is from here: GMailSender example Change `DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));` with`DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/html"));` and add the body like this: m.setBody("<html><h1>TESTING<h1></html>");
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android, html, email" }
Symfony 4 common data in all views - best practice What are the best practices for placing common data for many views (twig), eg. main menu, bottom menu, breadcrumbs, etc. I know that I can do it using embedded controllers, but it is not very efficient.
Many commonly used things can be accessed by using the built in variabble app, ie {{ app.user }} returns the currently logged in user. If you need something else you can write your own twig extensions.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "symfony, twig, symfony4" }
Ubuntu thinkpad e15 gen2 lid and fn keys not working I just got the thinkpad e15 gen2 (amd) and I installed ubuntu 20.04 lts on it and I can't seem to be able to get the fn keys working nor can I get the laptop to suspend when closing the lid. For the lid there are no options in the power settings and editing the logind.config file does not work either. the lid status in terminal does work correctly. I can't get the FN keys to work. I tried to change the bios settings, but disabling, swapping or putting the fn as default or not are not working. Testing for key output in terminal did work for the keys when they were in f1, f2,.. but I don't get any output when they are in fn mode. (pressing fn key gave wakeup command?) I know linux a bit for programming, however I am a bit out of my league here and I do not know how to proceed. Could you help me or point me in the right direction?
A bit late maybe, but Lenovo confirmed this bug a few weeks ago and has released a new BIOS update yesterday that fixes this issue. I've installed it and it works fine now. You can download the update on the official Lenovo website, it should work smoothly after that. Note that this update is primarily rolled out for Windows, so you have to install the update via the provided ISO file. You can do this with a bootable USB, see here for an example.
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 4, "tags": "20.04, suspend, thinkpad, function keys, lid" }
Diff where one file is regex file So basically I have File 1, that looks like this We have 2 persons. Jack bought 3 cars. John purchased 5 bananas. I want to use diff to see if it matches this File 2: .* 2 persons.* Jack .* 3 cars.* John .* 5 bananas.* I can't seem to figure out what arguments to pass to diff to treat the second file as a "Regex" file. PS: I would like to do this in diff. If it is absolutely impossible, I can use other available commands but no 3rd party tools.
yes. It is impossible using `diff`. There is no option that would interpret one the files as a regex. You could use `grep` instead: $ grep -Pzo '(?s).* 2 persons.*Jack .* 3 cars.*John .* 5 bananas.*' <<-'FILE' We have 2 persons. Jack bought 3 cars. John purchased 5 bananas. FILE Note: some `grep` versions do not support it.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "regex, linux, diff" }
Drop database owned by specific user in PostgreSQL I have created database with bad symbols at the end of its name. Now I want to drop it but I don't know how to type its name in the console. Can I remove databases owned by this user? I tried to `DROP OWNED BY devuser` but it does not worked. I see just `DROP OWNED` in the console. !command prompt
You could also try this from your shell: -bash-4.1$ bad_dbname=$(psql -t -q -c "select datname from pg_database where datname like 'bsw_ui%' limit 1") -bash-4.1$ echo "the next command will drop ${bad_dbname}" -bash-4.1$ psql -c "drop database ${bad_dbname}" I verified this works using bash4.1 on centos6.3 with posgresql8.4 for a database using this unicode character. YMMV
stackexchange-dba
{ "answer_score": 2, "question_score": 0, "tags": "postgresql" }
Outputting values from an NSArray I'm simply trying to output the values held in an NSArray as I want to see how big the thing is. However, I am very new to iOS development and object C in general so I was hoping someone could help me. The array is filled with the following call: -(void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region { if([beacons count] > 0) { } } I've been playing around with calling the following line in side the nested if statement, but each time it is called, the system crashes: NSLog([beacons count]); Can someone show me how to display the values inside this array and how I could possible go about accessing them?
Your NSLog statement is wrong it should be: NSLog(@"%d", [beacons count]);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "ios, objective c, nsarray" }
Proving limits for sequences I need to be able to show that if we have the$\lim \limits_{n \to {+\infty} }$$y_n$ = ${+\infty}$ and the $\lim \limits_{n \to {+\infty} }$$z_n$ = M for some M $\in$ (0,${+\infty}$) show that the $\lim \limits_{n \to {+\infty} }$$y_nz_n$ = ${+\infty}$.
I assume you want a proof “on first principles”. Let $K>0$; you want to prove that there exists $k$ such that, for $n>k$, $y_nz_n>K$. First choose $k_1$ such that, for $n>k_1$, $|z_n-M|<M/2$. In particular, $z_n>M/2>0$. This is possible because $\lim_{n\to\infty}z_n=M$. Since $\lim_{n\to\infty}y_n=\infty$, there exists $k_2$ such that, for $n>k_2$, $y_n>2K/M$. Now let $k=\max\\{k_1,k_2\\}$. For $n>k$ we have $$ y_nz_n>\frac{2K}{M}\frac{M}{2}=K $$
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "real analysis" }
Entity last modification date Is there any solution for getting last modification date of whole Enity? Timestamps of each `NSManagedObject` won't be a good solution because of app sync with web service (some of them would be in database with older date). I need to make a timestamp for the whole entity every time user decides to update the list so I can present this date in `SSPullToRefresh`. There is only one solution in my mind: `NSUserDefaults` but is it a good place to keep Entity last modification date?
I tend to avoid `NSUserDefaults` always feels like mixing apples and oranges. When I need to store information like this I like to put it in the metadata of the `NSPersistentStore` itself. That way it is attached to the file that I am syncing with the web service. There are methods on the `NSPersistentStoreCoordinator` that allow you to access the metadata and alter it. Then if the file gets transplanted to another device (say in a restore or something else) the metadata goes with it.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 4, "tags": "ios, objective c, core data, nsuserdefaults, nsmanagedobject" }
Short story: Anomalies appear, everyone can only move towards the centre Looking for a short story I read many years ago. As I recall, these anomalies would appear, and everyone was required to move to the centre in order to survive. But more than that, the anomalies exerted a sort of force that prevented you from ever moving further away from the centre — all houses had to be designed to have multiple exits to avoid trapping people, infants might be trapped out of reach, someone could get stuck just by taking a wrong turn, etc. (Breathing, circulation, etc. were fine.) I'm wondering if this was compiled into one of the Year's Best Sci-fi anthologies by Gardner Dozois, but I've flipped through all the ones I can find on my bookshelves and nothing rings a bell.
This is Into Darkness by Greg Egan. Wikipedia describes it briefly in the article for Egan's short story collection _Axiomatic)_. > A giant sphere of unknown origin jumps between random locations on the Earth's surface and restricts the movement of objects trapped inside in bizarre ways. You can read most of it online here.
stackexchange-scifi
{ "answer_score": 11, "question_score": 11, "tags": "story identification, short stories" }
Given a list of integers, return true if the length of the list is greater than 1 I'm try learning to Python and I need given a list of integers, return true if the length of the list is greater than 1 and the first element and the last element are equal. Here is my code: class Solution: def solve(self, nums): nums = [] if len(nums) > 1 and nums[0]== nums[-1]: return True return False But I get this error: if len(nums) > 1 and nums[0]== nums[-1]:IndentationError: unexpected indent
You could write it like class Solution: def solve(self, nums): return (len(nums) > 1 and nums[0] == nums[-1]) You were initializing the `nums` again and again to have zero elements plus the indention was wrong.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python" }
Make meta tag with reagent I want to render a meta tag with Reagent. I can not find any info with Google. [:div (header @company-name)] Looks like it outputs everything into body. How to write meta tags?
If you want to render something into `<head>` you should do it as usual with any Reagent UI code. (reagent.core/render [header] (.-head js/document)) The above will render into `<head>`. There's also NPM package that allows rendering into `<head>` from within your app's UI tree react-helmet.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "clojurescript, reagent" }
How to create a DateTime nicely which is today at 23:00 I want a DateTime variable which is today (any given time of the day) at 23:00. There has simply got to be a cleaner way to do this because this reminds me too much of good ol' ASP.Classic... var startDate = DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:00:00"); Anyone?
var eleven = DateTime.Today.AddHours(23);
stackexchange-stackoverflow
{ "answer_score": 24, "question_score": 3, "tags": "c#" }
Showing that $\frac{x!}{x^{x}}$ tends to zero as x tends to infinity The question is pretty much in the title, I'm having difficulty formally showing that $\lim\limits _{x\to\infty}\frac{x!}{x^{x}}=0$ (despite intuitively it's fairly obvious). Thanks in advance for helping ;)
We have that $$n! \leq \frac{n^n}{2^n} \text{ for } n \geq 6$$ so $$\lim_{n \to \infty} \frac{n!}{n^n} \leq \lim_{n\to \infty} \frac{1}{2^n} = 0.$$ For $x \in \mathbb{R}$, we know that $\Gamma$ function is increasing for inputs $\geq 2$, so the limit still holds (assume $x > n \geq 6$): \begin{align} \Gamma(n) &= (n-1)! \\\ \Gamma(x) &\leq \Gamma(\lfloor x+1 \rfloor) = \lfloor x \rfloor! \end{align} so $$\lim_{x \to \infty} \frac{\Gamma(x+1)}{x^x} \leq \lim_{x \to \infty} \frac{\lfloor x+1 \rfloor!}{\lfloor x \rfloor^{\lfloor x \rfloor}} = \lim_{n \to \infty} \frac{(n+1)!}{n^n} \leq \lim_{n\to \infty} \frac{n+1}{2^n} = 0.$$ I hope this helps ;-) **Edit:** Fixed some minor issues, thanks to @julien for noticing.
stackexchange-math
{ "answer_score": 4, "question_score": 4, "tags": "real analysis, limits" }
Fire when ENTER key pressed in dialog When dialog opens I focus it with `$(this).parents( ...` and when ENTER key is pressed it should execude but it's not. How to execute it when ENTER key pressed? open: function() { $(this).parents('.ui-dialog-buttonpane button:eq(0)').focus(); $("#DIALOG2").keydown(function(event) { if (event.which == 13) { //EXECUTE! $(this).dialog("close"); ajax_usun(del_id); } }); } JSfiddle with example: (click on delete button and instaed of pressing buttons in dialog with mouse press enter - nothing happens) <
EDIT: I've found out the problem. show: 'scale', is causing the focus to not be applied, probably because it tries (and fails) to apply the focus when the "scale" effect is still running, then when scale effect is over, you have no focus on the button. Fiddle: < EDIT 2: DEFINITELY a JQuery Bug, i've tried all the 'show' possible settings, and it turned out that it works with: blind clip drop fold puff slide size pulsate while it breaks with: scale explode Just choose another one, and/or report this bug to JQuery developers...
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "jquery, jquery ui" }
Run a jQuery script from resource file of UserControl to the Client's Script Manager I have a User Control that have a global resource with a string value that is jQuery script. I want to run this script in client side, the scenario in my mind (actually in my project manager mind) is that 1-we need a http handler for pass value from resource to client 2-we need to check: is any script manager defined in client, if not throw an exception, we find this script manager by move in the parents of the user control until find page or master page, so search the controls of the page(or master page) and find script manager 3-we need a way for run the mentioned script to this script manager do you have any idea for this implementation? how can i do?
it's need to force clients to add **server's httphandler helper** to webConfig of owns.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "c#, javascript, jquery, asp.net" }
$1+\frac{x}{1!}+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots +\frac{x^n}{n!}$ I am looking this answer and maybe it's trivial but now can't understand one part of José Carlos Santos's answer. And if $n$ is odd, then $Q_{(n+1)}$ first decreases and then increases (it's trivial I know but I don't remember how can I proof that).
Note that$$Q_{n+1}'(x)=Q_n(x).$$So, if $n$ is odd, $Q_n$ has a single real root, at some point $x_0$. But, again because $n$ is odd, $\lim_{x\to\infty}Q_n(x)=\infty$ and $\lim_{x\to-\infty}Q_n(x)=-\infty$. So, $Q_n(x)<0$ if $x<x_0$ and $Q(x)>0$ if $x>x_0$. Therefore, $Q_{n+1}$ is decreasing on $(-\infty,x_0]$ and increasing on $[x_0,\infty)$.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "real analysis, calculus, analysis" }
Adding Features with PyQGIS? I'm new to PyQGIS and I'm having some dificulties. I'm trying to implement / utilize "Add Feature" (polyline) functionality in my python plugin. I know I can do this by defining starting and ending points. PyQGIS, construct a polyline: line_start = QgsPoint(50,50) line_end = QgsPoint(100,150) line = QgsGeometry.fromPolyline([line_start,line_end]) This is what I'm trying to avoid. I'd like user to digitize / create polyline by clicking on map canvas to preview geometry. How can I do that?
You can start an edit session on your line layer and activate the `Add Feature` tool by including this code in your plugin: layer = self.iface.activeLayer() # See the note below... layer.startEditing() self.iface.actionAddFeature().trigger() _NOTE: the way you access the line layer might differ in your case. You could, for instance,get the layer by name (if it's already loaded into QGIS) or even load it by yourself, providing a URI, name, and data provider._ If you want to save the edits made to the line layer also from your plugin, you can call: layer.commitChanges() On the other hand, if you want to revert any edit made on the layer since you called `startEditing()`, you can call: layer.rollBack() Hope it helps!
stackexchange-gis
{ "answer_score": 3, "question_score": 6, "tags": "pyqgis, qgis plugins" }
How does JavaScript's grouping operator work? How does JavaScript's grouping operator work? 1 + 2; (1 + 2); function(){ return 1} + "text"; // SyntaxError (function(){return 1} + "text"); Given the above code, I have the following questions: 1. Why does `1 + 2;` work without syntax error, whereas `function(){ return 1} + "text"` raises a SyntaxError? 2. How does the grouping operator in `(function(){return 1} + "text")` fix the syntax error?
When `function` is at the beginning of a statement, it's treated as the beginning of a named function definition, which should be like: function someName() { return 1; } This is a statement, not an expression, so it can't be used as part of a larger expression. In fact, it's not valid to have that statement without a name. You get a syntax error from: function() { return 1} all by itself. But when you put it after a parenthesis, it's not the beginning of a statement any more, so it's a function expression, which returns the function as a value. Then it can be used as a sub-expression in a larger expression. It's not the grouping operator that does it, just the fact that it's not at the beginning of the statement. For instance, you can also write: var foo = function() { return 1 } + "text";
stackexchange-stackoverflow
{ "answer_score": 29, "question_score": 20, "tags": "javascript" }
not order $2$ implies not conjugate. This is a question I had in exam I failed miserablly perhaps someone can find me a solution to this exercise. Let $G$ be a group and let $g\neq e$ be an element in $G$ such that its order is not $2$. It's given that in the conjugacy class of $g$ there's an odd finite number of elements. prove that $g$ is not conjugate to $g^{-1}$. Here's what I wrote: Suppose $a_1,\ldots,a_{2n+1}$ are elements in the conjugacy class of $g$, i.e there exists $h_i\in G$ such that:$a_i=h_igh_i^{-1}$.If one of them, say $a_1$ were $g^{-1}$ then we could write down: $g^{2n+1}=\prod_i h_i^{-1}a_ih_i$. But then how to get a contradiction?
The argument is essentially the same as in this question. Note that if $x$ is conjugate to $y$, then $x^{-1}$ is conjugate to $y^{-1}$, since $gxg^{-1}=y\iff gx^{-1}g^{-1} = y^{-1}$. Moreover, if $y$ is conjugate to $x$, then the orders of $x$ and $y$ are equal. So let $C$ be the conjugacy class of $x$. If $x^{-1}\in C$, then for every $y\in C$ we also have $y^{-1}\in C$ (since $y^{-1}\sim x^{-1}\sim x$). Morevoer, $y\neq y^{-1}$. Thus, the conjugacy class of $x$ is either infinite, or if finite then it has even order, since we can partition it into elements and their inverses. Contrapositively, if $C$ has a finite odd number of elements, then we cannot have $x^{-1}\in C$.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "abstract algebra, group theory" }
How to store property file keys into variables in a shell script after reading them If I have a given property file and a shell script. How do I store each and every key-value pair in a different variable? For example if I read the property file thing.properties that consists of: USERNAME = "Me" PASSWORD = "Secret" DB_NAME = "THINGDB" How do I store each of these keys in its own variable within the shell script labeled thingUSERNAME, thingPASSWORD etc. (Variable name can be anything as long is it contains some semblance of the file and the key) (Note this must be done in an sh file) Any input is appreciated
You can use `eval`. Just be careful with this command though. It can be devastating. Unfortunately unlike `bash`, `sh` does not support `declare`. $ cat property.txt USERNAME = "Me" PASSWORD = "Secret" DB_NAME = "THINGDB" $ cat shell.sh #!/bin/sh while IFS= read -r line; do key="${line%% =*}" value="${line#*= }" eval "$key"="$value" # For ash, dash, sh. # declare "$key"="$value" # For bash, other shells. done < property.txt echo "username: $USERNAME" echo "password: $PASSWORD" echo "db_name: $DB_NAME" $ ./shell.sh username: Me password: Secret db_name: THINGDB
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "shell, sh, properties file" }
Searching MySQL data I am trying to search MySQL database with a search key entered by the user. My data contain upper case and lower case. My question is how to make my search function not case sensitive. ex:data in mysql is BOOK but if the user enters book in search input. The result is not found....Thanks.. My search code $searchKey=$_POST['searchKey']; $searchKey=mysql_real_escape_string($searchKey); $result=mysql_query("SELECT * FROM product WHERE product_name like '%$searchKey%' ORDER BY product_id ",$connection);
Just uppercase the search string and compare it to the uppercase field. $searchKey= strtoupper($_POST['searchKey']); $searchKey=mysql_real_escape_string($searchKey); $result=mysql_query("SELECT * FROM product WHERE UPPER(product_name) like '%$searchKey%' ORDER BY product_id ",$connection);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "php, mysql, search" }
JSON.NET JArray IndexOf I have var array = new JArray(new string[] { "one", "two", "three" }); But `array.IndexOf(new JValue("one"))` returns `-1`, which means that no such item found. How to use `IndexOf` correctly to obtain index of element by value?
See this GitHub issue. Also, here is the linked stackoverflow question in the issue.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "c#, arrays, json, json.net" }
What's the right way to access Angular on the console (from devtools) in Angular 8? I'm running Angular 8. Following the probably outdated advice here -- How can I test an AngularJS service from the console?, I'm trying to access an Angular service from the Chrome devtools console. Below is the disappointing output Angular is running in the development mode. Call enableProdMode() to enable the production mode. injector = angular.element(document.body).injector() VM914:1 Uncaught ReferenceError: angular is not defined at <anonymous>:1:1 What's the right way to access Angular on the command line in Angular 8?
you can just save a reference of injector class globally _main.ts_ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; if (environment.production) { // production enableProdMode(); } else { // development const platform = platformBrowserDynamic(); window['injector'] = platform.injector; } Injector **Updated!!** onther option without store a reference of the injector globaly const inj = ng.probe(document.querySelector('app-root')).injector;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "angular, console, google chrome devtools, angular8" }
How to immediately detect a change on a collection of inputboxes For select boxes, checkboxes, and radio buttons, jQuery's change()-event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus. I got a form with multiple inputboxes and i'd like to do something as soon as the user changes the value of any of those inputboxes. Is there an event that is not deferred until the inputbox loses focus, but fires immediately when the user changes a value?
you can do something like binding multiple events: $("input[type='text']").bind("change blur keyup mousedown", function () { // your foobar here }); or only keys and mouses ;) $("input[type='text']").bind("keydown mousedown", function () { // your foobar here });
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "jquery" }
TypeError: drop() got multiple values for argument 'axis' when dropping multiple columns I have a dataframe called "tips" in which I am trying to drop two columns, `tip` and `higher_than_15pct_true`, as follows: X = tips.drop('tip','higher_than_15pct_True', axis = 1) This results in the following error: TypeError: drop() got multiple values for argument 'axis' How can I fix this?
According to the pandas documentation for `DataFrame.drop`, you need to pass either a single label, or a list if you have multiple columns: X = tips.drop(['tip','higher_than_15pct_True'], axis = 1) The `TypeError` unfortunately ends up being quite cryptic and unrelated to the real problem at hand.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "python 3.x, pandas" }
java class leve exception handling - catch exceptions of all methods in single place I have a Java exception handling design question . I have a Backing layer(java bean class) in my web app. I would like to catch the exceptions(RunTimeE) thrown by all the methods in a class in single place. My backing bean class extends the AbstractBackingBean class. Is there any way ,can i catch the exceptions from all the methods and log it in one place.
Yes. For a web application you can do that in a `Filter`: public void doFilter(..) { try { chain.doFilter(req, resp); } catch (Exception ex) { // do something } } If a filter is not an option for some reason, take a look at AOP. For example spring has good AOP support. It's similar to the filter approach, but you specify exactly which classes and methods you want to attach the handler to.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java" }
Context-switch and thread execution on different CPU cores From my another question on SO I found out that its possible that following simple method void B() { if (_complete) { Console.WriteLine (_answer); } } may be executed on different CPUs if context switch happens between if and console writeline call.. This is news to me so I am wondering now when can single thread code become switched for another CPU and why it may make sense in such simple case as above?
Basically, a context switch is the OS "freezing" a thread where it is, so that another thread can get some CPU time. When the first thread is "thawed", there's no requirement that it continue running on the CPU where it was previously running. That detail is up to the OS to decide. For example, if when the thread is thawed there is a full core that is unused which happens to differ from the previous core that the thread was running on, it would be wasteful not to use the free core.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "c#, .net, multithreading, context switch, memory barriers" }
Linear algebra - reflection matrix of vectors of the same length I would appreciate a hint for a question I have been struggling with for the last couple of days. Let $v, w \in R^2$, and assume $||v||=||w||$. Prove that there is only one reflection matrix that fulfills $Av=w$. I’ve been trying to use the fact that $u+v$ and $u-v$ are orthogonal because $<u+v, u-v> = 0$ since $v$ and $u$ are from the same length and then look at $A(v+w)$ but that did not lead me anywhere.
**Hint:** Indeed, $v+w$ and $v-w$ are orthogonal and non-zero, which means that they form a basis of $\Bbb R^2$. If it is known what a linear transformation does to each element of a basis, then the linear transformation is completely determined (i.e. there is only one possible matrix for the transformation). Now, what should the reflection do to the vector $v+w$? What should the reflection do to $v-w$? Try to figure out how the line across which the transformation should reflect is related to $v+w$ or $v-w$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "matrices, vectors, reflection" }
"ConfigurationBuilder" no contiene una definición para "SetBasePath" ni un método de extensión accesible Tengo este error al tratar de colocar onconfiguring en el dbcontext de mi aplicación que usa CodeFirst protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { IConfigurationRoot configuration = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("appsettings.json") .Build(); optionsBuilder.UseSqlServer(configuration.GetConnectionString("MotrCompnyConn")); } } ya He cambiado el path a Directory.GetCurrentDirectory(), no se cual es el posible error. Estoy Usando DotNet Core 3.14
Simplemente es agregar la librería adicional al **using Microsoft.Extensions.Configuration;** con nugget se busca Microsoft.Extensions.Configuration.Json; se instala y desaparece el error * Tener en cuenta que en core 2.x no aparece * se debe seleccionar el proyecto de clase en mi caso es infraestructura.Data
stackexchange-es_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "asp.net, .net core, entity framework core" }
scaling a circular shape while keeping its thickness I have this circular shape: !original object I need to duplicate it and scale it, in order to have a copy of it, with the same thickness, just with a bigger radius. Using duplicate and scale (using the 3D cursor as center) the result looks like that: !after duplication and scaling As you can see the external one is much thicker, because the thickness was scaled as well, is there a simple way to have the second one as thick as the first one?
Add a curve with desired shape and set its orgin point as shown below. Then add the one segment of the model in the same place where the curve origin point is. Add the _Curve_ and _Array Modifiers_ to the model segment. Set the proper array count. !enter image description here Now scaling the curve and increasing the array count, you have a bigger object while keeping its thickness. !enter image description here
stackexchange-blender
{ "answer_score": 8, "question_score": 6, "tags": "modeling" }
Communicating with a Raspberry Pi that is underwater ? Is there a way, that I can communicate with a Raspberry Pi, that is underwater. The depth of the Raspberry Pi will be about 20 meters or less. I was thinking of using Bluetooth, or 433Hz RF Transmitter or other such sensors, but I am not too sure, if they will work. My goal is to have a transmitter and receiver with the Raspberry Pi, and I will have a controller that has transmitter and receiver as well, but I am not sure what transmitters and receivers, or if any, will work on the Raspberry Pi.
A good General rule of thumb, is if it will work on an Arduino Due or Zero (those are the 3.3 volt Arduinos I know of), it will work with a Pi. Another solution is, if the Pi is tethered for power or something else, is to run a physical cable carrying whatever you need transmitted.
stackexchange-raspberrypi
{ "answer_score": 2, "question_score": 1, "tags": "sensor" }
Can I use a jail broken device for iPhone app development > **Possible Duplicate:** > can Jailbroken iphone used for development For example, testing in app purchase, game centre, icloud or notification. Anyone have tested and verified if it work? Thanks.
I had tried to call server data from the app in Jail Broken device. I am not able to call webservices from it. It always display error. On other had application is working fine in factory unlock device.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "iphone, ios, xcode, ipad, jailbreak" }
Is there a difference between forces due to pressure differentials and collision? Imagine moving at a constant speed a flat object straight through a fluid: it could be a paddle in the water, the wing of a plane in the air or a sail. Ignoring whatever pushes the object at its constant speed, with my shaky, at best, understanding of physics I think there are two forces that are applied to the object: one from the collision with the fluid (equal and opposite reaction and all that) and one arising from the pressure differential in front and behind of the object. Are the two just the same thing (from conservation of momentum?) or do they differ? And if they differ, which is usually bigger?
They are the same. There is always at least a static pressure acting on the wings. This is the case for any object in a fluid. This is what leads to buoyancy for example. When you begin to move in the fluid; things change as the relative movement between the fluid and the surface you examine now becomes a factor. The object that you send through the fluid now has different pressures acting on it; because the air is now not just static; but able to "hit" the surface (and these will vary based on the geometry of the object). These interactions will also cause a change in the momentum of the air; and of the object itself. Basically, we design wings to push air the opposite direction we want our objects momentum; and the force of that generated momentum manifests itself as pressure gradients across the surface.
stackexchange-physics
{ "answer_score": 1, "question_score": 1, "tags": "everyday life" }
Driving on Tikz in Texmaker My LaTex distribution is MikTeX 2.9 and I am using TeXmaker. The LaTeX has been installed successfully and I have the deserving output for such test: \documentclass[]{article} \usepackage{amsmath} \begin{document} Matinking \begin{equation} \phi + \psi = \chi \end{equation} \end{document} But the problem is that there is no `TikZ` library within my distribution as I check the `package Manager (Admin)`... Even after the trying to find new updates, there is no `TikZ` among the offers. I just tried to add `\usepackage{tikz}` to above code but a message box containing below error will be appeared: The file required: tex\latex\ms\everyshi.sty is missing. It is part of the following packege: ms The odd thing is that there is even no `ms` package among update offers! How would I handle this?!... Thanks in advance
The weird error just resolved by re-installing some packages: ms + xcolor + mptopdf Actually, update was not a cure for the problem, but the re-installing above target packages, could which be taken as prerequisites of `TikZ` into account, removed the issue. Now calling `\usepackage{tikz}` is possible, safely.
stackexchange-tex
{ "answer_score": 2, "question_score": 1, "tags": "tikz pgf, texmaker" }
How to send UDP datagram to different network in java? I have made an UDP client server program in java. It is working well in localhost and in the same router/ network. But when I am running my UDP server program in my laptop connected to internet and running my UDP client program in my lab (on different network), then it is not working. Is there any way to send UDP datagram over the network from one system to another?
Yes, in theory it should be working just the same. It's still IP. In reality, routers with NAT exist. For example, if you address an UDP packet to your home PC's public IP address, it actually is addressed at your router. The router does not know which local IP he should address the packet to and discards the packet. The solution: Configure UDP port forwardings for routers on both ends.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "udp" }
てもいいですか vs. causative verb + もらってもいいですか > **** I know that _causative verb form + _ means to let somebody do something. And is for asking for permission. But I don't quite understand the use of these 2 constructions together. If I wanted to ask someone to let me use their phone, I would possibly say: > How are the meanings of the two sentences different? Is "" just more polite?
- May I do(To Grant Permission) causative form + - Would you Please let me do(To seek permission)
stackexchange-japanese
{ "answer_score": 0, "question_score": 4, "tags": "grammar" }
Emacs can't load swi-prolog with default prolog-mode? My Gnu Emacs 24.4 on Win 8 can't seem to work with it's default prolog mode. I have the latest version of SWI Prolog. When I load Gnu Emacs and type in Mx prolog-mode, the syntax gets highlighted. However, I am not able to compile the rules, or do anything with them. When I try to run prolog from inside Emacs using Cc RET, it says "Searching for program: no such file or directory, prolog".
The error message tells you that Emacs couldn't find any executable with name `prolog` in `load-path`. So presumably the problem is that you haven't put your installation of SWI-Prolog into your `$PATH`. An alternative to setting $PATH in your environment (or `load-path` in your `~/.emacs`) is to set `prolog-program-name` in your `~/.emacs`.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "emacs, prolog, swi prolog, emacs24" }
Android google maps API v2 route like in google maps app I am making an android app, and I want to show a route to the user, but if I create it via map.addPolyline(new PolylineOptions(...)); it looks terrible. Just a solid line. How do Google draws its gradient route line with borders? Is it possible for other developers to draw this route line?
You may try using `TileOverlay`, but it would be a bit more work to generate. Draw portions of the route into `Bitmap`s and convert them to `byte[]` pngs or jpegs.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android, google maps, google maps android api 2" }
Use Last Used DevExpress Style I'm looking to have a setting feature or something of the sort that will by default use the last selected style. Example: Form has the new application style gallery in the ribbon. When the user selects the style they want, and close out the application it will stay. So when they open it up the next time it will use the style selected when last opened. I have absolutely no idea on how to go about doing this.
We have published an example showing how this can be done at: How to save a skin name applied to an application to be able to apply it at the next application run?
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, coding style, settings, devexpress" }
How can I add space before my unit vectors? This is how I'm currently typesetting vectors: \documentclass{article} \newcommand{\ih}{\mathbf{i}} \newcommand{\jh}{\mathbf{j}} \newcommand{\kh}{\mathbf{k}} \begin{document} $1/z \ih + \jh - y/z^2 \kh$ \end{document} This gives me: ![]( I think the unit vectors are too close to the expressions they follow. But if I place a `\,` in the definitions of the commands, extra spacing will also be added before the **j** -component here, which would look odd. What is the best way to add more spacing, preferably by changing the definitions of my unit vectors?
It's a similar situation as for the differential symbol in integrals: \documentclass{article} % avoid code duplication \newcommand{\unitvector}[1]{% \mathop{}\!\mathbf{#1}% } \newcommand{\ih}{\unitvector{i}} \newcommand{\jh}{\unitvector{j}} \newcommand{\kh}{\unitvector{k}} \begin{document} $1/z \ih + \jh - y/z^2 \kh$ $(a+b)\ih + (a+b)\jh$ \end{document} !enter image description here
stackexchange-tex
{ "answer_score": 8, "question_score": 7, "tags": "math mode, spacing, vector" }
Get an email when there is activity on a question? Is it possible to get an email when there is any activity on a question I have posted, commented, or answered? I only see a message on the Stack Overflow site itself. I would like to be notified too.
I was initially in favour, but have reflected for a while and I think it's a bad idea: It allows people to post a drive-by question and then suck up the answers without returning. I got hooked on SO because I simply couldn't find an answer to my question but was sure there was one. Returning to check progress lured me in; I spotted some questions I could answer, and my reputation went up. Now I've given hours and hours to help people on a site which helped me. Email updates wouldn't have drawn me in - I'd have been able to stay away in between notifications, and the excitement of checking would be absent. Drive-by questions upset established users. Providing email updates would be handing a syphon to help vampires. The RSS feed Frédéric mentions is fine, because it's not in the nature of drive-by questioners to invest time setting up a subscription, whereas a tickbox to send updates would be very easy.
stackexchange-meta
{ "answer_score": 8, "question_score": -3, "tags": "feature request, questions, email notification" }
jre_home environment variable is not defined correctly while starting tomcat When I am trying to run tomcat using `startup.bat` I get the following error, The JRE_HOME environment variable is not defined correctly This environment variable is needed to run this program I have even tried setting JRE_HOME manually to system variable list, but this issue remains. My `JRE_HOME C:\Program Files\Java\jre1.8.0_121;` What can I do to solve it? I am using Windows 8
Hope you know the way of setting path in Windows 8. // **C:\Program Files\Java\jre1.8.0_121 surely as there is space between Program and Files, these kind of errors are possible. Please correct this path or store this in a path where no space is involved.** In Path add JRE_HOME path and click ok Reopen Command prompt window, then again give startup.bat Hope this helps
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "java, tomcat" }
Copy-Item not working as expected I cant figure out what I am doing wrong with this command and would like another set of eyes to point it out. I want to copy the directory structure but not the files the structure contains. Copy-Item -recurse -exclude *.* -path \\server1\z$\backups\ -destination \\server2\z$\ -Verbose The command runs but it copys files despite telling it not to copy files. How do i copy the directory tree and not the files?
Try this. `copy-item -path "\\server1\z$\backups\" -Destination "\\server2\z$\" -Filter {$_.PSIsContainer -eq $True} -recurse`
stackexchange-serverfault
{ "answer_score": 1, "question_score": 2, "tags": "windows server 2003, powershell" }
Using cask and then brew install I am trying to install gulp - which seems to require first cask: 17:14:34/mozaik-demo $brew install gulp Error: No available formula for gulp Searching formulae... Searching taps... Caskroom/cask/gulp Let us install the cask: 17:14:41/mozaik-demo $brew cask install gulp ==> Downloading ######################################################################## 100.0% ==> Symlinking App 'gulp.app' to '/Users/steve/Applications/gulp.app' gulp staged at '/opt/homebrew-cask/Caskroom/gulp/0.1.0' (830 files, 75M) But then what is the correct next step? Here is my attempt: 17:15:03/mozaik-demo $brew install gulp Error: No available formula for gulp Searching formulae... Searching taps... Caskroom/cask/gulp 17:15:09/mozaik-demo $which gulp
You don't need to do `brew install gulp` after `brew cask install gulp`. Once `brew cask install gulp` end, you have your app installed on `/Users/steve/Applications/gulp.app`, you don't need any extra steps.
stackexchange-apple
{ "answer_score": 2, "question_score": 1, "tags": "homebrew" }
SQL Server email function invalid syntax I have this `sp_send_dbmail` script. The error log shows "invalid syntax error". EXEC msdb.dbo.sp_send_dbmail @profile_name = 'PROFILE_NAME', @recipients = '[email protected]', @subject = ' Search for empty ID result ', @query = ' select * from [dbo].[TT_INCI] tt where tt.ts_caseid =''(Auto)'' ', @attach_query_result_as_file = 0 Please help
You need to speficy the database where the table is: EXEC msdb.dbo.sp_send_dbmail @profile_name = 'DBProfile', @recipients = '[email protected]', @subject = ' Search for empty ID result ', @query = ' select * from [SomeDatabase].[dbo].[TT_INCI] tt where tt.ts_caseid =''(Auto)'' ', @attach_query_result_as_file = 0 The error message is a bit misleading.
stackexchange-dba
{ "answer_score": 2, "question_score": 1, "tags": "sql server" }
Infinite series from Robert Bartle's book I need help solving this exercise about infinite series from Robert Bartle's "Elements of real analysis" book. > Let $x_{n}>0$ for $n \in \mathbb{N}$ and suppose that $n\left( 1-\frac{x_{n+1}}{x_{n}} \right)=a+\frac{k_{n}}{n^{p}}$ where $p>0$ and $k_{n}$ is bounded. Then the series $ \sum_n x_{n}$ converges if $a> 1$ and diverges if $ a<1 $.
One has $$ \frac{x_{n+1}}{x_n} = 1 - \frac{a}{n} + \frac{k_n}{n^{p+1}} = 1 - \frac{a}{n} + O \left( \frac{1}{n^{p+1}}\right)$$ Let's define $v_n = n^a x_n$. One has $$\frac{v_{n+1}}{v_n} = \left( 1 + \frac{1}{n}\right)^a \frac{x_{n+1}}{x_n} = \left( 1 + \frac{1}{n}\right)^a \left( 1 - \frac{a}{n} + O \left( \frac{1}{n^{p+1}}\right)\right)$$ $$=\left( 1 + \frac{a}{n} + O \left( \frac{1}{n^2}\right)\right) \left( 1 - \frac{a}{n} + O \left( \frac{1}{n^{p+1}}\right)\right) =1 + O \left( \frac{1}{n^{\gamma}}\right)$$ where $\gamma = \min \left( 2, p+1\right) > 1$. So $$\ln \left( \frac{v_{n+1}}{v_n}\right) = O \left( \frac{1}{n^{\gamma}}\right)$$ So the series $\ln \left( \frac{v_{n+1}}{v_n}\right)$ converges, so the sequence $(\ln (v_n))$ converges, so the sequence $(v_n)$ converges : denoting $K = \lim v_n$, you get directly $$u_n \sim \frac{K}{n^a}$$ which gives you the desired results.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "real analysis, convergence divergence, divergent series" }
Cutting of DNA strand Would EcoRI cut the following sequence?? 5'CTCGAGTTCGAG3' 3'GAGCTCAAGCTC5' What is the logic of cutting? Please explain how restriction enzymes work.
No, it will not cut it, because EcoRI recognizes the following palindromic sequence: GAATTC, and only if the whole sequence is present it will cut it at particular site. You can find these information for all restriction enzymes at sites of the providers, for example at New England Biolabs site < , just enter the name of the enzyme you are interested in.
stackexchange-biology
{ "answer_score": 0, "question_score": -2, "tags": "molecular biology, dna sequencing, restriction enzymes" }
OleDb Connection not reading all the rows from excel file I am using an OleDb in C# connection to read data from an Excel sheet. And fill it in a Datatable. The sheet contains 275 rows and 27 columns. After I read it, Rows 1,2 and 3 are empty. All the other rows are filled correctly. Anyone have an idea on the problem? Here is my code: string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + "C:/Sheets/DataSheet.xls" + ";Extended Properties=Excel 12.0;"; objConn = new OleDbConnection(connString); string Query = "SELECT * FROM [Sheet1$]"; OleDbCommand objCmd = new OleDbCommand(Query, objConn); DataTable Table = new DataTable(); objAdapter1.SelectCommand = objCmd; objAdapter1.Fill(Table);
The problem was that my sheet contained mixed data and it was only reading numbers. The solution is to specify Properties=\"Excel 12.0;IMEX=1\";" IMEX=1 allow the reader to import all data not only numbers
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "c#, excel, connection string, oledb, oledbconnection" }
Integration of $\log z$ in complex analysis Let $u(w)$ be a compact support, real valued, smooth function on $\mathbb C$(hence also on $\mathbb R^2$), can we define $\eta(z) = \int_{\mathbb {R^2}} \log(|z-w|) \, u(w) \, \mathrm{d}x \mathrm{d}y $ for all $z\in \mathbb C$? When $w=z$, $\log(0)=- \infty$, so the inside of $\eta(z)$ has a singularity, but it seems to me $\eta$ is well defined when reading my notes.
Since $u$ has compact support and is bounded, it suffices to show that $$ \int_{B_1(w)} \lvert \log |z-w| \rvert \, dxdy $$ is finite, where $B_1(w)$ is the ball with center $w$ and radius $1$. With polar coordinates $z = w + re^{i \varphi}$ this becomes $$ \int_{0}^{2\pi} \int_0^1 \lvert \log r \rvert r \, dr \, d\varphi = \- 2 \pi \int_0^1 r \, \log r \, dr $$ and that is finite because $r \, \log r$ has a finite limit at $r=0$, i.e. it can be extended to a continuous function on $[0, 1]$.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "complex analysis, complex integration" }
With what to replace WinForms Application.DoEvents() in a C# class library? I have an ActiveX control ("rumba" in my code) that connects to a mainframe. The code below works in WinForms, but I want to put the code in a class library project. With what do I replace Application.DoEvents()? I tried putting Thread.Sleep or just deleting the row but then rumba only starts to connect when the while cycle is done. Here is my code: public bool Connect(int timeOutInSeconds = 5) { DateTime limit = DateTime.Now.AddSeconds(timeOutInSeconds); rumba.Connect(); while (DateTime.Now < limit) { string s = GetCurrentScreenAsText(); s = s.Replace("\0", null); if (!string.IsNullOrWhiteSpace(s)) return true; Application.DoEvents(); } return false; }
1. If you really want to use it, you can always include system.windows.forms.dll to your project. 2, the only reason you call Application.DoEvent is allowing the application to handle other events when your event is processing. Hence, you want to wrap your event in a separate thread such as using a BackgroundWorker or a Thread object to emulate an async call. In WPF, there is a Dispatch you can invoke or beginInvoke to execute a method asynchronously.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#" }
ReactJS and JSX - can I have uncontrolled checkbox? In React I can have uncontrolled text inputs by using `defaultValue` property. However, there is no such property for checkboxes (there is only `checked`, which makes it controlled). I have a huge form with lots of checkboxes, but user can't change them! Probably I can use two-way data binding mixin, but docs suggest not to use them, so I'm stuck.
Use `defaultChecked` Reference: <
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 7, "tags": "reactjs" }
How to open Nautilus in a specified directory from the command line? In Microsoft Windows I'm used to being able to type `Win`+`R`, then `C:\Temp`, and that will open up the file explorer in the directory specified. Is there a similar way to navigate to a folder in Ubuntu (16.04)?
`Alt`+`F2` or `Fn`+`Alt`+`F2` is the key combination you are looking for. To open any window just specify the location as shown below in screenshot. ![enter image description here]( This method is very quick as it gives suggestions also. When I type `Do` it give suggestion for `Documents` and `Downloads` (see screenshot) **EDIT** : **Another useful method to quickly excess file and folders** Use `super` \+ `F` ![enter image description here]( This will show you frequently and recently used files and folders. Just type the few starting words of your file/folder and it will show you that file/folder and then hit `enter` to open the file/folder. These two methods will greatly save your time and make you more efficient.
stackexchange-askubuntu
{ "answer_score": 13, "question_score": 10, "tags": "nautilus, directory" }
What is a "亲传弟子" and how would you say it in English? > I'm not sure how to say it words, but I believe that they are disciples that get things personally passed down by their master and they have a very close relationship with them. However, is there any specific word that can describe it in English? EDIT: In terms of Chinese Wuxia novels.
How about "Direct Disciple", I remember that's how people used to describe my Wushu Master.
stackexchange-chinese
{ "answer_score": 2, "question_score": 2, "tags": "translation, meaning" }
Strip Numbers From String in Python Is there an efficient way to strip out numbers from a string in python? Using nltk or base python? Thanks, Ben
Yes, you can use a regular expression for this: import re output = re.sub(r'\d+', '', '123hello 456world') print output # 'hello world'
stackexchange-stackoverflow
{ "answer_score": 37, "question_score": 11, "tags": "python, nltk" }
Starting a 'For Each As DataGridViewRow' at a specific Row Currently I have a function that searches through every row in my DataGridView and looks like so. For Each row As DataGridViewRow In DataGridView1.Rows Next However due to an issue caused by something else I need to make it start the For Each Row at a specific row. I've tried "For Each row As DataGridViewRow In DataGridView1.Rows.IndexOf(RowToStartAt)" However this appears to be the wrong method to use. Is what I'm trying to do actually possible or not? Or have I just tried to use the wrong method?
You could use this kind of syntax For Each row in dgv.Rows.Cast(Of DataGridViewRow)().Skip(5) Console.WriteLine(row.Cells(0).Value.ToString()) Next In this example the loops skips the first 5 rows and then starts its enumeration Not sure if this is really beneficial or not. A traditional for ... loop is probably more clearer but as Linq goes this achieve the result required.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "vb.net, datagridview, datatable" }
Find users with unchanged passwords? I recently added a bunch of users and gave them randomly generated passwords. We've since instructed them to change their passwords, but we suspect that a large number of them have not. How can we expire the passwords of everyone who hasn't changed their password yet? We're on Ubuntu 9.04 server using normal /etc/passwd authentication.
You can use the chage command to see the last time they changed their password, for example: sudo chage -l kbrandt You can mix that with a loop and awk of the /etc/passwd file, might be a better way though. Maybe something like: while read line; do date_change=$(echo $line | awk -F: '{print $3}') user=$(echo $line | awk -F: '{print $1}') #Say you set them on 14120 days since Jan 1, 1970 if [[ $date_change -eq 14120 ]]; then #chage command to set warning and password expiration for $user fi done < /etc/shadow
stackexchange-serverfault
{ "answer_score": 4, "question_score": 3, "tags": "ubuntu, user management, password" }
facebook login by activity 1 and send post to fb wall by activity 2 i am making an android app which is using Facebook to post status to wall.Integration part is done.I am using Facebook sdk 3.0. My UI is **Tab layout** :1st Tab is Home.2nd Tab is settings.(two activities) Firstly in 2nd tab, i have Facebook Login Button,through which i log in and log out.(same button) Then in 1st tab,I have postButton,though which i post a status to facebook profile. I have checked lots of tutorials.But i am not getting any answers related to this.Morevoer all tutorials are having all the workings in single activity,which i don't want. Please can anyone help with my scenario. **Login in one activity and send post to fb wall by second activity** Thanks in advance.
It's much easier under Facebook 3.0 since you have the Session object. You can call the static `Session.getActiveSession()` in any activity, then you should make sure the session is open and ready with the required permissions (easily achieved) and publish whatever you want (or open the session and/or request publish permissions).
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "java, android, facebook" }
How to understand OR operator in a PHP statement I have a below PHP statement: if( (bool)is_check1($a) || (bool)is_check2($a) || (bool)is_check3($a) ){ callFunctionA(); } I have debugged and got a news thing so strange that, even if `is_check1` returns `TRUE`, PHP still invoke the functions: `is_check2`, and `is_check3`. In my mind, I always think that, if `is_check1` function returns TRUE, `PHP` SHOULD not invoke others. But when I check it again, for example: if( TRUE || (bool)is_check2($a) || (bool)is_check3($a) ){ callFunctionA(); } The result is: `is_check2` and `is_check3` function do not invoke. Please give me your advice to optimize in this case or am I missing something?
Attempting to reproduce with the following code: function a() { echo 'a'; return true; } function b() { echo 'b'; return true; } function c() { echo 'c'; return true; } if (a() || b() || c()) echo 'valid!'; if (true || b() || c()) echo 'valid!'; if ((bool)a() || (bool)b() || (bool)c()) echo 'valid!'; Prints: `avalid!valid!avalid!` That means the problem is probably the return values of your functions.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "php, expression" }
C# Winforms how to get text from Datagridview to a label based on another cell on the same row? I'm looking for an answer to the following: Here is my DataGridView: DataGridView The imported data updates every 5 minutes, which changes the row count and order. How can I get the data of one cell based on another cell which is on the same row? E.g. in the picture, I want to get the "raw_text" cell to be displayed on a label. To get that correct cell, I need to check that "station_id" is "AGGH", and then get all info from that row to different labels. I have tried this: labelmetar.Text = dataGridView1.Rows[1].Cells["raw_text"].Value as string; but the rows keep changing all the time, so it's not possible. Instead of row number (`.Rows[1]`...), it should ask "row where station_id equals AGGH". How can I do that? Any advice? Thanks a lot!
foreach (DataGridViewRow dgvRow in dataGridView1.Rows) { if (dgvRow.Cells["station_id"].Value.ToString() == "AGGH") { string rawText = dgvRow.Cells["raw_text"].Value.ToString(); } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "c#, datagridview" }
QLPreviewController with Core Data as data source I am trying to preview common files by using `QLPreviewController`. The files I have stored are stored in `Core Data`. The problem is that `QLPreviewController` asks for a URL to the file, which I don't have. Is there a way of combining `QLPreviewController` with `Core Data`? The files I have are stored in the database itself, but with `Allow external storage` checked, so some files might be stored separately.
It is better to store the path of binary data in core data. This link explains well. Storing images in Core Data or as file? Hope it is helpful.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, core data, qlpreviewcontroller" }
INSERT IGNORE when key is auto_incremented? I have a very basic table, consisting of an auto_incrementing id column (primary key), and a TEXT column containing some various text. I need to insert data into this table, but I don't want to insert duplicate rows. I thought using `INSERT IGNORE INTO` but apparently the `IGNORE` uses the table's key to determine if the row is a duplicate or not. Since the key field in my table is auto incrementing, that means a duplicate will never appear to show up. Is there a better approach to my table design? Does the TEXT column need to be a key also?
Make an UNIQUE index for your TEXT column : errors will be ignored. See <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mysql" }
Do JSON-Web Tokens (JWTs) cover both authentication and authorization? I am researching on how to create a blog website that allows a user to sign in and based on his/her user role they can edit blogs, delete blogs, etc. but only if they are the user that created that certain blog. However, another user can sign in and if he/she does not own a certain blog, they can only view the blog and not edit or delete. Before I dive deep into this project, I was wondering if JWTs would, by itself, be able to accomplish this mission or is there a better technology for this functionality? Thanks!
Store user's role in your database and while generation fresh jwt for user set key/value pair describing user's role. That's it for role based Authorization using jwt. This is nice short post related to role based Authorization using jwt
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, node.js, reactjs, jwt" }
PHP - URL variables that look like pages `/POSTID/` I'm new to websites with databases and was wondering how to make a url look like ` rather than ` I had an idea of forwarding the page to a 404 PHP script, so `/H34d2b` doesn't exist but the 404.php could read the url and display the content; but this seems a bit messy and would like to check if there is a better way other than what I am about to do. I tried searching for this but I don't know how else to search for this other than `url variables` and I keep getting `?v=` \- which is not a format I'd like.
If you're using Apache or a compatible web server you need to use: mod_rewrite - <
stackexchange-webmasters
{ "answer_score": 1, "question_score": 2, "tags": "php, url" }
Get addition of tow time in sql server 2008 I want to get Addition with tow time. Start Time - 08:30:00 Addition Time - 04:45:00 i want to get New Time - 13:15:00 How can i do that in sql server 2008. Thank you.
Try this: declare @start datetime = '08:30:00' declare @add datetime = '04:45:00' declare @result varchar(10) select @result = substring(convert(varchar(24), convert(datetime, @start+@add, 121), 121),12,8) If your start and added times are not `datetime` values, you need to cast them accordingly first.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sql, sql server, sql server 2008" }
MySQL : how to split text and number with "-" I would like to rewrite a number of user id which is splited by "-" between text and number. For example: * KT-12345 * BA-98765 * CC-98765 * ITA-87987 From a huge amount of data which is mixed up with text and number. For example: * KT98798 * CC94788 * BB87600 So the question is : I would like to make the user id from the 2nd examples into the first one. How to achieve it in MySQL. Please suggest.
SELECT CASE WHEN floor(substr(name, 3,1)) > 0 THEN CONCAT_WS('-', SUBSTRING(name, 1, 2), SUBSTRING(name, 3, LENGTH(name))) ELSE CONCAT_WS('-', SUBSTRING(name, 1, 3), SUBSTRING(name, 4, LENGTH(name))) END AS new_name FROM test
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "mysql, sql" }
No HTML email after installing Enigmail in Thunderbird 3.1.10 I am running Thunderbird 3.1.10 on Mac OS X 10.6.7, and have just installed GnuPG and Enigmail extensions per the official website's instructions. Unfortunately, all the emails I receive now are all in plain text, including the HTML emails. What setting can I change to make HTML emails I receive display correctly again? Thanks.
Perhaps it is a couple of settings in T-Bird and maybe Firefox? The 2nd post in this forums spells it out: > In Firefox, go to View menu, select Page Style, and make sure "Basic Page Style" is selected, NOT "No Style". > > In Thunderbird, you'd go to View menu, select Message Body As and make sure "Original HTML" is selected. > > These are changes Enigmail ask you if you want it to make during the Setup Wizard process. <
stackexchange-superuser
{ "answer_score": 4, "question_score": 3, "tags": "mac, thunderbird, html, gnupg, enigmail" }
Microscopic definition/expression of/for the heat current Often I see the following microscopic definition/expression of/for a heat current due to an external field $$ {\bf j}_Q = 2 \int \frac{\text{d}{\bf k}}{(2\pi)^3} \frac{\hbar {\bf k}}{m} (\epsilon_{{\bf k}} -\mu) f(\epsilon_{{\bf k}}), $$ where $f$ is the solution the the appropriate Boltzmann equation. Note that the factor of two is there for the spin of electrons. I do not really understand where this expression comes from. Especially the factor $(\epsilon_{{\bf k}} -\mu) $ bothers me. Does it tell us that only electrons near the Fermi level contribute to the heat current? Or does it have another meaning?
Let us decompose the formula to better understand what it means: * $\hbar \mathbf k/m$ is the velocity of the electrons * $\epsilon_k - \mu$ is the energy relative to the temperature, so if particles with higher energy than the temperature move in a direction, they produce a positive thermal energy flux, particles with lower energy an negative flux. * $f(\epsilon_k)$ tells who many particles are in this state. That only electrons near the Fermi level contribute has nothing to do with $(\epsilon_k - \mu)$. This states that particles with energy near the chemical potential $\mu$ contribute only little, as this term is small. The fact that (at least for temperatures $k_BT \ll E_F$) the electrons near the Fermi energy contribute to this flux, is due to the fact that those are the most mobile one. Higher energy levels are mostly empty, therefore not contributing, and lower energy levels are completely full, therefore the integral vanishes, and they don't contribute ether.
stackexchange-physics
{ "answer_score": 3, "question_score": 2, "tags": "statistical mechanics, solid state physics" }
How to recode a variable into another variable I am trying to recode the following variable: str(dades$Edat) num [1:30000] 24 26 34 37 57 37 29 23 28 35 ... Into this: agrupar.edat<-function(x){ for (i in 1:length(x)){ if (x[i]>=21 & x[i]<30) {x[i]<-'1'} else if (x[i]>=30 & x[i]<40) {x[i]<-'2'} else if (x[i]>=40 & x[i]<50) {x[i]<-'3'} else if (x[i]>=50 & x[i]<60) {x[i]<-'4'} else if (x[i]>=60 & x[i]<70) {x[i]<-'5'} else if (x[i]>=70 & x[i]<80) {x[i]<-'6'} } So I can put the results here: edx<-agrupar.edat(dades$Edat) But something is not working and edx keeps returning me "NULL"
**Problem 1.** Your function has no `return` argument. As a result, it reads that way: agrupar.edat<-function(x){ # do stuff # good bye } … so logically enough, nothing (`NULL`) comes out of it. Try simply adding `return(1)` at the end, just before the closing bracket, and magic will happen. Note, however, that your problem does _not_ require a function. It requires… **Problem 2.** … using `cut`, as @akrun's comment instructs you to do.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "r, recode" }
Moving parentheses vertically I have this equation: ![enter image description here]( \[ \text{solve}\left(10^{\displaystyle 0.78478 \cdot\left(\log \left(\frac{m}{173.961}\right)\right)^{2}}=1.2,m\right)\triangleright m=83.7164 \] As you can probably see, there is a row of empty space at the bottom of the bracket, which makes the brackets unnecessarily large. I was wondering if it is possible to either make the brackets more fitting, or move them up a little, which would make the space even on the top and at the bottom. A possible solution could also be to move everything but the brackets down a notch. However, if this is done, it would still be essential for the rest of the text to be aligned with the things inside the brackets. If anyone has an alternative solution that would look better, feel free to send that also! :)
Here you are, with `pmatrix`. I added a better-looking variant, with medium-sized exponents: \documentclass{article} \usepackage{amsmath, nccmath} \begin{document} \begin{align*} & \text{solve}\raisebox{1.5ex}{$ \begin{pmatrix}10^{\displaystyle 0.78478 \cdot\left(\log \left(\frac{m}{173.961}\right)\right)^{\!2}}=1.2,m\end{pmatrix} $}\triangleright m=83.7164 \\[2ex] & \text{solve}\raisebox{1.05ex}{$ \begin{pmatrix}10^{\medmath{0.78478 \cdot\left(\log \left(\frac{m}{173.961}\right)\right)^{\!2}}}=1.2,m\end{pmatrix} $}\triangleright m=83.7164 \end{align*} \end{document} ![enter image description here](
stackexchange-tex
{ "answer_score": 7, "question_score": 6, "tags": "math mode" }
Live Linux Distro for text only mode I'm looking for a linux distro where I can boot into it via USB, run a script on startup and shutdown. I need bare minimum, but I also need network drivers. Also need to save files across reboots. I've looked into DamnSmallLinux with networking. Are there any other options? Fastest boot is preferred. I don't need mouse, sound, etc. Bare minimum for fast booting. To save files across reboots, should I create a USB with two partitions and save to the non OS partition? I would have to mount this partition in the OS?
< the best compromise that i know between a tiny distribution and an usable and compact system.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "linux, text, live, mode, cd" }
How can I replace left CSS attribute (set in .css file) with right CSS attribute dynamically? I am working with a pre-existing javascript plugin (a slider) that aligns one of it's internal elements (navigation icons) with "left:50px". Under very specific circumstances, I want to align this to the right, using "right:50px" instead. The problem is that when I add "right:50px" to it inline, the right property is still over-ruled by the pre-existing "left:50px" property that is set in the plugin's .css file. I have been unsuccessful in finding a way to remove the left property, or to overwrite it with some other value, such as "left:none". Is there a way around this?
You want: left: auto; Along with setting the `right` property. It's not that your `right` declaration is being ignored, rather it will be applied at the same time as the existing `left`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript, jquery, css, alignment" }
GroupBy Python with a custom function I need to tranforme my DF. I have that for many other lines: 3 21-TV-0515 ACACIAS 21-TV-0515 4 21-TV-0515 ACACIAS 22-TV-0219 I found that: ACACIAS 21-TV-051521-TV-0515 21-TV-051522-TV-0219 When i used that code: ConcordanceMAPNOVA.groupby('Acronyme').sum() But in fact I want to have somethings like that: ACACIAS 21-TV-0515 21-TV-0515, 22-TV-0219 or ACACIAS [21-TV-0515] [21-TV-0515, 22-TV-0219] Do you know if it was possible?
The question is not very clear, but I think you want to aggregate and retain unique values, right? In that case, you could do: import pandas as pd df = pd.DataFrame({"col1": ["21-TV-0515", "21-TV-0515"], "Acronyme": ["ACACIAS", "ACACIAS"], "col2": ["21-TV-0515", "22-TV-0219"]}) df.groupby("Acronyme").agg(set) Or (if you want a list instead of a set): `df.groupby("Acronyme").agg(lambda x: list(set(x)))`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, group by" }