prompt
stringlengths
48
2.37k
chosen
stringlengths
7
4.28k
rejected
stringlengths
11
4.44k
Question: I would like to remove with purge all entries of locate and its database. I tried ``` apt-get purge locate ``` and ``` rm /etc/updatedb* ``` But is the database gone also? Where is the updatedb database located on debian squeeze? I would like to delete it manually too, so I can cleanly reinstall it Answer:
On debian, the locate database is stored by default in ``` /var/cache/locate/locatedb ``` If you use `mlocate` as search indexer: The mlocate database is stored at ``` /var/lib/mlocate/mlocate.db ``` see: [How can I view updatedb database content, and then exclude certain files/paths?](https://serverfault.com/questions/454051/how-can-i-view-updatedb-database-content-and-then-exclude-certain-files-paths)
[REDACTED in 2017]: See above answer: locate --statistics works. If you have an /etc/updatedb.conf, you can look in there. I don't. You can read the man page for locate, which says the default location is /var/cache/locate/locatedb. Mine isn't there. You can use locate itself to search for files named "updatedb" or "locatedb". I'm using Cygwin on Windows 7.
Question: I would like to remove with purge all entries of locate and its database. I tried ``` apt-get purge locate ``` and ``` rm /etc/updatedb* ``` But is the database gone also? Where is the updatedb database located on debian squeeze? I would like to delete it manually too, so I can cleanly reinstall it Answer:
On debian, the locate database is stored by default in ``` /var/cache/locate/locatedb ``` If you use `mlocate` as search indexer: The mlocate database is stored at ``` /var/lib/mlocate/mlocate.db ``` see: [How can I view updatedb database content, and then exclude certain files/paths?](https://serverfault.com/questions/454051/how-can-i-view-updatedb-database-content-and-then-exclude-certain-files-paths)
on mac --statistics is invalid man locate FILES /var/db/locate.database locate database
Question: I would like to remove with purge all entries of locate and its database. I tried ``` apt-get purge locate ``` and ``` rm /etc/updatedb* ``` But is the database gone also? Where is the updatedb database located on debian squeeze? I would like to delete it manually too, so I can cleanly reinstall it Answer:
No need to decompile the executable! Just kindly ask 'locate' :-) For updatedb/locate (GNU findutils) version 4.6.0 try calling ``` locate --statistics ``` For me (on cygwin) this yields someting like ``` Database /var/locatedb is in the GNU LOCATE02 format. Database was last modified at 2017:03:13 22:44:31.849172100 +0100 Locate database size: 6101081 bytes All Filenames: 202075 File names have a cumulative length of 22094021 bytes. Of those file names, 2591 contain whitespace, 0 contain newline characters, and 20 contain characters with the high bit set. Compression ratio 72.39% (higher is better) ```
I prefer to just strace the process, as it's going to lead you right there. This will be distribution agnostic and works if you don't have the man pages. ``` # strace updatedb 2>&1 |grep ^open|grep db open("/etc/updatedb.conf", O_RDONLY) = 3 open("/var/lib/mlocate/mlocate.db", O_RDWR) = 3 open("/var/lib/mlocate/mlocate.db.bUUaw4", O_RDWR|O_CREAT|O_EXCL, 0600) = 4 ```
Question: I would like to remove with purge all entries of locate and its database. I tried ``` apt-get purge locate ``` and ``` rm /etc/updatedb* ``` But is the database gone also? Where is the updatedb database located on debian squeeze? I would like to delete it manually too, so I can cleanly reinstall it Answer:
`man updatedb` search for 'FILES' mine says: ``` FILES /etc/updatedb.conf A configuration file. See updatedb.conf(5). /var/lib/mlocate/mlocate.db The database updated by default. ```
on mac --statistics is invalid man locate FILES /var/db/locate.database locate database
Question: I've built a form with Netbeans's visual editor. When I press one of the buttons it should do the following : * set it to disabled * perform a task that takes some time * when the task finishes the button will be enabled again However, the following happens: * the button remains in a pressed state until the task finishes * when the task finishes, the enabling/disabling of buttons will be very fast (they will happen, but you won't notice them) This behaviour is not something I want. I tried using repaint on the JButton, on the JFrame and even on the JPanel containing the button, but I can't seem to get it to do what I want. Some hints? Answer:
When you do things in a button callback, you are essentially stalling the gui painting thread - not just for the button, but for ANY gui painting. (Try covering the interface with another window and then exposing it again - it won't repaint until the task is finished!) What you need to do is spawn a thread to do the long running task, and then have that thread use SwingUtilities.invokeLater() to do the enabling of the button. invokeLater forces the button enable to happen in the gui painting thread. You may want to set a busy cursor or otherwise lock the interface while the long-running thread is operating.
You need to do the task that takes some time in a different thread. The reason the button is blocking is because the work is being done in the same thread that draws the button. Once the work is done the button can do the rest of what you tell it to. If you use a different thread the thread will go do the task while the drawing code can continue drawing the form.
Question: I've built a form with Netbeans's visual editor. When I press one of the buttons it should do the following : * set it to disabled * perform a task that takes some time * when the task finishes the button will be enabled again However, the following happens: * the button remains in a pressed state until the task finishes * when the task finishes, the enabling/disabling of buttons will be very fast (they will happen, but you won't notice them) This behaviour is not something I want. I tried using repaint on the JButton, on the JFrame and even on the JPanel containing the button, but I can't seem to get it to do what I want. Some hints? Answer:
When you do work in a button callback, you are stalling the GUI painting thread until it completes. What you need to do is spawn a thread to do the long running task, and then have that thread use `SwingUtilities.invokeLater()` to update the UI when it completes. Not using `invokeLater` is not thread safe, and is generally bad mojo. A basic example is: ``` button.setEnabled(false); new Thread(new Runnable() { public void run() { // Do heavy lifting here SwingUtilies.invokeLater(new Runnable() { public void run() { button.setEnabled(true); } }); } }).start(); ```
When you do things in a button callback, you are essentially stalling the gui painting thread - not just for the button, but for ANY gui painting. (Try covering the interface with another window and then exposing it again - it won't repaint until the task is finished!) What you need to do is spawn a thread to do the long running task, and then have that thread use SwingUtilities.invokeLater() to do the enabling of the button. invokeLater forces the button enable to happen in the gui painting thread. You may want to set a busy cursor or otherwise lock the interface while the long-running thread is operating.
Question: I've built a form with Netbeans's visual editor. When I press one of the buttons it should do the following : * set it to disabled * perform a task that takes some time * when the task finishes the button will be enabled again However, the following happens: * the button remains in a pressed state until the task finishes * when the task finishes, the enabling/disabling of buttons will be very fast (they will happen, but you won't notice them) This behaviour is not something I want. I tried using repaint on the JButton, on the JFrame and even on the JPanel containing the button, but I can't seem to get it to do what I want. Some hints? Answer:
When you do things in a button callback, you are essentially stalling the gui painting thread - not just for the button, but for ANY gui painting. (Try covering the interface with another window and then exposing it again - it won't repaint until the task is finished!) What you need to do is spawn a thread to do the long running task, and then have that thread use SwingUtilities.invokeLater() to do the enabling of the button. invokeLater forces the button enable to happen in the gui painting thread. You may want to set a busy cursor or otherwise lock the interface while the long-running thread is operating.
The [**Concurrency in Swing** tutorial](http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html) from Sun is well worth a read. Excellent explanation and background reading, including the event dispatching thread, using worker threads, etc
Question: I've built a form with Netbeans's visual editor. When I press one of the buttons it should do the following : * set it to disabled * perform a task that takes some time * when the task finishes the button will be enabled again However, the following happens: * the button remains in a pressed state until the task finishes * when the task finishes, the enabling/disabling of buttons will be very fast (they will happen, but you won't notice them) This behaviour is not something I want. I tried using repaint on the JButton, on the JFrame and even on the JPanel containing the button, but I can't seem to get it to do what I want. Some hints? Answer:
When you do work in a button callback, you are stalling the GUI painting thread until it completes. What you need to do is spawn a thread to do the long running task, and then have that thread use `SwingUtilities.invokeLater()` to update the UI when it completes. Not using `invokeLater` is not thread safe, and is generally bad mojo. A basic example is: ``` button.setEnabled(false); new Thread(new Runnable() { public void run() { // Do heavy lifting here SwingUtilies.invokeLater(new Runnable() { public void run() { button.setEnabled(true); } }); } }).start(); ```
You need to do the task that takes some time in a different thread. The reason the button is blocking is because the work is being done in the same thread that draws the button. Once the work is done the button can do the rest of what you tell it to. If you use a different thread the thread will go do the task while the drawing code can continue drawing the form.
Question: I've built a form with Netbeans's visual editor. When I press one of the buttons it should do the following : * set it to disabled * perform a task that takes some time * when the task finishes the button will be enabled again However, the following happens: * the button remains in a pressed state until the task finishes * when the task finishes, the enabling/disabling of buttons will be very fast (they will happen, but you won't notice them) This behaviour is not something I want. I tried using repaint on the JButton, on the JFrame and even on the JPanel containing the button, but I can't seem to get it to do what I want. Some hints? Answer:
When you do work in a button callback, you are stalling the GUI painting thread until it completes. What you need to do is spawn a thread to do the long running task, and then have that thread use `SwingUtilities.invokeLater()` to update the UI when it completes. Not using `invokeLater` is not thread safe, and is generally bad mojo. A basic example is: ``` button.setEnabled(false); new Thread(new Runnable() { public void run() { // Do heavy lifting here SwingUtilies.invokeLater(new Runnable() { public void run() { button.setEnabled(true); } }); } }).start(); ```
The [**Concurrency in Swing** tutorial](http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html) from Sun is well worth a read. Excellent explanation and background reading, including the event dispatching thread, using worker threads, etc
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
I believe what they are implying is a compliance issue. Granted ALL of you are suggesting much stronger passwords and ARE TOTALLY RIGHT. However, normal human beings don't comply. And won't comply. And if they don't and won't comply they will find a way to cheat back to something simple that breaks badly. So if it is going to break badly anyway, at least make it break badly hard and take 2 (or more times) to break badly hard before the bad guy figures out the pattern - and be simple enough people can comply. If you look at what Intel proposes, the passwords are remember-able; it takes at least 2 before a bad-guy can begin to infer a pattern (maybe they start guessing with 1); and even once they infer, they still have non-standard sequences to figure out (5 chars in one, 2 in the second, 4 in the third...) so its still some work to do. Yes the dictionary start scoping down, but work none-the-less. And you get potentially better compliance than rj3PL9$#U(BT. By my age, I would forget that daily. And yes, I use password managers, but occasionally, I don't have them with me - so I need to remember too!
Something a lot of people seem to forget. Using a huge password is better then confusing the user. eg the password: mySuperSecurePasswordKeepsMeSecuredAgainstHackersCrackersAutomatedToolsAndMoreStuff is more secure than: P@S$W0rD I can support with this numbers/math etc if required. For the downvoter: [XKCD #936: Short complex password, or long dictionary passphrase?](https://security.stackexchange.com/questions/6095/xkcd-936-short-complex-password-or-long-dictionary-passphrase/6116#6116)
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
Intel should know better - but this seems to be a recurring theme: how can we get end users, especially non-technical users, to improve aspects of their behaviour without alienating them completely. Here, and on other security communities, we already know all this stuff, and hopefully our families get some of the guidance that rubs off, but how do you get someone with no security or risk experience to understand that using their grand child's name as a password is a bad idea? It certainly helps them remember it, so that is important, right? If you want a sensible view on password strength, look at our [**blog post**](http://security.blogoverflow.com/2011/10/how-long-is-a-password-string/) on the topic, and follow all the links! Some very smart people have provided guidance - inspired by the famous xkcd cartoon.
Totally agree - using ANY predictable pattern, no matter how complex it is, would undermine the whole idea of strong passwords. I am doing it this way: - Random passwords generated in Keepass (and stored there) for 99% of the passwords - Very few passwords generated with the help of Gasser generator, i.e. passwords that are pronounceable, but still not from dictionary, for the critical websites, passwords which I do not store ANYWHERE. e.g. of generator of such passwords: <http://www.multicians.org/thvv/gpw-js.html>
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
The short answer is yes. However, human beings tend to be a creature of habit. Therefore they tend to use the same password for multiple accounts. I believe this article is trying to make it a little more palatable for those who don't want to change passwords. Just using "My 1st Password!" on every site is less secure than using "My 1st Password! FB" on one site and "My 1st Password! twitr" on another for the fact that if a hacker got your first password and added it to his dictionary he wouldn't necessary be able to break the second one. If your passwords were the same then if the hacker obtained your first password and added it to his/her dictionary and got the hash of your second password then he/she could break it easily.
Something a lot of people seem to forget. Using a huge password is better then confusing the user. eg the password: mySuperSecurePasswordKeepsMeSecuredAgainstHackersCrackersAutomatedToolsAndMoreStuff is more secure than: P@S$W0rD I can support with this numbers/math etc if required. For the downvoter: [XKCD #936: Short complex password, or long dictionary passphrase?](https://security.stackexchange.com/questions/6095/xkcd-936-short-complex-password-or-long-dictionary-passphrase/6116#6116)
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
Yes, using different passwords for different sites is a good idea. Yes, having a common theme which you use to generate your passwords is ok. With two caveats. It must not be so stupidly easy to guess as the one suggested by the Intel site. You **MUST** keep is a secret. The best solution of course is to just remember one long, highly random password which will grant you access to a password safe containing randomly generated passwords for your different accounts. Various solutions like [LastPass](https://lastpass.com/) or [KeePass](http://keepass.info/) exist and works well. See this arstechnia [article](http://arstechnica.com/security/2013/05/why-intels-how-strong-is-your-password-site-cant-be-trusted/) for a nice insight on how horrible that Intel site actually is.
Something a lot of people seem to forget. Using a huge password is better then confusing the user. eg the password: mySuperSecurePasswordKeepsMeSecuredAgainstHackersCrackersAutomatedToolsAndMoreStuff is more secure than: P@S$W0rD I can support with this numbers/math etc if required. For the downvoter: [XKCD #936: Short complex password, or long dictionary passphrase?](https://security.stackexchange.com/questions/6095/xkcd-936-short-complex-password-or-long-dictionary-passphrase/6116#6116)
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
Yes you are right. Using a pool of passwords is definitely recommended but the passwords should not follow a pattern, but that is how we think (we are security guys). May be the writer was thinking from a common user's point of view because most common users simply don't want to take the headache of remembering multiple passwords and having a common pattern in all the passwords may encourage them to use different passwords because now the passwords are much easier to remember (and easier to guess by a smart hacker). I personally prefer to maintain a pool of passwords.Nowadays you have to create an account with a number of random websites and you don't know how they are handling your passwords. I remember once on a job portal (read monster.com) I clicked on forgot password and then they mailed me my original password in plain text (they are still doing it!!!). Here in our community we have some great discussions on password management but there are people out there who do not care for your security. One should never use his bank related and other important passwords any where else. You can always remember a comparatively simpler password for these random websites.
Something a lot of people seem to forget. Using a huge password is better then confusing the user. eg the password: mySuperSecurePasswordKeepsMeSecuredAgainstHackersCrackersAutomatedToolsAndMoreStuff is more secure than: P@S$W0rD I can support with this numbers/math etc if required. For the downvoter: [XKCD #936: Short complex password, or long dictionary passphrase?](https://security.stackexchange.com/questions/6095/xkcd-936-short-complex-password-or-long-dictionary-passphrase/6116#6116)
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
Yes you are right. Using a pool of passwords is definitely recommended but the passwords should not follow a pattern, but that is how we think (we are security guys). May be the writer was thinking from a common user's point of view because most common users simply don't want to take the headache of remembering multiple passwords and having a common pattern in all the passwords may encourage them to use different passwords because now the passwords are much easier to remember (and easier to guess by a smart hacker). I personally prefer to maintain a pool of passwords.Nowadays you have to create an account with a number of random websites and you don't know how they are handling your passwords. I remember once on a job portal (read monster.com) I clicked on forgot password and then they mailed me my original password in plain text (they are still doing it!!!). Here in our community we have some great discussions on password management but there are people out there who do not care for your security. One should never use his bank related and other important passwords any where else. You can always remember a comparatively simpler password for these random websites.
Not the best advice ever, true, but I guess we should be grateful for any help from the big players in trying to raise public awareness regarding password security. Your concern regarding the 3rd step is justified, though. We should expect better from names like Intel. If you'd take their advice too literally, all that is needed for all your passwords to be compromised is to use one of its such iterations on an untrusted or compromised website, and an attacker could easily anticipate all other passwords you use with other services. This is an Intel's oversight and their advice should indeed be questioned. Another questionable choice is also the way the password check works - there is absolutely no need to type it two times and then press a button. Even if they mention it won't be sent and the password strength will be calculated on client-side, this could be further emphasised by a user interface that calculates password strength as we type, clearly showing a presence of a client-side script involved in these calculations. I find their choice rather peculiar, to be honest.
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
The short answer is yes. However, human beings tend to be a creature of habit. Therefore they tend to use the same password for multiple accounts. I believe this article is trying to make it a little more palatable for those who don't want to change passwords. Just using "My 1st Password!" on every site is less secure than using "My 1st Password! FB" on one site and "My 1st Password! twitr" on another for the fact that if a hacker got your first password and added it to his dictionary he wouldn't necessary be able to break the second one. If your passwords were the same then if the hacker obtained your first password and added it to his/her dictionary and got the hash of your second password then he/she could break it easily.
Totally agree - using ANY predictable pattern, no matter how complex it is, would undermine the whole idea of strong passwords. I am doing it this way: - Random passwords generated in Keepass (and stored there) for 99% of the passwords - Very few passwords generated with the help of Gasser generator, i.e. passwords that are pronounceable, but still not from dictionary, for the critical websites, passwords which I do not store ANYWHERE. e.g. of generator of such passwords: <http://www.multicians.org/thvv/gpw-js.html>
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
I think the general advice about starting with a base password and embellishing it with different characters based on the site (or computer name) you're visiting is good. This can provide the benefit of being easy to remember and still being secure because it would probably stop most automated methods of checking a compromised password list against multiple sites. That being said, the problem with their specific implementation of this model is that with a single compromised password, a hacker could guess your other passwords with a quick glance. Instead, they should recommend a strong base password like: `j3PL9$#U(B` This is something that is not trivial, but you would only have to memorize it once. Then you could come up with a non-obvious algorithm based on the characters in the URL. The algorithm could be: capitalize the first letter of the URL and put it at the end, and put the lower case version of the last letter of the URL at the beginning. So, in my example, your passwords would look like this: Facebook - `kj3PL9$#U(BF` Twitter - `rj3PL9$#U(BT` Reddit - `tj3PL9$#U(BR` Looking at any single one of these, it would be largely impossible to guess that the password has any relationship to the domain of the site. To most people, this just seems like a random string of numbers and letters. Of course, you could make this more complex by doing something like "put the second letter of the URL at the next to last character of the password".
Something a lot of people seem to forget. Using a huge password is better then confusing the user. eg the password: mySuperSecurePasswordKeepsMeSecuredAgainstHackersCrackersAutomatedToolsAndMoreStuff is more secure than: P@S$W0rD I can support with this numbers/math etc if required. For the downvoter: [XKCD #936: Short complex password, or long dictionary passphrase?](https://security.stackexchange.com/questions/6095/xkcd-936-short-complex-password-or-long-dictionary-passphrase/6116#6116)
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
The short answer is yes. However, human beings tend to be a creature of habit. Therefore they tend to use the same password for multiple accounts. I believe this article is trying to make it a little more palatable for those who don't want to change passwords. Just using "My 1st Password!" on every site is less secure than using "My 1st Password! FB" on one site and "My 1st Password! twitr" on another for the fact that if a hacker got your first password and added it to his dictionary he wouldn't necessary be able to break the second one. If your passwords were the same then if the hacker obtained your first password and added it to his/her dictionary and got the hash of your second password then he/she could break it easily.
I skimmed the majority of comments and I think as IT Security people we tend to over react when we see a password that appears to be simple, but isn't really. While there are many techniques for password attacking I actually somewhat agree with Intel in their thinking. Using `My 1st Password!: Twitr` according to GRC's Interactive Brute Force Password “Search Space” Calculator it would take approximately 9.88 billion trillion centuries doing 100 trillion guesses per second to brute force this password. Using the same password for even 10 different accounts with slight variations would still yield an near unimaginable time frame for attempting to brute force attack it. Just for reference, using a password such as `j3PL9$#U(B` would yield within a week for the 100 trillion guesses per second so what would seem impossible is easier. Now this is simply brute force methods. Obviously getting the hash and using rainbow tables would be a much better solution, but once they have the hash you're probably done for anyhow regardless of the complexity of your password.
Question: I came across this [Intel How Strong is Your Password?](http://www.intel.com/content/www/us/en/security/passwordwin.html) page which estimates how strong your password is. It has some advice on choosing better passwords including that you should use multiple passwords. But then after it says this: > > Step 3: Diversify your social passwords for added security > > "My 1st Password!: Twitr" "My 1st Password!: Fb" "My 1st Password!: Redd" > > > Does this increase security over just using "My 1st Password!"? I thought the reason not to use the same password more than once is so that if a site compromised, your passwords for other sites are still safe. But if your password here was "UltraSecurePassword: StackExchange" wouldn't it be easy to guess your Facebook password would be "UltraSecurePassword: FB"? Answer:
Not the best advice ever, true, but I guess we should be grateful for any help from the big players in trying to raise public awareness regarding password security. Your concern regarding the 3rd step is justified, though. We should expect better from names like Intel. If you'd take their advice too literally, all that is needed for all your passwords to be compromised is to use one of its such iterations on an untrusted or compromised website, and an attacker could easily anticipate all other passwords you use with other services. This is an Intel's oversight and their advice should indeed be questioned. Another questionable choice is also the way the password check works - there is absolutely no need to type it two times and then press a button. Even if they mention it won't be sent and the password strength will be calculated on client-side, this could be further emphasised by a user interface that calculates password strength as we type, clearly showing a presence of a client-side script involved in these calculations. I find their choice rather peculiar, to be honest.
Totally agree - using ANY predictable pattern, no matter how complex it is, would undermine the whole idea of strong passwords. I am doing it this way: - Random passwords generated in Keepass (and stored there) for 99% of the passwords - Very few passwords generated with the help of Gasser generator, i.e. passwords that are pronounceable, but still not from dictionary, for the critical websites, passwords which I do not store ANYWHERE. e.g. of generator of such passwords: <http://www.multicians.org/thvv/gpw-js.html>
Question: how can i refuse to assign an IP to a certain mac-address? or the other way round: how can i let the DHCP-server assign an IP only to some very special mac-addresses? i'm running two DHCP-servers on the same physical network - not good, i know that. but i need to boot a machine using PXE and the dhcp-server should assign addresses only to this machine, and not touch the others. the other machines receive an ip by the router. that one doesn't support adding a special dhcp-option which itself is required for PXE-boot. the server in question is a windows server 2003 R2 SP2 with the DHCP-services installed. i clicked around and looked for answers on the internet - without big success. thanks in advance and best regards atmocreations Answer:
I think this might help [How to Filter MAC Address with Windows Server 2003/2008 DHCP Server Callout DLL](http://www.petri.co.il/filter-mac-address-windows-server-2008-dhcp-server-callout-dll.htm)
Limit the scope on the one DHCP server to only the PXE MAC addresses. That way it won't assign IPs to any other machines except the ones that use PXE.
Question: how can i refuse to assign an IP to a certain mac-address? or the other way round: how can i let the DHCP-server assign an IP only to some very special mac-addresses? i'm running two DHCP-servers on the same physical network - not good, i know that. but i need to boot a machine using PXE and the dhcp-server should assign addresses only to this machine, and not touch the others. the other machines receive an ip by the router. that one doesn't support adding a special dhcp-option which itself is required for PXE-boot. the server in question is a windows server 2003 R2 SP2 with the DHCP-services installed. i clicked around and looked for answers on the internet - without big success. thanks in advance and best regards atmocreations Answer:
I think this might help [How to Filter MAC Address with Windows Server 2003/2008 DHCP Server Callout DLL](http://www.petri.co.il/filter-mac-address-windows-server-2008-dhcp-server-callout-dll.htm)
I believe it's easier than this. You can set up DHCP on the 2008 box to ONLY serve out PXE requests. So long as you can keep the router from assigning the addresses you want to give to PXE clients, all should be well. It should be buried in the DHCP server options. Don't have one handy atm, but leave a note if you need a hand.
Question: how can i refuse to assign an IP to a certain mac-address? or the other way round: how can i let the DHCP-server assign an IP only to some very special mac-addresses? i'm running two DHCP-servers on the same physical network - not good, i know that. but i need to boot a machine using PXE and the dhcp-server should assign addresses only to this machine, and not touch the others. the other machines receive an ip by the router. that one doesn't support adding a special dhcp-option which itself is required for PXE-boot. the server in question is a windows server 2003 R2 SP2 with the DHCP-services installed. i clicked around and looked for answers on the internet - without big success. thanks in advance and best regards atmocreations Answer:
I think this might help [How to Filter MAC Address with Windows Server 2003/2008 DHCP Server Callout DLL](http://www.petri.co.il/filter-mac-address-windows-server-2008-dhcp-server-callout-dll.htm)
If you want the DNS server to *only* assign addresses to certain macs, setup the range with *no* available address. (Yes none) then use the reservations to assign the macs you want to allow in there. Edit: You can do the other way around by using reservations with invalid ip addresses. We do this to stop certain machines connecting to our network at times. I'm not sure how it might affect you since you do need them to connect but a quick test will show you.
Question: how can i refuse to assign an IP to a certain mac-address? or the other way round: how can i let the DHCP-server assign an IP only to some very special mac-addresses? i'm running two DHCP-servers on the same physical network - not good, i know that. but i need to boot a machine using PXE and the dhcp-server should assign addresses only to this machine, and not touch the others. the other machines receive an ip by the router. that one doesn't support adding a special dhcp-option which itself is required for PXE-boot. the server in question is a windows server 2003 R2 SP2 with the DHCP-services installed. i clicked around and looked for answers on the internet - without big success. thanks in advance and best regards atmocreations Answer:
I think this might help [How to Filter MAC Address with Windows Server 2003/2008 DHCP Server Callout DLL](http://www.petri.co.il/filter-mac-address-windows-server-2008-dhcp-server-callout-dll.htm)
Create a scope with a range of one address. Set a reservation for that address to be assigned to the MAC address you want to use. Of course that won't stop your PXE machine from getting its IP address from the router if that answers the request first.
Question: hi I write a php file that contains two methods : **1)** ``` function restart(){ echo('restart') }; ``` **2)** ``` function shutdown(){echo ('shutdown')}; ``` then I include the **index.php** file to the **foo.php** and when I want to call index.php **methods** in an **eventHandler** in foo.php it doesn't work like this: ``` <?php include ('index.php'); ?> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <button id='res'>restart</button> <button id='sht'>shutdown</button> <script> document.getElementById('res').addEventListener('click',function(){ console.log('restarted'); <?php restart(); ?> }) </script> </body> </html> ``` output: **nothing and no errors** --- and when I **remove** the php code **inside the eventHandler** it works! like this: --- ``` <?php include ('index.php'); ?> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <button id='res'>restart</button> <button id='sht'>shutdown</button> <script> document.getElementById('res').addEventListener('click',function(){ console.log('restarted'); }) </script> </body> </html> ``` --- output: **restarted** **WHAT IS THE PROBLEM?** Answer:
The PHP code is being run when the file is 'rendered', so the function call to `restart`, even though it is within the JavaScript event listener, is being run on render. If you check the source (after fixing the missing semicolon), it should show `restart` in place of the PHP code. You cannot call PHP code within JavaScript, as JavaScript is client side and PHP is server side.
You have to use console.log in echo statement as well.. follow the below example. Assuming your index.php file code is already been added on top to explain you better. ```html <?php function restart(){ echo (" console.log('restarted')"); } function shutdown(){echo (" console.log('shutdown')"); } ?> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <button id='res'>restart</button> <button id='sht'>shutdown</button> <script> document.getElementById('res').addEventListener('click',function(){ //console.log('restarted'); <?php restart(); ?> }) </script> </body> </html> ```
Question: I would like to acces the broker via OData in our java application. I have the java web service running properly. However I'm getting stuck because I don't know how to add the service reference in our eclipse environment. In VS it's ok, but with Eclipse, the extension for odata.svc is invalid, due to is not a wsdl but a WCF service. There is an article about [OData and .NET for Tridion 2011](https://sdltridionworld.com/articles/sdltridion2011/tutorials/using-odata-with-tridion-and-net.aspx), but nothing about JAVA. Anybody has a clue how to get that working? We are thinking to use the odata4j API, but in this case we lost all the classes that the Web Service is providing. Answer:
Take a look at my blog post <http://yatb.mitza.net/2013/07/a-java-service-oriented-architecture.html>. It explains a Service Oriented approach to consuming OData content from a web-application using Java (namely OData4J). There is an example of the actual OData call.
I'm not sure you have the right level of expectations there, as it seems that you would want Java/Eclipse to provide you the same benefits that Microsoft / .NET / LINQ provide when working with OData services. The webservice and its capabilities are exactly the same independently of the client you use - .NET, Odata4j, JayData - but the client itself will expose more or less functionalities depending on its implementation. The Microsoft OData client is way ahead of everyone else on OData, but that has nothing to do with the service itself. Here's a sample JSP I wrote sometime ago using OData4j, might help getting you started: ``` <%@page import="org.odata4j.core.OProperty"%> <%@page import="org.odata4j.core.OEntity"%> <%@page import="java.util.List"%> <%@page import="org.odata4j.consumer.ODataConsumer"%> <%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <% ODataConsumer client = ODataConsumer.create("http://odata-server:8080/cd_webservice/odata.svc"); int PublicationId = client.getEntities("Publications").filter("Title eq 'Nexus 05 Website'").execute().first().getProperty("Id",Integer.class).getValue(); %> <div><%=PublicationId %></div> <% List<OEntity> Keywords = client.getEntities("Keywords").filter("(PublicationId eq 17) and (TaxonomyId eq 305)").execute().toList(); for(OEntity title : Keywords) { for(OProperty<?> p : title.getProperties()) { out.println(p.getName() + " = " + p.getValue() + "<br/>"); } } %> </body> </html> ```
Question: I'm currently stuck in a rut trying to create a `for` loop. Here's my objective: I want to create a list holding the proportion of people in each age group for e.g.: the proportion of people in age group 5-10 would be 500/2000 = 0.25 population of people = 2000 Of which 3 age group exists: "5-10", "11-20", "21-30" No. of people in each age group respectively: 500, 700, 800 this is what I did: ``` n_pop = 2000 label_list = ['5-10', '11-20', '21-30'] sub_pop = [500, 700, 800] proportion = [] for i in range(len(sub_pop)): proportion = sub_pop[i]/ n_pop print(proportion) ``` Not sure where I went wrong with the code. Answer:
I just did not realize that I have to declare all needed normailizer in the serializer definition. I solved it doing: ``` $encoder = new JsonEncoder(); $serializer = new Serializer(array( new JnToneNormalizer(), new JnWsKeyToneNormalizer() ), array($encoder)); ```
Symfony seems to have ObjectNormalizer. I think you may take advantage of it. Check the [installation](https://symfony.com/doc/current/components/serializer.html#installation) and [usage](https://symfony.com/doc/current/components/serializer.html#usage). I think there is also a way to perform serialization of complex nested objects using annotations and groups.
Question: I'm currently stuck in a rut trying to create a `for` loop. Here's my objective: I want to create a list holding the proportion of people in each age group for e.g.: the proportion of people in age group 5-10 would be 500/2000 = 0.25 population of people = 2000 Of which 3 age group exists: "5-10", "11-20", "21-30" No. of people in each age group respectively: 500, 700, 800 this is what I did: ``` n_pop = 2000 label_list = ['5-10', '11-20', '21-30'] sub_pop = [500, 700, 800] proportion = [] for i in range(len(sub_pop)): proportion = sub_pop[i]/ n_pop print(proportion) ``` Not sure where I went wrong with the code. Answer:
I just did not realize that I have to declare all needed normailizer in the serializer definition. I solved it doing: ``` $encoder = new JsonEncoder(); $serializer = new Serializer(array( new JnToneNormalizer(), new JnWsKeyToneNormalizer() ), array($encoder)); ```
If you get this error next time, first check that you have installed the serializer-pack. ``` composer require symfony/serializer-pack ```
Question: I'm currently stuck in a rut trying to create a `for` loop. Here's my objective: I want to create a list holding the proportion of people in each age group for e.g.: the proportion of people in age group 5-10 would be 500/2000 = 0.25 population of people = 2000 Of which 3 age group exists: "5-10", "11-20", "21-30" No. of people in each age group respectively: 500, 700, 800 this is what I did: ``` n_pop = 2000 label_list = ['5-10', '11-20', '21-30'] sub_pop = [500, 700, 800] proportion = [] for i in range(len(sub_pop)): proportion = sub_pop[i]/ n_pop print(proportion) ``` Not sure where I went wrong with the code. Answer:
Symfony seems to have ObjectNormalizer. I think you may take advantage of it. Check the [installation](https://symfony.com/doc/current/components/serializer.html#installation) and [usage](https://symfony.com/doc/current/components/serializer.html#usage). I think there is also a way to perform serialization of complex nested objects using annotations and groups.
If you get this error next time, first check that you have installed the serializer-pack. ``` composer require symfony/serializer-pack ```
Question: I'm trying to access a hiddenfield value from my masterpage that is set in my child aspx page, but cannot access it the masterpage codebehind page\_load event. Child aspx page: ``` <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server"> </telerik:RadStyleSheetManager> <div class="center_content"> <div style="text-align: left"> <h2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </h2> </div> <div style="text-align: left"> <uc1:Chart ID="Chart1" runat="server" /> </div> &nbsp;</div> <asp:HiddenField ID="hid1" runat="server" Value="Satellite Availability % Report" /> ``` Master page: ``` <asp:Label runat="server" ID="Label1" Style="text-align: right; font-size: xx-large; color: #808080"></asp:Label> ``` Master page code behind: This is where I want to set the text value of the report from the child page. ``` protected void Page_Load(object sender, EventArgs e) { HiddenField hid1 = (HiddenField)MainContent.FindControl("MainContent_hid1"); if (hid1 != null) { Label1.Text = hid1.Value; } } <input type="hidden" name="ctl00$MainContent$hdnRptTitle" id="MainContent_hdnRptTitle" value="Satellite Availability % Report" /> ``` There is no intellisense for the hdnRptTitle variable. How can I get this to work? It seems simple enough, but don't know why it not working... Answer:
You can add the below code in your `MasterPage`: ``` HiddenField hid1 = (HiddenField)MainContent.FindControl("hid1"); if (hid1 != null) { Label1.Text = hid1.Value; } ``` **EDIT:** Make sure your `Label` on the `MasterPage` is outside your `ContentPlaceHolder`, as I made this mistake when I first tested. The above code should work as provided, with your control names, I'm not sure why you are using: `.FindControl("MainContent_hid1");` instead of `.FindControl("hid1");`
Why do you think that you can access a control in a content-page of a master-page? A `MasterPage` is used for multiple pages, why do you want to hardlink it with a specific page, it won't work anymore without it. If the `HiddenField` is essential for the operation of the master you should declare it there. > > For every child page, there is a different rpt title which needs to > show up on the master page. How can I accomplish this? > > > Then the content page can access it's master to set the text but not vice-versa. You could provide a public property in the master, e.g.: ``` public string ReportTitle { get { return this.LblReportTitle.Text; } set { this.LblReportTitle.Text = value; } } ``` and in the `ContentPage`, for example in it's `Page_Load`: ``` protected void Page_Load(object sender, EventArgs e) { // assuming the type of your master is SiteMaster var master = this.Master as SiteMaster; if (master != null) master.ReportTitle = hdnRptTitle.Value; } ``` This approach is still linking the master with one (or multiple) of it's childs, but it would still "work" if the content-page would use a different master-type. You'd also be informed with a compiler error if somebody remove or change the property. However, where the content stores the report-type or where the master displays it is an implementation detail and can be changed in future without breaking anything.
Question: I'm trying to access a hiddenfield value from my masterpage that is set in my child aspx page, but cannot access it the masterpage codebehind page\_load event. Child aspx page: ``` <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server"> </telerik:RadStyleSheetManager> <div class="center_content"> <div style="text-align: left"> <h2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </h2> </div> <div style="text-align: left"> <uc1:Chart ID="Chart1" runat="server" /> </div> &nbsp;</div> <asp:HiddenField ID="hid1" runat="server" Value="Satellite Availability % Report" /> ``` Master page: ``` <asp:Label runat="server" ID="Label1" Style="text-align: right; font-size: xx-large; color: #808080"></asp:Label> ``` Master page code behind: This is where I want to set the text value of the report from the child page. ``` protected void Page_Load(object sender, EventArgs e) { HiddenField hid1 = (HiddenField)MainContent.FindControl("MainContent_hid1"); if (hid1 != null) { Label1.Text = hid1.Value; } } <input type="hidden" name="ctl00$MainContent$hdnRptTitle" id="MainContent_hdnRptTitle" value="Satellite Availability % Report" /> ``` There is no intellisense for the hdnRptTitle variable. How can I get this to work? It seems simple enough, but don't know why it not working... Answer:
You can add the below code in your `MasterPage`: ``` HiddenField hid1 = (HiddenField)MainContent.FindControl("hid1"); if (hid1 != null) { Label1.Text = hid1.Value; } ``` **EDIT:** Make sure your `Label` on the `MasterPage` is outside your `ContentPlaceHolder`, as I made this mistake when I first tested. The above code should work as provided, with your control names, I'm not sure why you are using: `.FindControl("MainContent_hid1");` instead of `.FindControl("hid1");`
You can use like this. There can be multiple `conterntPlaceHolder` on your master page. use the id which contains your `hidden field` in this case I assume that it is `ContentPlaceHolder1` ``` HiddenField hid1 = (HiddenField)ContentPlaceHolder1.FindControl("hdnRptTitle"); if (hid1 != null) { Label1.Text = hid1.Value; } ``` There is a similar post on `so` [How to access content page controls from master page in asp.net](https://stackoverflow.com/questions/4979669/how-to-access-content-page-controls-from-master-page-in-asp-net)
Question: I'm trying to access a hiddenfield value from my masterpage that is set in my child aspx page, but cannot access it the masterpage codebehind page\_load event. Child aspx page: ``` <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server"> </telerik:RadStyleSheetManager> <div class="center_content"> <div style="text-align: left"> <h2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </h2> </div> <div style="text-align: left"> <uc1:Chart ID="Chart1" runat="server" /> </div> &nbsp;</div> <asp:HiddenField ID="hid1" runat="server" Value="Satellite Availability % Report" /> ``` Master page: ``` <asp:Label runat="server" ID="Label1" Style="text-align: right; font-size: xx-large; color: #808080"></asp:Label> ``` Master page code behind: This is where I want to set the text value of the report from the child page. ``` protected void Page_Load(object sender, EventArgs e) { HiddenField hid1 = (HiddenField)MainContent.FindControl("MainContent_hid1"); if (hid1 != null) { Label1.Text = hid1.Value; } } <input type="hidden" name="ctl00$MainContent$hdnRptTitle" id="MainContent_hdnRptTitle" value="Satellite Availability % Report" /> ``` There is no intellisense for the hdnRptTitle variable. How can I get this to work? It seems simple enough, but don't know why it not working... Answer:
You can add the below code in your `MasterPage`: ``` HiddenField hid1 = (HiddenField)MainContent.FindControl("hid1"); if (hid1 != null) { Label1.Text = hid1.Value; } ``` **EDIT:** Make sure your `Label` on the `MasterPage` is outside your `ContentPlaceHolder`, as I made this mistake when I first tested. The above code should work as provided, with your control names, I'm not sure why you are using: `.FindControl("MainContent_hid1");` instead of `.FindControl("hid1");`
You can reference a master page and get the control like this: VB.Net: ``` Dim te As HiddenField Dim val As String te = Me.Page.Master.FindControl("hdnRptTitle") val = te.Value ``` c#: ``` HiddenField te = default(HiddenField); string val = null; te = this.Page.Master.FindControl("hdnRptTitle"); val = te.Value; ```
Question: I'm trying to access a hiddenfield value from my masterpage that is set in my child aspx page, but cannot access it the masterpage codebehind page\_load event. Child aspx page: ``` <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server"> </telerik:RadStyleSheetManager> <div class="center_content"> <div style="text-align: left"> <h2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </h2> </div> <div style="text-align: left"> <uc1:Chart ID="Chart1" runat="server" /> </div> &nbsp;</div> <asp:HiddenField ID="hid1" runat="server" Value="Satellite Availability % Report" /> ``` Master page: ``` <asp:Label runat="server" ID="Label1" Style="text-align: right; font-size: xx-large; color: #808080"></asp:Label> ``` Master page code behind: This is where I want to set the text value of the report from the child page. ``` protected void Page_Load(object sender, EventArgs e) { HiddenField hid1 = (HiddenField)MainContent.FindControl("MainContent_hid1"); if (hid1 != null) { Label1.Text = hid1.Value; } } <input type="hidden" name="ctl00$MainContent$hdnRptTitle" id="MainContent_hdnRptTitle" value="Satellite Availability % Report" /> ``` There is no intellisense for the hdnRptTitle variable. How can I get this to work? It seems simple enough, but don't know why it not working... Answer:
You can use like this. There can be multiple `conterntPlaceHolder` on your master page. use the id which contains your `hidden field` in this case I assume that it is `ContentPlaceHolder1` ``` HiddenField hid1 = (HiddenField)ContentPlaceHolder1.FindControl("hdnRptTitle"); if (hid1 != null) { Label1.Text = hid1.Value; } ``` There is a similar post on `so` [How to access content page controls from master page in asp.net](https://stackoverflow.com/questions/4979669/how-to-access-content-page-controls-from-master-page-in-asp-net)
Why do you think that you can access a control in a content-page of a master-page? A `MasterPage` is used for multiple pages, why do you want to hardlink it with a specific page, it won't work anymore without it. If the `HiddenField` is essential for the operation of the master you should declare it there. > > For every child page, there is a different rpt title which needs to > show up on the master page. How can I accomplish this? > > > Then the content page can access it's master to set the text but not vice-versa. You could provide a public property in the master, e.g.: ``` public string ReportTitle { get { return this.LblReportTitle.Text; } set { this.LblReportTitle.Text = value; } } ``` and in the `ContentPage`, for example in it's `Page_Load`: ``` protected void Page_Load(object sender, EventArgs e) { // assuming the type of your master is SiteMaster var master = this.Master as SiteMaster; if (master != null) master.ReportTitle = hdnRptTitle.Value; } ``` This approach is still linking the master with one (or multiple) of it's childs, but it would still "work" if the content-page would use a different master-type. You'd also be informed with a compiler error if somebody remove or change the property. However, where the content stores the report-type or where the master displays it is an implementation detail and can be changed in future without breaking anything.
Question: I'm trying to access a hiddenfield value from my masterpage that is set in my child aspx page, but cannot access it the masterpage codebehind page\_load event. Child aspx page: ``` <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server"> </telerik:RadStyleSheetManager> <div class="center_content"> <div style="text-align: left"> <h2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </h2> </div> <div style="text-align: left"> <uc1:Chart ID="Chart1" runat="server" /> </div> &nbsp;</div> <asp:HiddenField ID="hid1" runat="server" Value="Satellite Availability % Report" /> ``` Master page: ``` <asp:Label runat="server" ID="Label1" Style="text-align: right; font-size: xx-large; color: #808080"></asp:Label> ``` Master page code behind: This is where I want to set the text value of the report from the child page. ``` protected void Page_Load(object sender, EventArgs e) { HiddenField hid1 = (HiddenField)MainContent.FindControl("MainContent_hid1"); if (hid1 != null) { Label1.Text = hid1.Value; } } <input type="hidden" name="ctl00$MainContent$hdnRptTitle" id="MainContent_hdnRptTitle" value="Satellite Availability % Report" /> ``` There is no intellisense for the hdnRptTitle variable. How can I get this to work? It seems simple enough, but don't know why it not working... Answer:
You can use like this. There can be multiple `conterntPlaceHolder` on your master page. use the id which contains your `hidden field` in this case I assume that it is `ContentPlaceHolder1` ``` HiddenField hid1 = (HiddenField)ContentPlaceHolder1.FindControl("hdnRptTitle"); if (hid1 != null) { Label1.Text = hid1.Value; } ``` There is a similar post on `so` [How to access content page controls from master page in asp.net](https://stackoverflow.com/questions/4979669/how-to-access-content-page-controls-from-master-page-in-asp-net)
You can reference a master page and get the control like this: VB.Net: ``` Dim te As HiddenField Dim val As String te = Me.Page.Master.FindControl("hdnRptTitle") val = te.Value ``` c#: ``` HiddenField te = default(HiddenField); string val = null; te = this.Page.Master.FindControl("hdnRptTitle"); val = te.Value; ```
Question: I use jquery 1.8.2 I have these functions(below), but i want to call the bar() funtion when foo() have finished which dosen't happen. How can i do this? ``` function foo() { //something time consuming console.log("foo") } function bar() { console.log("bar"); } function helloWorld() { foo(); bar(); } ``` Answer:
You have several ways to do this. Right now, I can think of two I regularly use. The first one (and easiest to understand) is to use callbacks. Simply pass to the first function the second you want to call, as an argument. ``` function foo(callback) { setTimeout(function(){ console.log("foo"); callback(); }, 500); } function bar() { console.log("bar"); } function helloWorld() { foo(bar) } helloWorld(); ``` ([JSFiddle](http://jsfiddle.net/BWNba/109/)) This doesn't require any extra libraries, but when you have a lot of asynchronous stuff, the code quickly becomes a mess. The other solution, a bit harder to understand but much more powerful, is to use [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Promises are a great way to deal with asynchronous code by offering proper methods to deal with it. The only downside is that you need to learn them, and use an external library. **EDIT**: As pointed out, I didn't use the JQuery API. Here is how it would looks like using it: ``` function foo() { var deferred = jQuery.Deferred(); setTimeout(function(){ console.log("foo"); deferred.resolve(); }, 500); return deferred.promise(); } function bar() { console.log("bar"); } function helloWorld() { foo().then(bar); } helloWorld(); ``` ([JSFiddle](http://jsfiddle.net/BWNba/113/)) Following example is based on [Q](https://github.com/kriskowal/q). ``` function foo() { var deferred = Q.defer(); setTimeout(function(){ console.log("foo"); deferred.resolve(); }, 500); return deferred.promise; } function bar() { console.log("bar"); } function helloWorld() { foo().then(bar); } helloWorld(); ``` ([JSFiddle](http://jsfiddle.net/BWNba/110/))
function method1(){ // some code } ``` function method2(){ // some code } $.ajax({ url:method1(), success:function(){ method2(); } }) ```
Question: I use jquery 1.8.2 I have these functions(below), but i want to call the bar() funtion when foo() have finished which dosen't happen. How can i do this? ``` function foo() { //something time consuming console.log("foo") } function bar() { console.log("bar"); } function helloWorld() { foo(); bar(); } ``` Answer:
You have several ways to do this. Right now, I can think of two I regularly use. The first one (and easiest to understand) is to use callbacks. Simply pass to the first function the second you want to call, as an argument. ``` function foo(callback) { setTimeout(function(){ console.log("foo"); callback(); }, 500); } function bar() { console.log("bar"); } function helloWorld() { foo(bar) } helloWorld(); ``` ([JSFiddle](http://jsfiddle.net/BWNba/109/)) This doesn't require any extra libraries, but when you have a lot of asynchronous stuff, the code quickly becomes a mess. The other solution, a bit harder to understand but much more powerful, is to use [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Promises are a great way to deal with asynchronous code by offering proper methods to deal with it. The only downside is that you need to learn them, and use an external library. **EDIT**: As pointed out, I didn't use the JQuery API. Here is how it would looks like using it: ``` function foo() { var deferred = jQuery.Deferred(); setTimeout(function(){ console.log("foo"); deferred.resolve(); }, 500); return deferred.promise(); } function bar() { console.log("bar"); } function helloWorld() { foo().then(bar); } helloWorld(); ``` ([JSFiddle](http://jsfiddle.net/BWNba/113/)) Following example is based on [Q](https://github.com/kriskowal/q). ``` function foo() { var deferred = Q.defer(); setTimeout(function(){ console.log("foo"); deferred.resolve(); }, 500); return deferred.promise; } function bar() { console.log("bar"); } function helloWorld() { foo().then(bar); } helloWorld(); ``` ([JSFiddle](http://jsfiddle.net/BWNba/110/))
As simple as below: **[DEMO](https://jsfiddle.net/Guruprasad_Rao/a5w2fv69/)** ``` function foo() { var deferred=$.Deferred(); //create a deferred object console.log("foo"); return deferred.resolve() //once logging done resolve it and send back } function bar() { console.log("bar"); } function helloWorld() { $.when(foo()).done(bar()); //you can use $.when and done } $(document).ready(function(){ helloWorld(); }) ```
Question: First I ran: `rails generate model User name:string email:string` and this create a migration. Later I did a `db:migrate` and I get this error: ``` bundle exec rake db:migrate == 20150728195629 CreateUsers: migrating ====================================== -- create_table(:users) rake aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "users" already exists..... ``` When you `generate model` the table `user` is created but then when you `rake db:migrate` it tries to create it again. I'm confused! Am I doing something wrong? <https://www.railstutorial.org/book/modeling_users#code-generate_user_model> Answer:
You must have created a table as Marsatomic said. Run ``` bundle exec rake db:migrate:status ``` And look at your migration history to see where you created it. If you see it, you can roll back your migrations past that table, delete the migration file that created it, and then re-run your migrations. If you don't see it anywhere, you must have created the table without a migration. At that point you should do as Marsatomic instructed in his comment above.
you can use 'db:reset', it == 'db:drop db:create db:migrate'
Question: First I ran: `rails generate model User name:string email:string` and this create a migration. Later I did a `db:migrate` and I get this error: ``` bundle exec rake db:migrate == 20150728195629 CreateUsers: migrating ====================================== -- create_table(:users) rake aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "users" already exists..... ``` When you `generate model` the table `user` is created but then when you `rake db:migrate` it tries to create it again. I'm confused! Am I doing something wrong? <https://www.railstutorial.org/book/modeling_users#code-generate_user_model> Answer:
just run into the console ``` rails console ``` and type in ``` ActiveRecord::Migration.drop_table(:users) ``` and then exit the console and ``` rake db:migrate ```
You must have created a table as Marsatomic said. Run ``` bundle exec rake db:migrate:status ``` And look at your migration history to see where you created it. If you see it, you can roll back your migrations past that table, delete the migration file that created it, and then re-run your migrations. If you don't see it anywhere, you must have created the table without a migration. At that point you should do as Marsatomic instructed in his comment above.
Question: First I ran: `rails generate model User name:string email:string` and this create a migration. Later I did a `db:migrate` and I get this error: ``` bundle exec rake db:migrate == 20150728195629 CreateUsers: migrating ====================================== -- create_table(:users) rake aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "users" already exists..... ``` When you `generate model` the table `user` is created but then when you `rake db:migrate` it tries to create it again. I'm confused! Am I doing something wrong? <https://www.railstutorial.org/book/modeling_users#code-generate_user_model> Answer:
just run into the console ``` rails console ``` and type in ``` ActiveRecord::Migration.drop_table(:users) ``` and then exit the console and ``` rake db:migrate ```
you can use 'db:reset', it == 'db:drop db:create db:migrate'
Question: Is there a way of writing an `if` statement that involves the following? ``` if (MovieClip1 reaches last frame) { addChild(MovieClip2) removeChild(MovieClip1) } ``` Basically, all I want to happen is when my MovieClip finishes, it will change to another MovieClip or image. I know it is probably very simple, but how can I do it? Answer:
All code runs on command. So your conditional will run immediately and never run again. Instead, you use events. You attach a listener to an event and when that event fires (is "dispatched" to use correct vocabulary), your code is called again. ``` var movieClip:MovieClip = new MovieClip(); movieClip.addEventLister( Event.ENTER_FRAME, this.enterFrameHandler ); //will be called on every frame enter function enterFrameHandler( e:Event ):void { if ( movieClip.currentFrame == movieClip.totalFrames ) { // do something } } ``` So you listen for each new frame and in that handler, you check if it is the last frame or not. As an extra tidbit, the standard naming convention for AS3 is to use lowercase, camelcase (thisIsAnExampleOfthat) for all objects. Package names should be in all lowercase and only Class names should be capitalized.
``` package { import flash.display.MovieClip; import flash.events.KeyboardEvent; import flash.events.Event; public class Main extends MovieClip { var firstScene:FirstScene = new FirstScene; var movement:Movement = new Movement; var green:Green = new Green; public function Main() { addChild(firstScene); firstScene.addEventListener(KeyboardEvent.KEY_DOWN, mClick); movement.addEventListener(Event.ENTER_FRAME, endChange); } function mClick(event:KeyboardEvent):void { if (event.keyCode == 77); { addChild(movement); removeChild(firstScene); } } function endChange(event:Event):void { if (movement.currentFrame == movement.totalFrames) { addChild(green); removeChild(movement); } } } } ```
Question: I am new in angular. I have one scenario where I need only one field required from 5 fields in the form, means if the user fills at least one field then form makes valid. Thanks in advance. Answer:
Since you need to check for the validity of whole form only if one of the fields is non empty , You can manually set the validity like below : ``` if(!this.valid){ this.form.setErrors({ 'invalid': true}); }else{ this.form.setErrors(null); } ``` Where `this.valid` is your condition based on which you can set the validity You can check the example : <https://angular-exmphk.stackblitz.io> You can also check the answer : [FormGroup validation in "exclusive or"](https://stackoverflow.com/questions/53260398/formgroup-validation-in-exclusive-or/53261177) which does form validation based on some condition Hope this helps
Check this example of phone number validator ``` import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { NumberValidator } from '../validators/form-validators'; constructor( private fb: FormBuilder){} FormName: FormGroup = this.fb.group({ phoneNumber: ['', NumberValidator] }); ``` in form-validator file ``` import { AbstractControl, ValidatorFn } from '@angular/forms'; export const NumberValidator = (): ValidatorFn => { return (control: AbstractControl): { [key: string]: any } | null => { const mobileRegex = /^[()-\d\s]*$/g; const result = mobileRegex.test(control.value); return result ? null : { mobileInvalid: { value: control.value } }; }; }; ``` let me know if you have any doubts.
Question: I am new in angular. I have one scenario where I need only one field required from 5 fields in the form, means if the user fills at least one field then form makes valid. Thanks in advance. Answer:
See Custom Validators and Cross-field validation in <https://angular.io/guide/form-validation> Exact example from our app, where at least one phone number field must be entered. This is a Validator Function, i.e. implements <https://angular.io/api/forms/ValidatorFn> ``` import { AbstractControl } from "@angular/forms"; import { Member } from "../../members/member"; export function phone(control: AbstractControl): {[key: string]: any} { if (!control.parent) return; const form = control.parent; const member: Member = form.value; if (member.contactphone || member.mobile || member.contactphonesecond) { [ form.controls['contactphone'], form.controls['mobile'], form.controls['contactphonesecond'] ].forEach(control => { control.setErrors(null); }); } else return {'noPhone': 'None of contact phones is specified'}; } ``` Member is our class that defines all the form fields, your code will be different but the example of the custom validator should help.
Check this example of phone number validator ``` import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { NumberValidator } from '../validators/form-validators'; constructor( private fb: FormBuilder){} FormName: FormGroup = this.fb.group({ phoneNumber: ['', NumberValidator] }); ``` in form-validator file ``` import { AbstractControl, ValidatorFn } from '@angular/forms'; export const NumberValidator = (): ValidatorFn => { return (control: AbstractControl): { [key: string]: any } | null => { const mobileRegex = /^[()-\d\s]*$/g; const result = mobileRegex.test(control.value); return result ? null : { mobileInvalid: { value: control.value } }; }; }; ``` let me know if you have any doubts.
Question: I am new in angular. I have one scenario where I need only one field required from 5 fields in the form, means if the user fills at least one field then form makes valid. Thanks in advance. Answer:
Since you need to check for the validity of whole form only if one of the fields is non empty , You can manually set the validity like below : ``` if(!this.valid){ this.form.setErrors({ 'invalid': true}); }else{ this.form.setErrors(null); } ``` Where `this.valid` is your condition based on which you can set the validity You can check the example : <https://angular-exmphk.stackblitz.io> You can also check the answer : [FormGroup validation in "exclusive or"](https://stackoverflow.com/questions/53260398/formgroup-validation-in-exclusive-or/53261177) which does form validation based on some condition Hope this helps
``` <form [formGroup]="formdata"> <div class="form-group"> <label for="fieldlabel1">fieldLabel1</label> <input type="text" id="fieldlabel1" formControlName="fieldName1" class="form-control"><br> <label for="fieldlabel2">fieldLabel2</label> <input type="text" id="fieldlabel2" formControlName="fieldName2" class="form-control"> </div> </form> <div class="row"> <div class="col-sm-12"> <button type="submit" value="submit" (click)="somefunctioncall()" [disabled]="formdata.invalid"> Submit </button> </div> </div> import { FormGroup, FormControl, Validators } from '@angular/forms'; import { OnInit } from '@angular/core'; export class test { formdata: FormGroup; ngOnInit() { this.formdata = new FormGroup({ fieldName1: new FormControl("", Validators.compose([ Validators.required ])), fieldName2: new FormControl("", Validators.compose([ // remove required validation for one you dont need. ])) }) } } ```
Question: I am new in angular. I have one scenario where I need only one field required from 5 fields in the form, means if the user fills at least one field then form makes valid. Thanks in advance. Answer:
See Custom Validators and Cross-field validation in <https://angular.io/guide/form-validation> Exact example from our app, where at least one phone number field must be entered. This is a Validator Function, i.e. implements <https://angular.io/api/forms/ValidatorFn> ``` import { AbstractControl } from "@angular/forms"; import { Member } from "../../members/member"; export function phone(control: AbstractControl): {[key: string]: any} { if (!control.parent) return; const form = control.parent; const member: Member = form.value; if (member.contactphone || member.mobile || member.contactphonesecond) { [ form.controls['contactphone'], form.controls['mobile'], form.controls['contactphonesecond'] ].forEach(control => { control.setErrors(null); }); } else return {'noPhone': 'None of contact phones is specified'}; } ``` Member is our class that defines all the form fields, your code will be different but the example of the custom validator should help.
``` <form [formGroup]="formdata"> <div class="form-group"> <label for="fieldlabel1">fieldLabel1</label> <input type="text" id="fieldlabel1" formControlName="fieldName1" class="form-control"><br> <label for="fieldlabel2">fieldLabel2</label> <input type="text" id="fieldlabel2" formControlName="fieldName2" class="form-control"> </div> </form> <div class="row"> <div class="col-sm-12"> <button type="submit" value="submit" (click)="somefunctioncall()" [disabled]="formdata.invalid"> Submit </button> </div> </div> import { FormGroup, FormControl, Validators } from '@angular/forms'; import { OnInit } from '@angular/core'; export class test { formdata: FormGroup; ngOnInit() { this.formdata = new FormGroup({ fieldName1: new FormControl("", Validators.compose([ Validators.required ])), fieldName2: new FormControl("", Validators.compose([ // remove required validation for one you dont need. ])) }) } } ```
Question: I am new in angular. I have one scenario where I need only one field required from 5 fields in the form, means if the user fills at least one field then form makes valid. Thanks in advance. Answer:
Since you need to check for the validity of whole form only if one of the fields is non empty , You can manually set the validity like below : ``` if(!this.valid){ this.form.setErrors({ 'invalid': true}); }else{ this.form.setErrors(null); } ``` Where `this.valid` is your condition based on which you can set the validity You can check the example : <https://angular-exmphk.stackblitz.io> You can also check the answer : [FormGroup validation in "exclusive or"](https://stackoverflow.com/questions/53260398/formgroup-validation-in-exclusive-or/53261177) which does form validation based on some condition Hope this helps
See Custom Validators and Cross-field validation in <https://angular.io/guide/form-validation> Exact example from our app, where at least one phone number field must be entered. This is a Validator Function, i.e. implements <https://angular.io/api/forms/ValidatorFn> ``` import { AbstractControl } from "@angular/forms"; import { Member } from "../../members/member"; export function phone(control: AbstractControl): {[key: string]: any} { if (!control.parent) return; const form = control.parent; const member: Member = form.value; if (member.contactphone || member.mobile || member.contactphonesecond) { [ form.controls['contactphone'], form.controls['mobile'], form.controls['contactphonesecond'] ].forEach(control => { control.setErrors(null); }); } else return {'noPhone': 'None of contact phones is specified'}; } ``` Member is our class that defines all the form fields, your code will be different but the example of the custom validator should help.
Question: I've been researching this but can't find anything concerning these specific question I've found a lot of other interesting things though. My questions are In the image wall street what type of DoF is he using I think he's using a big DoF but I'm not an expert, the last question what type of shutter speed was he using I'm not even sure they had shutter speed back then, but searched and saw it was invented in the late 18 hundreds. This is one of my favorite photo by him, what do you think? [![enter image description here](https://i.stack.imgur.com/gzqfl.png)](https://i.stack.imgur.com/gzqfl.png) Answer:
This picture was made in 1915, with a large-format camera (probably a plate camera). Estimating depth-of-field is slightly hard as he quite likely used camera movements to shift plane of focus so it lines up with the line of the building. It's also slightly hard to asses the shutter speed as the image has been printed fairly softly (Strand was in the process of moving away from pictorialism to modernism, and this photograph is one of the examples of that move). However there's nothing significantly out of focus in the image, so the answer is 'enough DoF, combined with movements, to keep everything in focus'. It's possible to make some kind of numerical estimation: if you guess at a film (plate) speed of ISO 25, which is probably reasonable (although it's hard to get information about very old emulsion sensitivities) then you can see there is some motion-blur in people's feet, so may be an exposure of 1/8s or so. It's sunny, so using sunny-16 - 1 (25th at f/8) I get perhaps f/22 or f/32. Those would be reasonable apertures for a LF camera (all the shutters I have go down to f/45, and Group f/64 was called that for a reason).
As to a determination of the span of the depth of field for this image: Based on my expertise, this picture was taken from a substantially distant viewpoint. Likely the focus setting for this shot was at or near the infinity position. If true and I believe this is so, all objects depicted will be in focus. In other words, the span of the depth of field is moot. Your advised to research “hyperfocal distance” for more insight on this condition. As to shutter speed: On the date this image was taken, excellent shutters were available and their uses was the norm. One can guess the shutter speed, likely a moderate speed centered around 1/100 of a second
Question: My dataframe looks like this: ``` > data <- data.frame(A=c(1,1,1,2,2,3,3,3,3,3), B=c("1A","1B","1C","2A","2B","3A","3B","3C","3D","3E")) ``` I want to add a new variable labelled in function of variable A and B. The result must be: ``` > data A B LABEL 1 1 1A 1-2 2 1 1B 2-3 3 1 1C 3-4 4 2 2A 1-2 5 2 2B 2-3 6 3 3A 1-2 7 3 3B 2-3 8 3 3C 3-4 9 3 3D 4-5 10 3 3E 5-6 ``` I try this with data.table function. The code I try: ``` > setDT(data) > data <- data[,list(LABEL = for(i in 1:length(A)){paste(i, "-", i+1, sep="")}),by=c("A","B")] ``` Message Error: "*Error in `[.data.table`(data, , list(LABEL = for (i in 1:length(A)) { : Column 1 of j's result for the first group is NULL. We rely on the column types of the first result to decide the type expected for the remaining groups (and require consistency). NULL columns are acceptable for later groups (and those are replaced with NA of appropriate type and recycled) but not for the first. Please use a typed empty vector instead, such as integer() or numeric().*" Answer:
Your current code will compile into the following CSS: ```css .re-core-nav-menu-wide { width: 263px; } .re-core-nav-menu, .re-core-nav-menu-wide { margin: 0; padding: 0; width: 100px; background-image: linear-gradient(0deg, #20C0BF 0%, #1DC4F0 52%, #7067CF 100%); text-align: center; height: 100%; position: fixed; overflow: auto; } ``` As you can see ***there is a*** `width` ***setting in both the*** `.re-core-nav-menu-wide` selector and the one that has `.re-core-nav-menu, .re-core-nav-menu-wide`. ***Both are class selectors*** with just a single class in the selector and so they have the ***same specificity***. Thus the `width` setting which is present later in the CSS file wins and so you get only `width: 100px`. --- **Solution 1:** To solve the problem, move the `.re-core-nav-menu-wide` ruleset in your Sass code to the end or use a more specific selector. **Solution 2:** Another solution would be to form the `.re-core-nav-menu-wide` selector by nesting it under the `.re-core-nav-menu` selector. Some users may prefer this approach as the nesting makes it more readable than putting the ruleset for wide menu elsewhere in the document. ```css .re-core-nav-menu { width: $core-nav-width; /* other stuff */ &-wide { width: $core-nav-width-wide; @extend .re-core-nav-menu; } /* other stuff */ } ```
Turns out the order matters. Since SASS generates the CSS in the same order as defined putting `re-core-nav-menu-wide` before `re-core-nav-menu` in the .scss file results in properties of `re-core-nav-menu` overriding the properties of `re-core-nav-menu-wide`. I fixed this by changing the order to ``` .re-core-nav-menu {} .re-core-nav-menu-wide { width:.....; } ```
Question: I'm trying to learn some front-end development and I found an interesting thing [HERE][1]. I would like to keep the sliding effect whenever I move the cursor to left or right, but the navbar to be static/fixed. ``` [1]: https://codepen.io/bradtraversy/pen/dJzzdB ``` Answer:
The `ViewController` remains in the hierarchy. You can confirm this by verifying the value of `self.parentViewController` property in the modal view controller. **Edit:** > > Will that view controller affect the memory? > > > Yes it will continue to perform all operations or activities (e.g: streaming audio, playing animation, running timers etc) in the parentViewController. > > And if so, how can this situation be handled? > > > There are methods available in UIViewController class to detect when a ViewController will or is appeared / disappeared. More specifically, following methods are at your disposal: 1. [viewWillAppear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621510-viewwillappear) (Notifies the view controller that its view is about to be added to a view hierarchy) 2. [viewDidAppear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621423-viewdidappear) (Notifies the view controller that its view was added to a view hierarchy) 3. [viewWillDisappear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621485-viewwilldisappear) (Notifies the view controller that its view is about to be removed from a view hierarchy) 4. [viewDidDisappear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621477-viewdiddisappear) (Notifies the view controller that its view was removed from a view hierarchy) You can use `viewWillAppear` and `viewDidAppear` in `parentViewController` to start or resume such activities / operations. And `viewWillDisappear` and `viewDidDisappear` to suspend or stop such activities / operations. Hope this helps.
Yes, the previous UIViewController remains there. As described in [**Apple docs**](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621380-present) > > viewControllerToPresent > > The view controller to display over the > current view controller’s content. > > >
Question: I'm trying to learn some front-end development and I found an interesting thing [HERE][1]. I would like to keep the sliding effect whenever I move the cursor to left or right, but the navbar to be static/fixed. ``` [1]: https://codepen.io/bradtraversy/pen/dJzzdB ``` Answer:
You said: > > is my view controller still get removed after the transition finishes or is it still there but off the screen? > > > There are two completely separate issues here. First, there is a question of the view controller hierarchy. When you present a new view controller, the old view controller is always kept in the view controller hierarchy so that when you dismiss back to it, it will still be there. However, when you dismiss, the dismissed view controller will be removed from the view controller hierarchy and (unless you do something unusual, like keeping your own strong reference to it somewhere) it will be deallocated. Second, there is a separate question of the view hierarchy. When presenting, the `UIPresentationController` dictates whether the presenting view controller's view remains in the view hierarchy or not. By default, it keeps it in the view hierarchy, but generally if doing a modal, full-screen "present", you'd specify a `UIPresentationController` subclass that tells it to remove the presenting view controller's view when the transition is done. --- For example, when doing a custom modal "present" transition where the presented view controller's view is opaque and covers the whole screen, then your `UIViewControllerTransitioningDelegate` would not only supply the animation controllers, but also specify a presentation controller: ``` func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { return YourAnimationController(...) } func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { return YourAnimationController(...) } func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { return PresentationController(presentedViewController: presented, presenting: presenting) } ``` And that presentation controller might be fairly minimal, only telling it to remove the presenter's view: ``` class PresentationController: UIPresentationController { override var shouldRemovePresentersView: Bool { return true } } ```
The `ViewController` remains in the hierarchy. You can confirm this by verifying the value of `self.parentViewController` property in the modal view controller. **Edit:** > > Will that view controller affect the memory? > > > Yes it will continue to perform all operations or activities (e.g: streaming audio, playing animation, running timers etc) in the parentViewController. > > And if so, how can this situation be handled? > > > There are methods available in UIViewController class to detect when a ViewController will or is appeared / disappeared. More specifically, following methods are at your disposal: 1. [viewWillAppear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621510-viewwillappear) (Notifies the view controller that its view is about to be added to a view hierarchy) 2. [viewDidAppear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621423-viewdidappear) (Notifies the view controller that its view was added to a view hierarchy) 3. [viewWillDisappear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621485-viewwilldisappear) (Notifies the view controller that its view is about to be removed from a view hierarchy) 4. [viewDidDisappear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621477-viewdiddisappear) (Notifies the view controller that its view was removed from a view hierarchy) You can use `viewWillAppear` and `viewDidAppear` in `parentViewController` to start or resume such activities / operations. And `viewWillDisappear` and `viewDidDisappear` to suspend or stop such activities / operations. Hope this helps.
Question: I'm trying to learn some front-end development and I found an interesting thing [HERE][1]. I would like to keep the sliding effect whenever I move the cursor to left or right, but the navbar to be static/fixed. ``` [1]: https://codepen.io/bradtraversy/pen/dJzzdB ``` Answer:
The `ViewController` remains in the hierarchy. You can confirm this by verifying the value of `self.parentViewController` property in the modal view controller. **Edit:** > > Will that view controller affect the memory? > > > Yes it will continue to perform all operations or activities (e.g: streaming audio, playing animation, running timers etc) in the parentViewController. > > And if so, how can this situation be handled? > > > There are methods available in UIViewController class to detect when a ViewController will or is appeared / disappeared. More specifically, following methods are at your disposal: 1. [viewWillAppear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621510-viewwillappear) (Notifies the view controller that its view is about to be added to a view hierarchy) 2. [viewDidAppear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621423-viewdidappear) (Notifies the view controller that its view was added to a view hierarchy) 3. [viewWillDisappear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621485-viewwilldisappear) (Notifies the view controller that its view is about to be removed from a view hierarchy) 4. [viewDidDisappear](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621477-viewdiddisappear) (Notifies the view controller that its view was removed from a view hierarchy) You can use `viewWillAppear` and `viewDidAppear` in `parentViewController` to start or resume such activities / operations. And `viewWillDisappear` and `viewDidDisappear` to suspend or stop such activities / operations. Hope this helps.
I'm going assume that you are speaking about the `view` of your modal `viewController` staying in the window hierarchy - since you are asking if it is still there but off the screen, I believe you are talking about the view, and the controller, since controller is never on the screen. And if you are asking about the `view` (which I assume that you are), calling `completeTransition` on `transitionContext` will remove it from the window hierarchy (so there is no need to call `fromVC.view.removeFromSuperview()`) - and by contract you are required to call `completeTransition` when the transition finishes in the `UIViewControllerAnimatedTransitioning` implementation. You can confirm this behavior by checking the value of `fromVC.view.superview` before and after calling `transitionContext.completeTransition`: ``` UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: { fromVC.view.frame = endFrame }) { (_) in print(">>> \(fromVC.view.superview)") transitionContext.completeTransition(!transitionContext.transitionWasCancelled) print(">>> \(fromVC.view.superview)") } ```
Question: I'm trying to learn some front-end development and I found an interesting thing [HERE][1]. I would like to keep the sliding effect whenever I move the cursor to left or right, but the navbar to be static/fixed. ``` [1]: https://codepen.io/bradtraversy/pen/dJzzdB ``` Answer:
You said: > > is my view controller still get removed after the transition finishes or is it still there but off the screen? > > > There are two completely separate issues here. First, there is a question of the view controller hierarchy. When you present a new view controller, the old view controller is always kept in the view controller hierarchy so that when you dismiss back to it, it will still be there. However, when you dismiss, the dismissed view controller will be removed from the view controller hierarchy and (unless you do something unusual, like keeping your own strong reference to it somewhere) it will be deallocated. Second, there is a separate question of the view hierarchy. When presenting, the `UIPresentationController` dictates whether the presenting view controller's view remains in the view hierarchy or not. By default, it keeps it in the view hierarchy, but generally if doing a modal, full-screen "present", you'd specify a `UIPresentationController` subclass that tells it to remove the presenting view controller's view when the transition is done. --- For example, when doing a custom modal "present" transition where the presented view controller's view is opaque and covers the whole screen, then your `UIViewControllerTransitioningDelegate` would not only supply the animation controllers, but also specify a presentation controller: ``` func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { return YourAnimationController(...) } func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { return YourAnimationController(...) } func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { return PresentationController(presentedViewController: presented, presenting: presenting) } ``` And that presentation controller might be fairly minimal, only telling it to remove the presenter's view: ``` class PresentationController: UIPresentationController { override var shouldRemovePresentersView: Bool { return true } } ```
Yes, the previous UIViewController remains there. As described in [**Apple docs**](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621380-present) > > viewControllerToPresent > > The view controller to display over the > current view controller’s content. > > >
Question: I'm trying to learn some front-end development and I found an interesting thing [HERE][1]. I would like to keep the sliding effect whenever I move the cursor to left or right, but the navbar to be static/fixed. ``` [1]: https://codepen.io/bradtraversy/pen/dJzzdB ``` Answer:
I'm going assume that you are speaking about the `view` of your modal `viewController` staying in the window hierarchy - since you are asking if it is still there but off the screen, I believe you are talking about the view, and the controller, since controller is never on the screen. And if you are asking about the `view` (which I assume that you are), calling `completeTransition` on `transitionContext` will remove it from the window hierarchy (so there is no need to call `fromVC.view.removeFromSuperview()`) - and by contract you are required to call `completeTransition` when the transition finishes in the `UIViewControllerAnimatedTransitioning` implementation. You can confirm this behavior by checking the value of `fromVC.view.superview` before and after calling `transitionContext.completeTransition`: ``` UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: { fromVC.view.frame = endFrame }) { (_) in print(">>> \(fromVC.view.superview)") transitionContext.completeTransition(!transitionContext.transitionWasCancelled) print(">>> \(fromVC.view.superview)") } ```
Yes, the previous UIViewController remains there. As described in [**Apple docs**](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621380-present) > > viewControllerToPresent > > The view controller to display over the > current view controller’s content. > > >
Question: I'm trying to learn some front-end development and I found an interesting thing [HERE][1]. I would like to keep the sliding effect whenever I move the cursor to left or right, but the navbar to be static/fixed. ``` [1]: https://codepen.io/bradtraversy/pen/dJzzdB ``` Answer:
You said: > > is my view controller still get removed after the transition finishes or is it still there but off the screen? > > > There are two completely separate issues here. First, there is a question of the view controller hierarchy. When you present a new view controller, the old view controller is always kept in the view controller hierarchy so that when you dismiss back to it, it will still be there. However, when you dismiss, the dismissed view controller will be removed from the view controller hierarchy and (unless you do something unusual, like keeping your own strong reference to it somewhere) it will be deallocated. Second, there is a separate question of the view hierarchy. When presenting, the `UIPresentationController` dictates whether the presenting view controller's view remains in the view hierarchy or not. By default, it keeps it in the view hierarchy, but generally if doing a modal, full-screen "present", you'd specify a `UIPresentationController` subclass that tells it to remove the presenting view controller's view when the transition is done. --- For example, when doing a custom modal "present" transition where the presented view controller's view is opaque and covers the whole screen, then your `UIViewControllerTransitioningDelegate` would not only supply the animation controllers, but also specify a presentation controller: ``` func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { return YourAnimationController(...) } func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { return YourAnimationController(...) } func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { return PresentationController(presentedViewController: presented, presenting: presenting) } ``` And that presentation controller might be fairly minimal, only telling it to remove the presenter's view: ``` class PresentationController: UIPresentationController { override var shouldRemovePresentersView: Bool { return true } } ```
I'm going assume that you are speaking about the `view` of your modal `viewController` staying in the window hierarchy - since you are asking if it is still there but off the screen, I believe you are talking about the view, and the controller, since controller is never on the screen. And if you are asking about the `view` (which I assume that you are), calling `completeTransition` on `transitionContext` will remove it from the window hierarchy (so there is no need to call `fromVC.view.removeFromSuperview()`) - and by contract you are required to call `completeTransition` when the transition finishes in the `UIViewControllerAnimatedTransitioning` implementation. You can confirm this behavior by checking the value of `fromVC.view.superview` before and after calling `transitionContext.completeTransition`: ``` UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: { fromVC.view.frame = endFrame }) { (_) in print(">>> \(fromVC.view.superview)") transitionContext.completeTransition(!transitionContext.transitionWasCancelled) print(">>> \(fromVC.view.superview)") } ```
Question: I've been evaluating a number of JQuery table plugins to handle my paging and sorting needs. I am looking for something that allows be to page and sort my tables with an AJAX call. The problem that I am having is that all the plugins that I have found expect the Ajax call to return JSON. This is perfect for simple scenarios but falls down when I want to apply complex formatting to my tables, as soon as I want my table to include links or icons or other complex rendering I am faced with reproducing server side code that generates these links or chooses the appropriate icon as client side code to do the same thing. What I would like to do is return the new table data as an html table and have the plugin replace the existing table with the returned table (either directly or by copying cells, the specifics are not important). Are there any reccomendations for the best way to do this? Answer:
have a look at <http://www.datatables.net/> i think this will fill your needs :) Very good it is too! as for the formatting thru JSON i am doing this quite hapily... just make sure you encode any funny characters and it should be fine.
I have since found [ingrid](http://reconstrukt.com/ingrid/) and will throw it out as a potential solution. It seems to do what I want though the look and feel seems quite heavy. I'll see how this answer is voted I guess.
Question: I've been evaluating a number of JQuery table plugins to handle my paging and sorting needs. I am looking for something that allows be to page and sort my tables with an AJAX call. The problem that I am having is that all the plugins that I have found expect the Ajax call to return JSON. This is perfect for simple scenarios but falls down when I want to apply complex formatting to my tables, as soon as I want my table to include links or icons or other complex rendering I am faced with reproducing server side code that generates these links or chooses the appropriate icon as client side code to do the same thing. What I would like to do is return the new table data as an html table and have the plugin replace the existing table with the returned table (either directly or by copying cells, the specifics are not important). Are there any reccomendations for the best way to do this? Answer:
have a look at <http://www.datatables.net/> i think this will fill your needs :) Very good it is too! as for the formatting thru JSON i am doing this quite hapily... just make sure you encode any funny characters and it should be fine.
Try this, its from YUI, not JQuery, but I think it will do exactly what you need <http://developer.yahoo.com/yui/examples/datatable/dt_dynamicdata.html>
Question: I've been evaluating a number of JQuery table plugins to handle my paging and sorting needs. I am looking for something that allows be to page and sort my tables with an AJAX call. The problem that I am having is that all the plugins that I have found expect the Ajax call to return JSON. This is perfect for simple scenarios but falls down when I want to apply complex formatting to my tables, as soon as I want my table to include links or icons or other complex rendering I am faced with reproducing server side code that generates these links or chooses the appropriate icon as client side code to do the same thing. What I would like to do is return the new table data as an html table and have the plugin replace the existing table with the returned table (either directly or by copying cells, the specifics are not important). Are there any reccomendations for the best way to do this? Answer:
have a look at <http://www.datatables.net/> i think this will fill your needs :) Very good it is too! as for the formatting thru JSON i am doing this quite hapily... just make sure you encode any funny characters and it should be fine.
For jQuery, several grids can modfiy html tables in-place. Two I've used are flexigrid and jqgrid. If you do this, you could for example, inject the html table using an ajax call (if necessary), then apply flexigrid() or jqgrid() on the resulting html table.
Question: I've been evaluating a number of JQuery table plugins to handle my paging and sorting needs. I am looking for something that allows be to page and sort my tables with an AJAX call. The problem that I am having is that all the plugins that I have found expect the Ajax call to return JSON. This is perfect for simple scenarios but falls down when I want to apply complex formatting to my tables, as soon as I want my table to include links or icons or other complex rendering I am faced with reproducing server side code that generates these links or chooses the appropriate icon as client side code to do the same thing. What I would like to do is return the new table data as an html table and have the plugin replace the existing table with the returned table (either directly or by copying cells, the specifics are not important). Are there any reccomendations for the best way to do this? Answer:
I think your best option will be to create a controller action that returns a partial view which contains your table. The partial view can contain any JavaScript based table/grid you want. This solution has no dependency at all on any specific grid/table implementation. For instance, let's say you have a strongly typed partial view of type **ViewUserControl<IEnumerable<Foo>>** named FooList.ascx You would then define some action in your controller that rendered this partial ``` // For paging support, you would probably need to modify this action to accept // a parameter that could be used to tell which records to retrieve. // This would also require the appropriate route. However, this is beyond // the scope of this example. public PartialViewResult List() { // get the collection of stuff that you want to display var items = this.itemRepository.GetItems(); // return the partial return PartialView("FooList", items); } ``` In your view where this partial is going to be used, you will want to have something like the following... ``` <!-- this <div> will contain the partial, which we will be able to update via AJAX --> <div id="FooList"> <%-- this assumes a collection of "items" is available in Model.Items --%> <% Html.RenderPartial("FooList", Model.Items); %> </div> <!-- use an AJAX ActionLink to update the table --> <%= Ajax.ActionLink ( "Click Me to Update the Table using AJAX!", "List", new AjaxOptions() { HttpMethod = "GET", LoadingElementId = "FooList" } ) %> ``` All we're doing here is using the [ASP.NET MVC AJAX Helper](http://msdn.microsoft.com/en-us/library/system.web.mvc.ajaxhelper_members.aspx) to create a link that will generate an AJAX GET request to the List action in your controller. Also, by defining the **LoadingElementId** property in the AjaxOptions object, we have told the helper that we want to replace the inner contents of **<div id="FooList">** with the results of the AJAX request. When a user clicks that link, an AJAX request will cause your List action to be invoked. Your list action simply returns the rendered contents of the partial view FooList.ascx. The existing contents of the div with id="FooList" will be replaced by the contents that were retrieved from the AJAX request. In the above example, the controller action will always select the same data, which is not really what you want. In a real scenario, you would have to modify the controller action to retrieve the appropriate data for your partial view. I couldn't suggest an effective way for you to handle that without knowing the details for your implementation. If you don't want to use a link, then just look at the HTML and JavaScript that is generated by the Ajax.ActionLink helper and adapt it to your own needs. For instance, build your own custom helper, or just manually write out the JavaScript. Lastly, don't forget to include the MVC AJAX JavaScript source files. I recommend including them in your master page. For example: ``` <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script> <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script> ```
I have since found [ingrid](http://reconstrukt.com/ingrid/) and will throw it out as a potential solution. It seems to do what I want though the look and feel seems quite heavy. I'll see how this answer is voted I guess.
Question: I've been evaluating a number of JQuery table plugins to handle my paging and sorting needs. I am looking for something that allows be to page and sort my tables with an AJAX call. The problem that I am having is that all the plugins that I have found expect the Ajax call to return JSON. This is perfect for simple scenarios but falls down when I want to apply complex formatting to my tables, as soon as I want my table to include links or icons or other complex rendering I am faced with reproducing server side code that generates these links or chooses the appropriate icon as client side code to do the same thing. What I would like to do is return the new table data as an html table and have the plugin replace the existing table with the returned table (either directly or by copying cells, the specifics are not important). Are there any reccomendations for the best way to do this? Answer:
I think your best option will be to create a controller action that returns a partial view which contains your table. The partial view can contain any JavaScript based table/grid you want. This solution has no dependency at all on any specific grid/table implementation. For instance, let's say you have a strongly typed partial view of type **ViewUserControl<IEnumerable<Foo>>** named FooList.ascx You would then define some action in your controller that rendered this partial ``` // For paging support, you would probably need to modify this action to accept // a parameter that could be used to tell which records to retrieve. // This would also require the appropriate route. However, this is beyond // the scope of this example. public PartialViewResult List() { // get the collection of stuff that you want to display var items = this.itemRepository.GetItems(); // return the partial return PartialView("FooList", items); } ``` In your view where this partial is going to be used, you will want to have something like the following... ``` <!-- this <div> will contain the partial, which we will be able to update via AJAX --> <div id="FooList"> <%-- this assumes a collection of "items" is available in Model.Items --%> <% Html.RenderPartial("FooList", Model.Items); %> </div> <!-- use an AJAX ActionLink to update the table --> <%= Ajax.ActionLink ( "Click Me to Update the Table using AJAX!", "List", new AjaxOptions() { HttpMethod = "GET", LoadingElementId = "FooList" } ) %> ``` All we're doing here is using the [ASP.NET MVC AJAX Helper](http://msdn.microsoft.com/en-us/library/system.web.mvc.ajaxhelper_members.aspx) to create a link that will generate an AJAX GET request to the List action in your controller. Also, by defining the **LoadingElementId** property in the AjaxOptions object, we have told the helper that we want to replace the inner contents of **<div id="FooList">** with the results of the AJAX request. When a user clicks that link, an AJAX request will cause your List action to be invoked. Your list action simply returns the rendered contents of the partial view FooList.ascx. The existing contents of the div with id="FooList" will be replaced by the contents that were retrieved from the AJAX request. In the above example, the controller action will always select the same data, which is not really what you want. In a real scenario, you would have to modify the controller action to retrieve the appropriate data for your partial view. I couldn't suggest an effective way for you to handle that without knowing the details for your implementation. If you don't want to use a link, then just look at the HTML and JavaScript that is generated by the Ajax.ActionLink helper and adapt it to your own needs. For instance, build your own custom helper, or just manually write out the JavaScript. Lastly, don't forget to include the MVC AJAX JavaScript source files. I recommend including them in your master page. For example: ``` <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script> <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script> ```
Try this, its from YUI, not JQuery, but I think it will do exactly what you need <http://developer.yahoo.com/yui/examples/datatable/dt_dynamicdata.html>
Question: I've been evaluating a number of JQuery table plugins to handle my paging and sorting needs. I am looking for something that allows be to page and sort my tables with an AJAX call. The problem that I am having is that all the plugins that I have found expect the Ajax call to return JSON. This is perfect for simple scenarios but falls down when I want to apply complex formatting to my tables, as soon as I want my table to include links or icons or other complex rendering I am faced with reproducing server side code that generates these links or chooses the appropriate icon as client side code to do the same thing. What I would like to do is return the new table data as an html table and have the plugin replace the existing table with the returned table (either directly or by copying cells, the specifics are not important). Are there any reccomendations for the best way to do this? Answer:
I think your best option will be to create a controller action that returns a partial view which contains your table. The partial view can contain any JavaScript based table/grid you want. This solution has no dependency at all on any specific grid/table implementation. For instance, let's say you have a strongly typed partial view of type **ViewUserControl<IEnumerable<Foo>>** named FooList.ascx You would then define some action in your controller that rendered this partial ``` // For paging support, you would probably need to modify this action to accept // a parameter that could be used to tell which records to retrieve. // This would also require the appropriate route. However, this is beyond // the scope of this example. public PartialViewResult List() { // get the collection of stuff that you want to display var items = this.itemRepository.GetItems(); // return the partial return PartialView("FooList", items); } ``` In your view where this partial is going to be used, you will want to have something like the following... ``` <!-- this <div> will contain the partial, which we will be able to update via AJAX --> <div id="FooList"> <%-- this assumes a collection of "items" is available in Model.Items --%> <% Html.RenderPartial("FooList", Model.Items); %> </div> <!-- use an AJAX ActionLink to update the table --> <%= Ajax.ActionLink ( "Click Me to Update the Table using AJAX!", "List", new AjaxOptions() { HttpMethod = "GET", LoadingElementId = "FooList" } ) %> ``` All we're doing here is using the [ASP.NET MVC AJAX Helper](http://msdn.microsoft.com/en-us/library/system.web.mvc.ajaxhelper_members.aspx) to create a link that will generate an AJAX GET request to the List action in your controller. Also, by defining the **LoadingElementId** property in the AjaxOptions object, we have told the helper that we want to replace the inner contents of **<div id="FooList">** with the results of the AJAX request. When a user clicks that link, an AJAX request will cause your List action to be invoked. Your list action simply returns the rendered contents of the partial view FooList.ascx. The existing contents of the div with id="FooList" will be replaced by the contents that were retrieved from the AJAX request. In the above example, the controller action will always select the same data, which is not really what you want. In a real scenario, you would have to modify the controller action to retrieve the appropriate data for your partial view. I couldn't suggest an effective way for you to handle that without knowing the details for your implementation. If you don't want to use a link, then just look at the HTML and JavaScript that is generated by the Ajax.ActionLink helper and adapt it to your own needs. For instance, build your own custom helper, or just manually write out the JavaScript. Lastly, don't forget to include the MVC AJAX JavaScript source files. I recommend including them in your master page. For example: ``` <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script> <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script> ```
For jQuery, several grids can modfiy html tables in-place. Two I've used are flexigrid and jqgrid. If you do this, you could for example, inject the html table using an ajax call (if necessary), then apply flexigrid() or jqgrid() on the resulting html table.
Question: What exactly is a "contract" job? When I hear that I picture a part time project (or maybe a few projects) that is paid hourly or a fixed amount. Possibly with the potential to convert to full time. I have a full time job that I'm very happy with but I'm looking for some side work. But when I filter for "contract" work I see these 43 results. <https://stackoverflow.com/jobs?searchTerm=laravel&type=contract&allowsremote=true> Many of which have a **salary** listed, which conflicts with my understanding of contract work. Are employers just checking the "contract" checkbox to get more eyes on their listings? Or do I have a misunderstanding of the term? If it's the latter, would it be possible for us to filter by part time / single project jobs? Answer:
It's a common thing in Europe, and particularly in the UK. Many IT workers own their own company and do work on a fixed rate, fixed term basis through that company.
I'll try to to clear this up as best as I understand the situation in the "real world": 1. The job could be listed by a *contractor* that is looking to hire *full time workers* to then contract out to a client. The client's details are probably what you see on the page; the benefits are from the *contractor* that employs you; and the fact that its a contract job means you are - for legal and practical purposes - not a hired employee of the contracting client. 2. The other kind of contract job is a non-employee, non-salaried work based on a specific project or time frame. I am not sure if the system allows the posters to be more granular in how they write the salaries. These are the jobs where you'll generally see "no staffing agencies or contractors" - in this case *contractors* means *"companies that sign contracts to supply manpower"*; and not the individual person.
Question: What exactly is a "contract" job? When I hear that I picture a part time project (or maybe a few projects) that is paid hourly or a fixed amount. Possibly with the potential to convert to full time. I have a full time job that I'm very happy with but I'm looking for some side work. But when I filter for "contract" work I see these 43 results. <https://stackoverflow.com/jobs?searchTerm=laravel&type=contract&allowsremote=true> Many of which have a **salary** listed, which conflicts with my understanding of contract work. Are employers just checking the "contract" checkbox to get more eyes on their listings? Or do I have a misunderstanding of the term? If it's the latter, would it be possible for us to filter by part time / single project jobs? Answer:
I'll try to to clear this up as best as I understand the situation in the "real world": 1. The job could be listed by a *contractor* that is looking to hire *full time workers* to then contract out to a client. The client's details are probably what you see on the page; the benefits are from the *contractor* that employs you; and the fact that its a contract job means you are - for legal and practical purposes - not a hired employee of the contracting client. 2. The other kind of contract job is a non-employee, non-salaried work based on a specific project or time frame. I am not sure if the system allows the posters to be more granular in how they write the salaries. These are the jobs where you'll generally see "no staffing agencies or contractors" - in this case *contractors* means *"companies that sign contracts to supply manpower"*; and not the individual person.
Contract work means that you sign a contract to work for a company at a fixed rate for a fixed period of time based on the details of the contract. You will not get company benefits like healthcare, disability insurance, IRA matching, etc. In the United States, you will have to pay an additional 8% as self-employment tax on top of the normal 8% for social security and Medicare. Think of contract work as you running your own business and offering your services to a company. The only benefit is that you can deduct any purchases you make that could be construed as a business expense. See tax laws for details but this can work to your advantage. As a full-time employee, you gain various legal, tax, and company benefits as a result of your employment. You would be entitled to health care insurance, dental, etc. and whatever else the company offers. Benefits can equate to 20-25% of your annual salary in addition to your salary so nothing to sneeze at. For tax purposes, in the USA, for instance, you would pay 8% social security and Medicare tax while the company pays the other 8%. This is better than the 16% self-employment tax you would otherwise pay as a contractor. Depending on where you live, there are also legal advantages to being an employee. For instance, in my state, you can't get fired for discrimination or retaliation but these laws wouldn't apply to a contract position. Contractors are easier for companies to get rid of but you can sometimes make more on contract than you could as an employee. All depends on the situation and the circumstances. However, if you are getting paid the same amount on contract as you would as an employee, being an employee is better because of the company benefits, tax advantages, and legal protections you gain.
Question: What exactly is a "contract" job? When I hear that I picture a part time project (or maybe a few projects) that is paid hourly or a fixed amount. Possibly with the potential to convert to full time. I have a full time job that I'm very happy with but I'm looking for some side work. But when I filter for "contract" work I see these 43 results. <https://stackoverflow.com/jobs?searchTerm=laravel&type=contract&allowsremote=true> Many of which have a **salary** listed, which conflicts with my understanding of contract work. Are employers just checking the "contract" checkbox to get more eyes on their listings? Or do I have a misunderstanding of the term? If it's the latter, would it be possible for us to filter by part time / single project jobs? Answer:
It's a common thing in Europe, and particularly in the UK. Many IT workers own their own company and do work on a fixed rate, fixed term basis through that company.
Contractor in general is a loosely used term nowadays, at least in the U.S.. I did `contract` work for the military for 6 years, but was a W2 employee for the company that held that specific contract with the military. In those situations your employment is dependent upon that company holding the contract for its entirety, and when renewed. Which is why my resume will show I "technically" changed jobs multiple times, because a company does not always get renewed as someone else outbids it. In general on job postings (applies to Indeed, CareerBuilder, etc. also) recruiters are posting the job as both "permanent" and "contractor" to get more eyes on the posting...plain and simple. To differentiate between what is really a contract job is going to be difficult and up to SE on how they implement it. All job posting sites have the issue that recruiters will mis-use the system. Even if you add the ability to break down a job category to part-time they could likely still flag the job as that to just get eyes on it. In your reference to side work or single project jobs I consider that freelance work. Which might not be a bad idea if SE was up to opening it up to those type of postings. Freelance sites like freelance.com or guru.com are common places to find freelance jobs but it is a bidding system, where you bid on what work you could do. I can't stand those sites or that format. I can tell you the DBA work I used to do on the side for almost 3 years, I got from strict word-of-mouth. You are not likely going to find much of that type of job posting on any job site I have come across.
Question: What exactly is a "contract" job? When I hear that I picture a part time project (or maybe a few projects) that is paid hourly or a fixed amount. Possibly with the potential to convert to full time. I have a full time job that I'm very happy with but I'm looking for some side work. But when I filter for "contract" work I see these 43 results. <https://stackoverflow.com/jobs?searchTerm=laravel&type=contract&allowsremote=true> Many of which have a **salary** listed, which conflicts with my understanding of contract work. Are employers just checking the "contract" checkbox to get more eyes on their listings? Or do I have a misunderstanding of the term? If it's the latter, would it be possible for us to filter by part time / single project jobs? Answer:
Contractor in general is a loosely used term nowadays, at least in the U.S.. I did `contract` work for the military for 6 years, but was a W2 employee for the company that held that specific contract with the military. In those situations your employment is dependent upon that company holding the contract for its entirety, and when renewed. Which is why my resume will show I "technically" changed jobs multiple times, because a company does not always get renewed as someone else outbids it. In general on job postings (applies to Indeed, CareerBuilder, etc. also) recruiters are posting the job as both "permanent" and "contractor" to get more eyes on the posting...plain and simple. To differentiate between what is really a contract job is going to be difficult and up to SE on how they implement it. All job posting sites have the issue that recruiters will mis-use the system. Even if you add the ability to break down a job category to part-time they could likely still flag the job as that to just get eyes on it. In your reference to side work or single project jobs I consider that freelance work. Which might not be a bad idea if SE was up to opening it up to those type of postings. Freelance sites like freelance.com or guru.com are common places to find freelance jobs but it is a bidding system, where you bid on what work you could do. I can't stand those sites or that format. I can tell you the DBA work I used to do on the side for almost 3 years, I got from strict word-of-mouth. You are not likely going to find much of that type of job posting on any job site I have come across.
Contract work means that you sign a contract to work for a company at a fixed rate for a fixed period of time based on the details of the contract. You will not get company benefits like healthcare, disability insurance, IRA matching, etc. In the United States, you will have to pay an additional 8% as self-employment tax on top of the normal 8% for social security and Medicare. Think of contract work as you running your own business and offering your services to a company. The only benefit is that you can deduct any purchases you make that could be construed as a business expense. See tax laws for details but this can work to your advantage. As a full-time employee, you gain various legal, tax, and company benefits as a result of your employment. You would be entitled to health care insurance, dental, etc. and whatever else the company offers. Benefits can equate to 20-25% of your annual salary in addition to your salary so nothing to sneeze at. For tax purposes, in the USA, for instance, you would pay 8% social security and Medicare tax while the company pays the other 8%. This is better than the 16% self-employment tax you would otherwise pay as a contractor. Depending on where you live, there are also legal advantages to being an employee. For instance, in my state, you can't get fired for discrimination or retaliation but these laws wouldn't apply to a contract position. Contractors are easier for companies to get rid of but you can sometimes make more on contract than you could as an employee. All depends on the situation and the circumstances. However, if you are getting paid the same amount on contract as you would as an employee, being an employee is better because of the company benefits, tax advantages, and legal protections you gain.
Question: What exactly is a "contract" job? When I hear that I picture a part time project (or maybe a few projects) that is paid hourly or a fixed amount. Possibly with the potential to convert to full time. I have a full time job that I'm very happy with but I'm looking for some side work. But when I filter for "contract" work I see these 43 results. <https://stackoverflow.com/jobs?searchTerm=laravel&type=contract&allowsremote=true> Many of which have a **salary** listed, which conflicts with my understanding of contract work. Are employers just checking the "contract" checkbox to get more eyes on their listings? Or do I have a misunderstanding of the term? If it's the latter, would it be possible for us to filter by part time / single project jobs? Answer:
It's a common thing in Europe, and particularly in the UK. Many IT workers own their own company and do work on a fixed rate, fixed term basis through that company.
Contract work means that you sign a contract to work for a company at a fixed rate for a fixed period of time based on the details of the contract. You will not get company benefits like healthcare, disability insurance, IRA matching, etc. In the United States, you will have to pay an additional 8% as self-employment tax on top of the normal 8% for social security and Medicare. Think of contract work as you running your own business and offering your services to a company. The only benefit is that you can deduct any purchases you make that could be construed as a business expense. See tax laws for details but this can work to your advantage. As a full-time employee, you gain various legal, tax, and company benefits as a result of your employment. You would be entitled to health care insurance, dental, etc. and whatever else the company offers. Benefits can equate to 20-25% of your annual salary in addition to your salary so nothing to sneeze at. For tax purposes, in the USA, for instance, you would pay 8% social security and Medicare tax while the company pays the other 8%. This is better than the 16% self-employment tax you would otherwise pay as a contractor. Depending on where you live, there are also legal advantages to being an employee. For instance, in my state, you can't get fired for discrimination or retaliation but these laws wouldn't apply to a contract position. Contractors are easier for companies to get rid of but you can sometimes make more on contract than you could as an employee. All depends on the situation and the circumstances. However, if you are getting paid the same amount on contract as you would as an employee, being an employee is better because of the company benefits, tax advantages, and legal protections you gain.
Question: In an octo-copter design, is it better to put four pairs of counter-rotating props over each other so that each pair works in a column together? Or will you get more power or efficiency from staggering all eight props? It seems it would be more convenient to position them in pairs with a CW and CCW prop on the same axis, but I am wondering if this reduces the efficiency of the thrust to have them producing a single column of forced air rather than two separate columns. What are the physics involved? Answer:
It is better to stagger them. You want the largest overall effective propeller area for efficiency. This is the same reason that airplanes with wide wingspan are more efficient. Note that sailplanes, where efficiency really matters, have wide and thing wings. The reason is that lift comes from momentum, which is mass times velocity of the air that is pushed down. However, the power it takes to move this air is proportional to the square of velocity. Therefore you want to push a lot of air a little, instead of a little air a lot. Both produce the same lift, but the former takes less power. Rotors spread out will push more air, which therefore doesn't need to be pushed as fast, which saves power. There is one minor advantage to stacking counter-rotating propellors, which is that you can cancel the spin introduced into the air, which is just wasted motion. The Soviet Bear bomber is a good example of this. However, the spin induced in the air from a single propellor represents a relatively minor amount of power. The usual reason for stacked counter-rotating props in aircraft is for compactness and being able to increase the power imparted to the air over the limited area. That was the real reason for the configuration of the Bear. They simply needed more power to push a heavy aircraft at the speed they wanted, and more propellors sideways would have been difficult for other reasons. The Bear is a interesting lesson in what you can do with pushing propellors to the limit because you suck at jet engines.
I recently came across this information which seems quite relevant here: When you are comparing equal disk area, then yes staggering them is better than coaxial (in the same column) by roughly 20-30%. But consider the configuration shown below. For a given fram size, when you stagger them you have less room around the circumference of the vehicle's frame and so you therefore have to use smaller propellers in order for them to fit, but if you fit them in a co-axial configuration you can use larger props (with slower rpm) and get better overall coverage. Efficiency is therefore quite a bit better when you consider these additional factors. Keep in mind though, that the coaxial configuration using larger prop diameters will need motors to be of a lower kV rating than the staggered configuration Image came from *[here](http://www.ecalc.ch/calcinclude/help/xcoptercalchelp.htm#hints)*, which discusses this effect. ![enter image description here](https://i.stack.imgur.com/cOByw.png)
Question: I have got this code: ``` protocol GenericProtocol: class { associatedtype type func funca(component: type) } class MyType<T> { weak var delegate: GenericProtocol? // First error var t: T init(t: T) { self.t = t } func finished() { delegate?.funca(component: t) // Second error } } class UsingGenericProtocol: GenericProtocol { let myType: MyType<Int> typealias type = Int init() { myType = MyType<Int>(t: 0) } func funca(component: Int) { } } ``` I want to use delegates with a given type. The code will not compile because I got this errors: > > Protocol 'GenericProtocol' can only be used as a generic constraint > because it has Self or associated type requirements > > > And: > > Member 'funca' cannot be used on value of protocol type > 'GenericProtocol'; use a generic constraint instead > > > I can omit this error by removing the type from the protocol, make it Any and then casting it to the right type, but I thought generics should cover this problem. Is there any way I can get this code to compile? Thanks. Answer:
This is not possible to use generic protocols. Use concrete type or usual protocol instead. You have to declare concrete T outside of those abstractions For instance, this should work: ``` class MyType<T> { weak var delegate: UsingGenericProtocol<T>? // First error var t: T init(t: T) { self.t = t } func finished() { delegate?.funca(component: t) // Second error } } class UsingGenericProtocol<T>: GenericProtocol { let myType: MyType<T> typealias type = T init(t: T) { myType = MyType<T>(t: t) } func funca(component: T) { } } let instance = UsingGenericProtocol<Int>(t: 0) ```
The difference between generics and associated types is that generics are specified at instantiation, associated types during implementation. So you cannot use the protocol type as a concrete type because the associated type depends on the implementing type. However, there are a few workarounds: 1) Use the type of the delegate as a generic type: ``` class MyType<Delegate: GenericProtocol> { typealias T = Delegate.type ... } ``` 2) Use a common protocol on your delegate method instead of an associated type: ``` protocol CommonProtocol { ... } protocol DelegateProtocol { func funca(component: CommonProtocol) } ``` 3) Use closures for type erasure (this is also done in the Swift Standard Library for the `Sequence` protocol with `AnySequence<Element>`) ``` struct AnyGenericProtocol<GenericType>: GenericProtocol { typealias type = GenericType private let f: (GenericType) -> () init<G: GenericProtocol>(_ g: GenericProtocol) where G.type == GenericType { f = { component in g.funca(component: component) } } func funca(component: GenericType) { f(component) } } class MyType<T> { var delegate: AnyGenericProtocol<T> ... } ```
Question: I'm looking for the words in the list to be joined together in different combinations, but it's only returning single word results. I'm looking for strings like 'whywho' 'whatwhywhen' 'howwhywhatwho' etc. ``` import random, sys words = ['why', 'who', 'what', 'why', 'when', 'how'] for i in range(100): print ''.join(random.choice(words[:randint(1, 4)])) ``` Answer:
use `sample` function from random package. ``` import random words = ['why', 'who', 'what', 'why', 'when', 'how'] for i in range(100): print ''.join(random.sample(words, random.randint(1,4))) ``` **EDIT** If you don't care which element to be repeated, ``` for i in range(100): arr = random.sample(words, random.randint(1,4)) # select a random element from arr and append to self arr.append(random.choice(words)) print ''.join(arr) ``` if you don't want this operation to be repeated if repetitions are already there, ``` arr = random.sample(words, random.randint(1,4)) # first check if array contains repetetive elements or not # if contains, go and join the list, otherwise select a random element # from array and add to that array again if not [el for el in arr if arr.count(l) > 1]: arr.append(random.choice(words)) print ''.join(arr) ``` you might also want to use `insert` method defined for lists, which simply inserts an element to desired index in list. ``` arr = random.sample(words, random.randint(1,4)) if not [el for el in arr if arr.count(el) > 1]: r = random.choice(arr) index_of_r = arr.index(r) arr.insert(index_of_r, r) print ''.join(arr) ``` Check [this](https://repl.it/@marmeladze1/WingedAuthenticAmurminnow) for last one.
Try this out. Just find a random index and `join` it with a random list. To count the number of times a word was produced use the `Counter` object from the `collections` namespace. ``` import random as rand import sys from collections import Counter words = ['why', 'who', 'what', 'why', 'when', 'how'] list = [] for i in range(100): # print(words[rand.randint(1, 4)].join(words[:rand.randint(1, 4)])) # print(rand.sample(words, rand.randint(1, 4))) Prints out a 'list' of current combination list += rand.sample(words, rand.randint(1, 4)) c = Counter(list) print(c) # Counter({'why': 93, 'who': 48, 'what': 46, 'how': 46, 'when': 35}) ```
Question: I'm looking for the words in the list to be joined together in different combinations, but it's only returning single word results. I'm looking for strings like 'whywho' 'whatwhywhen' 'howwhywhatwho' etc. ``` import random, sys words = ['why', 'who', 'what', 'why', 'when', 'how'] for i in range(100): print ''.join(random.choice(words[:randint(1, 4)])) ``` Answer:
use `sample` function from random package. ``` import random words = ['why', 'who', 'what', 'why', 'when', 'how'] for i in range(100): print ''.join(random.sample(words, random.randint(1,4))) ``` **EDIT** If you don't care which element to be repeated, ``` for i in range(100): arr = random.sample(words, random.randint(1,4)) # select a random element from arr and append to self arr.append(random.choice(words)) print ''.join(arr) ``` if you don't want this operation to be repeated if repetitions are already there, ``` arr = random.sample(words, random.randint(1,4)) # first check if array contains repetetive elements or not # if contains, go and join the list, otherwise select a random element # from array and add to that array again if not [el for el in arr if arr.count(l) > 1]: arr.append(random.choice(words)) print ''.join(arr) ``` you might also want to use `insert` method defined for lists, which simply inserts an element to desired index in list. ``` arr = random.sample(words, random.randint(1,4)) if not [el for el in arr if arr.count(el) > 1]: r = random.choice(arr) index_of_r = arr.index(r) arr.insert(index_of_r, r) print ''.join(arr) ``` Check [this](https://repl.it/@marmeladze1/WingedAuthenticAmurminnow) for last one.
You are very close to the answer! `random.choice` returns **one** random element from the input sequence. What *you* are doing is that you are generating a slice of random size from the `words` list, from which you are choosing a single element. The following does what you want: ``` ''.join(random.choices(words, k=random.randint(1, 4))) ``` `random.choices` returns a `k` sized list of random elements from the input sequence. These elements are chosen *with replacement*, meaning that you may have more than one occurrence of an element from `words`.
Question: I'm looking for the words in the list to be joined together in different combinations, but it's only returning single word results. I'm looking for strings like 'whywho' 'whatwhywhen' 'howwhywhatwho' etc. ``` import random, sys words = ['why', 'who', 'what', 'why', 'when', 'how'] for i in range(100): print ''.join(random.choice(words[:randint(1, 4)])) ``` Answer:
You are very close to the answer! `random.choice` returns **one** random element from the input sequence. What *you* are doing is that you are generating a slice of random size from the `words` list, from which you are choosing a single element. The following does what you want: ``` ''.join(random.choices(words, k=random.randint(1, 4))) ``` `random.choices` returns a `k` sized list of random elements from the input sequence. These elements are chosen *with replacement*, meaning that you may have more than one occurrence of an element from `words`.
Try this out. Just find a random index and `join` it with a random list. To count the number of times a word was produced use the `Counter` object from the `collections` namespace. ``` import random as rand import sys from collections import Counter words = ['why', 'who', 'what', 'why', 'when', 'how'] list = [] for i in range(100): # print(words[rand.randint(1, 4)].join(words[:rand.randint(1, 4)])) # print(rand.sample(words, rand.randint(1, 4))) Prints out a 'list' of current combination list += rand.sample(words, rand.randint(1, 4)) c = Counter(list) print(c) # Counter({'why': 93, 'who': 48, 'what': 46, 'how': 46, 'when': 35}) ```
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
This also works: <https://meta.stackexchange.com/posts/comments/943975>
I agree, this has been a problem for me too a few times, mainly in meta-SO. It would have helped Jeff to link to me and TXI's bad joke in [a recent SO blog post](https://blog.stackoverflow.com/2009/07/migrate-questions-between-websites/) too! :)
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
This appears to be officially supported now: ![permalink to comments](https://i.stack.imgur.com/t0076.png) Right clicking on the timestamp gives what looks like a stable URL: [`https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436`](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436)
This would actually be really helpful for people who flag comments - being able to move directly to the item flagged.
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
This appears to be officially supported now: ![permalink to comments](https://i.stack.imgur.com/t0076.png) Right clicking on the timestamp gives what looks like a stable URL: [`https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436`](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436)
I agree, this has been a problem for me too a few times, mainly in meta-SO. It would have helped Jeff to link to me and TXI's bad joke in [a recent SO blog post](https://blog.stackoverflow.com/2009/07/migrate-questions-between-websites/) too! :)
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
FWIW, you *can* link to comments by combining the URL used behind the scenes to retrieve them with the internal ID for the specific comment: > > <https://meta.stackexchange.com/posts/27319/comments#comment-57475> > > > However, this relies on specific aspects of the current implementation, and there's no guarantee they won't change at some point in the future. Don't count on these links being *permanent*! Or, even worse, combining the permalink of an answer (to ensure proper pagination) with the id of a comment, which however might not be shown on a page if there's too many comments, or if it's deleted (and hence would result in the page not scrolling at all): > > [Direct Link to a Comment](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment/27319#comment-57475) > > > Links from the profile page currently use a slightly different format, where the comment ID has the answer ID appended to it (comment-<commentID>\_<answerID>): `comment-57475_27319` - this triggers a bit of client-side script that'll scroll to the proper answer and expand comments... So it works great, but again: *very* implementation-specific, so be wary of using this anywhere it *has* to keep working long-term (at least for now): if the format changes, this won't even be recognized by the browser as a valid ID. For a userscript that'll make this easier, see [the SEModification.user.js available here](http://rchern.github.com/StackExchangeScripts/).
I agree, this has been a problem for me too a few times, mainly in meta-SO. It would have helped Jeff to link to me and TXI's bad joke in [a recent SO blog post](https://blog.stackoverflow.com/2009/07/migrate-questions-between-websites/) too! :)
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
This appears to be officially supported now: ![permalink to comments](https://i.stack.imgur.com/t0076.png) Right clicking on the timestamp gives what looks like a stable URL: [`https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436`](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436)
This also works: <https://meta.stackexchange.com/posts/comments/943975>
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
This would actually be really helpful for people who flag comments - being able to move directly to the item flagged.
I agree, this has been a problem for me too a few times, mainly in meta-SO. It would have helped Jeff to link to me and TXI's bad joke in [a recent SO blog post](https://blog.stackoverflow.com/2009/07/migrate-questions-between-websites/) too! :)
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
FWIW, you *can* link to comments by combining the URL used behind the scenes to retrieve them with the internal ID for the specific comment: > > <https://meta.stackexchange.com/posts/27319/comments#comment-57475> > > > However, this relies on specific aspects of the current implementation, and there's no guarantee they won't change at some point in the future. Don't count on these links being *permanent*! Or, even worse, combining the permalink of an answer (to ensure proper pagination) with the id of a comment, which however might not be shown on a page if there's too many comments, or if it's deleted (and hence would result in the page not scrolling at all): > > [Direct Link to a Comment](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment/27319#comment-57475) > > > Links from the profile page currently use a slightly different format, where the comment ID has the answer ID appended to it (comment-<commentID>\_<answerID>): `comment-57475_27319` - this triggers a bit of client-side script that'll scroll to the proper answer and expand comments... So it works great, but again: *very* implementation-specific, so be wary of using this anywhere it *has* to keep working long-term (at least for now): if the format changes, this won't even be recognized by the browser as a valid ID. For a userscript that'll make this easier, see [the SEModification.user.js available here](http://rchern.github.com/StackExchangeScripts/).
This would actually be really helpful for people who flag comments - being able to move directly to the item flagged.
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
This appears to be officially supported now: ![permalink to comments](https://i.stack.imgur.com/t0076.png) Right clicking on the timestamp gives what looks like a stable URL: [`https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436`](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436)
FWIW, you *can* link to comments by combining the URL used behind the scenes to retrieve them with the internal ID for the specific comment: > > <https://meta.stackexchange.com/posts/27319/comments#comment-57475> > > > However, this relies on specific aspects of the current implementation, and there's no guarantee they won't change at some point in the future. Don't count on these links being *permanent*! Or, even worse, combining the permalink of an answer (to ensure proper pagination) with the id of a comment, which however might not be shown on a page if there's too many comments, or if it's deleted (and hence would result in the page not scrolling at all): > > [Direct Link to a Comment](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment/27319#comment-57475) > > > Links from the profile page currently use a slightly different format, where the comment ID has the answer ID appended to it (comment-<commentID>\_<answerID>): `comment-57475_27319` - this triggers a bit of client-side script that'll scroll to the proper answer and expand comments... So it works great, but again: *very* implementation-specific, so be wary of using this anywhere it *has* to keep working long-term (at least for now): if the format changes, this won't even be recognized by the browser as a valid ID. For a userscript that'll make this easier, see [the SEModification.user.js available here](http://rchern.github.com/StackExchangeScripts/).
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
This appears to be officially supported now: ![permalink to comments](https://i.stack.imgur.com/t0076.png) Right clicking on the timestamp gives what looks like a stable URL: [`https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436`](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment1232412_5436)
I just can't see any legitimate need to deep link (permalink) to a comment. Conceptually, they are too ephemeral compared to answers and questions. And on top of that, whether a comment is *visible* or not is completely dependent on how many other comments there are and how highly they are voted, among other variables... Linking to the question or answer should be sufficient, I think. edit: we do have a way to deep link to comments now, I believe -- I'll check and provide details.
Question: The increase in the character limit of comments has led them to become as important as the questions and answers that spawn them. On several occasions (especially on meta) I've found reason to want to link to a comment directly. I'd imagine something as simple as making the date / time stamp an anchored link which mimics the behavior of the question link. Answer:
FWIW, you *can* link to comments by combining the URL used behind the scenes to retrieve them with the internal ID for the specific comment: > > <https://meta.stackexchange.com/posts/27319/comments#comment-57475> > > > However, this relies on specific aspects of the current implementation, and there's no guarantee they won't change at some point in the future. Don't count on these links being *permanent*! Or, even worse, combining the permalink of an answer (to ensure proper pagination) with the id of a comment, which however might not be shown on a page if there's too many comments, or if it's deleted (and hence would result in the page not scrolling at all): > > [Direct Link to a Comment](https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment/27319#comment-57475) > > > Links from the profile page currently use a slightly different format, where the comment ID has the answer ID appended to it (comment-<commentID>\_<answerID>): `comment-57475_27319` - this triggers a bit of client-side script that'll scroll to the proper answer and expand comments... So it works great, but again: *very* implementation-specific, so be wary of using this anywhere it *has* to keep working long-term (at least for now): if the format changes, this won't even be recognized by the browser as a valid ID. For a userscript that'll make this easier, see [the SEModification.user.js available here](http://rchern.github.com/StackExchangeScripts/).
I just can't see any legitimate need to deep link (permalink) to a comment. Conceptually, they are too ephemeral compared to answers and questions. And on top of that, whether a comment is *visible* or not is completely dependent on how many other comments there are and how highly they are voted, among other variables... Linking to the question or answer should be sufficient, I think. edit: we do have a way to deep link to comments now, I believe -- I'll check and provide details.
Question: I want to generate sequence number that starts from 001,002 and continue like that.I want it to get incremented on each visit of that screen..Any help appreciated.Thank you. Answer:
Write this way ``` public void incrementNumber(){ int count = 1; SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit(); int defaultValue = getPreferences(MODE_PRIVATE).getInt("count_key",count); ++defaultValue; getPreferences(MODE_PRIVATE).edit().putInt("count_key",defaultValue).commit(); } ``` Read like this ``` public int getNumber(){ int count = getPreferences(MODE_PRIVATE).getInt("count_key",count); System.out.println("The count value is " + count); return count; } ``` call these methods from the onCreate of the Activity ``` public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.filters); incrementNumber(); getNumber(); } ```
You'll want to initialize your counter in `onCreate()` and increment it in `onResume()`, storing the counter in the class and not as a local variable.
Question: I want to generate sequence number that starts from 001,002 and continue like that.I want it to get incremented on each visit of that screen..Any help appreciated.Thank you. Answer:
Write this way ``` public void incrementNumber(){ int count = 1; SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit(); int defaultValue = getPreferences(MODE_PRIVATE).getInt("count_key",count); ++defaultValue; getPreferences(MODE_PRIVATE).edit().putInt("count_key",defaultValue).commit(); } ``` Read like this ``` public int getNumber(){ int count = getPreferences(MODE_PRIVATE).getInt("count_key",count); System.out.println("The count value is " + count); return count; } ``` call these methods from the onCreate of the Activity ``` public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.filters); incrementNumber(); getNumber(); } ```
You can save page visited count in SharedPreference, So every time you visit that screen increment it by one. Ref link <http://developer.android.com/guide/topics/data/data-storage.html#pref>
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
If nobody should ever create an instance of the master class, it is definitely appropriate to make it `abstract`. As for the property, make it an abstract property. In the master, write something like: ``` public abstract int MyProperty { get; } ``` and then the subclass must override it.
If the master class indeed cannot have concrete instances, then making it abstract is absolutely fine and indeed correct.
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
If the master class indeed cannot have concrete instances, then making it abstract is absolutely fine and indeed correct.
If there is nothing to extend except for setting some specific state that is already in the "master" then it sounds like you don't need the inheritance at all and perhaps need instead to control how instances of your "master" class are constructed. You could look at instead using a factory pattern. However, if you are changing behaviour then definitely the use of `abstract` is warranted!
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
If nobody should ever create an instance of the master class, it is definitely appropriate to make it `abstract`. As for the property, make it an abstract property. In the master, write something like: ``` public abstract int MyProperty { get; } ``` and then the subclass must override it.
Abstract class is appropriate. You can have it have a protected constructor that takes the property you care about, so that sub-classes will have to supply that
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
Abstract class is appropriate. You can have it have a protected constructor that takes the property you care about, so that sub-classes will have to supply that
If there is nothing to extend except for setting some specific state that is already in the "master" then it sounds like you don't need the inheritance at all and perhaps need instead to control how instances of your "master" class are constructed. You could look at instead using a factory pattern. However, if you are changing behaviour then definitely the use of `abstract` is warranted!
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
If nobody should ever create an instance of the master class, it is definitely appropriate to make it `abstract`. As for the property, make it an abstract property. In the master, write something like: ``` public abstract int MyProperty { get; } ``` and then the subclass must override it.
If there is nothing to extend except for setting some specific state that is already in the "master" then it sounds like you don't need the inheritance at all and perhaps need instead to control how instances of your "master" class are constructed. You could look at instead using a factory pattern. However, if you are changing behaviour then definitely the use of `abstract` is warranted!
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
If nobody should ever create an instance of the master class, it is definitely appropriate to make it `abstract`. As for the property, make it an abstract property. In the master, write something like: ``` public abstract int MyProperty { get; } ``` and then the subclass must override it.
It should be fine to make the master class abstract - after all you never want it to be used without it being inherited. You can also declare the property to be abstract, so that it will have to be overriden in the child class: ``` public abstract string MyProperty { get; set; } ```
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
If nobody should ever create an instance of the master class, it is definitely appropriate to make it `abstract`. As for the property, make it an abstract property. In the master, write something like: ``` public abstract int MyProperty { get; } ``` and then the subclass must override it.
> > My master class contains nearly all > the functionality and the sub-class > only needs to set a value from the > master. > > > This sounds more like you should expose a static factory method in your master class that accepts this value and returns an instance of the master class. Make the constructor of the master class private so only your static factory method can create an instance of your master class. Something like this: ``` public class MasterClass { public string MyValue { get; set; } private MasterClass() { } public static MasterClass CreateMaster(string val) { MasterClass mc = new MasterClass() { MyValue = val }; return mc; } } ```
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
It should be fine to make the master class abstract - after all you never want it to be used without it being inherited. You can also declare the property to be abstract, so that it will have to be overriden in the child class: ``` public abstract string MyProperty { get; set; } ```
If there is nothing to extend except for setting some specific state that is already in the "master" then it sounds like you don't need the inheritance at all and perhaps need instead to control how instances of your "master" class are constructed. You could look at instead using a factory pattern. However, if you are changing behaviour then definitely the use of `abstract` is warranted!
Question: I am using .Net and have a simple master- and sub-class design. My master class contains nearly all the functionality and the sub-class only needs to set a value from the master. I was considering making the master an abstract class but there is no methods that I must override, but I'd like to reinforce the idea that the master class cannot necessarily exist on its own. Also, I'd like to reinforce that the property from the master must be set by the sub-class. What is appropriate here? Thanks for any help! Answer:
> > My master class contains nearly all > the functionality and the sub-class > only needs to set a value from the > master. > > > This sounds more like you should expose a static factory method in your master class that accepts this value and returns an instance of the master class. Make the constructor of the master class private so only your static factory method can create an instance of your master class. Something like this: ``` public class MasterClass { public string MyValue { get; set; } private MasterClass() { } public static MasterClass CreateMaster(string val) { MasterClass mc = new MasterClass() { MyValue = val }; return mc; } } ```
If there is nothing to extend except for setting some specific state that is already in the "master" then it sounds like you don't need the inheritance at all and perhaps need instead to control how instances of your "master" class are constructed. You could look at instead using a factory pattern. However, if you are changing behaviour then definitely the use of `abstract` is warranted!
Question: I am trying to make a vueapp that sets a property when the user clicks on an option tag. I'm trying to use v-on:click but it hasn't worked. Any ideas? ```xml <div v-show="loggedin==1" class="searchBy"> <h2>Selected Display</h2> <select v-model="selectedDisplayShapeText"> <option value="" disabled>Please Choose One</option> <option v-for="display in displays" :value="display.shapetext" v-on:click="displayName=display.name">{{display.name}}</option> </select> </div> ``` Answer:
You can retrieve the option on the `change` event of select: ```js new Vue({ el: "#app", data() { return { displays: [{ name: "Display1", shapetext: "1" }, { name: "Display2", shapetext: "2" }, { name: "Display3", shapetext: "3" }], selectedDisplayShapeText: '', displayName: '' } }, methods: { getDisplayName(e){ let value = e.target.value let display = this.displays.find(d => d.shapetext == value) this.displayName = display.name } } }) ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"></script> <div id="app"> <h2>Selected Display</h2> <select v-model="selectedDisplayShapeText" v-on:change="getDisplayName($event)"> <option value="" disabled>Please Choose One</option> <option v-for="display in displays" :value="display.shapetext">{{display.name}}</option> </select> <p>Display selected: {{ displayName }}</p> </div> ```
You can bind the value of a select option in Vue to a complex expression (in this case an object). Instead of binding your selected option to a property of the display object, just bind it to the display object itself. Then, whenever you need one of the properties of the selected display, you can just reference them from the selected display. Here is an example. ```js console.clear() new Vue({ el: "#app", data:{ displays: [ {shapetext: "shape text 1", name: "display one"}, {shapetext: "shape text 2", name: "display two"}, {shapetext: "shape text 3", name: "display three"}, ], selectedDisplay: {} } }) ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script> <div id="app"> <h2>Selected Display</h2> <select v-model="selectedDisplay"> <option value="" disabled>Please Choose One</option> <option v-for="display in displays" :value="display" >{{display.name}}</option> </select> <hr> Selected Display shapetext: {{selectedDisplay.shapetext}} <br> Selected Display name: {{selectedDisplay.name}} </div> ```
Question: This is probably overkill for my problem, but I am curious about the answer. I have a matrix of `np.float32` values that I want to put into some code. It's 50x3 so I want to just put it in the source directly - it's not something that will change often. It's a little sensitive to rounding, so I want to encode the data *exactly* if possible. Is there a good way to do this in the source while also preserving the matrix format? I'm thinking something along the lines of putting [[0xC45B36F3, ...],...] and somehow encoding that to a `np.float32`. Answer:
If you chose to encode the integer values, you could then do: ``` int_data = np.array([[0xC45B36F3, ...],...], dtype=np.uint32) floats = int_data.view(np.float32) ```
Why don't you use the [`numpy.save`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html#numpy.save) builtin? I've tried it with several float32 inputs and the [`numpy.load`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.load.html#numpy.load) had no rounding issues. Or is there any reason why you can't or don't want to do it that way?
Question: This is probably overkill for my problem, but I am curious about the answer. I have a matrix of `np.float32` values that I want to put into some code. It's 50x3 so I want to just put it in the source directly - it's not something that will change often. It's a little sensitive to rounding, so I want to encode the data *exactly* if possible. Is there a good way to do this in the source while also preserving the matrix format? I'm thinking something along the lines of putting [[0xC45B36F3, ...],...] and somehow encoding that to a `np.float32`. Answer:
Why don't you use the [`numpy.save`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html#numpy.save) builtin? I've tried it with several float32 inputs and the [`numpy.load`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.load.html#numpy.load) had no rounding issues. Or is there any reason why you can't or don't want to do it that way?
You can convert the matrix `m` in bytes : ``` m.tobytes() ``` Then you paste the bytes it in your code : ``` data=b'\x34f\xd3.......paste the 4*50*3 bytes here ......\x12' ``` After you can reconstruct the exact matrix : ``` m=matrix(frombuffer(data,float32).reshape(50,3)) ``` without any loss.
Question: This is probably overkill for my problem, but I am curious about the answer. I have a matrix of `np.float32` values that I want to put into some code. It's 50x3 so I want to just put it in the source directly - it's not something that will change often. It's a little sensitive to rounding, so I want to encode the data *exactly* if possible. Is there a good way to do this in the source while also preserving the matrix format? I'm thinking something along the lines of putting [[0xC45B36F3, ...],...] and somehow encoding that to a `np.float32`. Answer:
If you chose to encode the integer values, you could then do: ``` int_data = np.array([[0xC45B36F3, ...],...], dtype=np.uint32) floats = int_data.view(np.float32) ```
You can convert the matrix `m` in bytes : ``` m.tobytes() ``` Then you paste the bytes it in your code : ``` data=b'\x34f\xd3.......paste the 4*50*3 bytes here ......\x12' ``` After you can reconstruct the exact matrix : ``` m=matrix(frombuffer(data,float32).reshape(50,3)) ``` without any loss.
Question: Let $a=\{a\_n\}\_{n\geq 0}$ be a sequence of positive real numbers with $a\_n\leq 1$, for all $n$, and observe that, for any real number $s\in [0,1)$, one has that $$ \sum\_{n=0}^\infty a\_ns^n \leq \sum\_{n=0}^\infty s^n = \frac 1 {1-s}. $$ Therefore the function $f\_a$ defined by $$ f\_a(s) = (1-s)\sum\_{n=0}^\infty a\_ns^n, \quad \forall s\in [0,1), $$ is bounded by 1. My main interest is to discuss the existence of the limit of $f\_a$ as $s$ tends to 1 from the left, namely $$ \lim\_{s\to 1\_-} (1-s)\sum\_{n=0}^\infty a\_ns^n. $$ Plugging in most naive examples of sequences $\{a\_n\}$, one would be tempted to conjecture that the limit always exists, but I've been shown examples where it doesn't. My gut impression is that this problem belongs to some well established theory, perhaps related to analytic number theory and this is precisely what brings me here. **Question**. Is there a particular point of view in Math from where the existence of the above limit has been discussed? Answer:
Let me give the condensed perspective: Regarding $A$ as a discrete condensed ring, I think the structure of the "internal spectrum" is codified by the functor that takes any extremally disconnected profinite set $S$ to the poset of sheaves of prime ideals in the constant sheaf on $A$ over $S$. (One could forget the poset structure and regard it only as a condensed set. I will comment below what structure this remembers.) Here, a "sheaf of prime ideals" is defined to be a sheaf of ideals $I$ of $A$ together with a sheaf of multiplicative subsets $M$ of $A$ such that the map $I\sqcup M\to A$ is an isomorphism (of sheaves of sets); I hope this is the correct way to talk about "internal prime ideals"? I claim that this is the "correct" answer to this question. Recall that Makkai's conceptual completeness theorem as explained by Lurie in his course on categorical logic, or by Barwick-Glasman-Haine in their work on exodromy, gives a fully faithful embedding of the category of coherent locales (aka spectral spaces) to condensed posets. In one direction, this takes any coherent locale to the condensed category of points. Summary: The spectrum of a ring is naturally a spectral space, i.e. coherent locale, so determined by its condensed poset of points. This is precisely the spectrum of $A$ as constructed internally in condensed sets. Addendum: If one forgets the poset structure and only looks at the condensed set of prime ideals, one actually ends up getting a condensed set that is representable by a profinite set, which is precisely $\mathrm{Spec}(A)$ with its constructible topology.
New answer, following up on Zhen Lin's comment for the "good" definition of prime filter. Sorry for the confusion! A prime filter in a ring $A$ is a multiplicatively closed subset $S$ of $A$ (containing $1$) such that if $a+b\in S$, then $a\in S$ or $b\in S$. This definition makes sense internally in a topos. And it is almost a tautology that the category of sheaves on $\mathrm{Spec}(A)$ is precisely the classifying topos for prime filters in $A$ (where the universal prime filter is the sheaf of units of the structure sheaf). In particular, if $X$ is any topological space, then continuous morphisms from $X$ to $\mathrm{Spec}(A)$ are equivalent to prime filters on the constant sheaf on $A$ on $X$. In particular, working on the big site of topological spaces, the space of prime filters on the constant sheaf on $A$ gives precisely the topological space $\mathrm{Spec}(A)$. (You could also work in pyknotic sets instead, and get the pyknotic space associated to $\mathrm{Spec}(A)$. Or work in Johnstone's topos, and get the sequential space...)
Question: I am using notepad++ and trying to find/replace occurrences of a particular word in an XML file with another word inside a particular tag. For example: XML file contains ``` <alerts> <ccEmails>abc@example.com,xyz@example.com</ccEmails> <toEmails>mnp@example.com</toEmails> </alerts> ``` I need to replace **example** with **myexample** present inside`<ccEmails>` but **not** inside`<toEmails>` I tried `ccEmails.*(example).*ccEmails` at <https://regex101.com/r/Q8UB6a/1>, and it is returning only last occurrence. Also, I am not able to replace the string with another there. When I tried this in notepad++, I am getting all the string inside `<ccEmails>` [![enter image description here](https://i.stack.imgur.com/SBcvN.png)](https://i.stack.imgur.com/SBcvN.png) Could you please help me in find/replace the substring contained within particular tags. Please let me know if more details are required. Answer:
If you plan to use the Find and replace dialog, you need to use a `\G` based regex like ``` (?:<ccEmails>|\G(?!^))[^<]*?\K\bexample\b ``` and replace with `myexample`. See an [online regex demo.](https://regex101.com/r/pMpzIj/2) **Details**: * `(?:<ccEmails>|\G(?!^))` - either `<ccEmails>` or the end of the last successful match * `[^<]*?` - any 0+ chars other than `<` as few as possible * `\K` - omit the text matched so far -`\bexample\b` - whole word `example`. [![enter image description here](https://i.stack.imgur.com/5fKvc.png)](https://i.stack.imgur.com/5fKvc.png)
Replace `(<ccEmails>[^<>]+@)example\.` with `\1myexample.` and doing a replace all. The replace-all will need to be done two or more times as each pass only changes one `example` within the required strings.
Question: Sending the following request (notice the encoded id in the query string) but the server gets just "law". Any ideas as to what I'm missing? ``` string url = "http://localhost/api/cms/content/?id=law&amp;Order@the#house!"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { ... } ``` Answer:
The problem is `&amp;` is not a "query string encoding" - it is an XML/HTML entity-escape and the server (correctly) breaks the id parameter at the `&` in the query string. The server cares about URLs, not XML. See [Percent Encoding (aka URI encoding)](http://en.wikipedia.org/wiki/Percent-encoding) for how to *correctly*1 write the URL which is ```none ..content/?id=law%26Order%40the%23house%21 ``` --- 1 The actual rules are a bit more complex (ie. the `@`, `!`, and `;` did not need to be encoded) - as "reserved characters that have no reserved purpose in a particular context may also be percent-encoded but are not semantically different from those that are not". For details, see [What every web developer must know about URL encoding](http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding) which provides a good review and some guidelines on how to correctly construct URLs.
``` ! # $ & ' ( ) * + , / : ; = ? @ [ ] %21 %23 %24 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B %3D %3F %40 %5B %5D ``` Here how you should encode it the query string. Here for your case: ``` http://localhost/api/cms/content/?id=law%26Order%40the%23house%21 ```
Question: Sending the following request (notice the encoded id in the query string) but the server gets just "law". Any ideas as to what I'm missing? ``` string url = "http://localhost/api/cms/content/?id=law&amp;Order@the#house!"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { ... } ``` Answer:
The problem is `&amp;` is not a "query string encoding" - it is an XML/HTML entity-escape and the server (correctly) breaks the id parameter at the `&` in the query string. The server cares about URLs, not XML. See [Percent Encoding (aka URI encoding)](http://en.wikipedia.org/wiki/Percent-encoding) for how to *correctly*1 write the URL which is ```none ..content/?id=law%26Order%40the%23house%21 ``` --- 1 The actual rules are a bit more complex (ie. the `@`, `!`, and `;` did not need to be encoded) - as "reserved characters that have no reserved purpose in a particular context may also be percent-encoded but are not semantically different from those that are not". For details, see [What every web developer must know about URL encoding](http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding) which provides a good review and some guidelines on how to correctly construct URLs.
Please be sure to encode your characters in the url for example ('&')is "%26" this is called reserved characters Like : ! # $ ' ( ) \* + , / : ; = ? @ [ ] check this url plz <http://www.w3schools.com/tags/ref_urlencode.asp>
Question: Sending the following request (notice the encoded id in the query string) but the server gets just "law". Any ideas as to what I'm missing? ``` string url = "http://localhost/api/cms/content/?id=law&amp;Order@the#house!"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { ... } ``` Answer:
The problem is `&amp;` is not a "query string encoding" - it is an XML/HTML entity-escape and the server (correctly) breaks the id parameter at the `&` in the query string. The server cares about URLs, not XML. See [Percent Encoding (aka URI encoding)](http://en.wikipedia.org/wiki/Percent-encoding) for how to *correctly*1 write the URL which is ```none ..content/?id=law%26Order%40the%23house%21 ``` --- 1 The actual rules are a bit more complex (ie. the `@`, `!`, and `;` did not need to be encoded) - as "reserved characters that have no reserved purpose in a particular context may also be percent-encoded but are not semantically different from those that are not". For details, see [What every web developer must know about URL encoding](http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding) which provides a good review and some guidelines on how to correctly construct URLs.
The problem is & is not a "query string encoding" - it is an XML/HTML entity-escape Use it like this: ```js string url = "http://localhost/api/cms/content/?id=law&Order@the#house!"; ``` works for me
Question: Sending the following request (notice the encoded id in the query string) but the server gets just "law". Any ideas as to what I'm missing? ``` string url = "http://localhost/api/cms/content/?id=law&amp;Order@the#house!"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { ... } ``` Answer:
``` ! # $ & ' ( ) * + , / : ; = ? @ [ ] %21 %23 %24 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B %3D %3F %40 %5B %5D ``` Here how you should encode it the query string. Here for your case: ``` http://localhost/api/cms/content/?id=law%26Order%40the%23house%21 ```
The problem is & is not a "query string encoding" - it is an XML/HTML entity-escape Use it like this: ```js string url = "http://localhost/api/cms/content/?id=law&Order@the#house!"; ``` works for me
Question: Sending the following request (notice the encoded id in the query string) but the server gets just "law". Any ideas as to what I'm missing? ``` string url = "http://localhost/api/cms/content/?id=law&amp;Order@the#house!"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { ... } ``` Answer:
Please be sure to encode your characters in the url for example ('&')is "%26" this is called reserved characters Like : ! # $ ' ( ) \* + , / : ; = ? @ [ ] check this url plz <http://www.w3schools.com/tags/ref_urlencode.asp>
The problem is & is not a "query string encoding" - it is an XML/HTML entity-escape Use it like this: ```js string url = "http://localhost/api/cms/content/?id=law&Order@the#house!"; ``` works for me