INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Dotnet for Linux: Console Input Cursor Navigation When using console input in .NET on Ubuntu (e.g. `Console.ReadLine()`), I am unable to use the arrow keys, home/end keys, etc to move the input cursor. Is there some way to enable this? It's getting rather irritating not being able to go back and correct typos without deleting everything in-between. Bonus points if the up/down-arrows can be used for input history.
You should install the NuGet package `ReadLine`. <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, .net, vb.net, ubuntu, .net core" }
Bulk read of all documents in an elasticsearch alias I have the following elasticsearch setup: * 4 to 6 small-ish indices (<5 million docs, <5Gb each) * they are unioned through an alias * they all contain the same doc type * they change _very_ infrequently (i.e. >99% of the indexing happens when the index is created) One of the use cases for my app requires to read all documents for the alias, ordered by a field, do some magic and serve the result. I understand using deep pagination will most likely bring down my cluster, or at the very least have dismal performance so I'm wondering if the `scroll` API could be the solution. I know the documentation says it is not intended for use in real-time user queries, but what are the actual reasons for that? Generally, how are people dealing with having to read through all the documents in an index? Should I look for another way to chunk the data?
When you use the scroll API, Elasticsearch creates a sort of a cursor for the current state of the index, so the reason for it not being recommended for real time search is because you will not see any new documents that were inserted after you created the scroll token. Since your use case indicates that you rarely update or insert new documents into your indices, that may not be an issue for you. When generating the scroll token you can specify a query with a sort, so if your documents have some sort of timestamp, you could create one scroll context for all documents with `timestamp: { lte: "now" }` and another scroll (or every a simple query) for the rest of the documents that were not included in the first search context by specifying a certain date range filter.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "elasticsearch" }
Are there list building macros in PGF/Tikz? In Mathematica, C# linq, or other languages, we can use auxiliary functions to produce list of certain pattern. For example: 1. In Mathematica, we can use `Table[]` or `Range[]` to produce a list of numbers in the specified pattern. 2. In C#, we can also use `Range` to produce a list of consecutive integers. I need this kind of function also in PGF/Tikz to be consumed by `\foreach`. Are there list building macros in PGF/Tikz?
TikZ's `\foreach` accepts a lot of abbreviated lists. Examples include * `\foreach \x in {1,2,...,6} {\x, }` yields 1, 2, 3, 4, 5, 6, * `\foreach \x in {1,3,...,11} {\x, }` yields 1, 3, 5, 7, 9, 11, * `\foreach \x in {Z,X,...,M} {\x, }` yields Z, X, V, T, R, P, N, * `\foreach \x in {0\pi,0.5\pi,...\pi,3\pi} {$\x$, }` yields 0π, 0.5π, 1π, 1.5π, 2π, 2.5π, 3π, For more details see “Repeating Things: The Foreach Statement“ in the TikZ manual (its Chapter 56 in the v2.10 manual).
stackexchange-tex
{ "answer_score": 5, "question_score": 4, "tags": "tikz pgf, loops, foreach" }
enable clicking on links in webview How do I enable clicking on links in my mac osx webview? I have the following code but I don't know what methods to implement for the policy delegate... @synthesize myWebView = _myWebView; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification /* webview setup here, everything works fine except cannot click links in webview..... */ //setup my delegate _myWebView.policyDelegate = self; } //Now what?.... Thanks.
WebView doesn't have restriction on links. But if you need a custom behavior when clicking on a link in your web view, you should implement "webView:decidePolicyForNavigationAction:request:frame:decisionListener:" in your policy delegate. Then you you get the action type from the action information dictionary and you do your custom behavior if it's a link clicked event. Example: - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id < WebPolicyDecisionListener >)listener { NSUInteger actionType = [[actionInformation objectForKey:WebActionNavigationTypeKey] unsignedIntValue]; if (actionType == WebNavigationTypeLinkClicked) { //Do your stuff } else { [listener use]; } }
stackexchange-stackoverflow
{ "answer_score": -2, "question_score": 3, "tags": "objective c, macos" }
Please burninate the [problem] tag We've had it before and way before that, and also on SO, but the "problem" (which is problem) seems to be reappearing. Can we please get rid of this meta-tag _again_? By the way: There are a few untagged questions left to clean up.
`<waves hand>` I see no problem here. (but seriously should we blacklist this?)
stackexchange-meta_superuser
{ "answer_score": 5, "question_score": 6, "tags": "discussion, status completed, retag request, meta tags" }
Is it possible to control gui tools that do not have cli support with cli? How can we manage a program that can only be used from a graphical interface through the bash shell. I'm not just saying to running the program. I mean being able to use the functions of the program from the command line. Is there a method where I can keep track of which commands the graphical interface is executing in the background? Or any alternative method that I can use the graphical interface via cli?
No, not in general. You can see what syscalls is the program using with `strace` but not the "commands" it is using. If you only need to control a running GUI program from CLI, you can try `xdotool` to "press" keys and move/click with the mouse. It would be hard to really control the program, but if you need something simple, it could do the trick. Other option would be to use Dogtail. It's a tool for testing GUI and uses accessibility interfaces to control the application. You can write a simple Python script to control the app and it should also work with the "fake" Xvfb X server.
stackexchange-unix
{ "answer_score": 4, "question_score": 0, "tags": "bash, command line, gui" }
a limit by Gosper involving a product of arctan and $4^{1/\pi}$ On the Wolfram page about pi formulas, there is this curious limit by R. W. Gosper (130) $$\lim\limits_{n\to\infty}\prod\limits_{k=n}^{2n}\dfrac{\pi}{2\arctan k}=4^{1/\pi}.$$ The only reference given is an entry from 1996 in some forum. Has anybody a proof or reference for this or similar formulas?
Here is a sketch, which can be completed to a proof. Asymptotically (i.e. for $k$ large), $\ln\left(\frac{\pi}{2\arctan k}\right) = \frac{2}{\pi k} + O(\frac{1}{k^2})$. Sum termwise to get $$\frac{2\Psi(2n+1)}{\pi} - \frac{2\Psi(n)}{\pi} + \sum_{k=n}^{2n} O(\frac{1}{k^2})$$ Use the propreties of $\Psi$ to simplify this to $$\frac{2\ln 2}{\pi} + \frac{\Psi(n+1/2)}{\pi} -\frac{\Psi(n)}{\pi} + \sum_{k=n}^{2n} O(\frac{1}{k^2}) $$ Now, for $n$ large, this is asymptotically $$\frac{2\ln 2}{\pi} + O(\frac{1}{n}).$$ All the terms in the product at positive, so taking the logarithm was legitimate. The termwise sum can similarly be justified.
stackexchange-mathoverflow_net_7z
{ "answer_score": 9, "question_score": 4, "tags": "reference request, ca.classical analysis and odes" }
GetComponentInChildren with child index when there are multiple child objects How can I select from which child I want to get a component from using `.GetComponentInChildren` when I have multiple child objects? With this code I get the `MeshRenderer` of the first child only. selectedObj.GetComponentInChildren<MeshRenderer>().material.SetColor("_EmissionColor", Color.red);
If you know the unique name of the child object that has the component you are after, you can use `transform.FindChild("nameOfChildObject")` to find the specific child object you are looking for. So in your case you could say: selectedObject.transform.FindChild("nameOfChildObject").GetComponent<MeshRenderer>().material.SetColor("_EmissionColor", Color.red);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "c#, unity3d" }
Orchard CMS Exclude page from search The title says it all, but basically I'm looking to exclude a specific page from search results (or being indexed really). How can I accomplish this in the Orchard CMS? I'm currently using the standard Lucene search index mechanism.
I went with Bertrand's suggestion, just created a new content type and did not mark it to index. Works well.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, asp.net mvc, orchardcms" }
Div creating scroll bars < The last div is supposed to be 100% for height but I want it to show only till the end of page, not beyond that which creates scroll bars. When the data inside the div goes beyond the end of div, then i would like it to expand but not if the content is very little. |xx | |xx | |______| That is how I want it to be when there is not a lot of content. But when the content is a lot, I want it to be like the following: |xx | |xx | |xx | |xx_____| << The point where if the content exceeds this, then a scroll bar comes up |xx | |xx | |_______| So basically, the scroll bar should come up if the content in the div crosses the page else, the scroll bars shouldn't come. Please help
Assuming you always know the height of the first two elements (which in your example you do), you could position the last element absolutely at the foot of the page with `overflow: auto` to provide scroll bars when neccessery: #last_div { position: absolute; top: 187px; bottom: 0; overflow: auto; } **JSFiddle:<
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "css, html" }
Remove Google Chrome Icon From Dash Search I just installed Chromium today and removed Google Chrome via `sudo apt-get purge Google-Chrome-stable` The application is gone, but the shortcut in my menu is still there. Does anyone have any ideas on how to remove it? Here's a screenshot of what I see when I type in "Chr(om)", which is how I typically search for Chromium. ![](
Let's check for the remaining launcher: ls /usr/share/applications/google-chrome.desktop if present, remove it with sudo rm /usr/share/applications/google-chrome.desktop You may also need to check the _applications_ folder in the user's home directory: `~/.local/share/applications/` and remove `google-chrome.desktop`. (thanks Tchalvak)
stackexchange-askubuntu
{ "answer_score": 6, "question_score": 3, "tags": "icons, unity dash" }
Get child element values using javascript How do I get all the href values which lie under `id="categoryName"` using javascript? <div class="makeStyles-categoryBreadscrumb-83" id="categoryName"> <a href="/">Home </a><a href="/category/shoes.html">Shoes</a><a>Boots &amp; Booties</a> </div> Here is what I have tried: document.getElementById("categoryName").innerHTML
You can use `.querySelectorAll("parent > child");` let elements =document.querySelectorAll("#categoryName > a"); elements.forEach((x) => { console.log(x); }) <div class="makeStyles-categoryBreadscrumb-83" id="categoryName"> <a href="/">Home </a><a href="/category/shoes.html">Shoes</a><a>Boots &amp; Booties</a> <a href="/">Bla </a><a href="/category/shoes.html">Shoes</a><a>Boots &amp; Booties</a> </div>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, html" }
один амперсанд в javascript function lovefunc(flower1, flower2){ return ((flower1 ^ flower2) & 1) == 1; } есть такой пример кода, подскажите пожалуйста что делает в данном примере один амперсанд '&' каретка '^'. гугл выдает только && (типа логические операторы). Спасибо
`&` и `^` \- это побитовые (bitwise) операторы. Побитовые операции действительно проводят вычисления над своими операндами - попарно над каждым битом из первого и второго операнда. Логические же операции сами по себе ничего не обрабатывают, они только проверяют условия и возвращают один из операндов. Например, логическое ИЛИ, `123 || 321`, возвращает `123`, т.к. для ИЛИ надо чтобы один из операндов был `true`, и проверки `123` на `true` достаточно для получения результата. alert(1 & 2); // 01 & 10 = 00 alert(1 ^ 2); // 01 ^ 10 = 11 (3) alert(1 && 2); // 01 && 10 = 2 - (true) alert(123 || 321); // 123 (true) дополнено @AndreyBakharev по мотивам <
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript" }
exit on error from noninteractive R scripts I have a script that I run from the commandline, like Rscript example.R and I'd like to have it tell me some debugging information when it exits. If I don't do anything special, if it hits an error, it exits, right there, and I see the error message. So, I added options(error=traceback) and then it gave me not only the error message but the stack at the time of the error, very useful. Great. **But** now the script continues on through to the end, tossing up a lot more errors. Why does setting the error change Rscript's behaviour on encountering an error? How do I get it to just exit after the first error, as before?
Ah-ha. The trick is to call `q()`. In the help for `dump.frames`: options(error = quote({dump.frames(to.file = TRUE); q()})) and to use `traceback` (and `function` instead of `quote`), options(error = function(){ traceback(); q()} ) would do it.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "r" }
Sequence satisfying condition conundrum Given the following statement: $(*)$ $\exists$ constants $c \in (0, \infty )$ and $\gamma \in (0,1)$ such that $\|\vec{x}_k - \vec{x}_{k+1}\| \leq c \cdot \gamma^k, \ \ \forall \, k \in \mathbb{N}$, I want to prove that $\| \vec{x}_p - \vec{x}_q \| \leq c \gamma^p / (1 - \gamma ), \ \ \forall \, 1 \leq p \leq q$ in $\mathbb{N}$. However, if we assume that $q=p+1$ then, by (*) we should have $\|\vec{x}_p - \vec{x}_{q}\| \leq c \cdot \gamma^p$, and not $\| \vec{x}_p - \vec{x}_q \| \leq c \gamma^p / (1 - \gamma )$. So where is the $1/(1-\gamma)$ coming from?
We have the following \begin{align} \|\vec{x}_p - \vec{x}_{q}\| &= \|(\vec{x}_p -\vec{x}_{p+1})+(\vec{x}_{p+1}-\vec{x}_{p+2} ) +\cdots +( \vec{x}_{q} -\vec{x}_{q-1})\| \\\ &\leq \|\vec{x}_p -\vec{x}_{p+1}\|+\|\vec{x}_{p+1}-\vec{x}_{p+2} \|+\cdot +\| \vec{x}_{q} -\vec{x}_{q-1}\| \\\ &\leq c\sum_{m=p}^{q}\gamma^n \\\ &\leq c\sum_{m=p}^{\infty}\gamma^n \\\ &=c\frac{\gamma^p}{1-\gamma} \end{align}
stackexchange-math
{ "answer_score": 3, "question_score": 2, "tags": "real analysis, sequences and series" }
Escaping period in Ack.vim I'm looking forward to search for the following pattern with **Ack.vim** : `.section` Where `.` should only match a period, and not any character. I tried the following: * `\.section` * `[.]section` * `-Q .section` What is the correct way of escaping the period?
From the documentation: For instance, '#'. You have to escape it like this `:Ack '\\\#define foo'` to search for `'#define foo'`. Use: `:Ack \\\.section`
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "vim, ack" }
If I am attacked from an area of heavy obscurement, am I under the effects of the Blinded condition? This is what the PHB (p. 183) says about Heavy Obscurement: > A **heavily obscured area** —such as darkness, opaque fog, or dense foliage—blocks vision entirely. A creature in a heavily obscured area effectively suffers from the blinded condition The Errata released to clarify Heavy Obscurement states: > A heavily obscured area doesn't blind you, but you are effectively blinded when you try to see something obscured by it. The Errata doesn't specify "suffers from" however while the PHB does. If I'm attacked from an area of heavy obscurement, am I under the effects of the blinded condition? An example would be if an archer fired an arrow through Fog Cloud at myself who is not in Fog Cloud.
# Yes, but so is the attacker. If you are in a fog cloud and subject to an attack, you are blind with respect to your attacker, and your attacker is blind with respect to you (assuming nobody has blindsight). The same is true if the attack is passing through the fog on its way to you. In the example you gave, the archer is 'obscured by' the fog cloud from your perspective; but you're obscured by the fog from the archer's perspective as well. You're blind with respect to the attack, so the archer has advantage; but the archer is blind with respect to you, so the archer has disadvantage, so it all cancels out and they're just rolling normally. That's assuming they can pick the right location to attack, of course. You can hide as long as the attacker's line of sight is obscured, and (depending on the DM) in this situation, the attacker will have to guess where to attack even without you doing an actual Hide action. If they pick wrong you're automatically missed.
stackexchange-rpg
{ "answer_score": 3, "question_score": 5, "tags": "dnd 5e, conditions, concealment, blind" }
How to prove that $\frac{1-z}{|1-z|}$ is a root of unity with $z=e^{i\frac{2\pi}{n}}$ Let $z=e^{i\frac{2\pi}{n}}$ with $n\ge 1$ > Then prove that $$ Z= \frac{1-z}{|1-z|}$$ is also a root of unity and find its order. Reminder $x$ is said to be the root of the unity of order $n$ if and only if $n$ is the smallest integer such that $x^n =1$. As a guess first I tried to compute $Z^n$ (without any reason but since $z^n =1$) but it turn out that $Z^n\neq 1.$ How can one find or guess the order of $Z$. Any tips are welcome
When you see $z-1$, it's usually a good choice to set $z=u^2$, in your case $$ u=\exp\left(\frac{i\pi}{n}\right)=e^{i\alpha} $$ which has $|u|=1$. Then $z-1=u^2-1=u^2-u\bar{u}=u(u-\bar{u})=2iu\sin\alpha$. Then $$ \frac{z-1}{|z-1|}= \frac{2iu\sin\alpha}{2\lvert\sin\alpha\rvert}=iu $$ because $\alpha=\pi/n$ and $\sin\alpha>0$. Now it should be easy. A different approach is to square the number $w=(z-1)/|z-1|$, to get $$ w^2=\frac{(z-1)^2}{(z-1)(\bar{z}-1)}=\frac{z-1}{z^{-1}-1}=-z $$ Now it's clear that $$ w^{2n}=(-1)^nz^n $$
stackexchange-math
{ "answer_score": 6, "question_score": 1, "tags": "complex analysis, algebra precalculus, complex numbers, finite groups" }
Sending Reactions on Bot messages in discord.js I am trying to create a wyr so the user can pick an emoji. I have used variations of the code below and I'm am unable to get the message to send to the message the bot sends. I did try the return (); but maybe I did it wrong because it did not work. Here is the code I am currently using. module.exports = { name: "wyr", description: "Would You Rather?", execute(message) { message.channel.send(dowyr()); function dowyr() { var theWyr = ["Would you rather...\n\:a: Have the ability to go to the future?\n\:b: Have the ability to go to the past?"]; return wry = theWyr[Math.floor(Math.random() * theWyr.length)]; message.react(""); message.react(""); } }, };
`message` is the message the user sent, so you need to point the `.react()` method to the message the bot sent, you can use `.then()` for that. So your code would be: module.exports = { name: "wyr", description: "Would You Rather?", execute(message) { message.channel.send(dowyr()).then((msg) => { msg.react(""); msg.react(""); }); function dowyr() { var theWyr = ["Would you rather...\n\:a: Have the ability to go to the future?\n\:b: Have the ability to go to the past?"]; return wry = theWyr[Math.floor(Math.random() * theWyr.length)]; } }, };
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "discord.js" }
Textual resolution of [Current User] and [Me] In a list-view filter, I think I want to use either `[Me]` or `[Current User]`. I can't find a list of possible filter variables with their possible resolutions anywhere (Sharepoint Server 2010). What values do these resolve to? That is, does me return a text value of `Doe, John` or `Doe,John` or `John Doe` or `Mr. John Doe`? I am interested in the same information for `[Me]`. Does anyone have a clue?
The short answer is: [Me] = domain\username It is returned as the login name with the domain prefixed.
stackexchange-sharepoint
{ "answer_score": 1, "question_score": 5, "tags": "list view, filter" }
create new vector from existing vectors by using "rep" Suppose I have the following two vectors, a<-c(2,3,5) b<-c(1,3,2) Now I want to create a new vector _c_ with this results from _a_ and _b_ , 2, 3, 3, 3, 5, 5 I tried this code, but it just does not work, I am stocked here. Help please. How can I get the results showed above? for (i in 1:3){ c<-rep(a[i], each=b[i]) }
`rep(a,b)` is what you're looking for.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": -2, "tags": "r" }
Cakephp 3.x how the get the session_id In PHP, To get the session id, we have to use like this: `session_id();` How can I get the id in Cakephp 3.x?
You can access session id as below, $this->request->session()->id()
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "php, session variables, session cookies, cakephp 3.0" }
Kafka topic creation command I am referring to a book on Kafka. To create a Kafka topic, it states: > Using the command line utility for creating topics on the Kafka server, let’s create a topic named replicated-kafkatopic with two partitions and two replicas: > > `kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic replicated-kafkatopic` While text states to create 2 partitions and 2 replicas, arguments passed are: 3 for replication-factor and 1 for partitions. Are arguments correct in context of what text states?
No, it must be a typo. If you want to create a topic with two partitions and two replicas, the command should be as follows: kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 2 --topic replicated-kafkatopic The command that you have provided, creates a topic `replicated-kafkatopic` with 1 partition (`--partitions 1`) and 3 replicas (`--replication-factor 3`).
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "apache kafka" }
Heroku and Java - No suitable driver I know there are lots of answers like this one and I've seen them all and tried what people suggested but nothing worked. I have this: String dbUrl = System.getenv("JDBC_DATABASE_URL"); connection = DriverManager.getConnection(dbUrl); After printing the value of dbUrl, I have this: jdbc:postgresql://ec2-54-217-213-156.eu-west-1.compute.amazonaws.com:5432/<DATABASE> ?user=<USER>&password=<PASSWORD>&sslmode=require I don't understand why but I always have the same error: java.sql.SQLException: No suitable driver found for jdbc:postgresql... I've tried doing in so many ways but I keep getting the same error. Everybody suggested the SSL thing but I have that. If anybody could help I'd be truly grateful.
I've solved my problem. For anybody that might be struggling with the same issue, here's what worked for me. I forgot to put the maven dependency plugin in my pom, so the mysql driver was not being found. Just add this to your pom: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals><goal>copy-dependencies</goal></goals> </execution> </executions> </plugin>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, postgresql, heroku, driver" }
Type deduction fails for array of enum interface In the following minimal example `useFoos(a)` is totally fine, but `useFoos(b)` gives a compiler error. interface FooInterface fun useFoos(foos: Array<FooInterface>) {} enum class FooEnum : FooInterface fun main() { val a = FooEnum.values() useFoos(a as Array<FooInterface>) useFoos(a) val b = FooEnum.values() useFoos(b) // Error: Type mismatch: inferred type is Array<FooEnum> but Array<FooInterface> was expected useFoos(b as Array<FooInterface>) } And idea why this is? And if it's not a compiler bug, but intended behavior instead, could somebody point me to the place where this behavior is specified/explained?
As explained by @IR42 in a comment, it's because of smart casts. Using the `out` keyword helps to make it work without casting. Corrected code: interface FooInterface fun useFoos(foos: Array<out FooInterface>) {} enum class FooEnum : FooInterface fun main() { val a = FooEnum.values() useFoos(a as Array<FooInterface>) useFoos(a) val b = FooEnum.values() useFoos(b) useFoos(b as Array<FooInterface>) }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "kotlin, interface, casting, type inference, type deduction" }
Create storage profile for launching Azure VM via Ruby I'm trying to create/delete VMs in Azure cloud using azure-sdk-for-ruby. I'm following the example in the compute API. There is one part that I can't understand: # create_storage_profile is hypothetical helper method which creates storage # profile by means of ARM Storage SDK. params.storage_profile = create_storage_profile How would I go about creating a profile for the new VM? I've looked through the storage API, but I didn't find anything.
There is an offical sample code for create a Azure VM using Azure SDK for Ruby, which you can find the code you want about `create_storage_profile` and `create_network_profile` via the keywords `storage_profile`, `storage_account`, `network_profile` and `create_vm`. Hope it helps.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "ruby, azure, azure resource manager, azure sdk for ruby" }
Keeping UI Elements in UINavigationBar across different Views I have a few UIElements in my UINvigationBar on the main screen of my iPad app. Namely a few buttons and a UISearchbar. I would like these items to remain in the UINavigationBar when ever a I push a new ViewController onto the navigation stack. At the moment I am not really sure how to do with, without setting up the nav bar over and over on each new screen. Also i am not sure where I would put the search bar logic so that it works on any screen. An excellent example of what I am trying to do can be seen on eBays current iPad app. How do I keep a "static" UINavigationBar on an iPad app and would I use a base view controller for the search maybe? Would appreciate any feedback on this! Thanks!
Create a subclass of `UIViewController` that does all of the nav bar setup. Have all of your custom view controllers inherit from that view controller.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "objective c, ipad, uinavigationcontroller, uinavigationbar" }
Wrong colours when converting TIFF image to PNG in ImageMagick I'm working on a PHP script that automatically converts TIFF images to PNG files. For that purpose, I use ImageMagick: $ convert a.tif a.png It works to some degree, however, the colours are very acute and deviant from the way they are pictured on my PC. To illustrate the problem, please have a look at the enclosed files, the include: * The Windows Live Foto Gallery output (that's pretty much how I want it to be) * The ImageMagick output (the mess I end up with) * The original TIFF file Has anyone an idea whether, and if so how, I can alter the ImageMagick colour interpretation? Thanks a lot!
Alright, thanks to ergosys, the problem was easily solved: I needed to apply ICC colour profiles. The XMP declared ISO 12647-2:2004, which was to be found at < $ convert -profile ISOcoated_v2_eci.icc -profile eciRGB_v2.icc a.tif c.png
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 10, "tags": "colors, imagemagick, tiff" }
Run TestNG class programmatically with parameters like a specific active profile and context configuration etc I have an integration tests class extended from AbstractTestNGSpringContextTests. I want to run test class twice, each time with a different profile programmatically and not by hard-coding profile and configuration xml as below. @ContextConfiguration(locations = { "classpath:MyBatisBeanConfiguration.xml" }) @ActiveProfiles("cloud") public class MyIntegrationTests extends AbstractTestNGSpringContextTests { @Test public void myTest() { //do something } }
You can use the VM argument spring.profiles.active to enable certain spring profile(s) in your tests (or any other application for that matter). Example: `-Dspring.profiles.active=cloud,someOtherProfile`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, spring, testng" }
dartium (chromium) error on yaml/src/loader.dart I keep getting this > Internal error: 'package:yaml/src/loader.dart': error: line 197 pos 32: unexpected token '?' _tryParseScalar(scalar) ?? new YamlScalar.internal(scalar.value, scalar)
`??` is a quite new extension (null-aware operators) to the Dart syntax. You probably use a Dart version that doesn't support it. Null aware operators were introduced with Dart 1.12 See < You can check your current Dart version with `dart --version` on the command line. The package using this new feature should have a SDK constraint that limits the package version to SDK versions that support this feature.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "dart, chromium" }
Where is WebsitePanel Server pool located on Windows? I need to find WebsitePanel Server pool on my PC. I don't know the location of it. Can anyone appoint me to that location. I don't know is it a part of IIS or something elese. Current configuration is Win 8 with IIS 7.5 installed. Than kyou
Is this what you are looking for? Adding a **WebsitePanel server** * Begin by going to Setup > Servers * Click Add New Server * In the server details box, select the server type "WebsitePanel" from the dropdown menu. * Enter the IP/Hostname of your Enterprise server install * Enter the username and password for the account that has permissions to create your users. The account has to be a reseller account with permissions to create packages under the top level hosting space your customers will be created under. * Tick SSL if you wish to connect using a SSL connection ref:< or this one WebSitePanel:007-Setting ACL for Root Organizational Unit ?
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "windows, iis" }
What does [a] stand for exactly? I'm doing some exercises from "Real World Haskell". One is to design a safe version of `init :: [a] -> [a]`. I'm supposed to start from `safeInit :: [a] -> Maybe [a]` This is what I have at the moment. safeInit :: [a] -> Maybe [a] safeInit [] = Nothing safeInit [a] = if length [a] <= 1 then Nothing else Just (take (length [a] -1) [a]) In GCHi, when testing `safeInit [1,2]` I get the error message > _*_ Exception: ch4exercise.hs:(21,1)-(24,44): Non-exhaustive patterns in function safeInit I was under the impression that `[a]` simply stands for a list (of any size) of `a`'s. What am I doing wrong?
As a type, `[a]` does stand for "a list of any size of `a`s". As a pattern however, `[a]` stands for "a list containing exactly one element, which shall henceforth be known by the name `a`". Similarly `[a,b]` would mean "a list containing two elements, the first of which shall be known as `a` and the second of which shall be known as `b`" and so. `[]`, as you already seem to know, stands for "a list containing exactly 0 elements". This is analogous to how you'd write list literals as expressions. I.e. if you write `myList = []`, `myList` is the empty list and if you write `myList = [x]`, `myList` is a list containing exactly one element, which is the value of the variable `x`.
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 3, "tags": "haskell" }
Azure Stream Analytics Tool for Visual Studio in 2019 preview I am just creating an Azure Stream Analytics using Azure Stream Analytics Tool for Visual Studio in 2019 preview version, but it is saying that the version of Visual Studio is not supported. I am sure that I have installed the required workloads and extensions. ![enter image description here]( I am also sure that I have connected to my Azure Subscription using the Server Explorer. ![enter image description here]( Any idea why? Is it really not supported yet or I am missing something?
Well, it seems like the extensions are not supported in the new Visual Studio yet. But it is not a blocker, we can still use the option "Provide data source settings manually" and complete the configuration. ![enter image description here]( Note: After configuring the Input, Output, Query when I try to Submit to Azure, the Visual Studio is getting closed. It seems like it is a bug. You can also consider using Visual Studio 2017 till the new release of the extension.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "azure, azure iot hub, azure stream analytics, stream analytics, visual studio 2019" }
Why doesn't distinct work in the run method of my query class? I want to get a distinct set of results based on an entity property. I am trying to run the following code. db.Query(EntityName, projection = ("entityProperty",)).run(distinct=True) I get the following error Unknown configuration option ('distinct') According to the GAE documentation distinct is part of the run method < Any idea what I am doing wrong?
I don't see anything wrong with your query. Are you using GAE dev server 1.7.4? It should be ok with that version.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "google app engine, python 2.7" }
Create a single class to map different object to a target object? I have a service (S) that receives an object of type 's', this service will be called by several classes (maybe 6) and each class has their own object a,b,c, etc. with the information necessary to fill object 's'. There is no big logic when setting the values of 's', just some `s.setPhone(a.getPhone())` calls. Would it be good practice to create a single class with one method for each object a,b,c and all of them return an object of type 's'? That way everything would be in a single file that would be called from the classes that will use the new service to create the object 's'.
This doesn't sound like a good idea: * your single "conversion class" would depend on all the classes A, B, C, that could ever potentially need to be converted to an `s`. * everywhere you invoke your service, you would then need your conversion class, and therefore have a dependency to a lot of other classes you might not need. * so you would have in the end a very tight coupling, which is no desired: every time you'd change one of the A, B, C classes, it could possibly require a change in your conversion class. Same, every time you create a new class to be converted to s. Keep the interface segregation and the single responsibility principles in mind. I'd rather propose to create an abstract interface with a single conversion method, and make A, B, C classes implement this interface.
stackexchange-softwareengineering
{ "answer_score": 4, "question_score": 5, "tags": "design, object oriented design, type conversion" }
Is it possible to retrieve the second dimension length of a 2 dimension array, if the first dimension is 0-length? Well, that might be a strange question, and maybe just because I'm not familiar enough with Java. So, I declared a 2D int array: int[][] arr = new int[0][10] Now, as you can see, the second dimension's length is 10, while the first dimension's length is 0. I'm not sure how Java treats these kind of arrays, but the compiler doesn't produce any errors, which means it's a legit declaration. Well, I passed the array to some function, and I want to retrieve from within the function, the length of the second dimension. Of course something like: arr[0].length won't work. is there another way to do this?
The objects created by `new int[0][10]` and `new int[0][20]` are equivalent. There _is_ no logical "second dimension" here. Effectively you're running something like this: int[][] createArray(int d1, int d2) { int[][] ret = new int[d1][]; for (int i = 0; i < d1; i++) { ret[i] = new int[d2]; } return ret; } Now if you translate that into your scenario, you'll end up with code which _never reads`d2`_. If you want to represent a general-purpose _rectangular_ array (instead of an array of arrays) you might want to consider creating your own type for it.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "java, arrays, multidimensional array" }
How do I check what is being repeated in the array? I need to know what is being repeated in an array, and I am not sure what method to use to do so. `[1,2,6,8,8,8,2]`. I need it to print `8 occurs 3 times` `2 occurs 2 times`. How would I do this. for(var i = 0; i < numberarray.count; i++){ }
let numbers = [1,2,6,8,8,8,2] let cs = NSCountedSet(array: numbers) cs.forEach { if cs.countForObject($0) > 1 { print("number: \($0) has an occurance of \(cs.countForObject($0))") } } Something like this? Output: number: 2 has an occurance of 2 number: 8 has an occurance of 3
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, arrays, swift" }
retina image on a 3gs or 3g phone I have a kind of problem where there are two set of photos in my photo viewer. One is a retina image and another is a image with less resolution. the size of the placeholder is around 300X200. The no retina based image is exactly the same size 300X200 and retina images is almost double the size. My question is what problem will we face when a high resolution image is placed in a non retina image, i know the image will get displayed for sure, but i want to know what could be other hidden issues. can someone surely say that a high resolution image in the placeholder is not going to create any image that will be fine. i know my question looks real silly, but want to clear that up.
Well there is only one problem, memory. Since the 3G and 3GS have less ram then 4/4S you will run out of memory faster.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "iphone, uiimage, retina display, iphone 3gs" }
I would like to know if a Research paper is possible for making a change in Open Source software tool I have been using this open-source network flow generator and after doing some research i was able to add a network classification engine based on ML into it, put it in other words i added a new feature into it. So i would like to know if a research paper is possible for such work?
I think in general, the answer would be no. However, if you can, somehow, show the usefulness of the tool by applying it to some difficult problem, then that falls more into the realm of research and so warrants publication. But it isn't the tool, per se, that classifies it as research. Note that in CS, many doctoral dissertations start out with the student building something. This can take a lot of time and effort. But then, they show that the tool is better in some way that the state of the art. It is that demonstration that gives it value and leads to the degree. Advances in operating systems and databases are often like this. Build a tool. Show that it extends the state of the art (faster, smaller, more secure,...). Now publish.
stackexchange-academia
{ "answer_score": 2, "question_score": 0, "tags": "publications, research topic" }
what is the LL(1) grammar for it statement? I want to convert LALR(1) grammar to LL(1) grammar especially if statement. I had used LALR(1) grammar for if statement IF_Stmt -> Matched|Unmatched. Matched -> if ( Expr_IF ) Matched else Matched | Other. Unmatched -> if ( Expr_IF ) Matched |if ( Expr_IF ) Matched else Unmatched. Here, I had realized that i have to remove Left factoring. After that i couldn't solve epsilon production problem... What is the LL(1) grammar for if-statement ?
IF_Stmt -> if ( Expr_IF ) Stmt Optional_Else_Stmt Optional_Else_Stmt -> (empty-string) |else Stmt.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "parsing" }
What should my Objective-C singleton look like? My singleton accessor method is usually some variant of: static MyClass *gInstance = NULL; + (MyClass *)instance { @synchronized(self) { if (gInstance == NULL) gInstance = [[self alloc] init]; } return(gInstance); } What could I be doing to improve this?
Another option is to use the `+(void)initialize` method. From the documentation: > The runtime sends `initialize` to each class in a program exactly one time just before the class, or any class that inherits from it, is sent its first message from within the program. (Thus the method may never be invoked if the class is not used.) The runtime sends the `initialize` message to classes in a thread-safe manner. Superclasses receive this message before their subclasses. So you could do something akin to this: static MySingleton *sharedSingleton; + (void)initialize { static BOOL initialized = NO; if(!initialized) { initialized = YES; sharedSingleton = [[MySingleton alloc] init]; } }
stackexchange-stackoverflow
{ "answer_score": 207, "question_score": 333, "tags": "objective c, design patterns, singleton, object initializers" }
How do I make tabs in a JTabbedPane rearrangeable? I want to be able to move my tabs in my jTabbedPane left or right to change the sorting order. I looked around but I noticed most of what I found is asking how to drag and drop a tab in. I just want to make it resortable so that I can move the rightmost tab to the left of the leftmost tab or any order I want. I know for table columns in a JTable, there is a method, something along the lines of JTable table = new JTable(); table.setReordering(false); //disables reordering of columns which prevents this so this functionality is already enabled with columns in tables but with tabs in JTabbedPanes, I cannot find any method similar to this but I'm thinking it would be something similar like tab.setReordering(true) as well but I don't see anything.
A quick search, yielded that it doesn't seem to be supported by Swing directly. Though this is fairly common with GUI frameworks, where you are often left to implement certain functionality yourself (e.g. I recently had to manually implement TreeCell to allow context menus on TreeItems). This prevents libraries from becoming monolithic unmaintainable messes. You can find an implementation of the drag-and-drop functionality here
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java" }
Is $2^{\frak{c}}$ separable? Let $2 = \\{0,1\\}$ be endowed with the discrete topology. My hunch was the following: Let $e_\mathbb{N}: \mathbb{N} \to 2^{2^{\mathbb{N}}}$ be the "evaluation map", that is, it is given by $$e_\mathbb{N}(n): 2^\mathbb{N}\ni f\mapsto f(n).$$ Then I hoped that $\text{im}(e_\mathbb{N})\subseteq 2^{2^{\mathbb{N}}}$ is dense, but I fear that if $\underline{1}\in 2^\mathbb{N}$ is the constant $1$-sequence, then $\pi^{-1}_{\underline{1}}(\\{0\\}) \cap \text{im}(e_\mathbb{N}) =\emptyset$. So am I just misremembering something, or is the mistake elsewhere? Maybe $2^{2^{\mathbb{N}}}$ is not separable at all?
You need to take the set of all (finite) Boolean combinations of your elements $e_\mathbb{N}(n)\in 2^{2^{\mathbb{N}}}$ (here I mean "Boolean combination" in the usual sense when you think of elements of $2^{2^{\mathbb{N}}}$ as subsets of $2^{\mathbb{N}}$). These Boolean combinations will still form a countable set, and actually are dense. Indeed, given a finite subset $S\subset 2^{\mathbb{N}}$, you can find a finite subset of $A\subset\mathbb{N}$ that distinguishes all the elements of $S$. Any function $2^A\to 2$ can then be written as a Boolean combination of the functions given by restricting $e_\mathbb{N}(n)$ for $n\in A$, and in particular this means that for any function $f:S\to 2$ there is a Boolean combination of the $e_\mathbb{N}(n)$ that agrees with $f$ on $S$.
stackexchange-math
{ "answer_score": 2, "question_score": 6, "tags": "general topology, separable spaces" }
Is this Lazy<T> considered a singleton? I need to be able to call this method IDatabase cache = CacheConnectionHelper.Connection.GetDatabase(); From anywhere on my application, I got this connection helper class from some azure page public class CacheConnectionHelper { private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() => { return ConnectionMultiplexer.Connect(SettingsHelper.AzureRedisCache); }); public static ConnectionMultiplexer Connection { get { return lazyConnection.Value; } } } The question is: 1. Is the above singleton and if not how should I change it, so that each time that I try get a Connection, its only using one instance and doesnt try to open more than one connection
Yes, that's a singleton because `Lazy<T>` makes sure that your factory delegate return ConnectionMultiplexer.Connect(SettingsHelper.AzureRedisCache); ...is only invoked once. It will be invoked the first time `lazyConnection.Value` is read. Remaining invocations will return the same value/instance that was returned from the first invocation (it is cached). For clarity, I would make `CacheConnectionHelper` static: public static class CacheConnectionHelper By the way, it looks like your code is copied from this MSDN article. > This provides a thread-safe way to initialize only a **single** connected ConnectionMultiplexer instance.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "c#, azure, singleton, stackexchange.redis, azure redis cache" }
wmic via .NET or C# All, Please forgive my ignorance of C#/.NET, I am absolutely new to both (mostly Java, C/C++) and find myself tasked with creating some code that performs the same thing as the "wmic qfe" and "wmic os" commands available at the DOS prompt. Can this be done? If so, any help is appreciated. I am trying to working my way through the System.Management.Instrumentation namespace since wmic is an acronym for Windows Management Instrumentation Command (according to Google), but have as yet to discover anything useful. Thanks in advance, Toddw
You will indeed need to use the System.Management namespace to perform WMI queries. There is lots info on using WMI from C#, Microsoft's is (archived) here.aspx) For your specific cases: qfe - query the Win32_QuickFixEngineering class os - query the Win32_OperatingSystem class
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "c#, .net, windows services" }
How to quickly estimate a lower bound on correlation for a large number of stocks? I would like to find stock pairs that exhibit low correlation. If the correlation between A and B is 0.9 and the correlation between A and C is 0.9 is there a minimum possible correlation for B and C? I'd like to save on search time so if I know that it is mathematically impossible for B and C to have a correlation below some arbitrary level based on A to B and A to C's correlations I obviously wouldn't have to waste time calculating the correlation of B and C. Is there such a "law"? If not, what are other methods of decreasing the search time?
Yes, there is such a rule and it is not too hard to grasp. Consider the 3-element correlation matrix $$\left(\begin{matrix} 1 & r & \rho \\\ r & 1 & c \\\ \rho & c & 1 \end{matrix}\right)$$ which must be _positive semidefinite_. In simpler terms, that means all its eigenvalues must be nonnegative. Assuming that $\rho$ and $r$ are known positive values, we find that the eigenvalues of this matrix go negative when \begin{equation} c<\rho r-\sqrt{1-\rho ^2+\rho ^2 r^2-r^2}. \end{equation} Therefore the right hand side of this expression is the lower bound for the AC correlation $c$ that you seek, with $\rho$ being the AB correlation and $r$ being the BC correlation.
stackexchange-quant
{ "answer_score": 25, "question_score": 24, "tags": "time series, correlation, numerical methods" }
as .*s does not work like gcc .*c when i run `gcc -c *.c`, it runs:- gcc -c file1.c -o file1.o gcc -c file2.c -o file2.o gcc -c file3.c -o file3.o ... but `as *.s` runs:- as file1.s -o a.out as file2.s -o a.out as file3.s -o a.out ... by default, gcc replaces the only the file extension while compiling into an object file but gnu as sets the default file output as a.out. how to make gnu as to replace .s into .o while assembling?
I don’t think you can get `as` to do that on its own, but you can use `gcc` to drive `as`: gcc -c *.s This will produce `file1.o`, `file2.o` etc. If you need to provide `as`-specific options, you can add them with `-Xassembler`, _e.g._ gcc -c -Xassembler -mindex-reg *.s
stackexchange-unix
{ "answer_score": 2, "question_score": 0, "tags": "compiling, gcc, assembly" }
In zsh, how can I dump all configuration? How can I print my current configuration including defaults and key bindings? This would allow me for example, to find what action is bound to say `^P` in emacs mode and find binding in `vi` mode or set if it is not there instead of browsing manuals.
All key bindings: for m ($keymaps) bindkey -LM $m All ZLE user widgets zle -lL All zstyles: zstyle -L Loaded modules: zmodload -L All variables: typeset -p +H -m '*' With the `zsh/parameters` module loaded, that will also include aliases, options, functions...
stackexchange-unix
{ "answer_score": 11, "question_score": 6, "tags": "zsh" }
why boost variant throw exception when template argument is non-POD? For POD and even std::string boost variant works for me, but when I try my user type A, it fails for this code: #include "stdafx.h" #include <boost/variant/variant.hpp> #include <boost/variant/get.hpp> struct A { char ch; }; int main() { boost::variant< int, A > n, a; n = 33; a = 'a'; try { int nn = boost::get< int >( n ); // ok auto aa = boost::get< A >( a ); // throws bad_get } catch( boost::bad_get& ) { bool okay = false; } return 0; } Why is that?
Your second example actually holds another `int` since `char` can be converted to `int`. To construct an `A` from a `char` you can do `a = A{'a'};` which will call one of the default constructors for your type (aggregate initialization perhaps? I don't know exactly) and then that initializes your `variant` with an `A`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "c++, variant" }
previous activity instead of hiding alertdialog When I press the button new activity starts. In this activity pop-ups alertdialog with options to choose. When I click back arrow alertdialog hides itself and blank screen leaves because of no option were chosen. I'd like to go back to previous activity. Instead of this single action I'd like back arrow to work normally as always. I've tried to override back arrow but alertdialog always has been hidding in place of go back to previous activity. And here is one more problem. Doing back arrow onclick action as start previos activity makes a loop. It switches to previos activity and next after arrow click switch to acitivity where was alertdialog.
If you must alter the expected behavior, try doing something like this: dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } });
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "android, android alertdialog" }
Loading camera roll images in iOS GridView very slow I am showing all the images from the camera roll in my iPhone app. I build an array of `ALAsset *` that contains the list of all images in the camera roll when the app starts. I form cells by loading these images in a image view: // Get the full resolution image for asset ALAssetRepresentation *assetRep = [asset defaultRepresentation]; UIImage *image = [UIImage imageWithCGImage:[assetRep fullResolutionImage]]; [cell.imageCropper setImage:image]; I do this when a new cell is requested in - (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSUInteger) index The problem is that it lags when there are many images and the user scrolls quickly through the images. What is the correct way of handling this?
Consider loading the images in the background using GCD. Maybe this helps: loading images from a background thread using blocks
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "iphone, ios, uitableview, alassetslibrary, aqgridview" }
AngularJS: initialize ZURB Foundation JS I am using both AngularJS and Foundation. To initialize Foundation JS, you have to make the following call: $(document).foundation(); What would be the best way to make this call in an AngularJS application? Code examples would be appreciated. Also, if I were to write a directive around a Foundation JS component, how could I ensure that Foundation is initialized?
You could `$apply` the code in order to bring it into the Angular framework. Here is an example using `$rootScope` with `run` and this could also be done inside a controller/directive with any `$scope`: app.run(function($rootScope){ $rootScope.$apply($(document).foundation()); }); Another option:: $compile($(document).foundation())($scope); Be sure to include the `$compile` service in your controller/directive to use it this way. E.g.: app.directive('mydirective', function($compile) { return { link: function(scope, element, attrs) { $compile($(document).foundation())(scope); } } });
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 30, "tags": "javascript, angularjs, zurb foundation" }
wordpress get_categories example Based on the example on < I try to run get_categories function on wordpress. But the result show nothing. Is it because of the new version wordpress 3.0? <?php $categories= get_categories('child_of=10'); foreach ($categories as $category) { $option = '<option value="/category/archives/'.$category->category_nicename.'">'; $option .= $category->cat_name; $option .= ' ('.$category->category_count.')'; $option .= '</option>'; echo $option; } ?> Need help on this one. Thanks.
> I am using the same data on my local as the one on www.sepakpojok.com. From the parent categories "soccer" I am trying to get its subcategories Are you sure that the category 'soccer' has the same ID on both servers (local and production)? If you've manually added the categories on each, rather than copying the DB from one to the other, the ID's for the same cat could be different. In other words, are you sure the 'soccer' category ID is **10**?
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "wordpress" }
Вывод значения по ключу в ассоциативном массиве Необходимо в ассоциативном массиве вывести значение по ключу: $myArray = Array ( [0] => Array ( [id] => 1603201, [name] => Масла, смазки и технические жидкости, [alias] => masla-smazki-i-tehnicheskie-jidkosti/, ), [1] => Array ( [id] => 24, [name] => Моторное масло, [alias] => motornoe-maslo/, ), [2] => Array ( [id] => 516, [name] => CEPSA, [alias] => motornoe-maslo/cepsa/ ), ); Нужно взять значение [name] у ключа [1]
Совсем обленились чтоль о_О echo $myArray[1]['name'];
stackexchange-ru_stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "php" }
Python New line in return from a function I am new to python and faced the following problem.. I am trying to get from a function a text in two lines using return, but still getting "\n" as a text (in IDLE 3.5). All works fine when I change "return" to "print", but I need "return". def myfunc(a): text1=["|"] i=int(a) mystr="abc|"*i+"\n" text1.append(mystr) text1=''.join(text1) b="0" text2=[b] for b in range(i): b+=1 text2.append("{0:5d}".format(b)) text1="".join((text1,"".join(text2))) return(text1) result: >>> myfunc(4) '|abc|abc|abc|abc|\n0 1 2 3 4' but (...) print(text1) >>> myfunc(4) abc|abc|abc|abc| 0 1 2 3 4
When entering an expression that returns a string in the interactive interpreter, you will be shown the _representation_ of that string. This is different from the _printing_ the string, which will write the characters of the string itself directly to the terminal. The representation generally tries to show the string in a format that Python would accept as a string literal, i.e. it is enclosed in quotes, and special characters are escaped, like you see for `\n`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "python, function, return, line" }
Is freeing allocated memory needed when exiting a program in C If I allocated memory in my C program using `malloc` and now I want to exit, do I have to free the allocated memory, or can I assume that since my entire program terminates, it will be freed by the OS? I run in Linux environment.
Any modern operating system will clean up everything after a process terminates, but it's generally not a good practice to rely on this. It depends on the program you are writing. If it's just a command line tool that runs and terminates quickly, you may not bother cleaning up. But be aware that it is this mindset that causes memory leaks in daemons and long-running programs.
stackexchange-stackoverflow
{ "answer_score": 21, "question_score": 23, "tags": "c, memory management, malloc, free" }
Remove CodeBlocks and know file path I had installed the code block earlier, Now I want to remove it and shift to IDE (recommendation are welcome, specially c/c++) but through the terminal > "Package 'codeblocks' is not installed, so not removed" and in ubuntu software, no software present as named codeblocks but I can see codeblocks in the application manager, I also tried to find the file through the file manager didn't get success. image showing codeblocks in application manager As told @N0rbert in comment `which codeblocks` command output: /usr/local/bin/codeblocks
It seems that you have compiled **CodeBlocks** previously in somewhere (for example in _~/Downloads/codeblocks..._ ) and then installed with `make install` to the `/usr/local`. If you can find this location, then use `sudo make uninstall` from this directory. If you can not find this location - then situation is some-kind of worse. You can try to move executable and its desktop-file with commands below: sudo chmod -x /usr/local/bin/codeblocks sudo mv /usr/local/share/applications/codeblocks*.desktop /usr/local/ and forget about the CodeBlocks :) * * * About **alternatives** \- I'll highly recommend to try KDevelop. You can install it with sudo apt-get install kdevelop
stackexchange-askubuntu
{ "answer_score": 0, "question_score": 1, "tags": "software recommendation, gnome terminal, software sources, code blocks" }
How to add a new column in one table based on values from another table in Mysql? **current** table_users - user_name, city_name table_cities - city_id, city_name I want to add a new column in table_users named city_id where city_id needs to get from table_cities. **expected** table_users - user_name, city_name, city_id (value of this needs to get from table_cities) table_cities - city_id, city_name is there any easy way to achieve this?
If city name is unique then: ALTER TABLE table_users ADD COLUMN city_id INT NULL; UPDATE table_users SET city_id = (SELECT city_id FROM table_cities WHERE table_users.city_name = table_cities.city_name LIMIT 1); ALTER TABLE table_users ADD CONSTRAINT FK_table_cities FOREIGN KEY (city_id) REFERENCES table_cities(city_id); ALTER TABLE table_users MODIFY city_id INT NOT NULL; -- optional
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "mysql" }
Automatic Website Backup that that are Hosted by Third Party Server I have a few websites, hosted on other people's server. To ease my system admin maintenance task I am thinking about using scripts or software tool to do the backup automatically ( I don't want to manually click on a batch script or configure this and that every time whenever I have to do backup). Is there any tools you can recommend?
I wrote a system to do exactly what you're requesting. It'll allow you to backup sites over FTP or SSH/SFTP, and also supports backups of MySQL databases. Backup Machine automatically accesses your site on a daily basis, and incrementally backs up your files, encrypts them, and stores them with Amazon S3. It's specifically designed for website owners who don't have full server access.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 1, "tags": "backup" }
xcode uitableviewcell options don't include identifier I am trying to change the identifier of my uitableviewcell in storyboards. The problem is that options pain doesn't have the option available anymore. See the image below: !enter image description here As you can see the options are limited. How can I see the full range of options?
When I hover over the Table View Cell menu bar, there is an option to 'Show' which then allows me to set the identifier. !enter image description here
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, objective c, xcode, uitableview" }
How to pass an array of id's as parameters for a delete request in javascript I have an array of id's whihc i want to append to a delete request. How should i append the params to the url request? var deleteArray = ['1', '5', '6']; if i want to send a request in this format for delete How do i parse the array contents to build the **ids=1 &ids=5&ids=6** for the request url for delete? My concern is the "&" , how could i append "& and build the string for the url request in javascript
var deleteArray = ['1', '5', '6']; You need key=value pairs so… var pairs = deleteArray.map(function (value) { return "id=" + encodeURIComponent(value) }); Then you need them joined by ampersands so: var query_string = pairs.join("&"); var deleteArray = ['1', '5', '6']; var pairs = deleteArray.map(function (value) { return "id=" + encodeURIComponent(value) }); var query_string = pairs.join("&"); console.log(query_string);
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "javascript, rest, http delete" }
The command line statement php artisan tinker isn't working I am using laravel 5.1 and I am following a tutorial that I've followed before without any issues. But today when I ran php artisan tinker I got the following error PsySH history file found at '/home/vagrant/.config/psysh_history'. Please delete it or move it to '/home/vagrant/.config/psysh/psysh_history'. I have never seen this before and I have been looking for it but dont know where to locate it so can either delete it or remove it. Also another question I have is should I delete it or move it? I don't want to do something that inadvertantly crashes my app. Thanks in advance
So you don't have to answer and accept your own question: It looks like pshsy_history is a history file for the php debugger psysh, and your php command wants it in a different location from where it is. I'm guessing it was created the first time you followed the tutorial. I'm thinking it's safe to delete with `rm /home/vagrant/.config/psysh_history` since your php command seems like it's going to create a new one. If you want to be on the safe side then to move it like the error message says with `mv /home/vagrant/.config/psysh_history /home/vagrant/.config/psysh/psysh_history` If you want to double check the contents of the file before doing either, try `head /home/vagrant/.config/psysh_history`.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "laravel 5.1, laravel artisan" }
Is $P+1$ prime for the perfect number $P$ corresponding to the exponent $74207281$? The even perfect numbers are closely related to the Mersenne primes. We currently know $51$ Mersenne primes and hence $51$ perfect numbers. It has already been checked for which of those perfect numbers $P$ , the number $P+1$ is prime. The formula for $P$ is $$P=2^{n-1}(2^n-1)$$ where $n$ is an exponent for which $2^n-1$ is prime. The exponents $n=2,3,13,19$ are known to give a prime. For all other exponents non-trivial factors are known except of the $49$ th exponent $n=74207281$ > Has this case been checked by someone ? If not , I invite everyone to search a nontrivial prime factor. According to my calculations , there is no prime factor below $2\cdot 10^{10}$ , nevertheless the chance of this number to be prime is extremely small.
As reported by mersenneforum user Neptune just yesterday, this number is divisible by the $17$-digit prime $14344999215792989$, found using the elliptic curve method. (Link posted by Martin Hopf in the comments.)
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "reference request, perfect numbers, primality test" }
Pandas Idxmax on a date-value DataFrame Given this DataFrame: import matplotlib.pyplot as plt import pandas as pd df = pd.DataFrame({'Date':['20/03/17 10:30:34','20/03/17 10:31:24','20/03/17 10:34:34'], 'Value':[4,7,5]}) df['Date'] = pd.to_datetime(df.Date) df Out[53]: Date Value 0 2017-03-20 10:30:34 4 1 2017-03-20 10:31:24 7 2 2017-03-20 10:34:34 5 Im am trying to extract the max value and its index. I can get the max value by `df.Value.max()` but when I use `df.idxmax()` to get the Index fo the value I get a TypeError: > TypeError: float() argument must be a string or a number Is there any other way to get the Index of the Max value of a Dataframe? (Or any way to correct this one?)
Because it should be: df.Value.idxmax() It then returns 1.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "python, pandas, datetime" }
Why did Holden have to kick Naomi? At near the end of Episode Four of _The Expanse_ , the Cant crew are trying to escape the Donnager before it goes kablooey. Naomi and Holden are the last ones left when the Donnager stops moving. There is no longer any gravity, and Naomi and Holden begin floating. Holden, thinking quickly, hooks his suit up to Naomi's and _kicks her_ , as hard as he can. She flies away from him, and he activates his mag boots. Then he yanks her back down. So what was that all about? Why not just push her down? Why not just hook her up to you?
> For every action, there is an equal and opposite reaction. > > --Newton. By kicking Naomi away, Holden propels himself down, so his activated magnetic boots can make contact with the floor. Once he's safe, he can reel her back in. Had Holden been in the right position, he could've done it in reverse, pushing _Naomi_ down, but he didn't know if she would've activated her boots in time. This way, he didn't need to depend on her, he just needed her mass.
stackexchange-scifi
{ "answer_score": 45, "question_score": 25, "tags": "tv, the expanse 2015" }
Fluidmaster 400A fill valve: very slow toilet tank fill I installed a Fluidmaster 400A almost 10 years ago. There is excellent water flow into the overflow pipe, but the tank is taking longer and longer to fill after flushing--now almost 4 minutes. Much water is thus being wasted going down the overflow pipe. Everything else is working perfectly. Do you recommend removing the valve cap assembly to try to flush out debris from the fill valve (I have instructions for that), or should I just buy a new 400A and replace the old unit? (I always have problems with leaks when I do replacements.)
Cleaning out the valve should help. On the other hand, a new 400A fill valve is about $7.50 and it will take you under 5 minutes to replace your existing one (water off, slide the retainer ring up, pull the old valve, throw it away, put the new valve down at the same height, click the retainer ring back down, re-attach tube to overflow, water on). I'm pretty sure any pro would just replace the valve to save time.
stackexchange-diy
{ "answer_score": 3, "question_score": 3, "tags": "toilet, valve" }
Is there a way to access an embedded template variable with PHP? Is there a way to access an embedded template variable with PHP? I thought maybe it'd be in the $_GET or $_POST var, but no such luck.
The array of embed_vars can be accessed this way on EECMS 2.5.5-: $this->EE->TMPL->embed_vars And this way on EECMS 2.6+: ee()->TMPL->embed_vars Use "embed:var_name" as the array key.
stackexchange-expressionengine
{ "answer_score": 3, "question_score": 1, "tags": "ee2, php" }
Probability of getters and setters getting inlined by the compiler My question is pretty straightforward: **Q:** What is the chance that a getter / setter method will get inlined by the compiler in Java? (Obviously there isn't a definite answer to this, but other information would be appreciated) **Extra:** I understand there is always a chance the compiler (Standard and JIT) will decide to make a method inline, and when it comes to getters and setters this is usually what the programmer wants. Thanks in advance.
The compiler (javac) tend to have negligible impact on optimization, as optimization happens at run time. As of the JIT yes,it will probably inline either sooner or later.depending on how heavily the code is used, so a function call overhead may be seen at first, but when the getter/setter has been called sufficiently often then it is inlined.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 9, "tags": "java, performance, compiler construction, jit" }
how to get null values in sqldatareader I get a row from table and some field of this row are `null`. How can I get these fields with `SqlDataReader`? //so_type , so_read are null able while (reader.Read()) { s.id = (Int64)reader["so_id"]; s.senderid = (Int64)reader["so_senderid"]; s.body = (string)reader["so_body"]; s.date = (string)reader["so_date"]; s.isread = (bool)reader["so_read"]; s.type = (int)reader["so_type"]; }
You can use the IsDBNull method. Something like that: int ordinal_so_type=reader.GetOrdinal("so_type"); //... while(reader.Read()==true) { //reading other columns here if (reader.IsDBNull(ordinal_so_type)==false) { s.type=reader.GetInt32(ordinal_so_type); } else { //do whatever you like if the so_type column is null } }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, sql server, ado.net" }
How to evaluate $\int_0^1\frac{1+x^4}{1+x^6}\,dx$ $$\int_0^1\frac{1+x^4}{1+x^6}\,dx$$ Can anyone help me solve the question? I am struggling with this.
$$ \begin{align} \int_{0}^{1} \frac{x^{4}+1}{x^{6}+1} \ dx &= \int_{0}^{1} \frac{x^{4}+1+x^{2}-x^{2}}{x^{6}+1} \ dx \\\ &= \int_{0}^{1} \frac{x^{4}-x^{2}+1}{x^{6}+1} \ dx + \int_{0}^{1}\frac{x^{2}}{x^{6}+1} \ dx \\\ &= \int_{0}^{1} \frac{x^{4}-x^{2}+1}{(x^{2}+1)(x^{4}-x^{2}+1)} \ dx + \int_{0}^{1}\frac{x^{2}}{(x^{3})^{2}+1} \ dx \\\ &= \int_{0}^{1} \frac{1}{x^{2}+1} \ dx + \frac{1}{3} \int_{0}^{1} \frac{1}{u^{2}+1} \ du \\\ &= \frac{4}{3} \int_{0}^{1} \frac{1}{x^{2}+1} \ dx \\\&= \frac{4}{3} \left(\frac{\pi}{4} \right) \\\ &= \frac{\pi}{3} \end{align}$$
stackexchange-math
{ "answer_score": 12, "question_score": 4, "tags": "calculus, integration, definite integrals, rational functions" }
SQL Divide by Two Count() I have the following query, which is trying to figure out the percentage of a certain product compared to the total number of products. IE: [Product Count] / [Total Products] = Percent ;WITH totalCount AS( SELECT CAST(COUNT(id) as Integer)as totalCount FROM TABLE_NAME ) SELECT ((CAST(COUNT(DISTINCT id) as Integer)/(SELECT * FROM totalCount))*100) as 'Percent' FROM TABLE_NAME However, the percent column always returns "0" unless there is only one record. In addition, is there a way to add the totalCount and Select query into one? Basically, how do you divide two Count() fields?
Cast your total count as a number besides integer (DECIMAL?) - the math rounds off.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 10, "tags": "sql, sql server, count" }
Windows Form + database (Sql Server)+ Windows Mobile Application I am student and i am doing project of Order Accepting system for five star hotels.Scenario is Waiter will accept order using Window Mobile which is Connected to WiFi present in hotel.I want to communicate to database(Sql Server) present on My Machine (Computer present in kitchen) through WiFi and Add order into table present inside database. This should notify my application present on Compter and should print order. After completion of Order Application from kitchen will notify to waiter about completion. My problem is How to Communicate with database present on Remote computer using WiFi from windows Mobile. I have other ideas to fulfil my requirment but still is It Possible !!!!!
Looks like you need to read-up on WCF. Obviously the compact edition of the database does not have all the functionality of the full version that will be running on the remote machine. Depending on what information will be stored on the mobile device you may not need a database on the device at all.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, database, vb.net, windows mobile, windows server 2008" }
capture/trace requests to a certain url - iis Is there a way to capture/trace/log all GET's or POST's to a certain url on IIS..? I'd like capture calls to certain url for a few minutes for analysis. Be able to look into the headers, payloads, IP, etc.. I can write C# to do it, but was wondering if there's a diagnostics tool to do it already..? Thanks
IIS captures all requests by default. You can find logs at C:\inetpub\logs\LogFiles\W3SVC1 You can parse the logs to filter out the URLs you are interested in.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "c#, iis, request, trace, capture" }
Dummit and Foote on Tensor Products of Modules In its usual fashion, DF's Algebra treatment of tensor products is insufferably verbose. The problem I am working on asks me to show that $\Bbb{C} \otimes_\Bbb{R} \Bbb{C}$ and $\Bbb{C} \otimes_\Bbb{C} \Bbb{C}$ are $\Bbb{R}$-modules, but I am not even sure where to begin, and poring over the text hasn't helped much. I think that most of my confusion lies in the fact that this "problem" doesn't seem very much like a problem at all. I mean, isn't $\Bbb{C}$ an $\Bbb{R}$-module and doesn't the tensor product construction guarantee that it is a module over whatever the factors are a module over. If so, then there is nothing to show, right? I'm confused.
As @Quasicoherent mentioned in the comments above, it seems likely that the main part of the problem was the latter half. I'd like to stress one point though. While it may be clear that both of these modules admit a left $\mathbb{R}$-module structure, I believe it is important that you pin down where it is coming from. It may surprise you. There are actually several ways these particular objects might acquire their module structures, and it is convenient that all the obvious ones coincide in this case. You may find the following little exercise instructive: Show that $\mathbb{C} \otimes_\mathbb{R} \mathbb{C}$ admits two different left $\mathbb{C}$-module structures. If you go on to study noncommutative algebraic structures, it can become quite a headache if you get fast and loose with where your actions are coming from.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "abstract algebra, ring theory, modules, tensor products" }
If $4x - 3$ is a factor of $4x^3 - 23x^2 + px + 27$, find the value of $p$. Okay so I got $x^2 - 5x (p-15)/4 + 27$ for my final answer but I'm sure this is not right. How do I solve and get the right answer for $p$? I did long division up until I got to the part with $px$, when I got to this part I got $(p-15)x$. I then put $4x$ over $1$ and divided into $(p-15)x$ which in the process canceled out the $x$'s and then I got $(p-15)$.
**Step $1$:** $$4x^3-23x^2+px+27=(4x-3)(?x^2\,+\,?x\,+\,?)$$ **Step $2$:** Since $4x^3=4x\cdot1x^2$ and $27=-3\cdot(-9)$, $$4x^3-23x^2+px+27=(4x-3)(\color{red}1x^2\,+\,?x\,+\,\color{blue}{-9})$$ **Step $3$:** $$4x^3-23x^2+px+27=(4x-3)(x^2+\color{green}ux-9)\\\\\implies -23x^2=4ux^2-3x^2\implies u=-5$$ **Step $4$:** Expand $(4x-3)(x^2-5x-9)$ to find the coefficient of $x$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "algebra precalculus, polynomials" }
Cassandra frozen keyword meaning What's the meaning of the `frozen` keyword in Cassandra? I'm trying to read this documentation page: Using a user-defined type, but their explanation for the `frozen` keyword (which they use in their examples) is not clear enough for me: > To support future capabilities, a column definition of a user-defined or tuple type requires the frozen keyword. Cassandra serializes a frozen value having multiple components into a single value. For examples and usage information, see "Using a user-defined type", "Tuple type", and Collection type. I haven't found any other definition or a clear explanation for that in the net.
**In Cassandra if you define UDT or Collection as frozen, you can't update UDT's or collection's individual item, you have to reinsert with full value.** > A frozen value serializes multiple components into a single value. Non-frozen types allow updates to individual fields. Cassandra treats the value of a frozen type as a blob. The entire value must be overwritten. Source : < @Alon : **"Long story short: frozen = immutable"**
stackexchange-stackoverflow
{ "answer_score": 75, "question_score": 44, "tags": "database, cassandra, nosql, keyword" }
how to remove bracket and name when modelchoicefield is used in Django? Here is my code: staff_id=forms.ModelChoiceField(label="Staff",widget=forms.Select(attrs={"class":"form- control"}),queryset=Staff.objects.all().values('name')) Here is my output: I am getting this name and brackets in this pop down menu, how can i remove these?
Use value_list instead as documented > This is similar to values() except that instead of returning dictionaries, it returns tuples when iterated over * * * > If you only pass in a single field, you can also pass in the flat parameter. If True, this will mean the returned results are single values values_list('name', flat=True)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "django, django models, django forms, django views, django templates" }
Calculating absolute differences between two angles I have two angles a and b, I want to calculate the absolute difference between both angles. Examples >> absDiffDeg(360,5) ans = 5 >> absDiffDeg(-5,5) ans = 10 >> absDiffDeg(5,-5) ans = 10
Normalize the difference, abs operation is not necessary because mod(x,y) takes the sign of y. normDeg = mod(a-b,360); This will be a number between 0-360, but we want the smallest angle which is between 0-180. Easiest way to get this is absDiffDeg = min(360-normDeg, normDeg);
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 6, "tags": "matlab, trigonometry, angle" }
How to change app developer website information in Apple app store How do I change the developer website information for an app? ![](
ok, go to itunesConnect , and change support url field.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "ios" }
How should I cite presentation slides? A friend has made some nice slides that I could reuse (similar topics). He sent me the slides and commented that if I use them and could cite him that would be nice, I asked him how should I cite the slides but he said that whatever suits better to me he said "Just add my surname in some place where it's not very intrusive". I'm not sure if he doesn't care or he doesn't want to be too picky, but I'd like to cite him, to each one his own. AFAIK, they are related to a paper (but not in the paper) and to his thesis, where they could be as a diagram but definitively not animated. The slides (as such) may be available at some URL, he said they will be but they are not available yet (so I don't have the URL yet). If citing by the URL I guess I could use this: "How to cite a website URL?" Should I cite slides? If yes, how?
There are two practical purposes to scholarly citations: 1. acknowledging scientific contribution of others, the borrowing of ideas (mainly) and content (sometimes, in the form of quotes) 2. helping people find relevant content if they want to read it 3. bookkeeping, for scientometric/bibliometric purposes In your particular case, you cannot fulfill #2 and #3, because your friend's slides are not available for others to read, and even if they were, random documents on the internet are not really used for bibliometric purposes. So, you want a solution that will achieve #1, i.e. make sure his contributions are recognized by people who will read your slides. To do so, you don't need to give your citation any specific format. I suggest you simply write, at the bottom of slides you borrowed from him: > _Slide courtesy of John Doe_ or > _Slide modified from John Doe, with permission_ In addition, you can thank him in your acknowledgements at the end of your talk.
stackexchange-academia
{ "answer_score": 17, "question_score": 9, "tags": "citations" }
What does this bash script involving "read" do? I found this in one of the bash scripts for capturing metrics running on CentOS. read -rd '' count <<< "$count" I know **read** reads the content of file descriptor into buffer, but I cannot find the documentation for the command line switches -r, -d. Additionally, What does triple left arrow <<< do?
All of these are Bash features which you will find amply documented in the Bash manual. `<<<` is "here string" format; it's sort of like a here document: cat <<____HERE Hello, World! ____HERE ... except the token after the separator is the actual string to pass in as standard input to the command. The `-r` option to `read` disables some legacy behavior with backslashes from the original Bourne shell. `-d` sets the record delimiter. An empty string says to stop reading when you get a NUL character.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "bash, herestring" }
Directly prove that$\ (S')' \subset S'$ Let$\ S \subset \mathbb R^n$. Directly prove that$\ (S')' \subset S'$ I know that the derived set of$\ S$ is the set of all the limit ponts of$\ S$, that is, $\ S'$ I don't exactly know how to approach this problem, I tried to prove it by contradiction, but don't know if that's the right way. I tried supposing that$\ x$ is not an element of$\ S$, so$\ x$ is no an accumulation point of$\ S$ so$\ \exists p$ such that $\ B_x(P) \cap S = ∅$. The fact that$\ x$ must be a point of$\ S'$ implies that $\ B_x(P) \cap S' \neq ∅$ Don't know where to go from here.
So here's the definition I'd use. Let me know if it's not close enough to yours. > $x \in S'$ if and only if every open ball $B$ containing $x$ contains another point $y$ distinct from $x$. So just use your standard set inclusion argument. Let $x \in (S')'$ then every open ball containing $x$ contains another distinct point of $S'$. Fix an open ball $x \in B$ then there is a $y \in S'\cap B$ with $y\neq x$ Then since $y \in S'$ and $y \in B$ there is another point $z \in S$ with $z\neq y$ Now if $z\neq x$ we are done. To handle the it more eloquently instead of taking $y \in B$ take a new ball $B'$ around $y$ with radius small enough so that $B' \subsetneq B$ and $x \not\in B'$ (this is up to you).
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "real analysis" }
Why does JSON.stringify return empty object notation "{}" for an object that seems to have properties? The following example shows that `JSON.stringify()` returns the string `"{}"` for SpeechSynthesisVoice objects: var voiceObject = window.speechSynthesis.getVoices()[0]; JSON.stringify(voiceObject); //returns "{}"? Complete example: JSFiddle Why does it return `"{}"` and not something like `"{voiceURI: "Google Deutsch", name: "Google Deutsch", lang: "de-DE", localService: false, default: false}"`? Note that the above example does not work for chrome or iOS; it is targeted for Mozilla Firefox.
`JSON.stringify` includes an object's _own, enumerable_ properties (spec) that have values that aren't functions or `undefined` (as JSON doesn't have those), leaving out ones it inherits from its prototype, any that are defined as non-enumerable, and any whose value is a function reference or `undefined`. So clearly, the object you get back from `getVoices()[0]` has no own, enumerable properties that can be represented in JSON. All of their properties must be either inherited, defined as non-enumerable, or (though it's probably not the case here) functions or `undefined`.
stackexchange-stackoverflow
{ "answer_score": 34, "question_score": 33, "tags": "javascript, json, text to speech, stringify" }
Send a Graphics object over the network In the context of a networked, centralized game I am designing, the best would be to perform the graphic context update on the server, and send a clone of the Graphics object to clients so the display process is straightforward; no prior calculations to do. Is there a way I could achieve exactly what I am describing or I have to alter my design and come up with another way of data distribution?
If you're using java on both sides: File tmp = File.createTempFile("test", ".xml"); XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(tmp))); e.writeObject(WIlopuGraphicsObject); e.close(); // there's now an XML representation of your graphic in the file named tmp.getName() To decode it: BufferedInputStream stream = new BufferedInputStream(new FileInputStream(tmp)); // tmp from above XMLDecoder d = new XMLDecoder(stream); WIlopuGraphicsObject graphic = (WIlopuGraphicsObject)d.readObject(); d.close(); Hope that helps.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, oop, network programming" }
why the command Diff2 is not working? The command Diff2 is not giving the supposed output in `TaggedOutputl` if we set the bool `taggedOutput` as true but if we set it to false the result is returned on the text `TextOutput` without problems so how can i resolve this problem the code: P4Command command = new P4Command(ps, "diff2", false, new String[] { "-ds", depotpathleft, depotpathright }); Perforce.P4.Options op= new Options(); op.Add("-u",""); P4CommandResult result= command.Run(op); TaggedObjectList list = (result.TaggedOutput);
This is a known behavior of the 'diff2' command. You might raise this concern with Perforce Technical Support so that they can notify you if this behavior is changed in the future. For the time being, I think your only option is to run the command with untagged output.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, .net, perforce" }
Remove a corrupted file in a Fedora based system How to remove a file that is corrupted? In Linux (Fedora based), when I type: `ll` I get drwxr-xr-x. 2 dmiller3 dmiller3 4096 Jul 26 13:57 SomeFile ?????????? ? ? ? 4096 Jul 26 13:57 CorruptedFile I can't do anything with this CorruptedFile. I can't use it in delete or anything. It's the only file in the entire system that is like this. What causes this, and how can I remove it? File system is ext2.
You are likely going to need to run a file system check (man fsck or man fsck.ext2) on that particular file system. I'd encourage doing some man lookups first as it never hurts to verify the commands for your particular distro/setup. If it's on the root file system, that could pose other problems and questions. As for what causes it... quite a few things, like powering off the machine without proper shutdown, for example.
stackexchange-superuser
{ "answer_score": 3, "question_score": 1, "tags": "fedora" }
Bash script containing binary executable Is it possible to write a bash script, which would contain a binary executable program inside? I mean a script, which would contain a dump of an executable in a textual form, which will be dumped back to an executable by this script when it is executed? I would love to know a solution, which will work out of the box without a need of installing additional packages. Is it possible? Thanks!
i never done something like this before ;) this will compile some c source, create a `b.bash` script containing the binary (and the original script for simple development) (a.bash) #!/bin/bash if [ "$0" == "b.bash" ];then tail -n +$[ `grep -n '^BINARY' $0|cut -d ':' -f 1` + 1 ] $0 | base64 -d > a2.out chmod +x a2.out ./a2.out echo $? exit fi cat "$0" > b.bash echo "BINARY" >> b.bash cat > a.c << EOF int main(){ return 12; } EOF gcc a.c base64 a.out >> b.bash invoke with (a.bash generates b.bash): bash a.bash ;bash b.bash i don't know how to evade writing out the binary into a temporary file before execution...
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 11, "tags": "bash, unix, binary, dump" }
Attributes dont appear in eclipse in programming time When, for instance declaring a new integer variable in java let's say `int number=7;` if I write in Eclipse `a.`, it does not appear on the right all the possible attributes that could be used, as it should do. I have tryed installing a new version of Eclise but it does not make any difference. Does anyone know how to fix this? PS: I tried to look in google for an image of the event i'm talking about and is similar to the one provided bellow but in my case for java programming. !
If i understood you well, here is the solution for autocompletion: Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced You click restore default and that should be it.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "java, eclipse" }
Java List.SubList() Performance comparison I need to implement a sliding window which slides over a sequence. (1:[0,1,2,3]2:[1,2,3,4],...) Which aprove might be faster? 1. for each step i; {List=wholeList.sublist(i,i+windowlen)} or 2. List window=wholeList.sublist(0,window); for each i{ window.remove(0); window.add(i+windowlen); } ? I measured the time with system.currtime bla .. +-std the SubLists seems to work faster.. but why? i think the second aproach is O(n) I need to operate huge databases.. therefor i need to look at this.. mfg Jan
Assuming the remove step is only part of step 2, they aren't equivalent, so comparing them is pointless. The second one modifies both the subsist and the underlying list. I doubt whether (2) will even work. I don't see any reason to go beyond (1).
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, list, sublist" }
Red bg + black field with opacity on 85 = pink text <style> * { background: red; } .blackbalk{ background:black; ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=85)"; filter:alpha(opacity=85); -khtml-opacity:.85; -moz-opacity:.85; opacity:.85; width: 985px; margin: 0 auto; height:255px; color: white; } </style> <div class="blackbalk">Text </div> Now my text gets pink, why? How can i get it white again? Greetings Edit: JS Fiddle to make it clear: <
You can do it by instead using an `rgba` background on your element: **_Live Demo_** \- this will work "in every browser you care about", and my jsFiddle includes the recommended IE conditional comment to make it also work in that browser. .blackbalk { /* Fallback for web browsers that doesn't support RGBa */ background: rgb(0, 0, 0); /* RGBa with 0.6 opacity */ background: rgba(0, 0, 0, 0.85); /* For IE 5.5 - 7*/ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#D8000000, endColorstr=#D8000000); /* For IE 8*/ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#D8000000, endColorstr=#D8000000)"; }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "css, opacity" }
Search if specified key and value exists I am working with hashmap datastructure in java. I have some data in which each entry(value) has a group(key). Now i am storing this data in hashmap as follows HashMap<Integer, String> map = new HashMap<Integer, String>(); map.put(1, "value1"); map.put(1, "value2"); map.put(2, "value3"); map.put(2, "value4"); map.put(3, "value5"); map.put(3, "value6"); map.put(3, "value7"); now I want to search if entry (with key=3 and value="value6") exists in map or not. Is there any specific method to call? or is there and other way to do it?
You can not keep multiple entry against same key in a map. If your map previously contained a mapping for the key, the old value is replaced. You need Map<Integer,List<String>> map = new HashMap<>(); ^^^^^ (Diamond operator) Where you could save List of string against same key. and you can get the value by `map#get` List<String> str = map.get(3);
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 6, "tags": "java, hashmap" }
Proofs for the sequence $a_n$ with $a_n = \cos\left(\frac{n\pi}{4}\right)$ Proves for the sequence $a_n$ with $a_n = \cos\left(\frac{n\pi}{4}\right)$ a)Show that it exist an $m \in \mathbb{N}$ that $a_n=a_{n+m} \forall n \in \mathbb{N}$ and determine $M=\\{a_n ; n \in \mathbb{N}\\}$ b) Find $\forall a \in M$ a subsequence $\\{b_j\\}$ of $\\{a_n\\}$ with $b_j = a \forall j \in \mathbb{N}$.Justify your answer. c)Does a convergent subsequence $\\{b_j\\}$ of $\\{a_n\\}$ with $\\{b_j; j \in \mathbb{N}\\}=M$ exist?Justify your answer. a)If $m=0: a_n =a_{n+m}$ If $n=1,m=6: a_n =a_{n+m}$ Do I only have to calculate $ \cos\left(\frac{\pi}{4}\right)= \frac{\sqrt{2}}{2}$ to define M?
Hint: Try evaluating/calculating $a_n$ for $n=1,2,3,...$ until you spot a pattern. The answers to all of the questions depend on this pattern. I would guess that either the definition of $\mathbb{N}$ being used, or the intention of the question, means that $m=0$ is not considered a valid answer to part (a). The pattern that you should be able to spot will show you the answer. You should find a value of $m$ that works for all $n$: $m=6$ works for $n=1$, but not for $n=2$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "real analysis, sequences and series" }
How to write html code in ASP.NET MVC controller I have string message that I want to put HTML code into that in controller. how can I do this? string message = @"<div style="direction: ltr; width: 700px; margin: 0px auto; font-family:Verdana; font-size:11px; line-height:25px;"> <div style="line-height: 21px; color: rgb(68, 68, 68); font-family: Calibri, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"> <div style="line-height: 21px; min-height: 14px;"> <br class="Apple-interchange-newline" /> <br style="line-height: 21px;" /> </div> </div>"; but it shows error. how can I do this?
Try to replace double quotes with single quotes, which are in HTML markup.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "html, asp.net mvc, razor" }
Docker Filter with policy restart Is there any way to filter all containers with policy --restart=always ? Server Version: 17.09.1-ce Operating System: Ubuntu 16.04.3 LTS
Its a start: docker inspect --format "{{.HostConfig.RestartPolicy.Name}},{{.Name}},{{.Config.Image}},{{.State.Status}}" $(docker ps -aq) | column -s, -t | awk '{ if ($1 != "no") print }'
stackexchange-superuser
{ "answer_score": 3, "question_score": 2, "tags": "docker" }
Trying to create a line chart with a linear x-axis, like the time axis, but with numerical data, in DimpleJS I have a line chart that I just noticed the x-axis is not linear. I'm using AddAxis, and it's acting like a category axis. This makes the scale on the x-axis non linear and spaces the points an equal distance apart. I want the x scale to go from minimum x-value to maximum x-value and to be spaced equally based on the linear scale of min to max. The time axis seems to do this, but I just have numerical data, not in a time format. Is there another axis type I should be using? Or, is it possible to use the time axis and format the data to basic number and decimal values? Thanks!
Yes you can use a measure axis like that. Here's an example: var data = [ { "X Value" : 1000, "Y Value" : 100 }, { "X Value" : 1500, "Y Value" : 200 }, { "X Value" : 3000, "Y Value" : 400 }, { "X Value" : 7000, "Y Value" : 100 }, { "X Value" : 8000, "Y Value" : 200 }, { "X Value" : 8500, "Y Value" : 100 }, ]; var svg = dimple.newSvg("#chartContainer", 600, 400); var chart = new dimple.chart(svg, data); chart.addMeasureAxis("x", "X Value"); chart.addMeasureAxis("y", "Y Value"); chart.addSeries("X Value", dimple.plot.line); chart.draw(); <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "d3.js, charts, linegraph, dimple.js" }
SoundCloud Autoplay in iFrame has Stopped Working this page < should autoplay as I understand it. the code looks like this: <iframe width="100%" height="166" scrolling="no" frameborder="no" src=" the audio does play if button clicked and I can change the button color and show or hide the artwork, as you'd expect. but no autoplay? I've simplified for debug purposes but I have another page which I'd swear was autoplaying last week just fine. I have tried different browsers, computers, connections: what gives? ~Marqso
your link auto plays fine for me on Chrome. It won't work on iOS devices though – there's a limitation on Apple's side that prevents media from auto playing in order to save on user's traffic.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "javascript, iframe, soundcloud, autoplay" }
Pandas seems to be merging same dataframe twice I have two dataframes in pandas, one of which, 'datapanel', has country data for multiple years, and the other, 'data', has country data for only one year, but also includes a "Regional indicator" column for each country. I simply want to create a new column in the datapanel frame that gives the 'Regional indicator' for each country. For some reason, the rows of the dataframe are just about doubling after this merge, whereas they should remain the same. What am I doing wrong? ![enter image description here](
The key (country name) you are merging on is duplicated in 'datapanel' (see 'Afghanistan' mentioned at least 5 times) and perhaps also in 'data', which causes troubles. Try using a different technique (v-lookup), something like this ("Country name" must be unique in 'data'): for country in data["Country name"].values: indicator = data.loc[data["Country name"] == country, "Regional indicator"].item() datapanel.loc[datapanel["Country name"] == country, "Regional indicator"] = indicator
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "pandas, join, merge" }
How I change the color with expression rdlc I need to change the color of my report.rdlc to `Red` when the `fields!Date.Value = "Sunday"` and the `fields!start.Value > 22` and `fields!finish.value < 5`. I tried to use =IIf(Hour(fields!start.Value) > 22,"Red","Black") but I don't know how I do the others cases. I am starting to report expressions now.
It should be very similar to any other logical expression. Just group all your conditions in parenthesis and if they are all true the action will happen so for your case try this... =IIf(()Hour(fields!start.Value) > 22) AND (Hour(fields!start.Value) < 5) AND (fields!Date.Value = "Sunday")),"Red","Black")
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "c#, expression, rdlc" }
About ios tap gesture I add a tap gesture on label. And add an action to change it text. but when I tap that label, it doesn't have any changes. enter image description here
By default label UserInteraction become disable. Enable label user interaction like this: label.isUserInteractionEnabled = true
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "ios" }
Unable to open an existing notebook in IPython Notebook I want to open a notebook, say 'IPython - beyond normal Python'. To achieve this, I perform the following steps, in order. 1. Move to the place where IPython Notebook is installed. 2. cd to 'Notebooks'. iPython dashboard opens in a browser with list of available notebooks. 3. Click on the desired notebook. The third step opens a new tab, but I can't see the contents of the notebook. A screen shot of what appears under that tab is shown below.!Contents of the new tab that opens upon completion of step 3. How can I see the contents of the notebook?
I would say that the notebook format is v3 and you are running IPython v0.12 that only read notebook v3. There is a warning message in newer versions if the notebook version is more recent than IPython. Also IPython, not iPython if possible.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "firefox, ipython, jupyter notebook" }