prompt stringlengths 48 2.37k | chosen stringlengths 7 4.28k | rejected stringlengths 11 4.44k |
|---|---|---|
Question: How does a Stack Overflow moderator know about sock puppet accounts?
How do they trap the user?
Answer: | I am not going to answer this directly, for reasons that should be obvious.
However; this isn't a "trap" - it is our attempt at *enforcing reasonable behaviour*; using a sock-puppet for *any purpose* (most commonly, but not exclusively: upvoting yourself) is unacceptable.
If you want the vote of the masses; write goo... | They have ways of finding pretty much any kind of sock puppets using their sites...
 |
Question: How does a Stack Overflow moderator know about sock puppet accounts?
How do they trap the user?
Answer: | I am not going to answer this directly, for reasons that should be obvious.
However; this isn't a "trap" - it is our attempt at *enforcing reasonable behaviour*; using a sock-puppet for *any purpose* (most commonly, but not exclusively: upvoting yourself) is unacceptable.
If you want the vote of the masses; write goo... | Actions speak louder than IP address… Possibly even a “view” of a question is an action. |
Question: How does a Stack Overflow moderator know about sock puppet accounts?
How do they trap the user?
Answer: | I am not going to answer this directly, for reasons that should be obvious.
However; this isn't a "trap" - it is our attempt at *enforcing reasonable behaviour*; using a sock-puppet for *any purpose* (most commonly, but not exclusively: upvoting yourself) is unacceptable.
If you want the vote of the masses; write goo... | You know, throughout your posts here, you keep referring to this as a "bug" or a "trap". It's not a bug at all; it's a *feature* designed to prevent people from abusing the site. **Which is exactly what you were doing.**
In your comments on Marc's answer, you complain that your friend "Nahid" got her account merged du... |
Question: How does a Stack Overflow moderator know about sock puppet accounts?
How do they trap the user?
Answer: | They have ways of finding pretty much any kind of sock puppets using their sites...
 | Actions speak louder than IP address… Possibly even a “view” of a question is an action. |
