INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How to pass variable when appendchild from anotehr script in javascript ? As title, I use JS load another JSfile, it's work in new JSfile, but cannot pass var back, I set it as global var, but it's work like local var. // index.html .js code function loadScript(url){ var script = document.createElement("script") script.type = "text/javascript"; script.src = url; document.getElementsByTagName("body")[0].appendChild(script); } loadScript("td01.js"); console.log("when run index: td01_var = " + td01_var); . // td01.js code td01_var = "td01varValue" console.log("when run td01.js: td01_var = " + td01_var); > ## console log > > Uncaught ReferenceError: td01_var is not defined(…) > > when run td01.js: td01_var = td01varValue
Hi try following... // index.html .js code function loadScript(url){ var script = document.createElement("script") script.type = "text/javascript"; script.src = url; document.getElementsByTagName("body")[0].appendChild(script); } loadScript("td01.js"); window.onload = function() { console.log("when run index: td01_var = " + td01_var); } // this will wait till your js file gets load...
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "javascript" }
Zend Framework 2 - Automatically create Doctrine Entity Getters and Setters Is there a way to automatically create the getters and setters which seems to be necessary? Would save loads of time... couldn't find anything on the internet so far... Thanks!
I checked it out with `PHPStorm5` and you can do the following when editing an entity: > Right-click > Generate > Getters and Setters > _select all variables_ > Ok You are done :)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "model, doctrine orm, zend framework2" }
C++ retrieve exception information I have a c++ dll which I need to debug. Due to the circumstances in which I am using the dll, I am unable to debug it via the calling application. So, I created a try -catch, where the catch writes the exception to a file. The line which needs to be debugged involves imported classes from a 3rd party dll, so I have no way of knowing what type of exception it is. When I tried catch(exception e), no message was written to the file. So I tried catch(...), which did trigger something: using std::exception::what, the only thing that got written to the file was "1". using std::exception::exception, the file received the following code : "0579EF90". Is there any way for me to retrieve meaningful info about the exception that was thrown? TIA CG
If you don't use `catch(KnownExceptionType ex)` and use your knwoledge about KnownExceptionType to extract info, no you can't. When you catch with `catch(...)` you are pretty much lost, you know that you handled an exception but there is no type information there, there is little you can do. You are in the worse case, an exception coming out from a library, you have no info on the exception, even if you had headers for the lib, that exception type doesn't need to be defined there.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 5, "tags": "c++, exception, try catch, extract error message" }
Is my Marigold plant dying? Two weeks ago, I bought this outdoor flower plant to brighten up my herb garden. I don't know the name of the plant and I had put it outdoors.The plant is exposed to full sun for 6-7 hours. Sadly, the leaves look like they are dying. Unfortunately, after buying this plant, it had rained for the whole week but contrary this week is hot (it is around 22 Degrees Celsius). I checked the plant today and soil was slightly dry. Do you think that this plant dying? ![enter image description here]( ![enter image description here]( Edit: Just discovered the plant's name thanks to @Stephie...Yipiiiii
Thanks for answers. Apparently, it was dying but the leaves from the bottom were dying and slowly slowly it also affected the top ones. Most probably it was fungus and it looked like some type of Wilt fungus but I'm not an expert of fungus so I might be wrong.
stackexchange-gardening
{ "answer_score": 1, "question_score": 5, "tags": "flowers, containers" }
How to calculate mean of multiple measures after removing outliers in R I have three independent measures of a variable, and they are subject to a lot of noise and sporadic sources of error that can be quite large. I would like to discard the value furthest away from the others, remember which one is discarded, and then calculate the mean with the remaining two. For example, a b c 15 6 7 11 10 3 5 12 6 would become a b c ave discard 15 6 7 6.5 15 11 10 3 10.5 3 5 12 6 5.5 12
Try: ddf a b c 1 15 6 7 2 11 10 3 3 5 12 6 ddf$ave = apply(ddf[1:3], 1, function(x) { x = sort(x) ifelse(abs(x[1]-x[2]) > abs(x[2]-x[3]), mean(x[2:3]), mean(x[1:2])) } ) ddf$discard = apply(ddf[1:3], 1, function(x) { x = sort(x) ifelse(abs(x[1]-x[2]) > abs(x[2]-x[3]), x[1], x[3]) } ) ddf a b c ave discard 1 15 6 7 6.5 15 2 11 10 3 10.5 3 3 5 12 6 5.5 12
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "r, mean, outliers" }
Split string into array in Python I have a string with the following structure. string = "[abcd, abc, a, b, abc]" I would like to convert that into an array. I keep using the split function in Python but I get spaces and the brackets on the start and the end of my new array. I tried working around it with some if statements but I keep missing letters in the end from some words. Keep in mind that I don't know the length of the elements in the string. It could be 1, 2, 3 etc.
First remove `[` and `]` from your string, then split on commas, then remove spaces from resulting items (using `strip`).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 6, "tags": "python, arrays, string" }
Нужно вывести 10 случайных чисел определенного диапазона, как найти минимальное и максимальное значение? Пока что накидал просто вывод десяти чисел из диапазона, как сделать, чтобы определялось максимальное и минимальное рандомное число? import java.util.Random; Random generator = new Random(); for (int i = 0; i < 10; i++) { int randomInt = generator.nextInt(34 - -25) + -25; System.out.println(randomInt); }
Написан в online редакторе, java ide нет у меня. import java.util.Random; // one class needs to have a main() method public class HelloWorld { // arguments are passed using the text field below this editor public static void main(String[] args) { Random generator = new Random(); int min = generator.nextInt(34 - -25) + -25; int max = min; for (int i = 0; i < 9; i++) { //первая итерация была выше. значит тут меньше int randomInt = generator.nextInt(34 - -25) + -25; System.out.println(randomInt); if(randomInt < min) min = randomInt; if(randomInt > max) max = randomInt; } System.out.println("min:"+min+" max"+max); } }
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "алгоритм, случайные числа" }
.Net DLL referencing another DLL I have one .Net 4.0 dll project that references third party PDF converter DLL. I have exposed this dll for COM. Now when I am trying to add my .tlb file to VB6 project it comes up with runtime error. Error says the dll which is third party pdf converter cannot be found. Is there any way I can avoid this? Many Thanks Ni
Ok at last it worked. All I did: open up .tlb file in Visual studio and added third party pdf dll using custom library. It started working.. Thanks everyone for help
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "c#, .net, dll, vb6, typelib" }
Find immediate descendants with PHP Simple DOM parser I would like to be able to do the equivalent of $html->find("#foo>ul") But the PHP Simple DOM library doesn't recognize the "immediate descendant" selector `>` and so finds all `<ul>` items under `#foo` including those that are nested deeper in the dom. What would you recommend as the best way to grab the immediate descendants that are of a specific type?
You can use DomElementFilter to fetch the desired type of nodes under some Dom branch. This is described here: PHP DOM: How to get child elements by tag name in an elegant manner? Or do a regular loop on all childNodes and filter then by their tag name by yourself: foreach ($parent->childNodes as $node) if ($node->nodeName == "tagname1") ...
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 4, "tags": "php, dom" }
Mutating a button into a form within a tabel cell I currently have a table cell which contains a form and allows me to update a row in the database. However I hope to be able to use Jquery to make the UI cleaner and user friendly. < what I visualize the end result to be after an onclick event.
Jeditable might be of use to use. It allows on click (or other events) to make text editable. Here you can find some demos.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, django" }
How do I change the title bar icon in Adobe AIR? I cannot figure out how to change the title bar icon (the icon in the furthest top left corner of the application) in Adobe AIR. It is currently displaying the default 'Adobe AIR' red icon. I have been able to change it in the system tray, however.
Does the following help? <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "apache flex, air" }
How to add a text to taken screenshot in Selenium WebDriver? My question might be a little bit reckless, but I would like to know if anybody had an experience with adding a text to a taken screenshot using Selenium WebDriver or any other Java library? Currently I'm utilizing: File screenShotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(screenShotFile, new File("C:\\XXX\\XXX\\SeleniumScreenshots\\" + "png")); in order to take a screenshot and it's working fine, but sometimes I need to add a descritive text to the screenshot smth like: "This is failed because of this..." What I need exactly is certain location of the page (e.g. global footer, header, burger menu, certain image) that may be found with xpath expression, take the screenshot of that location and add a text with the problem description. If anybody has an idea how this may be implemented please respond with a sample code.
Nothing Much! Tweaking the code from the link provided by @andrucz WebElement failedElement = driver.findElement(<locate your element>); File screenShotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); final BufferedImage image = ImageIO.read(screenShotFile); Graphics g = image.getGraphics(); g.setFont(g.getFont().deriveFont(30f)); g.drawString("Failed because of this!!", failedElement.getSize().getX(), failedElement.getSize().getY()); //Top-left coordinates of your failed element g.dispose(); ImageIO.write(image, "png", new File("test.png"));
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "java, selenium, appium, webpage screenshot" }
Is it possible to change the log file location for WP_DEBUG_LOG? I use WP_DEBUG_LOG in my development environment and have no issues with debug.log being in the wp-content directory. Sometimes I turn on WP_DEBUG in production when I need to debug something, and I still want to use the log but would like to redirect it to something outside my web root. Is this possible using WP_DEBUG_LOG?
It turns out that all WP_DEBUG_LOG does is: ini_set( 'log_errors', 1 ); ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' ); So, if you want to change the log location for WP_DEBUG_LOG in a plugin or theme, webaware's answer is best. If you just want to have it changed within `wp-config.php` you can replace `define( 'WP_DEBUG_LOG', true );` with the above 2 lines and change the log file to wherever you want.
stackexchange-wordpress
{ "answer_score": 21, "question_score": 27, "tags": "debug, wp config" }
Can every curve be represented as an equation? If I plot some points randomly on the graph and then join them, can that curve be represented as a polynomial? I know that a straight line can be expressed algebraically as a linear equation, and quadratic equation as a parabola, but can you express a smooth curve which is made by joining some random points on the graph algebraically ?
There are functions like trigonometric and logarithmic functions which cannot be represented as polynomials, yet they can be graphed: ![enter image description here]( ![enter image description here]( So it is not possible for every graph to represent a polynomial. However, these functions can be Approximated by Taylor series to any desired degree of accuracy. To illustrate it by an example, we may take the parabolic graph of $x^2$. ![enter image description here]( Now if one reflects the part of the graph to the left of y axis along the x axis, one roughly gets such a graph: ![enter image description here]( This graph is given by $x^2$ for $x>0$ and $-x^2$ for $x<0$, but it cannot be represented as a polynomial as the polynomial should be $x^2$ for x greater than zero and $-x^2$ otherwise.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "geometry, algebra precalculus" }
DI with Java 6? I read some documentation on DI with Java 6 and I'm not sure to fully understand. I have the following class in which I want to inject a service: @ManagedBean @RequestScoped public class MyBean implements Serializable { private static final long serialVersionUID = 1L; @Inject private MyService myService; private List<SomeObject> someObjects; // Getter and setter public List<SomeObject> getSomeObjects() { if (someObjects == null) { someObjects = myService.find(); } return someObjects; } } The service: public class MyServiceImpl implements MyService { public MyServiceImpl() { } } When running this code, myService is not injected. Please, what am I doing wrong? PS: I'm using Tomcat 7
Java 6 does not have built in dependency injection, nor does Tomcat 7 AFAIK. Are you thinking about Java EE 6? Then you have to run your code in a Java EE 6 compatible appserver, like TomEE or GlassFish. If you want to stay with Tomcat 7, you could concider Spring or Guice instead.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "java, dependency injection, java ee 6, java 6" }
Comparing float values in bash Hi I would like to compare 2 float numbers in bash but I haven't find anything that works properly. My actual code is the following: if [ $(echo " 0.5 > $X " | bc -l )==1 ] echo grande fi if [ "$(bc <<< "$X - 0.5")" > 0 ] ; then echo 'Yeah!' fi What happens is that no matter if the X is bigger or smaller than 0.5, it always echos both sentences and I don't know why. I know the X is bigger or smaller than 0.5 because I also echo it and I can see it.
In bash, you need to be very careful about spacing. For example: if [ $(echo " 0.5 > $X " | bc -l )==1 ]; then echo grande fi Here, there are no spaces around the `==`, so it'll be interpreted as: if [ 0==1 ]; then fi Believe it or not, this condition is always true. Consider: if [ "$(echo " 0.5 > $X " | bc -l )" == 1 ]; then echo grande fi .
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "bash, if statement, comparison, bc" }
Sidekiq won't shut down after Ctrl+C I'm using Sidekiq for background operations of my Rails 4.1 app. When I type `Ctrl`+`C` to shutdown Sidekiq, Sidekiq catches the signal but seems to freeze after this last log line: ^C2014-09-18T16:17:19.194Z 20686 TID-ovwtinh0g INFO: Shutting down 2014-09-18T16:17:21.041Z 20686 TID-ovwtixflc INFO: Shutting down 5 quiet workers Thus, I need another terminal window where I need to type: bundle exec sidekiqctl stop pidfile This is really inconvenient (and takes about 8 seconds) and I can't find why Sidekiq won't stop properly with `Ctrl`+`C`. My conf is: * Rails 4.1.5 * Sidekiq 3.2.4 * Postgresql DB
I came across this same issue. Sidekiq 3.2.4 relies on the Celluloid gem at version 0.16.0, which partially breaks Sidekiq. See here: < Update Sidekiq to 3.2.5 which locks Celluloid at version 0.15.2.
stackexchange-stackoverflow
{ "answer_score": 19, "question_score": 8, "tags": "ruby on rails, postgresql, ruby on rails 4, sidekiq" }
create hidden txt file with vbs i currently have a vbscript that creates a txt file in a directory and opens it, but id like to make it so that the file is hidden, currtly i have this code: Set objFSO=CreateObject("Scripting.FileSystemObject") outFile="C:\Users\User\Desktop\New map" Set objFile = objFSO.CreateTextFile(outFile,True) objFile.Write "test line 1" & vbCrLf objFile.Write "test line 2" & vbCrLf objFile.Close CreateObject("WScript.Shell").Run("""C:\Users\User\Desktop\New map""")
You can set the attribute like this Const cHidden = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") outFile = "C:\Users\User\Desktop\New map" Set objFile = objFSO.CreateTextFile(outFile, True) objFile.Write "test line 1" & vbCrLf objFile.Write "test line 2" & vbCrLf objFile.Close Set mapFile = objFSO.GetFile(outFile) mapFile.Attributes = cHidden CreateObject("WScript.Shell").Run Chr(34) & outFile & Chr(34) Quick Reference --> < <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "vbscript, hidden files" }
GPO: What's the scope of "Specify startup policy processing wait time"? Set on some GPO, the value of " _ **Specify startup policy processing wait time**_ " is **System-wide** or **GPO-specific** ?
This is system-wide, not gpo-specific. Take a look at "Always wait for the network at computer startup and logon" in `Computer Configuration\Administrative Templates\System\Logon` too if you want the computer to wait for the network.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 0, "tags": "group policy" }
pygame.mixer.Sound().play() gives no error but actually does not play I am trying to play a .wav file with pygame import pygame pygame.mixer.init() s = pygame.mixer.Sound('absolute path to file') s.play() it gives no error, but it seems like it doesn't play anything. This is the complete output pygame 1.9.6 Hello from the pygame community. installed pygame via pip in a conda python 3.6 enviroment. mac book pro 2019 with macOS Mojave
As bashBediam said the problem was that the code was ending not giving time to the audio to play. i fixed that doing like this. import pygame pygame.mixer.init() s = pygame.mixer.Sound(path) channel = s.play() while channel.get_busy(): pygame.time.wait(100)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python 3.x, pygame, python 3.6" }
Average value of potential energy and kinetic energy in simple harmonic motion In the Derivation of the formula of average potential energy and kinetic energy in simple harmonic motion. Please explain the step in the image.!enter image description here
The missing step is $sin^2(\omega t + \phi)={1 \over 2} (1-\cos(2(\omega t + \phi)))$
stackexchange-physics
{ "answer_score": -1, "question_score": 0, "tags": "homework and exercises, newtonian mechanics, energy, waves, harmonic oscillator" }
Command wc-1 returns illegal option I'm working my way through a unix tutorial. Contrary to the expectations bestowed upon me by the tutorial when I enter the command wc -1 I get the following wc: illegal option -- 1 usage: wc [-clmw] [file ...] Can anyone explain this and how i can use wc -1 to determine how many users are logged in
maybe it was wc -l l for larry not number 1.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "unix" }
How can one clear all the variables but the ones wanted Often when running long memory expensive programs I want to clear everything but some specific variables. If one wants to delete just some variables `clear varA varB` can be used, but what about deleting all but this specific variables?
As mentioned above, `clearvars` includes a syntax for keeping variables in the workspace while clearing the remainder: a = 1; b = 1; c = 1; d = 1; keepvars = {'c', 'd'}; clearvars('-except', keepvars{:}); Which functions as expected. Like `clear`, it can also accommodate `regexp` matching: a1 = 1; a2 = 1; b = 1; c = 1; keepvars = 'a\d'; % regex pattern clearvars('-except', '-regexp', keepvars); Which retains `a1` and `a2`, as expected.
stackexchange-stackoverflow
{ "answer_score": 20, "question_score": 10, "tags": "matlab" }
"Class 'Fideloper\Proxy\TrustProxies' not found" LARAVEL Class 'Fideloper\Proxy\TrustProxies' not found !enter image description here
composer require fideloper/proxy
stackexchange-stackoverflow
{ "answer_score": 41, "question_score": 6, "tags": "laravel" }
Check if memory was already freed in C As you know, after we finish using dynamic variables we `free()` them. However, sometimes those variables are already `free()`d. I need to check if it is free to avoid double free. Would anyone give me a clue?
You can't check if it's already been `free`'d (the signature of `free` should tell you that much; it can't modify the pointer from the caller's perspective). However, you can do one of two things. 1. Change your design. Who is responsible for this memory? It seems as though your design does not make that clear, which is the most common reason for memory leaks. Place ownership on one part of your code and be done with it. Why would the interrupt function conditionally deallocate the memory? Why does that seem like the most logical solution? 2. Set the pointer to `null` and double free all you like. `free(NULL)` is perfectly valid. * * * I prefer option 1 and learning this lesson now will help you write better code down the road.
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 1, "tags": "c, memory, free" }
How to fix "Component for route HomeScreen must be a react component " const RootStack = createStackNavigator( { Home : HomeScreen, }, ); const AppContainer = createAppContainer(RootStack); export default class App extends React.Component { render() { return ; } }
your tag specifies `react-native-navigation` which is different from `react-navigation`. You are using `react-navigation`. here is your solution: const AppContainer = createAppContainer(RootStack); export default class App extends React.Component { render() { return <AppContainer / > ; } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "react navigation" }
Does Microsoft Visual Studio Express C++ 2010 have installer maker capability? I've only started to play around with Visual Studio Express C++ 2010 (more comfortable with Autotools on *nix platforms) and am still exploring the menu items, but I'd like to just get the answer from someone who knows whether or not with the free version one can make .msi installers for their programs.
Sorry, you are out of luck : > The Express Editions do not include Windows Installer technology However, you should be able to get this capability for free via the Platform SDK.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "visual studio 2010, visual c++, installation" }
Duplicate declaration in TypeScript Consider this code: var a = []; for (var i in a) /* nothing */; var i : number; i = 9; If I compile this, the compiler complains about the last line, saying, "Cannot convert 'number' to 'string'". Presumably the for..in loop created `i` as a string, but I would have expected the compiler to complain about `var i : number` rather than wait until `i = 9` before it complained. If I change `var i : number` to `var i : number = 8`, the compiler still doesn't complain until it reaches `i = 9`. Is this a bug, or am I missing something?
If you had originally declared the variable it would warn you where you predict. For example, if you placed this line at the top of your code: var i: string; It would warn you of the duplicate identifier on the line: var i: number; It doesn't detect the duplicate identifier when you declare `i` in the for statement, perhaps it should - so you end up with a different error, which is when you assign a value of the wrong type. If you want the duplicate identifier warning, which is the first and foremost error here, your best bet is to log the bug on <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "typescript" }
If $ 0 \leq \lim_{n \rightarrow \infty} a_n < 1$, will $a_{n}$ eventually become become always smaller than 1? Suppose $(a_n)_{n \in \mathbb{N} }$ is a sequence, $a_n>0$. If $\lim_{n \rightarrow \infty} a_n = L$, where $ 0 \leq L < 1$, then: Is it possible to guarantee that there exists a $n_o$ sufficiently large for which $a_n < 1$ when $n>n_o$? Moreover, is it possible to guarantee that there exists a $M$, $L<M<1$, such that $a_n<M$ for sufficiently large values of $n$? I was trying to discuss those assertions using the definition of limit, i.e., for every real $\epsilon >0$, there exists a natural number $ n_{o}$ such that $n> n_{o} \implies \left | a_{n} - L \right | < \epsilon$ However, I couldn't conclude anything... Is the definition of limit the best approach to discuss that?
Put $L=\lim a_n$ and note that $1-L>0$. Then there exists an $N$ such that $n>N$ implies $$ \lvert a_n-L\rvert < 1-L $$ That is, $n>N$ implies $$ L-1 < a_n-L <1-L $$ Adding $L$ to this inequality gives $n>N$ implies $$ a_n<1 $$ as desired.
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "real analysis, sequences and series, limits" }
How to get the current temperature and tint for an AVCaptureDevice? I figured out how to adjust the temp and tint of an existing session with `deviceWhiteBalanceGainsForTemperatureAndTintValues` which takes a parameter of `AVCaptureWhiteBalanceTemperatureAndTintValues`. But I'm struggling to figure out a way to read the current of new value. Any one know of a way to do this? I would like to set `UISliders` with the values of the Temp and Tint.
Martin answered it in the comments. let tempAndTintValues = activeCameraDevice.temperatureAndTintValuesForDeviceWhiteBalanceGains(activeCameraDevice.deviceWhiteBalanceGains)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, swift, avfoundation, avcapturesession, avcapturedevice" }
How to delete someone else's comments? Someone recently posted a self-answered question with one serious error and with several areas which could use improvement. I posted a comment pointing these out, but did not DV - it was an otherwise ok attempt. The OP contended there was no error, but eventually came to understand the issue with the serious error. However, all the back and forth comments, including mine, which were **not** too chatty, spam or offensive just disappeared. Now, I understand not wanting a series of comments which are critical of your answer to remain there forever, but how does someone delete/remove someone else's comments like that? I've never seen that happen before.
You can flag comments that lead to the answer being improved as _obsolete_. A moderator will then remove those comments. If there are many comments, you can flag the post itself and ask a moderator to clean up the comments; this is easier for a moderator as they can purge all comments with one action. If any comments are still worth preserving, the moderator can then undelete individual comments.
stackexchange-meta_stackoverflow
{ "answer_score": 8, "question_score": 3, "tags": "support, comments" }
What is Splatfest? I've been playing Splatoon 2 and while I was watching Off The Hook, they were saying stuff about something called "Splatfest." I know nothing about it. I have picked my team, but I still don't get what Splatfest is.
The **Splatfest** is a festival within Splatoon and Splatoon 2. It's basically an event, where you choose one side or another, then fight against people from the other side. Participation is rewarded with **Super Sea Snails**. The amount you receive depends on whether your team won, and how much experience you collected during the festival. The amount ranges from 2 to 24 per Splatfest. Super Sea Snails are used to increase the number of slots on your **gear** or reroll all **abilities** on a specified piece of gear. The only other way to collect Super Sea Snails is to level up after reaching level 30, with each level up awarding a single Super Sea Snail (for a maximum of 20 in total).
stackexchange-gaming
{ "answer_score": 3, "question_score": -2, "tags": "splatoon 2" }
Need to Delete whole database in Jhipster using liquibase I am working on jhipster spring using angular js and database as "liquibase".Why We need to delete whole database when we have done change in our db-changelog.xml?.if i have add one field to old table in database then i have a get exception t_user table is already exist.which mean we have to remove t_user table or loss our data.please help and provide any other way to change our database without deleting whole database. Thanks in advance
Yesterday, we released the version 0.11; which supports the generation of the changelogs containing only your changes. The changes are applied automatically on the database. No need to drop your database now. Try it. <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "liquibase, jhipster" }
Can you legally sell parts of a car (engine, etc.) that still has a loan on it from a bank? Is it possible to dismantle a car and sell the parts even though the car is still on a loan in Illinois or any state? My thinking is that the car is still owned by the bank that the loan is through. Can I do whatever I want because the car is in my possession?
No, because you are affecting the car's value by selling its parts. The car is collateral to the loan, so if you don't make the payments, the lender has the right to repossess and resell it to recoup their money. If they are unable to recover at least the outstanding balance of the loan through resale, you will be on the hook for the difference. This is called a "deficiency balance". Simply having possession of something isn't adequate basis to decide you can do whatever you want with it. You have physical possession, but the lender is the first lien holder on the title until the loan is satisfied.
stackexchange-law
{ "answer_score": 5, "question_score": 2, "tags": "united states, vehicle, illinois" }
How to start a few QProcess in parallel and block until all of them have exited? I would like to start a few `QProcess` in parallel, and block until all of them have exited. I'm thinking of putting each `QProcess*` in a vector, and connect the `finished()` signal to a counter. The main thread busy waits until the counter reaches size of the vector. However, I'm concerned that the counter may not be thread safe, and it's not terribly efficient.
If you connect all of the finished() signals to a single object living in the main thread, you don't need to worry about protecting the counter. Each signal will get queued and processed in turn in the main thread. Just make sure you use a Qt::QueuedConnection when you connect. Amartel is correct about checking to make sure they launch before letting them run. **Edit:** As mentioned here (Is QProcess::finished emitted when process crashes in Qt?), you might consider connecting to the error() signal as well. Also, consider QtConcurrent. It was designed for this express purpose.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "c++, qt" }
dependencyManagement - imports and direct entries in parent poms My project and my parent pom both have a dependency management section. These sections both have direct entries and "imports" of boms (i.e. poms that purely consist of dependecyManagement and are imported). Now I try to figure out the evaluation order. My best guess: 1. parent pom imports 2. child pom imports 3. parent pom direct dependencyManagement entries 4. child pom direct dependencyManagement entries This means that later elements overwrite earlier elements. Is this correct? If so, can I change this behaviour so that the child elements always overwrite the parent elements?
Following the ticket issues.apache.org/jira/browse/MNG-5971 it is indeed true that direct management entries cannot be overwritten by imports in child projects. This behaviour should be altered in Maven 3.6.0, according to the statements in the ticket. As Maven 3.6.0 is distant future, I have to work around this problem. I will probably avoid direct management entries in the parent pom by constructing an auxiliary bom.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "java, maven, dependency management" }
Trigger a function when firebase notification receive while app is open I have a question about firebase notification service. I send notification from firebase console it receive successfully and i user click on notification then i open "TrackinActivity", this work fine. But if user open app and stay on "TrackinActivity" and then firebase notification receive i want without any refresh in TrackinActivity a funtion is trigger in TrackinActivity. which change some values in TrackinActivity without refresh. I mean in this function: @Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); } i want to call a function of that tracking activity without refresh.
for this you have to set a boolean variable in shared preference for example `isActivityOpened = true` set value `false` when you destroy `"TrackinActivity"` and set value `true` in `onCreate` of this activity @Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); if(isActivityOpened){//check sharedpreference //here send local broadcast message and receive in "TrackinActivity" //on receive method of local broadcast update some values in activity }else{ //here start activity as usual } } for getting details about local broadcast
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android, firebase" }
Windows Phone 8 (icon inside longlistselector datatemplate issue) I have an application which uses a data template to display items in a longlistselector. Inside the data template there are two images. One of the images, has a loaded event handler which checks if the image should be visible or not. This works perfectly and the image doesn't show up when not needed however when the user locks the screen and unlocks it or when they press the windows key and then return to the app it's all messed up. The image appears on places that it shouldn't. When normally navigating this does not occur. Also the image loaded event doesn't trigger when the user unlocks the phone or comes back after having pressed the windows key. Any help would be appreciated.
Use DataBinding to control the visibility (bind each item to an ItemViewModel)and also you could listen for the Application::Activated event if for some reason your UI state needs refreshing.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "windows phone 8" }
Is it a good idea to have database queries inside a data class? If I put database queries in a class that is representing a real world object, does that violate the design rule that entities must not have access to data sources? Here is an example class User { public function register { } private function save_user_data() { // database queries here, either in AR or ORM } }
To quote Steve McConnell (Code Complete [1,2]): > Sofware's Primary Technical Imperative is managing complexity. If you're writing a large scale app, in the long run it will reduce complexity to abstract data access. If you're writing a small to medium size app, it may make more sense to do your data access within the object itself, so long as you are clear and consistent with it. Reduce complexity in a way that makes sense.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "oop" }
node.js keep-alive web page I have a node.js app which routes events to a web page's "shotbox" which is similar to a chatbox on the home page. This shoutbox requires a sessionVar and sessionId that changes based on your browser, session_id, and some other things. I have been successful in getting these variables from my browser, but if I close that browser page, my node.js app no longer works. I assume this has to do with a keep-alive header or something (i'm not sure, I don't know all that much about http to be honest). I want to have my node.js app be free from needing the browser up at all. I'm thinking I could, upon starting up the node.js app, login into the site, and retrieve these custom variables. But how do I achieve the same effect that the browser accomplishes when staying open? Basically, how do I implement a keep-alive browser session in node.js?
The browser session is supposed to end when you close it, that's expected behavior. Your app shouldn't care if anywhere between 0 - [huge number] of sessions are active at any given time; it sounds like something really basic is wrong with your server. Post some code...
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "node.js" }
Matlab: multidimensional correlation coefficients Lets say that I have 10 datasets, 30 elements each. We can simulate it as: A = rand(30, 10); so each dataset is in one column. Now, I want to find set of `n` datasets which are correlated (or uncorrelated, whatever...). For `n=2` I can simply use `R = corr(A)` and find out that i.e. columns 1 and 3 show the highest correlation between each other. But what if I want to find set of three, or four correlated (or uncorrelated) datasets between each other? Is there a function for that or do I have to loop it somehow? Thanks!
You can treat this as a random simulation problem. You pick three (four) datasets and find the largest cross-correlation score, which I define as sum of pairwise correlation score. max_score = 0; max_set = []; max_prev = 0; counter = 0; while 1, idx = randperm(10); idx = idx(1:3); % or 1:4 for case of four score = R(idx(1), idx(2)) + R(idx(2), idx(3)) + R(idx(1), idx(3)); if score > max_score, max_score = score; max_set = idx; end counter = counter + 1; if mod(counter, 1000) == 0, % every 1000 iteration check convergence if max_score - max_prev < 0.0001, break; end end max_prev = max_score; end Althought it is not a deterministic process, it doesn't take long to converge and give you global optimal.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "matlab, multidimensional array, correlation, cross correlation" }
PostgreSQL 9.4 expand jsonb int array into table with row numbers Trying to wrap my head around postgresql 9.4 jsonb and would like some help figuring out how to do the following. Given the following example jsonb: ‘{“name1” : value1, “name2” : value2, “name3” : [int1, int2, int3] }’::jsonb AS table1.column1 Wanted: Return the “name3” array only, as a table with a return signature of TABLE( var_name varchar, var_value int, var_row_num int) So the resulting data would look like this: (‘name3’, int1, 1) (‘name3’, int2, 2) (‘name3’, int3, 3) Assume the array could be any length except zero and 'name3' is guaranteed to exist.
This seems to solve the problem (thanks, Bruno), but it seems like more code than should be necessary? WITH x AS (SELECT 'name3' as aname, jsonb_array_elements(column1->'name3') AS some_value FROM table1) SELECT x.*, row_number() OVER () FROM x; Anyone have a better solution?
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "arrays, postgresql, row number, postgresql 9.4, jsonb" }
Why does the main function in Java reside in a class? I just started studying Java. And the main function of the program always resides in a class. public class t{ public static void main(String[] args){ // do stuff } } I have studied C++, and in there the main function doesn't need to be in a class. Why in Java we have to do that? Why can't the main function exist in Java without a class, like it does in C++?
Probably for the same reason you put question marks at the end of a question: that's just how they decided it's done. The `main` method is the result of a convention that says "this is how the entry point's method signature should look" which doesn't exempt it from language semantics. Java does not support methods outside of classes/interfaces and as such it has to be contained in one.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 8, "tags": "java, class" }
What does the hex address mean in ldd output? For example: $ ldd /bin/ls linux-vdso.so.1 (0x00007ffcc3563000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f87e5459000) What do "0x00007ffcc3563000" and "0x00007f87e5459000" mean here? I have queried man page, according to the it: > ldd displays the location of the matching object and the (hexadecimal) address at which it is loaded. Does it mean the shared object's virtual address in the kernel space? But what if this shared object has not been loaded?
They _are_ loaded (if not before then certainly while running `ldd`), that's actually how `ldd` works. The `ldd` program uses the dynamic linker `ld.so` to find **_and load_** the objects needed to satisfy dependencies. This is described in the man-page for `ldd` along with a warning that you may want to heed about it possibly _executing_ the program you give it under certain circumstances (and giving an alternative). Basically, don't use it on untrusted binaries.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "linux, bash" }
What do Wild Silverfish Eat? Silverfish are famous for eating wallpaper paste. ![enter image description here]( The paste is made of starch mixed with water. Wikipedia says silverfish love starch > They consume matter that contains polysaccharides, such as starches and dextrin in adhesives.[4] These include book bindings, carpet, clothing, coffee, dandruff, glue, hair, some paints, paper, photos, plaster, and sugar. But all of these are artificial substances. I wonder what do they eat in the wild? I suspected they eat wood but a cursory search suggests they do not. Or maybe the articles I found are talking about them not eating wooden furniture. Perhaps they prefer to eat damp wood such as rotting logs in the wild. Most of the obvious info on Silverfish is about what they do inside your house, rather than in the wild. Does anyone know what they eat in the wild?
Silverfish are **shredders**. Shredders are... > ...responsible for processing coarse particulate organic matter (CPOM). CPOM is greater than 1 mm in size and typically derived from allochthonous sources, such as **woody debris** , **leaves** , and other **vegetation** [..]. Their **diet** includes sources of starch and protein, including grains, vegetables, fibers, sugars and fabrics. Silverfish can actually digest cellulose, a feat not shared by many animals. They are able to do so thanks to cellulase activity in microorganisms that live in their gut (Lasker & Giese, 1957). **Reference** **-** Lasker & Giese, _J Exp Biol_ (1957) **33** (3): 54–553
stackexchange-biology
{ "answer_score": 3, "question_score": 3, "tags": "zoology, entomology, behaviour, invertebrates, diet" }
Hardware support for non-power-of-two textures I have been hearing controversial opinions on whether it is safe to use non-power-of two textures in OpenGL applications. Some say all modern hardware supports NPOT textures perfectly, others say it doesn't or there is a big performance hit. The reason I'm asking is because I want to render something to a frame buffer the size of the screen (which may not be a power of two) and use it as a texture. I want to understand what is going to happen to performance and portability in this case.
Arbitrary texture sizes have been specified as core part of OpenGL ever since OpenGL-2, which was a long time ago (2004). All GPUs designed every since do support NP2 textures just fine. The only question is how good the performance is. However ever since GPUs got programmable any optimization based on the predictable patterns of fixed function texture gather access became sort of obsolete and GPUs now have caches optimized for general data locality and performance is not much of an issue now either. In fact, with P2 textures you may need to upscale the data to match the format, which increases the required memory bandwidth. However memory bandwidth is the #1 bottleneck of modern GPUs. So using a slightly smaller NP2 texture may actually improve performance. In short: You can use NP2 textures safely and performance is not much of a big issue either.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 7, "tags": "opengl, graphics, textures" }
ideal of holomorphic function that vanish on all but finite number of integers is not finite generated Let $\mathcal{O}$ be the ring of holomorphic function on $\Bbb{C}^1$. I want to show that the ideal of functions that vanish on all but a finite number of integers is not finitely generated, therefore the ring above is non-Noetherian. * * * My attempt if it's generated by $f_1,...,f_n$, my feeling is that I need to use something like the identity principle in some place, sorry I don't have idea.
Let $I$ denote that ideal and say $f_1, \ldots, f_n$ generate $I$. Note that by definition, there exists an integer $N$ large enough such that each $f_i$ vanishes on $N$. But then every function in $I$ must vanish on $N$. However, you can cook up a function which vanishes on $\Bbb Z$ and not on $N$, which would finish the job.
stackexchange-math
{ "answer_score": 5, "question_score": 2, "tags": "abstract algebra, complex analysis" }
#define PORTX.x in Avr Studio 5 (ATmega16) I'm writing a new and special library whith new algorithms and abilities for KS0108 GLCD Driver. I'm using ATMega16. My dot matrix GLCD dimension is 128x64. **How can I use #define code to define different port pins?** for example: **#define GLCD_CTRL_RESTART PORTC.0** IDE: **AVR Studio 5** Language: **C** Module: **128x64 dot matrix GLCD** Driver: **KS0108** Microcontroller: **ATMega16** Please explain which headers I should use? and also write a full and very simple code for ATMEga16.
In ATmega, pin values are assembled in PORT registers. A pin value is the value of a bit in a PORT. ATmega doesn't have a bit addressable IO memory like some other processors have, so you cannot refer to a pin for reading and writing with a single `#define` like you suggest. What you can do instead, if it helps you, is to define macros to read or write the pin value. You can change the name of the macros to suit your needs. #include <avr/io.h> #define PORTC_BIT0_READ() ((PORTC & _BV(PC0)) >> PC0) #define WRITE_PORTC_BIT0(x) (PORTC = (PORTC & ~_BV(PC0)) | ((x) << PC0)) uint8_t a = 1, b; /* Change bit 0 of PORTC to 1 */ WRITE_PORTC_BIT0(a); /* Read bit 0 of PORTC in b */ b = PORTC_BIT0_READ();
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c, c preprocessor, atmega16, avr studio5" }
Can list messages but cant create subscription I have an app that creates subscriptions for office365 users and does something whenever it gets a notification. For 99% of users it works fine. There's one user that I can't create subscription for even though he has an enabled exchange plan. When I try to create subscription for him I get status code `404` and message: `REST API is not yet supported for this mailbox`. However, I can list the user messages (i.e. mails) with API (GET request to ` Is it normal behavior? That user have no rest services enables for his mailbox (and therefore cant create subscription) but other rest services such as listing messages works just fine?
You are most likely getting this error because the organization has an hybrid deployment (Exchange on prem "linked" to the organization) and the mailbox that's failing is located on premises, not in the cloud. Your application should handle the error and/or let the administrators know that this mailbox is failing, but there isn't much that can be done besides migrating the mailbox. For reference
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "microsoft graph api, microsoft graph mail" }
integral and differential problem from my lecture 1 i got this problem from my lecture, 1\. integral equation, i need to know step by step to got the answer $$\int y^3 \sin(2x) dx$$ my friends said the answer is $-y^3 \cos^2(x)$, but i don't know how to get this. 1. differential equation, a. $\frac{Dm}{dy} (3y^2 + y \sin (2xy))$ b. $\frac{Dn}{dx}( 6xy + x \sin (2xy))$ my friend said again two of them have same answer, it said 6y + sin 2xy + 2xy cos 2xy but once again i don't know how to get thia, someone can tell me step by step please, i really appreciate it, thanks a lot.
If I'm interpreting your question correctly, you want to find: $$ \int y^3\sin(2x)dx, $$ $$ \frac{\partial }{\partial y}(3y^2+y\sin(2xy)) $$and $$ \frac{\partial }{\partial x}(6xy+x\sin(2xy)) $$ The first is an integral with respect to $x$, so we can pull the $y^3$ out: $$ \int y^3\sin(2x)dx=y^3\int\sin(2x)dx=y^3\left(-\frac{1}{2}\cos(2x)+C\right) $$ so your friend is incorrect. For the second, we differentiate with respect to $y$ so $x$ is treated as a constant: $$ \frac{\partial }{\partial y}(3y^2+y\sin(2xy))=6y+\frac{\partial }{\partial y}(y\sin(2xy))=6y+\sin(2xy)+2xy\cos(2xy) $$ so your friend is correct. For the third, we differentiate with respect to $x$ so $y$ is treated as a constant: $$ \frac{\partial}{\partial x}(6xy+x\sin(2xy))=6y+\sin(2xy)+2yx\cos(2xy) $$so that one is correct as well.
stackexchange-math
{ "answer_score": 0, "question_score": -1, "tags": "integration, derivatives" }
How to show shamsi date in django? I'm trying to make django's default 'DateTimeField' to show Shamsi (Persian) calendar, but I have no idea of how to do it. Is there any way to make this type of field use Shamsi completely or use it as it is and just converting to Shamsi when showing on the template?
I had this problem and solved it by just adding a textfield for shamsi date and converting the date manually each time. It't not the best way but it gets the job done!
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "django, persian calendar" }
Subset vector / replace values by lookup based on named vector with partial string matching I think somehow `grepl` might help, but I struggle with the following: Similar to subsetting a vector with a named lookup vector (aim is to replace the vector values with the lookup values) test <- letters[1:3] lu <- c(a = "a", b = "newb", c = "cool") lu[test] #> a b c #> "a" "newb" "cool" I wonder if I can use partial strings for names, so it matches only partially. test2 <- c("Athens hot", "Berlin warm", "Moscow cold") lu2 <- c(Athens = "a", Berlin = "newb", Moscow = "cool") # naturally not working lu2[test2] #> <NA> <NA> <NA> #> NA NA NA
We can use `grep` as the match/`[` is looking for an exact match sapply(names(lu2), function(x) grep(x, test2)) * * * Or can use `amatch` from `stringdist` with an appropriate `method` and `maxDist` library(stringdist) lu2[amatch(names(lu2), test2, method = 'jaccard', maxDist = 0.4)]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "r" }
Real number which is different from all rationals By diagonalization, it is possible to construct a real number $r \in [0,1]$ such that for every rational $q \in [0,1]$, there exists an index $i \in \mathbb{N}$ such that $r_i \neq q_i$ (where $x_i$ is the $i$'ith digit in $x$). Can we make a stronger claim, and construct a real number $r \in [0,1]$ such that for every rational $q \in [0,1]$ there exists an index $i \in \mathbb{N}$ such that for **every** $j \geq i$, $r_j \neq q_j$?
No. Consider the rational numbers 0, 0.111..., 0.222..., 0.333.., ..., 0.888... Any real number either shares infinitely many digits with one of these, or it has only finitely many digits which are not 9. But then it is after some point only 9s, so is equal to a terminating rational and has infinitely many 0s. If you prefer not to allow this equivalence, add 0.999... to the above list.
stackexchange-mathoverflow_net_7z
{ "answer_score": 2, "question_score": -1, "tags": "real analysis, irrational numbers" }
Post file using httpclient fluent API I always using httpclient fluent api to post messages because of the code is very clean. example : String html = Request.Post("URL") .connectTimeout(2000).socketTimeout(2000) .bodyForm(Form.form().add("type", "image").build(), Charset.forName("UTF8")) .execute().returnContent().asString(); After reading the httpclient document, I have found this: MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); builder.setCharset(Charset.forName(CHARSET)); builder.addBinaryBody("media", bytes, ContentType.MULTIPART_FORM_DATA, fileName); The question is how can I use fluent API to realize this function. I find `.bodyFile(new File(""), ContentType.MULTIPART_FORM_DATA)` but I don`t know how to set the form param name of the file.
HttpEntity entity = MultipartEntityBuilder.create() .setMode(HttpMultipartMode.BROWSER_COMPATIBLE) .setCharset(Charset.forName(CHARSET)) .addBinaryBody("media", bytes, ContentType.MULTIPART_FORM_DATA, fileName) .build(); String html = Request.Post("URL") .connectTimeout(2000) .socketTimeout(2000) .body(entity) .execute().returnContent().asString();
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "apache httpclient 4.x" }
Multiple file select only returns the last file I'm trying to upload images through a multiple `input` tag. buts only returning the last selected file. <input id="input1" name="img_1[]" type="file" accept="image/*" multiple="multiple" required /> When I try to get this File array on server size it returns the value of the last file select. $file = $request->file('img_1'); foreach($file as $f){ ... Even when I try to check the value in the console it shows the value of the last selected file. Can someone Kindly tell, what am I doing wrong here?
Multiple reasons : 1 - You may have forgot to add enctype="multipart/form-data" to your form. 2 - Did you tried to loop on your array, or uploading it with indexes : $files = Request::file('img_1'); die ($files[0]);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, php, html, laravel" }
How to push Ionic CalendarPlugin data to array Calendar.findAllEventsInNamedCalendar("Calendar").then(data => Hello, I am using Eddy Verbruggen's plugin to pull events from an IOS calendar. I want to store these into an array. How would I do so? So far the events from Calendar are coming out but not sure how to store x amount in an array.
As per the site, the response is something like, { calendar: "Kalender", endDate: "2016-06-10 23:59:59", id: "0F9990EB-05A7-40DB-B082-424A85B59F90", lastModifiedDate: "2016-06-13 09:14:02", location: "", message: "my description", startDate: "2016-06-10 00:00:00", title: "myEvent" } So, this is a common example of a JSON array object. To access it, you can iterate through the "data" object array. Calendar.findAllEventsInNamedCalendar("Calendar").then(data => .... for(var key in data){ console.log(data[key]); } To access a specific value in that object would be for(var key in data){ console.log(data[key].id); } To store it, var test ; test = data; this would then store the data into the test, in which u can iterate through the same as per above.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "cordova, ionic framework, ionic2, cordova plugins" }
Rails mailer template calculation I am new to rails and am writing a daily report email template. I am Outputting unique visitors, and calculating the difference between the 2 and displaying that as well with a + or - sign depending on if its positive or negative. Is there a better way to do this? Should I not be doing math inside the view? Unique Visitors: <%= number_with_delimiter(@stats["unique_visitors"]) %> <% uniquediff = @stats["unique_visitors"] - @stats["unique_visitors_yesterday"] %> (<% if uniquediff > 0 then %> + <% else %> - <% end %> <%= uniquediff %>)<br />
Try: ("+" if uniquediff>=0)+uniquediff.to_s `.to_s` turns `uniquediff` to a string, and the `("+" if uniquediff>=0)` bit evaluates to `"+"` if `uniquediff` is greater than or equal to zero, and nothing otherwise.. and you will already have a `"-"` if it is negative. =]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "ruby on rails 3, templates, view" }
Missing Assembly Can someone please help, I've managed to uninstall the wrong Nuget package and now I have the following error: > Error CS0234 The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
**Try to add some assembly by`NuGet Package Manager`, or clear `MEF Component Cache`.** **Suggestions:** 1. `Microsoft.AspNetCore.Mvc.Core`, then rebuild. ![enter image description here]( 2. `Microsoft ASP.NET Identity Framework`, then rebuild. ![enter image description here]( 3. Try to `Clear MEF Component Cache`. To fix this I deleted my Visual Studio's component model cache folder which can be found here. 4. Upgrad to the latest stable version of Visual Studio 2019.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "asp.net core" }
Ajax dropdown not working in mobile device In my Java spring application I have a form with Region drop down. On selection of particular region city list is populated using ajax. This functionality working fine in web browsers. But does not work from an iPhone or Android phone. The second dropdown is not populate. Is any solution for such problem ? Please help.
All my bets are on the Javascript code not being compatible with the mobile browsers. Or on Javascript being disabled there.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java" }
How to avoid overhead of continuous ajax request on keyup event? e.g. In a search form when user enter some text, at that time, AJAX request should send on each keyup event, with search key as query string. Search key will be value from input box. If user enters "ABCD", in this case first 3 AJAX request should get kill/cancel, because in 4th AJAX request searchkey will be "ABCD" $(document).ready(function(){ $("#searchInput").keyup(function(){ ajaxSearch( $("#searchInput").val() ); }); }); On keyup event I am calling following "ajaxSearch()" function. function ajaxSearch(searchKey) { $.ajax({ type: "get", url: " data: "action=search&searchkey=" + searchKey }).done(function() { /* process response */ }); }
var request; function ajaxSearch(searchKey) { /* if request is in-process, kill it */ if(request) { request.abort(); }; request = $.ajax({ type: "get", url: " data: "action=search&searchkey=" + searchKey }).done(function() { /* process response */ /* response received, reset variable */ request = null; }); }
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 9, "tags": "javascript, jquery, performance, optimization" }
Is there way to pass path parameter in Mountbank I was trying to pass path parameter using Mountebank. Below is working, but there path is static no any parameters. "predicates": [ { "equals": { "method": "GET", "path": "/accounts", "query": { "permissionId": "xxx" } } } ], "responses": [ { ..... } ] In case if I need to do `GET /accounts/[account-no]` where `account-no` is a parameter
Below regex worked, Please note use `matches` in case of regex instead of `equal` "predicates": [ { "matches": { "method": "GET", "path": "/accounts/\\d+", "query": { "permissionId": "xxx" } } } ], "responses": [ { ..... } ]
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "mountebank" }
Fetching Guild Categories I am attempting to fetch all of the guild's categories and list each channel inside of the category. Is it something like this? for category in ctx.guild.categories for channel in category.channels: print(channel.name)
Yes. If you wish to confirm this, you can review the `discord.py` documentation for Guild.categories and CategoryChannel.channels, or try running your own code.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, discord.py" }
access specific folder in Azure with ftp I have an app Service in Azure that contains some folders and files. There is a user who has to upload some files to an isolated folder or drive that my app can reach. He has to upload them via ftp. I know it’s possible to create an ftp with access to all content on the app service. But is it possible to limit the users access to only one folder or a specific drive that my app service can reach?
That is not currently supported. FTP access to an Azure Web App is 'all or nothing'. I would suggested using blob storage instead, which will give you fine grain control over this.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "azure, azure web app service" }
Strip away characters in array I am using a 3rd party script for uploading files and when I upload multiple files I get the names in this format: [{"file":"0:/gIpVCEAe4eiW.jpg"},{"file":"0:/5yA9n2IfNh65.jpg"}] I just want the actual file names. I wish I could post some code of what I have tried but I can't think of many options. I can't get .split alone to do what I want.
`map` over the array and return the `replaced` filename. You'll get a new array back. const arr = [{"file":"0:/gIpVCEAe4eiW.jpg"},{"file":"0:/5yA9n2IfNh65.jpg"}]; const out = arr.map(obj => { return obj.file.replace('0:/', ''); }); console.log(out);
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "javascript" }
Filtered Pubnub Twitter stream not returning results I'm consuming the PubNub Twitter stream and getting data on the console successfully. What I'm having trouble with, though, is the number of results. This is the code: PUBNUB({ subscribe_key: 'sub-c-78806dd4-42a6-11e4-aed8-02ee2ddab7fe' }).subscribe({ channel : 'pubnub-twitter', callback: processData }); function processData(data) { if(data.text.toLowerCase().indexOf("#brexit")>-1) { console.log(data.text); } } I'm getting results on my console for this too, but they're really slow (I had to wait about seven minutes to get two tweets, while on the Twitter app, there are are at least 3-5 tweets with this hashtag every minute). Is there a faster/more efficient way to filter the stream?
Are you using your own Twitter connection or the stream from this page? < This stream represents only a small fraction of the entire Twitter firehose, so it is very possible that you'd only get a hashtag match every few minutes. If you want a specific hashtag you should create your own Twitter to PubNub stream. I wrote this blog on how to do it with just a little bit of code. <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "twitter, pubnub" }
MATLAB: Enter to confirm input-dialog? I know there's a way to make the enter-key on the keyboard confirm the inputdlg() dialog, see here: Okay it's a workaround, the problem is, I have to store it in the matlab directory (because as said on the page: "Since it is dependent on several private functions, newid.m will only work if stored in this location.").. The problem now is, I want to make a code which doesn#t rely on user changes in the Matlab directory because of missing privileges... Is there still another (perhaps dirty) way to achieve this behaviour? Thanks!
Solution: 1. Copy the `newid.m` from to a arbitrary folder, e.g. into your projects folder 2. Go into the folder where the original `inputdlg()` is stored; you can find this out via `which inputdlg` (e.g. C:\Program Files\MATLAB\R2011b\toolbox\matlab\uitools\inputdlg.m) 3. Go into the `private`-subdirectory and copy the two files `getnicedialoglocation.m` and `setdefaultbutton.m` and paste them into your project's folder where the `newid.m` is located. Now call all your input dialogs by using `newid()` instead of `inputdlg()`
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 5, "tags": "matlab, permissions, dialog, user input" }
Remove post class twice For my wordpress child theme I'm using a function to remove the post class `has-post-thumbnail`. This class appears twice so I have to remove it twice with the function below: // Remove specific post_class() from Mytemplate add_filter('post_class', 'remove_has_post_thumbnail_class', 20); function remove_has_post_thumbnail_class($classes) { if(is_page_template('mytemplate.php') && ($key = array_search('has-post-thumbnail', $classes)) !== false ) unset($classes[$key]); if(is_page_template('mytemplate.php') && ($key = array_search('has-post-thumbnail', $classes)) !== false ) unset($classes[$key]); return $classes; } It works fine but I'd like to know if there is a cleaner way to do it, hopefully without repeating the `if()` statement twice.
You can use a simple foreach loop: function remove_has_post_thumbnail_class($classes) { if(is_page_template('mytemplate.php'){ foreach($classes as $key => $value){ if($value=='has-post-thumbnail'){ unset($classes[$key]); } } } return $classes; }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, wordpress" }
Blocking characters from PHP search script string I have a PHP search script that gets results based on tags assigned in a MySQL database. I would like to block certain things from the query string. For example **!** or **,** or **a** **How could I do this?** I hope people can understand my question. My current code is: if(!empty($_GET['q'])){ $keywords=explode(' ',$_GET['q']); foreach($keywords as $query){ $query=mysql_real_escape_string($query); $likes[]="keywords LIKE '%{$query}%'"; } $searchResult=mysql_query("select * from questions where ".implode('or ',$likes)."limit 1"); while($row=mysql_fetch_assoc($searchResult)){ $results="<div class='webresult'>{$row['result']}</div>"; } }
So I thought - you are trying to solve another problem wrong way. if you don't want to look for the _short_ words - do so: if(!empty($_GET['q'])){ $keywords=explode(' ',$_GET['q']); foreach($keywords as $query){ if (strlen($query) < 3) { $query=mysql_real_escape_string($query); $likes[]="keywords LIKE '%{$query}%'"; } } }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, html" }
Ampére-Maxwell's law in the absence of sources My question: If I have the Ampére-Maxwell law $$\oint_\gamma \mathbf{B}\cdot d\mathbf{l}=\mu_0\left(I_{\text{enc.}}+\epsilon_0\frac{d\Phi_S(\mathbf{E})}{dt}\right) \tag 1$$ where $I_{\text{enc.}}$ is the current due to a difference in potential $\Delta V$ and the $$\epsilon_0\frac{d\Phi_S(\mathbf{E})}{dt} \tag 2$$ is the displacement current $I_S$, why when we are in the absence of sources have I only the quantity $(2)$? If I have not a battery $\Delta V=0$ it's obvious that $I_{\text{enc.}}=0$. But the $(2)\neq 0$ why have I always a very small current near to zero that always circulates in a circuit or for other reasons? * * * **Translation of the text into Italian language of a Physics textbook** : in the particular case where there are neither charges nor currents in space, Maxwell's equations are simplified significantly. ![enter image description here](
The displacement current only exists when in your region of interest there exists an electric flux that varies over time. And if that is the case, then there’s a corresponding magnetic field. If there is no such flux, then $I_s=0$. These fields can exist in the absence of charges in the form of electromagnetic waves. This is because Maxwell’s equations allow for EM waves to exist in free space.
stackexchange-physics
{ "answer_score": 1, "question_score": 1, "tags": "electromagnetism, electric current, maxwell equations" }
Установка таймаута для запросов на сервер Зачем ставят таймаут для запросов на сервер?
Если таймаута не будет и сервер решит не отвечать, вы будете ждать ответа "вечно". А с таймаутом такой зависший запрос отвалится через некоторое время в любом случае. И делают так не только на андроиде.
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "android" }
function.require-once is giving error in my wamp server Im trying to run something like this: <a href="login.php?logout=1" id="logout">logout</a> <div id="main"> <?php require_once('getPhotos.php') ; ?> <div id="response" class="hidden" /> </div><!-- end main--> > But Im getting this error. **Warning: require_once(1) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\myPhotosWebsite\index.php on line 17 Fatal error: require_once() [function.require]: Failed opening required '1' (include_path='.;C:\php5\pear') in C:\wamp\www\myPhotosWebsite\index.php on line 17** > Any sugesstions...what iam doing wrong
* does the getPhotos.php exist? * where is it? * is it written exactly like that?
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php" }
Requirements gathering questionarie templete I have a client who ask me to redesign his e-learning website,and we had a first call he explained everything about his website.Now how I prepare a questionnaire template for asking him about all the functionalities in the website and about the design of the website. Thanks in advance.
I would start by asking what frameworks they are currently using (jQuery, Vue...) and what the backend setup is like (static, NodeJs, php...). From there you can ask where he wants to go with the website and what he wants done.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "web applications, requirements" }
Will published message with subscriber be persisted in the queue? I just did a quick test and seem that the published messages with bus.Publish does not get persisted in msmq until it has a subscriber. 1. Did I do something wrong in the configuration? 2. Is this by design? And Why? Thanks
That is how publish/subscribe works with MSMQ - when a publisher publishes a message, it will look for the queue names of the subscribers in its subscription storage, and send a copy of the message to each subscriber. It follows from this that if there's no subscribers, then no messages are actually sent. Logically, it works the same way when using multicast-capable transports like e.g. RabbitMQ - with RabbitMQ, then message will be published to the broker, which will then distribute a copy of the message to each subscriber - and again, if there are none, the message will no be delivered to anyone and thus cannot be seen anywhere. I hope that makes sense :)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "rebus" }
How to get this form and how to translate it 思わざるを得なくなる Found in the book for JLPT N2 and can't understand the sentence. I have highlighted the text I cant understand, rest of the text no need to translate, added just for clarifying context. Google translates this as "Because the person who said it has no choice but to lose." > **** []{}[]{}
theres a lot of these type sentences, and like what you got from Google Translate it pretty much does mean "No choice but to". It can ALSO mean "cannot help but..." In the context of that block you pasted, what that sentence is saying "By complaining, the individual cannot help but think by doing so he/she will be at a disadvantage" so like couple examples is like (looked up these sentences via google search): -Because of the bad weather, we have no choice but to cancel the trip. -The movie trailer alone was so good, can't help but be excited not exact translations, but hopefully you get the idea
stackexchange-japanese
{ "answer_score": 2, "question_score": 1, "tags": "translation" }
Как разбить по недостающим дням датафрейм и заполнить 0? < По данным не могу сделать resample по дням; при resample появляются несуществующие даты до декабря 2020 года. Как заполнить новые дни 0? df_ = df.resample('D').mean(); df2 = df_['2017-04-05':'2020-01-30'] Когда я делаю так, то нужные реальные данные заменяются средними, а мне надо, чтобы заменялись только null на 0.
Насколько я понял из документации по Pandas, можно сделать так: df.resample('D').asfreq().fillna(0) asfreq() - взять получившиеся после ресемпла данные "как есть" (не заполнять промежутки) fillna(0) - заменить везде NA на указанное значение (в данном случае 0)
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python" }
How to create documentation with devtools while building a package? Well, I want to create a documentation in my package project but I get this error: library(devtools) > devtools::document() Updating varbinq documentation Loading varbinq Error: contains a blank line why when I have no blank line in my function! It looks like this: #' function which do something #' #' @param x a value of something #' @return a value of something2 #' @examples #' f(2) f <- function(x){ x+2 } maybe it's because of others functions?
This might happen when there's a blank line in the package DESCRIPTION file.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "r, devtools" }
What's the real utility of make and ant? While i'm developing in C/C++ and Java, i simply make a compile.bat script that does everything, that's fine for me. Why should i use make and why should i use ant?
Suppose you have 1000 source files and change just one of them. With your .bat script you will have to recompile the lot, with make you recompile just the one that changed. This can save quite a bit (read hours on a big project) of time. Even better, if you change one of your header files, make will re-compile only the source files that use that header. These are the two main features that have meant make and its offspring are used for all serious software development with compiled languages.
stackexchange-stackoverflow
{ "answer_score": 22, "question_score": 6, "tags": "java, c++, c, ant, makefile" }
Potatoes left in the soil for winter I did not have time to dig out the purple potatoes I've planted during the spring, now it's early winter, not much frost is expected in this area. Will they survive if I leave them in the soil and will they grow in the spring again? Shall I dig them out now? Shall I harvest them during next summer?
Yes, they will growth again. Potatoes are the winter house of potato plant ( _Solanum tuberosum_ ). But you will have too many plants. I think in spring, you should harvest them and replant some of them (as the original distance). If you will do this early in spring, you can eventually eat the rest of potatoes, you should check visually that they are still full and no green parts. This was a "traditional" way to store potatoes (and other vegetables) in winter: putting them under dirt/sable. But usually it is done inside, humid but not wet. So you should check. In any case, you can use all of them as seed potato, for next harvest.
stackexchange-gardening
{ "answer_score": 6, "question_score": 6, "tags": "overwintering, potatoes" }
PrimeFaces : Supporting which Web Browser & which OS platform I am very new in using Primefaces. I & our team planning to write Web Application that need to be running on Web Browser on both Windows OS and Mac OS . Here are my questions that need help for the answers : (1) Can we develop Web Application be able to run on Web Browser on both Windows OS and Mac OS ? (2) What are Web Browsers on Windows OS that Primefaces support ? Which ones are the most compatible ? (3) What are Web Browsers on Mac OS that Primefaces support ? Which ones are the most compatible ? Thank you very much in advance. Best Regards Pearapon Bangkok, Thailand
I would suggest the following: create a test primefaces application which contains all component that your application will use (even better if you test also nesting the components) with a mocked backend. Then test your test ui in all desired browsers on desired platforms but on differents OS it shouldn't be different. I only work with windows but I test the application on Chrome, Firefox, IE, Safari and Opera. The only significant problems I faced was with CSS. E. g. a component does not use the full width etc.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "primefaces" }
How can I flatten a simple array without writing a loop operator explicitly? I'd like to turn a simple multidimensional array into an even more simple array. Turn this: Array ( [0] => Array ( [id] => 123 ) [1] => Array ( [id] => 456 ) ... [999] => Array ( [id] => 789 ) ) Into an array like this: Array ( [0] => 123 [1] => 456 ... [999] => 789 ) I'd like to do so without foreach `foreach`. Is this possible in PHP? Here's how I can already solve it with a `foreach` loop: $newArr = array(); foreach ($arr as $a) { $newArr[] = $a['id']; } $arr = $newArr; I'd like to do it without looping. Can you help?
You could `map` it: $arr = array_map(function($element) { return $element['id']; }, $arr); Since `array_map` probably internally loops, you could do it truly without looping: $arr = array_reduce($arr, function($arr, $element) { $arr[] = $element['id']; return $arr; }); **But there's no reason to not loop.** There's no real performance gain, and the readability of your code is arguably decreased.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "php, arrays, loops, multidimensional array, foreach" }
Commutator subgroup of a group of order $8q$, where $q$ is odd prime. > Let $G=\langle a,b :a^8=b^q=1,a^{-1}b a=b^{-1}\rangle$ be a group of order $8q$, ($q$ is odd prime). Then what will be the commutator subgroup of this group $G$. What have I done: If $x$ and $y$ be any two elements of $G$, such that $x,y \in \langle a\rangle$ or $x,y \in \langle b\rangle$ then $[x,y]=1$, and if $x \in \langle a\rangle ,~ y \in \langle b\rangle$ then $x=a^{i},~ y=b^j,~\text{for some $i~\text{and}~ j$}$, then the commutator $[x,y]=xyx^{-1}y^{-1}=a^ib^ja^{-i}b^{-j} \in \langle b^2\rangle$. This is similar like commutator operation in Dihedral groups $D_n$ of order $2n$. But if $x=a^ib^j$ and $y=a^lb^m$, for integers $i,j,l ~\text{and}~m$ then what we can do for $[x,y]$. I am stuck here, please help me.
I am writing here to make this thread answered. First, let $H$ be the subgroup generated by $b$. Then, as seen, $H$ is normal and isomorphic to $C_q$, where $C_n$ is the cyclic group of order $n$. We have the splitting exact sequence of groups $$1\to H \to G \to C_8\to 1\,.$$ Thus, $G/H\cong C_8$ is abelian, so the commutator subgroup $K$ of $G$ is contained in $H$. It is easy to see that $K=H$. Now, from the above paragraph, we see that $G$ is the internal semidirect product $\langle b\rangle\rtimes \langle a\rangle$, with $\langle b\rangle\cong C_q$ and $\langle a\rangle\cong C_8$. Writing each element of $G$ as $b^ua^v$ with $v\in\mathbb{Z}/q\mathbb{Z}$ and $u\in\mathbb{Z}/8\mathbb{Z}$, the multiplication rule of $G=\langle b\rangle\rtimes \langle a\rangle$ is given by $$\left(b^na^m\right)\cdot \left(b^la^k\right)=b^{n+(-1)^mk}a^{m+l}$$ for all $n,k\in\mathbb{Z}/q\mathbb{Z}$ and $m,l\in\mathbb{Z}/8\mathbb{Z}$.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "abstract algebra, group theory, finite groups, group presentation" }
Sum-up dates specified as strings $date = '2012-07-25 00:05'; $delay = '25'; Is there an easy way to add $delay to $date? The result must be '2012-07-25 00:30'.
Here's one way: $new_date = date("Y-m-d H:i", strtotime($date . " +" . $delay . " minutes")); Here's another: $date = new DateTime($date); $date->add(new DateInterval('P'.$delay.'i')); $new_date = $date->format('Y-m-d H:i')
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php, date" }
Does integral by parts apply when the integrand is discontinuous at some point? Suppose we have: $H(x)=a (x\ge0); H(x)=0 (x<0)$, where $a>0$ is a constant. Define $K(x)=ax (x\ge0); K(x)=0(x<0)$. When evaluate the integral: $$ \int_{-\infty}^{+\infty} H(x) f(x) dx $$ where $f(x)$ is continuous and differentiable. Does the above integral equal to the following expression? $$ -\int_{-\infty}^{+\infty} K(x)\frac{df(x)}{dx} dx + f(x)K(x)|_{-\infty}^{+\infty} $$ If not, please give me the reasons and a particular example.
On $[-C,C]$, apply integration by parts on $[-C,0]$ and $[0,C]$ respectively (both functions are continuous and differentiable here, so you're allowed to use the ordinary results). Then, $\int_{-C}^C H(x)f(x)\textrm{d}x=-\int_{-C}^0 K(x)f'(x)\textrm{d}x+[K(x)f(x)]_{-C}^0-\int_0^C K(x)f'(x)\textrm{d}x+[K(x)f(x)]_0^C.$ Now, analysing this bit, you see that we are done if we are allowed to say that $[K(x)f(x)]^0_{-C}+[K(x)f(x)]_{0}^C=[K(x)f(x)]_{-C}^C$ and this holds, since $K$ is continuous. The situation becomes more tricky when you're trying to fit the result on a function, the anti-derivative of which is not continuous. If the anti-derivative is bounded and $f(0)=0,$ then the result still works (just check the proof above).
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "calculus, integration" }
TYPO3 Extbase - Correct way to add unique-constraint? Does anybody know how to add an unique constraint to `ext_tables.sql` without creating problems like TYPO3 wanting to re-generate it every time you use the Database analyzer? Example: CREATE TABLE tableName( CONSTRAINT unique_iban UNIQUE (iban) ) CREATE TABLE tableName( iban varchar(255) DEFAULT '' NOT NULL UNIQUE ) With both ways the database analyzer wants to create the constraints, even if they are already there. First one additionally creates an error when you execute it: > Error: Duplicate key name 'unique_iban' Second one creates one new constraint every time you hit execute: ALTER TABLE tableName DROP KEY iban ALTER TABLE tableName DROP KEY iban_2 etc.
This worked ( _thanks to Christian Müller_ ): CREATE TABLE tableName( iban varchar(255) DEFAULT '' NOT NULL, UNIQUE KEY iban (iban) )
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "mysql, typo3, extbase" }
Getting More Performance out of a MacBook Pro So I've got a mid-2009 MacBook Pro 13". Integrated GPU so not a games machine but fast enough for doing .Net development in VMs. I love the little thing and wanted to give it a Christmas present so thought I'd mod it up a bit and give it a boost. I'm thinking of swapping out the stock 5400rpm HD with a faster drive (e.g. one of these new-fangled hybrid laptop drives with 4GB RAM that spin at 7200rpm) but was wondering if any of you had tried or knew of anything else I could change/upgrade/mod to squeeze more out of my laptop. Before you answer though, please be aware that I'm not sure I can run to putting in the 8GB of RAM Apple have suggested :-( EDIT: Is it true you can swap out the DVD burner for another drive? Thanks in advance.
Your only "easy" options are RAM and HDD. * For HDD, just get a good SSD. With VMs, you need quite a bit of storage, but it's worth it. * For RAM, the more, the better, especially with VMs. Spend what you're able. * * * Software-side, you can try going native with Boot Camp (although that can get ugly quickly with conflicting software -- I prefer multiple VMs somewhat specific to projects). If you only have a single Windows VM, remember that you can use your Boot Camp Windows installation as VM, so you get the best of two worlds. Only issue is with Windows 7 which some activation issues afaik. Windows XP works fine. * * * You can also try reinstalling OS X, or at least create a new, empty user account. Maybe you have too much cruft accumulated. This could speed up things quite a bit.
stackexchange-superuser
{ "answer_score": 3, "question_score": 0, "tags": "mac, performance, upgrade, macbook pro" }
SQL group rows by student_id on unique marks for any course I have a SQL table like this: Student_id mark course ---------- -------- --------- 1 15 math 1 15 physics 2 15 math 2 16 physics and want to produce this output: Student_id mark count ---------- -------- --------- 1 15 2 2 15 1 2 16 1 count is **number of single unique mark for each student (on any number of courses)**
SELECT `student_id`, `mark`, count(1) AS `count` FROM `the_table` GROUP BY `student_id`, `mark` ; If you want the results in a certain order, for now "GROUP BY" in MySql does it, but I've recently heard it's been deprecated in the latest versions so you might want to add an ORDER BY after the GROUP BY to future-proof a little.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mysql, select, group by" }
Irreducibility of $x^2 + 1$ in $\Bbb F_p$ I can show that in field formed by roots of $x^{4 \cdot 2^n + 1} - x$, the polynomial $x^2 + 1$ factors into linear factors. This gives $p = 4 \cdot 2^n+1\equiv 1 \pmod 4$. But how if $p \equiv 3 \pmod 4$, $x^2 + 1$ is irreducible in $\Bbb F_p$? So far, I think if $x^2 + 1$ is irreducible in $\Bbb F_p$ then $x(x^p-1)$ should not contain a factor $x^2 + 1$. Any value other than $p=4n+1$ does not give this factor. But why $p \equiv 3 \pmod 4$ in particular? **Why not $p \equiv 0 \pmod 4$ or $p \equiv 2 \pmod 4$**? Here it is done in example 1.0.3. > Workout: I was too stupid to realize that $p$ was prime. No primes have the form $p = 4n$ or $p = 4n+2 $
The polynomial $x^2+1$ factors into linear polynomials if the field has a fourth root of unity.
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "abstract algebra, ring theory, field theory, finite fields" }
regex for zip-code > **Possible Duplicate:** > What is the ultimate postal code and zip regex? I need Regex which can satisfy all my three condtions for zip-code. E.g- 1. 12345 2. 12345-6789 3. 12345 1234 Any pointers and suggestion would be much appreciated. Thanks !
^\d{5}(?:[-\s]\d{4})?$ * `^` = Start of the string. * `\d{5}` = Match 5 digits (for condition 1, 2, 3) * `(?:…)` = Grouping * `[-\s]` = Match a space (for condition 3) or a hyphen (for condition 2) * `\d{4}` = Match 4 digits (for condition 2, 3) * `…?` = The pattern before it is optional (for condition 1) * `$` = End of the string.
stackexchange-stackoverflow
{ "answer_score": 346, "question_score": 136, "tags": "regex" }
find wmic logicaldisk where DriveType how can set the DeviceID in a variable? output here is empty :( in cmd working : D:\>wmic logicaldisk where drivetype=5 get deviceid, volumename | find "bunny" F: bd50-bunny-comple here is my bat: @echo off d:\bunny.iso set isoname=bunny for /f "delims=" %%a in ('wmic logicaldisk where DriveType^="5" Get DeviceID^,volumename ^|find "%isoname%"') do ( set %%a ) echo %DeviceID% echo %volumename% Regards
Something like this perhaps: @Echo Off For /F "Skip=1 Delims=" %%A In ( '"WMIC LogicalDisk Where (DriveType='5') Get DeviceID, VolumeName"' ) Do For /F "Tokens=1-2" %%B In ("%%A") Do Set "DID=%%B" & Set "VOL=%%C" Echo Volume %VOL% is assigned to %DID% Timeout -1
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "batch file, cmd" }
set Volume level while mixing audios I am using below code to mix audios $cmd = 'ffmpeg -y -i audio.mp3 -filter_complex "amovie=src/bg.mp3:loop=999[s];[0][s]amix=duration=shortest out.mp3'; I want to set audio.mp3 volume to 75% and bg.mp3 to 50% , how can I do it ?
If you want to use the simple volume filter: $cmd = 'ffmpeg -y -i audio.mp3 -filter_complex "amovie=src/bg.mp3:loop=999,volume=0.5[s];[0]volume=0.75[t];[s][t]amix=duration=shortest" out.mp3';
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ffmpeg" }
Casimir Effect and parallel $D$-Branes In the well-known setup for the calculation of the Casimir effect, we take 2 perfectly reflecting plates, impose the appropriate boundary conditions on the relevant fields (scalar, vector, etc.) and calculate the energy of this configuration. So the most natural analog of plates (that is objects that impose boundary conditions on fields) in String Theory are $D$-Branes. This got me wondering whether a similar scenario can be realized in String Theory where we consider the energy of an open or closed string field theory interacting with 2 parallel $D$-Branes. The scenario I had in mind is loosely related to figure1. in Scattering of Strings from $D$-branes. I know that $D$-branes have open strings stretched between them, but that scenario would not be analogous to the Casimir effect setting because there is no **propagation**.
**No, there is no analogue of Casimir effect in between two parallel D-branes. The reason in supersymmetry.** Two D-branes interact with each other by means of open strings stretched among them. The one-loop amplitude for open strings streched between two D-branes is exactly computable (see equation (48) in TASI Lectures on D-Branes) and shown to be exactly zero. This shouldn't be so surprising, since parallel D-branes break only half of supersymmetry, therefore the "no-force condition" between two BPS states is satisfied.
stackexchange-physics
{ "answer_score": 1, "question_score": 2, "tags": "string theory, branes, casimir effect" }
Recurrence Relation when A = 0 Find the recurrence relation for: $a_k = -4_{k-1}-4_{k-2}$ when $a_0=0$ and $a_1=1$ Step 1: $r^k=-4r^{k-1}-4r^{k-2}$ Step 2: $0= r^2+4r+4 = (r+2)^2$ $r_1=r_2=-2$ $a_k=A(r_1)^k +Bk(r_2)^k$ (when roots are equal) $a_k=A(-2)^k+Bk(-2)^k$ $a_0=0=A(-2)^0+B(0)(-2)^0$ $a_0=0=A+B(0)1 = A=0$ $a_1=1=A(-2)^1+B(1)(-2)^1$ $a_1=1=-2A-2B=-\tfrac{1}{2}=A+B$ $a_1-a_0$:${0=A+0B}\over {-\tfrac{1}{2}=A+B}$=$\tfrac{1}{2}=B$ If $B=\tfrac{1}{2}$ Then $A+B=0$ then $A=-\tfrac{1}{2}$ So: $a_n=-\tfrac{1}{2}(-2)^n+\tfrac{1}{2}(-2)^n$ Does this look correct? I'm new to recurrence relations.
You started off great (although you might want to learn how to insert an implies symbol as in $\text{this } \implies \text{ that}$ so you are not writing something that looks like $-1 = -\frac12$). You went wrong after yourcorrect equation $A+B = -\frac12$. You already had correctly shown that $A = 0$ so you should have then said that $B = -\frac12$. And then the solution would be $$ a_n = -\frac{n}{2} (-2)^n $$
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "recurrence relations" }
controlling R output I have this code: x <- rnorm(10) print(x) is returning as output: [1] -0.67604293 -0.49002147 1.50190943 0.48438935 -0.17091949 0.39868189 [7] -0.57922386 -0.08172699 -0.82327067 0.07005629 I suppose that R is having a limit of characters per line or something and that is why is splitting the result in 2 lines. I am building a service based on the output of R. What should I do in order to get it in one line?
Than it is better to tell R to output things in a way that will be convenient to your wrapper; check out string functions like `paste()`, `sprintf()` and push the result into output with `cat()`; for instance putting numbers in a column could look like: x<-rnorm(10) cat(paste(x,collapse="\n"),"\n") what outputs just: 0.889105851072202 0.86920550247321 0.817785758768382 -0.0194490361401052 1.13386492568134 0.0786139738004322 0.7431631392675 0.93881227070957 0.534225167458455 1.08265812080696
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "r" }
How to float elements in a masonry layout like magazine/newspaper? I am trying to achieve a layout where items will float like newspaper/magazine article sections. It is something similar as what jQuery's Masonry does. But I was trying to achieve that only using CSS3. I thought perhaps the `box` display property could do it. Although after trying for few times, I wasn't able to make the items slide down after the parent column width as fulfilled. Is there any way to achieve this layout only using CSS? The markup would be something like this: <article> <section>...</section> <section>...</section> <section>...</section> <section>...</section> </article> Here a section would float left and adjust itself on the columns queue where better fit (and not bellow the baseline of the previous one, as simple float does).
It's possible using CSS columns. Here is a good explanation. CSS: div{ -moz-column-count: 3; -moz-column-gap: 10px; -webkit-column-count: 3; -webkit-column-gap: 10px; column-count: 3; column-gap: 10px; width: 480px; } div a{ display: inline-block; /* Display inline-block, and absolutely NO FLOATS! */ margin-bottom: 20px; width: 100%; } HTML: <div> <a href="#">Whatever stuff you want to put in here. Images, text, movies, what have you. No, really, anything!</a> ...and so on and so forth ad nauseum. </div> Also, I found this site by searching "CSS Masonry" on Google. It was the second result.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "layout, css, css float, jquery masonry, flexbox" }
Working with tempfiles in Ruby I would like to open a tempfile in user's editor ($EDITOR), let the user to write text there, and once he closes this file to use its contents somehow (e.g. inject in another file). What would be the most appropriate method to achieve this in Ruby 1.9.2?
I don't think that Tempfile is even needed here. All you need to do is create a temp file, let's say in /tmp, with an unique file name, and pass it to system( with the correct editor set. Something like this: def editor_command ENV.fetch('EDITOR') { 'vi' } end temp_path = "/tmp/editor-#{ Process.pid }" system "#{ editor_command } #{ temp_path }" puts File.read(temp_path) The problem with Tempfile, is that it assumes that the control over the file is always within your app, but you'll want to open the file in another OS process. For creating the file name, you can use `SecureRandom` of ruby's std lib. <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "ruby, file, ruby 1.9.2, temporary files" }
Checking NSMutableArray content I'm developing an iPhone app. I have the following **INIT** code: shapes = [NSMutableArray arrayWithCapacity:numShapes]; After that, I want to do the following: - (CGSize) sizeOfShapeType:(ShapeType)type{ CGSize shapeSize = CGSizeMake(0, 0); if (shapes != nil) { for(Object2D* obj in shapes) if (obj.figure == type) { shapeSize = obj.size; break; } } return (shapeSize); } But I always get a **EXEC_BAD_ACCESS** because all shapes in shapes array are null. How can I check if an Object2D is null? I get the exception here: for(Object2D* obj in shapes)
arrayWithCapacity returns autoreleased object, so you must retain it to make sure it won't get deallocated prematurely: shapes = [[NSMutableArray alloc] initWithCapacity:numShapes]; or // .h file @property (nonatomic, retain) NSMutableArray *shapes; // .m file @synthesize shapes; // your init method self.shapes = [NSMutableArray arrayWithCapacity:numShapes]; For the latter solution you need to declare property with retain attribute for shapes ivar.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "objective c, nsmutablearray, exc bad access" }
How do I trouble shoot input fields that won't focus? I'm not sure what happened but when I touch or click any of my input fields they don't become focused. I can still log the touch or click event on these inputs though. Where can I start to trouble shoot this issue? The code base is large so it's hard for me provide exact context or exact code that might be causing the issue. Thanks for any direction. :thanks for the suggestions so far. EDIT: Still haven't figured it out but I am still able to tab to the inputs and focus on them. If that helps anyone try to help with the vague context I'm providing. Thanks again.
I'd look through the code for anything that binds click or focus events. Something within those event handlers must be causing the problem.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript, jquery" }
OpenLayers time to layer (time control) I am new to OpenLayers and I would like to have something takes (date+time) and to get (layer) on the map E.g I have layers for the Weather in (15.02.2010), (16.02.2010) and so on. for example.. user enter (date+time) and the result (layer of the same date on the map) Are there any ideas? Example? API!
Adapted from the OpenLayers example: <input type="text" name="customParam" id="customParam"> <button onclick="showIt()">show it</button> <script> let source = null; const map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }) ], view: new ol.View({ center: [0, 0], zoom: 2 }) }); function showIt() { const customParam = document.getElementById("customParam").value; const isNew = (!source); if(isNew) { source = new ol.source.XYZ(); } source.setUrl(` source.refresh(); if(isNew) { map.addLayer(new ol.layer.Tile({ source: source })); } } </script>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, time, openlayers, tile" }
pyqtgraph : I want to execute pyqtgraph in new process Dear pyqtgraph masters, I want to execute pyqtgraph in a newly created process. In my project there is a python module : trading.py. This module makes a new process using this code p = Process(target = realDataProcess.realDataProcessStart, args=(self.TopStockList, self.requestCodeList, self.account)) And you know, To maintain pyqtgraph displaying the computer moniter, we have to use pyqt loop like below. QApplication.instance().exec_() But in new process, It seems that Above code doesn't work. My graph pops up and suddenly disappear..... Is there any solution about this? please help me out.
My experience with multiprocess and pyqtgraph is, that you can't create a new pyqtgraph window on new processes. Therefore, you can only use pyqtgrahp on your **main process**. I think there was the explanation somewhere on the net. If you want to create additional processes to do something, besides pyqtgraph, put your pyqtgraph code below if **name** == ' **main** ': Otherwise, you will have as many windows as you have processes.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, pyqt, pyqtgraph, multiprocess" }
Is there a way to open the JFace ElementTreeSelectionDialog unfolded? as the title already says... I'd like to open a ElementTreeSelectionDialog with the Tree already unfolded. Is there any way? Regards, Michael
The ElementTreeSelectionDialog doesn't have this capability out of the box, but you can easily extend it to add this behavior. Simply subclass it and override the createTreeViewer method. After calling super version of this method, you will have a handle on initialized TreeViewer for the dialog. At that point, it is simply a matter of using TreeViewer.setExpanded() or TreeItem.setExpanded() API to expand as little or as much as you'd like.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "java, eclipse, eclipse plugin, jface" }