INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
error: ‘for’ loop initial declarations are only allowed in C99 mode I am getting the below error, what is std=c99/std=gnu99 mode? source Code: #include <stdio.h> void funct(int[5]); int main() { int Arr[5]={1,2,3,4,5}; funct(Arr); for(int j=0;j<5;j++) printf("%d",Arr[j]); } void funct(int p[5]) { int i,j; for(i=6,j=0;i<11;i++,j++) p[j]=i; } Error Message: hello.c: In function ‘main’: hello.c:11:2: error: ‘for’ loop initial declarations are only allowed in C99 mode for(int j=0;j<5;j++) ^ hello.c:11:2: note: use option -std=c99 or -std=gnu99 to compile your code`
This happens because declaring variables inside a for loop wasn't valid C until C99(which is the standard of C published in 1999), you can either declare your counter outside the for as pointed out by others or use the `-std=c99` flag to tell the compiler explicitly that you're using this standard and it should interpret it as such.
stackexchange-stackoverflow
{ "answer_score": 69, "question_score": 35, "tags": "c, loops" }
What is the different between assigning a null to a valuable or not assign anything in java? What is the different between: Socket connection = null; and Socket connection; Thanks.
If it's a field (static or instance variable) then the two are broadly equivalent as `null` is the default value. (There's a subtle difference if a super-constructor calls an overridden method which sets the value, but that's a corner case.) If it's a local variable, they're very different - in the first form, the local variable is _definitely assigned_ , and the value can be read in the very next statement. In the second form, the variable _isn't_ definitely assigned, and you won't be able to read it from code until such a point where the compiler can _prove_ that a value will have been written: void foo() { String x = null; String y; System.out.println(x) // Fine, prints null System.out.println(y); // Compile-time error }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "java" }
checking probability logic in the birthday problem There are $5$ employees in the office. What is the probability of $2$ of them being born in the same month? I follow this logic. Just tell me where I am mistaken. The prior probability of one person being born in a random specific month is $\frac{1}{12}$. For two people it must be that person1 AND person2 being born in the same month is $\frac{1}{12}\times\frac{1}{12}=\frac{1}{144}$. For person1 and person3 it must still be $\frac{1}{144}$ and we must then calculate 'OR' $\frac{1}{144}+\frac{1}{144}$... Hence there are 5 people out of which we choose 2. That is $\frac{5!}{(2!\times(5-2)!}=10$. Thus, the result must be $\frac{10}{144}$ which is $6.9\%$. So where do I go wrong?
Let $p$ be the desired probability, and $q=1-p$. Then $q$ is the probability that each employee is born on a different month. How many possibilities are there for such an arrangement of birth months? We can pick $5$ out of the $12$ months in $\binom{12}{5}$ ways, and then assign them to each employee in $5!$ ways, for a total of $\binom{12}{5}\cdot5!=\frac{12!}{7!}$ scenarios. On the other hand, the total number of scenarios is $12^5$, obtained by picking one month for each of the $5$ different employees. Hence: $$q=\frac{\frac{12!}{7!}}{12^5}\simeq38.19\%$$ and the desired probability is $p=1-q\simeq61.81\%$.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "probability, statistics, discrete mathematics" }
Probability Question for two draws out of three items A bag contains $3$ red, $6$ yellow and $7$ blue balls. What is the probability that the two balls drawn are yellow and blue ?
If you do not replace the balls after they are drawn (I'm assuming this is your problem): Thinking of the balls as being distinct and imagining that we draw one ball, and then the other, there are $16\cdot15$ possible (ordered) outcomes. The number of outcomes where one ball is yellow and the other blue is $$ \underbrace{6\cdot 7}_{\text{ yellow first }}+\underbrace{7\cdot 6}_{\text{ blue first }}=84. $$ Since outcomes where we record the color of the drawn balls in order are equally likely, the probability that one ball is yellow and the other blue is $$ {\text{number of desired outcomes}\over\text {total number of outcomes}}={84\over 16\cdot 15}={ 21\over 4\cdot15}={7\over 20}. $$ If the balls are replaced after drawing, then the total number of outcomes is $16\cdot16$ and the number of outcomes in which one is yellow and the other blue is $2\cdot 7\cdot 6$. The probability that one is yellow and the other blue is ${2\cdot7\cdot6\over 16\cdot16}= {21\over64}.$
stackexchange-math
{ "answer_score": 3, "question_score": 2, "tags": "probability" }
Integrals, arc length I found this on my test today, and i didn't manage to solve it. My question is. How to find arc length of $f(x) = x^3/3$ from $x=1$ to $x=2$? If I use formula for arc length which is $\ell = \int_a^b \sqrt{1 + (f'(x))^2} \, dx$ where is $f'(x)=x^2$ I will get $\ell = \int_1^2 \sqrt{1+x^4} \, dx$ I used everything I could (know), partition and substitution, but nothing works... How to solve this definite integral? $$\ell =\int_1^2 \sqrt{1+x^4} \, dx$$
We have: $$\ell = \int_{1}^{2}x\,\sqrt{x^2+\frac{1}{x^2}}\,dx=\int_{1}^{2}x\,\sqrt{\left(x-\frac{1}{x}\right)^2+2}\,dx$$ and by replacing $x-\frac{1}{x}$ with $t$ we have: $$\ell = \frac{1}{4}\int_{0}^{3/2}\left(t+\sqrt{4+t^2}\right)^2\sqrt{\frac{2+t^2}{4+t^2}}\,dt$$ hence: $$\ell = \frac{17\sqrt{17}}{48}-\frac{\sqrt{2}}{3}+\frac{1}{2}\int_{0}^{3/2}(2+t^2)^{3/2}(4+t^2)^{-1/2}\,dt $$ but: $$\begin{eqnarray*} \frac{1}{2}\int_{0}^{3/2}(2+t^2)^{3/2}(4+t^2)^{-1/2}\,dt &=& \frac{1}{4}\int_{0}^{9/4}(2+t)^{3/2}(t(4+t))^{-1/2}\,dt\\\&=&\sqrt{2}\int_{0}^{9/8}(1+t)^{3/2}((t+1)^2-1)^{-1/2}\\\ &=& \frac{1}{4}\int_{0}^{9/4}(2+t)^{3/2}(t(4+t))^{-1/2}\,dt\\\&=&\sqrt{2}\int_{1}^{17/8}t^{3/2}(t^2-1)^{-1/2}\,dt\end{eqnarray*}$$ that can be written as an incomplete beta function if we replace $t$ with $\frac{1}{u}$.
stackexchange-math
{ "answer_score": 1, "question_score": 3, "tags": "real analysis, integration, derivatives, definite integrals" }
16.10 - Ignoring update files When I run `sudo apt-get update`, this is what shows up: hit1,hi2,3.. blah blah blah then this N: Ignoring file '20auto-upgrades.ucf-dist' in directory '/etc/apt/apt.conf.d/' as it has an invalid filename extension Need help as soon as possible This is happening to me after I upgraded to Ubuntu 16.10 from 16.04!
This is not a severe problem. It simply says that the file in `/etc/apt/apt.conf.d/20auto-upgrades.ucf-dist` is ignored because of invalid file extension. Remove the extension and it should be all OK. sudo mv /etc/apt/apt.conf.d/20auto-upgrades.ucf-dist /etc/apt/apt.conf.d/20auto-upgrades is the command you'll run to rename it. In my 16.04, the content of the file is some configuration options related to `apt` that control whether or not automatic package update will run and automatic cleaning of packages will occur. Here is the content of it APT::Periodic::Update-Package-Lists "0"; APT::Periodic::Download-Upgradeable-Packages "0"; APT::Periodic::AutocleanInterval "0"; APT::Periodic::Unattended-Upgrade "0";
stackexchange-askubuntu
{ "answer_score": 11, "question_score": 7, "tags": "upgrade, updates, update manager" }
How to show a label message, then hide it after some seconds? I would like to show a message on my ASP.Net page like "Record saved" on save button click. After 5 seconds, I would like to hide it. How can I do in JavaScript? Can I avoid to add jQuery (I'm not using it)?
You could use the `setTimeout` function which allows you to defer the execution of a callback in the future. So you could place the following in the page: <script type="text/javascript"> window.setTimeout(function() { // This will execute 5 seconds later var label = document.getElementById('IdOfTheElementYouWantToHide'); if (label != null) { label.style.display = 'none'; } }, 5000); </script> Due to ID name mangling with ASP.NET you could use a class selector. And once you start doing this and your users start to ask you about adding some fade out effects you will quickly realize that a framework such as jQuery might come in handy.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 2, "tags": "javascript, asp.net" }
ImageResizer S3Reader vs. RemoteReader As you can connect your S3 bucket to a simple domain like images.yourdomain.com, what is the advantage in using the S3Reader rather than simply using the RemoteReader? I know that RemoteReader will open and resample all images for security reasons, but thats no problem. Could I even switch between cloud providers by simply setting the nameserver to another destination?
_You can use RemoteReader to connect to any public HTTP-accessible datastore, including Amazon S3._ **However, S3Reader offers many benefits** * Less error-prone whitelisting. Validate by bucket name instead of managing the permutations for each S3 region and address method. * Optional file invalidation (RemoteReader cannot invalidate if a resource changes) * Optional SSL encryption * Optional IAM authentication so you can hide the source files, while serving resized versions.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "image resizing, imageresizer" }
Scientific American was once a great journal > Richard Dawkins comments on an Scientific American article titled "Denial of Evolution Is a Form of White Supremacy" with "Scientific American was once a great journal." Source: Twitter What does "Scientific American was once a great journal" mean? It seems to me to mean "Scientific American was once a great journal, but now it has degradated." I am not sure it is what Dawkins means here. What does it mean?
Yes, that is the implication. To paraphrase: > Scientific American used to be a great journal. This implies "it is not a great journal anymore". I won't attempt to analyse _why_ Dawkins believes this.
stackexchange-ell
{ "answer_score": 4, "question_score": 0, "tags": "phrase meaning" }
Why netlogo gives me error with set [] of x i have a question that i cant find answer anywhere , i have my code like this: exemple-own[energy] ask exemple[ let me one-of exemple-on patch-ahead 1 set [energy] of me [energy] of me + energy ] "This isn't something you can use set on" am i use set right?
You can only change the value of an agent's attribute from the perspective of that agent and you change perspectives with an `ask`. I think you want this: exemple-own[energy] ask exemple [ let me one-of exemple-on patch-ahead 1 ask me [ set energy energy + [energy] of myself ] ] The keyword `myself` refers to the asker.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "netlogo" }
How do I add a version name to the front of a dynamic image asset in rails I have a rails 4 app. I am uploading assets using Carrierwave and it allows me to save resized versions as well as the original. If I upload 'myimage.jpg' it will also save 'xs_myimage.jpg' to AWS S3. The problem is, the xs version name isn't stored anywhere, so I don't know how to serve that image. This is my image call in the view: <%= image_tag (@portfolio.img) %> Some how I'd like to call the xs_myimage.jp: <%= image_tag 'xs_'(@portfolio.img)%> #I know this doesn't work, its just what I've tried
`Carrierwave` will automatically generate an URL helper for every version of the asset you declare. Consider this: class MyUploader < CarrierWave::Uploader::Base version :xs do # ... end end You can then use the generated helper: uploader = MyUploader.new # or get the instance out of your model (@portfolio.img) uploader.xs.url
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby on rails, image, ruby on rails 4, carrierwave" }
select group , count zeros I have a table `users` like this: id user refid 1 a null 2 b 1 3 c 1 4 d 2 5 f 3 I need to select the users, grouping by id and the count number of each refid for each user For example, id user count 1 a 2 2 b 1 3 c 1 4 d 0 5 4 0 This is what I have tried: SELECT u1 . id,u1 . user , count( u1.id ) count FROM users u1 LEFT JOIN users u2 ON u1.id = u2.refid GROUP BY u1.id which returns id user count 1 a 2 2 b 1 3 c 1 How can i have mysql return both those whose id has not been used as refid?
You can use `SUM(IF(...,0,1))` to count only rows with a certain property. I think the following should work, although I am not sure, why the last two rows are missing in your output. SELECT u1.id, u1.user, SUM(IF(u2.id IS NULL,0,1)) count FROM users u1 LEFT JOIN users u2 ON u1.id=u2.refid GROUP BY u1.id
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "mysql, sql, group by" }
Percentage for two CGRect comparaison How can i get percentage for comparaison for two rects? Examples: if r1(0, 0, 150, 150) r2(0, 0, 150, 150) so receive 100%. if r1(0, 0, 150, 150) r2(75, 0, 150, 150) so receive 50%. I need some function that receive two rectangles and return percentage how much there are similar.. I need the percentage of the overlapping area of the two rectangles Thanks for your help :-)
Try This; var r1:CGRect = CGRect(x: 0, y: 0, width: 150, height: 150); var r2:CGRect = CGRect(x: 75, y: 0, width: 150, height: 150); //-- var per = rectIntersectionInPerc(r1, r2: r2); NSLog("per : \(per)) %"); - //Width and Height of both rects may be different func rectIntersectionInPerc(r1:CGRect, r2:CGRect) -> CGFloat { if (r1.intersects(r2)) { //let interRect:CGRect = r1.rectByIntersecting(r2); //OLD let interRect:CGRect = r1.intersection(r2); return ((interRect.width * interRect.height) / (((r1.width * r1.height) + (r2.width * r2.height))/2.0) * 100.0) } return 0; }
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 1, "tags": "ios, comparison, percentage, cgrect" }
Change ownership when owned have space in name? I run into a very stupid problem, trying to migrate files into new xampp server and having hard time until i realised: The installation from package created username with space in it. So now i have username "mysql -" and group "mysql" which control databases and i need to change ownership on 30 database and more than 300 tables in that folder, but the only way i know is manually change one by one folder of database. How can i bulk change ownership of all folders and files via terminal or somehow if user have space in name?
2 options come to mind: * Escape the space: `mysql\ -` * Use MySQL Workbench/administrator But I would advice to change the user to one without a space in it.
stackexchange-askubuntu
{ "answer_score": 0, "question_score": 1, "tags": "database, chown, ownership" }
jQuery: return string as html I have a "Label" control on my form which is being populated via jquery. My problem however, is I need to return my string with html tags, but my label doesn't seem to recognize html. Here's my control: <label id="comment"></label> And here's how I'm working with it in javascript: var comment; comment = $("#comment"); comment.text("<b>Please scan an <br/>item!</b>"); In the above code, the html in my string is ignored. Is there any way I can get my form to recognize the returned html tags? Thanks
Use the html function : comment.html("<b>Please scan an <br/>item!</b>");
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "javascript, jquery" }
What does "nilpotent" in a "nilpotent group" mean? It seems to have nothing to do with the usual nilpotency, i.e. $\exists n\in \mathbb{N}:x^n=0$. Actually I think the latter only makes sense in a ring or more rich structure. I tried to relate some examples, but examples like Heisenberg group or unitriangular matrices is in no way nilpotent in $M_n(R)$. Another guess would be to think of the central series as some kind of power of the group. I don't know whether this is right. So where does the terminology come from?
Nilpotent groups (of class $n$) yield the equality $[\ldots[[x_0,\;x_1],\;x_2],\;\ldots,\;x_n]=1$; nilpotent rings yield the equality $x_0x_1\ldots x_n=0$.
stackexchange-math
{ "answer_score": 2, "question_score": 3, "tags": "group theory, terminology" }
SQL query not working as expected I am using the standard ASP.NET Membership table structure in SQL Server and was doing a bit of manually querying in Management studio and ran this query SELECT * FROM [aspnet_Users] WHERE UserId = '2ac5dd56-2630-406a-9fb8-d4445bc781da&cID=49' Notice the &cID=49 at the end - I copied this from a querystring and forgot to remove that part. However, to my surprise it returned the data correctly (there is a user with the ID 2ac5dd56-2630-406a-9fb8-d4445bc781da) - any idea why this works? To my mind it should not match or probably more likely throw an error as it shouldn't be able to convert to a Guid?
The `uniqueidentifier` type is considered a character type for the purposes of conversion from a character expression, and therefore is subject to the truncation rules for converting to a character type. That is, when character expressions are converted to a character data type of a different size, **values that are too long for the new data type are truncated**. Because the uniqueidentifier type **is limited to 36 characters** , the characters that exceed that length are truncated. Note that above is quoted from MSDN
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 6, "tags": "asp.net, sql server" }
Show bootstrap navbar after scroll past initial screen I have an initial screen with a signup form and I want a navbar with a signup link to only appear after scrolling past the signup form. Is there a way to do this with jquery?
I wrote this jquery to add the class 'snap' to a navigation bar when you scrolled past the top of the container (#container) containing the nav bar. In this case, my 'snap' class gives my navigation a fixed position (relative to the body) so it'll stick to the top of the screen. If you use this code, you can change #container for the id of the block that comes after your sign up form. What I would do next is hide your navbar _maybe {top:-200px;}?_ by default and then add a class to it ('snap' - or whatever is semantically meaningful for you) to make it appear _{top:0;}_. $(window).scroll(function(scroll) { var navStart = $('#container').offset().top; var scroll = $(window).scrollTop(); if (scroll > navStart) { $('nav').addClass('snap'); } else { $('nav').removeClass('snap'); } });
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "jquery, html, css, twitter bootstrap, navbar" }
Do I need ubuntu-desktop if I'm using i3? I've found that I like using i3-wm manager and now I never use GNOME, which is the base distro I have installed. I'm wondering if I want to do a fresh install and I know I want to use a tiling window manager, if I install Ubuntu-Server instead of Ubuntu-Desktop and then install i3 will I be missing a lot of components needed for using GUI applications?
You don't need a desktop package to run GUI applications. Try to do the Ubuntu Server install with all the things you need. The dependencies will be loaded automatically. If that doesn't fit your needs, revert.
stackexchange-askubuntu
{ "answer_score": 4, "question_score": 4, "tags": "i3 wm, distro recommendation, tiling" }
Android Studio gradle-###-bin.zip vs. gradle-###-all.zip One developer on my team has some setting in Android Studio that replaces the `distributionUrl` entry in `gradle/wrapper/gradle-wrapper.properties` to use the `gradle-###-all.zip`, while my Android Studio changes it back to `gradle-###-bin.zip`. Basically, my diff always looks like: `-distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip ` This is annoying. What setting is it, and how do I change it?
`gradle-1.12-all.zip` file will have binaries, sources, and documentation. `gradle-1.12-bin.zip` will have only binaries(That should be enough as you don't need any samples/docs) If you want to know about gradle wrapper, please check this <
stackexchange-stackoverflow
{ "answer_score": 72, "question_score": 70, "tags": "android, android studio, android gradle plugin" }
Java: why does WeakHashMap implement Map whereas it is already implemented by AbstractMap? > **Possible Duplicate:** > Java.util.HashMap — why HashMap extends AbstractMap and implement Map? > Why would both a parent and child class implement the same interface? **WeakHashMap <K,V>** is declared to both extend **AbstractMap <K,V>** and implement **Map <K,V>**. But **AbstractMap <K,V>** already implements **Map <K,V>**. It looks like the `implements` declaration is redundant. What is the reason it was declared?
Barring someone being able to point to a reason posted online somewhere by the authors of `WeakHashMap` in the JDK, we can only speculate. The speculation is that it improves the auto-generated documentation. It has no effect on the interfaces exposed by the class or how you use it.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "java, collections, weakhashmap" }
TestFlight External Beta Tester Invitation Dexterity When I use TestFlight to invite external testers to test my binary, although my external testers are divided into groups, it seems that Test Flight only allows a None or All External Testers Invitation scheme ? This means that I either have to invite all external testers to test my binary, or none. Is it possible to invite external testers to test a binary selectively by group, with TestFlight ? Any help will be appreciated.
If you have already had a previous Beta then you are right the option after approval is to invite all the previous testers. The way round this is to edit the testers on the build and remove them all. Then you can invite "existing testers" again for the new Beta.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "ios, testflight" }
wordpress(woocomerce) how to add button to header I am using theme named storefront on wordpress(woocommrece) and I need to add simple button to header. I tried adding it in code (didn't work well), but only in header.php because I couldn't found hooks.
Find header.php of that theme then try find class _header-menu-signup header-menu-button wccom-component-button_ That class should contain header button by default so you can modify it by your needs. Best of luck.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wordpress, woocommerce, header, wordpress theming" }
Changing a Column type in my Android App's Database I have an app published in the play store. The app uses a database which holds a table which has a column of type int. I'm doing a new change where I need to change the column type to long. How do I go about handling it in the DatabaseHandler I'v created. I want to preserve the data stored in the older apps database, so what should ideally be the code in the onUpgrade() function???
You don't need to change the database column type. An `INTEGER` column will happily contain all the bits needed to represent a Java `long`. In fact, there's no `long` column type in sqlite.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "android, sqlite, upgrade" }
Union in c# with StructLayout I have multiple structs that all starts with a header struct. Like this public struct BaseProtocol { public Header header; public Footer footer; }; The header is public struct Header { public Byte start; public Byte group; public Byte dest; public Byte source; public Byte code; public Byte status; }; The problem now is that I need to union them with a Byte[]. I tried it with this [StructLayout( LayoutKind.Explicit, Size=255 )] public struct RecBuffer { [FieldOffset( 0 )] public Header header; [FieldOffset( 0 )] [MarshalAs( UnmanagedType.ByValArray, ArraySubType = UnmanagedType.I1, SizeConst = 255 )] public Byte[] buffer; }; When I fill the buffer with data I can't get the data from the header. How can I make c# do the same as I can do with union in c++?
Byte[] is a reference type field, which you cannot overlay with a value type field. You need a fixed size buffer and you need to compile it with `/unsafe`. Like this: [StructLayout(LayoutKind.Explicit, Size = 255)] public unsafe struct RecBuffer { [FieldOffset(0)] public long header; [FieldOffset(0)] [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.I1, SizeConst = 255)] public fixed Byte buffer[255]; };
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 3, "tags": "c#, union, structlayout" }
Can Ubuntu hard drives be swapped I have Ubuntu 19.10 installed on an SSD on a Thinkpad T430. Can I just pop it out and put it in my new T470, or do I need to do a complete new install on a separate drive for the T470? In general, are hard drives with only Ubuntu on them interchangeable to and from heterogeneous machines?
> I have Ubuntu 19.10 installed on an SSD on a Thinkpad T430. Can I just pop it out and put it in my new T470, Yes. With 1 comment: remove all 3rd party drivers. The 2 important 3rd party components are the display driver and the NIC driver. If the display in both is the same you can keep the display driver but it is better to re-install it. Same for the NIC: if the NIC is the same or in the same chipset range it is likely to work. > or do I need to do a complete new install on a separate drive for the T470? In general, are hard drives with only Ubuntu on them interchangeable to and from heterogeneous machines? No an yes. Linux/Ubuntu recreates the devices on every boot so it will notice the changes and adjust accordingly.
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 0, "tags": "system installation, hard drive, swap" }
MSN Messenger all of a sudden refuses to connect The clients in my domain could always connect to MSN-Messenger. This week, al of a sudden connection fails with error code 80072ee7. Troubleshooting learns that there is a problem with the "Keyports". All other internet activity is working. The server is set up with two LAN-adapters: one is connected to the internet, the other connects to the clients. If I bypass the server, the clients can again connect to msn messenger, but I do not want to reconfigure my network to that effect. So the server is blocking the msn messenger communication without any (conscious) intervention from me, the self professed system manager. The server runs Windows server 2003 Sp2. How can I troubleshoot this? Thanks!
It proved to be a DNS issue after all. Normally the clients are configured to request their DNS settings from the server. The server only supplies its own IP address for this. After manually setting the primary DNS to the server and the secondary DNS to an outside DNS server everything works as it should. But: How can I configure the server to supply the outside DNS to the clients? How can the problem have originated? It can only have happened after an automatic reboot after an update as I have not reconfigured the server in months.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 1, "tags": "windows server 2003" }
Is there a way to change folder for iCloud Drive? The icloud drive is in /users/username/icloud I want to change that to another folder. How do I do so? I can do that in dropbox and onedrive.
I'll assume this is about iCloudDrive for Windows (you don't mention that explicitly in your question). If that's the case, follow these steps: 1. Disable iCloud Drive from the Control Panel (please really do this, otherwise it will mess things up) 2. **Move** (not copy) your iCloudDrive directory (`C:\Users\<username>\iCloudDrive`) to the new location. 3. Open a command prompt and type: `mklink /J "C:\Users\<username>\iCloudDrive" "<new destination>"` This creates a junction (sort of a shortcut, but more powerfull) from the old location to the new location. 4. Reboot your computer and everything should be fine
stackexchange-superuser
{ "answer_score": 15, "question_score": 12, "tags": "icloud" }
PCB Board disappeared in Altium after redefine shape I tried to change my board size and potentially misclicked as I was redrawing the board. Is there a way to get the board back? I redefined the shape again and it shows up in 2D view but is missing in 3D view as you can see in the 2nd picture linked. (Undo did nothing to bring the board back) ![PCB before redefining shape]( ![PCB after redefining shape](
For me I had to go to board view using the 1 key, and the go to the properties of the board and rename the board region. In my case, I changed the name from "Layer Stack Region 1" to "Layer Stack Region".
stackexchange-electronics
{ "answer_score": 6, "question_score": 1, "tags": "pcb, altium" }
Changing textbox backcolor Conditionally I have a few textboxes in an aspx page. i would like to change the textbox color to yellow if they are enabled. I can do it individually for each textbox. But is there a way where I can get all the textbox collection of a page and check their enabled property and assign the backcolor?
Using JQuery Assuming they share a common class "textboxes" if (($(".textboxes").attr("enabled")){ $(".textboxes").css("background-color","green")} else{ $(".textboxes").css("background-color","red")} } or for earlier javascripts if (($(".textboxes").prop("enabled")){ $(".textboxes").css("background-color","green")} else{ $(".textboxes").css("background-color","red")} }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, asp.net" }
remove a list of string from a column of list of strings Its hard to describe the problem, but now I have a dataframe with a tokenized string, and I want to remove the most common words from it. So I got the list with the most common words and got the tail. But I don't know how to use this list to remove the words from the main column: The column is like that: > df['tokenized'] > > > {'dog', 'cat' , 'fish'} > > {'car', 'dog', 'water'} > > {'blue', 'red', 'green'} > Each row is a list of strings if the list of words I want to remove is {'dog', 'cat'} The desired output is: > df['tokenized'] > > {'fish'} > > {'car', 'water'} > > {'blue', 'red', 'green'} Any help with that?
Try with this: mcw = {'dog', 'cat'} df['tokenized'] = df['tokenized'].apply( lambda lst: [word for word in lst if word not in mcw] ) You should use a **set** for most common words, not a list (because it's much faster to check if an element belongs to a set).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "python" }
iso - Loading a local php file UIWebView and adding information I have a properly coded HTML page that I can display in my app. The file is embedded locally inside the app, but it pulls in data from an API. It is a Rest API that works with PHP. So my question now is - is it possible to have NSString inject it's value into the php file so that it can display the required result, or are PHP and Objective-c not designed to do that??
If you are looking to actually parse and execute PHP in your iOS app, I am afraid you are probably out of luck. If you simply want to dynamically update certain elements on a static HTML page and leverage a PHP service to do it, your best bet is probably to use javascript and AJAX to put the dynamic content from the service. Alternatively, you can treat the HTML file like a template, make a call to the PHP service to get the dynamic content; merge that content into the template and display the template. I guess what is most appropriate in your case, will ultimately depend on your desired user experience.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, ios, nsstring, code injection" }
Why after wrapping function that return object in useMemo I get warning about non function? I have this function and pass it to component but after useMemo wrapper it says me that modalComponentsData is not function const modalComponentsData = useMemo(() => { return [ { name: 'name', placeholder: 'Company name' }, ] }, [])
`useMemo` calls the function it gets to produce the value. You need `useCallback`. const modalComponentsData = useCallback(() => { return [ { name: 'name', placeholder: 'Company name' }, ] }, []) Or const modalComponentsData = useMemo(() => () => { return [ { name: 'name', placeholder: 'Company name' }, ] }, [])
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "reactjs" }
ERROR: current transaction is aborted, commands ignored until end of transaction block --- export data from Aqua studio I am trying to export one table from Aquastudio into CSV file. The table has approximately 4.4 million rows. When I am trying to use the export window function in the aqua studio, I am facing the following error: > Error: ERROR: current transaction is aborted, commands ignored until end of transaction block I am not understanding what the problem is. I read few articles regarding this error and found that this is happening due to some error in the last postgreSQL command. I did not use any SQL commands for this export and I dont know how to debug this. I am also unable to view the log files.
You probably shouldn't be exporting millions of rows through a JDBC/ODBC connection, especially for Redshift. For Redshift, please use the `UNLOAD` command documented here. You'll have to `UNLOAD` the file to S3 and download it from there. For Postgres, use `COPY TO` as documented here.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 4, "tags": "postgresql, amazon redshift, postgresql 9.1, postgresql 9.3, postgresql 9.2" }
Why is $\triangledown_x x^TA^TAx = 2A^TAx$ not $2x^TA^TA$? A proof I'm looking at shows $\triangledown_x x^TA^TAx = 2A^TAx$. I did Matlab symbolic calculation to verify this, but I found the converse. It should be $2x^TA^TA$. $\frac{d}{dx}x^TA^TAx = \\\ [ 2x_1A_{1,1}^2 + 2A_{1,2}x_2A_{1,1} + 2x_1A_{2,1}^2 + 2A_{2,2}x_2A_{2,1},\\\ 2x_2A_{1,2}^2 + 2A_{1,1}x_1A_{1,2} + 2x_2A_{2,2}^2 + 2A_{2,1}x_1A_{2,2}]$ I ran jacobian(x'*A' _A_ x, x) for this one. $2x^TA^TA=\\\ [ 2x_1A_{1,1}^2 + 2A_{1,2}x_2A_{1,1} + 2x_1A_{2,1}^2 + 2A_{2,2}x_2A_{2,1}, \\\2x_2A_{1,2}^2 + 2A_{1,1}x_1A_{1,2} + 2x_2A_{2,2}^2 + 2A_{2,1}x_1A_{2,2}]$ $2A^TAx = \\\ [ 2x_1A_{1,1}^2 + 2A_{1,2}x_2A_{1,1} + 2x_1A_{2,1}^2 + 2A_{2,2}x_2A_{2,1};\\\ 2x_2A_{1,2}^2 + 2A_{1,1}x_1A_{1,2} + 2x_2A_{2,2}^2 + 2A_{2,1}x_1A_{2,2}$ Am I missing something here?
If I do graident(x'*A'Ax, x), then I get $2A^TAx$, so the original proof is correct.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "matrix calculus" }
How do sites like facebook hide the password details when the url does not start with https? The facebook home page ( has an login form on it. It does not redirect me to the https version of the same page. I can submit the form, and it will login me in. I have turned JavaScript off (I am using Firefox), and I don't believe they are using a frame (not that I can imagine how that would help without javascript). If I was to make a page like this (without https), and I used fiddler to look at the data being posted, I would see the password information was being sent as plain text. However, when I tried the same thing with facebook, it does not show me anything at all (the text tab in fiddler is blank). I take it they have encrypted the data in some why. How are they doing this? Thanks
While the site you are viewing is not HTTPS, when you click the login button it does a post to < which is an HTTPS site, thus the data is secured when sent to the server.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "facebook, https" }
What is wrong with this mapping expression in my .vimrc? I'm trying to make Vim play nice with wrapped lines and I'm running into some problems. The following line xnoremap <expr> k ((v:count == 0) || (mode() !=# "V") ? 'gk' : 'k') gives me the following error when launching Vim Error detected while processing /cygdrive/c/Users/Chad/.vimrc: line 76: E749: empty buffer If I remove either of the conditions the map will work fine but I'd like to combine them. Any ideas? Thanks in advance.
See `:h map_bar`. The `|` is used also as a command separator in vim, so you are executing a map command: xnoremap <expr> k ((v:count == 0) Then an empty command line, and after that a command: (mode() !=# "V") ? 'gk' : 'k') To use the `|` character in mappings, the two best options in my opinion are `<Bar>` or `\|`. Your mapping can be written as xnoremap <expr> k ((v:count == 0) <Bar><Bar> (mode() !=# "V") ? 'gk' : 'k') for example.
stackexchange-vi
{ "answer_score": 7, "question_score": 6, "tags": "key bindings" }
Intercept files deleting in Android OS I need to know when a file is deleted from an android device, is it possibile? Are there some intents about the request to delete a file from device or SD?
You can register a file observer for files in some locations (though I've heard rumors this may not work for the simulated "external storage" on some recent versions). But there is no way to "intercept" as in prevent such deletion, short of modifying the installation of android. If the file is readable to your app, you could presumably make a backup copy ahead of time.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android, file, android intent" }
Opencart - load only some categories? can anybody help me? Have module. I need load only 10 categories (for example ID 2,5,10,14 etc..). Here's code: //categories $this->load->model("catalog/category"); $allCategories = $this->model_catalog_category->getCategories(array()); $categoria_shop = array(); foreach ($allCategories as $key => $value) { $categoria_shop[$value['name']] = $value['category_id']; } $categoria_shop_nezaradene = 69; how can I add ID's of categories
In the `catalog/model/catalog/category.php` file, you can see that the function `getCategories()` has an optional `parent_id` parameter and it must be an `int`, so try this: // Not tested $category_ids = array(2, 5, 10, 14); $categoria_shop = array(array()); foreach($category_ids as $category_id) { $categories = $this->model_catalog_category->getCategories($category_id); foreach ($categories as $key => $value) { $categoria_shop[][$value['name']] = $value['category_id']; } } Output example: $categoria_shop[0]['cat_name2'] = 1; $categoria_shop[1]['cat_name5'] = 2; $categoria_shop[2]['cat_name10'] = 3; $categoria_shop[3]['cat_name14'] = 4;
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "opencart, categories" }
Recalculate Normal Vector without rotation matrix I have 3 points in 3 dimensions (P0, P1, P2) and a normalised vector N1, that lies on the plane constructed by those points and is perpendicular to the line P0-P1. I want to find the normal vector N2 perpendicular to the line P0-P2, lying on the same plane and facing the same direction as N1. I think i know how to construct N2 by calculating the angle at P0, creating a rotation matrix and transforming N1 accordingly. But is it possible to construct N2 using simple operations like dot or cross product, without calculating and using the angle? sketch
Your vector $n_2$ can be expressed as $$n_2=\alpha (P_1-P_0)+\beta(P_2-P_0).$$ Solving $$ n_2\cdot(P_2-P_0) = 0,\\\ n_2\cdot n_2 = 1, $$ with condition $n_2\cdot n_1 \ge 0$, will give you $\alpha,\beta$. Alternatively, you can construct $((P_2-P_0)\times (P_1-P_0))\times(P_2-P_0)$, normalize it and invert if $n_1\cdot n_2<0$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "geometry" }
JSON like syntax vs switch statement javascript I saw a post on < where he talks about an alternative way to using switch statements. I have created a snippet below, but I'm not sure why the alternate is 99% slow. function doX(){} function doY(){} function doN(){} var something = 1; var cases = { 1: doX, 2: doY, 3: doN }; if (cases[something]) { cases[something](); } < Any idea?
The author never claimed the shorter code, which is just a hash map of the possible cases, would actually be faster. Obviously, the array creation negatively impacts the performance when you run it in a test suite. At the same time, the `switch` statement is compiled code. You will see some improvement if your code is being reused, i.e. you keep the value of `cases`; I've measured a difference of about 20-30% in this test case, depending on which case occurs more often. That said, an isolated performance test such as this won't be useful unless your code is run inside a tight loop, because the test cases run at 50M+ operations per second on my home computer. Differences between the two should therefore be based on other factors, such as code clarity or the fact that `switch` statements are easy to mess up if you forget to place `break;` a statement.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 7, "tags": "javascript, json" }
making site id increment by 1 Hey guys im trying to make a quiz and currently I have ran into an issue, I have made it increment but not send the data, so I need to fix it but don't really know how to, I need the users to be able to select an option the data get sent to the next page but the page must also increase in increment. this is what I have got <form name="form2" method="post" > <select name="answer"> <option value=$myrow['A']><?php echo $myrow['A']?></option> <option value=$myrow['B']><?php echo $myrow['B']?></option> <option value=$myrow['C']><?php echo $myrow['C']?></option> <option value=$myrow['D']><?php echo $myrow['D']?></option> <input type="submit" name="submit" value="Continue" onclick = "window.location.href = 'testttts.php?id=<?php echo $count?>'" any help would be great thank you!!
Is this what you mean? <?php if(isset($_POST['i'])) { $i = $_POST['i']; } else { $i = 0; } echo "increment: " . $i; $i++; ?> <form name="form2" method="post" > <select name="answer"> <option value=$myrow['A']><?php echo $myrow['A']?></option> <option value=$myrow['B']><?php echo $myrow['B']?></option> <option value=$myrow['C']><?php echo $myrow['C']?></option> <option value=$myrow['D']><?php echo $myrow['D']?></option> </select> <input type="hidden" name="i" value="<?php echo $i; ?>" /> <input type="submit" name="submit" value="Continue" />
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, forms, auto increment, increment" }
Batch Class add condition in the query I have a batch class where would like to add few condition in the query,how to add them.Any Suggestion please. 1)I would like to add more roles (such as EB ,TA ,RA etc where role is a picklist field) in this query . SELECT Contract__c FROM Contract_role__c WHERE Role__c = 'SA' 2)In getquerylocator i would like to add few condition such as When "Renewed" is Checked AND When "SRR" is YES AND when the "Status Renewed" is equal to "Status renewed for next quarter " or "Pipeline" AND when "Status Renewed next Year" is not equal to "Renewed" or"Renewed lost" i have the query as > return Database.getQueryLocator('Select id, Contract_Name__c , EndDate ,ownerId FROM Contract WHERE Id IN: setContractIds'); Any Suggestion please.
A typical start() method query locator would look like return Database.getQueryLocator([select contract__c, ... from Contract where role__c IN('role1','role2', ...) and renewed__c = true and srr__c = 'Yes' and status_renewed__c IN ( 'Status renewed for next quarter', 'Pipeline') and Status_Renewed_next_Year__c NOT IN ( 'Renewed','Renewed Lost'))];
stackexchange-salesforce
{ "answer_score": 0, "question_score": 0, "tags": "batch, contracts" }
What exactly does this Sphinx error-message mean? ... "[...] syntax error, unexpected ')' near '\/)|(\ [...]" When I try to query: (P \/ \-v)|(P \/)|(P)|(\/)|(\/ \-v)|(\-v) then Sphinx gives me: error -index keyword_broad: syntax error, unexpected ')' near '\/)|(\/ \-v)|(\-v)' similar problem with this query: ("^P \/ \-v$")|("^P \/$")|("^P$")|("^\/$")|("^\/ \-v$")|("^\-v$") it gives me: error -index keyword_phrase: syntax error, unexpected '$', expecting TOK_KEYWORD or TOK_INT near '\/$")|("^\/ \-v$")|("^\-v$")' Any ideas what the problem is? Cause to me those queries seem just fine.
Just a longshot, but try not escaping the forward-slashes, it's unneeded.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "regex, sphinx" }
How to do exact word parsing with ANTLR4? I have the following grammar grammar test; expression : SALUTATION NAME; SALUTATION:'Hello'; NAME: ('a'..'z'|'A'..'Z')+; If I have an input string like 1. Hello John 2. Hello John. 3. Hello John Smith All these strings will be parsed correctly by that grammar How to modify the grammar to make it parse only strings with the exact defined grammar as in example 1 and fail in other cases like example 2 and 3?
Pretty simple: expression : SALUTATION NAME EOF; Adding `EOF` will force the parser to try to match the `EOF` (end of file) token that's automatically inserted at the end of the token stream. so it'll fail if you have additional data at the end. You could also add the following lexer rule at the very end of the file: UNKNOWN_CHAR: . ; This will ensure the lexer always succeeds, and all errors will occur in the parser.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, parsing, antlr, antlr4" }
Сделать текст бегущей строкой при наведении Есть менюшка. `table-cell`. Состоит из 8 пунктов. По размеру все одинаковые `width: calc(100% / 8);`. В последнем пункте меню, не 1 слово как во всех,а 2. И по этому текст переходит на вторую строку, и под другими пунктами создается пустое пространство.По этому думаю сделать последнему пункту меню `overflow: hidden`. А при наведении, что б текст двигался как бегущая строка. Как это можно сделать? или есть еще какое то решение?
**Вроде бы так** * { margin: 0; padding: 0; text-decoration: none; list-style: none; } li { width: 100px; height: 22px; line-height: 22px; margin: 5px 20px; overflow: hidden; } li a { display: inline-block; width: 350px; } li:hover a { animation: trey 5s infinite; } @keyframes trey { 100%{ margin-left: -300%; } } <ul> <li> <a href="">Длинное меню из четырёх слов</a> </li> <li> <a href="">Очень длинное меню которое длинее предыдущего</a> </li> </ul>
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, html, jquery, css" }
Group by in MySQL I have a table of the following structure: ID | COMPANY_ID | VERSION | TEXT --------------------------------- 1 | 1 | 1 | hello 2 | 1 | 2 | world 3 | 2 | 1 | foo is there a way to get the most recent version of records only, i.e. I would want to have as a result set the IDs 2 and 3?
I'm sure there are better ways, but I tend to use this kind of query: SELECT * FROM (SELECT * FROM test ORDER BY VERSION DESC) AS my_table GROUP BY COMPANY_ID Produces this result set: ID | COMPANY_ID | VERSION | TEXT --------------------------------- 2 | 1 | 2 | world 3 | 2 | 1 | foo
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "mysql, group by" }
Program to view webcam on login/lock screen? Is there a program to show the (built-in) camera on the login or lock screen of Windows 7? It doesn't need to do anything else, no face detection, just be able to view the camera. Requirements: * runs on Windows 7 64 bit * <£10 or preferably free * uses the built in webcam * video is as big as possible (preferably full-screen) If possible, open source, but not necessarily :)
I could recommend two applications which fits with your requirements really close but unfortunately these both the software's does this whole face detection part :( * Freeware application LemonScreen it adds face recognition to your Windows login screen, allowing you to login to your locked PC by simply sitting down in front of your computer,for any additional features that you want you need to obtain the licence * Freeware application BananaScreen adds face recognition login to your webcam-enabled Windows computer,used as a Security software that allows users to unlock their computer via facial recognition.
stackexchange-softwarerecs
{ "answer_score": 2, "question_score": 5, "tags": "windows 7, webcam, lockscreen" }
what is difference between returning return from inside loop and outside loop? Actually, I am a newbie in python. I have doubt in return in for loop section. -> if i return inside loop output is 1 for (for string "abcd"). -> if I return with the same indentation that for is using in code, the output will 4. Can you please explain this happening? I have added my problem briefly using the comment in code also. def print_each_letter(word): counter = 0 for letter in word: counter += 1 return counter #its returning length 1 why ? return counter # its returning length 4 why? print_each_letter("abcd")
Because the `return` inside the loop executes the first time the loop is executed, so this happens: counter = 0 for letter in word: #'a' counter += 1 return counter #return counter (1) and terminate function. but if you let the loop run first: counter = 0 for letter in word: #'a' counter += 1 #1 #'b' counter += 1 #2 #'c' counter += 1 #3 #'d' counter += 1 #4 return counter #return counter (4) and terminate function.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -4, "tags": "python" }
Combination of logic operators in an equation in JavaScript, can someone explain it to me? Can anyone explain how would this equation work? There're too many operators combined in this equation. url = tmpUrl && tmpUrl.indexOf("/customURL?") > -1 ? tmpUrl.substring(0, tmpUrl.indexOf("/customURL")) : tmpUrl.split("?")[0] || tmpUrl
it just translates down to this if (tmpUrl) { if (tmpUrl.indexOf("/customURL?") > -1) { url = tmpUrl.substring(0, tmpUrl.indexOf("/customURL")) } else { if (tmpUrl.split("?")[0]){ url = tmpUrl.split("?")[0] } else { url = tmpUrl } } } And there are no bitwise operators used here
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -3, "tags": "javascript" }
How to set x,y in ggplot aes with one dimension dataframe? df <- data.frame( cola = c('1',NA,'c','1','1','e','1',NA,'c','d'), colb = c("A",NA,"C","D",'a','b','c','d','c','d'), colc = c('a',NA,'c','d','a',NA,'c',NA,'c','d'),stringsAsFactors = TRUE) bad<-lapply(df, function(x) sum(is.na(x))/nrow(df)) bad<-as.data.frame(bad) I want to make bar plot to one dimension dataframe `bad`. X axis should be `cola`,`colb`,`colc`,Y axis should be `0.2`,`0.1`,`0.3`. Then I tried but failed: ggplot(bad,aes(x=colnames(bad), y=bad[1,])) + geom_bar(stat='identity') As to one dimension dataframe,how to set `aes(x=?,y=?)`?
You need to change the dimension of the dataframe library(ggplot2) ggplot(stack(bad), aes(ind, values)) + geom_bar(stat='identity') ![enter image description here]( Or if you want to go the `tidyverse` way we can use `gather` as well ggplot(tidyr::gather(bad), aes(key, value)) + geom_bar(stat='identity')
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "r, ggplot2" }
Remove the containing LI from wordpress widget I need to remove the surrounding `li` from a widget that is pulled in with wordpress eg: <li id="dp-twitter-widget-2" class="widget-container widget-twitter"> That is the one I need to remove, however it must be server side as javascript manipulates it once it is served, so i would imagine a preg_replace with PHP but I cannot intercept it.
test it $strwithoutli=preg_replace_callback("~<li(.*)>(.*)</li>~si",function($m){print_r($m);return $m[2];}," ".$str." "); for old php version function replace($m){ print_r($m); return $m[2]; } $strwithoutli=preg_replace_callback("~<li(.*)>(.*)</li>~si","replace"," ".$str." "); in wordpress widget you didn't need to do this work. you can make change on widget class this is link of class between line 546-555 you can see widget output structure with make change on this you can remove **li** from output <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, html, wordpress" }
Problem with model loading in Zend Framework I have weird problem with zend framework basics. I have simple action in IndexController: public function updateusersAction() { $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout->disableLayout(); new Application_Model_Users(); } And a model I want to create is defined in application/models/Users.php (folders generated by zf.bat). The whole body of this file is as follow: <?php class Application_Model_Users { public function __construct() { echo "test"; } } If it matters I use zf 1.10.6 on Windows 7 with xampp. Do you have any idea what could be the problem? ps. I have to make it working on Windows as the target app will have to use COM components...
Huh. Found solution in another thread: zend framework can't find Model classes? Anyway, thanks for interest everyone.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "php, zend framework, model" }
Commuting real operators It's clear that if two operators in $\mathbb{C^n}$ are commuting then they have a common eigenvector and a basis in which they are upper triangularizable (simultaneously). Of course, in $\mathbb {R^n}$ it's wrong but how we can generalize result from $\mathbb{C^n}$ to $\mathbb{R^n}$? Possible there are necessary and sufficient conditions (if we know that two operators are commuting)?
If two real matrices share a non-real eigenvector $z$ over $\mathbb C$, they also share the eigenvector $\overline{z}$ and in turn, the real-linear span of the real and imaginary parts of $z$ is a two-dimensional invariant subspace of both matrices. So, in the real case, the analogue of simultaneous triangularisation is a simultaneous _block-triangularisation_ , where each diagonal block is either $1\times1$ or $2\times2$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "linear algebra, eigenvalues eigenvectors" }
How to parse json with JSONModel with not known keys I'm using JSONModel library in my iOS project, I need to manipule an object which is made of arbitrary keys and values. I didn't find anything about this problem anywhere ... How can I manage to map unknown keys ?
Response I got on Github from sauvikatinnofied : It is not possible, as the keys are unknown to JSONModel. It will be better if you declare that metadata model as NSDictionary then assess all the values using for key in [metaDictionary allKeys] { NSLog(@"Key: %@: Value: %@", key, metaDictionary[key]); }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "ios, json, jsonmodel" }
Show Matrix relationship Say $A$ and $B$ are 2x2 matrices with integer entries in the group of matrices with determinant 1, under matrix multiplication. Let $A$ and $B$ have the same first column, show there is exists an integer n where $T=(1,1;0,1)$ such that $A=BT^n$: Case where the second columns are equal is trivial with n=0. When the second columns aren't equal, using the $B^{-1}A$ solves that case. How does this change for entries in the reals and complex?
If $A = B T^n$, you must have $T^n = B^{-1} A$. Now if $A$ and $B$ have their first column the same, let's say $$ A = \pmatrix{a & c\cr b & d\cr}, \ B = \pmatrix{a & e\cr b & f\cr} $$ where $ad-bc = af-be = 1$. Then $$B^{-1} A = \pmatrix{f & -e\cr -b & a\cr} \pmatrix{a & c\cr b & d\cr} = \pmatrix{1 & cf - de\cr 0 & 1\cr} = T^n$$ where $n = cf - de$.
stackexchange-math
{ "answer_score": 4, "question_score": 0, "tags": "matrices" }
How do I do the border-bottom trick for tabbed navigation BUT with box-shadow not border? See here for code: < I know how to do the position bottom, negative margin trick with a bottom-border to make a hovered/active "tab" z-index over it but have been unable to recreate this effect when using a box-shadow. Any ideas? I.E. I want the main navigation tabs to be on top of the box-shadow! I am essentially attempting to replicate what the Nike.com navigation does. E.g. When you hover over "Sports," then the bottom shadow is covered. Thanks in advance! !enter image description here
I found a solution I'm willing to settle for: < Scott, you were on the right track that it could be done with z-index
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "css, tabs, navigation, nav" }
Can you reverse a bash script with a series of mv commands? If I have a script rename_everything.sh which contains mv 2022-05-03.txt hike_valley.txt mv 2022-05-20.txt not_overcooked.txt mv 2022-05-22.txt return_trip.txt but am nervous to run that in the one folder with bash rename_everything.sh If I decide to do that, and then think it was a bad idea and regret it, can that .sh file be called in such a way that it will do the complete reverse of what it just did?
In general there is no command that undoes `mv 2022-05-03.txt hike_valley.txt`. At first glance `mv hike_valley.txt 2022-05-03.txt` seems to be such "undo" command. But imagine a regular file `hike_valley.txt` had existed and was _overwritten_ by the first command. The original content of it is not easily recoverable. For sure the alleged "undo" command does not recover the original content. Another case is if `hike_valley.txt` is a directory (it may be) or a symlink to a directory. In such case the first command creates or overwrites `hike_valley.txt/2022-05-03.txt`. Here an alleged "undo" is `mv hike_valley.txt/2022-05-03.txt ./` which is already different than the "undo" from above. And again it does not really undo, if overwriting happened. The same reasoning applies to each `mv` command in your script.
stackexchange-unix
{ "answer_score": 5, "question_score": 0, "tags": "mv" }
Delay before dragging in gridster I'm using gridster.net in project, and i've run into problem. I'm trying to get widgets start dragging only after a second of holding mouse after click. I'm using the next code: $(".gridster .gs-w").on('mousedown', function(e) { gridsterObj.disable(); dragTimeout = setTimeout(function() { gridsterObj.enable(); }, 500); }).bind('mouseup mouseleave', function() { clearTimeout(dragTimeout); }); but it didn't work. It seems that i have to call function of starting dragging, something like `gridsterObj.on_start_drag.call(gridsterObj, e, ui);`, but where can i get the UI object? It's used everywhere in gridster code, but i can't find where it created. It seems that it jquery UI object. How can i create it?
I've ended with the next code: $(".gridster .gs-w").on('mousedown', function(e, data) { var self = this; if (!data || !data.start) { gridsterObj.disable(); dragTimeout = setTimeout(function() { gridsterObj.enable(); $(self).trigger(e, [{ start: true }]); }, 500); } else { $(self).addClass('dragging'); } }).bind('mouseup mouseleave', function() { clearTimeout(dragTimeout); }); With that, gridster has delay 0.5 second before starting dragging.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, jquery, jquery ui, gridster" }
Can't play video on TV using cast-android-sample-master project I'm developing playing video on TV via ChromeCast device. I whitelisted my device and got APP ID from google. I replaced it in receiver.html file and res/values/strings.xml file in Android project. I ran the project, it found the chromecast. But can't play video on TV. Nothing happens on TV. I already uploaded receiver.html file into URL server that I registered when whitelisting. Here my APP_ID: `<redacted>` Should I change it to `e81e1b35&#8211;414d&#8211;4684&#8211;82a0&#8211;c762837a2101`? And put it to strings.xml file in Android project and receiver.html file. Can anyone solve it? Thanks
Huy, first, it is best if you don't share your app id with the world :-) regarding your issue, putting "-" in the app id in your strings.xml is fine. First need to make sure your device is whitelisted; can you access your chromecast device through your chrome browser by hitting ` If not then there is an issue with your whitelising; in that case, did you remember to check the box 'Send serial number to Google' when you were setting up your chromecast device?
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android, video, google cast, chromecast" }
Find the conditional expectation Let $\Omega$ be a probability space with elements: $\Omega = \\{0,1,2,3\\}$ Let $\mathbb{P}$ be a probability measure such that: $\mathbb{P}(0) = \frac{1}{6}, \mathbb{P}(1) = \frac{1}{3}, \mathbb{P}(2) = \frac{1}{4}, \mathbb{P}(3) = \frac{1}{4}$ Finally, let X and Y be two random variables defined by: $X(0) = 1, X(1) = 1, X(2) = -1, X(3) = -1$ $Y(0) = 1, Y(1) = -1, Y(2) = 1, Y(3) = -1$ Find $\mathbb{E}[Y|X]$. **Attempt At Solution** By the conditional expectation formula, we have: $\mathbb{E}[Y|X] = \sum_{\omega \in \Omega} \frac{\mathbb{E}[Y\mathbb{1}_{X= \omega}]}{P(X= \omega)}$$\mathbb{1}_{X=\omega}$ But I'm not sure how to compute this sum?
Here, $X$ takes its values in $\\{-1,+1\\}$, so the sum in your formula should be on $\omega \in\\{-1,+1\\}$ (and $\omega$ is a very bad choice of notation). Actually, the idea behind the formula is that $E[Y\mid X]=f(X)$ where $f(x) = E[Y \mid X=x]$. Since $X$ takes its values in $\\{-1,+1\\}$, you just have to compute $f(1)$ and $f(-1)$, that is: $$ f(1) = E[Y \mid X=1] =\frac{E[Y1_{X=1}]}{P(X=1)},\qquad f(-1)=\frac{E[Y1_{X=-1}]}{P(X=-1)} $$ Therefore, the correct formula is: $$ E[Y\mid X] = \frac{E[Y1_{X=1}]}{P(X=1)}1_{X=1} + \frac{E[Y1_{X=-1}]}{P(X=-1)}1_{X=-1} $$ * * * Here is a model of the computations required to get $f(1)$. I leave the rest to you. $$ P(X=1) = P(0)+P(1)=\frac{1}{6}+\frac{1}{3} = \frac{1}{2}, $$ and $$ E[Y1_{X=1}] = 1\times P(0) + (-1) \times P(1) + 0\times P(2) + 0 \times P(3) = -\frac{1}{6} $$
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "probability, conditional probability" }
Hi.I want to use same menu in different pages in xaml.how to do it? I have two pages in xaml.in first page(MainWindow.xaml),i create menu.In second page i want to use menu again. Questions: * How i do this?
1 good option would be to put the menu into a UserControl that can be used on both pages. Here is a reasonably good tutorial on this <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "wpf, xaml, wpf controls" }
What is faster? Enumeration VS For loop What is faster in objective C and iphone? self enumeration or for loop? i have 2 fragments of code to help me compare. for this example we have as a fact that array is an NSMutableArray with "x" items. Case 1: -(void)findItem:(Item*)item { Item *temp; for (int i = 0 ;i<[array count];i++) { temp = [array objectAtIndex:i]; if(item.tag == temp.tag) return; } } Case 2: -(void)findItem:(Item*)item { for(Item *temp in array) { if(item.tag == temp.tag) return; } } it is almost obvious that case2 is faster, is it?
It's called fast enumeration, for a reason. See: <
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 4, "tags": "objective c, cocoa, foundation" }
Id is lost while trying to JSON.stringify Ember model I'm trying to `JSON.stringify()` the model of a route inside the controller by using the below code. It works and it returns all model attributes, except for the actual id of the model. Can we receive the id as well? var plan = this.get('model'); var reqBody = JSON.stringify( { plan, token });
You need to pass in the `includeId` option to the toJSON method in order to get the ID in the JSON. var plan = this.get('model'); var reqBody = JSON.stringify({ plan: plan.toJSON({ includeId: true }), token }); And if you didn't know, `JSON.stringify()` will call `toJSON()` for you (which is what is happening in your case). If you want to call `JSON.stringify()` instead of `model.toJSON({})`, you can always override it: App.Plan = DS.Model.extend({ toJSON: function() { return this._super({ includeId: true }); } }); That way `JSON.stringify(plan)` will give you exactly what you want.
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 5, "tags": "javascript, ember.js, ember data" }
sed command - apply in all text (.txt) files of folder I want to apply this sed command sed '/begin 644/,$d' file1.txt > file1.txt to all files of the directory.. basically I want to keep the having the same name but deleting all lines after a certain string is found.. how can i adjust this sed command to be applied to all the text (.txt) files in the folder and keep their original names ? EDIT : I am using Mac OS X I don't know if there is some issue with the sed command... if i try to do sed -i '/begin 644/,$d' *.txt i get an error sed: 1: bad flag in substitute command : 'x' 2nd EDIT : Anu's answer works !
You can use this `find` with `sed`: find . -maxdepth 1 -name '*.txt' -exec sed -i.bak '/begin 644/,$d' {} + Or if you want to keep `begin 644`: find . -maxdepth 1 -name '*.txt' -exec sed -i.bak -n '1,/begin 644/p' {} +
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "bash, sed" }
How can I quickly know the colors used in a web image? Supposing that I have the following table, ![enter image description here]( Is there a fast method (with external tools with the web: for example **ColorZilla** , browser extension) to recognize the color in RGB (or CMYK) without to install any software? For me it is important to know because I use `LaTeX` for my important document. Which software supports the function of identifying the color used in a given image?
Make a search for Color Picker. You find several tools like this: ![enter image description here]( It's here: < If you can run legacy Photoshop, you can as well do PrntScrn to copy an image to the clipboard, then open a new image in PS, paste and check the colors with the picker.
stackexchange-graphicdesign
{ "answer_score": 4, "question_score": 3, "tags": "color, software recommendation, tools, rgb, latex" }
Why does only_if Chef::Config['solo'] also run on server? I've tried using Chef::Config['solo'] to perform an action only when run locally, such as running kitchen tests. However, when running on another host, it still installs the epel-release package, which I would not like to do. Is this a bug, or am I missing something here? # added to pass kitchen test package 'epel-release' do action :upgrade only_if Chef::Config['solo'] end
Because you mean `only_if { Chef::Config['solo'] }`. Without the `{}` it's interpreted as a command string to run. Also solo vs. not isn't specifically related to "locally", it's `chef-solo` vs `chef-client` as the original command.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "chef infra" }
uploading site files, index.html or home.html just about to upload my first site and have just been doing some research into how to do this whilst I await my package to be upgraded to include mysql databases. Quick question - do I need to name my homepage 'index.html'?, and therefore change every 'home.html' link on every page of my site to 'index.html'? I've also heard 'index.htm', what is the difference between html and htm? From what I have read, this is good practice (well, even better practice would have been to call it that from the start!) but also that you can change the default page in the htaccess file. Is this correct, and if so, is there a downside? I am not relishing the task of changing every homepage link, but if it is considered a better option, I will. Thanks
Yes you can change the default index file and even the ordering. Some options are: a) You are using server side scripting - php for example Add this into a .htaccess file DirectoryIndex index.php index.html b) You are not using any server side scrpting DirectoryIndex index.html This way you do not have to deal with default values such as home.htm or index.htm
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "javascript, php, html, mysql, .htaccess" }
NodeJS module 'request' returns some symbols instead of html I am learning Nodejs, and try to do web scraping with node.js I am using node module `request` and `cheerio` but when I request the url it returns some symbol instead of the `html` body var request = require('request'); var cheerio = require('cheerio'); request({ url:" },(err, res, body) => { if(err) throw err; else { var $ = cheerio.load(body); console.log(body); } }); output in command prompt ![enter image description here]( Can anyone please tell me What is the problem here? Thank You
The problem is that the server is sending a compressed response, even though you aren't requesting a compressed response. The easy fix is to just add `gzip: true` to your `request()` options, which will not only automatically decompress responses but will also send the appropriate `Accept-Encoding` header to the server.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 0, "tags": "javascript, node.js, npm, cheerio, requestjs" }
The way to save streaming file (video or audio or both) through database and its effective I plan to make rtsp server that provides video or audio, saved live, such as camera video data. So I'm searching how to save these data. It will be quite a lot of files, about 10 ~ 10000. Each of that file size will be around 4GB. First time, I think each of files made just files and write index data to DB. It is the best simple and easy work i think. But how about save data directly to DB??? such as using blob. I seemed it looks much more easier than first thing if i deal DB well. Of course I searched in case of MySQL, MSSQL. Most of them are negative. then **how about big database? such as hadoop or NoSQL?**
i decided only index in db! there is so much disadvantages insert video data in db.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "mysql, sql server, hadoop, streaming" }
Get the value from an object when you don't know the keys I am passed an object lets say called **myobj**. Key: last, Value: "Yellow" To get the key it is Object.keys(myobj) // = ["last"] To get the value it is myobj.last // = "Yellow" But I want to handle any key. So in pseudo code I want to combine these. myobj.Object.keys(myobj) // to return "Yellow" or whatever the incoming key of the object is.
You can use square bracket notation to access object property var myobj = { last: "yellow" }; var res = myobj[Object.keys(myobj)[0]]; document.write(res);
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript" }
AppBar in WP7.5 Panorama page I'm currently developing a Windows Phone 7.5 app with a panorama page. At the panorama page, I'm implementing an appbar to deal with several things in the app, such as displaying phone location in a Bing Map which is located in one of the panorama page items. Now, I believe I have two options, but I don't know how they would work (if they even do work...): 1. Show only appbar icons relevant to current page/item 2. If you're not at the respective page/item, redirect to the page/item when clicking the appbar icon. Would any of these actually work? Could I set an ID for each of the panorama items, and then make either 1 or 2 to work? Thanks :)
Both are possible to accomplish. For showing only the **appbar icons relevent to the page** you can use the Panorama.SelectionChanged Event: var currentPanormaItem = ((Panorama)sender).SelectedItem if(currentPanormaItem.Equals(firstPageItem)) { // Set AppBar icons for first page } else if(currentPanormaItem.Equals(secondPageItem)) { // Set AppBar icons for secondpage } If you know which panorama item is selected you can set the appbar icon accordingly. **Changing the selected item** of a Panorama can be accomplished like this: panoramaControl.DefaultItem = panoramaControl.Items[indexToSet]; Though changing the selected index of a Panorama is possible, I would advise using a Pivot control. With a Pivot control it is easier to keep track of the selected item and you get a nice animation when you programatically switch the selected page.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "windows phone 7, panorama control, appbar" }
What is the equivalent of `npm install` for `gradle`? Is there an equivalent of `npm install` for Gradle? I wanted to cache layers of my Gradle build. Normally if it was an npm project I would do this FROM node COPY package.json package-lock.json . RUN npm install # at this point the dependencies are downloaded COPY src/ src/ RUN npm run build So I am trying to do it the same way but with Gradle FROM gradle:jdk12 AS build COPY *.gradle . RUN ???? COPY src/ src/ RUN gradle build
So as I see you are insterested in caching gradle depenencies in you docker image. You can use `gradle dependencies` to list dependencies and as side effect dependenices will be downloaded (you have to have `build.gradle` file already copied to the image) : RUN gradle dependencies or with gradle wrapper : RUN ./gradlew dependencies Also to force refreshing dependencies you could use `--refresh-dependencies` : RUN gradle dependencies --refresh-dependencies
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 8, "tags": "docker, gradle" }
Backslash-single quote \' My question regarding the \'add \' backslash-single quote that being passed into the method validate, what is the use of that backslash-single code? document.writeln('<td width="12%"><INPUT name=btnAdd type=button value="Add" align="right" onclick="if(Validate(this.form,\'add\',\'<%=i%>\',\'N\'))></td>');
Welcome to Stack Overflow. Backslash tells the code that this isn't a part of qoutation, it instead is a text character. And it is known as escape character which is used to escape the code start and ending points. For example: alert("Hi, " is a double qoute"); won't work, since the qoutation of the string has been ended! Might provide an exception if environment throws one. While this one: alert("Hi, \" is a double qoute"); Won't show up any error. And you will get the written text as the alert popup. You can even see the difference in the Stack Overflow code viewer. Your code: this.form,\'add\',\'<%=i%>\',\'N\') Will be executed as: this.form, 'add', '<%=i%>, 'N' And you will get the value as needed!
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript" }
how to change CRUD "add" button name? by default the CRUD **add** button name is the same as model name. how can we change that? $tabs->addTab('Users')->add('CRUD')->setModel('Admin_User');
## If you can - first set the model caption properly Set $model->`$caption` of your model. ## If it's just the CRUD which needs to have custom button name, then Set $crud->entity_name either by extending or by specifying second parameter to add('CRUD') ## Finally if you want to change it after crud->setModel() You can access button through $crud->add_button, and use either set() or setLabel().
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "atk4" }
How to Select specific link from Database using query in Datatable i have 117 links of paging=3 like p=2 and 3 links of paging=3 like i want to select just links of p=2 through Data table in C# sql , contains and Not IN query is not working
you can use this query to get specific results i guess it will help you out select * from tablename WHERE columnName LIKE '%&p=3%'
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "sql, sql server, datatable" }
Change default locale behavior for currency formatting I am facing a strange problem. My app relies on a double conversion: > currency string -> number -> currency string Basically, the single conversions are realized through the built-in localization functions of iOS. I recently found that the app does not work properly when the user uses CHF as currency. Apparently the default for this locale is to round all currency values to the nearest 5 cents. (eg. CHF 1.28 will become CHF 1.30, and 1.21 CHF will become CHF 1.20). For a bunch of reasons it's easier for me to solve the formatting convention than solve the bug for that only locale. Do you know a way to force the conversion to use a more detailed rounding approach (eg. 0.01 instead of 0.05) for every locale? Thank you!
I found an interesting solution: currencyFormatter = [[NSNumberFormatter alloc] init]; [currencyFormatter setGeneratesDecimalNumbers:YES]; [currencyFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; // This will force the rounding behavior: [currencyFormatter setRoundingIncrement:[NSNumber numberWithFloat:0.01]];
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "ios, concurrency, nsnumberformatter" }
Count number of 1's in $\textbf{u}\textbf{v}^T$ I am seeking for an efficient algorithm to count the number of 1's in the outer product $\textbf{u}\textbf{v}^T$, where $\textbf{u}$ and $\textbf{v}$ are both binary column vectors. The dimension of $\textbf{u}$ is about 50, and the dimension of $\textbf{v}$ is about 20,000. I have a loop of about 1,000,000 iterations, in each iteration, one (and only one) element of both $\textbf{u}$ and $\textbf{v}$ are randomly chosen and are overwritten with 0 or 1 (could be the same as the old value). I would like to know something in MATLAB that could finish this task on a desktop machine (no parallel, no cluster) within 3 seconds (or 5 seconds, depend on hardware). I've tried $bsxfun()$, $gpuArray()$, and all those tricks I know of, but without luck.
If both $u,v$ are 0-1 vectors, the number of ones in $uv^T$ is the no. of ones in $u$ times the no. of ones in $v$. So, how about `sum(u)*sum(v)`? **Edit:** That doesn't mean you should really sum up $u$ and $v$ inside the loop, because even MATLAB's `sum` function is still very slow. Instead, you may keep track of count $r=$ no. of ones in $u$ and the count $c=$ no. of ones in $v$. For example, in each iteration, if the $i$-th element of $u$ is selected and it switches from 0 to 1, increment $r$ by $1$. Update $c$ in a similar manner. Now the number of ones is computed as $r\times c$ at the end of each iteration. On my 4-year old PC with the _antique MATLAB 5.3_ installed, one million iterations cost only 7 seconds.
stackexchange-math
{ "answer_score": 4, "question_score": 1, "tags": "linear algebra, matlab" }
Copying a mapping from Contract A to contract B Is there any way at the moment that I can copy a mapping from one contract to the other? mapping (address => uint256) public balanceOf; function importFrom(address _from) onlyOwner { Token s = Token(_from); balanceOf = s.balanceOf; } I want to allow this feature to enable smart contract upgrades. If this is not possible, I know that it is possible to use a delegatecall from one contract to the other; but then the problem is: how do I see the interface of the contract that is being called from the Ethereum wallet? I don't want to call directly the functions in that contract, but rather through the intermediary contract that then makes the call.
There is no 'one-liner' in Solidity to copy/duplicate an entire mapping. If you maintain a list of the keys of a mapping, it is possible to copy a _finite_ amount of values from one mapping into another. The amount of copies is finite as there is a limit on the amount of gas which can be consumed in a single block (`block.gasLimit`). Reading from and writing to contract storage costs gas. The maximum `key => value` pairs in a mapping is `2**256`. From the Ethereum Yellow Paper, a `SSET` operation costs `20,000` gas. Multiplying these gives `20000*(2**256) == 2.3e81` gas. The most recent `block.gasLimit` when writing was`6.7e6`. This is dramatically lower than `2.3e81`, which was a purposeful underestimation of the true cost. Duplicating a mapping of even a millionth (`1/1,000,000)` the maximum mapping size is an unreasonable amount of work for the EVM to do in a single transaction (or block).
stackexchange-ethereum
{ "answer_score": 6, "question_score": 4, "tags": "solidity" }
Should the primary winding of a transformer have more or less resistance to increase efficiency? I'm a bit unclear about how to think of the energy transfer in a transformer and how it would be optimized. On the one hand, if the primary winding of a transformer is more resistive than the rest of the equivalent circuit (the power source's internal resistance and any connecting wires), most of the voltage drop would be across the transformer, but on the other hand, if the resistance of the primary winding was lower than the connection to the transformer, the I^2*R losses of the primary winding would be lower. Basically my question is, assuming the entire primary side of a transformer has some given and constant resistance, would the transformer be more efficient if the primary winding had the highest possible portion of the resistance or the lowest portion of the resistance?
I think you are on the wrong track with this question. The primary winding should have ideally zero resistance but it needs an impedance to prevent it shorting out the AC power applied. So, it has inductance and, for a typical power transformer that might be in the realm of 10 henries for 50/60 Hz applications. The transformer equivalent circuit is shown below: - ![enter image description here]( With the secondary unloaded (not connected to a load) the primary impedance is due to \$X_M\$. Core losses and other resistive losses are shown as resistors. Leakage inductances are shown as \$X_P\$ and \$X_S\$.
stackexchange-electronics
{ "answer_score": 5, "question_score": 0, "tags": "power, transformer, resistance" }
iPhone/iPad - help freeing up a little memory I am having a problem with memory I cant get straightened out. What I am doing is this: I have a viewcontroller that looks similar to a book with 7 different tabs. Each time the user presses a tab, the content on the "page" changes and the background image changes to reflect the different tab selected. Each background image is 768x1024 and there is one for each of the 7 tabs. My problem is that when each tab is selected, the memory is never released for the previous image, and after 7 tabs are selected I have something like 30MB being used up for 7 different images. I have 7 different methods for each of the 7 tabs that the user presses. -(IBAction) pressedTab1 { self.tabsImageView.image = nil; //tabsImageView is the imageView I am keeping he background image in. UIImage *tempUIImage = [UIImage imageNamed:@"tab1selected.png"]; self.tabsImageView.image = tempUIImage; }
There is no leak in the code that you have posted. When you tapped all 7 tabs then your app reaches 30MB of memory. But what happens if you continue to switch among tabs? Does it continue to increase in every switch? If yes, then you definitely have leak in some other portion. If not (i.e memory is more or less 30MB constant), then this might not be a problem at all. Sometimes system don't free up things until memory is required and 30MB is acceptable. It may also cache image data. You don't need to be worried in this case. Though I have found no Apple doc stating this feature, I have faced a similar scenario. Apart from your original question, one thing is you should really avoid such big images (768x1024 pixel). This may cause huge problem, at least in low end devices.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "iphone, memory, uiimageview" }
В чём отличие выражений "про меня" и "обо мне"? Эти выражения очень похожи. "Про" и "обо" — это слова с почти что одинаковым значением, "меня" или "мне" зависит только от слов, стоящих перед ними. И мне стало интересно, в чем же разница и есть ли она вообще.
Предлогом **про** в таком контексте намекают на _конкретную_ информацию о человеке, обычно известную собеседнику и связанную, например, с _действиями_ того человека или с _ситуацией_ , в которой он оказался. При этом адресат информации может близко знать человека, о котором идёт речь. Предлог **о(бо)** в этом отношении _нейтрален_ : подразумеваемая информация может оказаться самой _общей_. > Она рассказала **про** меня маме [что её сын вчера курил]. > > Она рассказала **обо** мне родителям [какой интересный у неё бойфренд].
stackexchange-rus
{ "answer_score": 2, "question_score": 2, "tags": "выбор слов, фразеология" }
Return array keys and values I am creating some options in the functions.php file. I created a function that gets input on the front end, puts the values into a new array and returns them to the front end. I am trying to figure out how to return the values like an associative array. For example, I want to the array to return like this Array ( [dribble_id] => dribble [google_id] => google [facebook_id] => facebook [twitter_id] => twitter ) the below function returns them like so Array ( [0] => dribble [1] => google [2] => facebook [3] => twitter ) Here is the function that returns them function ritual_get_options() { $arg_list = func_get_args(); $options = array(); foreach( $arg_list as $key => $value){ $options[] = ot_get_option($value); } return $options; } Do you now how I can do this?
This is not really a Wordpress question but more PHP. To solve this problem, you need to use `$value` as your key as well plus `_id` You can do something like this $options[$value . '_id'] = ot_get_option($value); **EDIT** If you need `$key` to be the value of `id`, you can also try something like this $options[$value . '_' . $key] = ot_get_option($value); This will render something like google_0 => google google_1 => google google_2 => google
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "array" }
iOS VoIP Notification Crashing Before Launch Our iOS app integrates with Twilio and is set up to receive PushKit VoIP notifications. Occasionally and indeterminately, the app will crash before launching - preventing us from processing the push notification. This only occurs when the app has been fully force-quit. Provision violated for watchdog process-launch: <FBSProcessResourceProvision: 0x281e68880; allowance: <; FBSProcessResourceAllowance; type: scheduledTime; timeValue: 5.0s>; violated: YES> The codepath for processing the notification more or less passes it directly to Twilio, then takes the resulting CallKit structures and attempts to open CallKit. None of this codepath gets executed (or, at least logged) when this crash occurs. Where can I start to understand why the Resource Allowance is being violated?
Not sure with the abbreviation, but if it stand for FrontBoardServices, then your app seems taking to much time launching. Examine your AppDelegte. Whats is launched there that could be blocking and can it moved to a different thread? Another Pitfall: **PKRegistryDeleagte needs to be registered during the launch or quickly as possible, else you never get the Push.**
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "ios, twilio, voip, callkit, pushkit" }
Itext pdf setKeepTogether without repeating header row ![example how my result would come]( I try to use below code to make sure title and content on same page but it header will be print out on every page. table.setHeaderRows(1); table.setKeepTogether(true); Then, i try to change setHeaderRow to 0 but the result will come like the picture: table.setHeaderRows(0); table.setKeepTogether(true); How to make Title and Content on the same page but the title only on first page?
When you add rows that don't fit the current page, the default behavior is to split the table and to forward the row to the next page. This is what happens in your case: the first row fits the page, the second row doesn't. As a result, you have one row on one page, the other row on the next page. You can change this default behavior by adding this line: table.setSplitLate(false); Now iText won't forward a row in case it doesn't fit. It will split the row in two (or more) parts, and put port of it on the current page and another part on the next page(s).
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, itext" }
Can you adopt a 'specific' single property from another style? I'm pretty new to LESS and have been playing with ways to reuse properties from existing styles. Is there a way I get reuse a Single Style/Property (by name) of a known CSS Class, for example: **This Obviously merges all of .source into .target:** .source { width: 100%; display: block; color: #ff0000; } .target { height: 10px; .source; } **What if I wanted just the width property, something like this:** .source { width: 100%; display: block; color: #ff0000; } .target { height: 10px; width : .source:width; } I've been looking for a while now, and I'm doubtful its possible, but hoping someone has some suggestions. Essentially I'm hoping to not generate tons of repeated CSS for properties I don't need.
## Short Answer, Not at Present (as of version 1.7) There is no way to target just a single property for retrieval without setting up the class to allow access to it. For example, if it was worth it to you, a class could be set up like so: .source { .get(@prop) when (@prop = width), (@prop = all) {width: 100%;} .get(@prop) when (@prop = display), (@prop = all) {display: block;} .get(@prop) when (@prop = color), (@prop = all) {color: #ff0000;} .get(all); } .target { height: 10px; .source > .get(width); } This will get the output you want. But as you can see, it involves _much more coding_ than just setting the properties on the two items themselves (or setting a global variable for both to access, which would be the better way to go). I cannot think of a situation when it would be best to use the above method, but maybe someone might find this useful.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "less" }
How many square numbers are there? Let $F$ be a non-archimedean local field or a general global field. Has $F^\times / (F^\times)^2$ cardinality $2$?
For $F = \mathbb Q_2$ we have $\mathbb Q_2^\times / (\mathbb Q_2^\times)^2 \cong (\mathbb Z / 2\mathbb Z)^3$, so the cardinality is 8, not 2. A 2-adic number $x =\mathbb Q_2^\times$ can be written as $x = 2^k u$ with $k \in \mathbb Z$ and $u \in \mathbb Z_2^\times$, so $\mathbb Q_2^\times \cong \mathbb Z \times \mathbb Z_2^\times$ . One can easily show that $x$ is a square in $\mathbb Q_2^\times$ iff $k$ is even and $u \equiv 1 \pmod {2^3}$, so $(\mathbb Q_2^\times)^2 \cong 2\mathbb Z \times U^{(3)}$ where $U^{(3)} = \\{ u \in \mathbb Z_2^\times | u \equiv 1 \pmod{2^3} \\}$ is the third group of principal units. Thus $$\mathbb Q_2^\times / (\mathbb Q_2^\times)^2 \cong \mathbb Z/2\mathbb Z \times \mathbb Z_2^\times/U^{(3)} \cong (\mathbb Z/2\mathbb Z)^3.$$
stackexchange-math
{ "answer_score": 7, "question_score": 4, "tags": "number theory, algebraic number theory" }
Maildir on Debian Squeeze - Finding email boxes on /lost+found A server that I'm helping to administrate had a severe file system problem and now there's a lot of files inside the `/lost+found` directory. I'd like to find the `[email protected]`'s **received** and **sent** mail boxes. We're using Maildir email format, Postfix as MTA and Dovecot as POP3/IMAP server on a Debian Squeeze. I've already tried grep -r ".*user.*" and grep -r ".*From: \"John Doe.*" The majority of the results where files like `1412216683.V804I9e3a201M324743.example` inside directories like `Maildir10805257/new/`. Since there are many different `Maildir/new` directories, I'd like to know if there's a specific one that is the `[email protected]` mailbox and if so, if someone knows a better way to find it. Otherwise, are his remaining messages spread all around these directories?
_For received email_ , you can rely on **Delivered-To** to identify the correct recipient _as@sebix has said in above comment_.The challenge is, if the email has more than one **Delivered-To** header. So you must modify the grep to search [email protected] mailbox grep -r -m 1 '^Delivered-To:' directory/ | grep [email protected] * * * _For sent email_ , you can rely on **From** header. Again, you should limit it in first occurrence. grep -r -m 1 '^From:' directory/ | grep [email protected]
stackexchange-serverfault
{ "answer_score": 2, "question_score": 4, "tags": "postfix, dovecot, debian squeeze, maildir" }
What to put in the Type targetType parameter in IValueConverter I am calling a IValueConverter class via code behind, but I am not sure what to put in the `Type targetType` parameter. The object is `string` but using that give me 'invalid expression term 'string'` my code to call the converter secondConverter.Convert(score, string, null, CultureInfo.CurrentCulture); The converter class public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { TimeSpan ts = new TimeSpan(0, 0, (int)value); return String.Format("{0:D2}:{1:D2}:{2:D2}", ts.Hours, ts.Minutes, ts.Seconds); }
You can put `typeof(string)` instead of string, but your converter does not seem to use or validate target type, so you can put just about anything there, including null. Generally, your converter should at least validate that target type is string and throw exception if it is not.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "c#, types, windows phone 8, ivalueconverter" }
How to concatenate string when setting a parameter in Transact-SQL First question here and is the following. I wrote the following code and everything works fine: DECLARE @subject NVARCHAR(100) SET @subject = 'Report executed on ' + CONVERT(VARCHAR(12), GETDATE(), 107) SELECT @subject Result: Report executed on Aug 17, 2012 but when trying to concatenate the previous string while setting the parameter of msdb.dbo.sp_send_dbmail procedure, it fails EXEC msdb.dbo.sp_send_dbmail @profile_name='XXX', @recipients='[email protected]', @subject = 'Report executed on ' + CONVERT(VARCHAR(12), GETDATE(), 107), @body= @tableHTML, @body_format = 'HTML'; I know I could declare and send a variable to the parameter but I would like to understand why it fails when concatenating directly in the parameter. thank you for your time and knowledge
Parameter values to T-SQL stored procedures cannot be expressions. They need to be either a constant or a variable. From MSDN - Specify Parameters: > The parameter values supplied with a procedure call must be constants or a variable; a function name cannot be used as a parameter value. Variables can be user-defined or system variables such as @@spid.
stackexchange-stackoverflow
{ "answer_score": 36, "question_score": 28, "tags": "sql server, tsql" }
Implement picture password in Android app I want to secure my app using a password like on this picture: ![picture]( (source: karganys.fr) is there already a class that i can use or i must create by myself? i don't find anything about this....
Android is open source and this is a part of Android, so the code is available. See Source of Android's lock screen for a link to it.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -5, "tags": "android, security" }
PHP & .htaccess - turn example.com/index.php?a=6&b=3 into example.com/6/3? How would I do this URL change?
Try this mod_rewrite rule: RewriteEngine on RewriteCond %{QUERY_STRING} ^a=(\d+)&b=(\d+)$ RewriteRule ^index\.php$ %1/%2 This will rewrite a request of `/index.php?a=6&b=3` internally to `/6/3`. And if you rather want the other way round: RewriteEngine on RewriteRule ^(\d+)/(\d+)$ index.php?a=$1&b=$2 This will rewrite a request of `/6/3` internally to `/index.php?a=6&b=3`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "url, .htaccess" }
About Open MP and cudaSetDevice() Does anyone know if the following usage of `cudaSetDevice` is correct? I want to repeatedly call resources created on different devices at any time, in any host thread; is there a way to do this in CUDA? cudaSetDevice(0); /...create cuda streams and do some memory allocation on gpu.../ cudaSetDevice(1); /...create cuda streams and do some memory allocation on gpu.../ #pragma omp parallel num_threads(2) { int omp_threadID=omp_get_thread_num(); .... if (omp_threadID==0) { cudaSetDevice(0); /...calling streams/memory created on device 0.../ } else { cudaSetDevice(1); /...calling streams/memory created on device 1.../ }; };
Yes, something like that should work. Make sure that all things you created on device 0, you only use in OpenMP thread 0, and likewise for device 1 and thread 1. You may also want to look at the CUDA OpenMP Sample Code, which demonstrates how to use OpenMP threads to each manage an individual device.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "c++, c, cuda, openmp, nvidia" }
How to package node-js application into single rpm? I'm trying to pacakge my **node-js** application into single rpm-package. The first thing that came to mind: add `nodejs` and `npm` as package dependencies. Requires: node npm Such rpm worked perfectly on Fedora. But on CentOS rmp installation had been failed on dependency resolution step. The problem is that on CentOS nodejs and npm aren't in default package repository, but they are in EPEL repo. I had tried to add `epel-release` package to _requires_ , but it didn't help. So, what's the best option for packaging node-js applications into rpm's? Should I install it from sources instead of from repo? Or this issue with EPEL can be handled?
Add the EPEL repository to yum in order to satisfy the requirements is the easiest path, particularly if you wish to use Fedora node.js pre-built sources. You can bundle the EPEL node.js and npm from your own repository. Meanwhile double click install of *.rpm isn't easy (SuSE can do this, just Ick )
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "node.js, centos, rpm, rpm spec" }
In Moon [2009], why are there any humans at all? SPOILERS AHEAD > It's obvious that the corporation is relying more on the AI than on the clones. In a conversation they blame the AI for losing a worker and a digging machine on the same day. Considering the level of technology it should be trivial to build machines to replace the clones, remotely controlled by the powerful AI. And if something went terribly wrong with the AI, the corporation already has a protocol to send a human team. So why are there any humans at all in the lunar base?
Perhaps the point of the cloned humans is not really to assist in the mining but to test out the technology required to create them. The rapid deterioration of the clones on the base shows that this technology has not been perfected but it would be of huge use to a corporation involved in space exploration or industry. The secrecy of the operation, maintained by the communication blocking devices on the Moon, along with the uproar caused at the end of the film by the revealing of the clone's existence suggests that such research would have been extremely vigorously opposed on Earth. However, an off planet mining facility is the perfect place to carry out such unethical research since access can be easily monitored and controlled.
stackexchange-scifi
{ "answer_score": 18, "question_score": 22, "tags": "artificial intelligence, clones, moon movie" }
Why catch code of an try catch exception are not executed when System.LimitException: Too many DML statements: 151 I have the next code block that generates a limitException: Account myAccount = new Account(Name = 'MyAccount'); Insert myAccount; For (Integer x = 0; x < 150; x++) {Account newAccount = new Account (Name='MyAccountyyy' + x); try { Insert newAccount; System.debug ('inserted:'+x); } catch (Exception ex) {System.debug ('EXCEPTION:'+ex) ;} } System.debug ('Last debug log'); If you see the debug, it will show only until: "Inserted: 149", but not "EXCEPTION:System.LimitException: Too many.... etc". Why catch code block is not executed? Could someone explain me? Is not clear for me in documentation.
It's buried in the documentation a bit, but on Exception Class and Built-In Exceptions, there is this... > LimitException: A governor limit has been exceeded. This exception can’t be caught. This is also outlined near the bottom of Exceptions in Apex > ## Exceptions that Can’t be Caught > > Some special types of built-in exceptions can’t be caught. Those exceptions are associated with critical situations in the Lightning Platform. These situations require the abortion of code execution and don’t allow for execution to resume through exception handling. One such exception is the limit exception (System.LimitException) that the runtime throws if a governor limit has been exceeded, such as when the maximum number of SOQL queries issued has been exceeded. Other examples are exceptions thrown when assertion statements fail (through System.assert methods) or license exceptions. > > When exceptions are uncatchable, catch blocks, as well as finally blocks if any, aren’t executed.
stackexchange-salesforce
{ "answer_score": 3, "question_score": 0, "tags": "exception, try catch, limitexception" }
How to increase timeout for activating features through Visual Studio deployment I get the following error sometimes when deploying a SharePoint 2010 solution via Visual Studio 2010: > Error occurred in deployment step 'Activate Features': A timeout has occurred while invoking commands in SharePoint host process. It's true -- it's taking a long time because we do a lot of work in the feature receiver. But **This is not an error; I would just like Visual Studio to wait longer**. Is there a place I can configure the amount of time to wait before timing out?
ChannelOperationTimeout < Do not forget to restart Visual Studio
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 8, "tags": "visual studio 2010, deployment, sharepoint 2010" }
SQL select ids like unique tag Each id in my table has an tags column where the text are comma separated strings like Biology,Life sciences,Organisms,Biotechnology I am using this query to select all the ids that are like the tag "carbon". SELECT f.id FROM ttrss_user_entries e INNER JOIN ttrss_entries f ON f.id = e.ref_id WHERE e.tags_new LIKE '%carbon%' The problem is that because there are also tags like "carbon dioxide", there are duplicate ids. Is there a way to select ids that match _only_ the text between single quotes? The above query returns 3362 Polycyclic aromatic hydrocarbon,Nature 69984 Low-carbon economy,Renewable Energy 444573 Fluorocarbon,Magnesium 5637 Carbon,Fossil but I want it to return 5637 Carbon,Fossil
Fix your data structure! Don't store tags in a delimited string. One option in Postgres is as an array. Another is as a separate table with one row per entry and tag (the traditional approach). Here is how the array solution would look: WHERE 'carbon' = any (regexp_split_to_array(e.tags_new, ','::text) I would suggest that you change the data format so the column is an array.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sql, postgresql" }
Display new content on hover or click I would like my `<nav>` menu to display new content on the page. For example, my menu is below the center of the page which contains a big .png design. I'd like that when you click a link, it doesn't load another page, but displays new content on the page, with a basic animation. Like if clicking the link pulled the new content out of the `<nav>`. Is it possible to do this with only HTML5 and CSS ?
It will be easy enough with jQuery to hook at the click event of the navigation links. So if you have: <a id="navigationLink1" > Some Navigation Item </a> you might link a click-handler like this: $(document).ready(function() { var linkClickHandler = function() { // your code with the animation and etc }; $('#navigationLink1').hover(linkClickHandler); $('#navigationLink1').click(linkClickHandler); });
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "css, html, menu" }
Removing navigation buttons for SCO package The LMS automatically displays prev, next and close buttons. I can hide these buttons and here tells about it. But I didn't find an example of how to do. What is the approach to handle this? * * * _Edit:_ ... an other source clearly indicates the pieces to do this job. Adding these bits into manifest file; <sequencing> <controlMode choice="false" choiceExit="false" flow="true" /> </sequencing> will solve the problem. * * * I posted this as an answer but it did not go well. It seems `choice` property does it but LMS still show these. The flash content goes back and forward itself well and I just do not want to display buttons. So how can I hide nav buttons?
Try out this on a item after the title. <adlnav:presentation> <adlnav:navigationInterface> <adlnav:hideLMSUI>continue</adlnav:hideLMSUI> <adlnav:hideLMSUI>previous</adlnav:hideLMSUI> </adlnav:navigationInterface> </adlnav:presentation>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "xml, scorm, scorm2004" }