INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Does $A_1\supset A_2 \supset \cdots $ imply $\bigcap A_n \neq \emptyset$? given a countable collecstion of sets $\\{A_n\\}$ which satisfies $$A_1\supset A_2 \supset \cdots \supset A_n\supset \cdots $$ My intuition is $$ \bigcap A_n \neq \emptyset $$ Please show me a counter-example.
$A_n = (0, \frac1n) \subseteq \Bbb R$ is a counterexample.
stackexchange-math
{ "answer_score": 7, "question_score": 1, "tags": "general topology" }
button click prior to scraping html table Hi I am trying to scape an HTML table and I have working code. The one URL, however, contains two html tables. The first table contains "quarterly" numbers and loads by default with the url. When you click the button above the table, you can switch to the second table with "annual" numbers. My code only picks up first default (quarterly) table that appears when the url loads. How can I get my python code to scrape the second "annual" table? Can selenium do this? If so could anyone provide any guidance? #!/usr/local/bin/python3 import requests import pandas as pd headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0'} r = requests.get(" headers=headers) df = pd.read_html(r.content)[1] print(df) Many thanks
After much googling and some other stack posts, finally got this working: from selenium import webdriver from bs4 import BeautifulSoup import pandas as pd browser = webdriver.Firefox(executable_path=r'/Users/xxxxxx/Documents/python/web_drivers/geckodriver') browser.get(' linkElem = browser.find_element_by_link_text('Annual') linkElem.click() r = browser.find_element_by_css_selector("#rrtable > table").get_attribute('outerHTML') browser.quit() soup = BeautifulSoup(r, 'html.parser') df = pd.read_html(str(soup))[0] print(df)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, pandas, selenium" }
Using Regular expression to find out numbers in my text? I have to find out all the numbers in my document which are in the format 1., 2.,3. etc i am using the regular expression `[0-9]+.\.` this is working fine with double digit numbers but having issue with the single digit numbers like 1. 2. can someone help me out with this one?
Remove the in-between unescaped dot. Because an unescaped dot in regex matches any character. [0-9]+\.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php, regex" }
Google AdWords and Laravel 5.2 So I've got a project in Laravel 5.2, and I have to use Google Ads here. How should I request necessary files and libraries in my controllers? For example, I have `/var/www/project/app/controllers/Controller.php`, and all Google provided src, examples etc. are stored in `/var/www/project/public/ads` folder. Then, from my Controller.php I want to get list of campaigns available in my account. What should I write in the head of the controller? Some `use` or `require_once`? For now I have only these two: require_once public_path('ads') . '/init.php'; require_once ADWORDS_UTIL_VERSION_PATH . '/ReportUtils.php';
Welp it looks like those are included simply like `use AdWordsUser`, `use Selector` and so on. That was easy.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "php, laravel 5, google ads api" }
SQL auto increment pgadmin 4 I am trying to make a simple database with an number generator but why do I get the error below? > ERROR: syntax error at or near "AUTO_INCREMENT" > LINE 2: IDNumber int NOT NULL AUTO_INCREMENT, Code: CREATE TABLE Finance ( IDNumber int NOT NULL AUTO_INCREMENT, FinName varchar(50) NOT NULL, PRIMARY KEY(IDNumber) );
For Postgres you have to use `SERIAL` CREATE TABLE Finance ( IDNumber SERIAL PRIMARY KEY, FinName varchar(50) NOT NULL );
stackexchange-stackoverflow
{ "answer_score": 20, "question_score": 24, "tags": "sql" }
What is wrong with the query? I'm implementing this query with `asp.net` in `VB`, the objective of that query is to sort out the email data other than `@yahoo.com` and `@gmail.com`, it shows an error : Incorrect syntax near '@yahoo' and '@gmail". "select * from print_venue where not (email_id like %" & "@yahoo.com" & "%) AND (email_id like %" & "@gmail.com" & "%)" What's wrong with the above query ?
You forgot the quotes around the `like` statement "select * from print_venue where not (email_id like '%" & "@yahoo.com" & "%') AND (email_id like '%" & "@gmail.com" & "%')" It has to be email_id like '%@yahoo.com%' and not email_id like %@yahoo.com%
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "asp.net, sql server, vb.net, visual studio 2008" }
Finding all Points on a Edwards curve I need to find all affine points on the Edwards curve: $x^2 + y^2 = 1 - 5x^2y^2$ over $F_{13}$ I tackle this by transforming the equation to: $y^2 = \frac{1-x^2}{1+5x^2}$ I then go from x = 0 to $\frac{p-1}{2}$ in this case x from 0 to 6. If you can take the square root of $y^2$ you found a point. If you have a match you will find 4 points because of the symmetry of this equation. (x,y)(x,-y)(-x,y)(-x,-y). I managed to find these points: (0,1)(0,12)(6,3)(6,10)(7,3)(7,10)(12,0) However my computer algorithm says I'm missing the following points (3,6)(3,7)(10,6)(10,7). Simply put I'm missing x = 3. This is my calculation of x = 3: $y^2 = \frac{1-3^2}{1+5*3^2} = \frac{-8}{46} = \frac{5}{7} \rightarrow 5 * 7^{-1} \mod{13} \equiv 10$ however the square root of 10 isn't an integer. Could anyone answer my question?
The congruence class of $10$ is a square in $\mathbb{F}_{13}$. Indeed, $$6^2\equiv 36\equiv 10 \bmod 13$$ and similarly $(-6)^2\equiv 7^2\equiv 49\equiv 10\bmod 13$. Thus, for $x\equiv 3$ and $-3\equiv 10\bmod 13$, there are two possibilities for $y$, namely $6$ and $7\bmod 13$. **Notice** that your algorithm could have run into trouble if $1+5x^2\equiv 0 \bmod 13$, for some $x\bmod 13$. Although $1+5x^2$ is never $0$ over $\mathbb{Q}$, it could have happened that $1+5x^2\equiv 0$ has a solution in $\mathbb{F}_{13}$. This is not the case, because a solution would imply that $x^2\equiv 5\bmod 13$, and $5$ is not a square in $\mathbb{F}_{13}$ (the squares are $1,3,4,9,10$, and $12$).
stackexchange-math
{ "answer_score": 2, "question_score": 4, "tags": "elliptic curves, cryptography" }
Custom keyboard shortcut to paste a pre-defined text? I've been working on several website designs lately, and it looks like I'll be making a lot more in the near future. I find myself browsing to lipsum.com and copying a handful of paragraphs of random text to fill a design almost daily. I was wondering, is there any way I can set up a keyboard shortcut that will always paste a certain text, for instance a few paragraphs of lorem ipsum that I saved in a text file or something? thanks
Autohotkey will do exactly that (although there are many similar apps). See < for your specific requirements
stackexchange-superuser
{ "answer_score": 7, "question_score": 18, "tags": "windows, keyboard shortcuts, clipboard" }
iOS 11 - how to change the position of rightBarButtonItems? the code in iOS 10 or earlier is worked UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom]; [btn1 setTitle:@"yyyyy" forState:UIControlStateNormal]; [btn1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; [btn1 sizeToFit]; UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithCustomView:btn1]; UIBarButtonItem *fixed = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFixedSpace target:nil action:nil]; fixed.width = -22; self.navigationItem.rightBarButtonItems = @[fixed, item1]; ![enter image description here]( if i want to do the same thing in iOS 11, what can i do fo it?
We have acomplished this by subclassing UINavigationBar: #import <UIKit/UIKit.h> @interface InsetButtonsNavigationBar : UINavigationBar @end and setting layoutMargins #import "InsetButtonsNavigationBar.h" @implementation InsetButtonsNavigationBar - (void)layoutSubviews { [super layoutSubviews]; for (UIView * view in self.subviews) { view.layoutMargins = UIEdgeInsetsMake(0, 8, 0, 8); } } @end
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, objective c, uinavigationitem" }
No ClassTag available for T -- not for Array Here is a part of code involving akka: abstract class AkkaBaseClass[T <: AkkaClass1, U <: Loger] extends Actor { protected val val1 = context.actorOf(Props[T]) protected val val2 = context.actorOf(Props[U]) def receive = { case "test" => { implicit val timeout = Timeout(Config.timeout seconds) val future = val1 ? "request" val result = Await.result(future, timeout.duration).asInstanceOf[List[ActorRef]] sender ! result } case "log" => val2 ! "log" } class AkkaClass1 extends Actor { .... } trait Loger extends Actor { ..... } There are 2 errors: No ClassTag available for T and No ClassTag available for U But `T` and `U` are not arrays. What do I do about that?
Though you omitted the place where the errors took place, I'm guessing they are happening at `Props`. It is probably the case that `Props` take an implicit `ClassTag` as a parameter, particularly since it doesn't take any other parameter. And though a `ClassTag` is used by array creation, it can also be used for other things, such as getting a `Class` that can then be used to instantiate classes by reflection, or as a reference when comparing instances received. To solve it, declare `AkkaBaseClass` like this: import scala.reflect.ClassTag abstract class AkkaBaseClass[T <: AkkaClass1 : ClassTag, U <: Loger : ClassTag] extends Actor {
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "scala" }
What do I risk by putting a 40W tip on a 50W iron? All I have on hand is a 40W tip and a Weller WES51 (50W). I plan to work for about 8 hours. Can I do any major damage to the iron or the work?
What you are asking makes no sense. We have several Weller WES51 around here, so I am quite familiar with them. The tips don't have a power rating. The difference between the tips is the shape. For example, the ETP tip is good for most general work, and is listed as being ".8mm conical". The ETT tip is ".61mm conical" and comes to a slightly finer point. These tips are just metal. The heater and temperature feedback are in the iron. All the tips have the same mechanical interface on the iron side. There is no such thing as a "40 W" tip. If the tip you have fits mechanically into the PES51 iron, then I'd say give it a try. As long as the fit is good, the iron should regulate the temperature well enough. Also, wattage of a temperature controlled iron only tells you the maximum it is capable of, which should be rather more than you actually use on average so that the temperature controller has some extra to work with.
stackexchange-electronics
{ "answer_score": 2, "question_score": 4, "tags": "soldering, tools" }
Where to place business logic is Symfony 2 model layer? I'm moving my old codebase to the Symfony 2.2 framework. In my old code, my Article entity has had a method **getUrl()** , which was returning a URL for current article. In Symfony i have to use **Router** service to generate such an URLs. I can't access Router from inside the Entity, cause it's a bad practice and not really supported by the framework. I can call the router from the Twig template itself using Twig helper **path()** and provide all the arguments (from the Article instance) needed to construct the URL. But this approach is not very good, cause if i'll decide to change URL formatting rules - i will have to find all this calls and rewrite them (not very **DRY** ). I really want to save the business-logic encapsulation here and not to pull all the guts to the view layer. How should i proceed in this situation?
Create an `ArticleManager` class in your service layer, and handle any business logic there. You can pass the router to it through dependency injection. For your example, `ArticleManager` would have a `getUrl(Article $article)` method which would use the router instance (that you either injected through `__construct` or a separate setter method) to generate the Url based on properties of `$article`, and return it. This method will ensure that your business logic doesn't pollute the view or controller layers. Be sure to read up on the Service Container docs.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 8, "tags": "symfony, model, symfony 2.2" }
Is there a specific name for a $[1,n]$ interval as compared to $[0,n]$? Interval $[0,n]$ behaves quite differently to $[1,n]$ if values are used in multiplication, e.g. for scaling other values. Is there a formal terminology to distinguish those?
_(I'm assuming in both cases you are talking about real number intervals.)_ No, there isn't any official term. You could say one is a closed interval containing $0$ and one is a closed interval not containing $0$. However, I'm not sure exactly what property that differs between those two intervals you are looking for a term for.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "terminology" }
What's the main difference between ESI and EBX for char arrays? i was thinking about some IA-32 ASM examples with char arrays. I'm trying to understand the main difference between ESI/EDI and EBX, when you need to read an array. In my examples, signed or unsigned char arrays. It seems that when you don't need a destination (EDI), you can use both ESI and EBX to read an array. My question comes from the "standard" definitions of those registers: ESI/EDI are for string operations, and EBX is for memory pointing. Ok, arrays are in memory, but: there is a real difference for using ESI or EBX in this case? I know, it's a dumb question, but i can't find anything useful on the net.
Convenience and available registers are about it. There's a handful of instructions that require specific registers, and a few others that will make shorter instructions given a specific register (16-bit code using AX comes to mind). However, for standard addressing I can't think of any worthwhile differences imposed by the chip itself. You may choose one or the other simply due to which registers are free (or to avoid a save/restore operation).
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "assembly, x86" }
Is there a way to check if Ektron is loading a page in Edit mode in my codebehind? (C#) I have a page that prompts the user for a password in order to display the content. However, when Ektron users are editing the page content, I want it to just show the content without asking for the password. The password functionality is all set in the codebehind; the password in the metadata for the page tells the code to hide the usercontrols that show the content (ux.Visible = false) and display the usercontrol that asks for a password. What I'd like to do is check at this point to see whether Ektron is currently in Edit mode, and if so, set ux.Visible = true. Is there a way to check for this?
I found this on the Ektron developer center. [Works with 8.7] if (_host != null) // make sure widget is being used inside a PageBuilder page { var p = this.Page as PageBuilder; // get PageBuilder object if (p.Status == Mode.Editing) // check for Editing mode { ux.Visible = true //Display UX } }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c#, asp.net, edit, mode, ektron" }
R apply correlation function to a list I have a data frame like this: set.seed(1) category <- c(rep('A',100), rep('B',100), rep('C',100)) var1 = rnorm(1:300) var2 = rnorm(1:300) df<-data.frame(category=category, var1 = var1, var2=var2) I need to calculate the correlations between var1 and var2 by category. I think I can first `split` the `df` by `category` and apply the `cor` function to the list. But I am really confused about hot to use the `lapply` function. Could someone kindly help me out?
This should produce the desired result: lapply(split(df, category), function(dfs) cor(dfs$var1, dfs$var2)) EDIT: You can also use `by` (as suggested by @thelatemail): by(df, df$category, function(x) cor(x$var1,x$var2))
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "r, list, function" }
Splash screen text changes color I currently have a text box on the bottom portion of my splash screen that displays the last build date. The text color is set to black but for some reason when you run the splash screen the color starts out at black, turns to white and then turns back to black right before the actual program starts. This is only happening on Vista. Does anyone know why this would happen?
Thank you for the help Chandra! I managed to fix it finally by switching the transparency color of the background from black to white. I have no idea why it worked but it did so I figured I would post it on here so if someone else has this obscure (and annoying) problem they can check that.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "c#, splash screen, textcolor" }
GitHub Pages Precedence Say I have the following repositories on GitHub: caffinatedmonkey (user) caffinatedmonkey.github.io tree master foo index.html foo tree master gh-pages index.html If I go to caffinatedmonkey.github.io/foo, which page will be shown? Which page takes precedence, the project page, ` or the user page, `
I set up a test by replicating the repository structure in the question. When I visited `caffinatedmonkey.github.io/foo` I was taken to the user's foo page, ` User pages take precedence.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 4, "tags": "github, github pages" }
Problems with IE and Edge, probably scroll smoothing I have fixed header that animates up (by the height of header) if scrolled down and reappears when scrolled up. I had header jumping issues before with IE and I used this: //IE jumping fixed elements fix if(navigator.userAgent.match(/Trident\/7\./)) { // if IE $('body').on("mousewheel", function () { //Remove default behavior event.preventDefault(); //Scroll without smoothing var wheelDelta = event.wheelDelta; var currentScrollPosition = window.pageYOffset; window.scrollTo(0, currentScrollPosition - wheelDelta); }); } It shows JS error that `Object doesn't support property or method 'preventDefault'` with every scroll but it somehow works. But now with new Edge, even this doesn't work (I tried `/Edge\/12./`). Everything works nicely with Firefox and Chrome.
You're attempting to call `.preventDefault` off of `event`, but `event` isn't in your handler's list of arguments. As such, `event` is either defined outside of this scope, or _undefined_. Either way, it's not what you're expecting. One other suggestion (in particular for older versions of IE and older hardware) would be to throttle this method so that it's not running dozens of times each second. Microsoft Edge should function like Chrome and Firefox. If it's not, please direct me to a resource that shows the issue and I'll gladly file a bug for the team to evaluate.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, internet explorer, smooth scrolling, microsoft edge" }
Why class { int i; }; is not fully standard-conformant? This is a follow-up question. In the previous question, @JohannesSchaub-litb said that the following code is **not** fully standard-conformant: class { int i; }; //unnamed-class definition. § 9/1 allows this! and then he added, > while it is grammatically valid, it breaks the rule that such a class must declare at least one name into its enclosing scope. I couldn't really understand this. What name is he talking about? Could anyone elaborate on this further (preferably quoting the Standard)?
Clause 9 of the standard allows `class {public: int i;}` (note the lack of a final semicolon) because this _decl-specifier-seq_ for an unnamed class might be used in some other construct such as a typedef or a variable declaration. The problem with `class {public: int i;};` (note that the final semicolon is now present) is that this class specification now becomes a declaration. This is an illegal declaration per clause 7, paragraph 3 of the standard: > In such cases, and except for the declaration of an unnamed bit-field (9.6), the _decl-specifier-seq_ shall introduce one or more names into the program, or shall redeclare a name introduced by a previous declaration.
stackexchange-stackoverflow
{ "answer_score": 51, "question_score": 43, "tags": "c++, class, definition, identifier, standards compliance" }
RoR and Filemaker Where condition Not sure if this is possible, but I am wondering if I can compare two fields in a `where` As I am trying to avoid `if` statements in this case. For example: Article.where(clidlive: '*', "#{mod_date} > "#{releae_date}) * `mod_date` is a date field in filemaker * `releae_date` is a date field in filemaker. I'd really appreciate if you could direct me to the right path, or even this is possible. Thanks, Rob
Short answer: No Longer answer: Rails has no knowledge of filemaker or its records until you point Rails to FM. You can use this gem to do so: < Once you parse the data you could store it in SQL to use ActiveRecord query methods in the style you listed above: `Article.where.not(clidlive: nil).where("mod_date > ?", release_date)` You could also create a calculation on the filemaker side and just query that field. Hope that helps!
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby on rails, ruby on rails 3, ruby on rails 4, filemaker" }
Glassware uninstalled after google glass reboot I have created a test build of a GDK Glass app that I want to deliver to a few test users. However the app disappears after a reboot. Logcat shows this: 08-19 18:18:18.256: I/GlasswareSyncAdapter(978): Uninstalling Glassware ID #6DBADA7634397F00 (com.example.demo). A look at the issue tracker explains that this is caused due to the fact that the MyGlass app didn't install this app and that the app thus isn't linked to the user's account. Are there any workarounds? With a submission process of over a month how can we get our app tested properly?
It seems like this issue only occurs when the application you are side loading has been submitted to Google for approval. Just change change the package name of the APK you want to sideload and your problem should be solved.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android, google glass, google gdk" }
DefaultFirebaseOptions not configured for windows [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Unsupported operation: DefaultFirebaseOptions have not been configured for windows - you can reconfigure this by running the FlutterFire CLI again.
You can initialise using option like this await Firebase.initializeApp( // Replace with actual values options: const FirebaseOptions( apiKey: "api key here", appId: "app id here", messagingSenderId: "messaging id", projectId: "project id here", ), You can get these values from firebase console
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "flutter, firebase, dart" }
How to highlight all keywords in a piece of text? We are using a large common spammer phrase list as part of our spam filtering system. Any matches in the subject or message body of an email cause it to go straight to our Office 365 hosted quarantine. Today, I noticed our first false positive getting sent to the hosted quarantine. I want to find out which words or phrases matched something in the phrase list so I could remove it from the list but could not find it (due to the large number of keywords and phrases we now have in the list). Everything is currently in a notepad document. I thought of using Beyond Compare but don't see how it could work in this situation. How can I highlight matches between the original message and the keyword/phrase list?
If each key phrase is on a separate line then the easiest way is to use a batch file: @echo off (for /F "tokens=*" %%i in (keywords.txt) do findstr /C:"%%i" /N /I message.txt) > result.txt Save it as `filter.bat` and run form the command line. `keywords.txt` is the name of the file with the keywords, e.g. spammer1 spammer2 mr. spammer3 and `message.txt` should contain the message in question: Hi, I am spammer2. Give me money regards, Mr. spammer3 After the script is run, the matching line numbers will be output in `results.txt`: 1:Hi, I am spammer2. Give me money 4:Mr. spammer3
stackexchange-superuser
{ "answer_score": 1, "question_score": 1, "tags": "comparison, office365" }
Is it correct to use the word "final" if there are only two items in the list? Google's definition of final: > final 1\. coming at the end of a series. I'm a bit hesitant to use final in a two-item list. Because two items isn't enough to make a series, I think?
In a two-item list, it is the usual practice to refer to the first of the two as "the former" and to the second of the two as "the latter."
stackexchange-english
{ "answer_score": 1, "question_score": -1, "tags": "usage" }
Display partial unless content_for was defined? What I want to do is, show default sidebar content UNLESS the current view has something else to display in the sidebar. How would I do this? (rails3)
content_for?(:sidebar) ? yield(:sidebar) : render(:partial => "shared/default_sidebar")
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "ruby on rails 3" }
How to toggle different forms in NetBeans GUI design I'm using _NetBeans 8 IDE_ to design a desktop application. How can I transit among different forms (e.g. _login page_ and _homepage_ )? Should I design multiple `.java` _JForms_ or is it possible to completely delete previous components and bring new ones? Is there something like hidden tabs that aren't shown to the user but really exist? I am looking for a high performance way to toggle forms.
Were you to have the form constructed programmatically - although this is a bit inefficient - you could use a switch statement in a loop with cases that contain the individual forms, and statements to clear the existing form components. There's also an easy JavaFX navigation solution using a larger-than-viewport area (containing each form in a horizontal series) wherein the forms get the viewport one-by-one, but it looks like you're using swing; sorry if it's of no help in this case.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "java, forms, user interface, netbeans" }
Undefined method when accessing active record in a loop I am trying to do rendering of @artclasses_mine. This is what I have in the artclasses_controller - I access another model Cregistration. @array = Array.new Cregistration.where(cuser: current_user.email).find_each(batch_size: 50) do |i| @array[i] = Cregistration.cclass end @artclasses_mine = Artclass.where( id: @array ) Then in the HTML file I do <%= render @artclasses_mine %> The error I get is `"undefined method 'cclass' for #<Class"` I realize that probably by using "where" I access the relation and not the actual record, so I tried Cregistration.find_each(:batch_size => 50) do |i| Still the same error If I access the Cregistration model out of the loop, everything works fine. I think the problem is with syntax, but I can not figure it out. Any help is appreciated!
You are trying to access an instance method in a class object. @array = [] Cregistration.where(cuser: current_user.email).limit(50).each do |reg| @array << reg.cclass end @artclasses_mine = Artclass.where(id: @array) Here we talk to each instance as `reg` inside the loop and `push`/`<<` the `cclass` into the `@array`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "ruby on rails" }
Component to short 2 wires when powered I am attempting to short 2 different wires, call them A and B when C I'd powered. I am attempting to use a transistor, but when I attatch C to the base and A or B to the emittor, it just powers A/B which isn't what I want, I need A/B to be shorted. Is there a way to configure a transistor to do this? Or might I need a relay of some sort?
I would use a relay - the relay contacts are totally isolated from the controlling source so there is no chance of introducing unwanted voltages, and no need to be concerned with the polarity between the points you want to short (although you do have to select a relay whose contacts can handle the voltage and current that may be encountered.
stackexchange-electronics
{ "answer_score": 4, "question_score": 1, "tags": "transistors, short circuit" }
Ruby on Rails - form_for collection_select options not visable I'm using a collection_select in a form_for however the options are not displaying in the browser (empty select box) but are present in the debugger view. (this happens in both chrome and IE10). View: <%= form_for(@lot) do |f| %> <%= f.label :client_id, "Client" %> <%= f.select :client_id, collection_select(:lot, :client_id, Client.all, :id, :org, :include_blank => "Please select") %> Rendered page source: <label for="lot_client_id">Client</label> <select id="lot_client_id" name="lot[client_id]"></select> <option value="">Please select</option> <option selected="selected" value="1">Client 1</option> <option value="2">client 2</option> Controller: def new @lot = Lot.new(:client_id => 1) end Any insight would be much appreciated thanks,
collection_select is also a formHelper of sorts which returns both a select and options elements, try: `<%= f.collection_select(:lot, :client_id, Client.all, :id, :org, :include_blank => "Please select") %>` instead
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby on rails" }
Haskell chain functions based on separate conditions Is there an efficient/easy way, when chaining functions applied to one argument, to only apply functions that fulfill their requirements in order to be applied? E.g.: I have 1 argument 'Obj' and 3 functions: func1, func2, func3. Each have their own requirements which need to be fulfilled in order for the function to be applied to the argument as well. E.g. pseudo-code: (if condition1 then func1) . (if condition2 then func2) . (if condition3 then func3) Obj So if all conditions are qualified, all 3 functions would be applied to Obj. Is there any way I can do this properly?
First, you have a missing `$` before `Obj`. I think in answer to your question, you just need to supply an `else` clause: (if c0 then f0 else id) $ (if c1 then f1 else id) $ (if c2 then f2 else id) $ arg
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "function, haskell, chain" }
programmatically set PreferenceScreen I have a preferncescreen page for showing of data only and not saving it for setting the code is as below <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android=" <PreferenceCategory android:title="Member Subscription Status"> <PreferenceScreen android:title="Subscription Status" android:summary="Active"> </PreferenceScreen> <PreferenceScreen android:title="Next Payment Date" android:summary="2012-06-21 18:00:00s"> </PreferenceScreen> <PreferenceScreen android:title="Plan Type" android:summary="Family"> </PreferenceScreen> </PreferenceCategory> </PreferenceScreen> Right now i am wondering how should i set the summary of the preferncescreen to show on the screen?
Found the solution. have to add a key first android:key="Subscriptionstatus" then in activity Preference pref = findPreference( "Subscriptionstatus" ); pref.setSummary("test");
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "android, android layout" }
How set a dynamically generated attribute name for a Blob? I have an Expando model on App Engine. How do store images in Blob properties if the attribute name is a variable? Let's say I post a bunch of images where I dont know the name beforehand. Is there any real, existing equivalent of my imagined `p.image[entry] = db.Blob(image)` code below? images = self.request.arguments() for entry in images: image = self.request.get(entry) ##some validation stuff p = Pictures() p.image[entry] = db.Blob(image) p.put()
I expect you want `setattr`: setattr(p.image, entry, db.Blob(image))
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, google app engine, google cloud datastore" }
GnuPG symmetric encryption yields different output I have a use case where I want to commit symmetrically encrypted source code using GnuPG (think of Coursera assignments for backup and collaboration). I encrypt/decrypt all sources in a batch with a script and was wondering, why the output is not stable. So basically, why does echo "plain text" | gpg --armor --symmetric --cipher-algo AES256 with password `secret` yield different cipher texts with each call? (Surely enough, this doesn't affect the decryption – different cipher texts may decrypt back to the same plain text.) I am not experienced with crypto algorithms, but skimming the Wikipedia article it seems the algorithm is deterministic. So in short, my questions are: 1. Is this behaviour a property of AES or am I using GnuPG incorrectly? 2. If the former is the case, are there other symmetric crypto algorithms which are better suited for this use case?
Usually, symmetric encryption starts with a random initialization vector (IV). OpenPGP uses a slightly different cypher feedback mode with an all-zero IV, but the first two blocks are random. Because of this, also the symmetric encryption is not deterministic; you cannot compare the plain text by comparing the encrypted message, the encrypted result is not deterministic any more.
stackexchange-security
{ "answer_score": 9, "question_score": 6, "tags": "encryption, cryptography, gnupg" }
Should I use a constraint? I'm developing a Twitter-like system, and have a model to record who follows who. There are two fields and both fields are foreign keys and point to the User model. Clearly you wouldn't want a follower-followee record duplicated, so I'm using the `unique_together` attribute in the inner `Meta` class, in order that the follower-followee pair is unique. Trying to violate this throws `IntegrityError` and 500 status code. This feels like a "second line of defence" as my view and template code doesn't give a user the chance to follow someone twice. Should I/can I do something similar to ensure you can't follow yourself? The view and template that lists all users (each with a button to click to follow that user) does not list the currently logged in user, so there should be no opportunity to follow yourself. But I don't have anything equivalent to `unique_together`.
Dude, no. I don't know _why_ you're doing this, but assuming it isn't for a uni project with a lunatic professor, you're wasting your time. That is, if he's not a lunatic he's not going to try and hack the following/followee . And so what if he does? If its for a startup-idea, then spend less time solving this (trivial) problem and more time working on whatever business model or marketing or whathaveyou thing you _need_ to do. A little bug isn't going to be a show stopper. If you're being contracted out, leave it as a bug and get the conteact extended to fix it :) If you just want to fix this, just do a check in the model or the validation that the follower isn't the same as the followee
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "django, django models" }
Obtaining a number using the Chinese remainder theorem We have a number $X$ between $4899$ and $7330$. When divided by $11$ the number $X$ leaves behind $3$, and when it is divided by $13$ it leaves behind $2$, and finally when divided by $17$ the remainder would be $7$. What is $X$? How do I go about this using the Chinese remainder theorem? I am able to obtain $1367$ but it not between $4899$ and $7330$.
Chinese Remainder Theorem tells you that all solutions have the form $1367 + k \cdot 11 \cdot 13 \cdot 17$. Now, $11 \cdot 13 \cdot 17=2431$, so that $$1367+2431=3798$$ $$1367+ 2 \cdot 2431 = 6229$$ $$1367+ 3 \cdot 2431 = 8660$$ are other solutions (you can go on and write all other solutions). The unique belonging to your range is $\mathbf{6229}$, and this is what you were looking for.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "elementary number theory, chinese remainder theorem" }
Prevent UINavigationItem's TitleView from blinking I'm using `UINavigationItem`s `titleView` property to set view in center of `UINavigationBar` of my ViewController. The problem is, when I push another ViewController with same `titleView`, it blinks. ![Animation showing Blinking of titleView]( Here is how I set `titleView` inside my ViewControllers let view = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) view.backgroundColor = .red self.navigationItem.titleView = view What can I do to prevent this?
I ended up using custom view and adding it as subView to `UINavigationBar`. I'm also setting `UINavigationItem`s `titleView` to blank view to prevent LargeTitle from appearing in place of my view.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, swift, uinavigationbar, ios11, uinavigationitem" }
Recognizing keydown() in JavaScript with Arrow Keys I am trying to use JavaScript (inside PHP) to recognize keyDown events - specifically the arrow keys. I have looked through various threads on here, as well as other sources but have not been able to find a solution. My code looks like: echo '<script> alert ("Hi"); $(document).keydown = (function(e) { if (e.which == 37 || e.which == 38) { alert("It works!"); } if (e.which == 39 || e.which == 40) { alert("It works, also!"); } }); </script>'; The first alert is just there so I know it is even recognizing the script, which it is. However, when I press the arrow keys - nothing happens.
Use this instead: echo '<script> alert ("Hi"); $( document ).on( "keydown", function ( e ) { if ( e.which == 37 || e.which == 38 ) { alert( "It works!" ); } if ( e.which == 39 || e.which == 40 ) { alert( "It works, also!" ); } } ); </script>'; the code which you used will just add a method on the object which is returned by jquery and is not actually adding the listener :)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, php, jquery" }
How To Get Food Out of Braces After eating I always find there is food stuck in my braces. It might seem easy to remove the food by brushing your teeth, but at school, you can't. It can get annoying with all the food stuck in them and it just looks disgusting. **How can I remove food from my braces?** Methods I've tried: * Picking them out with nails - disgusting and time-consuming There aren't many options to really choose...
Who says you can't brush your teeth at school? Just keep a small travel toothbrush (or brush with travel cap/tube) in your backpack and visit the bathroom after lunch. This was my dentist/orthodontist's recommendation when I had braces 10+ years ago, still a good idea today I think. Alternatively they do sell different sizes and shapes of disposable "brushpick" style tools in the dental aisle of pharmacies/Walmart/Target, and even plain old toothpicks might work. Carry some in a plastic baggie for after lunch at school. This method is probably more time consuming. For a very basic approach, try swishing plain old water vigorously around your mouth then spitting it out, repeating a few times. Probably will not dislodge the most stubborn food particles, but should get rid of the majority of it.
stackexchange-lifehacks
{ "answer_score": 15, "question_score": 1, "tags": "cleaning, personal care" }
How to use assertNotEquals for 2 lists of different size I'm trying to assert two List of Strings having different number of elements. I'm testing an application and my goal is to Fail a test case if the Actual list contains even one element that matches the Expected list. I have tried below approaches but none of these suffice my requirement. List<String> expected = Arrays.asList("fee", "fi", "foe", "foo"); List<String> actual = Arrays.asList("feed", "fi"); assertThat(actual, not(equalTo(expected)));` I want this comparision yo fail since there is 1 element in actual list which matches the expected one. Assert.assertNotEquals(actual,expected); assertThat(actual, is(not(expected))); Assert.assertNotEquals(actual, containsInAnyOrder(expected)); None of these work. Any help would be appreciated.
This is a one-liner. Assert.assertTrue(Collections.disjoint(list1, list2)); The `disjoint` method returns `true` if its two arguments have no elements in common. It helps to know the libraries that come with the JDK. See <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, junit4, assert, assertions" }
File uploaded via FTP has no content, and is checked out by an empty string? I've attempted to upload the same PHP file to my shared hosting server through Dreamweaver and Filezilla and in both cases my 2KB file gets uploaded onto the server as 0KB. In Filezilla, I've attempted to upload in both ASCII and Binary mode and get the same result. I renamed the local file, uploaded it, and it also ended up empty. I created a new HTML file, 1KB, and uploaded it. It seemed to keep its size until I viewed the file on the server in which it showed up empty. I checked the server again, and the file was down to 0 bytes. One strange thing I've noticed is that Dreamweaver marks the most recently uploaded file as "Checked out by: " - essentially nobody. All of the other files including files that have been emptied are "Checked out by: _my name_ ". I'm at a loss.
I'd double check to see if the FTP server is out of disk space.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ftp, locking" }
Can you set multiple paints on the same XYPlot? So I have a working XYPlot but I want to add different colors to the background, not a single one. I know this appears to be doable for quadrants, but I want it basically row by row, or ranges of rows I should say. Basically something like this : ![enter image description here]( but with ideally 3-4 colors instead of just 2. Can you set the background paint for a specified Axis range for example? I haven't found any info or way to do it yet.
`IntervalMarker` "Represents an interval to be highlighted in some way." In the example below, two markers span the plot's range. XYPlot plot = new XYPlot(…); plot.addRangeMarker(new IntervalMarker(.3, 1, new Color(0x60CCFFE5, true))); plot.addRangeMarker(new IntervalMarker(0, .3, new Color(0x60FFCCE5, true))); ![image](
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "jfreechart" }
Is there any C# equivalent to the Perl's LWP::UserAgent? In a project I'm invovled in, there is a requirment that the price of certain stocks will be queryed from some web interface and be displayed in some way. I know the "query" part of the requirment can be easily implemented using a Perl module like LWP::UserAgent. But for some reason, C# has been chosen as the language to implement the Display part. I don't want to add any IPC (like socket, or indirectly by database) into this tiny project, so my question is there any C# equivalent to the Perl's LWP::UserAgent?
You can use the System.Net.HttpWebRequest object. It looks something like this: // Setup the HTTP request. HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(" // This is optional, I'm just demoing this because of the comments receaved. httpWebRequest.UserAgent = "My Web Crawler"; // Send the HTTP request and get the response. HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); if (httpWebResponse.StatusCode == HttpStatusCode.OK) { // Get the HTML from the httpWebResponse... Stream responseStream = httpWebResponse.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); string html = reader.ReadToEnd(); }
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "c#, perl" }
Using Redux with React v0.12.2 I want to use Redux in a React (v0.12.2) based project. However Redux is much newer than React and mainly supports only latest versions of it. Is there a version of Redux that would work? If no one would, what could be the alternative state container library to use with this version of React, without ES6 syntax?
The Facebook codebase has more than 20,000 components, and it keeps up with React updates. I’d suggest at least giving updates a try. Make sure that rather than jump from 0.12 to latest, you upgrade one version at a time, so you can react to the deprecation warnings. Also check out react-codemod that lets you automate some of the changes. That said you can totally use Redux in an older projects, just without React Redux. You can use the store API directly, `subscribe()` from your components, and use `getState()` to read the current state. Or you can fork React Redux and try to get it to work with 0.12.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript, reactjs, state, redux, react redux" }
Why GRB format for programmable LEDs? Why manufacturers use GRB(Green, Red, Blue) format for "RGB programmable LEDs" instead classic RGB format? Eg. IN-PI55TAT RGB LED 4 pin From the bottom of Page 6 on the datasheet: ![enter image description here]( Is this choice based on hardware simplicity or with by engineers?
The physical arrangement of the LED dice is in that order (photo from Pololu), which would represent the physical arrangement of the shift register on the chip. ![enter image description here]( As to why you'd want to put the red die in the center of the lens, I would speculate that it is because red is typically the weakest of the three LEDs in terms of light output per mA so placing it near the center gives it a better chance. Note: this is just speculation, but it holds together. Note also that the chip version of the WS2811 is shown with RGB data arranged in that order, so the chip designers had the notion to connect them to LEDs in that order. The LED manufacturers (typically distinct firms) decided to scramble the outputs for some reason of their own.
stackexchange-electronics
{ "answer_score": 3, "question_score": 0, "tags": "led, rgb, grb" }
Laravel validation allow image or pdf I have a file input in Laravel and I would like it to only allow images or pdf. How do I do this in controller validation? $validator = Validator::make($request->all(), [ 'image' => 'image', ]);
You should rather make a MIME type validation: $validator = Validator::make($request->all(), [ 'image' => 'mimes:jpeg,bmp,png,gif,svg,pdf', ]);
stackexchange-stackoverflow
{ "answer_score": 21, "question_score": 7, "tags": "php, laravel, laravel 5" }
How to "Set previous context mark"? From the vim manual: m' or m` Set the previous context mark. This can be jumped to with the "''" or "``" command (does not move the cursor, this is not a motion command). I could not understand what this does or what its used for, tried to "set" previous mark to another mark using that, but it did not work.
The `'` and ``` are synonymous. It correspond to position before the last move (with the exception of the very small moves. e.g. one character, one line) The `m'` (and its sister: `m``): * Set the last position mark explicitly * Add an entry at the top of jump list * Move the jump list cursor to the to of the it I believe this command is used by plugin developers when they create moves. It let them: * Mark the original position before the jump * Maintain the jump list This to make the jump commands works like expected: * `Ctrl``o` * `Ctrl``i` * `''` * ``'`
stackexchange-vi
{ "answer_score": 1, "question_score": 2, "tags": "vimscript, cursor movement, mark" }
How to get world coordinates of a UV parameter on a NURBS Curve Surface? I am looking for a solution to get the world x, y, z coordinates of a given UV parameter on a NURBS Curve Surface. The output should be a `mathutils.Vector`, or at least a Python tuple. Thanks in advance!
This isn't supported, in general Blender's nurbs support is quite basic. Blender uses a method of calculating nurbs that steps over the curve in U and V directions at a fixed level of subdivisions (tessellated for drawing in the viewport), and there are no built-in methods to ray-cast into a nurbs surface, though such methods exist and could be added to Blender. However if you really wanted its possible to take the nurbs data (before tessellation) and evaluate it from Python, but this would be quite an involved task. As a simple solution you could just get the mesh of a nurbs object and (knowing the order of grid verts/faces), you could find the face that lies on a UV coord, then interpolate across the face... it wont give an accurate location but may be good-enough in some cases.
stackexchange-blender
{ "answer_score": 2, "question_score": 2, "tags": "python, nurbs surface" }
Convergence to zero in $L^{p}(\mathbb{R}^{N})$ Is true that if $u_{n} \in L^{p}(\mathbb{R}^{N}) \cap L^{q}(\mathbb{R}^{N})$ and $u_{n} $ converges to $0$ in $L^{p}(\mathbb{R}^{N})$ then $u_{n}\rightarrow 0$ in $L^{q}(\mathbb{R}^{N})$. **Edit:** I added that $u_{n} \in L^{p} \cap L^{q}$ My guess is that the above statement is true, once that convergence in $L^{p}$ implies in convergence _almost everywhere_ , so $u_{n}(x)$ is bounded. I should find a integrable function $\varphi$ such that $|u_{n}(x)| \leq \varphi(x)$ a.e and conclude the proof using the Dominated Convergence Theorem. Am I right? What function $\varphi$ I can choice?
Actually, for all $p,q\in [1,+\infty)$ such that $p\neq q$, there exists a sequence $\left(f_n\right)_n$ such that $\left\lVert f_n\right\rVert_p\to 0$, $\sup_{n\geqslant 1}\left\lVert f_n\right\rVert_q$ is finite but $\left\lVert f_n\right\rVert_q$ does not converge to zero. For example, let $f_n(x)=n^{1/q}\mathbf 1_{(0,1/n)}(x)$ if $q>p$ and $f_n(x)=n^{-1/q}\mathbf 1_{(0,n)}(x)$ if $p>q$.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "real analysis, measure theory, convergence divergence, lebesgue integral" }
How to use subscript in pattern names? For example I want to define a function with parameters σx and σy, that is, the function will be declared as: f[σx_,σy_] := . . . I tried `Symbolize` but it doesn't work. How can I use `Subscript` in pattern names?
You can use `Symbolize`, from the `Notation` package following the tutorial as you did. Then, just take the precaution of writing the pattern with its head explicit, such as: Pattern[xr, _] The problem is that Mathematica can't interpret the short notation for patterns (`xr_` for example) if it has a box structure before the "_"
stackexchange-mathematica
{ "answer_score": 17, "question_score": 21, "tags": "custom notation, pattern matching" }
og:image shows upp blank I'm maintaining a WordPress site and for some reason I can't get a thumbnail (the image is there but blank) to the post when I share it on Facebook. I've checked the facebook debugger but doesn't see any warnings or errors. For example: < < What could be wrong? Appreciate the help Kind regards, /Linus
Look at your page's source - you're setting the og:image property twice. Once with a plugin and I assume once by directly coding it into your template.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "facebook, wordpress, facebook opengraph" }
WS2812B Reset time i am trying to implement the ws2812b with an atmega8,but i didn't understand a thing very well. if i pull low for >50 us, it says it resets, but what does that mean? it resets the current LED all data to 0 and latches the next data to the next led?
It's the "communication" reset. You pull the data pin low for 50uS or more to start a new batch of communication. It's illustrated in the datasheet here: ![enter image description here]( As you can see, between each batch of bits being sent the reset code is set. This is so that the first chip knows to start receiving again and not pass any data on until it's had all 24 of its bits.
stackexchange-arduino
{ "answer_score": 1, "question_score": 1, "tags": "ws2812, atmega" }
plot multiple pandas dataframes in one graph python plotly I want to plot line charts for **multiple pandas data frames in one graph** using **python plotly** (set x-axis: **Day-shift** and y-axis: **PRO** ). I tried using for loop but it failed to generate expected output.Code I tried is given below. import plotly.express as px for frame in [df1, df2, df3, df4, df5]: fig = px.line(frame, x='Day-Shift', y='PRO',template="plotly_dark") fig.show() Also I want to set legend as df1 to df5
With plotly you can try the following: import pandas as pd import plotly.graph_objects as go from plotly.offline import iplot # dict for the dataframes and their names dfs = {"df1" : df1, "df2": df2, "df3" : df3, "df4" : df4, "df5" : df5} # plot the data fig = go.Figure() for i in dfs: fig = fig.add_trace(go.Scatter(x = dfs[i]["day-shift"], y = dfs[i]["PRO"], name = i)) fig.show()
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "python, pandas, dataframe, linechart, plotly python" }
Improve image quality by quantization I know it is possible to convert high level image format like PNG into low level format like GIF as we have all the data and we can decide what to keep and what to spare.. or for example convert 256 colors image into black and white. The question is what happens in other way. What if I have a black and white picture and i want to convert it to 256 colors. Can it be done? will it be too noisy? or for example if I have a really high quality image with range of 2^20 colors and i'd like to convert it to 2^21 colors... will it be better but my eye won't see the difference? basically my question is what if i'd like to add more levels instead of reducing. (it also applies to sound if i have mono sound file and i'd like to convert it to wav). levels can indicate colors or whatever... of curse it won't be perfect but can it be done?
you have no gain by doing so, since you do not have more information. Low level example: you have a bit so it can be one or zero: b = [0 1]. Now you store that bit in 2 bit field. It will still have the value 0 or 1, so the rest of the bitfield is simply unused since there is no information to fill it with. The same for your image example: you have 2^20 colors you want to sort them in 2^21 bins. this leaves some of the bins empty. no gain here. you can use methodes to fill those level, like interpolation but this will not make additional information "appear".
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "signal processing, transformation, quantization" }
How long should I wait to make sure the game is saved? The game autosaves. However, when I buy some last hero-upgrades before quitting the game, I often find those upgrades undone when I come back later, thus reducing them precious AFK gainz. So basically the question would be, in what intervals does the game autosave?
Like games such as Cookie Clicker, the save time for Clicker Heroes is usually around 30 seconds to a minute. According to Reddit, this game can be found around the web at various places, such as its website, Kongregate and Miniclip and that each version has differences, such as the Steam version does not have a login feature. But, upon experimentation, the game autosaves approximately every 60 seconds since its launch. As said in this answer, you can avoid having to wait up to 60 seconds for the autosave to occur (since your last action) is to hit the wrench at the top right corner and then 'save'.
stackexchange-gaming
{ "answer_score": 3, "question_score": 2, "tags": "clicker heroes" }
cl date function working differently in Intel and M1 machines I have a shell script to calculate the number of days from a particular date: echo D$((($(date +%s)-$(date +%s --date "2018-01-01"))/(3600*24))) On my 2019 MBP (Intel), it works. On my 2020 Mac mini (M1), it doesn't. The error: date: illegal time format usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format] /usr/local/bin/days: line 1: (1614815225-)/(3600*24): syntax error: operand expected (error token is ")/(3600*24)") The man pages are different. On the MBP it's DATE(1) User Commands DATE(1) On the Mac mini it's DATE(1) BSD General Commands Manual DATE(1) 1. What's going on here? 2. How do I get back the old functionality?
The answer (thanks to a hint by @mmmmmm in the comments) is that in the M1 Mac mini you have to install the gnu coreutils (e.g. via Homebrew), but since the names of some of them overlap with the names of similar (but not identical!) utilities that come with the Mac mini, the system automatically prefixes "g" to any utilities whose names overlap. Therefore, the problem was solved in my case by changing `date` to `gdate` in my code.
stackexchange-apple
{ "answer_score": 1, "question_score": 1, "tags": "command line, compatibility, m1" }
Playing audio files in android I need to play long audio files using the Android SDK. I am aware of the MediaPlayer framework shipped by Android, but I was wondering wether the built-in "Music Player" application could be invoked, so I don't have to write my own player GUI and code.
**Yes, you can.** Set up an intent like this: act=android.intent.action.VIEW dat=file:///mnt/sdcard/song_name.mp3 typ=audio/mpeg3 Action: VIEW Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri .parse("file:///mnt/sdcard/song_name.mp3"), "audio/mpeg3"); startActivity(intent);
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "android, audio, android intent, playback" }
Energy transfer between oscillators Suppose I have two mechanical oscillators $a(t), b(t)$, coupled through the interaction $V_\text{int} = \mu^2 a(t) b(t)$. Is there a simple way to express the rate of energy transfer from $a$ to $b$ using only $V_\text{int}$? Something like $\partial_t V_\text{int}$ would have the correct units, but it is symmetric in $a$ and $b$, and therefore cannot represent energy transfer from $a$ to $b$. Something like $a\partial_t(\partial_a V) - b\partial_t(\partial_b V)$ is antisymmetric under $a\leftrightarrow b$, but I can't figure out how to justify this expression.
The answer is actually extremely simple. The power transfer between oscillators is just the time derivative of the work done on $a$ by $b$, minus the work done by $b$ on $a$ \begin{align} P &= \frac{dW_{a\to b} - dW_{b\to a}}{d t}\,,\\\ W_{a\to b}-W_{b\to a}&=\int{\rm d}a \partial_b V_\text{int} - \int{\rm d}b \partial_a V_\text{int}\,. \end{align} Changing integration variables from $a$ and $b$ to $t$ using the chain rule \begin{align} {\rm d}a = \frac{da}{dt}{\rm d t}\,,\hspace{1cm} {\rm d}b = \frac{d b}{dt}{\rm d}t\,, \end{align} we arrive at the following expression for the power \begin{align} P = (\dot a\partial_b - \dot b\partial_a)V_\text{int}\,, \end{align} regardless of the form of $V_\text{int}$.
stackexchange-physics
{ "answer_score": 0, "question_score": 2, "tags": "energy, harmonic oscillator, oscillators, power" }
Stream is so laggy I have started my streaming career 3 days ago. And when I watch back my streams they are really bad. Not voice quality or my English spelling but my laggy video. I have got about 3 - 7 people on my channel watching me and honestly I am very happy after 3 days. I am playing games from BlueStacks and streaming via OBS. My internet is good on speedtest.net it is like this: -download speed: 94.9 Mb/s -upload speed: 90.4 Mb/s so I think that my problem is not in my internet connection. I have MacBook Pro (Retina, 13-inch, early 2015) with 2,7 GHz Intel Core i5. So what do you think guys. Where can be the problem?
It is likely that the issue is connected to either your encoding settings or your advanced settings, I recommend watching an instructional video on what should work for twitch. For reference, these are my settings for twitch streaming (I have included video settings also just in case) ![Advanced settings tab]( ![Encoding settings tab]( ![Video settings tab](
stackexchange-gaming
{ "answer_score": 3, "question_score": -1, "tags": "twitch" }
iphone:access UIButton instance by Tag I placed 6 UIButton on nib, I don't want to create 6 variables for each of button, is there any way to access buttons by their Tag or something else? I found a method viewWithTag, but seems it is used for NSView. THX~
If you created them by Interface Builder, you must go to IB and assign a unique tag to each button (1, 2, ...) and inside your code you can refer to them by `UIButton *button1 = (UIButton *)[self.view viewWithTag:1]`, `UIButton *button2 = (UIButton *)[self.view viewWithTag:2]` and so on.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "iphone, tags" }
Destroying objects in Ember.js Imagine I create an ember object, then add it to an arbitrary unknown number of array controllers. Is there a simple way of destroying the object so that all the array controllers get notified and remove it? < destroy from Ember.CoreObject doesn't seem to notify the collections that their objects have been destroyed, or the collections don't remove their objects. I'm not even sure if they're meant to or not.
The easiest way that I can think of is adding an observer on the object's `isDestroyed` property. That way when you destroy something and that property becomes `true` you can run whatever code you need to. See this jsfiddle: < Code: obj = Ember.Object.create({}); a1 = Ember.ArrayController.create({ content: [], destroyedObj: function() { alert('destroyed obj observer in a1'); }.observes('[email protected]') }); a2 = Ember.ArrayController.create({ content: [], destroyedObj: function() { alert('destroyed obj observer in a2'); }.observes('[email protected]') }); a1.pushObject(obj); a1.pushObject(obj); a2.pushObject(obj); obj.destroy() alert(a1.get('content').length)
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "javascript, ember.js, destroy" }
updating Text Box Items in WINAPI I created a textbox with following code. It is placed under WM_COMMAND of WNDPROC function. htextbox=CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("Edit"), TEXT("test"), WS_CHILD \ | WS_VISIBLE | WS_BORDER, 100, 20, 140, 20, hWnd, NULL, NULL, NULL); I want to update the element "test" written in the textbox when I receive: DT_MSG which is a message I receive from another application and the DT_MSG contains the item I want to write in the textbox. suppose the item I get is number say int a=dtmsg.somenumber Do I have to delete the above htextbox window and again create new textbox window with updated value or is there alternative and I can simply update `"test"` item in the same text box?
I think you can simply do it like this: SetWindowText(htextbox, TEXT("new text"));
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c, winapi" }
Missing Bib(la)tex directory in Texmaker I am having a nightmare with compiling citations using Texmaker. As part of this I was changing directories and somehow ended up with no directory. I have attempted uninstalling Texmaker and the MacTex as well as removing the program preferences but this hasn't worked. I know you can browse to the Bibtex file but I have no idea where it could be. Can anyone help me get back to some semblance of usage? ![Missing directory in texmaker]( Thank you in advance.
If your environment variables are set to include the location of `bibtex` and/or `biber` you don't need to worry about the full path, just fill "bibtex" %.aux or "biber" % into the empty field.
stackexchange-tex
{ "answer_score": 1, "question_score": 0, "tags": "bibtex, texmaker, biber" }
How to transform Python 3 script to Mac OS application bundle? Is there currently a way to create an application bundle from Py3k script? py2app uses Carbon package and therefore, as far as I understand, cannot be ported to py3k - Carbon development was terminated.
I have not checked if that's true, but cx_freeze 4.1 claims to support Python 3.1 (`cx_freeze` in general has long supported Mac OS X, as well as Windows and Linux, and I believe that also applies to the recent 4.1 release).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "python, macos" }
" on the example of the Equation" or "using the Equation as an example" Which of the following is more correct? > "we show our results on the example of the Duffing equation" or > "we show our results using the Duffing equation as an example" I am very thankful for any help.
The first sentence is arguably incorrect: the verb "show" does not usuallt take "on" as a preposition. This sentence may be understood, but it's not eloquent writing. The second sentence is correct and eloquent.
stackexchange-ell
{ "answer_score": 1, "question_score": 1, "tags": "sentence structure, terminology" }
MySQL join performance vs correlated queries I'm wondering if a 'normal' inner join leads to higher execution performance in MySQL queries than a simplistic query where you list all tables and then join them with 'and t1.t2id = t2.id' and so on ..
The execution plan and runtime is the same. One is called ANSI style (INNER JOIN, LEFT, RIGHT) the other is called Theta style. These two queries are equivalent in every way to mysql server SELECT * FROM A INNER JOIN B ON A.ID = B.ID; SELECT * FROM A, B WHERE A.ID = B.ID; You can test this by typing EXPLAIN in front of both queries and the result returned should be the same.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "mysql, performance, join" }
Dell PowerEdge 750 Can I use Dell PowerEdge 750 just 1U without a rack at home? Does it need cooling? I want to have a low end server for learning.
I had one sitting on a shelf for 2 years worked fine.
stackexchange-serverfault
{ "answer_score": 3, "question_score": 0, "tags": "rack, dell poweredge, physical environment" }
Spring Data REST - Spring still calls fndById despite my providing a custom entity lookup I've an almost identical use case to the example given at < I've registered a custom entity lookup and it works great - until the username doesn't exist; it then falls back to `findById(int)` at which point it throws a `java.lang.NumberFormatException` as it tries to convert the `String` into an `int`. Is there a way to disable the fallback? I don't need or want to access the entity by it's internal id.
That's a bug. I've filed and fixed DATAREST-1261 for you.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, spring, spring data rest" }
How to design a binary up down counter using D flip flop's and the 'up' or 'down' count will be controlled by another flip flop? I have to design a 4bit Binary Up Down counter using D flip-flops . But here is the catch I cannot directly use a switch to control whether the counter will count up or down, I have to do that using a D flip flop. Any help on how I can solve this? N.B. I can design an up down counter , but I need to know how to use another D flip flop to control the whether I want up or down count
Without knowing exactly what "using a D flip flop" means, I can provide at least two approaches. First, instead of a single switch, you can provide two - an up/down switch and a "load control" switch. Using an NO switch operating on the open-to-close action for the control switch can be done by !schematic simulate this circuit - Schematic created using CircuitLab But keep in mind that I have provided no debouncing on the clock switch, which you must provide. Alternatively, if you want the control FF driven by the same clock which drives the counter, you can do it but you have to delay the clock between the control FF and the counter in order to allow a change in the control input to settle before the counter acts on it. !schematic simulate this circuit Note that a pair of inverters makes a perfectly usable delay, and multiple pairs of inverters make for longer delays.
stackexchange-electronics
{ "answer_score": 0, "question_score": 0, "tags": "flipflop, counter" }
href# moves the scroll position Hi when you click the a link i want it to toggle the 'vartalo' without page going scrolling to the top, i want 'A' to be link like that but dont want it to scroll the page up. <!DOCTYPE html > <html> <style> #oikea{ position:absolute; top:800px; } .paneelinvartalo{ border:1px solid black; background-color:lightblue; margin-top:5px; padding:15px; height:200px; width:200px; } </style> <body> <div id="panel1" class="paneelinvartalo">vartalo </div> <script src=" </script> <script> $(function(){ $('.nappulat').click(function(){ $('#panel1').toggle(200); }); }); </script> <div id="oikea" > <a class="nappulat" href="#" rel="">A< /a> </div> </body> </html>
It's the default action of the link that takes you to to the top of the page. The URL `#` is the empty bookmark, which is the same thing as linking to a named bookmark anchor placed at the top of the page. Use the `preventDefault` method to stop the default action of the link: $('.nappulat').click(function(e){ e.preventDefault(); $('#panel1').toggle(200); });
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "jquery, button, toggle" }
how do I get the Id of elements having a same class? i have a class `.myclass` i want to get the id of all textbox [html] who have this class. how i can do this. i need to do this in jquery
Another way: var ids = $('.class').map(function() { return this.id; }).get(); < It works best if you are sure that all elements have an ID attribute. If not, the array will contain `undefined` entries. Reference: `map()`, `get()`
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "jquery, html" }
Is there a way to disable scrolling to the Spy-disguise & Engineer Build/Demolish menus? With most other classes I can quickly switch between weapons easily with the scroll-wheel (with the option to Auto-switch instead of menu-switch turned on), and this is quite helpful. However, when I'm bringing up the Spy's Disguise menu (or the engineer's build/demolish menus) I'll press the keybind to bring up the menu, as I then need to press another key to select the disguise/building. However, I can also scroll on the wheel into these menus, which is _never_ what I intended to do. I always just want to switch from the wrench to, say the pistol or the shotgun, or the sapper to the knife. So, is there any way to disable those menus from appearing when scrolling?
I don't know of a way to do this. However, I have an alternate control scheme which you might find worth trying. I don't find single-stepping a scroll wheel a reliable input method, so I have rebound my wheel to function simply as switching buttons: bind "MWHEELUP" "slot3" bind "MWHEELDOWN" "slot1" bind "MOUSE4" "slot2" bind "MOUSE5" "slot4" I've also bound `Q` to be an 'absolute' switch key rather than the default last-weapon function: bind "q" "slot10; slot3" The `slot10` causes it to continue to function as the cancel key for spy/engineer menus. If you don't have a fourth mouse button (as I do) and don't want to use wheel-press as a switch key (as I don't), then you could bind `Q` to the slot that wheel up/down aren't bound to.
stackexchange-gaming
{ "answer_score": 4, "question_score": 6, "tags": "team fortress 2, tf2 spy, tf2 engineer" }
messy classnames construction Can anyone suggest a way to clean up this messy classname construction: const ButtonTemplate = props => { const themed = `btn-${props.theme}` const themedButton = `${styles[themed]} ${themed}${(props.disabled) ? ' disabled' : ''}}` return ( <button className={`${styles.btn} ${themedButton}`} type='button' onClick={props.onClick}>{props.children}</button> ) }
What about function ButtonTemplate({theme, disabled, onClick, children}) { const themed = `btn-${theme}`; return ( <button className={[ styles.btn, styles[themed], themed, disabled ? 'disabled' : '' ].join(" ")} type='button' onClick={onClick}>{children}</button> ); }
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "javascript, reactjs, ecmascript 6" }
How can I clean up Symfony admin routes? My backend URLs look like this: mysite.com/backend.php/blog I'd like to change it to: mysite.com/backend/blog Technically this isn't limited to admin apps, as Symfony grants every application two front controller scripts. But I hate having the script name in URLs and as such I'd like to change it. Is this possible? Thanks in advance. **Edit** @codecowboy - I did resolve this by creating a 'backend' directory in the web directory. I then copied over the .htaccess file symfony puts in web, and I moved the backend.php and backend_dev.php front controllers to /backend and renamed them index.php and index_dev.php. Then within each front controller I tell PHP to look one directory further up for the project config class. I've been doing this for a while now and it serves my needs perfectly. I actually wrapped this all up in a task so that setting up a new admin app is a 1 step processs.
You can add #I'm no regular expression expert or mod_rewrite expert, this line probably has some bugs RewriteRule ^backend(.*)$ backend.php [QSA,L] to your .htaccess file right before RewriteRule ^(.*)$ index.php [QSA,L] and that solves 1/2 of your problem. Anything sent to yoursite.com/backend/xxx will be routed through backend.php. The other problem you get is with internal symfony routing. It will interpret yoursite.com/backend/xxx as a request for module "backend" and action "xxx". I'm sure it's not too hard to solve. Good Luck!
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "php, routes, symfony1" }
Difference between AWS IAM and secrets manager On AWS an application can access a database by attaching an IAM role that allows access. Or an application can access the database by obtaining passwords from the secret manager. In what use cases would one use IAM or a secret manager to connect their DB and Application?
Secrets Manager is just storing your database password. You would be reading the password from Secrets Manager, and then connecting to the database with username/password. The fact that you are storing the password in Secrets Manager is kind of irrelevant. Your question should actually be stated something like this: > What are the advantages of using AWS IAM authentication for RDS databases, instead of the default username/password authentication. In answer to that question, the primary benefit is that you can use IAM roles attached to EC2/ECS/EKS/Lambda to provide database authentication credentials, instead of having to separately configure those resources with a database password somehow. You also don't have to worry about rotating the database passwords periodically if you are using IAM authentication.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "database, amazon web services, amazon iam, aws secrets manager" }
Retrieving Last comment from joining 3 tables Having the follow tables examples: JOBS jobid jobname COMMENTS jobid userid comment date USERS userid name I need to retrieve the last comment from each jobid I've been trying distinct and such but no luck so far. the jobid can be multiple times in the comments table(multiple comments etc)
As long as date from a comment and a jobID is unique this will work fine. If not then this answer will get you the most recent comment, including ties. select comment, jobid from (select max(date) as MaxDate, jobid from comments group by jobid) x inner join comments c on c.jobid = x.jobid and c.date = x.MaxDate
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sql, sql server 2008" }
Sum multiple TIME()'s I have this table of scores: --------- | TIME | --------- | L4:10 | | W2:32 | | L2:23 | | L6:10 | | W1:10 | --------- To convert a score to an actual time, I use: =TIME(0, MID(A1, 2, 1), MID(A1, 4, 2)) [ which outputs 00:04:10 for the A1 ] Is there any way to sum all these totals at once without creating new cells? _(Note: I cannot remove the L's and W's from the original cells)_
Consider wrapping it up into `ARRAYFORMULA` this way: =ARRAYFORMULA(SUM(TIME(0, MID(A1:A5, 2, 1), MID(A1:A5, 4, 2)))) This will sum all the values in A1:A5 range into one cell.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "google sheets, array formulas, google sheets formula" }
how to remove the file when "permisson denied" in R? My system is "win7", and I want to delete the file "workspace". file.remove("c:\\workspace") # [1] FALSE # Warning message: # In file.remove("c:\\workspace") : # cannot remove file 'c:\workspace', reason 'Permission denied' How can I give the R the power to delete it? file.info("c:\\workspace") # size isdir mode mtime ctime # c:\\workspace 0 TRUE 777 2014-01-01 14:42:51 2014-01-01 14:33:27 # atime exe # c:\\workspace 2014-02-25 09:39:08 no
@TypeIA answered it in a comment, but I'll formalize it here: `help(unlink)`. file.create('somefile') # [1] TRUE file.remove('somefile') # [1] TRUE dir.create('somedir') file.remove('somedir') # [1] FALSE # Warning message: # In file.remove("somedir") : # cannot remove file 'somedir', reason 'Permission denied' unlink('somedir', recursive=TRUE) (The directory is gone.)
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 13, "tags": "r, file" }
deinit not called inside uiviewcontroller after pressing back - Swift I am trying to dealloc / destroy an NSTimer after a user clicks back, but the deinit{...} inside the uiviewcontroller never gets called.
Beware that a view controller going out of the screen does not mean that it will be deallocated afterwards. I would recommend moving the timer dealloc to viewDidDisappear, but obviously it depends what you are using that timer for as well.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "swift, uiviewcontroller, nstimer, dealloc" }
How to teleport Minecart with chests above a players head? I've been having trouble making menu GUIs in 1.16. My best idea so far was to create a command making it so when ever there is a nether star in my inventory it teleports a minecart with a chest in it to me. But the problem is it teleports it to my feet, and not my head. Here are the commands I used: `/execute if entity @p[nbt={Inventory:[{id:"minecraft:nether_star",tag:{display:{Name:'{"text":"Menu"}'}}}]}]` **(to find a nether star in my inventory)** `/teleport @e[type=minecraft:chest_minecart,y=3] @p` **(to teleport the minecart)**
You must use ~ ~2 ~ instead of @p! If you teleport an entity to another entity the entity you teleport will always get teleported to the feat! But if you only replace @p with ~ ~2~ the minecart will be teleported to the command block! To fix that you must do it like this: /execute as @p at @s run tp @e[type=minecraft:chest_minecart,y=3] ~ ~2 ~ I hope that solve your problem! Do you know you dont need to type /teleport! /tp will also work :)
stackexchange-gaming
{ "answer_score": 2, "question_score": 1, "tags": "minecraft java edition, minecraft commands" }
Characters removed when saving with $.ajax() I have an textarea where I write javascript. I want to save the javascript-code with $.ajax(). The problem is that the + sign and everything after the first & is removed. Is there anybody who have any tips on this one, or can give me an clue in the right directions? This is my jQuery code: $("#save").click(function(){ var code = editor.getValue(); $.ajax({ type: "POST", url: "save.php", data: "id=1&code="+ code, contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1", success: function(html){ alert("Done"); } }); });
jQuery automatically serializes the data for you so you can send an object instead: $("#save").click(function(){ var code = editor.getValue(); $.ajax({ type: "POST", url: "save.php", data: { id: 1, code: code }, contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1", success: function(html){ alert("Done"); } }); });
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, ajax, save" }
Are there any differences between "ascribe" and "attribute" when used as "because of"? Are there any differences between "ascribe" and "attribute" when used as "because of"? The following two sentences, which one sounds more natural? > The fall in the number of deaths from heart disease is generally attributed to improvements in diet. > > The fall in the number of deaths from heart disease is generally ascribed to improvements in diet. Thanks.
Whether they mean the same or not is easily ascertained: > [ODO] > > **ascribe** _verb_ [ _with object_ ] ( **ascribe something to** ) > regard something as being due to (a cause): > _he ascribed Jane’s short temper to her upset stomach_ > > **attribute** _verb_ [ _with object_ ] ( **attribute something to** ) > regard something as being caused by: > _he attributed the firm’s success to the efforts of the managing director_ > _his resignation was attributed to stress_ Which "sounds more natural" is a subjective question, but Ngrams can provide some objective data. In your sentences **_I_** would use _attributed to_ , which happens to match Google's data, but others may disagree. !enter image description here
stackexchange-english
{ "answer_score": 4, "question_score": 8, "tags": "meaning, differences, verbs" }
Latency between Azure Web App and a VM I have an Azure Web App and an Azure VM running in the same data center under the same VNet. The web app can properly connect to the VM using its internal IP (as well as using the DNS server I've configured). The VM runs the web app's database (SQL Server) thus I'd like the network latency to be the lowest possible (this is why I've put both machine in a VNet). My question is how should I measure the latency ? From within the VM, using "psping -l 1k -n 1000 -h 20 _public_url_ :80" is ok when using the public address, but I wanna check the latency using the web app's internal IP and this cannot be resolved. Thanks, Noam.
You can test the latency from the Web App to your VM easily from DebugConsole for the Web App. The other way around (VM to Web App over internal IP) may not be possible because Web Apps don't have a documented way of acquiring their internal IP and hostname.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "azure, azure web app service" }
Sum of derivative of integrals: $f(x)=\left(\int\limits_0 ^{x} e^{-t^2}dt\right)^2$ and $g(x)=\int\limits_{0}^{1}\frac{e^{-x^2(t^2+1)}}{t^2+1}dt$ > For all $x$ in $\mathbb R$ define $\displaystyle f(x)=\left(\int_0 ^{x} e^{-t^2}dt\right)^2$ and $\displaystyle g(x)=\int_{0}^{1}\frac{e^{-x^2(t^2+1)}}{t^2+1}dt$. Show that for all $x$ in $\mathbb R$ $f'(x)+g'(x)=0$ I did: $\displaystyle f'(x)=2\left( \int_{0}^{x}e^{-t^2}dt\right)e^{-x^2}$ and $\displaystyle g'(x)=\int_{0}^{1}e^{-x^2(t^2+1)}(-2x)dt$ then changing $xt\rightarrow t$ $\displaystyle g'(x)=-2x e^{-x^2}\int_{0}^{x}e^{t^2}dt$ , finally $\displaystyle f'(x)+g'(x)=2(1-x)e^{-x^2}\int_{0}^{x}e^{t^2}dt$ then this is equal to zero only if x=1. Am i missing something? thanks beforehand.
There was a minor error, almost but not quite a typo. When you substituted, "changing" $xt$ to $t$, there were two slips. I think the slips could have been avoided if you had made the substitution in slightly different language, letting $u=xt$. Then $du=(x)dt$, which absorbs the extra $x$ in the integral. And your $e^{t^2}$ should be, in my notation, $e^{-u^2}$ (this really was a typo). With these minor corrections, things work out fine. There must be a more conceptual way of doing it, though the computational approach you took is reasonable, and works quickly enough.
stackexchange-math
{ "answer_score": 1, "question_score": 5, "tags": "calculus, integration" }
Move Exchange mailbox 2007 to another Exchange server We have a couple of hundred users that we are moving to a new domain. The user accounts will be freshly created on the new domain, but we need to move the mailboxes to a new Exchange server. We found this but this isn't quite what we are after. This will not move the mailbox to a new server.. **Any tips on moving mailboxes to a new exchange server (preferably with Powershell)?**
Look up cross-forest mailbox moves. You can do this natively with Exchange 2007/2010. Here's a good starter: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "powershell, exchange server" }
How do I get the previous or last item? How do I get the last or previous or unselected item and then the new item for a `JComboBox`?
I assume this applies to all Objects that allow for which you to add Item Listeners to them. String[] items = {"item 1","item 2"," item 3","item 4"}; JComboBox combo = new JComboBox(items) combo.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent ie) { if(ie.getStateChange() == ItemEvent.DESELECTED) //edit: bracket was missing { System.out.println("Previous item: " + ie.getItem()); //edit: bracket was missing } else if(ie.getStateChange() == ItemEvent.SELECTED) { System.out.println("Current \ New item: " + ie.getItem()); } }
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 4, "tags": "java, swing, jcombobox, itemlistener" }
CSS by data-attribute will not refresh/repaint In a HTML5/JS application we have a view with some styles depending on the `data-attribute` of elements: like <li data-level="0"></li> or <li data-level="1"></li> CSS li[data-level^="1"] { /* some styles */ } This seems to work just fine everywhere on `page reload`. But when the data-attribute get set programmatically via JS, the CSS properties get rendered in all relevant desktop browsers, but not in mobile safari. JS part looks like this: this.$el.attr('data-level', this.model.getLevel()) Any ideas on how to force to apply those properties (refresh/repaint something) ? I would like to avoid using the class attribute and different classes as things are more complex than shown here...
ok, changing data attributes simply doesn't seem to trigger a redraw of the element in all browsers !? Changing the `class` attribute however does. Kind of a workaround, but does the trick. this.$el .attr('data-level', this.model.getLevel()) .addClass('force-repaint') .removeClass('force-repaint'); As seen here: Changing a data attribute in Safari, but the screen does not redraw to new CSS style
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 9, "tags": "javascript, css, mobile safari, repaint, custom data attribute" }
2008 Pontiac G5 Coolant is starting to run hot when driving. Slowly climbs to 225-230 Just wanting to know what a possible diagnosis could be on why it is starting to overheat?
It could be a few things: 1. Low coolant 2. Failing water pump (or slipping belt) 3. Sticking thermostat 4. Obstructed passages in the radiator 5. Cooling system not holding pressure (rad cap not sealing, cracked rad, leak somewhere, bad head gasket)
stackexchange-mechanics
{ "answer_score": 3, "question_score": 4, "tags": "coolant, overheating" }
how to compare output of two ls in linux So here is the task which I can't solve. I have a directory with .h files and a directory with .i files, which have the same names as the .h files. I want just by typing a command to have all .h files which are not found as .i files. It's not a hard problem, I can do it in some programming language, but I'm just curious how it will look like in cmd :). To be more specific here is the algo: * get file names without extensions from ls *.h * get file names without extensions from ls *.i * compare them * print all names from 1 that are not met in 2 Good luck!
diff \ <(ls dir.with.h | sed 's/\.h$//') \ <(ls dir.with.i | sed 's/\.i$//') \ | grep '$<' \ | cut -c3- `diff <(ls dir.with.h | sed 's/\.h$//') <(ls dir.with.i | sed 's/\.i$//')` executes `ls` on the two directories, cuts off the extensions, and compares the two lists. Then `grep '$<'` finds the files that are only in the first listing, and `cut -c3-` cuts off the `"< "` characters that `diff` inserted.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "linux, unix, sed, awk" }
Can I find the distance? Please look at the diagram: !img I know $D$, $\alpha$ and $\theta$. I also know the $a/b$ ratio of $k$. I don't know $c$. Can I find out $a$ or $b$ or $a+b$?
This is a slightly different question to this one. But the answer is the same: it is not possible to determine $a$ or $b$ or $a+b$. Look at this figure: !enter image description here We can move the red lines anywhere in the $\theta$ cone without changing $\alpha$ and $k=a/b$. But $a$ and $b$ are changed.
stackexchange-math
{ "answer_score": 3, "question_score": 2, "tags": "geometry" }
How to debug django-excel zero output + no error? I need a simple data-export from a Django app to xls. I set up django-excel and files are generated/downloaded but with 0 kB / no content. There is no error message and there are tons of objects for the model I am trying to export. My code looks like this: def export_data(request, atype): if atype == "sheet": return excel.make_response_from_a_table(City, 'xls', file_name="cities")
So it turns out I had django-parler installed which django-excel wasn't compatible with or rather I didn't try to make then work together.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "pyexcel, django excel" }
A Mozzie Murder While we see Mozzies as pests they are more civilized than you'd think. In fact they have laws and police in their society. Which is why on this unfortunate day, the investigation into the murder of Max the Mozzie is taking place. As a senior Mozzie in society, having bitten thousands of humans, you have been asked to be the judge. There are 5 suspects each who have there own story about what they were doing at the time the murder took place. > **Suspect 1 - Anne** > > 'I was feeding on a deer that came to drink at the river' > > **Suspect 2 - Jack** > > 'I was sleeping in a hollow tree in the woods' > > **Suspect 3 - Ella** > > 'I was flying around a swamp looking for food' > > **Suspect 4 - John** > > 'I was biting a human who was bird watching' > > **Suspect 5 - Steve** > > 'I was trying to avoid being eaten by a bird' ## You're the judge, Whodunnit?
Assuming Mozzie actually means mosquito, not something trickier... > John did it, male mosquitoes don't bite, they eat nectar.
stackexchange-puzzling
{ "answer_score": 7, "question_score": 10, "tags": "knowledge" }
LassoLarsCV: different results after removing variables with coef=0 I am using LassoLarsCV from sklearn on a dataset with around 100 variables. After fitting the model around 80 of them have a coefficient of 0. I want to remove those variables from my dataset because it requires unnecessary load to the DB and network to request them every time during prediction. After refitting LassoLarsCV with the same settings on the reduced dataset I get different coefficients and R2 score on my test dataset. Is this behavior expected? What would be a better approach to not change the actual model, can i remove manually the 0-coefficients from the model object or would it have side effects on the internal model structure?
> Is this behavior expected? Yes. By removing the variables, you are changing the loss function, and so the optimization will be different. > What would be a better approach You could pass the full data to the model. This would be the easiest but it seems you aren't interested in doing that. Because the Lasso is a linear model, it would not be so hard to write your own function to compute the predictions. That way, you only need to pull the data you need and the computation is just a matrix vector product.
stackexchange-stats
{ "answer_score": 1, "question_score": 0, "tags": "scikit learn, lasso" }
Consuming from added partitions in Apache Kafka I have a `KafkaConsumer` and use manual partition assignment. To distribute partitions I use `consumer.partitionsFor(topicId)` in regular intervals to detect added partitions, because the job runs forever and I want to support this case. However, this always returns initial list of partitions, unless I restart the consumer. Is there a way detect added partitions from consumer? What to poll or listen for?
`KafkaConsumer` has a configuration property "metadata.max.age.ms", which defaults to 5 minutes. That means, that each call to `consumer.partitionsFor` will return cached copy for that time and only then fetch new metadata. Setting the property to `0` fetches new metadata each time.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "apache kafka, kafka consumer api" }
IPsec using pre-shared keys I am trying to understand why do we really use those pre-shared keys when creating a IPSec tunnel. From all the reading that I have done the DH group creates the keys that are used to do the actual data encryption, hope I am correct. If yes, the pre-shared keys are used only for the authentication?
The preshared key is used for authentication, as @toottoot points out. It also has another role. It is used in the DH calculation to generate the session keys. This gives the communicating parties a way to generate fresh session keys without additional key sharing, making it practical to change session keys frequently. By doing so, they can minimize the impact of a single compromised session key. Note that, by design, compromising a session key should not help an attacker compromise the preshared key (and therefore other session keys).
stackexchange-security
{ "answer_score": 1, "question_score": 3, "tags": "ipsec" }
is installing a module on a live site ill advised? I am trying to install Code Per Node on my website. All i have to do is ad content types that would accept HTML5 webgames. There would be theming involved. Is this a no go?
I successfully installed modules on sites with thousands hits a day. Maybe even an hour. And I must tell it's not wise, from the point of my experience. Sometimes you have no choice (installing captcha on the spam wave when client forbids technical break), but way to many things can go wrong. If your site has any significant number of visitors and you care about your reputation, either: * Install module on a copy of your site * Put your site in maintenance mode * Add `.htaccess` "maintenance mode" screen * Sync files * Sync data Or simplier, but with longer break: * Put your site in maintenance mode * Add `.htaccess` "maintenance mode" screen * Install module That way if your site dies, visitors will see nice static html screen saying "Sorry, technical break" and you will be able to revert from backups.
stackexchange-drupal
{ "answer_score": 3, "question_score": 2, "tags": "7, theming" }
Best way to check for positive integer (PHP)? I need to check for a form input value to be a positive integer (not just an integer), and I noticed another snippet using the code below: $i = $user_input_value; if (!is_numeric($i) || $i < 1 || $i != round($i)) { return TRUE; } I was wondering if there's any advantage to using the three checks above, instead of just doing something like so: $i = $user_input_value; if (!is_int($i) && $i < 1) { return TRUE; }
the difference between your two code snippets is that `is_numeric($i)` also returns true if $i is a **numeric string** , but `is_int($i)` only returns true if $i is an integer and not if $i is an **integer string**. That is why you should use the first code snippet if you also want to return true if $i is an **integer string** (e.g. if $i == "19" and not $i == 19). See these references for more information: php is_numeric function php is_int function
stackexchange-stackoverflow
{ "answer_score": 36, "question_score": 55, "tags": "php, validation" }
Install opencv3 on ubuntu installation without remove opencv2 package I need to install opencv V3 in a ubuntu 16.04. I have the packages libopencv-* (opencv 2.4.9) installed and lot of applications and libraries depends of it so I can't remove it. I can make and install opencv 3.1 from git repos but my doubt is if I do that installation i will have conflicts between both version or even a posterior upgrade from opt-get will overwrite the new ones and make everything unstable. Is there a way to have both at time, or remove 2.4.9 without uninstall all packages ho depend on it?
The default install folder of OpenCV is `/usr/local/`. You can install OpenCV 3.1 to a separate location, say `/home/your_username/opencv_3.1` with CMake option cmake -D CMAKE_INSTALL_PREFIX=/home/your_username/opencv_3.1 To build your project with OpenCV 3.1 using CMake, add set(OpenCV_DIR /home/your_username/opencv_3.1/share/OpenCV) to your `CMakeLists.txt`, after `project(projName)`. You can also link the corresponding libraries/headers manually or with IDE.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "opencv, ubuntu" }
Variable 'value' is used before being assigned My code: function test() { let value: number; for (let i = 0; i < 10; i++) { value = i; console.log(value); } return value; } test(); And got this: Variable 'value' is used before being assigned I found this very odd, as I had seen other similar problems that either used a callback or a Promise or some other asynchronous method, while I used just a synchronous for loop. \---------------------------------- Some update ------------------------ function test() { let value: number; for (let i = 0; i < 100; i++) { // a() is very expensive and with some effects const result = a(i) if(i===99) { value = result } } return value; }
Use the non-null assertion operator to ensure that "its operand is non-null and non-undefined in contexts where the type checker is unable to conclude that fact." function test() { let value!: number; for (let i = 0; i < 10; i++) { value = i; console.log(value); } return value; } test(); Result
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "javascript, typescript, for loop, variables, variable assignment" }
Where is the compiled java code stored in an nsf / ntf? Where is the compiled java code stored in an nsf / ntf? Or is it compiled from the java "files" at runtime? I looked all through the java perspective but do not see anything that jumps out at me.
Under **WebContent/WEB-INF/classes**. You can find it with **Navigator** (Window -> Show Eclipse Views -> Navigator).
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "xpages" }