INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Quoted identifier error Codefluent We have a QUOTEDIDENTIFIER problem with the Azure producer. We have an entity where we defined a Geography property. We created a geospatial index on that table. However, if we perform an insert or update on that table we get the followind error: > INSERT failed because the following SET options have incorrect settings: ‘QUOTED_IDENTIFIER’. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. We solved the error by dropping and restoring all stored procedures of this table but set QUOTED IDENTIFIER ON now. The problem is, every time we run the producer the stored procedures are dropped and created with QUOTED IDENTIFIER OFF. How can we solve this situation?
You can configure the SQL Server producer to generate `set quoted_identifier ON` at the top of the files: <cf:producer name="SQL Server" typeName="CodeFluent.Producers.SqlServer.SqlServerProducer, CodeFluent.Producers.SqlServer"> <cf:configuration quotedIdentifier="ON" ... /> </cf:producer>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "codefluent, quoted identifier" }
Como pegar a descrição de um Enum no xhtml? Preciso de uma ajuda para resolver uma situação com uma classe Enum juntamente com o framework demoiselle. Ex.: eu tenho essa classe: !Classe EnumTipoLei porem gostaria de que apareça em meu combobox o descritivo Ex.: Lei Ordinária, e não LEI_ORDINARIA. Veja a imagem abaixo: !tela do cadastro ok você deve ter pensado, ah faltou o adicionar a "descricao", mas foi feito isso também, ele não esta aceitando chamar o atributo descricao do método getDescricao conforme imagem 1, veja a imagem abaixo: !input jsf Erro: !Erro
Tenta assim que vai dar certo: <p:selectOneMenu id="enumTipoLei" value="#{leiEditMB.bean.enumTipoLei}"> <f:selectItems value="#{leiEditMB.enumTipoLei}" var="tipoLei" itemLabel="#{tipoLei.descricao}" itemValue="#{tipoLei}"/> </p:selectOneMenu> No ManagedBean: private List<EnumTipoLei> enumTipoLei; public LeiEditMB(){ enumTipoLei = Arrays.asList(EnumTipoLei.values()); } public List<EnumTipoLei> getEnumTipoLei() { return enumTipoLei; } Resumindo: criando um List do tipo do Enum apenas com o método get e no construtor do ManagedBean, colocando os valores String dentro dessa lista usando Arrays, funciona que é uma beleza!! Boa sorte!
stackexchange-pt_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, jsf, primefaces, demoiselle" }
How can I create a firewall containing a ban system with Apache? I have a home server exposed to the internet, and host some services such as Nextcloud and Gitea for friends. However, there are people I'd like to keep out of my network via an IP ban. How can I have a virtual host sit between the services and the internet, check incoming connections against a ban list, and accordingly redirect to the site the user or app tried to access if the check fails? In case the check passes, showing the user a "banned" page, even if I need to write a Node.js app for it would be preferable, but not needed, simply timing them out is fine.
As Gantendo mentioned in his comment, fail2ban is exactly what I was looking for. Thanks! I used the answer at < to create a permanent jail in the file `/etc/fail2ban/jail.d/recidive.conf`: [recidive] enabled = true logpath = /var/log/fail2ban.log banaction = %(banaction_allports)s bantime = -1 ; permanent findtime = 86400 ; 1 day maxretry = 6 and manually added IPs to it using the command `sudo fail2ban-client set recidive banip <IP_ADDRESS>`.
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "networking, apache http server" }
Android string resource - need to include '%' character So how do I include in a string resource the '%' character? **VALID** <string name="my_string">Total discount boundary:\nmin=%1$s nmax=%2$s</string> **INVALID** <string name="my_string">Total discount boundary:\nmin=%1$s % nmax=%2$s %</string>
You should be able to use `%%` to get a percentage sign without being parsed as a string format character.
stackexchange-stackoverflow
{ "answer_score": 15, "question_score": 11, "tags": "android, string" }
What's the best way to conditionally import a component from another component? So, the problem is, I have a component A, that should render a component B according to some condition. I could import B at the top and everything will be fine, but If the condition isn't met, I don't want to end up with all B's component code not needing it. The way im doing is: let B; if (condition) { B = require('./B.js' } Does this make sense? Thanks. The problem is that I'm getting the "Element type is invalid: expected a string" error. Edit1: I'm using create-react-app Edit2: **Solution:** let comp; if(condition) { comp = require('./SomeComponent').default; }
If you are using Webpack, you can perform a dynamic import along with having that import bundled separately from the component code. const B = condition && import(/* webpackMode: "lazy-once" */ './b.js') Otherwise you can simply use dynamic imports: const B = condition && import('./b.js')
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "javascript, reactjs, webpack" }
How to find out which key is pressed in keyDown event in visual basic? I'm writing my first visual basic program, And I want to do something when for example the 'k' button is pressed, I know that I should write the code in "KeyDown" event, but I don't know how to find out that 'k' button is pressed or not
If you are using a Windows Forms Application, you have to put the `KeyPreview` property of the form to `True` so the form will monitorize key events. Then: Private Sub Form1_KeyPress(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress If e.KeyChar = "k" OrElse e.KeyChar = "K" Then MessageBox.Show("Pressed!") End If End Sub If you prefer, you could use other event: Private Sub Form1_KeyDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If e.KeyCode = Keys.K Then MessageBox.Show("Pressed!") End If End Sub
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "vb.net, visual studio 2010" }
"Message/letter was read?" - Sentence help! I am writing an essay and it needs to be in formal language, I am referring to a letter/message and I am supposed to quote it for the readers, but before jumping right into quoting that letter, I like to make an introducing comment like, "The letter was read as follows," I know I'm confusing "is as follows" into it, but I like to have it in the same shade, just grammatical and perhaps formal. Like, "The message was read as.." Can someone with a better understanding of the English language and its idioms help me, please?
Here are two common ways to write it. > The message read: "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch . . . ." Or > The message read as follows: "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch . . . ."
stackexchange-ell
{ "answer_score": 6, "question_score": 4, "tags": "sentence construction, verbs, punctuation, direct speech" }
Is it possible to replace a public static method in Java? I'm using a library that has a public static method `getFile()` defined in the `Utils` class. The library uses `Utils.getFile()` a lot internally, but this method is not very well implemented. I was wondering if it's possible to somehow override `Utils.getFile()` so it would use my implementation instead?
No - not with pretty much copying the class and replacing it there. Otherwise, a better alternative may be +1 for Christian's comment: Why doesn't Java allow overriding of static methods? If it was non-static and the method wasn't private or final, you could subclass the class, provide your own overridden method, and use that.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "java, static methods" }
Plotting curves containing constants using ezplot I want to plot a function using ezplot, different values of two constants. like ezplot('a*x^2+b*y^2=1') How can I plot it for different values of a and b? Thanks everyone.
The easy way is: first define your function with a handler, something like this: a = 1; b = 3; fh = @(x,y) (a*x.^2 + b*y.^2 - 1); Then easily use ezplot with the function: ezplot(fh) axis equal If you have different values of a, and b, you can use them in a loop (or using vectorized calculation), and feed them to your function, then plot the function, and after a plot use 'hold on' command to keep the previous plot something like this: for i=1:n fh = @(x,y) (a(i)*x.^2 + b(i)*y.^2 - 1); ezplot(fh); hold on end That's it.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "matlab, plot" }
$f$ is continuous & real valued on $E$ then {$p \in E : f(p) \leq 0$},{$p \in E : f(p) = 0$},{$p \in E : f(p) \geq 0$} closed Let $E, E'$ be metric spaces, $f: E \rightarrow E'$ a continuous function. Show that if $S$ is a closed subset of $E'$ then $f^{-1}(S)$ is a closed function. Derive from this result that if $f$ is continuous and real-valued on $E$ then the sets {$p \in E : f(p) \leq 0$}, {$p \in E : f(p) = 0$}, {$p \in E : f(p) \geq 0$} are closed. I have proven the first result. I know that all $f(p)$ fall into at least one of the above sets, and points $p$ where $f(p) = 0$ are in all three sets. What should I construct as my closed set in $E$ or $E'$ so that the above sets are closed?
Note that $$\\{p:f(p) \leq 0\\}=f^{-1}((-\infty,0])$$ $$\\{p:f(p) = 0\\}=f^{-1}(\\{0\\})$$ $$\\{p:f(p) \geq 0\\}=f^{-1}([0,+\infty))$$ Since $f$ is continuous and $[0,+\infty),(-\infty,0],\\{0\\}$ are closed subests of $\Bbb{R}$ we have that their inverse images are closed subsets of $E$.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "real analysis, continuity" }
dynamic object definition This is a serious question, It has been nagging me for a while. In JavaScript you can declare a variable which has no type. It's type is often dynamic, depends on further value assigned to it. e.g var text; typeof(text); //undefined text = 'someText'; typeof(text); //string So as we know that Javascript can dynamically change variable's type why these assignments are invalid then? e.g var someObj; someObj.a = 'hello world'; console.log(someObj) //TypeError var someTable; someTable[0] = 'hello world'; console.log(someTable[0]) //TypeError where this problem can be fixed just by adding definition to variable declaration: var someObj = {}; var someTable = []; I'd expect a good explanation of this problem. Thanks for answers.
1) Data types in Javascript are not dynamic, they are mutable. This means that depending on kind of operation you are applying to them they can change from being something into another thing (e.g. a number can become a string doing something like this: 4 + 'a'). 2) The "error" is a consequence of having a variable not initialized. In Javascript when you are doing this:`var something = 'a'` you are doing two operations, a declaration, and an assignment. If you don't do the assignment and you try to access to a property of the object you have declared it will throw an error. In your case, you are declaring a variable but not initializing it to the "compiler" can't access the "a" property or the position 1 because it is of type `undefined`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, variables, undefined, declaration" }
My computer does not want to start-up I copied photos onto my notebook hard drive and got a warning of limited hard drive space...I continued to copy photos onto my hard dirve. I got a message that the space limit was reached an no more photos could be copied onto the hard drive. I restarted my notebook and the initial Ubuntu page could not load due to lack of memory. I tried to start-up in safe mode, buit to no avail. I guess that will mean that I uninstall Ubuntu completely and reinstall it again. I have all important stuff backed up in case I need to unistall Ubuntu. My screen is black at the moment with my computer name prompting for the password. When I type in the password I get a message" the configuration defaults for GNOME Power Manager have not been installed correctly. See administrator." What can I do and how do I do it?
* Try a terminal Ctrl+alt+F1 * Boot with live CD And delete files
stackexchange-askubuntu
{ "answer_score": 3, "question_score": 0, "tags": "startup, login screen" }
How do I fix a “System command error” when running “devtools::build_vignettes()” in R? I am developing a package. The “.Rmd” files already exist in the “./vignettes” folder in the root directory of the package. I want to automatically create “.html” and “.pdf” documents into./inst/doc, so run the following code library("devtools") build_vignettes Then Errors occurred > Building PhosMap vignettes Error in (function (command = NULL, args = character(), error_on_status = TRUE, : System command error > Error in (function (command = NULL, args = character(), error_on_status = TRUE, : System command error My R version is 3.6.0.
I get similar issue when run `devtools::build_vignettes()`. In my case reason of this issue was that I made a mistake in `namespace` in the names of exported functions. So try to verify the package by `devtools::check()` But also you can try next: 1. Check you PATH, there must be a path to rtools: `C:\Rtools\bin\;` and `C:\Rtools\mingw_64\bin\`. 2. Set system environment variables BINPREF `"C:/Rtools/mingw_64/bin/"`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "r, devtools" }
Does the Abysmal Armour break in werewolv.es? In werewolv.es, the joke-version of the protective Abyssal Armour is the Abys **mal** Armour - truly terrible because it offers no protection, but blocks the holder at night instead! However, if someone is killed at night whilst holding the Armour, does it 'break' like normal armour items and disappear from the game, or is ownership transferred to the killer?
It follows the same rules as other forms of armour do (aside from offering zero protection) and it breaks if the person holding it is attacked.
stackexchange-gaming
{ "answer_score": 2, "question_score": 0, "tags": "werewolv.es" }
Can BCNF decomposition preserve all functional dependencies given F = {AB -> E, BC -> G, C-> BG, CD->A, EC->D, G->CH}? > Given `F = {AB -> E, BC -> G, C-> BG, CD->A, EC->D, G->CH}`, perform a BCNF decomposition and check whether it preserves all functional dependencies. The minimal cover is `R = {AB->E,C->B,C->G,CD->A,EC->D,G->C,G->H}` I performed on `R` a BCNF decomposition(it is a must to perform on the minimal cover) and I stayed with two dependencies of which one is preserved and one isn't preserved. In the answers they tell me that all of the dependencies are preserved. Can please anyone confirm this?
**AB** E, **C** BG, **CD** A, **CE** D, **G** CH are in BCNF and loosless join and dependency preserving. relation keys are in **bold** There is always a possibility to add a new relation for preserving a dependency as long as this new relation is in BCNF.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "database, relational database, database normalization, functional dependencies, bcnf" }
How to put IFNULL I have column in table1 where name column has lot of rows as null table1.name=table2.userID So I m trying to put IFNULL condition as this select (IFNULL(name,'empty')) But My output table after exceution comes blank.
It should work SELECT IFNULL(`name`, 'empty') FROM `tablename`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "mysql" }
Why do all linear transformations have no restrictions on their natural domains? Some normal functions have restrictions on their natural domains, but linear functions don't. Why? Related: Is there a linear transformation who domain isn't all of $\mathbb{R}^n$? **Why my question is _not_ a duplicate of the above question**: The above question asks if there asks if there is _any_ function whose domain isn't $\mathbb{R}^n$. This function clearly exists by limiting the domain of any linear transformation. My question is asking about the _natural domain_ of a linear transformation, which none of the answers from the question above address. **Natural Domain:** The largest domain where the transformation makes sense. In other words, the domain of a linear transformation, without any artificial "restrictions" put on it.
Here's an attempt to understand the question. Imagine that the natural domain of the linear transformation $T$ is some proper subset $A$ of ${\bf R}^n$. By linearity, $T$ extends to the span of $A$, and is linear on that span, so we may assume $A$ is a subspace of ${\bf R}^n$. Now you can define $T$ to be zero on the complement of $A$, and you will have a linear transformation that extends your original to all of ${\bf R}^n$. And that's why there is no restriction on the natural domain of a linear transformation. EDIT: As Anthony points out in the comments, I got the extension of $T$ wrong. Extend the basis $\\{\,v_1,v_2,\dots,v_r\,\\}$ of $A$ to a basis $\\{\,v_1,v_2,\dots,v_r,v_{r+1},\dots,v_n\,\\}$ of ${\bf R}^n$, define $T(v_j)=0$ for $r+1\le j\le n$, and then extend $T$ to all of ${\bf R}^n$ by linearity.
stackexchange-math
{ "answer_score": 3, "question_score": 4, "tags": "linear algebra, matrices, vector spaces" }
How can i find the Data Usage on Per Application Basis? hi i am workig on Traffic Application in Android which show the data recived and Sent By the Android Device. how can i fetch the recived and Sent Data for a patucular time like how can i fetch last 24 hrs recived and sent data .
You can use `TrafficStats` to determine bandwidth usage per-UID, which roughly corresponds to per-app.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android" }
Remove a version of cabal I accidentally installed cabal twice. I did this by: cabal install cabal-install sudo cabal install cabal-install Now I have two versions of cabal and two versions of each package and it's causing headaches. I want to completely remove cabal from my system (and all packages therein) in order to restart so I don't have two versions. Is this possible and if so, how can I do it? (Alternatively, I wouldn't mind removing the root version and keeping only the local user version so that I can get xmobar to work without needing to sudo.) I guess I should note that I have ubuntu 17.10.
You won't have two versions of each package with this. Different `cabal-install` binaries share the same user packagedb just fine. _However_ , different users will have different packagedbs. For each user, the user packagedb will be by default in `~/.cabal/lib/` and `~/.cabal/store/` (the latter for `new-build` only). The bin dir that cabal puts binaries in, including those from `cabal install cabal-install` is in `~/.cabal/bin`. So you can remove the program from either of those bindirs. But you really don't need to remove it from anywhere. Rather, you should just make sure you only ever run it as either root or as local user. But if you really want, you can clear the entire `~/.cabal/` directory from the root user only.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "uninstallation, cabal" }
Overhead in using "Verify-full" while connecting postgresql through SSL Am trying to establish a secure connection using SSL for postgres RDS instance. I wanted to use SSL MODE "verify-full",since it provides the highest protection while transferring sensitive data. As mentioned in the doc postgresql documentation, I see that using "verify-full" provides some overhead in performance. I tried searching multiple sites but was unable to find the overhead stats. Has anyone tried it can kindly help. 1. How fast is encryption and decryption of records? 2. Is it advisable to use when dealing with 10K+ records and what will be the performance rate drop?
It is not `sslmode=verify-full` that incurs a performance penalty, it is using encrypted connections as such. It is impossible to give you a simple percentage by which you can performance to drop. The additional load is on the CPU, so if your workload is I/O bound or network bound, you may experience no performance drop at all. You should set up a little test case and perform some benchmarks, that is the only way to get reliable data.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, postgresql, ssl, ssl certificate" }
Sockets in OSX Lion with xcode4? I want to create an TCP connection (client) with sockets in OSX. I'm using xcode 4. Which class should I use?
I would take a look at CocoaAsyncSocket, which is open source and available at: < They have very good examples as to how to use the framework, and it's much better than dealing with the C calls directly... CocoaAsyncSocket supports TCP and UDP. The AsyncSocket class is for TCP, and the AsyncUdpSocket class is for UDP.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "macos, sockets, xcode4, osx lion" }
Remove surrounding lines in vim I often surround some code/text with some other lines of text. For the sake of a concrete example, say I have some text: this is some text I then have macro that lets me convert that (after highlighting the lines) to if false then this is some text end; the macros I use to do this are: nmap <space>i ccif false then<CR><c-r>"end;<esc> vmap <space>i cif false then<CR><c-r>"end;<esc> However I would like to be able to create macro to then remove the surrounding text. That is, if the cursor is surrounded by lines "if false then" and "end;" then those lines should be removed. Any ideas how I would create a macro like that? Let me note that I have looked at surround.vim, but have not found a way to do it using that package.
Try following dirty function and check if can help to solve your issue. From cursor position it looks forward and backwards for those strings. Delete them only when both match: function! RemoveSurrondingIfCondition() let s:current_line = line('.') "" Look backwards for the key string. let s:beginif = search( '\v^if\s+false\s+then\s*$', 'bWn' ) if s:beginif == 0 || s:current_line <= s:beginif return endif "" Set a mark where the _if_ begins execute s:beginif 'mark b' "" Look forward for the end of the _if_ let s:endif = search( '\v^end;\s*$', 'Wn' ) if s:endif == 0 || s:endif <= s:beginif || s:current_line >= s:endif return endif "" Delete both end points if searches succeed. execute s:endif . 'delete' 'b delete endfunction noremap <space>d :call RemoveSurrondingIfCondition()<CR>
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "vim, surround" }
How do I cycle through REQUEST and use dynamic variable naming? PHP ! :) I have a form that submits details of multiple people i.e in the $_REQUEST I get : title1 = Mr, first_name1 = 'Whatever', surname1 = 'Whatever', title2 = Mr, first_name2 = 'Whatever', surname2 = 'Whatever' There's obviously more but this explains the situation. There could be ten people being submitted and therefore it would go up to title10, first_name10, surname10... I have been trying to use: for ($x = 1; $x < 4; $x++) { $a = new applicant(); $a->title = $_REQUEST['title'+$x]; $a->first_name = $_REQUEST['first_name'+$x]; $a->surname = $_REQUEST['surname'+$x]; $a->Save(); } However it appears that you cannot do this +$x bit. I know there is a way around it since I remember doing this ages ago yet I don't have my code at work :/ Any ideas guys?
PHP uses `.` for concatenating strings, and `+` for adding numbers; this is different from some other languages which use `+` for both. Possibly confusing, but unlikely to change. `'title' + $x` will try to add the parts as if they were numbers, casting if necessary. `'title' . $x` should do what you seem to be looking for. Read also: The Fine Manual
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "php, forms, request" }
Prevent android from splitting line at a specific point? I have the text `Improve and Personalize App Name`. The way I have it in my layout, it runs out of space and wraps to the next line such that the text is like `Improve and Personalize App\nName`. But it looks weird to have the app name be split across lines. How do I specify to Android not to split the app name?
Not sure if this is the best way, but it works. You can use a character that looks like a space but isn't a space. Android will consider your app name to be one word, even if it isn't. I used `&#160;` so my string became `Improve and Personalize App&#160;Name`
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "android, android layout" }
How can I make these two circles the same size? please help me ![enter image description here]( here's the code: \node[circle, draw=black, solid] (Q9) at (10.5,-1.5){Q9}; \node[circle, draw=black, solid] (Q10) at (9.0, -1.5){Q10};
It is recommended that you post a minimal working example (MWE) that starts with `\documentclass` and ends with `\end{document}`. Anyway, I came up with \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[circle, draw=black, solid] (Q9) at (10.5,-1.5){\phantom{Q10}}; \node at (Q9) {Q9}; \node[circle, draw=black, solid] (Q10) at (9.0, -1.5){Q10}; \end{tikzpicture} \end{document} which produces the next output: ![output]( Notice how I put `{\phantom{Q10}}` in the first `\node` to get the spacing of Q10, and in the line below, I place the text Q9 at the coordinate (Q9).
stackexchange-tex
{ "answer_score": 1, "question_score": 0, "tags": "circles" }
pip install django mysqlclient 'path should be string, bytes, os.PathLike or integer, not NoneType' on windows I am new to Python and Django and want to install mysqlclient on windows. When I use the command `pip install django mysqlclient` in cmd it throws this error : > File "d:\myprojects\python\mytestdjangoprj\myproject\lib\genericpath.py", line 30, in isfile st = os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType Please help me.
As Alasdair said , using 64 bit solve problem.thanks Alasdair.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "python, mysql, django, windows" }
Name of integers whose prime factorization is exponent free [squarefree] Let $n > 1$ be a positive integer. Suppose that $n$ is a product of distinct primes $$n= \prod_{i=1}^kp_i^{\alpha_i}$$ i.e. $\alpha_i=1$ for every $i$. Said equivalently: $\,n\,$ has no repeated (square) factor. Surely if $n=pq$ we call them semiprimes but beyond that do we have a general term? Would you just say that $n$ is a "product of distinct primes" The motivation here is simple. I noticed that the numbers of the form $${2^n \choose 2}^n+1$$ appear to be exponent free in thier prime factorization up to $n=12$ using GAP. * * * Update 2021: The first value $n$ for which ${2^n \choose 2}^n+1$ is not squarefree is 15. \begin{align} {2^{15} \choose 2}^{15}+1=3^3×11×19×251×331×4051×18837001×4714696801×1133836730401×281941472953710177758647201 \end{align}
Such numbers are called _square-free integers_ , see for instance here. A way to express the fact that $n$ is square-free is to write $\mu(n) \neq 0$, where $\mu$ is the Möbius function. I have no idea about your particular problem. I know that it was only proved recently (1996) that ${2n \choose n} $ is never square-free for $n \geq 5$… ! Notice that your numbers are just $x(n) = 1+(2^{n-1} (2^n-1))^n$.
stackexchange-math
{ "answer_score": 5, "question_score": 2, "tags": "terminology, definition, prime factorization" }
How to lock int that accessing via different threads I have this variable: private static volatile int _filesInUse; This variable is accessed via different threads and I want to lock this when it's value is changing in order to update my UI about the current state.
For changing the integer, you have `Interlocked.Increment`.aspx). You just have to pass it in with the `ref` keyword: int result = Interlocked.Increment(ref _filesInUse); Use `result` along the way (it doesn't get updated when `_filesInUse` does, so it is save in your procedure to use it).
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "c#, multithreading, int" }
label in MDI parent form do not remain in background of child form? Please guide and help me. I have a MDI parent form which has a label at its center (to display application name in center). On opening a form in this MDI parent, this label should appear on back side of newly opened form, but on showing a child form, label appears in front of newly opened form (appears like newly opened form is between label and MDI parent). How to manage it please guide me. thanks
public partial class MyMdiForm : Form { public MyMdiForm() { InitializeComponent(); foreach (Control control in Controls) { if (control is MdiClient) control.Paint += mdiBackgroundPaint; } } private void mdiBackgroundPaint(object sender, PaintEventArgs e) { var mdi = sender as MdiClient; if (mdi == null) return; e.Graphics.Clip = new System.Drawing.Region(mdi.ClientRectangle); e.Graphics.DrawString("*** YOUR NAME HERE ***",this.Font,Brushes.Red,100F,100F); } }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c#, .net, winforms" }
Two models with an association of have_one to have_many possible in Rails? I am making a rails site where you can schedule an appointment for a service. Currently I have an Appointment and Client model. Now I have decided that in order to get the Client's information (name, email, etc) from an Appointment object, I would make an association between the two models. Now the way I see it, an Appointment should `have_one` client and a Client should `have_many` appointments. However, I have never seen an association between two model where they both have `have_x` associations. So what I am wondering is this is possible, will it work? Also is there a better way to do this, maybe something I'm missing? Any insight would be much appreciated!
I don't believe that will work. You may want to use the `belongs_to` method to associate your `Appointment` to your `Client`: class Appointment < ActiveRecord::Base belongs_to :client end class Client < ActiveRecord::Base has_many :appointments end
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "ruby on rails, database design, ruby on rails 3.1, associations" }
JS loop increment each value by 2 Is there a way to increment each result of a loop by 2 each time? So it should increase the values by 2, then 4, then 6... So if the first result is 2, it should be `2*2=4` But the second result should be increased by 4: `2*4=8` This is the loop: function setDatePosition(timelineComponents, min) { for (i = 0; i < timelineComponents['timelineDates'].length; i++) { var distance = daydiff(timelineComponents['timelineDates'][0], timelineComponents['timelineDates'][i]), distanceNorm = Math.round(distance/timelineComponents['eventsMinLapse']) + 2; timelineComponents['timelineEvents'].eq(i).css('left', (distanceNorm*min)+'px'); } } At the moment, the first result is left:120px and the second result is left:180px. I want to achieve: First result + 20px: 140px Second result + 40px: 220px Third result + 60px... And so on
I believe your 20px coming from min? If that is the case, you just need to increase min after each iteration. `min += 20;` function setDatePosition(timelineComponents, min) { for (i = 0; i < timelineComponents['timelineDates'].length; i++) { var distance = daydiff(timelineComponents['timelineDates'][0], timelineComponents['timelineDates'][i]), distanceNorm = Math.round(distance/timelineComponents['eventsMinLapse']) + 2; timelineComponents['timelineEvents'].eq(i).css('left', (distanceNorm*min)+'px'); min += 20; } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, loops, operators" }
how to get value of speific column in PHP I used to here values from column with this code. $con=new PDO("mysql:dbname=weLit","root",""); $sql="SELECT * FROM UserTable WHERE uEmail='[email protected]' AND uPass='aabb'"; $arr=$con->query($sql); $con=null; foreach ($arr as $row){ $name=$row["uName"]; echo $name; } and i can get value from from specific column. Now I use this code to prevent SQL Injection. $con=new PDO("mysql:dbname=server","root",""); $stmt = $con->prepare("select uName from UserTable where uEmail=:email AND uPass=:pass") ; $stmt->bindParam(':email', $email); $stmt->bindParam(':pass', $pass); $stmt->execute(); how to get value from specific column as above ? please help ! I'm new to PHP. And how to minimize the code as there will be always one row in result so i don't want to use foreach.
Use `->fetch()` / `->fetchAll()` on the statement you just executed to get the data as an array or object. It's pretty well documented: * < * < In your case it would look like: $stmt->execute(); foreach ($stmt->fetchAll() as $row){ $name=$row["uName"]; echo $name; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "php, pdo" }
Can not read property of array element in javascript Im fairly new to javascript and im trying to find an object of an array i created by the `configID` property. I used the method `find()` for this. **JS Code:** var configurationArray = flow.get("configurationArray") || []; var configurationId = msg.topic.split("/")[1]; var configuration = { configID: this.configurationID, configurationModules: this.MSGesture.payload }; if(!configurationArray.find(x => x.configID == this, configurationId)){ configurationArray.push(this.configuration); } else { //to do } I am using node-red which gives me `flow` and `msg`. **The Error i get:** Cannot read property 'configId' of undefined Any help is appreciated
You could destructure the property and add a default object. Then take `some` instead of `find`, because you need only the check. At last, omit `this` and take directly the value. if (!configurationArray.some(({ configID } = {}) => configID === configurationId)) { configurationArray.push(this.configuration); } else { //to do } If you like to have an abstract callback, you could take a closure over `configurationId`, like const hasId = id => ({ configID } = {}) => configID === id; if (!configurationArray.some(hasId(configurationId)) { configurationArray.push(this.configuration); } else { //to do }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript, arrays, node red" }
iPhone/iPad HTTP streaming library or server Is there any available open-source (preferred) or commercial library for on-fly segmenting and streaming of video to iPhone / iPad? Also, is there any open-source/commercial server (alternative to Wowza) which supports this?
Apple offers mediastreamsegmenter: < You might also want to peek at Best Practices for Creating and Deploying HTTP Live Streaming Media for the iPhone and iPad: < There's also Darwin Streaming Server, but you may not need it.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 5, "tags": "iphone, http, ipad, streaming" }
django: No module named entities.foo I'm trying to set up my first django project. Within the project, I have created a package called 'domain'. Within the package 'domain', there is a folder called 'entities'. Within the 'entities' folder, there is a file called 'foo.py', which contains a class called 'Foo'. I'm trying to import the class 'Foo' into another file (module?) I've tried pretty much every permutation I can think of. When I try this: from domain.entities.foo import Foo Eclipse stops highlighting the Foo class as unfound. It seems to be satisfied. But when I look at the page in a browser, I get an error screen: Import Error at /[URL] No module named entities.foo Can anyone help? I am entirely out of ideas.
You certainly don't have a `__init__.py` empty file on each folder (package). If you are using Python 2.X, you need it. domain |---- __init__.py |---- entities | |---- foo.py | |---- __init__.py After that, you will be able to import the class `Foo` inside the module `domain.entities.foo` from domain.entities.foo import Foo
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "python, django" }
Showing that $x$ is non-positive I've just started to study analysis by myself and I'm having a hard time proving things. I can understand the logic behind it and can describe it by words but I can't write it in "mathematics". This is the question: $x, y ∈ R$ If for all $y>0$ we have $y≥x$ show that $0≥x$ What I understand is that basically it says if all numbers from 0 to positive infinity is bigger than x than x is either 0 or a negative number because even the small numbers like $1/{10^{100000000}}$ are bigger than x. But how can I prove this in math? It seems pretty straightforward.
If $x>0$, take $y=\frac x2$. Then $y>0$, too. Besides, $x>y$. This is impossible, because $y>0$ and therefore $y\geqslant x$. Since we reached a contradiction, the original assumption ($x>0$) is false. Therefore, $x\leqslant0$.
stackexchange-math
{ "answer_score": 14, "question_score": 6, "tags": "inequality, real numbers" }
Android : Getting CURRENT coordinates (not lastKnownLocation) Right now, I only know of one method to do this: \- Get last known location \- Have the location manager request location updates However, I really only need to get the CURRENT coordinates ONCE right when the application is called, but it's not doing what I want. What's the simplest way to get the current coordinates? Is there something I could call or some code I could use just to get the location RIGHT NOW ? thanks in advance! I'm still a little new with android development.
> What's the simplest way to get the current coordinates? There is no way to get the current coordinates on demand. > Is there something I could call or some code I could use just to get the location RIGHT NOW ? No, for three related reasons: 1. Not all location technologies are low power. GPS, for example, is a serious battery hog. Hence, GPS is not powered on unless something is actively seeking a GPS fix. 2. Not all location technologies are instantaneous. GPS, for example, takes some number of seconds to get a fix after being powered on. 3. No location technology is universally available. GPS, for example, may be unavailable because you are in a large building.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "android, gps, coordinates" }
Strongly typed controller name in asp.net mvc 2 Is it possible to use strongly typed controller name and action name in asp.net mvc? for example instead of ActionLink("ActionName", "ControllerName"); somthing like this ActionLink(ControllerName(x=>x.ActionName()), ControllerName) Thanks, Alexander.
T4MVC does this. Watch this video for an introduction: <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "asp.net mvc, strong typing" }
Infinitely many integer solutions for the equations $x^3+y^3+z^3=1$ and $x^3+y^3+z^3=2$ How do you show that the equation $x^3+y^3+z^3=1$ has infinitely many solutions in integers? How about $x^3+y^3+z^3=2$?
You can reduce the first equation to $$x^3 = -y^3, z = 1$$ with obvious infinite solutions. This paper details other families of solutions. The second equation has solutions $(x,y,z)\equiv (6t^3+1, 1-6t^3, -6t^2)$ which (AFAIK) you find by construction (i.e you have to guess it).
stackexchange-math
{ "answer_score": 13, "question_score": 5, "tags": "number theory, elementary number theory, diophantine equations" }
Difference between Priority in the Positioning dialog and Z-Index in the Rendering dialog in QGIS I studying the layer labeling options in QGIS and encountered two options which seem to be the same. If I understand the QGIS documentation correctly, the option "priority" within "Positioning" determines which label to render when there are two Labels overlaping. The Z-Index Option in "Rendering" seems to be doing the same. What is the difference between these two options?
The "priority" option tells which label will be displayed if two labels overlap but if you set the option to render all labels (even overlapping labels), the Z index option lets you choose which one will be on top and will be more likely to be readable.
stackexchange-gis
{ "answer_score": 3, "question_score": 2, "tags": "qgis, labeling" }
Cross-browser method to prevent all methods of text copying from a textarea? I am working on an online typing software. In the typing software, all is going well but I have the problem of dishonest users who might possibly type the text into the textarea, copy it, then reload the page (therefore resetting the timer) and pasting it in straightaway. So I was thinking along the lines of using something like `evt.preventDefault();` when javascript detects the pressing of the ctrl / cmd button along with the `C` key. But then I realized that the user could always go up to the menu bar to press `Edit -> Copy`. So I was wondering, is there a cross-browser method to disable both methods of copying?
You can try to use the following jQuery code: $('input[type=text],textarea').bind('copy paste cut drag drop', function (e) { e.preventDefault(); });
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 6, "tags": "javascript, jquery, textarea, clipboard, copy paste" }
regular expression to use in PHP for removing particular text in brackets from a text string Can't figure this one out... I need a regular expression to use in PHP for removing particular text from a text string... My text strings are like this: "The product we're talking about [Art.0430000] is a good product" "The product we're talking about [Art.0430001] is a good product" "The product we're talking about [Art.7852000] is a good product" I need to remove [Art.0430000], [Art.0430001], [Art.7852000] from the strings...
If you also want to compress the white space left over (2 spaces to 1 space); $pattern = '/\[Art\.[0-9]+\]\s*/'; $result = preg_replace($pattern, "", $string);
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, regex" }
How to get rid of zero standard error values, missing t-values and p-values I was running a couple of Tobit regressions on SAS. Surprisingly, I found that estimates from one model show 0 standard errors, missing (.) t-values and p-values. Why did this happen? What does this scenario imply? If this is not normal, how can I get rid of it? Please allow me to share the output. And much thanks for your guidance. ![enter image description here]( ![enter image description here](
This typically happens when your Hessian matrix is nearly singular. The following SAS article describes your exact situation I believe. < Try re-scaling the variables that have zero standard errors as this is most likely the cause of the problem you are experiencing. I'm guessing that these variables are measured on a scale that is significantly larger/smaller than your other variables, which is leading to the invertibility problems with the Hessian matrix. You're likely to resolve this problem by standardizing the predictors before running `proc qlim.` See `proc standard` for this. Verify that you have correctly specified your model and didn't accidentally include some variables twice. It seems this has lead to some other problems noted here (the answer there by @placidia is a good one and may help you resolve your issue with `proc qlim`). If that does't work, try reading through this article and try some of the suggestions there.
stackexchange-stats
{ "answer_score": 1, "question_score": 1, "tags": "standard error, sas, tobit regression" }
Using "THIS" inside function How can I use "this" in this case? I got an error.. The page can't set display at null or undefined. <button onclick="myFunction(this)"> <script> function myFunction() { this.style.display='none'; } </script>
You can use func.call to bind a context for that function invocation (otherwise in your case it will be pointing the the global object (window) ): myFunction.call(this); or with `myFunction(this)` You should do: function myFunction(elm) { elm.style.display='none'; }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "javascript" }
Why am I getting 'Permission Denied' on my static assets? Question basically says it all. When I try to access my calendar page (which contains events), I get the following error: Permission denied - /Users/usernam/sitter/tmp/cache/assets/development/sass (in /Users/username/sitter/app/assets/stylesheets/events.css.scss) i've done a chmod 777 on all directories in my rails directory (i.e in myapp directory, i've done chmod 777 *). Not sure what I should be doing instead or in addition.
Add a -R to your chmod. Simply adding the star will only do the files. Chmod -R 777 * should work. Although you may have some ownership issues that need to be addressed. I would look into using chown instead of granting all access to everyone.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ruby on rails" }
AngularJS - How to not trigger hover action (ng-mouseenter) on mobile devices and only the cilck event I'm using AngularJS, and I currently have both a hover behaviour (using ng-mouseenter and ng-mouseleave) so when you hover on my content elements, it shows content on the page, but if you click on that element (using ng-click) it should go into a detail page for that element. I have all of these configured on the same `<div>`, and it works on desktop. But if I use my iPhone, then when I click the element, it triggers the hover action instead of the click action. It takes a second click to get to the click action, and I want it to trigger on the first click for mobile devices. How can I achieve this? Thanks for any help you can offer.
You should emulate double click on touch devices. You can use this directive: angular.module('app').directive('touchDevicesClick', function() { return function(scope, elem) { var element = angular.element(elem); element.on('touchstart', function(e) { element.triggerHandler('click') }); }; }) or you can use `$(elem).click()` instead `element.triggerHandler('click')`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, angularjs" }
Creating A Binary Tree From Two Traversal Output This is homework, but for some reason it would not allow me to add the homework tag. We were assigned a lab for data structures in which the last question asked us to find the binary tree that would produce the following output from the given traversal methods: LRN: 12, 9, 4, 7, 1, 14, 8, 13, 10, 15, 11, 2, 5, 16, 6, 3 and LNR: 12, 3, 4, 9, 8, 1, 7, 14, 6, 13, 10, 16, 5, 15, 2, 11 I have identified the following about the tree: The root node is 3. The root nodes left child and only left child of the tree is 12. The root nodes right child is 6. The furthest right node is 5. Unfortunately I am stuck as to how to proceed. Any hints would be greatly appreciated.
From the post-order(LRN), we know that last element is the root. We can find the root in in-order(LNR). Then we can identify the left and right sub-trees of the root from in-order. Using the length of left sub-tree, we can identify left and right sub-trees in post-order array. Recursively, we can build up the tree. Check this link.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "binary tree, inorder, postorder" }
What is the view volume of the projection without glFrustum and glOrtho setting? I am reading sample code GLVideoFrame from WWDC2010. In this sample, it has code like below: static const GLfloat squareVertices[] = { -0.5f, -0.33f, 0.5f, -0.33f, -0.5f, 0.33f, 0.5f, 0.33f, }; ... glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0f, (GLfloat)(sinf(transY)/2.0f), 0.0f); transY += 0.075f; ... glVertexPointer(2, GL_FLOAT, 0, squareVertices); Notice that this code does not call any function like glFrustum or glOrtho for openGL projection setting. By only calling gLoadIdentity(), what will be the "default" view volume? it wil be a perspective project or orthographic projection? edited: to be more specific, is the view volume a cube that "ranging from -1 to 1 in all three axes" ?
OpenGL assumes that after the ModelView and Projection transform, all visible elements are in clip space (or NDC space); it uses the cube `[-1;+1]^3`. The matrices contents is entirely your responsibility. Since you load the identity matrix, there is no Projection at all.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, opengl es" }
Do I need a view for every action? I have been developing in ASP.NET MVC for a short while. Up to this point, the controller actions have been fairly simple. Each action returns its corresponding view. However, I recently created an action that I don't necessarily need a page for (the purpose of the action is to work with the database). My question is - what is the proper thing to do here. At the end of the method, I return Response.Redirect('\Controller\View'), so I go back to another view. Is it possible to not have to return any kind of view at the end of an action? What are the best practices here?
If you need to redirect a user because they clicked a link then redirect a user. If your posting with Ajax or another technique and there is no meaningful response change the controller action method to have a return type of void.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 4, "tags": "asp.net mvc, view, controller, action" }
Evaluate $\int_{A}(x-y)^{2} \cos (x+y) d(x, y)$ where $A$ is the square region in the plane with vertices $(0,1),(1,2),(2,1)$ and $(1,0).$ > Evaluate (Use a linear change of variables) > > $$\int_{A}(x-y)^{2} \cos (x+y) d(x, y)$$ > > where $A$ is the square region in the plane with vertices $(0,1),(1,2),(2,1)$ and $(1,0).$ I can compute followwing integral, that is I know what i'd do like this: $\iint_{R}\left(4 x^{2}-y^{2}\right)^{4} d x d y$, but I don't know what i'd do in uppermost question, may you add answer? Thanks...
Let $w=x-y$ and $z = x+y$ then solving for $x$ and $y$ we get $x= \dfrac{z+w}{2}$ and $y = \dfrac{z-w}{2}$. Then just compute the Jacobian and the integral becomes $$\int_{A'} w^2 \cos(z) \left\|\begin{bmatrix} \frac{\partial{x}}{\partial{z}} \ \frac{\partial{x}}{\partial{w}} \\\ \frac{\partial{y}}{\partial{z}} \ \frac{\partial{y}}{\partial{w}}\end{bmatrix} \right\|\,\mathrm dw\,\mathrm dz.$$
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "real analysis, calculus, multivariable calculus, change of variable" }
SDL ld returned 1 exit status im writing a sample SDL program, and I just wrote the simplest program, but i get the following error because of my SDL_pollevent() function: Test.cpp:(.text._ZN4CApp9OnExecuteEv[CApp::OnExecute()]+0x41): undefined reference to `SDL_PollEvent' collect2: ld returned 1 exit status and the code is: int OnExecute() { if(OnInit()==false) return -1; SDL_Event Event; while(Running) { while(SDL_PollEvent(&Event)) { OnEvent(&Event); } OnLoop(); OnRend(); } OnClean(); return 0; }
This is a linker error. You are not correctly linking the SDL libraries to your project. Usually you would need to add `-lSDL` to your linker. If you are using Windows I believe you have to add `-lSDLmain` too. Make sure your compiler knows where to find these files (set your library path correctly). If you don't know how to do this, check the system and IDE specific installation instructions in this tutorial. I assume that `SDL_Init()` is called within `OnInit()`? Otherwise your program will not run correctly.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "sdl" }
Invertibility and rank How do you formally prove that a matrix A is invertible if and only if it has full rank, without using determinants?
If a matrix $A$ has full rank the row reduced echelon form of $A$ will be the identity matrix. We can find the inverse of $A$, multiplying I by the elementary row operations. Note that if $E_1 E_2...E_k A= I$, then $A^{-1}= E_1 E_2...E_k I.$
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "linear algebra, matrices" }
Adding another column when row reaches XX I am trying to make a nice display of my array data within an element that has a certain width/height. What I want to do is that when my data reaches the bottom of the element to start a new column and continue with printing the data within that next column and so on/forth Any help is much appreciated! My code: <div class="repeater" ng-repeat="files in files"> {{files.name}} <div class='progress-bar'> <div class='percentage' ng-style="style"> </div> </div> </div> Current view: !enter image description here
# HTML/CSS solution This should be better solved by CSS than by your application logic. You could display the file names as list and adapt the approach at How to display an unordered list in two columns? to display them in multiple columns.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "angularjs, angularjs ng repeat, css tables" }
Pdf.js not working on Internet Explorer Can anyone explain me why this code don't work in IE? In Chrome everything works just fine. Part of my Html: <head> <script type='text/javascript' src="//code.jquery.com/jquery-1.9.1.js"></script> <script type='text/javascript' src=" <script type='text/javascript' src=" </head> <body> <div id="pdfContainer" class = "pdf-content"></div> </body> Full code and example that works on Chrome: <
I've figured out what my problem was. I replaced the pdf.js with pdf.min.js and now everything works fine in both Explorer 10 and Chrome. Don't know exactly why, but it works.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 7, "tags": "javascript, html, internet explorer" }
JavaScript: Retrieve Only Minute From Server Generated Date().toTimeString() My server WebSocket app is sending the client the time in the following format: client.send(new Date().toTimeString()); And the JavaScript client is receiving it like so: 01:32:13 GMT+0700 (Indochina Time) I would like to retrieve only the MINUTE and nothing else. How may I do so? Any help is greatly appreciated.
console.log("01:32:13 GMT+0700 (Indochina Time)".split(":")[1])
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, regex, datetime" }
Real world Spring. Do you really inject primitive values via bean definition? The following seems making sense if we consider the attributes are constant. <bean id="student" class="com.Student"> <property name="name" value="Paul"/> <property name="id" value="12"/> </bean> * * * Object s = fac.getBean("student"); Student stu = (Student) s; Probably the most dynamic way would be : <bean id="student" class="com.Student"/> * * * Object s = fac.getBean("student"); Student stu = (Student) s; stu.setName(...); stu.setId(..); My question is that, is this just way to introduce the basic mechanism of Spring framework or you really do primitive values injection.
Imagine scenario: <beans profile="development"> <bean id="student" class="com.Student"> <property name="name" value="${name}"/> <property name="id" value="123"/> </bean> </beans> <beans profile="production"> <bean id="student" class="com.Student"> <property name="name" value="${name}"/> <property name="id" value="#{idProvider.getId()}"/> </bean> </beans> now you would have 2 different property files... development.properties name=developer production.properties name=Paul To do it your way you would need 2 versions of code.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, spring" }
Reference to HTML-element that invoked an action I'm invoking an Ember action via a link: <a {{action "openApps"}}>Apps</a> and handling it in the appropriate controller actions: { openApps: function() { //... } } How do I get a reference to the `<a>` which invoked the action inside the controller-function.
It's funny. Someone answered the question yesterday with exactly what I wanted but he/she deleted the answer. Therefore here it is: It is perfectly possible to get the target of an action by using `window.event.target`: actions: { openNav: function() { Ember.$(window.event.target).slideToggle(); } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "ember.js, ember cli" }
What is the best reference for real number objects? Are there textbooks that, assuming a decent grasp of category theory and topos theory in particular, start with a natural numbers object and build the integers, the rationals and the real numbers (dedekind and cauchy) in general and also making the explicit construction in some important toposes? Also it should include proofs for basic theorems of real analysis valid in every (or most) topos. Thanks!
There are two sections about this in _Sheaves in Geometry and Logic_ by Mac Lane and Moerdijk: * VI.8, which is about the construction of the real numbers object in a topos; * VI.9, which is about Brouwer's theorem that all functions are continuous (which can hold in certain intuitionistic toposes).
stackexchange-math
{ "answer_score": 4, "question_score": 2, "tags": "reference request, category theory, topos theory" }
Ajax Progress Bar I am building a file uploader and execute in my project. First it uploads a invoice PDF file, after upload is complete, I extract all pdf text and them I do a series of queries to store some information in mysql. Some PDF is about 40~70 pages, so it take some time to process everything, I already have the upload system with progress bar, now I want to do a second progress bar that show the pdf extract informations. Can someone give me a suggestion how to do it? It's php project. Thanks
There a few ways to approach this. **Ajax polling** You can upload the file and set the job's progress in a database. After the file is uploaded you ajax a page which reads the progress from the database. **Without Ajax polling** You can also do this with streaming ,This article is a great place to start. ajax-based-streaming-without-polling
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, ajax, progress bar" }
Can I cycle or run with shoulder niggles? I have developed a slight niggle in my right shoulder. Reason could be because of over workout in swimming. The niggle is light pain when I move my shoulders a bit fast with some weight on it. For example pulling the water while swimming. It is not severe and all. That is why mentioned it as niggles. Now my question is, can I cycle or run? I have planned for a slow jogging or very slow cycling(both being a bit long) for coming three days followed with one day's rest and then start swimming. Is it okay? Any suggestions? The answer I am expecting is similar to this: For different extent of shoulder injury, different allowance of running or cycling can be done or may be that there is no such thing (can do running or cycling, it doesn't matter to the shoulder at all) or may be that I shouldn't do both.
Well, I found this a bit subjective, hence I am answering it myself. The shoulder niggle may vary for different person. When we call it 'niggle' which means slight but persistent discomfort is not a serious injury but one has to be careful with it, since it may lead to some serious injury. I took rest for a day and then the next 2 days I followed the exercises given in this link without weights. It was very helpful. And then the following day I cycled 50 km and the following day I ran a half marathon and I made my personal best. This is very subjective, I know. But in my opinion, after experiencing the constantly irritating niggle in my shoulder, cycling or running doesn't hurt the shoulder, provided resting 1 or 2 days.
stackexchange-fitness
{ "answer_score": 1, "question_score": 4, "tags": "running, swimming, bicycling" }
Loop structure inside gnuplot? Is there any way to iteratively retrieve data from multiple files and plot them on the same graph in gnuplot. Suppose I have files like data1.txt, data2.txt......data1000.txt; each having the same number of columns. Now I could write something like- plot "data1.txt" using 1:2 title "Flow 1", \ "data2.txt" using 1:2 title "Flow 2", \ . . . "data1000.txt" using 1:2 title "Flow 6" But this would be really inconvenient. I was wondering whether there is a way to loop through the **plot** part in gnuplot.
There sure is (in gnuplot 4.4+): plot for [i=1:1000] 'data'.i.'.txt' using 1:2 title 'Flow '.i The variable `i` can be interpreted as a variable or a string, so you could do something like plot for [i=1:1000] 'data'.i.'.txt' using 1:($2+i) title 'Flow '.i if you want to have lines offset from each other. Type `help iteration` at the gnuplot command line for more info. Also be sure to see @DarioP's answer about the `do for` syntax; that gives you something closer to a traditional `for` loop.
stackexchange-stackoverflow
{ "answer_score": 108, "question_score": 93, "tags": "gnuplot" }
Waiting mouse cursor in my GWT application stays infinitely (only in Chrome, only in Production) Could you please tell me why I have waiting mouse cursor in my gwt application as if page not fully loaded ? It doesn't happen on dev server. It only happens in production. Also it's happening in Chrome but doesn't in IE. Link to my app is **here**. Screenshot !enter image description here
I checked it again in Chrome, but for me no wait cursor is Displayed. But i think, your Google Chrome is trying to open the Google Translate Menu. For me it came quickly and the page loading stopped and the mouse was at normal position. I prefer you try updating your chrome. I have also checked the same in my co-workers Laptop and its working fine too. !Screenshot If problem still persists, please use CCleaner Software and clear all Temporary files, Browser Cache, Recent files etc. Why because, GWT creates a lot of temporary files which may reduce your system performance. So after each cleaning, just restart the system also. I had few such resolutions recently.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "gwt" }
Compability JDBC driver versions and PostgreSQL versions Can anyone point me on where to find an exact documenation which postgreSQL database version requires which JDBC driver version? In the case at hand I want to know: What is the minimum required JDBC version in a Java server application connecting to a database of version PostgreSQL 11.13? Unfortunately the PostgreSQL JDBC Driver website is not really precise on this: > The current version of the driver **should be compatible** with PostgreSQL 8.2 and higher, and Java 6 (JDBC 4.0), Java 7 (JDBC 4.1), Java 8 (JDBC 4.2) and Java 9. <
The question is a wrong one. Why would you want to use a JDBC driver that has as many bugs as possible? Rather, you want to ask what the oldest version is that the latest JDBC driver supports, and the documentation will tell you that > [...] nning old applications or JVMs), this is the driver you should be using. It supports PostgreSQL 8.2 or newer and requires Java 6 or newer. Always use the latest JDBC driver, and you won't go wrong.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "java, postgresql, jdbc" }
Spring custom authentication manager (with custom user details service) In my Spring app, I want my ProviderManager class to implement Serializable class (for my own reason), of course we can't edit Spring code, so one way that I did is to use a custom class called CustomProviderManager that extends ProviderManager and implements Serializable class. My old declaration of authentication manager likes this: <security:authentication-manager alias="authenticationManager"> <security:authentication-provider user-service-ref="customUserDetailsService" > <security:password-encoder hash="md5" /> </security:authentication-provider> </security:authentication-manager> How can I config likes above snippet for my CustomProviderManager class (my authentication provider of my custom authentication manager should use custom user details service name " **customUserDetailsService** " and password encoder is " **md5** ")
Depends a little bit on your CustomProviderManager, but something like this: <bean id="authenticationManager" class="CustomProviderManager"> <constructor-arg> <bean class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"> <property name="userDetailsService" ref="customUserDetailsService"/> <property name="passwordEncoder"> <bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder"/> </property> </bean> </constructor-arg> </bean>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "spring security" }
Wide tile for wp 7.1 app runned on wp8 I need to add wide tile template for my WP 7.1 app. When it runned on wp8 devices, tile what I created from app list can not be expanded to "wide tile" how on image below. !Tiles template example I only can set it to first and second position. Can I add an image for wide template into wp 7.1 application?
There are few ways to do that. * Reflection * Mangopolo lib Here you can find an overview.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "windows phone 7, windows phone 7.1, windows phone 8" }
perf trouble drawing 256 polygons on a sphere with three js i'm facing a problem when i'm trying to insert on my sphere, 256 mesh using polygon previously generated and triangulated 1) Perf overwhelming, 5fps, don't understand really why, when i inspect the buffers using webgl inpspector i can see over 30k buffer stored ! i'm just drawing 256 polygon max... 2) the polygon aren't on the surface of my sphere but inside, they did not morph
Move: new THREE.MeshBasicMaterial({color:0x00ff00*0.05})); before the loop. Since you are using the same material you only need to declare it once (pushed to the gpu once) not every loop iteration. So: var mat = new THREE.MeshBasicMaterial({color:0x00ff00*0.05})); for(i=0; i<mygeometry.length;i++){ var object = new THREE.mesh(mygeometry[i],mat); }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "three.js, opengl es 2.0, webgl" }
MSBuild Macro for NuGet package directory I'm working on a NuGet package that adds a step to the build process by using a `.targets` file. I need to reference other files from my NuGet package in order to complete the build successfully. In the past, I've used `$(SolutionDir)packages\MyPackage` and all has worked fine. However, I was just playing around with the VS 2017 RC, and I noticed that my package was installed in the global NuGet package directory, not in the solution folder. Is there some macro that I can use from MSBuild, that contains the path for the NuGet `packages` folder? It is a requirement that I maintain compatibility with VS2012.
You can use an alternative method that create a NuGet.Config file in the root of the \Solutions\ folder to set the package repositoryPath of VS 2017 RC, add to NuGet.Config the following: <?xml version="1.0" encoding="utf-8"?> <configuration> <config> <add key="repositoryPath" value="$\..\Packages" /> </config> </configuration> For the repositoryPath setting, you can specify an absolute path or relative path (recommended) using the $ token. The $ token is based on where the NuGet.Config is located. In this case, you package will install in `$(SolutionDir)packages\` folder, you can used `$(SolutionDir)packages\MyPackage` for Visual Studio 2017 RC. It`s also maintain compatibility with VS2012.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 15, "tags": "visual studio, msbuild, nuget" }
Can I hook into user registration *before* a user is created? I want to limit registration based on the domain associated with their email address. I was looking at the `user_register` action hook, but it fires _after_ the user is already inserted, which, although it could be hacked into working, is less than ideal. I want to preempt rather than retroactively remove invalid users. I've looked through the source in `wp-includes/user.php`, but nothing in there looks to be helpful. I did notice the `pre_user_email` filter, but that doesn't seem to offer any options for doing anything useful since I can't see a way to do anything with that.
You're looking in the wrong place. When a user first attempts to register, their username and email is processed and sanitized inside the `register_new_user()` function in `wp-login.php`. This is where you want to do your filtering. Before the user is created, WordPress will pass the sanitized user login, email address, and an array or errors through the 'register_post' action. If there are any errors after that, then the user is not added and they will see the errors in the UI. So the following _untested_ function might help: function prevent_email_domain( $user_login, $user_email, $errors ) { if ( strpos( $user_email, '@baddomain.com' ) != -1 ) { $errors->add( 'bad_email_domain', '<strong>ERROR</strong>: This email domain is not allowed.' ); } } add_action( 'register_post', 'prevent_email_domain', 10, 3 );
stackexchange-wordpress
{ "answer_score": 14, "question_score": 7, "tags": "user registration, limit" }
Значение слова «вобчью» Привожу цитату из «Сродства мировых сил» Козьмы Пруткова: Свет земле вобчью. Вывожу зарю. Что свершилось ночью — Вскоре озарю. Подскажите, пожалуйста, что такое «вобчью»? Буду признательна.
Ольга: > Привожу цитату из «Сродства мировых сил» Козьмы Пруткова: > > Свет земле вобчью. > > Вывожу зарю. > > Что свершилось ночью — > > Вскоре озарю. > > Подскажите, пожалуйста, что такое «вобчью»? Мимоходов правильно написал в своём ответе: ошибка оцифровки. У Козьмы Пруткова ни в одном из просмотренных мною бумажных изданиях "вобчью" нет. Есть: **_воо́чью_**. Вот как этот отрывок выглядел, к примеру, в 7-ом издании полного собрания сочинений Козьмы Пруткова, вышедшем в 1899 году: > ![введите сюда описание изображения]( А употребляться это слово во времена Козьмы Пруткова могло не только в значениях, к которым мы привыкли...
stackexchange-rus
{ "answer_score": 1, "question_score": 2, "tags": "значение слов, выбор слов, литература" }
How do I deploy on Heroku a Python wrapper? I am trying to deploy a program on heroku. The program uses Flask and Python. It does not make any calls to a database. It runs locally without an issue. It builds successfully on heroku. But when I interact with the web page, an AJAX call fails because it lacks a dependency. Error message: `POST 500 (Internal Server Error)` Inspecting the logs shows: 2020-02-29T23:45:05.133568+00:00 app[web.1]: raise InstallError('The SDD library is not available. Please install the PySDD package.') 2020-02-29T23:45:05.133574+00:00 app[web.1]: problog.errors.InstallError: The SDD library is not available. Please install the PySDD package.. The `PySDD` library is part of `requirements.txt`. **How do I push to heroku the underlying SDD library?**
You must add all dependencies on your pipfile, for example: [[source]] url = " verify_ssl = true [packages] Flask = "*" PySDD = "*" [requires] python_version = "3.6" Hope it suits well
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "flask, heroku, web applications" }
How do I enable automatic login in Mythbuntu 11.10 I just upgraded to Mythbuntu 11.10, and everything is working great, except for one snag. Automatic login has gone away. When I try to call up the interface for setting it, the option to make the setting is grayed out, as shown in the picture below. I have tried running the mythbuntu-control-centre as a regular user, and as root, and either way, I can't access the settings. How do I get my autologin function back? !greyed out autologin
I played with the lightdm.conf (the one located at `/etc/lightdm/lightdm.conf` not the one in /etc/init/) and got the auto login working for me: [SeatDefaults] user-session=mythbuntu allow-guest=false autologin-user=your username greeter-session=mythbuntu-lightdm-gtk-greeter Think that the greeter-session needed to be updated for mythbuntu.
stackexchange-askubuntu
{ "answer_score": 5, "question_score": 3, "tags": "11.10, login, mythbuntu" }
No mysql password under linux? I was told that mysql user, similar to root user, by default "has no password". Not an empty password, but rather "no password". I wasn't aware this situation was possible - I thought every user on a linux had to have a password. Am I wrong? Can you point me to a link that explain this?
When you add a user in unix, ever notice how it doesn't prompt you for a password? Try it: `useradd testuser`. Didn't ask did it? Just gave you a new command prompt. Congratulations, now you have a user with no password. Of course, you can't log in using the user until you set a password for it, so it's not much of a security hole. This is the reason the mysql user is set up with no password: if it HAD a default password it would be a MASSIVE security hole, because you'd be able to log in using that user and have rights over the database. If you look in your /etc/shadow file, you should see the user with a ! where the password would otherwise be. Means the account is locked.
stackexchange-superuser
{ "answer_score": 8, "question_score": 3, "tags": "linux, passwords, mysql" }
Is it correct to say 'We will do it when we got a decision'? Someone will make a decision, then we receive it, and do something according to it.
Some tenses are mixed here, making the sentence incomprehensible. Your sentence would be grammatically correct if you said, "We will do it we when we **_get_** a decision."
stackexchange-english
{ "answer_score": 2, "question_score": 1, "tags": "phrases, word usage" }
Flagged answer was "helpful" but was not deleted > **Possible Duplicate:** > Why does flag marking as helpful/declined not always correlate with moderator action? An answer I flagged today as being of a "very low quality" was deemed to be "helpful": !enter image description here yet it was not removed. Note that I don't mind it still being there (the question is closed, so it might even get deleted with the question in due time), but I thought that "helpful" flags always caused the answer to be deleted. Am I wrong, or did something go wrong in this case? I scrolled through ~10 of my "very low quality" flags that were "helpful", and all of them were removed by a mod.
"Helpful" just means that a moderator thought your flag had merit and was useful. Now, VLQ flags are supposed to indicate problems with the post that cannot be fixed by an edit. The answer you flagged is a link-only answer, which isn't great, but it's not really a "very low quality" answer either. It's the kind of answer we'd normally leave a comment on or convert to a comment. It looks like your flag resulted in the closure of the question as duplicate, so it still had a net positive effect on the site and that's likely the reason why it was dismissed as helpful.
stackexchange-meta
{ "answer_score": 9, "question_score": 7, "tags": "support, flags" }
selenium - trouble clicking a button to export I've been learning how to use selenium to parse data and I've been doing alright with that process. So I'm trying something different, in that I found data ta parse, but there is a provided export button which to me, sounds like a quicker solution, so I thought I'd have a stab at it. But I'm not quite understanding how it's not working: browser = webdriver.Chrome() url = ' browser.get(url) button = browser.find_elements_by_xpath('//*[@id="injury-report"]/div[2]/div[2]/button[2]') button.click() browser.close() I just want to click on the export csv button on the page. Also, I haven't looked yet, but my next step would be to specify where to save the csv file it exports. Right now it, defaults to the downloads folder. Is there a way to specify a location without changing the default? Also is there a way to specify a file name?
Try below code to click required button: from selenium.webdriver.support.ui import WebDriverWait as wait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC browser = webdriver.Chrome() url = ' browser.get(url) button = wait(browser, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "is-csv"))) button.click() browser.close() Also check how to save file to specific folder
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, selenium" }
how to specify DYLD_LIBRARY_PATH using buildbot? I am building and runing test for my project using buildbot. I am using mac as slave. The problem arises when I try to run the test because it cannot find the dynamic library which is shaved in different directory. From the buildbot tutorial I can see a varibale called env. It uses PATH so I supposed DYLD_LIBRARY_PATH would also work the same way so I did env = {"DYLD_LIBRARY_PATH":["/x/y/lib","/x1/y1/lib","${DYLD_LIBRARY_PATH}"]} but it still cannot find the shared library that I want those binary to find. can anyone help me on this one.pls
I was kind of right. This is the way to do but you should do in BuilderConfig ( ..,..,..,env = {'DYLD_LIBRARY_PATH':'/x/y/lib:x1/y1/lib'} and thats it
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, continuous integration, buildbot" }
Does complex analytic function $f(z)$ imply $f'(z)$ continuous? Just ask a very fundamental question. I am reading the following textbook: `Ablowitz and Fokas: Complex Variables, Introduction and Applications, second edition` On p.83, it says > analytic only means $f'(z)$ exists, not that it is necessarily continuous On p.38, it says > an analytic function has derivatives of all orders in the region of analyticity and that the real and imaginary parts have continuous derivatives of all orders as well On p.37, Definition 2.1.1 says > $f(z)$ is said to be analytic at $z_0$ if $f(z)$ is differentiable in a neighborhood of $z_0$. If $f(z)$ has derivatives of all orders, I think $f'(z)$ should be continuous, right? Otherwise $f(z)$ is not differentiable. So I am confused about the three statements above. Is there an example that $f(z)$ is analytic in $D$ but $f'(z)$ is not continuous in $D$? Thanks so much!
It appears that the statements on pages 83 and 37 contradict each other. The function $f(z) = |z|^2$ is differentiable only at $z=0.$ I would not call it analytic, nor holomorphic. There is a fastidious distinction that says "holomorphic" means (complex-)differentiable in an _open_ set, whereas "analytic" means locally equal to the sum of a convergent power series. But in the context of functions from $\mathbb C$ to $\mathbb C,$ those two can be shown to be the same, and many authors will make no such distinction. But even those who make no such distinction I would expect **not** to consider $z\mapsto |z|^2$ to be $\text{“analytic at $0,$”}$ since there is no open neighborhood of $0$ within which it's differentiable.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "complex analysis" }
How avoid ambiguousness when joining tables with a where statement? i have a query such as SELECT * FROM bookings left JOIN answers on bookings.id=answers.booking_id where id=1 since both tables have id and booking_id i am getting : `column reference "id" is ambiguous`
Qualify the column references -- _all_ of them. To facilitate this, use table alias that are abbreviations of the table names. Something like this: SELECT * FROM bookings b LEFT JOIN answers a ON b.id = a.booking_id WHERE b.id = 1; (Note: I don't know if you want `b.id = 1` or `a.id = 1`, but the latter condition should be in the `ON` clause for a `LEFT JOIN`.) I would also advise you to list out the columns in the `SELECT` \-- you have duplicate names so you want to be careful there too.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "sql, postgresql" }
Liferay Hook override current JS Is there a special tag i can use when creating a liferay hook that allows liferay to use my specific javascript over the default liferay javascript. I want to override the liferay session.js with my own version in my hook. So for overriding jsp you can use <custom-jsp-dir>/custom_jsps</custom-jsp-dir>
I'd expect the non-theme-related js to be overridden just like JSPs. In fact, I've seen a hook for updating alloy-ui, and if memory doesn't serve me wrong, this has been done through exactly these mechanics. Have you tried this but it didn't work or didn't you try it because you supposed it wouldn't work?
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript, hook, liferay" }
How to take a screenshot of the X virtual framebuffer display? I would like to take a screenshot from Xvfb display server. I already tried: xwd -root -silent -out screen.xwd but I can't read this file and I couldn't find any software (via Homebrew) which can display or convert it. Is there any better way of doing that on OS X?
netpbm (`brew install netpbm`) can process xwd files, so you should be able to do the standard Unix X11 process: $ xwd -root -silent -out screen.xwd $ xwdtopnm < screen.xwd | pnmtojpeg > screen.jpg xwdtopnm: writing PPM file
stackexchange-unix
{ "answer_score": 2, "question_score": 0, "tags": "osx, screenshot, xvfb" }
What are the best SEO practices when changing domain names? I'm using the Yoast SEO plugin on a WordPress site on a new, more memorable domain to replace an old static HTML site with no SEO. I've followed Google's documentation for moving a site, set up 301 redirects from the old domain to the new one, and filed a change of address in the Google Search Console. However, after a few days, the old site still shows in search results, and is ranked higher than the new one if you google our company name. And, if I try to set the preferred domain in the Google Search Console Site Settings for the new site, I see this in place of the options to prefer www/non-www/http/https: > Not all options are available because of a Change of Address request related to this site. I've read of some cases where this condition has lasted for least least a month. Is there anything more I can do to fix this? Have I done something wrong, or do I just need to wait, and for how long?
Yeah, "after a few days" isn't much time at all for a small site. It sounds like you've done what you need to do and are just in the waiting phase. The one thing you didn't mention was using the Fetch as Google feature in Search Console. That can be used to ask Google to crawl and index your URLs.
stackexchange-webmasters
{ "answer_score": 2, "question_score": 1, "tags": "seo, domains, google search console, google search" }
R problem with finding all combinations of coordinates in a hexagonal grid Given the coordinates of any hexagon in the image below, I want to return the 6 sets coordinates of the adjacent hexagons. What is the best approach to this? I have figured out that the coordinates adjacent to (x,y) consist of all combinations of x-1,x,x+1,y-1,y,y+1 but I'm not sure the best way to approach this programmatically. ![enter image description here](
The coordinates adjacent to (x,y) are not all combinations of those expressions because there are 9 such combinations and only 6 adjacent hexes ((1, 1), (-1, -1) and (0, 0) are not adjacent to (0, 0)). An R function to list the correct coords needn't be any more complicated than this: adjacent_coords = function(x) { list(c(x[1], x[2]+1), c(x[1]+1, x[2]), c(x[1]+1, x[2]-1), c(x[1], x[2]-1), c(x[1]-1, x[2]), c(x[1]-1, x[2]+1)) } adjacent_coords(c(1, -1)) [[1]] [1] 1 0 [[2]] [1] 2 -1 [[3]] [1] 2 -2 [[4]] [1] 1 -2 [[5]] [1] 0 -1 [[6]] [1] 0 0
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "r" }
How to stop program for 1 second in Java Android? I would like the program to work like this: public void onClick(View view){ method1(); // sleep for 1 second method2(); } I used **Threed.sleep()** but it works like: public void onClick(View view){ // sleep for 1 second method1(); method2(); }
public void onClick(View view){ method1(); new Handler().postDelayed(new Runnable() { @Override public void run() { method2(); } },1000); } Find more about handler here
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "java, android, sleep" }
Integration work: $\int\sqrt{\frac{2-x}{x-3}} \ \mathrm dx$ > $$\int\sqrt{\dfrac{2-x}{x-3}}\mathrm dx$$ My approach I=$$\int\sqrt{\dfrac{2-x}{x-3}}\mathrm dx$$ I= $$\int\frac{2-x}{\sqrt{-x^2+5x-6}}\mathrm dx$$ Next I substituted 2-x =t and processed but I am not getting the answer. Can you guys help me with this
Hint: try to compute $I$ via the substitution $$ \frac{2-x}{x-3}=t $$
stackexchange-math
{ "answer_score": 3, "question_score": 2, "tags": "calculus, integration" }
Should I keep a SerialPort connection open? I am working with serial communication and I'm wondering whether I should keep the SerialPort open or not? I'm creating a queue of commands and only one will be running at a time. Should I create a SerialPort and open/close it in each command, or should I have another class which holds the port open and is called from the commands? Or does it really matter?
Keep it open. No point to have the overhead of opening and closing it.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 5, "tags": ".net, .net 3.5, serial communication" }
What is the name of the statistical fallacy whereby outcomes of previous coin flips influence beliefs about subsequent coin flips? As we all know, if you flip a coin that has an equal chance of landing heads as it does tails, then if you flip the coin many times, half the time you will get heads and half the time you will get tails. When discussing this with a friend, they said that if you were to flip the coin 1000 times, and lets say the first 100 times it landed heads, then the chances of landing a tail was increased (the logic being that if it is unbiased, then by the time you have flipped it 1000 times you will have roughly 500 heads and 500 tails, so tails must be more likely). I know that to be a fallacy, as past results don't influence future results. Is there a name for that particular fallacy? Also, is there a better explanation of why this is fallacious?
It's called the _Gambler's fallacy_.
stackexchange-stats
{ "answer_score": 46, "question_score": 33, "tags": "probability, distributions, sampling" }
Is it possible to search for all dependencies of a field I am searching for a specific line in my database and wanted to know if there is a function in ibexpert to look up for all dependencies of a field.
When field is selected in table click on "Field dependencies" tab. ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "firebird, ibexpert" }
Client app able to call API Locally but unable to do it in IIS I have an application that his a .Net Core API. Everything works locally, and by that means, Client App --> hits an .Net Core API successfully. Howevever we have pushed the app to IIS Server, and we are not able to successfuly hit the API. I know this is extremely vague, but what is something that I should be looking at to diagnose address this. I pulled the code from the published branch, and it works like a charm on local, but does not work on Server. I do not get any Server Side exceptions.
Is there network connectivity? Log into the server and open a browser and put in the URL to the API. Any HTTP error is good. It means you can reach the API. If it times out, that's bad and that's your problem. How do you know there are no exceptions? Are you logging all exceptions? Are you sure no exceptions are hidden in `try` blocks that end up ignoring the exception? Assuming it's a Windows server, check the Event Viewer for warnings or errors.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": ".net core" }
$M= \begin{bmatrix} 1 & -1 & 1\\ 2 & 1 & 2 \end{bmatrix}$,find a rank one $2 \times 3$ matrix $N$ such that $\|M-N\|_2$ is minimized We have a matrix $M= \begin{bmatrix} 1 & -1 & 1\\\ 2 & 1 & 2 \end{bmatrix}$. My question is how to find a rank one $2 \times 3$ matrix $N$ such that $\|M-N\|_2$ is minimized? I don't know where to start. I appreciate any hints or solutions.
Hint: Let $$M=\sum_{i=1}^2\sigma_i U_i V_i^T$$ be the SVD decomposition where $\sigma_1 > \sigma_2$. It is known that the best rank $1$ $2-$norm approximation is $M_1=\sigma_1U_1V_1^T$. Similar result is known for best rank $k$ $2-$norm approximation or Frobenius norm approximation.
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "linear algebra, matrices, numerical methods, normed spaces, numerical linear algebra" }
correcto manejo de crontab Mi consulta es la siguiente: tengo que programar 3 respaldos, base de datos, configuración del sistema y logs. en la propuesta los definí de ésta manera, es correcto (va con el comentario para comparen lo que hice con lo que quería hacer) 0 0/3 0 0 0 root sh /opt/backups/dbBack.sh #Backup de la BD cada 3 horas. 0 0 0/1 0 0 root sh /opt/backups/logBack.sh #Backup de logs del sistema diario. 0 0 0/1 0 0 root sh /opt/backups/syscfgBack.sh #Backup de configuracion del sistema diario. Aparte aprovecho, como es el proceso para comprimir cada uno de los archivos o directorios que genera cada uno de los scripts, para ahorrar espacio, ya que no tengo idea alguna. Gracias.
Puedes hacer algo como: 0 */3 * * * root sh /opt/backups/dbBack.sh #Backup de la BD cada 3 horas. 0 0 * * * root sh /opt/backups/logBack.sh #Backup de logs del sistema diario a las 12AM (hora 0). 0 1 * * * root sh /opt/backups/syscfgBack.sh #Backup de configuracion del sistema diario a las 1AM para que no corra junto con el de las 12. Si quieres controlar las horas en las que se hace el de cada 3 horas: 0 2,5,8,11,14,17,20,23 * * * root sh /opt/backups/dbBack.sh #Backup de la BD cada 3 horas y no corre junto a los otros backups.
stackexchange-es_stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "linux, crontab" }
Finding Probability $P(X^2 \leq X)$ I'm looking to find the probability that $P(X^2 \leq X)$ with $X$ having a cfd which is a piecewise function
We have: $$X^2 \le X \iff X(X - 1) \le 0$$ giving $X^2 \le X \iff 0 \le X \le 1$. Should be straightforward to continue from there.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "probability, probability distributions, random variables" }
How to Translate Nested If/AND Statements into MIPS? As part of a class project I'm working on, a debug feature must be included. I'm having trouble with some if/and statements. This is what I wrote: / _previous code to find where status matrix contains a 1_ / `beq s0, 1, _debug_mode #debug feature is ON if s0 contains 1 _debug_mode: li a0, 0 #tile flipped to say NOT revealed _else: li a0, 1 ` I'm not getting the results I'm expecting, so my thinking is that the code is written incorrectly. Any insight would be great!
This works out to the smallest C code of: if (debug) status = !status; In MIPS, this can be written (assuming s0 is debug, and a0 is status): blez s0, no_debug_mode xori a0, a0, 1 no_debug_mode: # ... Or more verbosely blez s0, no_debug_mode blez a0, set_status_high li a0, 0 j no_debug_mode set_status_high: li a0, 1 no_debug_mode: # ... The example you have posted only branches on one of the values and does not use a negation, so it will give the wrong results. Further, you don't have a jump at the end of your `_debug_mode` label, so the `_else` will _always_ execute. It has been a while since I've done MIPS. If there are branch delay slots required, those would have to be added to both of the above answers.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "assembly, mips" }
With VS-Code, I can't utilise the emmet option for Styled-component in React Using VS-code, I'm attempting to use emmet for styled-components in react. I've tried every tip on the internet, but I still can't get it. * I have tried to install extensions like **vscode-styled-components** * i have added `"emmet.includeLanguages": { "jsx": "javascriptreact, css", "javascript": "javascriptreact, css" }, in my settings.json` * for reference if we type`df` it will be added as `display:flex` but still im not getting it help me with solving this issue
You can use **vscode-styled-components** extension in VSCode. Link here. ![enter image description here]( an awesome Extension of VSCode.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "reactjs, visual studio code, styled components" }
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN When I'm clicking button I'm getting this exception.I don't know where I'm doing wrong Someone help me .my app is rejected because of this exception my code: UILabel *rememberMeLabelObj = [[UILabel alloc]initWithFrame:CGRectMake(xaxisForRememberMeLabel, yaxisForRememberMeLabel, widthForRememberMeLabel, heightForRememberMeLabel)]; rememberMeLabelObj.text = @"Remember me"; rememberMeLabelObj.font =[UIFont systemFontOfSize:14.0]; rememberMeLabelObj.textColor = [UIColor colorWithRed:0.816f green:0.592f blue:0.157f alpha:1.00f]; [self.view addSubview:rememberMeLabelObj];
I solved my issue actually I didn't gave float values because of this I got exception.I gave CGFloat and gave values as integer like 400,350,etc but I need give 400.0f .so,I got this issue .Now it was cleared
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 8, "tags": "ios, uibutton" }
Python: How to get an updated Entry text to use in a command binded to it? Consider the following code: text = Entry(); text.pack() def show(e): print text.get() text.bind('<Key>', show) Let's say I put the letters ABC in the Entry, one by one. The output would be: >>> >>> A >>> AB Note that when pressing A, it prints an empty string. When I press B, it prints A, not AB. If i don't press anything after C, it will never be shown. It seems that the Entry content is only updated after the binded command has returned, so I can't use the actual Entry value in that function. Is there any way to get an updated Entry value to use inside a binded command?
You could replace the `<Key>` event with the `<KeyRelease>` event. That should work. Here is a list of events: <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, tkinter, tkinter entry" }
How to calculate sum of multiple responses inside a loop using javascript? I have two loops as shown: for (var i = 0; i < nearPlacements.length; i++) { var meshInstances = nearPlacements[i].model.model.meshInstances; var mat; var matEach = 0; for (var i2 = 0; i2 < meshInstances.length; i2++) { mat = parseFloat(meshInstances[i2].mesh.indexBuffer[0].numIndices / 3); matEach += mat; } console.log(matEach); } console.log(matEach); outputs data as: ![enter image description here]( How to display data as a sum of all responses? Thanks
its like what you did with `matEach` variable but outside outer loop. let total = 0; for (var i = 0; i < nearPlacements.length; i++) { var meshInstances = nearPlacements[i].model.model.meshInstances; var mat; var matEach = 0; for (var i2 = 0; i2 < meshInstances.length; i2++) { mat = parseFloat(meshInstances[i2].mesh.indexBuffer[0].numIndices / 3); matEach += mat; } console.log(matEach); total += matEach; } console.log(total);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript" }
Is a substring of a CSPRN also a CSPRN? I want to generate a 4 character long CSPRN (Cryptographically Secure Psuedo Random Number) string. I know I can create an 8 character one by creating a 5 byte long random array and encoding as base32: string CSPRN = ""; System.Security.Cryptography.RandomNumberGenerator rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); byte[] tokenData = new byte[5]; rng.GetBytes(tokenData); CSPRN = Base32.ToBase32String(tokenData); //should produce a string 5bytes*1.6charsperbyte = 8 chars long. If I now take a substring of the first 4 characters of CSPRN - is it still a CSPRN? My best guess is that it is, but wondering if there is any "gotcha"s from taking a substring rather than generating a smaller number.
Yes, it is. First lets look at your first security claim. Base 32 is a 5 bit encoding, so if you generate 5 times anything, say a byte, the string you generate contains full entropy per character. Now the amount of entropy per character doesn't suddenly drop if you take it out of the string of course. So if you take 4 characters each should still contain the full entropy, giving you simply 4 characters of full of entropy _within the base 32 alphabet_.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "c#, string, random, cryptography" }
Using a foreach loop within coloumn data How Can I make it so that it only does foreach on the data and not the html columns? <div class="columns"> <div class="title">Donation Amount</div> <div class="title">Support</div> <div class="title">View Grant</div> <?php foreach ($results->result() as $grant) : ?> <div class="col1"><p>AUD $<?php echo number_format($grant->user_budget);?></p></div> <div class="col2"></div> <div class="col3"></div> </div> <div class="clear"></div> <?php endforeach ; ?>
Try this <div class="columns"> <div class="title">Donation Amount</div> <div class="title">Support</div> <div class="title">View Grant</div> <?php foreach ($results->result() as $grant) : ?> <div class="col1"><p>AUD $<?php echo number_format($grant->user_budget);?></p></div> <div class="col2"></div> <div class="col3"></div> <div class="clear"></div> <?php endforeach ; ?> </div>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "php, html, for loop, foreach" }
Does zlib allow decompressing from the middle of a file Does zlib allow decompressing from the middle of a file? What I mean is, if I call `inflate` with a stream that points to the middle of compressed data without calling `inflate` to the data preceding the middle, would it work?
Copy from the zlib FAQ (the emphasis is mine): > 28\. _Can I access data randomly in a compressed stream?_ > > **No, not without some preparation.** If when compressing you periodically use `Z_FULL_FLUSH`, carefully write all the pending data at those points, and keep an index of those locations, then you can start decompression at those points. You have to be careful to not use `Z_FULL_FLUSH` too often, since it can significantly degrade compression. Alternatively, you can scan a deflate stream once to generate an index, and then use that index for random access. See examples/zran.c.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 7, "tags": "c, zlib" }
pandas replace specific string with numeric value in a new column for all rows I have a data frame with a column `message`, and I want to create a column `media` such that if for index x, `df.ix[x][message]=="<Media omitted>"` ,then I want `df.ix[x][media] = 1` for example for the dataframe: index message 1 hello 2 <Media omitted> 3 hello 4 <Media omitted> I would get: index message media 1 hello 0 2 <Media omitted> 1 3 hello 0 4 <Media omitted> 1 I tried to do so only by using a loop, but I'm sure there is a smarter and faster way.
Try this: df['media'] = (df['message'] == '<Media omitted>').astype(int) **Explanation** * `df['message'] == '<Media omitted>'` creates a Boolean series. * `astype(int)` casts the Boolean series as integer type for display purposes.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, python 3.x, pandas, dataframe" }