Question: How does a Stack Overflow moderator know about sock puppet accounts?
How do they trap the user?
Answer: | You know, throughout your posts here, you keep referring to this as a "bug" or a "trap". It's not a bug at all; it's a *feature* designed to prevent people from abusing the site. **Which is exactly what you were doing.**
In your comments on Marc's answer, you complain that your friend "Nahid" got her account merged du... | Actions speak louder than IP address… Possibly even a “view” of a question is an action. |
Question: I've got my first RoR app deployed to Dreamhost and it's using Passenger. The one note on Dreamhost's wiki about slow response mentioned changing a RewriteRules line in the public/.htaccess file to use FastCGI. But I assume this will have no effect if I'm using Passenger, is that right?
I've looked at the lo... | You must be running in Development mode. Try running in Production mode to see if it is still slow.
Post below may help:
[Ruby On Rails is slow...?](https://stackoverflow.com/questions/566401/ruby-on-rails-is-slow) | [New Relic](http://www.newrelic.com/) is a Rails performance monitoring app. I haven't personally used it, but I hear their name a lot and it looks like they have a free lite version that you could try. From my experience profiling other applications, a tool like this is worth using because the slow parts of your appli... |
Question: I can't find a way to toggle mc internal editor in hex mode. [Here](http://www.tldp.org/LDP/LG/issue23/wkndmech_dec97/mc_article.html) it says to use F4 however it suggest to replace. How to do it?
Answer: | You can open file with `F3`.
Hex view - `F4`.
Start edit - `F2`. | `F4` toggles hex mode in the Midnight Commander **viewer** (accessed using `F3`), not in the editor. Once in hex mode in the viewer, `F2` allows you to make changes to the file being viewed.
As you discovered, `F4` in the editor starts a search. |
Question: I'm getting crazy, cause I cannot find what are the "default" keys you would have in a PDF Document.
For example, if I want to retrieve an hyperlink from a CGPDFDocument, I do this:
```
CGPDFStringRef uriStringRef;
if(!CGPDFDictionaryGetString(aDict, "URI", &uriStringRef)) {
break;
}
```
In this case,... | The [Adobe PDF Reference](http://www.adobe.com/devnet/pdf/pdf_reference_archive.html) describes all of the keys. | The keys in a dictionary depend on the actual object the dictionary represents (a page dictionary has other keys than an annotation dictionary). The Adobe PDF reference describes all these objects and their keys. |
Question: I'm getting crazy, cause I cannot find what are the "default" keys you would have in a PDF Document.
For example, if I want to retrieve an hyperlink from a CGPDFDocument, I do this:
```
CGPDFStringRef uriStringRef;
if(!CGPDFDictionaryGetString(aDict, "URI", &uriStringRef)) {
break;
}
```
In this case,... | It's absurd that you would have to go read 1300 page long specs just to find what keys a dictionary contains, a dictionary that could contain anything depending on what kind of annotation it is.
To get a list of keys in a `CGPDFDictionaryRef` you do:
```
// temporary C function to print out keys
void printPDFKeys(con... | The [Adobe PDF Reference](http://www.adobe.com/devnet/pdf/pdf_reference_archive.html) describes all of the keys. |
Question: I'm getting crazy, cause I cannot find what are the "default" keys you would have in a PDF Document.
For example, if I want to retrieve an hyperlink from a CGPDFDocument, I do this:
```
CGPDFStringRef uriStringRef;
if(!CGPDFDictionaryGetString(aDict, "URI", &uriStringRef)) {
break;
}
```
In this case,... | It's absurd that you would have to go read 1300 page long specs just to find what keys a dictionary contains, a dictionary that could contain anything depending on what kind of annotation it is.
To get a list of keys in a `CGPDFDictionaryRef` you do:
```
// temporary C function to print out keys
void printPDFKeys(con... | The keys in a dictionary depend on the actual object the dictionary represents (a page dictionary has other keys than an annotation dictionary). The Adobe PDF reference describes all these objects and their keys. |
Question: This is the HTML I want to extract from.
```
<input type="hidden" id="continueTo" name="continueTo" value="/oauth2/authz/?response_type=code&client_id=localoauth20&redirect_uri=http%3A%2F%2Fbg-sip-activemq%3A8080%2Fjbpm-console%2Foauth20Callback&state=72a37ba7-2033-47f4-8e7e-69a207406dfb" />
```
I need a X... | The XPATH:
```
//input[@id="continueTo"]/@value
```
It will get the value of the node `input` with id `continueTo`. Then it will need to be processed with a Regex first to get a final result.
The Regex:
```
`[^=]+$`
```
`$` means the end of the string. It will get everything on the end of the string which is not... | Use below code:-
```
String val = driver.findElement(By.xpath("//input[@id='continueTo']/@value")).getText();
String [] myValue = val.split("&state=");
System.out.println(myValue[1]);
```
Hope it will help you :) |
Question: This is the HTML I want to extract from.
```
<input type="hidden" id="continueTo" name="continueTo" value="/oauth2/authz/?response_type=code&client_id=localoauth20&redirect_uri=http%3A%2F%2Fbg-sip-activemq%3A8080%2Fjbpm-console%2Foauth20Callback&state=72a37ba7-2033-47f4-8e7e-69a207406dfb" />
```
I need a X... | Hi you can only get value of a attribute using xpath not its sub-string but if you want to get sub-string then please do it like below
```
String AttributeValue = driver.findElement(By.id("continueTo")).getAttribute("value");
System.out.println("Value of the attribute value is : " + AttributeValue);
// now as yo... | Use below code:-
```
String val = driver.findElement(By.xpath("//input[@id='continueTo']/@value")).getText();
String [] myValue = val.split("&state=");
System.out.println(myValue[1]);
```
Hope it will help you :) |
Question: I am working on node.js where forever is installed. I am not sure where is intalled . when i go to project directory then type command `forever list` then it will display no forever
Can any body tell me how to check and how to resart processes.
My website is running. it means forever may be running
Answe... | If `forever list` is empty, your nodeJS app is not running.
You have to start it first by doing `forever start yourApp.js` | You have to install forever with sudo. |
Question: I'm starting a VPN connection using Network Manager.
Once the connection is established I have to change [MTU](http://en.wikipedia.org/wiki/Maximum_transmission_unit) in order it to work properly.
For example:
```
sudo ifconfig ppp0 mtu 777
```
It is very annoying to execute this command every time I open ... | Create a script in `/etc/network/if-up.d`, containing
```
#!/bin/sh
if [ "$IFACE" = "ppp0" ]; then
ifconfig ppp0 mtu 777
fi
```
and [make it executable](https://askubuntu.com/questions/122428/how-to-run-sh-file). | Here's a modernized (using `ip` instead of `ifconfig`) and generic (`openconnect` on the command-line uses `tun0`, Network Manager uses `vpn0` through the network applet; the numbers may vary if another network is already active) variant of @enzotib's excellent answer, tested on Ubuntu 20.04:
```
#!/bin/bash
if [[ "$... |
Question: Sorry for the very noob question.
Let's suppose I have an enum like so
```
public enum MyElementType {
TYPE_ONE,
TYPE_TWO,
TYPE_THREE;
}
```
When I want to loop over this enum, I always see this solution:
```
for(MyElementType type: MyElementType.values())
{
//do things
}
```
I wonder if there exist a v... | Why do you want to use a while loop rather than the for-each you more typically see?
In any case, it's pretty simple
```
Set<MyElementType> elements = EnumSet.allOf(MyElementType.class);
Iterator<MyElementType> it = elements.iterator();
while (it.hasNext()) {
MyElementType el = it.next();
// etc
}
// or
Iter... | Take a look @ <http://www.javaspecialists.eu/archive/Issue107.html> |
Question: Consider an application that currently uses a combination of license file and/or subscription to verify which features to activate. I can use a smart contract instead of the license file, and potentially the subscription. But today, the subscription check requires an online validation and associated credentia... | When your app is able to sync with the blockchain (network connection available), the check the blockchain and update your app settings file to allow use for up to e.g. 1 week after the blockchain subscription check. Just tell the user that they have to sync before the period is up.
One extra feature you can add:
* Y... | If you want to get up-to-date information from the Ethereum blockchain then you'll need a node somewhere that's synced up. However, in theory you could do this with either a trusted server or a more lightweight proof so you wouldn't necessarily need the whole chain to be downloaded to the client.
If you can tolerate p... |
Question: I ask this as someone who loves maths but has no ability. So 2 axioms & a question.
Axiom 1 - a digital processor exists that can find the n'th prime number of any size instantly.
Axiom 2 - all natural numbers can be expressed as the sum of 2 primes.
Would it take more/less/same amount of bits to define a n... | The ordinary way of storing natural numbers by means of bits is already optimal. This can easily be seen: Each of the $2^n$ combinations of assignments of $n$ bits represents exactly one distinct natural number between $0$ and $2^n-1$. If there was a way of storing more numbers with the same amount of bits, and we woul... | In this reference, <https://en.m.wikipedia.org/wiki/Goldbach%27s_conjecture>
they give a nineteen digit number whose lower prime must be at least 9781.
The $n$th prime is about $n\ln n$ so you save a factor of 42, or about six bits, by storing the index of the larger prime. But 9781 is about the 1000th prime, so you... |
Question: I'm working through Example 2.22 in Steward and Tall's Algebraic Number Theory book. The goal is to determine the ring of integers of $\mathbb Q(\sqrt[3]5)$. Let $\theta\in\mathbb R$ such that $\theta^3=5$. Let $\omega=e^{2\pi i/3}$. I'm at the point where I need to check whether
$$
\alpha=\frac 13(1+\theta+\... | [](https://i.stack.imgur.com/7hWo2.png)
As pointed out by dezdichado, the problem can be done by two applications of Cosine Formula.
Refer to the figure,
One such formula is:
$$\cos \alpha=\frac{(c-x)^2+y^2-a^2}{2(c-x)y}$$
Applying Cosine Formula ... | I have an idea to start :
In $\Bbb C, A=0, B=1, C=\xi +i\eta, D=x$
Unfortunately, none of my calculations succeed, although simplifications appear: I suspect that there is a sign error in the proposed equality. |
Question: I want my marker to appear not in the center of the screen, but 25% of the way up to give extra room for the popup box. Although sticking an offset in is easy, the offset depends on the zoom level as if you're zoomed far out, you'll want to center the map quite far up (such as 50km). If you're really zoomed i... | Try this:
Take the height of the plugin and get 25% of that.
Then you need to multiply that by the degrees or kilometres per pixel scale at that height (if you can't get it straight from the plugin then I guess do the math), then centre the screen at that point on the globe. | I am not sure as it has been a while since I messed around with the API, but I think you can create a custom marker object with its own pixel based offset, and display that instead of the default marker.
EDIT: Whoops read it again and realized you probably just wanted to move the whole map and not the marker. |
Question: I know this is a very classical question which might be answered many times in this forum, however I could not find any clear answer which explains this clearly from scratch.
Firstly, imgine that my dataset called my\_data has 4 variables such as
my\_data = variable1, variable2, variable3, target\_variable
... | First off, you are using the deprecated package `cross-validation` of scikit library. New package is named `model_selection`. So I am using that in this answer.
Second, you are importing `RandomForestRegressor`, but defining `RandomForestClassifier` in the code. I am taking `RandomForestRegressor` here, because the me... | Also in the for loop it should be:
```
model = RandomForestRegressor(n_estimators=100)
for train_index, test_index in cv.split(X):
``` |
Question: Requirements for a TextBox control were to accept the following as valid inputs:
1. A sequence of numbers.
2. Literal string 'Number of rooms'.
3. No value at all (left blank). Not specifying a value at all should allow for the RegularExpressionValidator to pass.
Following RegEx yielded the desired results... | The order matters since that is the order which the Regex engine will try to match.
Case 1: `Number of rooms|[0-9]*`
In this case the regex engine will first try to match the text "Number of room". If this fails will then try to match numbers or nothing.
Case 2: `[0-9]*|Number of rooms`:
In this case the engine wil... | The point is that the `[0-9]*` at the beginning is matching empty strings if you specify that first.
If you specify that *the whole string* should be digits, then it should work:
```
^[0-9]*$|Number of rooms
```
Unless you specify `^` and `$`, to indicate that *the whole string* must be a match, an empty string w... |
Question: Requirements for a TextBox control were to accept the following as valid inputs:
1. A sequence of numbers.
2. Literal string 'Number of rooms'.
3. No value at all (left blank). Not specifying a value at all should allow for the RegularExpressionValidator to pass.
Following RegEx yielded the desired results... | The order matters since that is the order which the Regex engine will try to match.
Case 1: `Number of rooms|[0-9]*`
In this case the regex engine will first try to match the text "Number of room". If this fails will then try to match numbers or nothing.
Case 2: `[0-9]*|Number of rooms`:
In this case the engine wil... | You probably wanted to use regex `Number of rooms|[0-9]+` or `[0-9]+|Number of rooms`, because pattern `[0-9]*` (with star) will always match at least empty string (`*` means `{0,}`, so "zero or more..."). |
Question: I am trying to round the corners of a custom shape, but it is just straightening the original curves out.
*Note: This is in Illustrator CS5*
**Here is the shape before the effect:**
[](https://i.stack.imgur.com/luohd.png)
The 3 "corners s... | I don't have CS5, but this should work:
Select your path. With the pen tool selected, create points on each side of the anchor points, something like the following:
[](https://i.stack.imgur.com/U3Mk7.png)
With the... | My way is easier if you have good experience with the pen tool.
First, make your triangle. In my case, I just made a box, deleted 1 anchor point, joined the two points creating a segment opposite to the middle point and rotated about 45 degrees (please correct me if I'm wrong).
[](https://i.stack.imgur.com/luohd.png)
The 3 "corners s... | I don't have CS5, but this should work:
Select your path. With the pen tool selected, create points on each side of the anchor points, something like the following:
[](https://i.stack.imgur.com/U3Mk7.png)
With the... | The simple way:
Create additional anchor points around cornes (as it was mentioned at first answer), then apply Round Corner effect as usual. |
Question: I am trying to round the corners of a custom shape, but it is just straightening the original curves out.
*Note: This is in Illustrator CS5*
**Here is the shape before the effect:**
[](https://i.stack.imgur.com/luohd.png)
The 3 "corners s... | I don't have CS5, but this should work:
Select your path. With the pen tool selected, create points on each side of the anchor points, something like the following:
[](https://i.stack.imgur.com/U3Mk7.png)
With the... | **Purely for comparison’s sake**, I thought it would be good to show what Adobe Illustrator CC (in this case, I am using v2017) can do:
[](https://i.stack.imgur.com/8d2hQ.gif)
1. With the selection tool, select your entire path
2. On a Mac, hold down... |
Question: I am trying to round the corners of a custom shape, but it is just straightening the original curves out.
*Note: This is in Illustrator CS5*
**Here is the shape before the effect:**
[](https://i.stack.imgur.com/luohd.png)
The 3 "corners s... | **Purely for comparison’s sake**, I thought it would be good to show what Adobe Illustrator CC (in this case, I am using v2017) can do:
[](https://i.stack.imgur.com/8d2hQ.gif)
1. With the selection tool, select your entire path
2. On a Mac, hold down... | My way is easier if you have good experience with the pen tool.
First, make your triangle. In my case, I just made a box, deleted 1 anchor point, joined the two points creating a segment opposite to the middle point and rotated about 45 degrees (please correct me if I'm wrong).
[](https://i.stack.imgur.com/luohd.png)
The 3 "corners s... | **Purely for comparison’s sake**, I thought it would be good to show what Adobe Illustrator CC (in this case, I am using v2017) can do:
[](https://i.stack.imgur.com/8d2hQ.gif)
1. With the selection tool, select your entire path
2. On a Mac, hold down... | The simple way:
Create additional anchor points around cornes (as it was mentioned at first answer), then apply Round Corner effect as usual. |
Question: I use a custom hook to support dark mode with tailwindcss in my new react-native app, created with Expo CLI. The TailwindProvider with the dark mode logic looks like this:
```js
const TailwindProvider: React.FC = ({ children }) => {
const [currentColorScheme, setcurrentColorScheme] = useState(Appearance.ge... | Use `systimestamp` since that includes a time zone.
```
select systimestamp at time zone 'US/Eastern'
from dual;
```
should return a timestamp in the Eastern time zone (assuming your database time zone files are up to date).
Note that if you ask for a timestamp in EST, that should be an hour earlier than the curr... | Use `systimestamp` rather than `sysdate`, because it is already timezone-aware; then `at time zone` to translate:
```
select systimestamp at time zone 'America/New_York' from dual
```
Using a region is better/safer than an abbreviation like 'EST", which might not be unique; and [gives you the wrong answer](https://d... |
Question: I use a custom hook to support dark mode with tailwindcss in my new react-native app, created with Expo CLI. The TailwindProvider with the dark mode logic looks like this:
```js
const TailwindProvider: React.FC = ({ children }) => {
const [currentColorScheme, setcurrentColorScheme] = useState(Appearance.ge... | Use `systimestamp` rather than `sysdate`, because it is already timezone-aware; then `at time zone` to translate:
```
select systimestamp at time zone 'America/New_York' from dual
```
Using a region is better/safer than an abbreviation like 'EST", which might not be unique; and [gives you the wrong answer](https://d... | If you really want to use `SYSDATE` then you can use:
```sql
SELECT from_tz(CAST(sysdate AS TIMESTAMP),'PST') AT TIME ZONE 'EST5EDT' FROM DUAL;
```
Which outputs:
>
>
> ```
>
> | FROM_TZ(CAST(SYSDATEASTIMESTAMP),'PST')ATTIMEZONE'EST5EDT' |
> | :--------------------------------------------------------- |
> | 02-A... |
Question: I use a custom hook to support dark mode with tailwindcss in my new react-native app, created with Expo CLI. The TailwindProvider with the dark mode logic looks like this:
```js
const TailwindProvider: React.FC = ({ children }) => {
const [currentColorScheme, setcurrentColorScheme] = useState(Appearance.ge... | Use `systimestamp` since that includes a time zone.
```
select systimestamp at time zone 'US/Eastern'
from dual;
```
should return a timestamp in the Eastern time zone (assuming your database time zone files are up to date).
Note that if you ask for a timestamp in EST, that should be an hour earlier than the curr... | If you really want to use `SYSDATE` then you can use:
```sql
SELECT from_tz(CAST(sysdate AS TIMESTAMP),'PST') AT TIME ZONE 'EST5EDT' FROM DUAL;
```
Which outputs:
>
>
> ```
>
> | FROM_TZ(CAST(SYSDATEASTIMESTAMP),'PST')ATTIMEZONE'EST5EDT' |
> | :--------------------------------------------------------- |
> | 02-A... |
Question: (<https://webapps.stackexchange.com/review/suggested-edits/111499> shows action by both.) [Edit: At first glance they both looked like special users. Not so.]
Answer: | Community♦ is [a special user](https://meta.stackexchange.com/questions/19738/who-is-the-community-user). Community is credited for reviews when they are:
* Done by deleted users
* Improved, in which case Community is shown as having approved the edit
* Rejected and edited, in which case Community is shown as having r... | A key difference is that their real user numbers, respectively, are -1 for Community♦ and 186471 for user0 (on webapps, and thus *not* 0), as can be seen in the URL (classically displayed in a browser's status bar when mousing over the usernames) that clicking on the name opens.
[Community♦](https://stackexchange.com... |
Question: My project can switch between languages. The items are stored in a database, and using $\_GET['lang'] in the database gives back the correct items. For now, only English and French are in use, so it works with this code :
```
if ($_GET['lang'] == 'fr' OR ($_GET['lang'] == 'en')) {
$header = getTranslatio... | You should move the else part outside of the loop, as otherwise you will always execute it at some point in the loop iterations. Only when you have iterated through *all* possibilities, and you still have no match, then you can be sure there to have to navigate to the language page:
```
$header = null;
while ($transla... | Easiest is to have a mapping in an array, check if your language is present there, and if so, do stuff. Something like this;
```
$languages = array('en', 'fr', 'de', '...');
$default_language = 'en';
$language = in_array($_GET['lang'], $languages) ? $_GET['lang'] : $default_language;
$header = getTranslation('header'... |
Question: I have a list of strings (see below) how do I concatenate these strings into one list containing one string.
```
["hello","stack","overflow"]
```
to
```
["hellostackoverflow"]
```
I am just allowed to import Data.Char and Data.List
Answer: | Consider each string in a list as a list of characters
```
["hello","stack","overflow"] :: [[Char]]
```
Concatenation is a process of connecting several lists into one. It must have a following type:
```
concat :: [[a]] -> [a]
```
If you will have such a function, you'll get a half of job done. You are looking fo... | You can also use the list monad to reduce the list to a single string, then re-wrap the result in a list.
```
> [["hello", "stack", "overflow"] >>= id]
["hellostackoverflow"]
```
The preceding avoids explicitly use of `Control.Monad.join`:
```
> import Control.Monad
> [join ["hello", "stack", "overflow"]
["hellosta... |
Question: I have a list of strings (see below) how do I concatenate these strings into one list containing one string.
```
["hello","stack","overflow"]
```
to
```
["hellostackoverflow"]
```
I am just allowed to import Data.Char and Data.List
Answer: | Consider each string in a list as a list of characters
```
["hello","stack","overflow"] :: [[Char]]
```
Concatenation is a process of connecting several lists into one. It must have a following type:
```
concat :: [[a]] -> [a]
```
If you will have such a function, you'll get a half of job done. You are looking fo... | ```hs
concat ["hello","stack","overflow"] -- => "hellostackoverflow"
``` |
Question: I have a list of strings (see below) how do I concatenate these strings into one list containing one string.
```
["hello","stack","overflow"]
```
to
```
["hellostackoverflow"]
```
I am just allowed to import Data.Char and Data.List
Answer: | ```hs
concat ["hello","stack","overflow"] -- => "hellostackoverflow"
``` | You can also use the list monad to reduce the list to a single string, then re-wrap the result in a list.
```
> [["hello", "stack", "overflow"] >>= id]
["hellostackoverflow"]
```
The preceding avoids explicitly use of `Control.Monad.join`:
```
> import Control.Monad
> [join ["hello", "stack", "overflow"]
["hellosta... |
Question: Here T could be an array or a single object. How can add the array to an arraylist or add a single object to the same arraylist. This gives me a build-time error that the overloaded match for `AddRange` has invalid arguments.
```
T loadedContent;
if (typeof(T).IsArray)
{
contentArrayList.AddRange(loadedC... | Make sure you have set the correct editor associations and content types
Go to settings (`Window -> preferences`)
**Content Types**
1. Type in `Content Types` in the search box (should show under `General -> Types`
2. Click on the arrow next to `Text`, select `PHP Content Type`
3. Add `*.ctp` by clicking on the Add ... | You can change the extension that CakePHP uses for view files to an extension that Eclipse likes. In the controller (or app\_controller) add the following variable:
```
var $ext = '.tpl';
```
If you change the extension to "PHP" you may have problems because CakePHP will try to load a class that matches the filename... |
Question: I've tried connecting a camera to my Raspberry Pi and I've enabled it on `raspi-config` but `vcgencmd get_camera` still shows `supported=0` `detected=0`. Also, in my `boot/config.txt`, `start_x=1` is not even commented nor enabled upon enabling camera interface. Another thing to note is my Raspberry Pi consta... | Thanks to the comments, I have rectified the issue. The issue was with the bullseye version of the os. I used a buster version and it worked just fine | 1. [Check first if the camera is supported](http://elinux.org/RPi_VerifiedPeripherals#USB_Webcams)
2. Try a powered USB hub to plug in the camera / maybe it isnt getting enough power
Then you can install this tool to test out the camera `sudo apt-get install luvcview` |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | For each result in the result set, create a `new Bike()` and copy the values from that result to the new bikes fields. At the end, add the bike to the list.
```
Bike bike = new Bike()
bike.setName(rs.getString("name"));
//...
bikeList.add(bike);
``` | you would instantiate a Bike object and set properties that you read from result set, then add the bike object to your arraylist, isnt it what you are looking for? |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | For each result in the result set, create a `new Bike()` and copy the values from that result to the new bikes fields. At the end, add the bike to the list.
```
Bike bike = new Bike()
bike.setName(rs.getString("name"));
//...
bikeList.add(bike);
``` | You have Banana in your hand..just eat it :)
Create a empty list and in iteration Create new Bike and add into the List.
```
List<Bike> bikes = new ArrayList<Bikes>();
while(rs.next())
{
Bike bike = new Bike();
bike.setname( rs.getString("name"));
//other prope... |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | For each result in the result set, create a `new Bike()` and copy the values from that result to the new bikes fields. At the end, add the bike to the list.
```
Bike bike = new Bike()
bike.setName(rs.getString("name"));
//...
bikeList.add(bike);
``` | ```
while (rs.next()) {
Bike bike = new Bike();
bike.setName(rs.getString("name"));
bike.setModel(rs.getString("model"));
bikeList.add(bike);
}
``` |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | For each result in the result set, create a `new Bike()` and copy the values from that result to the new bikes fields. At the end, add the bike to the list.
```
Bike bike = new Bike()
bike.setName(rs.getString("name"));
//...
bikeList.add(bike);
``` | I don't know how Your Bike class look like, but you should do it like this way:
```
while(rs.next())
{
String column1 = rs.getString("column1_name");
.... and the others columns
Bike bike = new Bike();
bike.setColumn1(column1);
.... and others...
bikeList.add(bike)
}
``` |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | For each result in the result set, create a `new Bike()` and copy the values from that result to the new bikes fields. At the end, add the bike to the list.
```
Bike bike = new Bike()
bike.setName(rs.getString("name"));
//...
bikeList.add(bike);
``` | You need to instantiate Bike in while loop and add to `List`.
```
List<Bike> bikes = new ArrayList<>();
while(rs.next())
{
Bike bike = new Bike();
bike.setname( rs.getString("name"));
//other properties
bikes.add(bike);
}
return bikes;
``` |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | you would instantiate a Bike object and set properties that you read from result set, then add the bike object to your arraylist, isnt it what you are looking for? | You need to instantiate Bike in while loop and add to `List`.
```
List<Bike> bikes = new ArrayList<>();
while(rs.next())
{
Bike bike = new Bike();
bike.setname( rs.getString("name"));
//other properties
bikes.add(bike);
}
return bikes;
``` |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | You have Banana in your hand..just eat it :)
Create a empty list and in iteration Create new Bike and add into the List.
```
List<Bike> bikes = new ArrayList<Bikes>();
while(rs.next())
{
Bike bike = new Bike();
bike.setname( rs.getString("name"));
//other prope... | You need to instantiate Bike in while loop and add to `List`.
```
List<Bike> bikes = new ArrayList<>();
while(rs.next())
{
Bike bike = new Bike();
bike.setname( rs.getString("name"));
//other properties
bikes.add(bike);
}
return bikes;
``` |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | ```
while (rs.next()) {
Bike bike = new Bike();
bike.setName(rs.getString("name"));
bike.setModel(rs.getString("model"));
bikeList.add(bike);
}
``` | You need to instantiate Bike in while loop and add to `List`.
```
List<Bike> bikes = new ArrayList<>();
while(rs.next())
{
Bike bike = new Bike();
bike.setname( rs.getString("name"));
//other properties
bikes.add(bike);
}
return bikes;
``` |
Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?
Here is the code:
```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
... | I don't know how Your Bike class look like, but you should do it like this way:
```
while(rs.next())
{
String column1 = rs.getString("column1_name");
.... and the others columns
Bike bike = new Bike();
bike.setColumn1(column1);
.... and others...
bikeList.add(bike)
}
``` | You need to instantiate Bike in while loop and add to `List`.
```
List<Bike> bikes = new ArrayList<>();
while(rs.next())
{
Bike bike = new Bike();
bike.setname( rs.getString("name"));
//other properties
bikes.add(bike);
}
return bikes;
``` |
Question: What is the best and/or fastest to learn Java API for consuming XML feeds like this:
```
<body copyright="Company">
<student id="1" fname="Anthony" lname="Hopkins"/>
<student id="2" fname="John" lname="Anderson"/>
<student id="3" fname="Will" lname="Smitherman"/>
</body>
```
As you can see it ... | Easiest way is to use JaxB to generate the Java classes for you. If you have a schema you use xjb tool that will create the classes and can let java do all the parsing without you needing to do anything.
Look at <http://www.javaworld.com/javaworld/jw-06-2006/jw-0626-jaxb.html> | It depends on what you want to do with it but XStream might be the easiest way to import data from XML. This can produce a data structure to match your data. |
Question: I'm trying to make a Greasemonkey script to hide a really annoying div, on a website, that pops up after a few seconds. Neither of these works:
```
$("#flyin").hide();
$(document).ready(function(){
$("#flyin").hide();
});
```
I assume it's because the `#flyin` div is not created, yet. How do I tell jQuer... | There's [a utility for that (waitForKeyElements)](https://gist.github.com/2625891).
Your **whole script** would simply be:
```
// ==UserScript==
// @name _YOUR_SCRIPT_NAME
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @require http... | Try
```
(function () {
var $el = $("#flyin").hide();
//the element is not already created
if (!$el.length) {
//create an interval to keep checking for the presents of the element
var timer = setInterval(function () {
var $el = $("#flyin").hide();
//if the element is ... |
Question: I'm a complete cooking newb. I saw on youtube the other day that you should cook steak in an oven before frying it. I think it makes it softer (not sure, please let me know).
But anyway, I never used an oven in my entire life. And I looked inside the oven and there are no trays in there. So I went to the st... | To answer your question directly, if the method of cooking is what I think it is, the pan you use should be fine, even if it has a nonstick coating on it. You can read the second section to see if my assumption about your cooking method is correct.
It's important that you don't use nonstick cookware for extremely high... | The method I think you are referring to is called "reverse sear". When I do a reverse sear, I use a standard [wire rack](http://dailydecor.foodiefriendsfridaydailydish.com/wp-content/uploads/2015/04/30b0052baa76.jpg) on top of a foil covered baking sheet. I'm not sure precisely what you mean by a dessert tray - but you... |
Question: I have two strings.
```
str_a = "the_quick_brown_fox"
str_b = "the_quick_red_fox"
```
I want to find the first index at which the two strings differ (i.e. `str_a[i] != str_b[i]`).
I know I could solve this with something like the following:
```
def diff_char_index(str_a, str_b)
arr_a, arr_b = str_a.spl... | Something like this ought to work:
```
str_a.each_char.with_index
.find_index {|char, idx| char != str_b[idx] } || str_a.size
```
**Edit:** It works: <http://ideone.com/Ttwu1x>
**Edit 2:** My original code returned `nil` if `str_a` was shorter than `str_b`. I've updated it to work correctly (it will return `str... | ```
i = 0
i += 1 while str_a[i] and str_a[i] == str_b[i]
i
``` |
Question: I have two strings.
```
str_a = "the_quick_brown_fox"
str_b = "the_quick_red_fox"
```
I want to find the first index at which the two strings differ (i.e. `str_a[i] != str_b[i]`).
I know I could solve this with something like the following:
```
def diff_char_index(str_a, str_b)
arr_a, arr_b = str_a.spl... | Something like this ought to work:
```
str_a.each_char.with_index
.find_index {|char, idx| char != str_b[idx] } || str_a.size
```
**Edit:** It works: <http://ideone.com/Ttwu1x>
**Edit 2:** My original code returned `nil` if `str_a` was shorter than `str_b`. I've updated it to work correctly (it will return `str... | This uses a binary search to find the index where a slice of `str_a` no longer occurs at the beginning of `str_b`:
```
(0..str_a.length).bsearch { |i| str_b.rindex(str_a[0..i]) != 0 }
``` |
Question: I have two strings.
```
str_a = "the_quick_brown_fox"
str_b = "the_quick_red_fox"
```
I want to find the first index at which the two strings differ (i.e. `str_a[i] != str_b[i]`).
I know I could solve this with something like the following:
```
def diff_char_index(str_a, str_b)
arr_a, arr_b = str_a.spl... | Something like this ought to work:
```
str_a.each_char.with_index
.find_index {|char, idx| char != str_b[idx] } || str_a.size
```
**Edit:** It works: <http://ideone.com/Ttwu1x>
**Edit 2:** My original code returned `nil` if `str_a` was shorter than `str_b`. I've updated it to work correctly (it will return `str... | ```
str_a = "the_quick_brown_dog"
str_b = "the_quick_red_dog"
(0..(1.0)/0).find { |i| (str_a[i] != str_b[i]) || str_a[i].nil? }
#=> 10
str_a = "the_quick_brown_dog"
str_b = "the_quick_brown_dog"
(0..(1.0)/0).find { |i| (str_a[i] != str_b[i]) || str_a[i].nil? }
#=> 19
str_a.size
#=> 19
``` |
Question: I have two strings.
```
str_a = "the_quick_brown_fox"
str_b = "the_quick_red_fox"
```
I want to find the first index at which the two strings differ (i.e. `str_a[i] != str_b[i]`).
I know I could solve this with something like the following:
```
def diff_char_index(str_a, str_b)
arr_a, arr_b = str_a.spl... | ```
i = 0
i += 1 while str_a[i] and str_a[i] == str_b[i]
i
``` | This uses a binary search to find the index where a slice of `str_a` no longer occurs at the beginning of `str_b`:
```
(0..str_a.length).bsearch { |i| str_b.rindex(str_a[0..i]) != 0 }
``` |
Question: I have two strings.
```
str_a = "the_quick_brown_fox"
str_b = "the_quick_red_fox"
```
I want to find the first index at which the two strings differ (i.e. `str_a[i] != str_b[i]`).
I know I could solve this with something like the following:
```
def diff_char_index(str_a, str_b)
arr_a, arr_b = str_a.spl... | ```
str_a = "the_quick_brown_dog"
str_b = "the_quick_red_dog"
(0..(1.0)/0).find { |i| (str_a[i] != str_b[i]) || str_a[i].nil? }
#=> 10
str_a = "the_quick_brown_dog"
str_b = "the_quick_brown_dog"
(0..(1.0)/0).find { |i| (str_a[i] != str_b[i]) || str_a[i].nil? }
#=> 19
str_a.size
#=> 19
``` | This uses a binary search to find the index where a slice of `str_a` no longer occurs at the beginning of `str_b`:
```
(0..str_a.length).bsearch { |i| str_b.rindex(str_a[0..i]) != 0 }
``` |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | I've certainly done my bit to try and get rid of that question, as well as similar ones, but the system is against us. If Jeff brought it back from the dead I'd love to hear his reasoning for doing so. The only reasoning I can think of is that it brings traffic due to Google and traffic translates to revenue and revenu... | Send it back from whence it came. |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | Hear ye, hear ye, hear ye,
--------------------------
Three days have passed. Since then:
* 30% of our >10K users have voted to delete that question, independent of the vote going on here.
* 22 upvotes for sun-based disposal
* 4 upvotes for 'send it back from whence it came'
* Showers of hate upon 'Leave it'.
Based ... | Leave it, just keep it locked down. |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | Throw this question into the sun. | Hear ye, hear ye, hear ye,
--------------------------
Three days have passed. Since then:
* 30% of our >10K users have voted to delete that question, independent of the vote going on here.
* 22 upvotes for sun-based disposal
* 4 upvotes for 'send it back from whence it came'
* Showers of hate upon 'Leave it'.
Based ... |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | It needs to be burniated.
It adds nothing to the site. It was a "fun" question once upon a time *maybe* but we've moved on from that.
Perhaps it should be locked while its fate is being debated? | Send it back from whence it came. |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | Throw this question into the sun. | If it were my choice, I'd just hit the delete button on it here and be done with it.
Yes, by today's rules it is off topic both here and on Stack Overflow. I don't feel it adds *any* useful information to this site, or any on the Stack Exchange network. It goes no way towards the Stack Exchange mission of "make the in... |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | Throw this question into the sun. | I've certainly done my bit to try and get rid of that question, as well as similar ones, but the system is against us. If Jeff brought it back from the dead I'd love to hear his reasoning for doing so. The only reasoning I can think of is that it brings traffic due to Google and traffic translates to revenue and revenu... |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | Send it back from whence it came. | Leave it, just keep it locked down. |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | Hear ye, hear ye, hear ye,
--------------------------
Three days have passed. Since then:
* 30% of our >10K users have voted to delete that question, independent of the vote going on here.
* 22 upvotes for sun-based disposal
* 4 upvotes for 'send it back from whence it came'
* Showers of hate upon 'Leave it'.
Based ... | It needs to be burniated.
It adds nothing to the site. It was a "fun" question once upon a time *maybe* but we've moved on from that.
Perhaps it should be locked while its fate is being debated? |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | Hear ye, hear ye, hear ye,
--------------------------
Three days have passed. Since then:
* 30% of our >10K users have voted to delete that question, independent of the vote going on here.
* 22 upvotes for sun-based disposal
* 4 upvotes for 'send it back from whence it came'
* Showers of hate upon 'Leave it'.
Based ... | I've certainly done my bit to try and get rid of that question, as well as similar ones, but the system is against us. If Jeff brought it back from the dead I'd love to hear his reasoning for doing so. The only reasoning I can think of is that it brings traffic due to Google and traffic translates to revenue and revenu... |
Question: So this question... <https://serverfault.com/questions/45734/the-coolest-server-names>
It's horribly off topic. It's got a few votes to delete it right now because the community does not want it here (it's already been deleted once by the community).
I understand that it's being kept around for its historic... | It needs to be burniated.
It adds nothing to the site. It was a "fun" question once upon a time *maybe* but we've moved on from that.
Perhaps it should be locked while its fate is being debated? | Leave it, just keep it locked down. |
Question: I have a 40 gallon (bladdered) pressure tank in the basement which keeps pressure to my office building, and a 2-inch 2 horsepower submersible pump in a dug well 450 feet away.
The pump is cycling waaay too fast, and the tank will hold pressure at 41 pounds to 43 pounds but not at 60 pounds at shut-off pres... | The bladder is there to flatten the pressure/volume curve so pressure doesn't change rapidly as water is pumped.
This allows for a longer duty cycle.
The expected symptom of a burst bladder is just as you describe. | It needs air.
Get hold of an air compressor and give it a charge. Be sure to be running water while charging, and the pump is off. Easy.
If you need to do this more than once a year there might be a problem with the bladder. |
Question: I am creating a BitSet with a fixed number of bits.
In this case the length of my String holding the binary representation is 508 characters long.
So I create BitSet the following way:
```
BitSet bs = new BitSet(binary.length());
// binary.length() = 508
```
But looking at the size of bs I always get a si... | The number of bits in the constructor is a sizing hint, not a limit on the number of bits allowed. The `size()` of a Bitset is effectively its current *capacity*, though the specification is rather more rubbery than that.
>
> So I can't rely on the size if I get passed another bitset? There may also be some bits app... | According to [the documentation](http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html), the actual size in memory is implementation dependent, so you can't really know for sure what `size()` you're going to get. You as a user shouldn't have to worry about it, though, because the `length()` of the BitSet is al... |
Question: I am creating a BitSet with a fixed number of bits.
In this case the length of my String holding the binary representation is 508 characters long.
So I create BitSet the following way:
```
BitSet bs = new BitSet(binary.length());
// binary.length() = 508
```
But looking at the size of bs I always get a si... | The number of bits in the constructor is a sizing hint, not a limit on the number of bits allowed. The `size()` of a Bitset is effectively its current *capacity*, though the specification is rather more rubbery than that.
>
> So I can't rely on the size if I get passed another bitset? There may also be some bits app... | That's just a hint for a collection (this applies to all collections I think) so it don't have to resize itself after adding elements. For instance, if you know that your collection will hold 100 elements at maximum, you can set it's size to 100 and no resize will be made which is better for performance. |
Question: I am creating a BitSet with a fixed number of bits.
In this case the length of my String holding the binary representation is 508 characters long.
So I create BitSet the following way:
```
BitSet bs = new BitSet(binary.length());
// binary.length() = 508
```
But looking at the size of bs I always get a si... | The number of bits in the constructor is a sizing hint, not a limit on the number of bits allowed. The `size()` of a Bitset is effectively its current *capacity*, though the specification is rather more rubbery than that.
>
> So I can't rely on the size if I get passed another bitset? There may also be some bits app... | The BitSet size will be set to the first multiple of 64 that is equal to or greater than the number you use for 'size'. If you specify a 'size' of 508, you will get a BitSet with an actual size of 512, which is the next highest multiple of 64. |
Question: I am creating a BitSet with a fixed number of bits.
In this case the length of my String holding the binary representation is 508 characters long.
So I create BitSet the following way:
```
BitSet bs = new BitSet(binary.length());
// binary.length() = 508
```
But looking at the size of bs I always get a si... | According to [the documentation](http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html), the actual size in memory is implementation dependent, so you can't really know for sure what `size()` you're going to get. You as a user shouldn't have to worry about it, though, because the `length()` of the BitSet is al... | That's just a hint for a collection (this applies to all collections I think) so it don't have to resize itself after adding elements. For instance, if you know that your collection will hold 100 elements at maximum, you can set it's size to 100 and no resize will be made which is better for performance. |
Question: I am creating a BitSet with a fixed number of bits.
In this case the length of my String holding the binary representation is 508 characters long.
So I create BitSet the following way:
```
BitSet bs = new BitSet(binary.length());
// binary.length() = 508
```
But looking at the size of bs I always get a si... | According to [the documentation](http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html), the actual size in memory is implementation dependent, so you can't really know for sure what `size()` you're going to get. You as a user shouldn't have to worry about it, though, because the `length()` of the BitSet is al... | The BitSet size will be set to the first multiple of 64 that is equal to or greater than the number you use for 'size'. If you specify a 'size' of 508, you will get a BitSet with an actual size of 512, which is the next highest multiple of 64. |
Question: I tried to look in other solutions. But it didn't help me out. Kindly look into this.
my html code.
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn... | You are using `re_path` like it is `path`. `re_path` expects regex, it does not have path converters like `path`. You can either write a regex or switch to `path`.
Regex solution:
```
urlpatterns=[
re_path(r'delete/(?P<pk>\d+)/',views.delete_data,name="deletedata")
]
```
path solution:
```
from django.urls i... | Try this
In the template, you have used pk
change in the template or in view and url
```
urlpatterns=[
re_path('<int:pk>/',views.update_data,name="deletedata")
]
```
Or
```
<form action="{% url 'deletedata' id = st.id %}" method = "POST" class="d-inline"> {% csrf_token %}
<input type="submit" class="... |
Question: I tried to look in other solutions. But it didn't help me out. Kindly look into this.
my html code.
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn... | Try this
In the template, you have used pk
change in the template or in view and url
```
urlpatterns=[
re_path('<int:pk>/',views.update_data,name="deletedata")
]
```
Or
```
<form action="{% url 'deletedata' id = st.id %}" method = "POST" class="d-inline"> {% csrf_token %}
<input type="submit" class="... | {% url 'deletedata' pk = st.id %}
in thr URL just remove the spaces, bellow code it should work
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn-warning b... |
Question: I tried to look in other solutions. But it didn't help me out. Kindly look into this.
my html code.
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn... | Try this
In the template, you have used pk
change in the template or in view and url
```
urlpatterns=[
re_path('<int:pk>/',views.update_data,name="deletedata")
]
```
Or
```
<form action="{% url 'deletedata' id = st.id %}" method = "POST" class="d-inline"> {% csrf_token %}
<input type="submit" class="... | You can also write it with one a tag
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn-warning btn-sm">Edit</a>
<a href="{% url 'deletedata' pk=st.... |
Question: I tried to look in other solutions. But it didn't help me out. Kindly look into this.
my html code.
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn... | You are using `re_path` like it is `path`. `re_path` expects regex, it does not have path converters like `path`. You can either write a regex or switch to `path`.
Regex solution:
```
urlpatterns=[
re_path(r'delete/(?P<pk>\d+)/',views.delete_data,name="deletedata")
]
```
path solution:
```
from django.urls i... | {% url 'deletedata' pk = st.id %}
in thr URL just remove the spaces, bellow code it should work
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn-warning b... |
Question: I tried to look in other solutions. But it didn't help me out. Kindly look into this.
my html code.
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn... | You are using `re_path` like it is `path`. `re_path` expects regex, it does not have path converters like `path`. You can either write a regex or switch to `path`.
Regex solution:
```
urlpatterns=[
re_path(r'delete/(?P<pk>\d+)/',views.delete_data,name="deletedata")
]
```
path solution:
```
from django.urls i... | You can also write it with one a tag
```
<tbody>
{% for st in stu %}
<tr>
<th scope="row">{{st.id}}</th>
<td>{{st.name}}</td>
<td>{{st.email}}</td>
<td>{{st.role}}</td>
<td>
<a href="{}" class="btn btn-warning btn-sm">Edit</a>
<a href="{% url 'deletedata' pk=st.... |
Question: You know how PHP's `isset()` can accept multiple (no limit either) arguments?
Like I can do:
```
isset($var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10,$var11);
//etc etc
```
How would I be able to do that in my own function? How would I be able to work with infinity arguments passed?
How do ... | You can use `func_get_args()`, it will return an array of arguments.
```
function work_with_arguments() {
echo implode(", ", func_get_args());
}
work_with_arguments("Hello", "World");
//Outputs: Hello, World
``` | Calling `[func\_get\_args()](http://php.net/manual/en/function.func-get-args.php)` inside of your function will return an array of the arguments passed to PHP. |
Question: You know how PHP's `isset()` can accept multiple (no limit either) arguments?
Like I can do:
```
isset($var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10,$var11);
//etc etc
```
How would I be able to do that in my own function? How would I be able to work with infinity arguments passed?
How do ... | [`func_get_args`](http://php.net/manual/en/function.func-get-args.php) will do what you want:
```
function infinite_parameters() {
foreach (func_get_args() as $param) {
echo "Param is $param" . PHP_EOL;
}
}
```
You can also use `func_get_arg` to get a specific parameter (it's zero-indexed):
```
func... | You can use `func_get_args()`, it will return an array of arguments.
```
function work_with_arguments() {
echo implode(", ", func_get_args());
}
work_with_arguments("Hello", "World");
//Outputs: Hello, World
``` |
Question: You know how PHP's `isset()` can accept multiple (no limit either) arguments?
Like I can do:
```
isset($var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10,$var11);
//etc etc
```
How would I be able to do that in my own function? How would I be able to work with infinity arguments passed?
How do ... | Starting with PHP 5.6 you can use the token "**...**"
Example:
```
<?php
function sum(...$numbers) {
$acc = 0;
foreach ($numbers as $n) {
$acc += $n;
}
return $acc;
}
echo sum(1, 2, 3, 4);
?>
```
Source:
<http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list> | You can use `func_get_args()`, it will return an array of arguments.
```
function work_with_arguments() {
echo implode(", ", func_get_args());
}
work_with_arguments("Hello", "World");
//Outputs: Hello, World
``` |
Question: You know how PHP's `isset()` can accept multiple (no limit either) arguments?
Like I can do:
```
isset($var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10,$var11);
//etc etc
```
How would I be able to do that in my own function? How would I be able to work with infinity arguments passed?
How do ... | [`func_get_args`](http://php.net/manual/en/function.func-get-args.php) will do what you want:
```
function infinite_parameters() {
foreach (func_get_args() as $param) {
echo "Param is $param" . PHP_EOL;
}
}
```
You can also use `func_get_arg` to get a specific parameter (it's zero-indexed):
```
func... | Calling `[func\_get\_args()](http://php.net/manual/en/function.func-get-args.php)` inside of your function will return an array of the arguments passed to PHP. |
Question: You know how PHP's `isset()` can accept multiple (no limit either) arguments?
Like I can do:
```
isset($var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10,$var11);
//etc etc
```
How would I be able to do that in my own function? How would I be able to work with infinity arguments passed?
How do ... | Starting with PHP 5.6 you can use the token "**...**"
Example:
```
<?php
function sum(...$numbers) {
$acc = 0;
foreach ($numbers as $n) {
$acc += $n;
}
return $acc;
}
echo sum(1, 2, 3, 4);
?>
```
Source:
<http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list> | Calling `[func\_get\_args()](http://php.net/manual/en/function.func-get-args.php)` inside of your function will return an array of the arguments passed to PHP. |
Question: You know how PHP's `isset()` can accept multiple (no limit either) arguments?
Like I can do:
```
isset($var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10,$var11);
//etc etc
```
How would I be able to do that in my own function? How would I be able to work with infinity arguments passed?
How do ... | [`func_get_args`](http://php.net/manual/en/function.func-get-args.php) will do what you want:
```
function infinite_parameters() {
foreach (func_get_args() as $param) {
echo "Param is $param" . PHP_EOL;
}
}
```
You can also use `func_get_arg` to get a specific parameter (it's zero-indexed):
```
func... | Starting with PHP 5.6 you can use the token "**...**"
Example:
```
<?php
function sum(...$numbers) {
$acc = 0;
foreach ($numbers as $n) {
$acc += $n;
}
return $acc;
}
echo sum(1, 2, 3, 4);
?>
```
Source:
<http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list> |
Question: I've seen quite a few security camera examples and many have options for a duty schedule that activates the camera during certain specified days/hours to set up a routine. However I have fairly dynamic schedule and would like for my security cameras to turn on when our phones are not on the WiFi network. This... | You'd need to know either the MAC or IP address of the phones you want to monitor but you could just `ping` or `arping` each one in turn and if none reply start your recording otherwise stop recording. Calling something like this from `cron` might do the trick:
```
#!/bin/bash
#
# Determine if we should be recording ... | Your question appears to be about ***activating*** and ***disabling*** the cameras when you are not able to connect to them directly when your phones are not on the same local subnet. So it seems to be about ***networking*** and access to control them, rather than the phones themselves that you reference. That's what I... |
Question: I did some changes at my CoreData Model. So far, I added a attribute called 'language'. When my application is launched and I click on "Create new Customer" a instance variable Customer is created. This variable is created by:
```
Customer *newCustomer = [NSEntityDescription insertNewObjectForEntityForName:@... | What I did to get around this problem was to add this
>
> [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil];
>
>
>
to my appDelegate in the persistentStoreCoordinator before adding the persistent store. This deletes the existing store that no longer is compatible with your data model. Remember t... | The answer is a bit tricky but this always works for me. This is for a **clean** installation of a new compatible .sqlite file, **not a migration**!
launch simulator, delete the app and the data (the popup after you delete the app).
quit simulator
open X-Code, after making any edits to your data model
delete the `{... |
Question: I have problem with dll file and have project which need this file System.Windows.Controls.dll for
```
listBox1.ItemsSource
```
error fix , and add reference with this dll to fix error.
Where i can find this dll file?
Is there any download link ? Share please !
Thanks !
In "Add Reference" it doesn't exis... | Here are the steps:
1. Right click on `References` in the `Solutions Explorer` (Solutions explorer is on the right of your IDE)
2. Select `Add Reference`
3. In the window that opens, Select `Assemblies > Framework`
4. Check the `PresentationFramework` component box and click ok | This should be in the PresentationFramework.dll but that control is in the System.Windows.Controls namespace.
<http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.aspx>
You can add it by going to your project, Right clicking on References > Add Reference > .Net Tab > And selecting this DLL |
Question: I have problem with dll file and have project which need this file System.Windows.Controls.dll for
```
listBox1.ItemsSource
```
error fix , and add reference with this dll to fix error.
Where i can find this dll file?
Is there any download link ? Share please !
Thanks !
In "Add Reference" it doesn't exis... | This should be in the PresentationFramework.dll but that control is in the System.Windows.Controls namespace.
<http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.aspx>
You can add it by going to your project, Right clicking on References > Add Reference > .Net Tab > And selecting this DLL | I was able to find the dll file by searching my computer for "System.Windows.Controls.dll". I found it under the following file location... "C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.Windows.Controls.dll"
Hope this helps! |
Question: I have problem with dll file and have project which need this file System.Windows.Controls.dll for
```
listBox1.ItemsSource
```
error fix , and add reference with this dll to fix error.
Where i can find this dll file?
Is there any download link ? Share please !
Thanks !
In "Add Reference" it doesn't exis... | Here are the steps:
1. Right click on `References` in the `Solutions Explorer` (Solutions explorer is on the right of your IDE)
2. Select `Add Reference`
3. In the window that opens, Select `Assemblies > Framework`
4. Check the `PresentationFramework` component box and click ok | I was able to find the dll file by searching my computer for "System.Windows.Controls.dll". I found it under the following file location... "C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.Windows.Controls.dll"
Hope this helps! |
Question: I am very new to CSS and javascript, so take it easy on me.
I am trying to remove the class `disable-stream` from each of the div elements under the div class="stream-notifications". (See image, below)
I have tried the following in Tampermonkey, but it doesn't seem to work:
```
(function() {
'use strict';
... | ```
var divs =document.getElementsByClassName("stream-notifications");
divs=Array.from(divs);
divs.forEach(function(div){
div.classList.remove('disable-stream');
});
``` | Use something like this using jQuery
```
$(".disable-stream div").removeClass("disable-stream");
```
[Plunker demo](https://plnkr.co/edit/hP4IyF64trUEjTmZpwBK?p=preview) |
Question: I am very new to CSS and javascript, so take it easy on me.
I am trying to remove the class `disable-stream` from each of the div elements under the div class="stream-notifications". (See image, below)
I have tried the following in Tampermonkey, but it doesn't seem to work:
```
(function() {
'use strict';
... | That looks to be an AJAX-driven web page, so you need to use AJAX-aware techniques to deal with it. EG [waitForKeyElements](https://gist.github.com/2625891), or `MutationObserver`, or similar.
Here's **a complete script** that should work:
```
// ==UserScript==
// @name _Remove a select class from nodes
// @match... | Use something like this using jQuery
```
$(".disable-stream div").removeClass("disable-stream");
```
[Plunker demo](https://plnkr.co/edit/hP4IyF64trUEjTmZpwBK?p=preview) |
Question: I am very new to CSS and javascript, so take it easy on me.
I am trying to remove the class `disable-stream` from each of the div elements under the div class="stream-notifications". (See image, below)
I have tried the following in Tampermonkey, but it doesn't seem to work:
```
(function() {
'use strict';
... | That looks to be an AJAX-driven web page, so you need to use AJAX-aware techniques to deal with it. EG [waitForKeyElements](https://gist.github.com/2625891), or `MutationObserver`, or similar.
Here's **a complete script** that should work:
```
// ==UserScript==
// @name _Remove a select class from nodes
// @match... | ```
var divs =document.getElementsByClassName("stream-notifications");
divs=Array.from(divs);
divs.forEach(function(div){
div.classList.remove('disable-stream');
});
``` |
Question: Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially.
What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode ... | It's very hacky, but I've done this by having an item selected, but making it look like it's not selected, by making the background temporarily transparent. When an item is then selected by the user, the secretly-selected item is deselected and the background restored to normal. Or, if it's the secretly-selected item w... | You just have to use :
```
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
``` |
Question: Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially.
What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode ... | Just call:
```
mListView.setItemChecked(-1, true);
```
ListView's actionMode will be started without selecting any list element.
Make sure you've properly set your ListView before call:
```
mListView.setMultiChoiceModeListener( ... )
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
or
mListView.setChoiceM... | You just have to use :
```
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
``` |
Question: Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially.
What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode ... | It's very hacky, but I've done this by having an item selected, but making it look like it's not selected, by making the background temporarily transparent. When an item is then selected by the user, the secretly-selected item is deselected and the background restored to normal. Or, if it's the secretly-selected item w... | If you want to change the action bar, call this from your activity:
>
> startActionMode(new ActionMode.Callback {
>
>
>
> ```
> @Override
> public boolean onCreateActionMode(ActionMode mode, Menu menu) {
> return false;
> }
>
> @Override
> public boolean onPrepareActionMode(ActionMode ... |
Question: Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially.
What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode ... | Just call:
```
mListView.setItemChecked(-1, true);
```
ListView's actionMode will be started without selecting any list element.
Make sure you've properly set your ListView before call:
```
mListView.setMultiChoiceModeListener( ... )
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
or
mListView.setChoiceM... | If you want to change the action bar, call this from your activity:
>
> startActionMode(new ActionMode.Callback {
>
>
>
> ```
> @Override
> public boolean onCreateActionMode(ActionMode mode, Menu menu) {
> return false;
> }
>
> @Override
> public boolean onPrepareActionMode(ActionMode ... |
Question: Our UX asks for a button to start multi-choice mode. this would do the same thing as long-pressing on an item, but would have nothing selected initially.
What I'm seeing in the code is that I cannot enter multi-choice mode mode unless I have something selected, and if I unselect that item, multi-choice mode ... | It's very hacky, but I've done this by having an item selected, but making it look like it's not selected, by making the background temporarily transparent. When an item is then selected by the user, the secretly-selected item is deselected and the background restored to normal. Or, if it's the secretly-selected item w... | Just call:
```
mListView.setItemChecked(-1, true);
```
ListView's actionMode will be started without selecting any list element.
Make sure you've properly set your ListView before call:
```
mListView.setMultiChoiceModeListener( ... )
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
or
mListView.setChoiceM... |
Question: I have a solution with a C# project of 'library' and a project 'JavaScript' after that compiled it generates a .winmd file being taken to another project. But this project is built on x86 and I need to compile for x64, to run the application in order x64 get the following error:
```
'WWAHost.exe' (Script): L... | It looks like you were making calls with no Access Token at all, to data that's publicly visible on Facebook.com
v1.0 of Facebook's Graph API was deprecated in April 2014 and scheduled for removal after 2015-04-30 - one of the changes between v1.0 and v2.0 was that in v2.0 all calls require an Access Token - the depre... | I finally realized that since May 1, it is **necessary** to create an app and then generate a token and use it in my JSON call URL.
So this:
```
$.getJSON('https://graph.facebook.com/616894958361877/photos?limit=100&callback=?
```
Became this:
```
$.getJSON('https://graph.facebook.com/616894958361877/photos?acce... |
Question: I have a solution with a C# project of 'library' and a project 'JavaScript' after that compiled it generates a .winmd file being taken to another project. But this project is built on x86 and I need to compile for x64, to run the application in order x64 get the following error:
```
'WWAHost.exe' (Script): L... | It looks like you were making calls with no Access Token at all, to data that's publicly visible on Facebook.com
v1.0 of Facebook's Graph API was deprecated in April 2014 and scheduled for removal after 2015-04-30 - one of the changes between v1.0 and v2.0 was that in v2.0 all calls require an Access Token - the depre... | You need an App Access Token.
Go to <http://developers.facebook.com/apps/> and create an app for the client's Facebook page. When you're presented with the options, select the "Website" type of app. You can skip the configuration option using the "Skip and Create App ID" button in the top right corner.
Give it a Disp... |
Question: I am late game Alien Crossfire, attacking with gravitons aremed with [string disruptor](https://strategywiki.org/wiki/Sid_Meier%27s_Alpha_Centauri/Weapon#String_Disruptor).
Unfortunately, the others have gotten wise and are building everything [AAA](https://strategywiki.org/wiki/Sid_Meier%27s_Alpha_Centauri/... | Psi attack/defense is orthogonal to conventional weapons. Its result depends on *Morale* levels of attacking/defending units.
If an attacker/defender is a *Mind Worm*, they have their own class, plus both faction's *Planet (Green)* scores/attitudes largely affect the outcome of the fight.
**Answer:** see what's your ... | If you have dominant weapons, mixing in hovertanks and even air-dropped infantry will let you continue leveraging those dominant weapons.
Psi-combat is mostly useful when facing technologically superior enemies that your weapons cannot defeat. Switching from overwhelming firepower to psi-attack will make you lose as m... |
Question: **Goal**: I aim to use t-SNE (t-distributed Stochastic Neighbor Embedding) in R for dimensionality reduction of my training data (with *N* observations and *K* variables, where *K>>N*) and subsequently aim to come up with the t-SNE representation for my test data.
**Example**: Suppose I aim to reduce the K ... | From the author himself (<https://lvdmaaten.github.io/tsne/>):
>
> Once I have a t-SNE map, how can I embed incoming test points in that
> map?
>
>
> t-SNE learns a non-parametric mapping, which means that it does not
> learn an explicit function that maps data from the input space to the
> map. Therefore, it is... | t-SNE fundamentally does not do what you want. t-SNE is designed only for visualizing a dataset in a low (2 or 3) dimension space. You give it all the data you want to visualize all at once. It is not a general purpose dimensionality reduction tool.
If you are trying to apply t-SNE to "new" data, you are probably not... |
Question: **Goal**: I aim to use t-SNE (t-distributed Stochastic Neighbor Embedding) in R for dimensionality reduction of my training data (with *N* observations and *K* variables, where *K>>N*) and subsequently aim to come up with the t-SNE representation for my test data.
**Example**: Suppose I aim to reduce the K ... | t-SNE does not really work this way:
The following is an expert from the t-SNE author's website (<https://lvdmaaten.github.io/tsne/>):
>
> Once I have a t-SNE map, how can I embed incoming test points in that
> map?
>
>
> t-SNE learns a non-parametric mapping, which means that it does not
> learn an explicit fu... | t-SNE fundamentally does not do what you want. t-SNE is designed only for visualizing a dataset in a low (2 or 3) dimension space. You give it all the data you want to visualize all at once. It is not a general purpose dimensionality reduction tool.
If you are trying to apply t-SNE to "new" data, you are probably not... |
Question: **Goal**: I aim to use t-SNE (t-distributed Stochastic Neighbor Embedding) in R for dimensionality reduction of my training data (with *N* observations and *K* variables, where *K>>N*) and subsequently aim to come up with the t-SNE representation for my test data.
**Example**: Suppose I aim to reduce the K ... | This the mail answer from the author (Jesse Krijthe) of the Rtsne package:
>
> Thank you for the very specific question. I had an earlier request for
> this and it is noted as an open issue on GitHub
> (<https://github.com/jkrijthe/Rtsne/issues/6>). The main reason I am
> hesitant to implement something like this ... | t-SNE fundamentally does not do what you want. t-SNE is designed only for visualizing a dataset in a low (2 or 3) dimension space. You give it all the data you want to visualize all at once. It is not a general purpose dimensionality reduction tool.
If you are trying to apply t-SNE to "new" data, you are probably not... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.