qid
int64 1
74.7M
| question
stringlengths 0
58.3k
| date
stringlengths 10
10
| metadata
sequence | response_j
stringlengths 2
48.3k
| response_k
stringlengths 2
40.5k
|
---|---|---|---|---|---|
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | It's actually not PHP, it's apache using mod\_rewrite. What happens is the person requests the link, www.example.com/profile/12345 and then apache chops it up using a rewrite rule making it look like this, www.example.com/profile.php?u=12345, to the server. You can find more here: [Rewrite Guide](http://httpd.apache.org/docs/2.0/misc/rewriteguide.html) | There are lots of different ways to do this. One way is to use the RewriteRule techniques mentioned earlier to mask query string values.
One of the ways I really like is if you use the [front controller](http://martinfowler.com/eaaCatalog/frontController.html) pattern, you can also use urls like <http://yoursite.com/index.php/path/to/your/page/here> and parse the value of $\_SERVER['REQUEST\_URI'].
You can easily extract the /path/to/your/page/here bit with the following bit of code:
```
$route = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
```
From there, you can parse it however you please, but for pete's sake make sure you sanitise it ;) |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | I recently used the following in an application that is working well for my needs.
.htaccess
```
<IfModule mod_rewrite.c>
# enable rewrite engine
RewriteEngine On
# if requested url does not exist pass it as path info to index.php
RewriteRule ^$ index.php?/ [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?/$1 [QSA,L]
</IfModule>
```
index.php
```
foreach (explode ("/", $_SERVER['REQUEST_URI']) as $part)
{
// Figure out what you want to do with the URL parts.
}
``` | There are lots of different ways to do this. One way is to use the RewriteRule techniques mentioned earlier to mask query string values.
One of the ways I really like is if you use the [front controller](http://martinfowler.com/eaaCatalog/frontController.html) pattern, you can also use urls like <http://yoursite.com/index.php/path/to/your/page/here> and parse the value of $\_SERVER['REQUEST\_URI'].
You can easily extract the /path/to/your/page/here bit with the following bit of code:
```
$route = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
```
From there, you can parse it however you please, but for pete's sake make sure you sanitise it ;) |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | According to [this article](https://web.archive.org/web/20140220075845/http://www.phpriot.com/articles/search-engine-urls), you want a mod\_rewrite (placed in an `.htaccess` file) rule that looks something like this:
```
RewriteEngine on
RewriteRule ^/news/([0-9]+)\.html /news.php?news_id=$1
```
And this maps requests from
```
/news.php?news_id=63
```
to
```
/news/63.html
```
**Another possibility is doing it with `forcetype`**, which forces anything down a particular path to use php to eval the content. So, in your `.htaccess` file, put the following:
```
<Files news>
ForceType application/x-httpd-php
</Files>
```
And then the index.php can take action based on the `$_SERVER['PATH_INFO']` variable:
```
<?php
echo $_SERVER['PATH_INFO'];
// outputs '/63.html'
?>
``` | Simple way to do this. Try this code. Put code in your `htaccess` file:
```
Options +FollowSymLinks
RewriteEngine on
RewriteRule profile/(.*)/ profile.php?u=$1
RewriteRule profile/(.*) profile.php?u=$1
```
It will create this type pretty URL:
>
> <http://www.domain.com/profile/12345/>
>
>
>
For more htaccess Pretty URL:<http://www.webconfs.com/url-rewriting-tool.php> |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | Simple way to do this. Try this code. Put code in your `htaccess` file:
```
Options +FollowSymLinks
RewriteEngine on
RewriteRule profile/(.*)/ profile.php?u=$1
RewriteRule profile/(.*) profile.php?u=$1
```
It will create this type pretty URL:
>
> <http://www.domain.com/profile/12345/>
>
>
>
For more htaccess Pretty URL:<http://www.webconfs.com/url-rewriting-tool.php> | ModRewrite is not the only answer. You could also use Options +MultiViews in .htaccess and then check `$_SERVER REQUEST_URI` to find everything that is in URL. |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | I try to explain this problem step by step in following example.
**0) Question**
I try to ask you like this :
i want to open page like facebook profile www.facebook.com/kaila.piyush
it get id from url and parse it to profile.php file and return featch data from database and show user to his profile
normally when we develope any website its link look like
www.website.com/profile.php?id=username
example.com/weblog/index.php?y=2000&m=11&d=23&id=5678
now we update with new style not rewrite we use www.website.com/username or example.com/weblog/2000/11/23/5678 as permalink
```
http://example.com/profile/userid (get a profile by the ID)
http://example.com/profile/username (get a profile by the username)
http://example.com/myprofile (get the profile of the currently logged-in user)
```
**1) .htaccess**
Create a .htaccess file in the root folder or update the existing one :
```
Options +FollowSymLinks
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php
```
What does that do ?
If the request is for a real directory or file (one that exists on the server), index.php isn't served, else every url is redirected to index.php.
**2) index.php**
Now, we want to know what action to trigger, so we need to read the URL :
In index.php :
```
// index.php
// This is necessary when index.php is not in the root folder, but in some subfolder...
// We compare $requestURL and $scriptName to remove the inappropriate values
$requestURI = explode(‘/’, $_SERVER[‘REQUEST_URI’]);
$scriptName = explode(‘/’,$_SERVER[‘SCRIPT_NAME’]);
for ($i= 0; $i < sizeof($scriptName); $i++)
{
if ($requestURI[$i] == $scriptName[$i])
{
unset($requestURI[$i]);
}
}
$command = array_values($requestURI);
With the url http://example.com/profile/19837, $command would contain :
$command = array(
[0] => 'profile',
[1] => 19837,
[2] => ,
)
Now, we have to dispatch the URLs. We add this in the index.php :
// index.php
require_once("profile.php"); // We need this file
switch($command[0])
{
case ‘profile’ :
// We run the profile function from the profile.php file.
profile($command([1]);
break;
case ‘myprofile’ :
// We run the myProfile function from the profile.php file.
myProfile();
break;
default:
// Wrong page ! You could also redirect to your custom 404 page.
echo "404 Error : wrong page.";
break;
}
```
**2) profile.php**
Now in the profile.php file, we should have something like this :
```
// profile.php
function profile($chars)
{
// We check if $chars is an Integer (ie. an ID) or a String (ie. a potential username)
if (is_int($chars)) {
$id = $chars;
// Do the SQL to get the $user from his ID
// ........
} else {
$username = mysqli_real_escape_string($char);
// Do the SQL to get the $user from his username
// ...........
}
// Render your view with the $user variable
// .........
}
function myProfile()
{
// Get the currently logged-in user ID from the session :
$id = ....
// Run the above function :
profile($id);
}
``` | It's actually not PHP, it's apache using mod\_rewrite. What happens is the person requests the link, www.example.com/profile/12345 and then apache chops it up using a rewrite rule making it look like this, www.example.com/profile.php?u=12345, to the server. You can find more here: [Rewrite Guide](http://httpd.apache.org/docs/2.0/misc/rewriteguide.html) |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | I recently used the following in an application that is working well for my needs.
.htaccess
```
<IfModule mod_rewrite.c>
# enable rewrite engine
RewriteEngine On
# if requested url does not exist pass it as path info to index.php
RewriteRule ^$ index.php?/ [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?/$1 [QSA,L]
</IfModule>
```
index.php
```
foreach (explode ("/", $_SERVER['REQUEST_URI']) as $part)
{
// Figure out what you want to do with the URL parts.
}
``` | I try to explain this problem step by step in following example.
**0) Question**
I try to ask you like this :
i want to open page like facebook profile www.facebook.com/kaila.piyush
it get id from url and parse it to profile.php file and return featch data from database and show user to his profile
normally when we develope any website its link look like
www.website.com/profile.php?id=username
example.com/weblog/index.php?y=2000&m=11&d=23&id=5678
now we update with new style not rewrite we use www.website.com/username or example.com/weblog/2000/11/23/5678 as permalink
```
http://example.com/profile/userid (get a profile by the ID)
http://example.com/profile/username (get a profile by the username)
http://example.com/myprofile (get the profile of the currently logged-in user)
```
**1) .htaccess**
Create a .htaccess file in the root folder or update the existing one :
```
Options +FollowSymLinks
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php
```
What does that do ?
If the request is for a real directory or file (one that exists on the server), index.php isn't served, else every url is redirected to index.php.
**2) index.php**
Now, we want to know what action to trigger, so we need to read the URL :
In index.php :
```
// index.php
// This is necessary when index.php is not in the root folder, but in some subfolder...
// We compare $requestURL and $scriptName to remove the inappropriate values
$requestURI = explode(‘/’, $_SERVER[‘REQUEST_URI’]);
$scriptName = explode(‘/’,$_SERVER[‘SCRIPT_NAME’]);
for ($i= 0; $i < sizeof($scriptName); $i++)
{
if ($requestURI[$i] == $scriptName[$i])
{
unset($requestURI[$i]);
}
}
$command = array_values($requestURI);
With the url http://example.com/profile/19837, $command would contain :
$command = array(
[0] => 'profile',
[1] => 19837,
[2] => ,
)
Now, we have to dispatch the URLs. We add this in the index.php :
// index.php
require_once("profile.php"); // We need this file
switch($command[0])
{
case ‘profile’ :
// We run the profile function from the profile.php file.
profile($command([1]);
break;
case ‘myprofile’ :
// We run the myProfile function from the profile.php file.
myProfile();
break;
default:
// Wrong page ! You could also redirect to your custom 404 page.
echo "404 Error : wrong page.";
break;
}
```
**2) profile.php**
Now in the profile.php file, we should have something like this :
```
// profile.php
function profile($chars)
{
// We check if $chars is an Integer (ie. an ID) or a String (ie. a potential username)
if (is_int($chars)) {
$id = $chars;
// Do the SQL to get the $user from his ID
// ........
} else {
$username = mysqli_real_escape_string($char);
// Do the SQL to get the $user from his username
// ...........
}
// Render your view with the $user variable
// .........
}
function myProfile()
{
// Get the currently logged-in user ID from the session :
$id = ....
// Run the above function :
profile($id);
}
``` |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | I try to explain this problem step by step in following example.
**0) Question**
I try to ask you like this :
i want to open page like facebook profile www.facebook.com/kaila.piyush
it get id from url and parse it to profile.php file and return featch data from database and show user to his profile
normally when we develope any website its link look like
www.website.com/profile.php?id=username
example.com/weblog/index.php?y=2000&m=11&d=23&id=5678
now we update with new style not rewrite we use www.website.com/username or example.com/weblog/2000/11/23/5678 as permalink
```
http://example.com/profile/userid (get a profile by the ID)
http://example.com/profile/username (get a profile by the username)
http://example.com/myprofile (get the profile of the currently logged-in user)
```
**1) .htaccess**
Create a .htaccess file in the root folder or update the existing one :
```
Options +FollowSymLinks
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php
```
What does that do ?
If the request is for a real directory or file (one that exists on the server), index.php isn't served, else every url is redirected to index.php.
**2) index.php**
Now, we want to know what action to trigger, so we need to read the URL :
In index.php :
```
// index.php
// This is necessary when index.php is not in the root folder, but in some subfolder...
// We compare $requestURL and $scriptName to remove the inappropriate values
$requestURI = explode(‘/’, $_SERVER[‘REQUEST_URI’]);
$scriptName = explode(‘/’,$_SERVER[‘SCRIPT_NAME’]);
for ($i= 0; $i < sizeof($scriptName); $i++)
{
if ($requestURI[$i] == $scriptName[$i])
{
unset($requestURI[$i]);
}
}
$command = array_values($requestURI);
With the url http://example.com/profile/19837, $command would contain :
$command = array(
[0] => 'profile',
[1] => 19837,
[2] => ,
)
Now, we have to dispatch the URLs. We add this in the index.php :
// index.php
require_once("profile.php"); // We need this file
switch($command[0])
{
case ‘profile’ :
// We run the profile function from the profile.php file.
profile($command([1]);
break;
case ‘myprofile’ :
// We run the myProfile function from the profile.php file.
myProfile();
break;
default:
// Wrong page ! You could also redirect to your custom 404 page.
echo "404 Error : wrong page.";
break;
}
```
**2) profile.php**
Now in the profile.php file, we should have something like this :
```
// profile.php
function profile($chars)
{
// We check if $chars is an Integer (ie. an ID) or a String (ie. a potential username)
if (is_int($chars)) {
$id = $chars;
// Do the SQL to get the $user from his ID
// ........
} else {
$username = mysqli_real_escape_string($char);
// Do the SQL to get the $user from his username
// ...........
}
// Render your view with the $user variable
// .........
}
function myProfile()
{
// Get the currently logged-in user ID from the session :
$id = ....
// Run the above function :
profile($id);
}
``` | Simple way to do this. Try this code. Put code in your `htaccess` file:
```
Options +FollowSymLinks
RewriteEngine on
RewriteRule profile/(.*)/ profile.php?u=$1
RewriteRule profile/(.*) profile.php?u=$1
```
It will create this type pretty URL:
>
> <http://www.domain.com/profile/12345/>
>
>
>
For more htaccess Pretty URL:<http://www.webconfs.com/url-rewriting-tool.php> |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | Simple way to do this. Try this code. Put code in your `htaccess` file:
```
Options +FollowSymLinks
RewriteEngine on
RewriteRule profile/(.*)/ profile.php?u=$1
RewriteRule profile/(.*) profile.php?u=$1
```
It will create this type pretty URL:
>
> <http://www.domain.com/profile/12345/>
>
>
>
For more htaccess Pretty URL:<http://www.webconfs.com/url-rewriting-tool.php> | It looks like you are talking about a RESTful webservice.
<http://en.wikipedia.org/wiki/Representational_State_Transfer>
The .htaccess file does rewrite all URIs to point to one controller, but that is more detailed then you want to get at this point. You may want to look at [Recess](http://www.recessframework.org/)
It's a RESTful framework all in PHP |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | According to [this article](https://web.archive.org/web/20140220075845/http://www.phpriot.com/articles/search-engine-urls), you want a mod\_rewrite (placed in an `.htaccess` file) rule that looks something like this:
```
RewriteEngine on
RewriteRule ^/news/([0-9]+)\.html /news.php?news_id=$1
```
And this maps requests from
```
/news.php?news_id=63
```
to
```
/news/63.html
```
**Another possibility is doing it with `forcetype`**, which forces anything down a particular path to use php to eval the content. So, in your `.htaccess` file, put the following:
```
<Files news>
ForceType application/x-httpd-php
</Files>
```
And then the index.php can take action based on the `$_SERVER['PATH_INFO']` variable:
```
<?php
echo $_SERVER['PATH_INFO'];
// outputs '/63.html'
?>
``` | It looks like you are talking about a RESTful webservice.
<http://en.wikipedia.org/wiki/Representational_State_Transfer>
The .htaccess file does rewrite all URIs to point to one controller, but that is more detailed then you want to get at this point. You may want to look at [Recess](http://www.recessframework.org/)
It's a RESTful framework all in PHP |
812,571 | Normally, the practice or very old way of displaying some profile page is like this:
```
www.domain.com/profile.php?u=12345
```
where `u=12345` is the user id.
In recent years, I found some website with very nice urls like:
```
www.domain.com/profile/12345
```
How do I do this in PHP?
Just as a wild guess, is it something to do with the `.htaccess` file? Can you give me more tips or some sample code on how to write the `.htaccess` file? | 2009/05/01 | [
"https://Stackoverflow.com/questions/812571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87473/"
] | I recently used the following in an application that is working well for my needs.
.htaccess
```
<IfModule mod_rewrite.c>
# enable rewrite engine
RewriteEngine On
# if requested url does not exist pass it as path info to index.php
RewriteRule ^$ index.php?/ [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?/$1 [QSA,L]
</IfModule>
```
index.php
```
foreach (explode ("/", $_SERVER['REQUEST_URI']) as $part)
{
// Figure out what you want to do with the URL parts.
}
``` | It looks like you are talking about a RESTful webservice.
<http://en.wikipedia.org/wiki/Representational_State_Transfer>
The .htaccess file does rewrite all URIs to point to one controller, but that is more detailed then you want to get at this point. You may want to look at [Recess](http://www.recessframework.org/)
It's a RESTful framework all in PHP |
14,236,835 | I have multiple UPDATE statements inside my ExecuteSQL Task. Each one is dependent on one Vairiable e.g. MyId
```
UPDATE TABLE_A SET COL_A={Something} WHERE ID=?
UPDATE TABLE_B SET COL_B={SomeTHing} WHERE ID=?
```
This Query takes MyId Variable as Parameter.
Do i need to have as many parameters as my Update Statements are OR there is a way to Have `one` shared parameter defined inside my ExecuteSQL Task | 2013/01/09 | [
"https://Stackoverflow.com/questions/14236835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1711287/"
] | Try this:
```
DECLARE @id int
SELECT @id = ?
UPDATE TABLE_A SET COL_A={Something} WHERE ID=@id
UPDATE TABLE_B SET COL_B={Something} WHERE ID=@id
``` | The other option is to change your Connection Manager from an OLE to an ADO.NET provider type. ADO.NET connection managers use [named parameters](http://technet.microsoft.com/en-us/library/cc280502.aspx) instead of `?` so you can re-use them instead of dealing with ordinal positions in the mapping tab. We often have 2 pointing to the same database, one OLE for Data Flow type components and an ADO.NET for Execute SQL Task.
```
UPDATE TABLE_A SET COL_A={Something} WHERE ID=@id;
UPDATE TABLE_B SET COL_B={SomeTHing} WHERE ID=@id;
``` |
21,196,159 | I try to open other Fragment from Fragment with code:
```
btnRegister.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
register();
}
});
private void register(){
....
Intent i = new Intent(getActivity(), LoginFragment.class);
startActivity(i);
}
```
Anyone have idea why my app stops working?
Runtime exception error:
Unable to instantiate activity ComponentInfo{com.bakalauras.rtaujenis/com.bakalauras.rtaujenis.LoginFragment}: java.lang.ClassCastException: com.bakalauras.rtaujenis.LoginFragment cannot be cast to android.app.Activity
I do that becouse i found example <http://developer.android.com/guide/components/fragments.html#Example> look for TitlesFragment class in last rows else statement. | 2014/01/17 | [
"https://Stackoverflow.com/questions/21196159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3099680/"
] | From the name of your class, which is the only thing we see since there is little to no code, it seems you are trying to load a `Fragment` using an `Intent`. This mechanism is what `Activities` use to start one another. Adding `Fragments` dynamically requires you use `FragmentTransaction` from `FragmentManager`.
If `LoginFragment` is actually an `Activity` we will need to see more code.
If `LoginFragment` is a `Fragment` please read the [Android guide for using `Fragments`](http://developer.android.com/guide/components/fragments.html) | Try this code sample.
```
private void register(){
// Create new fragment and transaction
Fragment newFragment = new LoginFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
// Commit the transaction
transaction.commit();
}
``` |
21,196,159 | I try to open other Fragment from Fragment with code:
```
btnRegister.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
register();
}
});
private void register(){
....
Intent i = new Intent(getActivity(), LoginFragment.class);
startActivity(i);
}
```
Anyone have idea why my app stops working?
Runtime exception error:
Unable to instantiate activity ComponentInfo{com.bakalauras.rtaujenis/com.bakalauras.rtaujenis.LoginFragment}: java.lang.ClassCastException: com.bakalauras.rtaujenis.LoginFragment cannot be cast to android.app.Activity
I do that becouse i found example <http://developer.android.com/guide/components/fragments.html#Example> look for TitlesFragment class in last rows else statement. | 2014/01/17 | [
"https://Stackoverflow.com/questions/21196159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3099680/"
] | It's crashing because you are trying to start a fragment using the `startActivity` function.
That's not how fragments are used. you can think of Activity as the app's window, and the Fragments as the various sections of that app, therefore if you are trying to change from one fragment to another, you need to replace the current view using `FragmentTransaction`
```
android.support.v4.app.FragmentManager fragmentManager1 = getSupportFragmentManager();
FragmentTransaction fragmentTransaction1 = fragmentManager1.beginTransaction();
fragmentTransaction1.replace(R.id.container, LoginFragment);
fragmentTransaction1.commit();
```
where `R.id.container` is the frame that will contain the original view and will 'wrap' the new view.
Check out [this tutorial](http://www.vogella.com/tutorials/AndroidFragments/article.html) to learn how to work with fragments. Also check the official documentation Fragment to understand the life-cycle of [Fragments](http://developer.android.com/guide/components/fragments.html) since they are different than activities | Try this code sample.
```
private void register(){
// Create new fragment and transaction
Fragment newFragment = new LoginFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
// Commit the transaction
transaction.commit();
}
``` |
56,927,444 | I'm trying to reverse a string with the following code but am getting an error `Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)`.
I understand that it's telling me that I'm trying to access a NULL pointer but I fail to see where:
```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int empty(char s[]){
return strcmp(s, "") == 0 ? 1 : 0;
}
char getHead(char s[]){
char *dup = (char *)malloc(sizeof(char));
strcpy(dup, (s + 0));
return *dup;
}
char * getTail(char s[]){
char *dup = malloc(sizeof(char) * strlen(s) - 1);
for(int i = 0; i < strlen(s) - 1; i++){
dup[i] = s[i+1];
}
return dup;
}
char * ReverseStringHeadTail(char s[]){
if(empty(s))
{
return NULL;
}
else
{
char head = getHead(s);
char *tail = getTail(s);
return strcat(ReverseStringHeadTail(tail), head); // Error: Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)
}
}
int main(int argc, const char * argv[]) {
char string[] = "string";
printf("%s\n", ReverseStringHeadTail(string));
return 0;
}
```
Thanks! | 2019/07/08 | [
"https://Stackoverflow.com/questions/56927444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11681952/"
] | `scanf` is a standard input function in C.
The first thing you should learn about `scanf` is the 'return value'. Refer to the manual page for `scanf` by accessing `man scanf` if you're on Linux.
`scanf` returns the number of values read in from standard input. i.e your `scanf` would return 1, as only one value has been read in, in this case.
So if you run
```
int a = scanf("%d", &a);
```
first the expression `int a` would create a new int variable of size int (4 bytes). Then `scanf("%d", &a)` would input a value of size int from your standard input. Say you enter 5.
But then as you are setting `a` to whatever `scanf` is returning, i.e the number of values read from the standard input which is 1. so `a` would always be 1 no matter what value you enter into input.
Now, as for
```
int a;
scanf("%d", &a);
```
What you are doing is, first creating `a` with `int a`. Then you are "NOT" saving the return value of `scanf` anywhere. That means from `scanf`, any value you enter is read into `a`. And that's it. The return value (for `scanf`, the return value is the number of input values; in this case we are only entering one value so it's 1) is not being fed to a or any other variable. So `a` now has the value what you entered earlier from your standard input. | ```
int a; scanf("%d", &a);
```
In the above code an integer variable is declared and its address is passed to scanf function,because inside scamf function the value of a get modified.So in order to reflect the change in the main function you have to pass the address. scanf function reads input from the standard input stream stdin and the value of a will be changed to that.
```
int a = scanf("%d", &a);
```
In this piece of code also the working of scanf is similar.But after scanf function,it's return value is assigned to a. scanf function return the number of input items successfully matched and assigned, which can be fewer than provided for, or even zero in the event of an early matching failure.so here the value of a will be 1 or zero. |
40,114,634 | ```
(define (element-of-set x lst1)
(cond ((null? lst1) '())
((equal? x (car lst1)) (cons (car lst1) (element-of-set x (cdr lst1))))
(else
(element-of-set x (cdr lst1)))))
(define (helper set1 set2) (append set1 set2))
(define (union-set set1 set2)
(cond ((null? set1) '())
((> (length (element-of-set (car set1) (helper set1 set2))) 1) (cons (car set1) (union-set (cdr set1) (cdr set2))))
((> (length (element-of-set (car set2) (helper set1 set2))) 1) (cons (car set2) (union-set (cdr set1) (cdr set2))))
(else
(append (helper set1 set2) (union-set (cdr set1) (cdr set2))))))
```
This code is suppose to find the union of 2 sets. I tried to put the two sets together and then take out any repeats but it didn't work. | 2016/10/18 | [
"https://Stackoverflow.com/questions/40114634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How about this:
```
#lang racket
(require racket/set)
(define (union-set set1 set2)
(set-union set1 set2))
(union-set '(1 2 3) '(4 3 2))
=> '(4 1 2 3)
```
FYI, `set` is a built-in data type in Racket, so it's easy to write a set union - just call the existing procedure! Anyway, if you want to roll your own version it's also easy, and simpler than your current implementation:
```
(define (element-of-set x lst1)
(cond ((null? lst1) #f)
((equal? x (car lst1)) #t)
(else (element-of-set x (cdr lst1)))))
(define (union-set set1 set2)
(cond ((null? set1) set2)
((element-of-set (car set1) set2)
(union-set (cdr set1) set2))
(else
(cons (car set1) (union-set (cdr set1) set2)))))
``` | Here's how I'd do it in Common Lisp if it didn't include functions for set operations.
```
(defun set-union (set1 set2)
(remove-duplicates (append set1 set2)))
```
I'll write one in Scheme. |
10,683,550 | I wonder whether someone may be able to help me please.
I've put together [this](http://www.mapmyfinds.co.uk/development/testgallery.php) gallery page.
Using the icon under each image a user can delete any image they wish. Rather than deleting the image immediately, I'me trying to implement a Modal Confirmation Dialog box, so the user has the option to cancel the delete.
I can get the onlick event to work, but the text which asks the user whether they want to delete the image disappears from the dialog box when clicked.
I did have an issue with dialog box text appearing at the top of my page on page load. To overcome this I've used the following:
I have tried adding the following to prevent this:
```
.hide{ display: none !important; }
<div id="dialog-confirm" class="hide" title="Delete This Image?">
```
So I know that the issue is more than likely being caused by the this, but I'm not sure how to overcome both problems.
I just wondered whether someone may be able to look at this please and let me know where I've gone wrong.
Many thanks and regards | 2012/05/21 | [
"https://Stackoverflow.com/questions/10683550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/794000/"
] | u didn't mentioned your code, but i think problem is something like ,
your class "`.hide`" is getting apply properly, which contain "`display:none`".
but
you defined "`display:block`" property "**inline**", for u r "dialog-confirm" box, in earlier code.
and
css attributes defined "**inline**" always have high priority than attributes defined in "**class**".
so `display:none` is gets overridden by "`display:block`".
try to give attribute at both location by "`.addClass()/.removeClass()`" or by "inline"
it might help u !!! bcoz it worked for me in same kind of situation
i am also new to this field, so others please make me correct if i am wrong !! | Please Remove below style definition on the page. Then it will work:
```
.hide{ display: none !important; }
```
You need to define the dialog box with option `autoOpen: false` and need to invoke with open command on click of delete button(where you used `.live` code ). Please, Modify code as below:
```
$( "#dialog-confirm" ).dialog({
resizable: false,
modal: true,
autoOpen: false
buttons: {
"Delete image": function() {
var img = $(this).closest(".galleria-image").find("img");
// send the AJAX request
$.ajax({
url : 'delete.php',
type : 'post',
data : { image : img.attr('src'), userid: "VALUE", locationid: "VALUE"},
success : function(){
img.parent().fadeOut('slow');
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
$(".btn-delete").live("click", function(){
$( "#dialog-confirm" ).dialog( "open" );
return false;
});
``` |
10,683,550 | I wonder whether someone may be able to help me please.
I've put together [this](http://www.mapmyfinds.co.uk/development/testgallery.php) gallery page.
Using the icon under each image a user can delete any image they wish. Rather than deleting the image immediately, I'me trying to implement a Modal Confirmation Dialog box, so the user has the option to cancel the delete.
I can get the onlick event to work, but the text which asks the user whether they want to delete the image disappears from the dialog box when clicked.
I did have an issue with dialog box text appearing at the top of my page on page load. To overcome this I've used the following:
I have tried adding the following to prevent this:
```
.hide{ display: none !important; }
<div id="dialog-confirm" class="hide" title="Delete This Image?">
```
So I know that the issue is more than likely being caused by the this, but I'm not sure how to overcome both problems.
I just wondered whether someone may be able to look at this please and let me know where I've gone wrong.
Many thanks and regards | 2012/05/21 | [
"https://Stackoverflow.com/questions/10683550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/794000/"
] | You can pass the option `autoOpen: false` instead in your dialog call to hide it until it is called;
```
$( "#dialog-confirm" ).dialog({
autoOpen: false
});
```
With this option in place, the dialog should be hidden from view until its called.
Also, you have placed the `.hide` class outside the `<style>..</style>` tags and its appearing on top of your page. | Please Remove below style definition on the page. Then it will work:
```
.hide{ display: none !important; }
```
You need to define the dialog box with option `autoOpen: false` and need to invoke with open command on click of delete button(where you used `.live` code ). Please, Modify code as below:
```
$( "#dialog-confirm" ).dialog({
resizable: false,
modal: true,
autoOpen: false
buttons: {
"Delete image": function() {
var img = $(this).closest(".galleria-image").find("img");
// send the AJAX request
$.ajax({
url : 'delete.php',
type : 'post',
data : { image : img.attr('src'), userid: "VALUE", locationid: "VALUE"},
success : function(){
img.parent().fadeOut('slow');
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
$(".btn-delete").live("click", function(){
$( "#dialog-confirm" ).dialog( "open" );
return false;
});
``` |
1,119,319 | I am finding it hard to turn off the hotspots on the desktop (Ubuntu 18.04.2) at the top left corner that shows up with a miniature version of the windows I have available to switch to. The stuff I can think to search for like "activities hotspot ubuntu" are all too generic to get me there.
I checked gnome-shell extensions in Firefox, but I didn't see anything obviously it and am not very familiar with the interface yet. Does anyone know what to call this feature? I just want to turn it off because it false triggers all the time when I hit close buttons on a maximized application, and having two monitors makes this happen as well when on a second monitor that shows no floating taskbar.
Where are such configurations stored in the latest version? | 2019/02/18 | [
"https://askubuntu.com/questions/1119319",
"https://askubuntu.com",
"https://askubuntu.com/users/868842/"
] | ```
ERROR: Unable to load the 'nvidia-drm' kernel module message was accompanied with a bit more detail.
```
The problem was solved by running the driver-installer (.run) file in **rescue.terget**, with **Secure Boot disabled**.
This successfully completed the installation. However, the **NVIDIA driver works only with secure boot disabled**.
**Keeping the Secure Boot permanently disabled definitely leaves the system prone to a lot of other threats and problems!**
[Link](https://devtalk.nvidia.com/default/topic/1048483/cuda-setup-and-installation/ubuntu-trouble-installing-the-latest-drivers-for-gtx-1050/post/5324194/?offset=7#5324830) to the NVIDIA forum post.
I appreciate all the help and guidance I received in solving this problem, especially from **heynnema**. I am really grateful.
[This](https://askubuntu.com/questions/1023036/how-to-install-nvidia-driver-with-secure-boot-enabled) post describes the procedure for signing the driver so that **it would work even with Secure Boot enabled**.
For an in-depth understanding, please refer to [this](http://us.download.nvidia.com/XFree86/Linux-x86_64/418.43/README/installdriver.html#modulesigning). | **Note**: assuming that turning off `Secure Boot` in your BIOS didn't fix this problem...
In the `terminal`...
`cd /var/log` # change to the syslog directory
`grep -i pkcs syslog*` # search syslog and syslog.1
Notice if it finds `pkcs` in which log file... syslog... or syslog.1
`sudo -H gedit syslog` # lets look at syslog
Search for `pkcs` in the log
Look a few lines before/after the `pkcs` line, and note which driver is called out
That driver needs to be updated or removed
**Update #1:**
```
Feb 20 00:22:57 gdm3[2133]: modprobe: ERROR: could not insert 'nvidia': Operation not permitted
Feb 20 00:22:57 kernel: [ 81.556911] PKCS#7 signature not signed with a trusted key
Feb 20 00:22:57 systemd[1]: Stopped /run/user/120 mount wrapper.
Feb 20 00:22:57 gdm3[2133]: modprobe: ERROR: could not insert 'nvidia': Operation not permitted
Feb 20 00:22:57 kernel: [ 81.687080] PKCS#7 signature not signed with a trusted key
Feb 20 00:22:57 gdm3: Child process -2397 was already dead.
```
**Update #2:**
To view the extensive Nvidia installation instructions, **paying special attention to the kernel module signing information**...
Download the latest Nvidia driver 418.43 which was just released on 2/22/19.
`sh ./NVIDIA-Linux-x86_64-418.43.run -x`
`cd ./NVIDIA-Linux-x86_64-418.43`
`more README.txt`
`cd ..`
`sudo sh ./NVIDIA-Linux-x86_64-418.43.run`
**Note**: be patient when the installer is building the dkms kernel modules |
15,058,853 | I have an install.bat file and a resource folder. so long as these two files are in the same directory, if you run install.bat, it will install a my lwjgl game. so what im trying to do is make a self extracting file that when completed runs the launch.bat file. I have tried using iexpress, and got it working for the most part. i have added in all my files and such so it will extract to some directory and then i can run the install.bat file to get my program to work. thing is though, i want the exe i created with iexpress to launch install.bat when its finished. so, i tried using the option in iexpress that says it will execute a command when finished the "installation" (using quotes because its not the actual installation, just extracting the files to some directory specified by the user). when i get to the step where it says what i would like to execute during and after the "installation". during the installation i left blank. after the installation i chose the install.bat file. when i try to click next though, it tells me i must choose something for the command during the extraction. I don't have anything specific to do during the installation so i just said "echo." (without quotes). after i was done i tried running the installer. before it even prompted me for a folder to extract to, it told me that echo. could not be executed. so i went back into my installation (via a .sed file) and changed the "echo." to "pause". that didn't work either. i then read on another website that in order to run a file the way i would like to, i put the file name in both the during and after installation boxes. i tried doing that and it didn't work either. can anyone please help me? | 2013/02/25 | [
"https://Stackoverflow.com/questions/15058853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1807744/"
] | Mocha has built-in Promise support as of version 1.18.0 (March 2014). You can return a promise from a test case, and Mocha will wait for it:
```
it('does something asynchronous', function() { // note: no `done` argument
return getSomePromise().then(function(value) {
expect(value).to.equal('foo');
});
});
```
Don't forget the `return` keyword on the second line. If you accidentally omit it, Mocha will assume your test is synchronous, and it won't wait for the `.then` function, so your test will always pass even when the assertion fails.
---
If this gets too repetitive, you may want to use the [chai-as-promised](https://github.com/domenic/chai-as-promised) library, which gives you an `eventually` property to test promises more easily:
```
it('does something asynchronous', function() {
return expect(getSomePromise()).to.eventually.equal('foo');
});
it('fails asynchronously', function() {
return expect(getAnotherPromise()).to.be.rejectedWith(Error, /some message/);
});
```
Again, don't forget the `return` keyword! | Then 'returns' a promise which can be used to handle the error. Most libraries support a method called `done` which will make sure any un-handled errors are thrown.
```
it('does something asynchronous', function (done) {
getSomePromise()
.then(function (value) {
value.should.equal('foo')
})
.done(() => done(), done);
});
```
You can also use something like [mocha-as-promised](https://github.com/domenic/mocha-as-promised) (there are similar libraries for other test frameworks). If you're running server side:
```
npm install mocha-as-promised
```
Then at the start of your script:
```
require("mocha-as-promised")();
```
If you're running client side:
```
<script src="mocha-as-promised.js"></script>
```
Then inside your tests you can just return the promise:
```
it('does something asynchronous', function () {
return getSomePromise()
.then(function (value) {
value.should.equal('foo')
});
});
```
Or in coffee-script (as per your original example)
```
it 'does something asynchronous', () ->
getSomePromise().then (value) =>
value.should.equal 'foo'
``` |
13,094,317 | This is probably very easy/obvious.
I'm writing a Chrome extention.
My Javascript catches the text nodes from any site and changes part of the text to something else. I would like to mark the changed text by changing its color (adding tags).
```
return "<font color = \"FF0000\">"+a+"</font>"
```
And the result:
```
<font color = "FF0000">SomeText</font>
```
But all I want of course is that the **SomeText** will appear in red. | 2012/10/26 | [
"https://Stackoverflow.com/questions/13094317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1405667/"
] | I recommend you use CSS in your chrome extension. so my solution would involve giving the DOM element (for your instance maybe its a paragraph or a span) a class. It's not good conventions to put style attributes in your HTML markup.
```
<p class="red">SomeText</p>
```
And in your CSS file
```
.red {
color: #ff0000 /* I actually love this color */
}
```
**So how does this use JavaScript?**
Instead of adding the styles directly into the HTML tag, you can instead add a class to an element.
```
document.getElementByTagName("p").className = "red";
```
Or if you want to target a specific ID
```
document.getElementById("object").className = "red";
```
And that text will be red. And since you can add the red class to any class attribute for any object in the DOM, your code will look cleaner than throwing styles everywhere.
I hope this helps you out. Let me know if otherwise. | You need to add color in your style sheet...
Like `<input type="text" style="color:red" value="sometext"/>`. |
13,094,317 | This is probably very easy/obvious.
I'm writing a Chrome extention.
My Javascript catches the text nodes from any site and changes part of the text to something else. I would like to mark the changed text by changing its color (adding tags).
```
return "<font color = \"FF0000\">"+a+"</font>"
```
And the result:
```
<font color = "FF0000">SomeText</font>
```
But all I want of course is that the **SomeText** will appear in red. | 2012/10/26 | [
"https://Stackoverflow.com/questions/13094317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1405667/"
] | ```
function newText(tag, text, style) {
var element = document.createElement(tag); //this creates an empty node of the type specified
element.appendChild(document.createTextNode(text)); //this creates a new text node and inserts it into our empty node
if (style) element.setAttribute('style', style); //this sets the style in inline CSS (warning, this needs different syntax in IE)
return element; //this returns a DOM object
}
```
This will return a DOM object, and you will need to append it to another node.
```
var myText = newText('p', 'This is some text!', 'color: red;');
document.getElementById('myTextBox').appendChild(myText);
``` | You need to add color in your style sheet...
Like `<input type="text" style="color:red" value="sometext"/>`. |
26,968,408 | Since I am new to Jquery, I want a code in JQUERY for following function:
```
if(checkbox.checked==true)
{
checkbox.checked=false;
}
else
checkbox.checked=true;
```
please help me with this. | 2014/11/17 | [
"https://Stackoverflow.com/questions/26968408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2554069/"
] | ```
var $checkbox = $(/*your selector*/);
$checkbox.prop("checked", !$checkbox.prop("checked" ) );
``` | You can use following code: (Using [.attr()](http://api.jquery.com/attr/) or [.prop()](http://api.jquery.com/prop/))
```
var checkbox = $('#targetId');
if(checkbox.prop('checked')==true)
checkbox.prop('checked','false');
else
checkbox.prop('checked','true');
```
OR
```
var checkbox = $('#targetId');
if(checkbox.attr('checked')=='checked')
checkbox.attr('checked','checked');
else
checkbox.removeAttr('checked');
```
* [**Single Checkbox demo**](http://jsfiddle.net/su7cw4u1/)
* [**Multiple Checkbox Demo**](http://jsfiddle.net/su7cw4u1/1/) |
26,968,408 | Since I am new to Jquery, I want a code in JQUERY for following function:
```
if(checkbox.checked==true)
{
checkbox.checked=false;
}
else
checkbox.checked=true;
```
please help me with this. | 2014/11/17 | [
"https://Stackoverflow.com/questions/26968408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2554069/"
] | ```
var $checkbox = $(/*your selector*/);
$checkbox.prop("checked", !$checkbox.prop("checked" ) );
``` | ```
$(document).ready(function() {
$("#YourIdSelector,.YourClassSelector").click(function() {
$(this).prop('checked',!$(this).is(':checked'));
});
});
```
Hope it helps... |
26,968,408 | Since I am new to Jquery, I want a code in JQUERY for following function:
```
if(checkbox.checked==true)
{
checkbox.checked=false;
}
else
checkbox.checked=true;
```
please help me with this. | 2014/11/17 | [
"https://Stackoverflow.com/questions/26968408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2554069/"
] | ```
var $checkbox = $(/*your selector*/);
$checkbox.prop("checked", !$checkbox.prop("checked" ) );
``` | See this snippet:
```js
$("#btn").on("click", function() {
$("input[type=checkbox]").each(function() {
this.checked = !this.checked;
});
});
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" checked />
<input type="checkbox" />
<input type="checkbox" checked />
<input type="checkbox" />
<br /><br />
<input id="btn" type="button" value="Invert" />
``` |
39,984,444 | Original python dictionary list:
```
[
{"keyword": "nike", "country":"usa"},
{"keyword": "nike", "country":"can"},
{"keyword": "newBalance", "country":"usa"},
{"keyword": "newBalance", "country":"can"}
]
```
I would like to consolidate the python dict list and get an output like:
```
[
{"keyword": "nike", "country":["usa","can"]},
{"keyword": "newBalance", "country":["usa","can"]}
]
```
What is the most efficient way to do this? | 2016/10/11 | [
"https://Stackoverflow.com/questions/39984444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1551852/"
] | Here are some general pointers. I'm not going to code the whole thing for you. If you post more of what you've tried and specific code you need help with, I'd be happy to help more.
It looks like you're combining only those which have the same value for the "keyword" key. So loop over values of that key and combine them based on that.
To combine a bunch of dictionaries once you've split them up as above, you'll first need to create a new one where "country" maps to an empty list. Then as you consider each of the dictionaries, check if its value for "country" is already in that list. If it's not, `append` it. | ```
L = [
{"keyword": "nike", "country":"usa"},
{"keyword": "nike", "country":"can"},
{"keyword": "newBalance", "country":"usa"},
{"keyword": "newBalance", "country":"can"}
]
def consolidate(L):
answer = {}
for d in L:
if d['keyword'] not in answer:
answer['keyword'] = set()
answer['keyword'].add(d['country'])
retval = []
for k,countries in answer.items():
retval.append({'keyword':d['keyword'], 'country':list(countries)})
return retval
``` |
68,343,847 | I see `notify::` prefix in `g_signal_connect` call:
```
g_signal_connect(p_obj, "notify::ice-gathering-state", G_CALLBACK(on_ice_gathering_state_changed), p_obj);
```
What does it mean? Is this prefix required? | 2021/07/12 | [
"https://Stackoverflow.com/questions/68343847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5447906/"
] | Since you might see this pop up in other contexts, I'll try to explain what's going on at a lower level: `notify` is the name of the signal, not a prefix.
The `notify` signal is what's known as a signal "with detail", and the `::ice-gathering-state` part is the "detail". For the [`notify` signal](https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#GObject-notify), the detail is the name of the property to notify about. If you omit the detail, then you will get change notifications for all the properties on that object.
You might see other signals with details, though `notify` is by far the most common. What the detail means, depends on the signal, and you should read about it in that signal's documentation. | Yes, it is required. It is not for usual signals. It is for signals that notify about property change. If you check [documentation](https://gstreamer.freedesktop.org/documentation/webrtc/index.html?gi-language=c), you will see that `ice-gathering-state` is not an action signal, it is a property. Properties are usually read with `g_object_get`. But instead you can set a signal hander that will be called each time the property changes. And this is done by calling `g_signal_connect` with `notify::<property>` as the signal name.
Check [this page](https://developer.gnome.org/clutter-cookbook/stable/actors-allocation-notify.html) on GLib site. |
497,702 | I was wondering if there is an OEM version of Ubuntu like that of windows which has nothing but the necessities to operate. (ex no add-ins or any thing of the likes. | 2014/07/14 | [
"https://askubuntu.com/questions/497702",
"https://askubuntu.com",
"https://askubuntu.com/users/305470/"
] | You can do an OEM install , see <https://help.ubuntu.com/community/Ubuntu_OEM_Installer_Overview>
Can you please clarify what you mean by "nothing but the necessities to operate"? If you want a bare bones install, use the mini iso
See <https://help.ubuntu.com/community/Installation/MinimalCD>
Note : a minimal install will be command line only with a minimal number of packages
Or you can do a server install
<http://www.ubuntu.com/download/server>
Sort of depends on what you are looking for. | Have you looked at [Installing ubuntu desktop without all the bloat](https://askubuntu.com/questions/42964/installing-ubuntu-desktop-without-all-the-bloat)? This shows you how to do an absolute bare-bones install of Gnome without anything extra installed. It sounds like what you're looking for.
Edit: I based my install off the second guys answer: Download the netinstall ISO from here: <https://help.ubuntu.com/community/Installation/MinimalCD> - don't install any extra packages. When you reboot, log into the console & run:
```
sudo apt-get install --no-install-recommends ubuntu-desktop synaptic gksu gdm
sudo apt-get upgrade
``` |
117,128 | How a native speaker would ask the following sentence:
>
> * What is your field of working?
>
>
>
The second person would possibly say: "Accountancy" or "Nursing" or "Medicine" or "Engineering" etc.
For me, all of the following sentences work:
>
> * What is your field of working?
> * What is your occupation?
> * What is your career?
>
>
> | 2017/01/26 | [
"https://ell.stackexchange.com/questions/117128",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/5652/"
] | In order to answer, it's worthwhile looking at the differences between *field*, *occupation* and *career*.
>
> What is your **field** of working?
>
>
>
A *field* is a particular branch of study or sphere of activity or interest. Field is often used to indicate a specific occupational area or academic branch (e.g.civil engineering, physics, marine science), rather than referring to a specific job. In other words, it's a person's area of expertise, and it's common to ask the question in such a manner:
* What is your **field** of expertise?
A person does not have to be currently working (or working in that occupation) in order to have a field.
>
> What is your **occupation**?
>
>
>
occupation refers to the field or type of work you perform. For example:
>
> A: What's your occupation/profession?"
>
>
> B: "I'm an accountant." or "I'm an engineer."
>
>
>
**Profession** is another term worth mentioning here. Occupation and profession are similar in that they both refer to the general type of work a person does (or would want to do). The difference is that an *occupation* may require specialised training, such as an apprenticeship, while a *profession* normally requires some form of third level education in that particular field.
>
> What is your **career**?
>
>
>
A career is the total progression of a person's professional life, and can include many different jobs over the years. For example, if a person had a career in politics, it means they could have many different jobs over many years, all under the broad umbrella that is 'politics'. The being said, it's not particularly common to ask a person *'What is your career?'*
Given the answers you've provided ("Accountancy", "Nursing", "Medicine", "Engineering"), these are all fields of expertise, therefore it would be acceptable to ask:
>
> A: What is your field of expertise?
>
>
> B: Engineering is my field.
>
>
>
IF you wanted to ask about occupation however, the answers would have to change somewhat:
>
> A: What is your occupation?
>
>
> B: I'm an accountant/nurse/doctor/engineer.
>
>
> | You are **in** a field.
>
> What field are you in?
>
>
>
You **choose** a career as you would choose a path.
>
> What is your chosen career?
>
>
> What career did you choose?
>
>
> |
4,233,214 | I'am currently working on a project using Hadoop 0.21.0, 985326 and a cluster of 6 worker nodes and a head node.
Submitting a regular mapreduce job fails, but I have no idea why. Has anybody seen this exception before?
```
org.apache.hadoop.mapred.Child: Exception running child : java.io.IOException: Spill failed
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.checkSpillException(MapTask.java:1379)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.access$200(MapTask.java:711)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer$Buffer.write(MapTask.java:1193)
at java.io.DataOutputStream.write(DataOutputStream.java:90)
at org.apache.hadoop.io.Text.write(Text.java:290)
at org.apache.hadoop.io.serializer.WritableSerialization$WritableSerializer.serialize(WritableSerialization.java:100)
at org.apache.hadoop.io.serializer.WritableSerialization$WritableSerializer.serialize(WritableSerialization.java:84)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.collect(MapTask.java:967)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:583)
at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:92)
at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.write(WrappedMapper.java:111)
at be.ac.ua.comp.ronny.riki.invertedindex.FilteredInvertedIndexBuilder$Map.map(FilteredInvertedIndexBuilder.java:113)
at be.ac.ua.comp.ronny.riki.invertedindex.FilteredInvertedIndexBuilder$Map.map(FilteredInvertedIndexBuilder.java:1)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:652)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:328)
at org.apache.hadoop.mapred.Child$4.run(Child.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:742)
at org.apache.hadoop.mapred.Child.main(Child.java:211)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: org.apache.hadoop.io.ArrayWritable.<init>()
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:123)
at org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:68)
at org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:44)
at org.apache.hadoop.mapreduce.task.ReduceContextImpl.nextKeyValue(ReduceContextImpl.java:145)
at org.apache.hadoop.mapreduce.task.ReduceContextImpl.nextKey(ReduceContextImpl.java:121)
at org.apache.hadoop.mapreduce.lib.reduce.WrappedReducer$Context.nextKey(WrappedReducer.java:291)
at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:168)
at org.apache.hadoop.mapred.Task$NewCombinerRunner.combine(Task.java:1432)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.sortAndSpill(MapTask.java:1457)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.access$600(MapTask.java:711)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer$SpillThread.run(MapTask.java:1349)
Caused by: java.lang.NoSuchMethodException: org.apache.hadoop.io.ArrayWritable.<init>()
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117)
... 10 more
```
Currently, I'm experimenting with some configuration parameters hoping that this error disappears, but until now this was unsuccessful.
The configuration parameters I'm tweaking are:
* mapred.map.tasks = 60
* mapred.reduce.tasks = 12
* Job.MAP\_OUTPUT\_COMPRESS (or mapreduce.map.output.compress) = true
* Job.IO\_SORT\_FACTOR (or mapreduce.task.io.sort.factor) = 10
* Job.IO\_SORT\_MB (or mapreduce.task.io.sort.mb) = 256
* Job.MAP\_JAVA\_OPTS (or mapreduce.map.java.opts) = "-Xmx256" or "-Xmx512"
* Job.REDUCE\_JAVA\_OPTS (or mapreduce.reduce.java.opts) = "-Xmx256" or "-Xmx512"
**Can anybody explain why the exception above occurs? And how to avoid it? Or just a short explanation what the hadoop spill operation implies?** | 2010/11/20 | [
"https://Stackoverflow.com/questions/4233214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/506746/"
] | Ok, all problems are solved.
The Map-Reduce serialization operation needs intern a default constructor for **org.apache.hadoop.io.ArrayWritable**.
Hadoops implementation didn't provide a default constructor for ArrayWritable.
That's why the java.lang.NoSuchMethodException: org.apache.hadoop.io.ArrayWritable.() was thrown and caused the weird spill exception.
A simple wrapper made ArrayWritable really writable and fixed it! Strange that Hadoop did not provide this. | This problem came up for me when the output of one of my map jobs produced a tab character ("\t") or newline character ("\r" or "\n") - Hadoop doesn't handle this well and fails. I was able to solve this using this piece of Python code:
```
if "\t" in output:
output = output.replace("\t", "")
if "\r" in output:
output = output.replace("\r", "")
if "\n" in output:
output = output.replace("\n", "")
```
You may have to do something else for your app. |
17,908,576 | I'm writing a generic library. I have a protected object that needs to be accessed by code in two packages. Both the package containing the object, and the packages that need to access it, are generic. I'll call the packages `Main_Pkg`, `Second_Pkg` and `Object_Pkg` for clarity. All three packages are instantiated with the same type.
With non-generic code, I would simply 'with' `Object_Pkg` in `Main_Pkg` and `Second_Pkg`. I understand that I can't do this with generic packages, since `Object_Pkg` won't be instantiated.
So far, I've tried having `Main_Pkg` create an instance of `Object_Pkg`
```
package Instance_Of_Object_Pkg is new Object_Pkg(Custom_Type)
```
and having `Second_Pkg` access it using code like
```
Main_Pkg.Instance_Of_Object_Pkg.Object.Procedure
```
but I get a compiler error
```
invalid prefix in selected component "Main_Pkg"
```
This is my first time working with generic types, so I'm not sure what's causing the problem or what to try next. Is it possible to do this at all, and if so how? | 2013/07/28 | [
"https://Stackoverflow.com/questions/17908576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2627577/"
] | I think you may be able to use a [generic formal package](http://www.ada-auth.org/standards/12rm/html/RM-12-7.html).
Not bothering with the protected object (being able to access *anything* should demonstrate the point) something like
```
generic
type T is private;
package Object_Pkg is
Arr : array (1 .. 10) of T;
end Object_Pkg;
```
and then specify that `Main_Pkg` is to be instantiated with a type `T` and an instantiation of `Object_Pkg` with the same type, like this:
```
with Object_Pkg;
generic
type T is private;
with package Inst is new Object_Pkg (T);
package Main_Pkg is
Obj : T := Inst.Arr (1);
end Main_Pkg;
```
Now, first instantiate `Object_Pkg`:
```
with Object_Pkg;
package Object_Inst is new Object_Pkg (T => Integer);
```
and then instantiate `Main_Pkg` with the same type and the new instance of `Object_Pkg`:
```
with Object_Inst;
with Main_Pkg;
package Main_Inst is new Main_Pkg (T => Integer,
Inst => Object_Inst);
``` | If Main\_Pkg and Second\_Pkg are closely enough related that you're going to have one of those packages accessing something defined in the other package, then perhaps making them totally separate generic packages isn't the right way to organize them. Consider making them both children of some other package.
It sounds like you have something like
```
generic
type T is private;
package Main_Pkg is ... end Main_Pkg;
generic
type T is private;
package Second_Pkg is ... end Second_Pkg;
```
Note that this doesn't set up a rule that Main\_Pkg and Second\_Pkg have to be instantiated with the same type for T. If your program says something like
```
package Main_Inst is new Main_Pkg (T => T1);
package Second_Inst is new Second_Pkg (T => T2); -- some different type
```
then obviously Second\_Inst and Main\_Inst couldn't really communicate with each other (using the generic type T). Instantiating them with the same type doesn't magically cause a connection between the two instantiations where no connection existed before.
So there has to be some connection between the two generics. Generic formal packages are one possibility, the way Simon presented it. Another possibility is for Second\_Pkg to have a generic formal package parameter that's an instance of Main\_Pkg:
```
generic
with package With_Main_Pkg is new Main_Pkg (<>);
package Second_Pkg is ...
```
and now Second\_Pkg could refer to With\_Main\_Pkg (and it could use `With_Main_Pkg.T` to get Main\_Pkg's formal type).
But it might be simplest to put Main\_Pkg and Second\_Pkg in some larger package, and have T be a parameter to that larger package instead of Main\_Pkg and Second\_Pkg.
```
generic
type T is private;
package Larger_Pkg is
package Object_Inst is new Object_Pkg (T);
-- this might belong in Larger_Pkg's body, instead of the specification.
-- The bodies of Main_Pkg and Second_Pkg would both have it available.
package Main_Pkg is ...
package Second_Pkg is ...
end Larger_Pkg;
```
Maybe Main\_Pkg and Second\_Pkg need to be generic also, if they need some other generic parameters besides T; I don't know. This solution doesn't let you put the specifications of Main\_Pkg and Second\_Pkg in separate units; you have to nest them in Larger\_Pkg. But you can still make the bodies separate by using separate compilation (`package body Main_Pkg is separate;`). And if Main\_Pkg and Second\_Pkg can be generics, you can make them child units:
```
generic
package Larger_Pkg.Main_Pkg is ...
end Larger_Pkg.Main_Pkg;
```
but then Object\_Inst can't be in the body of Larger\_Pkg. It could be in the private part, though.
Anyway, the best answer depends in part on what concepts these packages are supposed to represent in your real program. |
2,110,020 | **Update**
Hi guys!
Got the linking working but now im facing another problem. When i've clicked the link within the tab and clicks on the "Menu"-tab again, the tabs look like shit. See working example link and code below.
Rgds
muttmagandi
<http://www.vallatravet.se/thetabs/>
```
$(document).ready(function(){
$(".fadeOut").fadeTo(0, 0.5);
$("#forklara").bind("click", function(e)
{
$("div:hidden:#one").fadeIn("slow");
});
$(".Rehabilitering").bind("click", function() {
var $tabs= $("#container-1").tabs();
$tabs.tabs('select', 3); // switch to third tab
$("div:hidden:#one").fadeIn("slow");
return false;
});
$(".SO").bind("click", function() {
var $tabs= $("#container-1").tabs();
$tabs.tabs('select', 3); // switch to third tab
$("div:hidden:#two").fadeIn("slow");
return false;
});
});
</script>
<div id="container-1">
<ul>
<li><a href="#fragment-1"><span>one</span></a></li>
<li><a href="#fragment-2"><span>two</span></a></li>
<li><a href="#fragment-3"><span>three</span></a></li>
<li><a href="#fragment-4"><span id="forklara">four</span></a></li>
</ul>
<div id="fragment-1">
<div class="cat-1">
<li><a href="#Rehabilitering" class="Rehabilitering">Rehabilitering</a></li>
<li><a href="#SO" class="SO">Second opinion</a></li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li class="fadeOut">Sjukgymnastik, naprapat & kiropraktor</li>
<li class="fadeOut">Psykologi</li>
<li class="fadeOut">Personstöd</li>
</div>
</div>
<div id="fragment-2">
<div class="cat-1">
<li><a href="#tolast" class="tolast">Rehabilitering</a></li>
<li>Second opinion</li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li>Sjukgymnastik, naprapat & kiropraktor</li>
<li class="fadeOut">Psykologi</li>
<li class="fadeOut">Personstöd</li>
</div>
</div>
<div id="fragment-3">
<div class="cat-1">
<li><a href="#tolast" class="tolast">Rehabilitering</a></li>
<li>Second opinion</li>
<li>Krisstöd</li>
<li>Specialistläkarbesök</li>
<li>Cancerbehandling</li>
</div>
<div class="cat-2">
<li>Dagkirurgi</li>
<li>Inläggning på sjukhus</li>
<li>Sjukgymnastik, naprapat & kiropraktor</li>
<li>Psykologi</li>
<li>Personstöd</li>
</div>
</div>
<div id="fragment-4">
<div id="one" style="padding:25px 0px 0px 20px; display:none;"><b>Rehabilitering</b><br />
The event handler is passed an event object that you can use to prevent default behaviour. To stop both default action and event bubbling, your handler has to return false.
</div>
<div id="two" style="padding:25px 0px 0px 20px; display:none;"><b>Second opinion</b><br />
Ytterligare bedömning av annan läkare vid allvarlig sjukdom eller svårt medicinskt ställningstagande.
</div>
</div>
</div>
``` | 2010/01/21 | [
"https://Stackoverflow.com/questions/2110020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/255861/"
] | I think your problem is just a missing brace and parenthesis in your JavaScript because the same code works fine with those two things added - <http://jsbin.com/eriba/2> .
```
$(document).ready(function(){
var $tabs= $("#container-1").tabs();
$('.tolast').click(function() {
$tabs.tabs('select', 2);
return false;
});
```
Should be...
```
$(document).ready(function(){
var $tabs= $("#container-1").tabs();
$('.tolast').click(function() {
$tabs.tabs('select', 2);
return false;
});
});
``` | no, your problem is that
in here:
```
var $tabs= $("#container-1").tabs();
$('.tolast').click(function() {
$tabs.tabs('select', 2);
return false;
});
```
you have selected the elements with classname 'tolast' which the onclick points to the third tab.
here you can see you have two of that element that has the class set to 'tolast'
```
<div class="cat-1">
<li><a href="#fragment-4" class="tolast">Link to four</a></li>
</div>
<div class="cat-2">
<li><a href="#fragment-4" class="tolast">Link to three</a></li>
</div>
```
I'm sure when you click either of that anchors the third tab will open (Which I can see it's wrong).
I suggest something like this:
```
<div class="cat-1">
<li><a href="#fragment-4" class="to-forth">Link to four</a></li>
</div>
<div class="cat-2">
<li><a href="#fragment-4" class="to-third">Link to three</a></li>
</div>
```
then:
```
var $tabs= $("#container-1").tabs();
$('.to-forth').click(function() {
$tabs.tabs('select', 3); // go to forth tab
return false;
});
$('.to-third').click(function() {
$tabs.tabs('select', 2); // go to third tab
return false;
});
``` |
6,043,841 | i'm trying to fit a negbin model with sqrt link. Unfortunately it seems to be that I have to specify starting values. Is anybody familiar with setting starting values when running the `glm.nb` command (package `MASS`)?
When I don't use starting values, I get an error message:
>
> no valid set of coefficients has been found: please supply starting values
>
>
>
Looking at `?glm.nb` it seems to be possible to set starting values, unfortunately I absolutely don't know how to do this. Some further information: 1.When computing the regression with the standard log link, the regression can be estimated. 2. It is not possible to set the start value for the algorithm to an arbitrary value, so for example
```
glm.nb(<model>,link=sqrt, start=1)
```
does not work! | 2011/05/18 | [
"https://Stackoverflow.com/questions/6043841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/734124/"
] | Finding suitable starting values can be difficult for sufficiently complex problems. However for setting the starting values (the documentation of which is not great, but exists) you should learn to read the error messages. Here is a replicate of your unsuccessful attempt using `start=1` with a built-in data set:
```
>quine.nb1 <- glm.nb(Days ~ Sex + Age + Eth + Lrn, data = quine,
link=sqrt, start=1)
Error in glm.fitter(x = X, y = Y, w = w, start = start, etastart = etastart, :
length of 'start' should equal 7 and correspond to initial coefs for
c("(Intercept)", "SexM", "AgeF1", "AgeF2", "AgeF3", "EthN", "LrnSL", )
```
It tells you exactly what it is expecting: a vector of values for each coefficient to be estimated.
```
quine.nb1 <- glm.nb(Days ~ Sex + Age + Eth + Lrn, data = quine,
link=sqrt, start=rep(1,7))
```
works, because I gave a vector of length 7. You might have to play around with the actual values in it to get a model that always predicts positive values. It is likely that the default algorithm of generating starting values in `glm.nb` gives negative prediction somewhere, and the `sqrt` link cannot tolerate that (unlike the `log`). If you are having trouble finding valid starting values by hand, you can try running a simpler model, and expand estimates from it by 0's for the other parameters to get a good starting location.
**EDIT: building up a model**
Suppose you can't find valid starting values for your complicated model. Then start with a simple one, for example
```
> nb0 <- glm.nb(Days ~ Sex, data=quine, link=sqrt)
> coef(nb0)
(Intercept) SexM
3.9019226 0.3353578
```
Now let's add the next variable using the previous starting values by adding 0 estimates for the effect of the new variable (in this case `Age` has four levels, so needs 3 coefficients):
```
> nb1 <- glm.nb(Days ~ Sex+Age, data=quine, link=sqrt, start=c(coef(nb0), 0,0,0))
> coef(nb1)
(Intercept) SexM AgeF1 AgeF2 AgeF3
3.9127405 -0.1155013 -0.5551010 0.7475166 0.5933048
```
You usually want to keep adding 0's and not, say, 100's, because a coefficient of 0 means that the new variable has no effect - which is exactly what the simpler model that you just fitted assumes. | I got similar error while doing the RR regression using log link binomial as shown below
```
adjrep <-glm(reptest ~ momagecat + paritycat + marstatcat + dept,
family = binomial(link = "log"),
data = hcm1)
> Error: no valid set of coefficients has been found: please supply
> starting values
```
After following up on the instructions of building up a model I arrived on the code below and got coefficients for each the variables below.
```
rep3 <-glm (reptest ~ momagecat + paritycat + marstatcat + dept,
family = binomial(link = "log"),
data = hcm1,
start=c(coef(rep1),0,0,0))
``` |
13,298,432 | I am attemping to do a nested join from 2 sets of unioned tables. I do not understand why I am getting the following errors:
>
> Msg 156, Level 15, State 1, Line 15 Incorrect syntax near the keyword
> 'INNER'. Msg 156, Level 15, State 1, Line 24 Incorrect syntax near the
> keyword 'On'.
>
>
>
I assume based on the errors there is a problem with my ()'s but the syntax does follow the language shown from [Inner Join Operation](http://msdn.microsoft.com/en-us/library/office/bb208854%28v=office.12%29.aspx).
Here is the code:
```
SELECT TOP 1000
Pus.SerialnoId,Hus.RT,Hus.DIVISION,Hus.REGION,Hus.ADJHSG,Hus.ADJINC,Hus.WGTP,Hus.NP,Hus.TYPE,Hus.ACR,Hus.AGS,Hus.BLD,Hus.BUS,Hus.CONP,Hus.ELEP,Hus.FS,Hus.FULP,Hus.GASP,Hus.HFL,Hus.INSP,Hus.KIT,Hus.MHP,Hus.MRGI,Hus.MRGP,Hus.MRGT,Hus.MRGX,Hus.RNTM,Hus.RNTP,Hus.SMP,Hus.TEL,Hus.TEN,Hus.VACS,Hus.VEH,Hus.WATP,Hus.YBL,Hus.FES,Hus.FINCP,Hus.FPARC,Hus.GRNTP,Hus.GRPIP,Hus.HHL,Hus.HHT,Hus.HINCP,Hus.HUGCL,Hus.HUPAC,Hus.HUPAOC,Hus.HUPARC,Hus.LNGI,Hus.MV,Hus.NOC,Hus.NPF,Hus.NPP,Hus.NR,Hus.NRC,Hus.OCPIP,Hus.PARTNER,Hus.PSF,Hus.R18,Hus.R60,Hus.R65,Hus.RESMODE,Hus.SMOCP,Hus.SMX,Hus.SRNT,Hus.SVAL,Hus.TAXP,Hus.WIF,Hus.WKEXREL,Hus.WORKSTAT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TP54,Pus.PWGTP55,Pus.PWGTP56,Pus.PWGTP57,Pus.PWGTP58,Pus.PWGTP59,Pus.PWGTP60,Pus.PWGTP61,Pus.PWGTP62,Pus.PWGTP63,Pus.PWGTP64,Pus.PWGTP65,Pus.PWGTP66,Pus.PWGTP67,Pus.PWGTP68,Pus.PWGTP69,Pus.PWGTP70,Pus.PWGTP71,Pus.PWGTP72,Pus.PWGTP73,Pus.PWGTP74,Pus.PWGTP75,Pus.PWGTP76,Pus.PWGTP77,Pus.PWGTP78,Pus.PWGTP79,Pus.PWGTP80
FROM
(select * FROM
(select serialnoId,RT,DIVISION,PUMA,REGION,ST,ADJHSG,ADJINC,WGTP,NP,TYPE,ACR,AGS,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,KIT,MHP,MRGI,MRGP,MRGT,MRGX,RNTM,RNTP,SMP,TEL,TEN,VACS,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP,HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,LNGI,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PSF,R18,R60,R65,RESMODE,SMOCP,SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP,FMRGXP,FPLMP,FRMSP,FRNTMP,FRNTP,FSMP,FSMXHP,FSMXSP,FTAXP,FTELP,FTENP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3,WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28,WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54,WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WGTP77,WGTP78,WGTP79,WGTP80 from dbo.AcsBy320052007Hus
UNION ALL
select serialnoId,RT,DIVISION,PUMA,REGION,ST,ADJHSG,ADJINC,WGTP,NP,TYPE,ACR,AGS,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,KIT,MHP,MRGI,MRGP,MRGT,MRGX,RNTM,RNTP,SMP,TEL,TEN,VACS,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP,HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,LNGI,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PSF,R18,R60,R65,RESMODE,SMOCP,SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP,FMRGXP, FPLMP,FRMSP,FRNTMP,FRNTP,FSMP,FSMXHP,FSMXSP,FTAXP,FTELP,FTENP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3,WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28,WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54,WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WGTP77,WGTP78,WGTP79,WGTP80 from dbo.AcsBy320082010Hus
) AS Hus
)
INNER JOIN
(select * FROM
(
SELECT serialnoId,RT,SPORDER,PUMA,ST,ADJINC,PWGTP,AGEP,CIT,COW,DDRS,DEYE,DOUT,DPHY,DREM,ENG,FER,GCL,GCM,GCR,INTP,JWMNP,JWRIP,JWTR,LANX,MAR,MIG,MIL,MLPA,MLPB,MLPC,MLPD,MLPE,MLPF,MLPG,MLPH,MLPI,MLPJ,MLPK,NWAB,NWAV,NWLA,NWLK,NWRE,OIP,PAP,RETP,SCH,SCHG,SCHL,SEMP,SEX,SSIP,SSP,WAGP,WKHP,WKL,WKW,YOEP,ANC,ANC1P,ANC2P,DECADE,DRIVESP,ESP,ESR,HISP,INDP,JWAP,JWDP,LANP,MIGPUMA,MIGSP,MSP,NAICSP,NATIVITY,OC,PAOC,PERNP,PINCP,POBP,POVPIP,POWPUMA,POWSP,QTRBIR,RAC1P,RAC2P,RAC3P,RACAIAN,RACASN,RACBLK,RACNHPI,RACNUM,RACSOR,RACWHT,RC,SFN,SFR,VPS,WAOB,FAGEP,FANCP,FCITP,FCOWP,FDDRSP,FDEYEP,FDOUTP,FDPHYP,FDREMP,FENGP,FESRP,FFERP,FGCLP,FGCMP,FGCRP,FHISP,FINDP,FINTP,FJWDP,FJWMNP,FJWRIP,FJWTRP,FLANP,FLANXP,FMARP,FMIGP,FMIGSP,FMILPP,FMILSP,FOCCP,FOIP,FPAP,FPOBP,FPOWSP,FRACP,FRELP,FRETP,FSCHGP,FSCHLP,FSCHP,FSEMP,FSEXP,FSSIP,FSSP,FWAGP,FWKHP,FWKLP,FWKWP,FYOEP,PWGTP1,PWGTP2,PWGTP3,PWGTP4,PWGTP5,PWGTP6,PWGTP7,PWGTP8,PWGTP9,PWGTP10,PWGTP11,PWGTP12,PWGTP13,PWGTP14,PWGTP15,PWGTP16,PWGTP17,PWGTP18,PWGTP19,PWGTP20,PWGTP21,PWGTP22,PWGTP23,PWGTP24,PWGTP25,PWGTP26,PWGTP27,PWGTP28,PWGTP29,PWGTP30,PWGTP31,PWGTP32,PWGTP33,PWGTP34,PWGTP35,PWGTP36,PWGTP37,PWGTP38,PWGTP39,PWGTP40,PWGTP41,PWGTP42,PWGTP43,PWGTP44,PWGTP45,PWGTP46,PWGTP47,PWGTP48,PWGTP49,PWGTP50,PWGTP51,PWGTP52,PWGTP53,PWGTP54,PWGTP55,PWGTP56,PWGTP57,PWGTP58,PWGTP59,PWGTP60,PWGTP61,PWGTP62,PWGTP63,PWGTP64,PWGTP65,PWGTP66,PWGTP67,PWGTP68,PWGTP69,PWGTP70,PWGTP71,PWGTP72,PWGTP73,PWGTP74,PWGTP75,PWGTP76,PWGTP77,PWGTP78,PWGTP79,PWGTP80 FROM dbo.AcsBy320052007Pus
UNION ALL
select serialnoId,RT,SPORDER,PUMA,ST,ADJINC,PWGTP,AGEP,CIT,COW,DDRS,DEYE,DOUT,DPHY,DREM,ENG,FER,GCL,GCM,GCR,INTP,JWMNP,JWRIP,JWTR,LANX,MAR,MIG,MIL,MLPA,MLPB,MLPC,MLPD,MLPE,MLPF,MLPG,MLPH,MLPI,MLPJ,MLPK,NWAB,NWAV,NWLA,NWLK,NWRE,OIP,PAP,RETP,SCH,SCHG,SCHL,SEMP,SEX,SSIP,SSP,WAGP,WKHP,WKL,WKW,YOEP,ANC,ANC1P,ANC2P,DECADE,DRIVESP,ESP,ESR,HISP,INDP,JWAP,JWDP,LANP,MIGPUMA,MIGSP,MSP,NAICSP,NATIVITY,OC,PAOC,PERNP,PINCP,POBP,POVPIP,POWPUMA,POWSP,QTRBIR,RAC1P,RAC2P,RAC3P,RACAIAN,RACASN,RACBLK,RACNHPI,RACNUM,RACSOR,RACWHT,RC,SFN,SFR,VPS,WAOB,FAGEP,FANCP,FCITP,FCOWP,FDDRSP,FDEYEP,FDOUTP,FDPHYP,FDREMP,FENGP,FESRP,FFERP,FGCLP,FGCMP,FGCRP,FHISP,FINDP,FINTP,FJWDP,FJWMNP,FJWRIP,FJWTRP,FLANP,FLANXP,FMARP,FMIGP,FMIGSP,FMILPP,FMILSP,FOCCP,FOIP,FPAP,FPOBP,FPOWSP,FRACP,FRELP,FRETP,FSCHGP,FSCHLP,FSCHP,FSEMP,FSEXP,FSSIP,FSSP,FWAGP,FWKHP,FWKLP,FWKWP,FYOEP,PWGTP1,PWGTP2,PWGTP3,PWGTP4,PWGTP5,PWGTP6,PWGTP7,PWGTP8,PWGTP9,PWGTP10,PWGTP11,PWGTP12,PWGTP13,PWGTP14,PWGTP15,PWGTP16,PWGTP17,PWGTP18,PWGTP19,PWGTP20,PWGTP21,PWGTP22,PWGTP23,PWGTP24,PWGTP25,PWGTP26,PWGTP27,PWGTP28,PWGTP29,PWGTP30,PWGTP31,PWGTP32,PWGTP33,PWGTP34,PWGTP35,PWGTP36,PWGTP37,PWGTP38,PWGTP39,PWGTP40,PWGTP41,PWGTP42,PWGTP43,PWGTP44,PWGTP45,PWGTP46,PWGTP47,PWGTP48,PWGTP49,PWGTP50,PWGTP51,PWGTP52,PWGTP53,PWGTP54,PWGTP55,PWGTP56,PWGTP57,PWGTP58,PWGTP59,PWGTP60,PWGTP61,PWGTP62,PWGTP63,PWGTP64,PWGTP65,PWGTP66,PWGTP67,PWGTP68,PWGTP69,PWGTP70,PWGTP71,PWGTP72,PWGTP73,PWGTP74,PWGTP75,PWGTP76,PWGTP77,PWGTP78,PWGTP79,PWGTP80 FROM dbo.AcsBy320082010Pus
) AS Pus
)
On Hus.SerialNoId = Pus.SerialNoId
``` | 2012/11/08 | [
"https://Stackoverflow.com/questions/13298432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/714237/"
] | I don't think you need the outer `SELECT *` statements... try changing your `FROM` to the following:
```
FROM
(
SELECT serialnoId...
FROM dbo.AcsBy320052007Hus
UNION ALL
SELECT serialnoId...
FROM dbo.AcsBy320082010Hus
) AS Hus
INNER JOIN
(
SELECT serialnoId...
FROM dbo.AcsBy320052007Pus
UNION ALL
SELECT serialnoId...
FROM dbo.AcsBy320082010Pus
) AS Pus
ON Hus.SerialNoId = Pus.SerialNoId
``` | Have you tried adding parenthesis around the sub query?
```
SELECT TOP 1000
Pus.SerialnoId,Hus.RT,Hus.DIVISION,Hus.REGION,Hus.ADJHSG,Hus.ADJINC,Hus.WGTP,Hus.NP,Hus.TYPE,Hus.ACR,Hus.AGS,Hus.BLD,Hus.BUS,Hus.CONP,Hus.ELEP,Hus.FS,Hus.FULP,Hus.GASP,Hus.HFL,Hus.INSP,Hus.KIT,Hus.MHP,Hus.MRGI,Hus.MRGP,Hus.MRGT,Hus.MRGX,Hus.RNTM,Hus.RNTP,Hus.SMP,Hus.TEL,Hus.TEN,Hus.VACS,Hus.VEH,Hus.WATP,Hus.YBL,Hus.FES,Hus.FINCP,Hus.FPARC,Hus.GRNTP,Hus.GRPIP,Hus.HHL,Hus.HHT,Hus.HINCP,Hus.HUGCL,Hus.HUPAC,Hus.HUPAOC,Hus.HUPARC,Hus.LNGI,Hus.MV,Hus.NOC,Hus.NPF,Hus.NPP,Hus.NR,Hus.NRC,Hus.OCPIP,Hus.PARTNER,Hus.PSF,Hus.R18,Hus.R60,Hus.R65,Hus.RESMODE,Hus.SMOCP,Hus.SMX,Hus.SRNT,Hus.SVAL,Hus.TAXP,Hus.WIF,Hus.WKEXREL,Hus.WORKSTAT,Hus.FACRP,Hus.FAGSP,Hus.FBDSP,Hus.FBLDP,Hus.FBUSP,Hus.FCONP,Hus.FELEP,Hus.FFSP,Hus.FFULP,H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TP62,Pus.PWGTP63,Pus.PWGTP64,Pus.PWGTP65,Pus.PWGTP66,Pus.PWGTP67,Pus.PWGTP68,Pus.PWGTP69,Pus.PWGTP70,Pus.PWGTP71,Pus.PWGTP72,Pus.PWGTP73,Pus.PWGTP74,Pus.PWGTP75,Pus.PWGTP76,Pus.PWGTP77,Pus.PWGTP78,Pus.PWGTP79,Pus.PWGTP80
FROM
(
(select * FROM
(select serialnoId,RT,DIVISION,PUMA,REGION,ST,ADJHSG,ADJINC,WGTP,NP,TYPE,ACR,AGS,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,KIT,MHP,MRGI,MRGP,MRGT,MRGX,RNTM,RNTP,SMP,TEL,TEN,VACS,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP,HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,LNGI,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PSF,R18,R60,R65,RESMODE,SMOCP,SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP,FMRGXP,FPLMP,FRMSP,FRNTMP,FRNTP,FSMP,FSMXHP,FSMXSP,FTAXP,FTELP,FTENP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3,WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28,WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54,WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WGTP77,WGTP78,WGTP79,WGTP80 from dbo.AcsBy320052007Hus
UNION ALL
select serialnoId,RT,DIVISION,PUMA,REGION,ST,ADJHSG,ADJINC,WGTP,NP,TYPE,ACR,AGS,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,KIT,MHP,MRGI,MRGP,MRGT,MRGX,RNTM,RNTP,SMP,TEL,TEN,VACS,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP,HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,LNGI,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PSF,R18,R60,R65,RESMODE,SMOCP,SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP,FMRGXP, FPLMP,FRMSP,FRNTMP,FRNTP,FSMP,FSMXHP,FSMXSP,FTAXP,FTELP,FTENP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3,WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28,WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54,WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WGTP77,WGTP78,WGTP79,WGTP80 from dbo.AcsBy320082010Hus
) AS Hus
)
INNER JOIN
(select * FROM
(
SELECT serialnoId,RT,SPORDER,PUMA,ST,ADJINC,PWGTP,AGEP,CIT,COW,DDRS,DEYE,DOUT,DPHY,DREM,ENG,FER,GCL,GCM,GCR,INTP,JWMNP,JWRIP,JWTR,LANX,MAR,MIG,MIL,MLPA,MLPB,MLPC,MLPD,MLPE,MLPF,MLPG,MLPH,MLPI,MLPJ,MLPK,NWAB,NWAV,NWLA,NWLK,NWRE,OIP,PAP,RETP,SCH,SCHG,SCHL,SEMP,SEX,SSIP,SSP,WAGP,WKHP,WKL,WKW,YOEP,ANC,ANC1P,ANC2P,DECADE,DRIVESP,ESP,ESR,HISP,INDP,JWAP,JWDP,LANP,MIGPUMA,MIGSP,MSP,NAICSP,NATIVITY,OC,PAOC,PERNP,PINCP,POBP,POVPIP,POWPUMA,POWSP,QTRBIR,RAC1P,RAC2P,RAC3P,RACAIAN,RACASN,RACBLK,RACNHPI,RACNUM,RACSOR,RACWHT,RC,SFN,SFR,VPS,WAOB,FAGEP,FANCP,FCITP,FCOWP,FDDRSP,FDEYEP,FDOUTP,FDPHYP,FDREMP,FENGP,FESRP,FFERP,FGCLP,FGCMP,FGCRP,FHISP,FINDP,FINTP,FJWDP,FJWMNP,FJWRIP,FJWTRP,FLANP,FLANXP,FMARP,FMIGP,FMIGSP,FMILPP,FMILSP,FOCCP,FOIP,FPAP,FPOBP,FPOWSP,FRACP,FRELP,FRETP,FSCHGP,FSCHLP,FSCHP,FSEMP,FSEXP,FSSIP,FSSP,FWAGP,FWKHP,FWKLP,FWKWP,FYOEP,PWGTP1,PWGTP2,PWGTP3,PWGTP4,PWGTP5,PWGTP6,PWGTP7,PWGTP8,PWGTP9,PWGTP10,PWGTP11,PWGTP12,PWGTP13,PWGTP14,PWGTP15,PWGTP16,PWGTP17,PWGTP18,PWGTP19,PWGTP20,PWGTP21,PWGTP22,PWGTP23,PWGTP24,PWGTP25,PWGTP26,PWGTP27,PWGTP28,PWGTP29,PWGTP30,PWGTP31,PWGTP32,PWGTP33,PWGTP34,PWGTP35,PWGTP36,PWGTP37,PWGTP38,PWGTP39,PWGTP40,PWGTP41,PWGTP42,PWGTP43,PWGTP44,PWGTP45,PWGTP46,PWGTP47,PWGTP48,PWGTP49,PWGTP50,PWGTP51,PWGTP52,PWGTP53,PWGTP54,PWGTP55,PWGTP56,PWGTP57,PWGTP58,PWGTP59,PWGTP60,PWGTP61,PWGTP62,PWGTP63,PWGTP64,PWGTP65,PWGTP66,PWGTP67,PWGTP68,PWGTP69,PWGTP70,PWGTP71,PWGTP72,PWGTP73,PWGTP74,PWGTP75,PWGTP76,PWGTP77,PWGTP78,PWGTP79,PWGTP80 FROM dbo.AcsBy320052007Pus
UNION ALL
select serialnoId,RT,SPORDER,PUMA,ST,ADJINC,PWGTP,AGEP,CIT,COW,DDRS,DEYE,DOUT,DPHY,DREM,ENG,FER,GCL,GCM,GCR,INTP,JWMNP,JWRIP,JWTR,LANX,MAR,MIG,MIL,MLPA,MLPB,MLPC,MLPD,MLPE,MLPF,MLPG,MLPH,MLPI,MLPJ,MLPK,NWAB,NWAV,NWLA,NWLK,NWRE,OIP,PAP,RETP,SCH,SCHG,SCHL,SEMP,SEX,SSIP,SSP,WAGP,WKHP,WKL,WKW,YOEP,ANC,ANC1P,ANC2P,DECADE,DRIVESP,ESP,ESR,HISP,INDP,JWAP,JWDP,LANP,MIGPUMA,MIGSP,MSP,NAICSP,NATIVITY,OC,PAOC,PERNP,PINCP,POBP,POVPIP,POWPUMA,POWSP,QTRBIR,RAC1P,RAC2P,RAC3P,RACAIAN,RACASN,RACBLK,RACNHPI,RACNUM,RACSOR,RACWHT,RC,SFN,SFR,VPS,WAOB,FAGEP,FANCP,FCITP,FCOWP,FDDRSP,FDEYEP,FDOUTP,FDPHYP,FDREMP,FENGP,FESRP,FFERP,FGCLP,FGCMP,FGCRP,FHISP,FINDP,FINTP,FJWDP,FJWMNP,FJWRIP,FJWTRP,FLANP,FLANXP,FMARP,FMIGP,FMIGSP,FMILPP,FMILSP,FOCCP,FOIP,FPAP,FPOBP,FPOWSP,FRACP,FRELP,FRETP,FSCHGP,FSCHLP,FSCHP,FSEMP,FSEXP,FSSIP,FSSP,FWAGP,FWKHP,FWKLP,FWKWP,FYOEP,PWGTP1,PWGTP2,PWGTP3,PWGTP4,PWGTP5,PWGTP6,PWGTP7,PWGTP8,PWGTP9,PWGTP10,PWGTP11,PWGTP12,PWGTP13,PWGTP14,PWGTP15,PWGTP16,PWGTP17,PWGTP18,PWGTP19,PWGTP20,PWGTP21,PWGTP22,PWGTP23,PWGTP24,PWGTP25,PWGTP26,PWGTP27,PWGTP28,PWGTP29,PWGTP30,PWGTP31,PWGTP32,PWGTP33,PWGTP34,PWGTP35,PWGTP36,PWGTP37,PWGTP38,PWGTP39,PWGTP40,PWGTP41,PWGTP42,PWGTP43,PWGTP44,PWGTP45,PWGTP46,PWGTP47,PWGTP48,PWGTP49,PWGTP50,PWGTP51,PWGTP52,PWGTP53,PWGTP54,PWGTP55,PWGTP56,PWGTP57,PWGTP58,PWGTP59,PWGTP60,PWGTP61,PWGTP62,PWGTP63,PWGTP64,PWGTP65,PWGTP66,PWGTP67,PWGTP68,PWGTP69,PWGTP70,PWGTP71,PWGTP72,PWGTP73,PWGTP74,PWGTP75,PWGTP76,PWGTP77,PWGTP78,PWGTP79,PWGTP80 FROM dbo.AcsBy320082010Pus
) AS Pus
)
) myData
On Hus.SerialNoId = Pus.SerialNoId
``` |
13,298,432 | I am attemping to do a nested join from 2 sets of unioned tables. I do not understand why I am getting the following errors:
>
> Msg 156, Level 15, State 1, Line 15 Incorrect syntax near the keyword
> 'INNER'. Msg 156, Level 15, State 1, Line 24 Incorrect syntax near the
> keyword 'On'.
>
>
>
I assume based on the errors there is a problem with my ()'s but the syntax does follow the language shown from [Inner Join Operation](http://msdn.microsoft.com/en-us/library/office/bb208854%28v=office.12%29.aspx).
Here is the code:
```
SELECT TOP 1000
Pus.SerialnoId,Hus.RT,Hus.DIVISION,Hus.REGION,Hus.ADJHSG,Hus.ADJINC,Hus.WGTP,Hus.NP,Hus.TYPE,Hus.ACR,Hus.AGS,Hus.BLD,Hus.BUS,Hus.CONP,Hus.ELEP,Hus.FS,Hus.FULP,Hus.GASP,Hus.HFL,Hus.INSP,Hus.KIT,Hus.MHP,Hus.MRGI,Hus.MRGP,Hus.MRGT,Hus.MRGX,Hus.RNTM,Hus.RNTP,Hus.SMP,Hus.TEL,Hus.TEN,Hus.VACS,Hus.VEH,Hus.WATP,Hus.YBL,Hus.FES,Hus.FINCP,Hus.FPARC,Hus.GRNTP,Hus.GRPIP,Hus.HHL,Hus.HHT,Hus.HINCP,Hus.HUGCL,Hus.HUPAC,Hus.HUPAOC,Hus.HUPARC,Hus.LNGI,Hus.MV,Hus.NOC,Hus.NPF,Hus.NPP,Hus.NR,Hus.NRC,Hus.OCPIP,Hus.PARTNER,Hus.PSF,Hus.R18,Hus.R60,Hus.R65,Hus.RESMODE,Hus.SMOCP,Hus.SMX,Hus.SRNT,Hus.SVAL,Hus.TAXP,Hus.WIF,Hus.WKEXREL,Hus.WORKSTAT,Hus.FACRP,Hus.FAGSP,Hus.FBDSP,Hus.FBLDP,Hus.FBUSP,Hus.FCONP,Hus.FELEP,Hus.FFSP,Hus.FFULP,Hus.FGASP,Hus.FHFLP,Hus.FINSP,Hus.FKITP,Hus.FMHP,Hus.FMRGIP,Hus.FMRGP,Hus.FMRGTP,Hus.FMRGXP,Hus.FPLMP,Hus.FRMSP,Hus.FRNTMP,Hus.FRNTP,Hus.FSMP,Hus.FSMXHP,Hus.FSMXSP,Hus.FTA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P77,Pus.PWGTP78,Pus.PWGTP79,Pus.PWGTP80
FROM
(select * FROM
(select serialnoId,RT,DIVISION,PUMA,REGION,ST,ADJHSG,ADJINC,WGTP,NP,TYPE,ACR,AGS,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,KIT,MHP,MRGI,MRGP,MRGT,MRGX,RNTM,RNTP,SMP,TEL,TEN,VACS,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP,HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,LNGI,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PSF,R18,R60,R65,RESMODE,SMOCP,SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP,FMRGXP,FPLMP,FRMSP,FRNTMP,FRNTP,FSMP,FSMXHP,FSMXSP,FTAXP,FTELP,FTENP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3,WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28,WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54,WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WGTP77,WGTP78,WGTP79,WGTP80 from dbo.AcsBy320052007Hus
UNION ALL
select serialnoId,RT,DIVISION,PUMA,REGION,ST,ADJHSG,ADJINC,WGTP,NP,TYPE,ACR,AGS,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,KIT,MHP,MRGI,MRGP,MRGT,MRGX,RNTM,RNTP,SMP,TEL,TEN,VACS,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP,HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,LNGI,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PSF,R18,R60,R65,RESMODE,SMOCP,SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP,FMRGXP, FPLMP,FRMSP,FRNTMP,FRNTP,FSMP,FSMXHP,FSMXSP,FTAXP,FTELP,FTENP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3,WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28,WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54,WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WG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,PWGTP26,PWGTP27,PWGTP28,PWGTP29,PWGTP30,PWGTP31,PWGTP32,PWGTP33,PWGTP34,PWGTP35,PWGTP36,PWGTP37,PWGTP38,PWGTP39,PWGTP40,PWGTP41,PWGTP42,PWGTP43,PWGTP44,PWGTP45,PWGTP46,PWGTP47,PWGTP48,PWGTP49,PWGTP50,PWGTP51,PWGTP52,PWGTP53,PWGTP54,PWGTP55,PWGTP56,PWGTP57,PWGTP58,PWGTP59,PWGTP60,PWGTP61,PWGTP62,PWGTP63,PWGTP64,PWGTP65,PWGTP66,PWGTP67,PWGTP68,PWGTP69,PWGTP70,PWGTP71,PWGTP72,PWGTP73,PWGTP74,PWGTP75,PWGTP76,PWGTP77,PWGTP78,PWGTP79,PWGTP80 FROM dbo.AcsBy320052007Pus
UNION ALL
select serialnoId,RT,SPORDER,PUMA,ST,ADJINC,PWGTP,AGEP,CIT,COW,DDRS,DEYE,DOUT,DPHY,DREM,ENG,FER,GCL,GCM,GCR,INTP,JWMNP,JWRIP,JWTR,LANX,MAR,MIG,MIL,MLPA,MLPB,MLPC,MLPD,MLPE,MLPF,MLPG,MLPH,MLPI,MLPJ,MLPK,NWAB,NWAV,NWLA,NWLK,NWRE,OIP,PAP,RETP,SCH,SCHG,SCHL,SEMP,SEX,SSIP,SSP,WAGP,WKHP,WKL,WKW,YOEP,ANC,ANC1P,ANC2P,DECADE,DRIVESP,ESP,ESR,HISP,INDP,JWAP,JWDP,LANP,MIGPUMA,MIGSP,MSP,NAICSP,NATIVITY,OC,PAOC,PERNP,PINCP,POBP,POVPIP,POWPUMA,POWSP,QTRBIR,RAC1P,RAC2P,RAC3P,RACAIAN,RACASN,RACBLK,RACNHPI,RACNUM,RACSOR,RACWHT,RC,SFN,SFR,VPS,WAOB,FAGEP,FANCP,FCITP,FCOWP,FDDRSP,FDEYEP,FDOUTP,FDPHYP,FDREMP,FENGP,FESRP,FFERP,FGCLP,FGCMP,FGCRP,FHISP,FINDP,FINTP,FJWDP,FJWMNP,FJWRIP,FJWTRP,FLANP,FLANXP,FMARP,FMIGP,FMIGSP,FMILPP,FMILSP,FOCCP,FOIP,FPAP,FPOBP,FPOWSP,FRACP,FRELP,FRETP,FSCHGP,FSCHLP,FSCHP,FSEMP,FSEXP,FSSIP,FSSP,FWAGP,FWKHP,FWKLP,FWKWP,FYOEP,PWGTP1,PWGTP2,PWGTP3,PWGTP4,PWGTP5,PWGTP6,PWGTP7,PWGTP8,PWGTP9,PWGTP10,PWGTP11,PWGTP12,PWGTP13,PWGTP14,PWGTP15,PWGTP16,PWGTP17,PWGTP18,PWGTP19,PWGTP20,PWGTP21,PWGTP22,PWGTP23,PWGTP24,PWGTP25,PWGTP26,PWGTP27,PWGTP28,PWGTP29,PWGTP30,PWGTP31,PWGTP32,PWGTP33,PWGTP34,PWGTP35,PWGTP36,PWGTP37,PWGTP38,PWGTP39,PWGTP40,PWGTP41,PWGTP42,PWGTP43,PWGTP44,PWGTP45,PWGTP46,PWGTP47,PWGTP48,PWGTP49,PWGTP50,PWGTP51,PWGTP52,PWGTP53,PWGTP54,PWGTP55,PWGTP56,PWGTP57,PWGTP58,PWGTP59,PWGTP60,PWGTP61,PWGTP62,PWGTP63,PWGTP64,PWGTP65,PWGTP66,PWGTP67,PWGTP68,PWGTP69,PWGTP70,PWGTP71,PWGTP72,PWGTP73,PWGTP74,PWGTP75,PWGTP76,PWGTP77,PWGTP78,PWGTP79,PWGTP80 FROM dbo.AcsBy320082010Pus
) AS Pus
)
On Hus.SerialNoId = Pus.SerialNoId
``` | 2012/11/08 | [
"https://Stackoverflow.com/questions/13298432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/714237/"
] | I don't think you need the outer `SELECT *` statements... try changing your `FROM` to the following:
```
FROM
(
SELECT serialnoId...
FROM dbo.AcsBy320052007Hus
UNION ALL
SELECT serialnoId...
FROM dbo.AcsBy320082010Hus
) AS Hus
INNER JOIN
(
SELECT serialnoId...
FROM dbo.AcsBy320052007Pus
UNION ALL
SELECT serialnoId...
FROM dbo.AcsBy320082010Pus
) AS Pus
ON Hus.SerialNoId = Pus.SerialNoId
``` | You have the table aliases in the wrong place, try:
```
SELECT TOP 1000
Pus.SerialnoId,Hus.RT,Hus.DIVISION,Hus.REGION,Hus.ADJHSG,Hus.ADJINC,Hus.WGTP,Hus.NP,Hus.TYPE,Hus.ACR,Hus.AGS,Hus.BLD,Hus.BUS,Hus.CONP,Hus.ELEP,Hus.FS,Hus.FULP,Hus.GASP,Hus.HFL,Hus.INSP,Hus.KIT,Hus.MHP,Hus.MRGI,Hus.MRGP,Hus.MRGT,Hus.MRGX,Hus.RNTM,Hus.RNTP,Hus.SMP,Hus.TEL,Hus.TEN,Hus.VACS,Hus.VEH,Hus.WATP,Hus.YBL,Hus.FES,Hus.FINCP,Hus.FPARC,Hus.GRNTP,Hus.GRPIP,Hus.HHL,Hus.HHT,Hus.HINCP,Hus.HUGCL,Hus.HUPAC,Hus.HUPAOC,Hus.HUPARC,Hus.LNGI,Hus.MV,Hus.NOC,Hus.NPF,Hus.NPP,Hus.NR,Hus.NRC,Hus.OCPIP,Hus.PARTNER,Hus.PSF,Hus.R18,Hus.R60,Hus.R65,Hus.RESMODE,Hus.SMOCP,Hus.SMX,Hus.SRNT,Hus.SVAL,Hus.TAXP,Hus.WIF,Hus.WKEXREL,Hus.WORKSTAT,Hus.FACRP,Hus.FAGSP,Hus.FBDSP,Hus.FBLDP,Hus.FBUSP,Hus.FCONP,Hus.FELEP,Hus.FFSP,Hus.FFULP,Hus.FGASP,Hus.FHFLP,Hus.FINSP,Hus.FKITP,Hus.FMHP,Hus.FMRGIP,Hus.FMRGP,Hus.FMRGTP,Hus.FMRGXP,Hus.FPLMP,Hus.FRMSP,Hus.FRNTMP,Hus.FRNTP,Hus.FSMP,Hus.FSMXHP,Hus.FSMXSP,Hus.FTAXP,Hus.FTELP,Hus.FTENP,Hus.FVACSP,Hus.FVALP,Hus.FVEHP,Hus.FWATP,Hus.FYBLP,Hus.WGTP1,Hus.WGTP2,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GTP,NP,TYPE,ACR,AGS,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,KIT,MHP,MRGI,MRGP,MRGT,MRGX,RNTM,RNTP,SMP,TEL,TEN,VACS,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP,HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,LNGI,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PSF,R18,R60,R65,RESMODE,SMOCP,SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP,FMRGXP,FPLMP,FRMSP,FRNTMP,FRNTP,FSMP,FSMXHP,FSMXSP,FTAXP,FTELP,FTENP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3,WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28,WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54,WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WGTP77,WGTP78,WGTP79,WGTP80 from dbo.AcsBy320052007Hus
UNION ALL
select serialnoId,RT,DIVISION,PUMA,REGION,ST,ADJHSG,ADJINC,WGTP,NP,TYPE,ACR,AGS,BLD,BUS,CONP,ELEP,FS,FULP,GASP,HFL,INSP,KIT,MHP,MRGI,MRGP,MRGT,MRGX,RNTM,RNTP,SMP,TEL,TEN,VACS,VEH,WATP,YBL,FES,FINCP,FPARC,GRNTP,GRPIP,HHL,HHT,HINCP,HUGCL,HUPAC,HUPAOC,HUPARC,LNGI,MV,NOC,NPF,NPP,NR,NRC,OCPIP,PARTNER,PSF,R18,R60,R65,RESMODE,SMOCP,SMX,SRNT,SVAL,TAXP,WIF,WKEXREL,WORKSTAT,FACRP,FAGSP,FBDSP,FBLDP,FBUSP,FCONP,FELEP,FFSP,FFULP,FGASP,FHFLP,FINSP,FKITP,FMHP,FMRGIP,FMRGP,FMRGTP,FMRGXP, FPLMP,FRMSP,FRNTMP,FRNTP,FSMP,FSMXHP,FSMXSP,FTAXP,FTELP,FTENP,FVACSP,FVALP,FVEHP,FWATP,FYBLP,WGTP1,WGTP2,WGTP3,WGTP4,WGTP5,WGTP6,WGTP7,WGTP8,WGTP9,WGTP10,WGTP11,WGTP12,WGTP13,WGTP14,WGTP15,WGTP16,WGTP17,WGTP18,WGTP19,WGTP20,WGTP21,WGTP22,WGTP23,WGTP24,WGTP25,WGTP26,WGTP27,WGTP28,WGTP29,WGTP30,WGTP31,WGTP32,WGTP33,WGTP34,WGTP35,WGTP36,WGTP37,WGTP38,WGTP39,WGTP40,WGTP41,WGTP42,WGTP43,WGTP44,WGTP45,WGTP46,WGTP47,WGTP48,WGTP49,WGTP50,WGTP51,WGTP52,WGTP53,WGTP54,WGTP55,WGTP56,WGTP57,WGTP58,WGTP59,WGTP60,WGTP61,WGTP62,WGTP63,WGTP64,WGTP65,WGTP66,WGTP67,WGTP68,WGTP69,WGTP70,WGTP71,WGTP72,WGTP73,WGTP74,WGTP75,WGTP76,WGTP77,WGTP78,WGTP79,WGTP80 from dbo.AcsBy320082010Hus
)
) AS Hus
INNER JOIN
(select * FROM
(
SELECT serialnoId,RT,SPORDER,PUMA,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38,PWGTP39,PWGTP40,PWGTP41,PWGTP42,PWGTP43,PWGTP44,PWGTP45,PWGTP46,PWGTP47,PWGTP48,PWGTP49,PWGTP50,PWGTP51,PWGTP52,PWGTP53,PWGTP54,PWGTP55,PWGTP56,PWGTP57,PWGTP58,PWGTP59,PWGTP60,PWGTP61,PWGTP62,PWGTP63,PWGTP64,PWGTP65,PWGTP66,PWGTP67,PWGTP68,PWGTP69,PWGTP70,PWGTP71,PWGTP72,PWGTP73,PWGTP74,PWGTP75,PWGTP76,PWGTP77,PWGTP78,PWGTP79,PWGTP80 FROM dbo.AcsBy320052007Pus
UNION ALL
select serialnoId,RT,SPORDER,PUMA,ST,ADJINC,PWGTP,AGEP,CIT,COW,DDRS,DEYE,DOUT,DPHY,DREM,ENG,FER,GCL,GCM,GCR,INTP,JWMNP,JWRIP,JWTR,LANX,MAR,MIG,MIL,MLPA,MLPB,MLPC,MLPD,MLPE,MLPF,MLPG,MLPH,MLPI,MLPJ,MLPK,NWAB,NWAV,NWLA,NWLK,NWRE,OIP,PAP,RETP,SCH,SCHG,SCHL,SEMP,SEX,SSIP,SSP,WAGP,WKHP,WKL,WKW,YOEP,ANC,ANC1P,ANC2P,DECADE,DRIVESP,ESP,ESR,HISP,INDP,JWAP,JWDP,LANP,MIGPUMA,MIGSP,MSP,NAICSP,NATIVITY,OC,PAOC,PERNP,PINCP,POBP,POVPIP,POWPUMA,POWSP,QTRBIR,RAC1P,RAC2P,RAC3P,RACAIAN,RACASN,RACBLK,RACNHPI,RACNUM,RACSOR,RACWHT,RC,SFN,SFR,VPS,WAOB,FAGEP,FANCP,FCITP,FCOWP,FDDRSP,FDEYEP,FDOUTP,FDPHYP,FDREMP,FENGP,FESRP,FFERP,FGCLP,FGCMP,FGCRP,FHISP,FINDP,FINTP,FJWDP,FJWMNP,FJWRIP,FJWTRP,FLANP,FLANXP,FMARP,FMIGP,FMIGSP,FMILPP,FMILSP,FOCCP,FOIP,FPAP,FPOBP,FPOWSP,FRACP,FRELP,FRETP,FSCHGP,FSCHLP,FSCHP,FSEMP,FSEXP,FSSIP,FSSP,FWAGP,FWKHP,FWKLP,FWKWP,FYOEP,PWGTP1,PWGTP2,PWGTP3,PWGTP4,PWGTP5,PWGTP6,PWGTP7,PWGTP8,PWGTP9,PWGTP10,PWGTP11,PWGTP12,PWGTP13,PWGTP14,PWGTP15,PWGTP16,PWGTP17,PWGTP18,PWGTP19,PWGTP20,PWGTP21,PWGTP22,PWGTP23,PWGTP24,PWGTP25,PWGTP26,PWGTP27,PWGTP28,PWGTP29,PWGTP30,PWGTP31,PWGTP32,PWGTP33,PWGTP34,PWGTP35,PWGTP36,PWGTP37,PWGTP38,PWGTP39,PWGTP40,PWGTP41,PWGTP42,PWGTP43,PWGTP44,PWGTP45,PWGTP46,PWGTP47,PWGTP48,PWGTP49,PWGTP50,PWGTP51,PWGTP52,PWGTP53,PWGTP54,PWGTP55,PWGTP56,PWGTP57,PWGTP58,PWGTP59,PWGTP60,PWGTP61,PWGTP62,PWGTP63,PWGTP64,PWGTP65,PWGTP66,PWGTP67,PWGTP68,PWGTP69,PWGTP70,PWGTP71,PWGTP72,PWGTP73,PWGTP74,PWGTP75,PWGTP76,PWGTP77,PWGTP78,PWGTP79,PWGTP80 FROM dbo.AcsBy320082010Pus
)
) AS Pus
On Hus.SerialNoId = Pus.SerialNoId
``` |
51,661,094 | I want to setup web app using three components that i already have:
1. Domain name registered on domains.google.com
2. Frontend web app hosted on Firebase Hosting and served from `example.com`
3. Backend on Kubernetes cluster behind Load Balancer with external static IP `1.2.3.4`
I want to serve the backend from `example.com/api` or `api.example.com`
My best guess is to use Cloud DNS to connect IP adress and subdomain (or URL)
* `1.2.3.4` -> `api.exmple.com`
* `1.2.3.4` -> `example.com/api`
The problem is that Cloud DNS uses custom name servers, like this:
```
ns-cloud-d1.googledomains.com
```
So if I set Google default name servers I can reach Firebase hosting only, and if I use custom name servers I can reach only Kubernetes backend.
What is a proper way to be able to reach both api.example.com and example.com?
edit:
As a temporary workaround i'm combining two default name servers and two custom name servers from cloud DNS, like this:
* `ns-cloud-d1.googledomains.com` (custom)
* `ns-cloud-d2.googledomains.com` (custom)
* `ns-cloud-b1.googledomains.com` (default)
* `ns-cloud-b2.googledomains.com` (default)
But if someone knows the proper way to do it - please post the answer. | 2018/08/02 | [
"https://Stackoverflow.com/questions/51661094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2445648/"
] | **Approach 1:**
```
example.com --> Firebase Hosting (A record)
api.example.com --> Kubernetes backend
```
Pro: Super-simple
Con: CORS request needed by browser before API calls can be made.
**Approach 2:**
```
example.com --> Firebase Hosting via k8s ExternalName service
example.com/api --> Kubernetes backend
```
Unfortunately from my own efforts to make this work with service `type: ExternalName` all I could manage is to get infinitely redirected, something which I am still unable to debug.
**Approach 3:**
```
example.com --> Google Cloud Storage via NGINX proxy to redirect paths to index.html
example.com/api --> Kubernetes backend
```
You will need to deploy the static files to Cloud Storage, with an NGINX proxy in front if you want SPA-like redirection to index.html for all routes. This approach does not use Firebase Hosting altogether.
The complication lies in the /api redirect which depends on which Ingress you are using.
Hope that helps. | I would suggest creating two host paths. The first would be going to "example.com" using NodePort type. You can then use the [External Name](https://kubernetes.io/docs/concepts/services-networking/service/#externalname) service for "api.exmple.com". |
25,395,932 | Does anyone know how to make a cursor blink in the textarea even before you click on it?
Like <https://medium.com/p/new-post> | 2014/08/20 | [
"https://Stackoverflow.com/questions/25395932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1511361/"
] | You can use `autofocus` to accomplish this, [check out w3schools for basic information on it](http://www.w3schools.com/tags/att_input_autofocus.asp).
`<input type="text" name="fname" autofocus>` | Probably the styling is set to show no cursor.
And try below examples:
[**Cursor examples in CSS**](http://www.echoecho.com/csscursors.htm) |
25,395,932 | Does anyone know how to make a cursor blink in the textarea even before you click on it?
Like <https://medium.com/p/new-post> | 2014/08/20 | [
"https://Stackoverflow.com/questions/25395932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1511361/"
] | You can use `autofocus` to accomplish this, [check out w3schools for basic information on it](http://www.w3schools.com/tags/att_input_autofocus.asp).
`<input type="text" name="fname" autofocus>` | I would suggest that you download a blinking gif then put it as backround of your text area to make it blink. Then when you type it will go away.
Add bootstrap form like this to clone the same display: [jsfiddle](http://jsfiddle.net/v9ec3/146/)
```
<textarea class="form-control" placeholder="Tell your story.." rows="3" autofocus></textarea>
```
Bootstrap forms: bootstrapform |
25,395,932 | Does anyone know how to make a cursor blink in the textarea even before you click on it?
Like <https://medium.com/p/new-post> | 2014/08/20 | [
"https://Stackoverflow.com/questions/25395932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1511361/"
] | Probably the styling is set to show no cursor.
And try below examples:
[**Cursor examples in CSS**](http://www.echoecho.com/csscursors.htm) | I would suggest that you download a blinking gif then put it as backround of your text area to make it blink. Then when you type it will go away.
Add bootstrap form like this to clone the same display: [jsfiddle](http://jsfiddle.net/v9ec3/146/)
```
<textarea class="form-control" placeholder="Tell your story.." rows="3" autofocus></textarea>
```
Bootstrap forms: bootstrapform |
54,425,766 | I have one model that is
```
class Retailer < ActiveRecord::Base
...
has_attached_file :onboarding_image
...
end
```
If the onboarding\_image is not present, when doing `retailer.onboarding_image_url` i'm getting: "/onboarding\_images/original/missing.png"
Is there a config to get `nil` when no image is present? i know that i can do something like
`retailer.onboarding_image.present? ? retailer.onboarding_image : nil` but that is not the approach i want to follow, cause i have thousand of attached\_files in all of my code. | 2019/01/29 | [
"https://Stackoverflow.com/questions/54425766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6211950/"
] | You can set the `default_url` as outlined [here](https://github.com/thoughtbot/paperclip#models):
```
has_attached_file :onboarding_image, default_url: ''
```
Another approach is to override the `onboarding_image_url` method:
```
def onboarding_image_url(default_value=nil)
onboarding_image.present? ? onboarding_image.url : default_value
end
``` | if you have this attached files on multiple models, you can create concern for all classes that have `has_attached_file` :
```
module BoardUrl
def board_url
onboarding_image.present? ? onboarding_image.url : nil
end
end
```
```
class Retailer
include BoardUrl
end
```
This way you can use your `board_url` method on any model you need. |
27,271,027 | JS:
```
$scope.find = function() {
$scope.onlyUsers = Users.query();
console.log(" $scope.onlyUsers-->", $scope.onlyUsers);
var len = $scope.onlyUsers.length;
console.log('length',+len);
var peruser = [{}];
if(data){
for(var x=0; x< $scope.onlyUsers.length; x++){
if( $scope.onlyUsers[x].orgId == $scope.authentication.user.orgId)
peruser.push(data[x]);
}
}
console.log('peruser--->',peruser);
}
}
};
```
But in console $scope.onlyUsers data is coming .
console:
`$scope.onlyUsers--> []
0 Resource { __v=0, _id="547dc4a4ae31830800267e48", displayName="praveen Nune", more...}
1 Resource { __v=0, _id="547daf3bae31830800267e47", displayName="siva google12344545", more...}
2 Resource { __v=0, _id="547dae6eaf1a68c01c8020cc", displayName="siva acertis564e54354", more...}
3 Resource { __v=0, _id="547dabf151fc25a40124a9ff", displayName="microsoft google453234", more...}
4 Resource { __v=0, _id="547dab68571f9d0800bef142", displayName="e43545345 rtrgtr453", more...}
5 Resource { __v=0, _id="547da711078519dc14590cc4", displayName="microsoft acertis564e5", more...}
6 Resource { __v=0, _id="547da009a5a2493007f6a3de", displayName="microsoft acertis6786", more...}
7 Resource { salt=""?5???~?_?|?]?c", provider="local", role="54756bbc089822ac1fcd0226", more...}
8 Resource { __v=0, _id="547d983093b8cb181307751f", displayName="sap google56987", more...}
9 Resource { __v=0, _id="547d9605e9847d601062ea3f", displayName="mico admin", more...}
10 Resource { __v=0, _id="547d950ddbcdb90800a495d0", displayName="google user5678", more...}`
and length is coming as zero. How to get the length?...plz help me
```
length 0
``` | 2014/12/03 | [
"https://Stackoverflow.com/questions/27271027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4144379/"
] | Besides one wrong `&&`, reading nextInt should be done first.
```
while (true) {
System.out.print("Enter the Length of wall 1: ");
if (scan.hasNextInt()) {
length1 = scan.nextInt();
if (1 <= length1 && length1 <= 24) {
break:
}
System.out.println("Error Error");
System.out.println("Please only enter numbers between 1 and 24.");
} else {
System.out.println("Error Error");
System.out.println("Please only enter numbers.");
scan.next();
}
}
``` | Use the following Code:
```
while (length1 == Integer.MIN_VALUE) {
System.out.print("Enter the Length of wall 1: ");
if (scan.hasNextInt() && 1<=length1 && length1<=24) {
length1 = scan.nextInt();
}
else if (length1<1 || 24<length1) {
System.out.println("Error Error");
System.out.println("Please only enter numbers between 1 and 24.");
scan.next();
} else {
System.out.println("Error Error");
System.out.println("Please only enter numbers.");
scan.next();
}
}
``` |
453,359 | I am using ubuntu 14.04 LTS (64 bit). I could access the 4GB memory of my fujifilm AV-150 digital camera through nautilus in 13.10, but it is no longer shown in 14.04!
### `lsusb`
```
Bus 002 Device 003: ID 046d:c52f Logitech, Inc. Unifying Receiver
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 011: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270/E870 HSDPA/HSUPA Modem
Bus 001 Device 012: ID 04cb:021b Fuji Photo Film Co., Ltd
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
```
### `lsblk`
```
prasad@Trusty-ubuntu:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 100M 0 part
├─sda2 8:2 0 99.9G 0 part
├─sda3 8:3 0 1K 0 part
├─sda4 8:4 0 30.2G 0 part
├─sda5 8:5 0 100G 0 part /mnt/Linux
├─sda6 8:6 0 200G 0 part /mnt/Media
├─sda7 8:7 0 300G 0 part
└─sda8 8:8 0 201.3G 0 part /media/prasad/Home
sdb 8:16 0 465.8G 0 disk
├─sdb1 8:17 0 300M 0 part
├─sdb2 8:18 0 100M 0 part
├─sdb3 8:19 0 128M 0 part
├─sdb4 8:20 0 39.5G 0 part
├─sdb5 8:21 0 250G 0 part
├─sdb6 8:22 0 4G 0 part [SWAP]
├─sdb7 8:23 0 10G 0 part
├─sdb8 8:24 0 28G 0 part
└─sdb9 8:25 0 28.6G 0 part /
sr0 11:0 1 32.8M 0 rom
```
[dmesg](http://pastebin.com/J841Re1B)
The camera is detected but not mounted as a mass storage. In ubuntu 13.10, it detects and mounts automatically without any hassle. | 2014/04/23 | [
"https://askubuntu.com/questions/453359",
"https://askubuntu.com",
"https://askubuntu.com/users/46933/"
] | ### It's a [bug](https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/1296275)
The camera will be detected after executing following commands
**Option One**
```
echo 'ACTION="add", ENV{ID_USB_INTERFACES}=="*:060101:*", ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="PTP", MODE="0664", GROUP="plugdev"' | sudo tee /lib/udev/rules.d/40-libgphoto2-6.rules
```
Then unplug/replug the camera.
**Option Two**
```
sudo -H gedit /lib/udev/rules.d/40-libgphoto2-6.rules
```
and make the file look like this:
```
ACTION!="add", GOTO="libgphoto2_rules_end"
SUBSYSTEM!="usb", GOTO="libgphoto2_usb_end"
ENV{ID_USB_INTERFACES}=="", IMPORT{builtin}="usb_id"
ENV{ID_USB_INTERFACES}=="*:060101:*", ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="PTP", MODE="0664", GROUP="plugdev"
LABEL="libgphoto2_rules_end"
```
thanks to [Martin pitt](https://launchpad.net/%7Epitti) | I have virtually the same problem but with another camera brand. To get access to the pictures while the basic problem is not solved I use a workaround which is described in my posting:
[Canon IXUS 155 camera no longer found when connected to USB after update to 14.04](https://askubuntu.com/questions/454651/canon-ixus-155-camera-no-longer-found-when-connected-to-usb-after-update-to-14-0) |
32,520,959 | I have this format of code. Can anyone help me how can I read the array? I need to read contacts array.
```
{
"success": true,
"contacts": [
{
"username": "ceema",
"profile": {
"name": "Ceema S",
"email": "[email protected]",
"address": "No 143, gangaeyam, Maikkad P O, Kerala",
"phone": {
"mobile": "3333",
"home": "2222",
"office": "6666"
}
}
},
{
"username": "hari",
"profile": {
"name": "Harikrishnan V S",
"email": "[email protected]",
"address": "No 143, harihome, Maikkad P O, Kerala",
"phone": {
"mobile": "3333",
"home": "2222",
"office": "6666"
}
}
},
{
"username": "pranav",
"profile": {
"name": "Pranav Mohan",
"email": "[email protected]",
"address": "No 143, harihome, Maikkad P O, Kerala",
"phone": {
"mobile": "3333",
"home": "2222",
"office": "6666"
}
}
}
]
}
```
**I tried this :**
```
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
contacts = jsonObj.getJSONArray(TAG_CONTACTS);
// looping through All Contacts
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
//String id = c.getString(TAG_NAME);
String name = c.getString(TAG_NAME);
String email = c.getString(TAG_EMAIL);
String address = c.getString(TAG_ADDRESS);
//String gender = c.getString(TAG_GENDER);
// Phone node is JSON Object
JSONObject phone = c.getJSONObject(TAG_PHONE);
String mobile = phone.getString(TAG_PHONE_MOBILE);
String home = phone.getString(TAG_PHONE_HOME);
String office = phone.getString(TAG_PHONE_OFFICE);
```
This **jsonstr** is json response from the site.
I need to read the nested contacts and populate it to | 2015/09/11 | [
"https://Stackoverflow.com/questions/32520959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101520/"
] | >
> This jsonstr is json response from the site. I need to read the nested
> contacts and populate it to
>
>
>
you got it almost right. The objects you are looking for are inside profile
```
JSONObject c = contacts.getJSONObject(i);
JSONObject profile = c.getJSONObject("profile");
```
and use `profile` instead of `c`, to look of name, phone and the others | check this link a very simple way to parse json
<http://kylewbanks.com/blog/Tutorial-Android-Parsing-JSON-with-GSON> |
32,520,959 | I have this format of code. Can anyone help me how can I read the array? I need to read contacts array.
```
{
"success": true,
"contacts": [
{
"username": "ceema",
"profile": {
"name": "Ceema S",
"email": "[email protected]",
"address": "No 143, gangaeyam, Maikkad P O, Kerala",
"phone": {
"mobile": "3333",
"home": "2222",
"office": "6666"
}
}
},
{
"username": "hari",
"profile": {
"name": "Harikrishnan V S",
"email": "[email protected]",
"address": "No 143, harihome, Maikkad P O, Kerala",
"phone": {
"mobile": "3333",
"home": "2222",
"office": "6666"
}
}
},
{
"username": "pranav",
"profile": {
"name": "Pranav Mohan",
"email": "[email protected]",
"address": "No 143, harihome, Maikkad P O, Kerala",
"phone": {
"mobile": "3333",
"home": "2222",
"office": "6666"
}
}
}
]
}
```
**I tried this :**
```
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
contacts = jsonObj.getJSONArray(TAG_CONTACTS);
// looping through All Contacts
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
//String id = c.getString(TAG_NAME);
String name = c.getString(TAG_NAME);
String email = c.getString(TAG_EMAIL);
String address = c.getString(TAG_ADDRESS);
//String gender = c.getString(TAG_GENDER);
// Phone node is JSON Object
JSONObject phone = c.getJSONObject(TAG_PHONE);
String mobile = phone.getString(TAG_PHONE_MOBILE);
String home = phone.getString(TAG_PHONE_HOME);
String office = phone.getString(TAG_PHONE_OFFICE);
```
This **jsonstr** is json response from the site.
I need to read the nested contacts and populate it to | 2015/09/11 | [
"https://Stackoverflow.com/questions/32520959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1101520/"
] | >
> This jsonstr is json response from the site. I need to read the nested
> contacts and populate it to
>
>
>
you got it almost right. The objects you are looking for are inside profile
```
JSONObject c = contacts.getJSONObject(i);
JSONObject profile = c.getJSONObject("profile");
```
and use `profile` instead of `c`, to look of name, phone and the others | The simplest way is to get POJO class from json using <http://www.jsonschema2pojo.org/>
You will get all the required classes to convert this json into POJO class,
and later you can use Gson library from google to convert json into Object and the other way around.
Think of this, if you get a Contact class as parent class then you can easily use fromjson method from Gson.
```
Gson gson=new Gson();
Contact contact = gson.fromJson(json_string, Contact.class);
```
Now you can easily use this class for further use.
Hope this helps. |
47,290,183 | Firstly,i fill in the list with some objects with different propetries and afterwards I'd like to remove all inappropriate objects from this list.
For sure, it throws an exception, saying that the list has been modified and it leads to problems with enumeration. How to manage this and remove all inappropriate objects without using another List, for example, ListFiltred, where I can add all appropriate objects?
```
MyList.Add(new Houses() { Number = "04" });
MyList.Add(new Houses() { Number = "01" });
MyList.Add(new Houses() { Number = "02" });
MyList.Add(new Houses() { Number = "04" });
MyList.Add(new Houses() { Number = "04" });
foreach (var item in MyList)
{
if (item.Number != "04")
{
MyList.Remove(item);
}
}
``` | 2017/11/14 | [
"https://Stackoverflow.com/questions/47290183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5539510/"
] | `List<T>` has a [`RemoveAll`](https://msdn.microsoft.com/en-us/library/wdka673a(v=vs.110).aspx) method that takes a predicate. You can use it like this:
```
MyList.RemoveAll(x=>x.Number != "04");
``` | Use **[`RemoveAll`](https://msdn.microsoft.com/en-us/library/wdka673a(v=vs.110).aspx)** direct method
```
MyList.RemoveAll(val=>val.Number != "04");
``` |
40,505,127 | I am trying to scrape a site but the results returned for just the links is different from when I inspect it with the browser.
In my browser I get normal links but all the a HREF links all become `javascript:void(0);` from Nokogiri.
Here is the site:
```
https://www.ctgoodjobs.hk/jobs/part-time
```
Here is my code:
```
url = "https://www.ctgoodjobs.hk/jobs/part-time"
response = open(url) rescue nil
next unless response
doc = Nokogiri::HTML(open(url))
links = doc.search('.job-title > a').text
``` | 2016/11/09 | [
"https://Stackoverflow.com/questions/40505127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4390569/"
] | is not that easy, urls are "obscured" using a js function, that's why you're getting `javascript: void(0)` when asking for the hrefs... looking at the html, there are some hidden inputs for each link, and, there is a preview url that you can use to build the job preview url (if that's what you're looking for), so you have this:
```
<div class="result-list-job current-view">
<input type="hidden" name="job_id" value="04375145">
<input type="hidden" name="each_job_title_url" value="barista-senior-barista-咖啡調配員">
<h2 class="job-title"><a href="javascript:void(0);">Barista/ Senior Barista 咖 啡 調 配 員</a></h2>
<h3 class="job-company"><a href="/company-jobs/pacific-coffee-company/00028652" target="_blank">PACIFIC COFFEE CO. LTD.</a></h3>
<div class="job-description">
<ul class="job-desc-list clearfix">
<li class="job-desc-loc job-desc-small-icon">-</li>
<li class="job-desc-work-exp">0-1 yr(s)</li>
<li class="job-desc-salary job-desc-small-icon">-</li>
<li class="job-desc-post-date">09/11/16</li>
</ul>
</div>
<a class="job-save-btn" title="save this job" style="display: inline;"> </a>
<div class="job-batch-apply"><span class="checkbox" style="background-position: 0px 0px;"></span><input type="checkbox" class="styled" name="job_checkbox" value="04375145"></div>
<div class="job-cat job-cat-de"></div>
</div>
```
then, you can retrieve each job\_id from those inputs, like:
```
inputs = doc.search('//input[@name="job_id"]')
```
and then build the urls (i found the base url at `joblist_preview.js`:
```
urls = inputs.map do |input|
"https://www.ctgoodjobs.hk/english/jobdetails/details.asp?m_jobid=#{input['value']}&joblistmode=previewlist&ga_channel=ct"
end
``` | Take the output of a browser and that of a tool like `wget`, `curl` or `nokogiri` and you will find the HTML the browser presents can differ drastically from the raw HTML.
Browsers these days can process DHTML, Nokogiri doesn't. You can only retrieve the *raw* HTML using something that lets you see the content without the browser, like the above mentioned tools, then compare that with what you see in a text editor, or what `nokogiri` shows you. Don't trust the browser - they're known to lie because they want to make you happy.
Here's a quick glimpse into what the raw HTML contains, generated using:
```
$ nokogiri "https://www.ctgoodjobs.hk/jobs/part-time"
```
Nokogiri dropped me into IRB:
```
Your document is stored in @doc...
Welcome to NOKOGIRI. You are using ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]. Have fun ;)
```
Counting the hits found by the selector returns:
```
>> @doc.search('.job-title > a').size
30
```
Displaying the text found shows:
```
>> @doc.search('.job-title > a').map(&:text)
[
[ 0] "嬰 兒 奶 粉 沖 調 機 - 兼 職 產 品 推 廣 員 Part Time Promoter (時 薪 高 達 HK$90, 另 設 銷 售 佣 金 )",
...
[29] "Customer Services Representative (Part-time)"
]
```
Looking at the actual `href`:
```
>> @doc.search('.job-title > a').map{ |n| n['href'] }
[
[ 0] "javascript:void(0);",
...
[29] "javascript:void(0);"
]
```
You can tell the HTML doesn't contain anything but what Nokogiri is telling you, so the browser is post-processing the HTML, processing the DHTML and modifying the page you see if you use something to look at the HTML. So, the short fix is, don't trust the browser if you want to know what the server sends to you.
This is why scraping isn't very reliable and you should use an API if at all possible. If you can't, then you're going to have to roll up your sleeves and dig into the JavaScript and manually interpret what it's doing, then retrieve the data and parse it into something useful.
Your code can be cleaned up and simplified. I'd write it much more simply as:
```
url = "https://www.ctgoodjobs.hk/jobs/part-time"
doc = Nokogiri::HTML(open(url))
links = doc.search('.job-title > a').map(&:text)
```
The use of `search(...).text` is a big mistake. `text`, when applied to a NodeSet, will concatenate the text of each contained node, making it extremely difficult to retrieve the individual text. Consider this:
```
require 'nokogiri'
doc = Nokogiri::HTML(<<EOT)
<html>
<body>
<p>foo</p>
<p>bar</p>
</body>
</html>
EOT
doc.search('p').class # => Nokogiri::XML::NodeSet
doc.search('p').text # => "foobar"
doc.search('p').map(&:text) # => ["foo", "bar"]
```
The first result `foobar` would require being split apart to be useful, and unless you have special knowledge of the content, trying to figure out how to do it will be a major pain.
Instead, use `map` to iterate through the elements and apply `&:text` to each one, returning an array of each element's text.
See "[How to avoid joining all text from Nodes when scraping](https://stackoverflow.com/questions/43594656/how-to-avoid-joining-all-text-from-nodes-when-scraping)" and "[Taking apart a DHTML page](https://stackoverflow.com/a/19714636/128421)" also. |
26,830,979 | I have an Asp.Net MVC 5 website and I'm using Entity Framework code first to access its database. I have a `Restaurants` table and I want to let users search these with a lot of parameters. Here's what I have so far:
```
public void FilterModel(ref IQueryable<Restaurant> model)
{
if (!string.IsNullOrWhiteSpace(RestaurantName))
{
model = model.Where(r => r.Name.ToUpper().Contains(RestaurantName));
}
if (Recommended)
{
model = model.Where(r => r.SearchSponsor);
}
//...
}
```
Basically I look for each property and add another `Where` to the chain if it's not empty.
After that, I want to group the result based on some criteria. I'm doing this right now:
```
private static IQueryable<Restaurant> GroupResults(IQueryable<Restaurant> model)
{
var groups = model.GroupBy(r => r.Active);
var list = new List<IGrouping<bool, Restaurant>>();
foreach (var group in groups)
{
list.Add(group);
}
if (list.Count < 1)
{
SortModel(ref model);
return model;
}
IQueryable<Restaurant> joined, actives, inactives;
if (list[0].FirstOrDefault().Active)
{
actives = list[0].AsQueryable();
inactives = list.Count == 2 ? list[1].AsQueryable() : null;
}
else
{
actives = list.Count == 2 ? list[1].AsQueryable() : null;
inactives = list[0].AsQueryable();
}
if (actives != null)
{
//....
}
if (inactives != null)
{
SortModel(ref inactives);
}
if (actives == null || inactives == null)
{
return actives ?? inactives;
}
joined = actives.Union(inactives).AsQueryable();
return joined;
}
```
This works but it's got a lot of complications which I rather not talk about for the sake of keeping this question small.
I was wondering if this is the right and efficient way to do it. It seems kind of "dirty"! Lots of `if`s and `Where`s. Stored procedures, inverted indices, etc. This is my first "big" project and I want to learn from your experience to do this the "right" way. | 2014/11/09 | [
"https://Stackoverflow.com/questions/26830979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/603200/"
] | You can do something like this:
```
from itertools import takewhile
def get_items_upto_count(dct, n):
data = dct.most_common()
val = data[n-1][1] #get the value of n-1th item
#Now collect all items whose value is greater than or equal to `val`.
return list(takewhile(lambda x: x[1] >= val, data))
test = Counter(["A","A","A","B","B","C","C","D","D","E","F","G","H"])
print get_items_upto_count(test, 2)
#[('A', 3), ('C', 2), ('B', 2), ('D', 2)]
``` | For smaller sets, just write a simple generator:
```
>>> test = Counter(["A","A","A","B","B","C","C","D","D","E","F","G","H"])
>>> g=(e for e in test.most_common() if e[1]>=2)
>>> list(g)
[('A', 3), ('D', 2), ('C', 2), ('B', 2)]
```
For larger set, use [ifilter](https://docs.python.org/2/library/itertools.html#itertools.ifilter) (or just use `filter` on Python 3):
```
>>> list(ifilter(lambda t: t[1]>=2, test.most_common()))
[('A', 3), ('C', 2), ('B', 2), ('D', 2)]
```
Or, since `most_common` are already ordered, just use a for loop and break on the desired condition in a generator:
```
def fc(d, f):
for t in d.most_common():
if not f(t[1]):
break
yield t
>>> list(fc(test, lambda e: e>=2))
[('A', 3), ('B', 2), ('C', 2), ('D', 2)]
``` |
63,033,422 | My axios response (or fetch, tried both) it's plain text (string). But I expect javaScript map. If I tried JSON.parse() (or from fetch .json()) I got error:
>
> Uncaught (in promise) SyntaxError: Unexpected token in JSON at
> position 0
> at JSON.parse ()
> at eval (List.vue?8915:66)
>
>
>
* UTF-8 without BOM
* I checked my json via few json validators online - json is valid
* I tried create my json via some online json creator - the same error
so I have few questions:
1. I thought that json is a special format. If you got it via axios/fetch your response always will be js map? It's not true?
2. What is the best way to creating and validating json to be sure it's ok?
3. I use vue cli, there haven't json loader (i think so, not sure, it not use webpack, but I can't see some loaders). It could be problem? Or some environment settings? I tried to check it, but maybe can't find.
4. Or maybe ma header is still wrong, ad accept give me nothing?
votingService.ts
```
import axios, { AxiosResponse } from "axios";
export const getVotingsService = (): Promise<AxiosResponse> => {
return axios
.get("http://localhost:8080/fakeData/votings.json", {
headers: {
"accept": "application/json",
'Content-Type': 'application/json'
},
})
};
```
List.vue
```
...
private getVotings() {
getVotingsService().then(response => {
console.log("resp", response.data); //string, data is ok
console.log(JSON.parse(response.data)); //error
});
}
...
```
votings.json (in public folder)
```
{
"votings": [
{
"createDate": "20-07-20",
"deadline": "20-08-20",
"status": "active",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
},
{
"createDate": "20-07-20",
"deadline": "20-08-20",
"status": "active",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
},
{
"createDate": "20-07-20",
"deadline": "20-08-20",
"status": "active",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
}
]
}
```
chrome consola:
[](https://i.stack.imgur.com/PPsyK.png)
chrome network response:
[](https://i.stack.imgur.com/tXg5c.png)
chrome network headers:
[](https://i.stack.imgur.com/qhKGe.png) | 2020/07/22 | [
"https://Stackoverflow.com/questions/63033422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12451768/"
] | How interesting this all character escaping thing works!
I continued serching, and read everything I could find. The result is that all that should be escaped with in double quotes, are the double quotes themselves...
*(correct me if there's something I am missing, that was correct for my case)*
The resulting string that should be used in the TFS variable (and I tested it, it works!) is this:
```
;d#se#&4~75EY(H[SM""%cznGB
```
**The only thing I added to the original password was another double quote near the double quote.**
That answer certainly helped me. No wonder why experementing by yourselves preserves better than reading tons of articles :/
<https://stackoverflow.com/a/15262019/2443719>
Thanks to everyone who commented and left an answer to this thread. | ```bat
rem // enable delayed expansion to expand other poison characters safely
@Echo off & setlocal EnableExtensions EnableDelayedExpansion
rem // escape % character by doubling
Set "PW=;d#se#&4~75EY(H[SM"%%cznGB"
"C:\WINDOWS\system32\inetsrv\appcmd.exe" set vdir /vdir.name:"appfolder/Files" -physicalPath:"\\servername\virtualfolder" -userName:"[email protected]" -password:"!PW!"
Endlocal
``` |
127,071 | When I select the "Additional Drivers" program, it searches for available drivers but becomes unresponsive shortly after. I tried closing it, to try again, but now it just blinks 3 times when I select it. Any ideas to work around this? I'm unsure if there's a driver I need. My network connection seems fine, though.
Edit: When I use the command `jockey-gtk`, I get an error message that ends with:
```
Possible causes include: the remote application did not send a reply, the message bus
security policy blocked the reply, the reply timeout expired, or the network connection
was broken.
``` | 2012/04/28 | [
"https://askubuntu.com/questions/127071",
"https://askubuntu.com",
"https://askubuntu.com/users/56988/"
] | Try starting it from a terminal: `jockey-gtk`. See if it displays any error regarding the crash.
Alternatively there is `jockey-text` if the graphical version would fail.
In case of problems you'd probably want to read the backend debug log (`/var/log/jockey.log`). Try this:
* In a terminal window type `tail -f /var/log/jockey.log`
* Press a few `Enter`s in the same window to separate the new output from the old lines.
* Now start the *"Additional Drivers"* utility. The terminal window should start to log debug messages as the driver check is carried out.
* The last few lines might contain information about what is going wrong.
(Be warned there will be quite a couple of lines.)
There is a related Launchpad bug [#912236](https://bugs.launchpad.net/ubuntu/+source/jockey/+bug/912236) ([#864572](https://bugs.launchpad.net/ubuntu/+source/jockey/+bug/864572)) confirming your error message:
>
> Possible causes include: the remote application did not send a reply,
> the message bus security policy blocked the reply, the reply timeout
> expired, or the network connection was broken.
>
>
>
But no solution so far. | I wasn't able to get jockey working either, no matter what i tried. However i did find a workaround. If you haven't already, install the synaptic package manager from the software center. From synaptic you can search for the driver you are trying to install and install through there.
The only downside is you have to know the name of the driver you are looking for, but some googling should be able to answer that for you. |
35,220,392 | What is the proper/right resolution for Image to be put using src in ImageView to avoid stretching or unscaled images? | 2016/02/05 | [
"https://Stackoverflow.com/questions/35220392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5870896/"
] | A key element of the [Visitor pattern](https://en.wikipedia.org/wiki/Visitor_pattern) is [double-dispatch](https://en.wikipedia.org/wiki/Double_dispatch): you need to invoke the visitor method *from the actual subclass*:
```
abstract class Animal {
abstract void accept(Visitor v);
}
class Dog extends Animal {
@Override void accept(Visitor v) { v.talk(this); }
}
// ... etc for other animals.
```
Then, you pass the visitor to the animal, not the animal to the visitor:
```
for (Animal a : list)
a.accept(visitor);
```
The reason for this is that the *compiler* chooses the overload on `Visitor` to invoke - it is not selected at runtime. All the compiler knows is that `a` is an `Animal`, so the only method it knows it is safe to invoke is the `Visitor.visit(Animal)` overload. | The visitor pattern is basically a many-to-many class behavior resolution mechanism. In order to be useful / applicable to your animals example, we need to add a visitor, as Andy Turner indicated.
How about including "Animal Trainers" as the visitors? Different animal trainers could get the different animals to speak differently (or not).
So, first, the entity (animal interface). I like to think of this as the "Thing" being "acted on by an Actor":
```
public interface IAnimal {
public String getAnimalName();
// aka... public void accept(Visitor v)
public void allowAnimalTrainerToMakeMeSpeak(IAnimalTrainer animalTrainer);
}
```
Then let's define a visitor type (animal trainer interface). I like to think of the visitor as an "Actor" acting on the various "Things" (entities):
```
public interface IAnimalTrainer {
public String getTrainerName();
//aka... public void visit(Dog dog);
public void animalTrainerMakesAnimalSpeak(Dog dog);
public void animalTrainerMakesAnimalSpeak(Cat cat);
public void animalTrainerMakesAnimalSpeak(Poodle poodle);
}
```
Now lets create the animals (implement IAnimal interface):
Cat:
```
public class Cat implements IAnimal {
private String animalName;
@Override
public String getAnimalName() {
return animalName;
}
public void setAnimalName(String animalName) {
this.animalName = animalName;
}
public Cat(String animalName) {
this.animalName = animalName;
}
public Cat() {
// Default constructor
}
@Override
public void allowAnimalTrainerToMakeMeSpeak(IAnimalTrainer animalTrainer) {
animalTrainer.animalTrainerMakesAnimalSpeak(this);
}
}
```
Dog:
```
public class Dog implements IAnimal {
private String animalName;
@Override
public String getAnimalName() {
return animalName;
}
public void setAnimalName(String animalName) {
this.animalName = animalName;
}
public Dog(String animalName) {
this.animalName = animalName;
}
public Dog() {
// Default constructor
}
@Override
public void allowAnimalTrainerToMakeMeSpeak(IAnimalTrainer animalTrainer) {
animalTrainer.animalTrainerMakesAnimalSpeak(this);
}
}
```
Poodle:
```
public class Poodle extends Dog {
public Poodle(String animalName) {
super(animalName);
}
public Poodle() {
super();
}
@Override
public void allowAnimalTrainerToMakeMeSpeak(IAnimalTrainer animalTrainer) {
animalTrainer.animalTrainerMakesAnimalSpeak(this);
}
}
```
Now lets create the animal trainers, Phil and Jack (implement IAnimalTrainer interface):
Animal Trainer Phil:
```
public class AnimalTrainerPhil implements IAnimalTrainer {
private String trainerName = "Phil";
@Override
public String getTrainerName() {
return trainerName;
}
public void setTrainerName(String trainerName) {
this.trainerName = trainerName;
}
@Override
public void animalTrainerMakesAnimalSpeak(Dog dog) {
System.out.println(
"Animal trainer "
+ getTrainerName()
+ " gets "
+ dog.getAnimalName()
+ " the dog to say: BARK!!");
}
@Override
public void animalTrainerMakesAnimalSpeak(Cat cat) {
System.out.println(
"Animal trainer "
+ getTrainerName()
+ " gets "
+ cat.getAnimalName()
+ " the cat to say: MEOW!!");
}
@Override
public void animalTrainerMakesAnimalSpeak(Poodle poodle) {
animalTrainerMakesAnimalSpeak((Dog)poodle);
}
}
```
Animal Trainer Jack:
```
public class AnimalTrainerJack implements IAnimalTrainer {
private String trainerName = "Jack";
@Override
public String getTrainerName() {
return trainerName;
}
public void setTrainerName(String trainerName) {
this.trainerName = trainerName;
}
@Override
public void animalTrainerMakesAnimalSpeak(Dog dog) {
System.out.println(
"Animal trainer "
+ getTrainerName()
+ " gets "
+ dog.getAnimalName()
+ " the dog to say: Bark bark.");
}
@Override
public void animalTrainerMakesAnimalSpeak(Cat cat) {
System.out.println(
"Animal trainer "
+ getTrainerName()
+ " gets "
+ cat.getAnimalName()
+ " the cat to say: Meoooow.");
}
@Override
public void animalTrainerMakesAnimalSpeak(Poodle poodle) {
System.out.println(
"Animal trainer "
+ getTrainerName()
+ " gets "
+ poodle.getAnimalName()
+ " the poodle to say: Yip! Yip!");
}
}
```
Now lets pull this all together and get all the animal trainers (Phil and Jack) to get all the animals (Cat, Dog, Poodle) to speak, via a Manager class:
```
public class ManagerOfAnimalTrainersAndAnimals {
public static void main(String[] args) {
ArrayList<IAnimal> allAnimals = new ArrayList<>();
allAnimals.add(new Dog("Henry"));
allAnimals.add(new Cat("Priscilla"));
allAnimals.add(new Poodle("Spike"));
ArrayList<IAnimalTrainer> allAnimalTrainers = new ArrayList<>();
allAnimalTrainers.add(new AnimalTrainerPhil());
allAnimalTrainers.add(new AnimalTrainerJack());
// Allow all animal trainers to get each animal to speak
for (IAnimalTrainer animalTrainer : allAnimalTrainers) {
for (IAnimal animal : allAnimals) {
animal.allowAnimalTrainerToMakeMeSpeak(animalTrainer);
}
}
}
}
```
Here's the output:
```
Animal trainer Phil gets Henry the dog to say: BARK!!
Animal trainer Phil gets Priscilla the cat to say: MEOW!!
Animal trainer Phil gets Spike the dog to say: BARK!!
Animal trainer Jack gets Henry the dog to say: Bark bark.
Animal trainer Jack gets Priscilla the cat to say: Meoooow.
Animal trainer Jack gets Spike the poodle to say: Yip! Yip!
```
This makes it relatively easy to add new trainers who have access to animal-type specific things (like if you added claw info to cats and paw info to dogs, ...) as they act on the various animals. I think the problem with the traditional "visitor" example is it's too nebulous and not concrete enough. The taxi example didn't do it for me, either. I hope this example helps. |
38,710,304 | Just trying to run a simple function when the button "calculate" is pressed. Function won't run at all when inputs are in a form, ultimately I want to be able to modify the other inputs when the calculate button is pressed. Any help at all please!
```js
function calculate() {
alert("called");
}
```
```html
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<form name="form">
Price:
<input name="priceCAD" value="0">
<br>
<br>Markup:
<input name="percentage" value="0">
<br>
<br>Fiat:
<input name="fiat" value="0">
<br>
<br>BTC:
<input name="btc" value="0" maxlength="11">
<br>
<br>
<input type="button" onClick="calculate()" name="calculate" value="Caculate">
<input type="button" name="clear" value="Clear" onClick="form.fiat.value=0, form.btc.value=0, form.markup.value=0">
</form>
``` | 2016/08/02 | [
"https://Stackoverflow.com/questions/38710304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1437728/"
] | Button HTML just need it:
```
<input type="button" onClick="calculate()" name="calculate" value="Caculate" >
```
And don't forget insert `jquery lib` in your `<head>`. | ```js
function calculate() {
alert("called");
}
document.getElementsByName("calculate")[0].addEventListener("click", calculate);
```
```html
<form name="form">
Price:
<input name="priceCAD" value="0">
<br>
<br>Markup:
<input name="percentage" value="0">
<br>
<br>Fiat:
<input name="fiat" value="0">
<br>
<br>BTC:
<input name="btc" value="0" maxlength="11">
<br>
<br>
<input type="button" name="calculate" value="Caculate">
<input type="button" name="clear" value="Clear" onClick="form.fiat.value=0, form.btc.value=0, form.markup.value=0">
</form>
``` |
1,431,359 | I am interested in evaluating the following infinite sum
\begin{equation}
\sum\_{n=0}^{\infty} \frac{\alpha^{n}}{n!}n^{\beta}
\end{equation}
where both $\alpha$ and $\beta$ are real numbers. However, in addition, $\alpha$ is always positive.
Clearly the sum converges for any value of $\alpha$ and $\beta$ since the factorial kills both exponential and power terms for sufficiently large $m$'s.
Does the sum have a closed form? | 2015/09/11 | [
"https://math.stackexchange.com/questions/1431359",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/220425/"
] | $A=\begin{bmatrix}a&b\\b&-a\end{bmatrix}$ and
$A^2=(a^2 + b^2) \begin{bmatrix}1&0\\0&1\end{bmatrix}$
So $$A^{2k}=(a^2 + b^2)^k\begin{bmatrix}1&0\\0&1\end{bmatrix}$$ and $$A^{2k + 1}=A^{2k}A=(a^2 + b^2)^k\begin{bmatrix}a&b\\b&-a\end{bmatrix}$$ | You can use the diagonalization of your matrix $A$. In particular, you can found $$A = T D T^{-1},$$ where $D$ is diagonal and contains all eigenvalues of matrix $A$, while $T$'s columns are the eigenvectors of your matrix $A$.
Using this form, then:
$$A^n = T D^n T^{-1},$$
which can be really easy to compute.
In your case:
$$T = \left[\begin{array}{cc}\frac{a-m}{b} & \frac{a+m}{b}\\1 & 1\end{array}\right]$$
and
$$D = \left[\begin{array}{cc}-m & 0 \\ 0 & m \end{array}\right],$$
having posed $m = \sqrt{a^2+b^2}$.
In this case, you have that:
$$D^n = \left[\begin{array}{cc}(-m)^n & 0 \\ 0 & m^n \end{array}\right]$$
**Why this work**
Look at equation $A = T D T^{-1}$. Then:
$$A^n = T D T^{-1} \cdot T D T^{-1} \cdot T D T^{-1} \cdots T D T^{-1} = \\
= T D (T^{-1} T) D (T^{-1} T) D (T^{-1} \cdots T) D T^{-1} = \\
= T D I D I D I \cdots I D T^{-1} = \\
= T D^n T^{-1}$$ |
1,431,359 | I am interested in evaluating the following infinite sum
\begin{equation}
\sum\_{n=0}^{\infty} \frac{\alpha^{n}}{n!}n^{\beta}
\end{equation}
where both $\alpha$ and $\beta$ are real numbers. However, in addition, $\alpha$ is always positive.
Clearly the sum converges for any value of $\alpha$ and $\beta$ since the factorial kills both exponential and power terms for sufficiently large $m$'s.
Does the sum have a closed form? | 2015/09/11 | [
"https://math.stackexchange.com/questions/1431359",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/220425/"
] | $A=\begin{bmatrix}a&b\\b&-a\end{bmatrix}$ and
$A^2=(a^2 + b^2) \begin{bmatrix}1&0\\0&1\end{bmatrix}$
So $$A^{2k}=(a^2 + b^2)^k\begin{bmatrix}1&0\\0&1\end{bmatrix}$$ and $$A^{2k + 1}=A^{2k}A=(a^2 + b^2)^k\begin{bmatrix}a&b\\b&-a\end{bmatrix}$$ | Take
$$
A = \pmatrix{a&b\\b&-a}
$$
The eigenvalues of $A$ are $\pm \sqrt{a^2+b^2}$, as we can note using the trace and determinant. Define $\alpha = \sqrt{a^2+b^2}$ for convenience. Assume that $\alpha \neq 0$, in which case the answer is obvious.
We note that the matrix
$$
M = \frac 1{\alpha} A
$$
has eigenvalues $\pm 1$. It follows that
$$
M^2 = I = \pmatrix{1&0\\0&1}
$$
so that $M^{n}$ switches between $I$ and $M$. We can then conclude that
$$
A^n = (\alpha M)^n = \alpha^nM^n
$$
which is to say that
$$
A^n =
\begin{cases}
\alpha^n \pmatrix{1&0\\0&1} & n \text{ is even}\\
\alpha^{n-1} \pmatrix{a&b\\-b&a} & n \text{ is odd}
\end{cases}
$$ |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | [jQuery Templates Plugin](http://weblogs.asp.net/scottgu/archive/2010/05/07/jquery-templates-and-data-linking-and-microsoft-contributing-to-jquery.aspx) created by Microsoft and accepted as an official jQuery plugin.
**But note** that it’s now deprecated. | You should get a look on Javascript-Templates, this is a small template engine used within the famous jQuery File Upload plugin, and developed by the same author, Sebastian Tschan (@blueimp)
<https://github.com/blueimp/JavaScript-Templates>
**Follow the usage guide made** by Sebastian, just **remove this line**
```
document.getElementById("result").innerHTML = tmpl("tmpl-demo", data);
```
**Replace it with this one**
```
$('#result').html(tmpl('tmpl-demo', data));
```
**Don't forget** to add the div result tag in you HTML file too
```
<div id="result"></div>
```
Enjoy |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | [jTemplates](http://jtemplates.tpython.com/)
>
> ### a template engine for JavaScript.
>
>
> ### Plugin to [jQuery](http://jquery.com/)...
>
>
> Features:
>
>
> * 100% in JavaScript
> * precompilator
> * Support JSON
> * Work with Ajax
> * Allow to use JavaScript code inside template
> * Allow to build cascading templates
> * Allow to define parameters in templates
> * Live Refresh! - automatic update content from server...
>
>
> | You should get a look on Javascript-Templates, this is a small template engine used within the famous jQuery File Upload plugin, and developed by the same author, Sebastian Tschan (@blueimp)
<https://github.com/blueimp/JavaScript-Templates>
**Follow the usage guide made** by Sebastian, just **remove this line**
```
document.getElementById("result").innerHTML = tmpl("tmpl-demo", data);
```
**Replace it with this one**
```
$('#result').html(tmpl('tmpl-demo', data));
```
**Don't forget** to add the div result tag in you HTML file too
```
<div id="result"></div>
```
Enjoy |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | [jTemplates](http://jtemplates.tpython.com/)
>
> ### a template engine for JavaScript.
>
>
> ### Plugin to [jQuery](http://jquery.com/)...
>
>
> Features:
>
>
> * 100% in JavaScript
> * precompilator
> * Support JSON
> * Work with Ajax
> * Allow to use JavaScript code inside template
> * Allow to build cascading templates
> * Allow to define parameters in templates
> * Live Refresh! - automatic update content from server...
>
>
> | [jQuery Templates Plugin](http://weblogs.asp.net/scottgu/archive/2010/05/07/jquery-templates-and-data-linking-and-microsoft-contributing-to-jquery.aspx) created by Microsoft and accepted as an official jQuery plugin.
**But note** that it’s now deprecated. |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | [jTemplates](http://jtemplates.tpython.com/)
>
> ### a template engine for JavaScript.
>
>
> ### Plugin to [jQuery](http://jquery.com/)...
>
>
> Features:
>
>
> * 100% in JavaScript
> * precompilator
> * Support JSON
> * Work with Ajax
> * Allow to use JavaScript code inside template
> * Allow to build cascading templates
> * Allow to define parameters in templates
> * Live Refresh! - automatic update content from server...
>
>
> | I would check out [json2html](http://www.json2html.com), it forgoes having to write HTML snippets and relies instead on JSON transforms to convert JSON object array's into unstructured lists. Very fast and uses DOM creation. |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | [jQuery Templates Plugin](http://weblogs.asp.net/scottgu/archive/2010/05/07/jquery-templates-and-data-linking-and-microsoft-contributing-to-jquery.aspx) created by Microsoft and accepted as an official jQuery plugin.
**But note** that it’s now deprecated. | A couple years ago i built IBDOM: <http://ibdom.sf.net/> | As of december 2009, it supports jQuery binding if you get it straight from the trunk.
```
$("#foo").injectWith(collectionOfJavaScriptObjects);
```
or
```
$("#foo").injectWith(simpleJavaScriptObject);
```
Also, you can now put all the "data:propName" markers in class="data:propName other classnames" attributes, so you don't have to litter your application's content with those markers.
I've yet to update a bunch of the documentation on there to reflect my recent enhancements, but the i've had various versions of this framework in production since 2007.
To skeptics of this question:
Back when Microsoft invented with IE5 what we now know as XmlHttpRequest and the "ajax" pattern, part of the promise behind this was to purely exchange data between a web browser and the server. That data was to be encapsulated in XML, because in 1999/2000, XML was simply just so very hot. Beyond retrieving an xml document over the network with a call-back mechanism, MS's MSXML ActiveX component also supported a pre-draft implementation of what we now know as XSL-T and XPath.
Combining retrieving HTTP/XML, XPath, and XSL-T, afforded developers tremendous creativity to build rich "documents" which behaved as "applications", purely sending, and more importantly, retrieving data from the server.
Why is this a useful pattern? It depends on how complex your user interface is, and how much you care about its maintainability.
When building a visually very rich semantically marked-up interface with advanced CSS, the last thing you want to do is chunk-out pieces of markup into "mini-controller/views", just so you can .innerHTML a document fragment into the main document, and here's why.
One key tenet of keeping an advanced html/css user interface manageable, is to preserve its validation at least during its active phase of development. If your markup validates, you can focus on your CSS bugs. Now, if fragments of markup end-up getting injected during various stages of user-interaction, it all becomes very unwieldy to manage, and the whole thing gets brittle.
The idea was to have all of your markup UI constructs in a single document, retrieve *ONLY DATA* over the network, and use a solid framework which will at the very least simply inject your data into your markup constructs, and at the most replicate markup constructs which you flagged as repeatable.
This was possible with XSL-T and XPath in IE5+, but virtually no other browsers. Some F/OSS browser frameworks have been dabbling with XPath but it's not quite something we can rely on just yet.
So what's the next best thing to achieve such pattern? IBDOM. Get data from your server, inject it in your document. effortlessly. |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | [jTemplates](http://jtemplates.tpython.com/)
>
> ### a template engine for JavaScript.
>
>
> ### Plugin to [jQuery](http://jquery.com/)...
>
>
> Features:
>
>
> * 100% in JavaScript
> * precompilator
> * Support JSON
> * Work with Ajax
> * Allow to use JavaScript code inside template
> * Allow to build cascading templates
> * Allow to define parameters in templates
> * Live Refresh! - automatic update content from server...
>
>
> | There is a reasonable discussion document on this topic [here](http://ajaxpatterns.org/Browser-Side_Templating), which covers a range of templating tools. Not specific to jQuery, though. |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | Well, to be frank, client-side templating is very hot nowadays, but quite a jungle.
the most popular are, I believe:
* [pure](http://beebole.com/pure/): It use only js, not his own
"syntax"
* [mustache](http://mustache.github.com/): quite stable and nice I
heard.
* [jqote2](http://aefxx.com/jquery-plugins/jqote2/): extremely fast
according to jsperfs
* jquery templates (deprecated):
there are *plenty* others, but you have to test them to see what suits you, and your project style, best.
Personally, I have a hard time with adding a new syntax and set of logic (*mixing logic and template, hello??*), and went pure js. Every single one of my templates is stored in it's own html file (./usersTable.row.html). I use templates only when ajaxing content, and I have few "logic" js files, one for tables, one for div, one for lists. and not even one for select's options (where i use another method).
Each time I tried to do something more complex, I found out the code was less clear and taking me more time to stabilize than doing it the "old" way. Logic in the template is an utter non-sense in my opinion, and adding it's own syntax adds only very-hard-to-trace bugs. | A couple years ago i built IBDOM: <http://ibdom.sf.net/> | As of december 2009, it supports jQuery binding if you get it straight from the trunk.
```
$("#foo").injectWith(collectionOfJavaScriptObjects);
```
or
```
$("#foo").injectWith(simpleJavaScriptObject);
```
Also, you can now put all the "data:propName" markers in class="data:propName other classnames" attributes, so you don't have to litter your application's content with those markers.
I've yet to update a bunch of the documentation on there to reflect my recent enhancements, but the i've had various versions of this framework in production since 2007.
To skeptics of this question:
Back when Microsoft invented with IE5 what we now know as XmlHttpRequest and the "ajax" pattern, part of the promise behind this was to purely exchange data between a web browser and the server. That data was to be encapsulated in XML, because in 1999/2000, XML was simply just so very hot. Beyond retrieving an xml document over the network with a call-back mechanism, MS's MSXML ActiveX component also supported a pre-draft implementation of what we now know as XSL-T and XPath.
Combining retrieving HTTP/XML, XPath, and XSL-T, afforded developers tremendous creativity to build rich "documents" which behaved as "applications", purely sending, and more importantly, retrieving data from the server.
Why is this a useful pattern? It depends on how complex your user interface is, and how much you care about its maintainability.
When building a visually very rich semantically marked-up interface with advanced CSS, the last thing you want to do is chunk-out pieces of markup into "mini-controller/views", just so you can .innerHTML a document fragment into the main document, and here's why.
One key tenet of keeping an advanced html/css user interface manageable, is to preserve its validation at least during its active phase of development. If your markup validates, you can focus on your CSS bugs. Now, if fragments of markup end-up getting injected during various stages of user-interaction, it all becomes very unwieldy to manage, and the whole thing gets brittle.
The idea was to have all of your markup UI constructs in a single document, retrieve *ONLY DATA* over the network, and use a solid framework which will at the very least simply inject your data into your markup constructs, and at the most replicate markup constructs which you flagged as repeatable.
This was possible with XSL-T and XPath in IE5+, but virtually no other browsers. Some F/OSS browser frameworks have been dabbling with XPath but it's not quite something we can rely on just yet.
So what's the next best thing to achieve such pattern? IBDOM. Get data from your server, inject it in your document. effortlessly. |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | Well, to be frank, client-side templating is very hot nowadays, but quite a jungle.
the most popular are, I believe:
* [pure](http://beebole.com/pure/): It use only js, not his own
"syntax"
* [mustache](http://mustache.github.com/): quite stable and nice I
heard.
* [jqote2](http://aefxx.com/jquery-plugins/jqote2/): extremely fast
according to jsperfs
* jquery templates (deprecated):
there are *plenty* others, but you have to test them to see what suits you, and your project style, best.
Personally, I have a hard time with adding a new syntax and set of logic (*mixing logic and template, hello??*), and went pure js. Every single one of my templates is stored in it's own html file (./usersTable.row.html). I use templates only when ajaxing content, and I have few "logic" js files, one for tables, one for div, one for lists. and not even one for select's options (where i use another method).
Each time I tried to do something more complex, I found out the code was less clear and taking me more time to stabilize than doing it the "old" way. Logic in the template is an utter non-sense in my opinion, and adding it's own syntax adds only very-hard-to-trace bugs. | I would check out [json2html](http://www.json2html.com), it forgoes having to write HTML snippets and relies instead on JSON transforms to convert JSON object array's into unstructured lists. Very fast and uses DOM creation. |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | Well, to be frank, client-side templating is very hot nowadays, but quite a jungle.
the most popular are, I believe:
* [pure](http://beebole.com/pure/): It use only js, not his own
"syntax"
* [mustache](http://mustache.github.com/): quite stable and nice I
heard.
* [jqote2](http://aefxx.com/jquery-plugins/jqote2/): extremely fast
according to jsperfs
* jquery templates (deprecated):
there are *plenty* others, but you have to test them to see what suits you, and your project style, best.
Personally, I have a hard time with adding a new syntax and set of logic (*mixing logic and template, hello??*), and went pure js. Every single one of my templates is stored in it's own html file (./usersTable.row.html). I use templates only when ajaxing content, and I have few "logic" js files, one for tables, one for div, one for lists. and not even one for select's options (where i use another method).
Each time I tried to do something more complex, I found out the code was less clear and taking me more time to stabilize than doing it the "old" way. Logic in the template is an utter non-sense in my opinion, and adding it's own syntax adds only very-hard-to-trace bugs. | There is a reasonable discussion document on this topic [here](http://ajaxpatterns.org/Browser-Side_Templating), which covers a range of templating tools. Not specific to jQuery, though. |
449,780 | Any suggestions on which HTML template library would go well with JQuery? Googling turns up quite a number of libraries but I'm not sure whether there is a well recognized library that would stand the test of time. | 2009/01/16 | [
"https://Stackoverflow.com/questions/449780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51570/"
] | Well, to be frank, client-side templating is very hot nowadays, but quite a jungle.
the most popular are, I believe:
* [pure](http://beebole.com/pure/): It use only js, not his own
"syntax"
* [mustache](http://mustache.github.com/): quite stable and nice I
heard.
* [jqote2](http://aefxx.com/jquery-plugins/jqote2/): extremely fast
according to jsperfs
* jquery templates (deprecated):
there are *plenty* others, but you have to test them to see what suits you, and your project style, best.
Personally, I have a hard time with adding a new syntax and set of logic (*mixing logic and template, hello??*), and went pure js. Every single one of my templates is stored in it's own html file (./usersTable.row.html). I use templates only when ajaxing content, and I have few "logic" js files, one for tables, one for div, one for lists. and not even one for select's options (where i use another method).
Each time I tried to do something more complex, I found out the code was less clear and taking me more time to stabilize than doing it the "old" way. Logic in the template is an utter non-sense in my opinion, and adding it's own syntax adds only very-hard-to-trace bugs. | You should get a look on Javascript-Templates, this is a small template engine used within the famous jQuery File Upload plugin, and developed by the same author, Sebastian Tschan (@blueimp)
<https://github.com/blueimp/JavaScript-Templates>
**Follow the usage guide made** by Sebastian, just **remove this line**
```
document.getElementById("result").innerHTML = tmpl("tmpl-demo", data);
```
**Replace it with this one**
```
$('#result').html(tmpl('tmpl-demo', data));
```
**Don't forget** to add the div result tag in you HTML file too
```
<div id="result"></div>
```
Enjoy |
44,943,478 | I have been trying to post URL-encoded data using below code snippet
```
$.post( "url",{param:"value"},function(data){
alert("data==="+data);
});
```
Here URL is a `restful API` URL
This one is not working. Then I tried with `$.ajax`
```
$.ajax({
url:"url",
type:"POST",
dataType:"application/json",
contentType:"application/x-www-form-urlencoded",
data:$.param( $(param:'value') ),
success:function(data){
alert("data==="+data);
}
});
```
still not able to get data using a demo.html page
Then later tried with `PostMan` with the same configuration and it was working fine with the desired `json` result. | 2017/07/06 | [
"https://Stackoverflow.com/questions/44943478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4093604/"
] | $.ajax has a `success` param in the passed object.
To send `json` use `dataType: 'json'`.
No need for contentType, really.
Here's your updated code:
```
$.ajax({
url:"url",
type:"POST",
dataType:"json",
data:{param:'value'},
success: function( data )
{
alert("data==="+data);
}
})
```
<http://api.jquery.com/jquery.ajax/> | Your callback is wrong,
```
$.ajax({
url: "URL",
type: "POST",
dataType: "xml/html/script/json", // format for response
contentType: "application/json", // send as JSON
data: $.param( $(param:'value') ),
complete: function(data) {
//called when complete
console.log(data);
},
success: function(data) {
//called when successful
console.log(data);
},
error: function(err) {
//called when there is an error
console.log(err);
},
});
```
This is a full Ajax function. |
164,974 | ```
Set rs = con.Execute("select IIF(MAX(bill_bno) IS NULL,1,MAX(bill_bno)+1) from rec_all where rw=0 and iif(month(bill_date)>=1 AND month(bill_date)<=3,year(bill_date)-1,year(bill_date))=" & IIf(Month(Date) >= 1 And Month(Date) <= 3, Year(Date) - 1, Year(Date)))
```
how to change vb6 code (MS access) database to SQL Server 2012? | 2017/02/21 | [
"https://dba.stackexchange.com/questions/164974",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/118037/"
] | Try this:
```
SELECT COALESCE(MAX(bill_bno) + 1, 1) AS bill_bno
FROM rec_all
WHERE rw = 0
AND
(CASE WHEN MONTH(bill_date) >= 1 AND MONTH(bill_date) <= 3
THEN (YEAR(bill_date) - 1)
ELSE YEAR(bill_date) END)
=
(CASE WHEN MONTH(Date) >= 1 AND MONTH(Date) <= 3
THEN (YEAR(Date) - 1)
ELSE YEAR(Date) END)
```
or this one:
```
SELECT COALESCE(MAX(bill_bno) + 1, 1) AS bill_bno
FROM rec_all
WHERE rw = 0
AND
(
(MONTH(bill_date) >= 1 AND MONTH(bill_date) <= 3 AND (YEAR(bill_date) - 1) = (YEAR(Date) - 1))
OR
((MONTH(bill_date) <> 1 OR MONTH(bill_date) <> 3) AND (YEAR(bill_date)) = (YEAR(Date)))
)
``` | this should work
```
select max( isnull(billno, 0) ) + 1 from rec_all
``` |
164,974 | ```
Set rs = con.Execute("select IIF(MAX(bill_bno) IS NULL,1,MAX(bill_bno)+1) from rec_all where rw=0 and iif(month(bill_date)>=1 AND month(bill_date)<=3,year(bill_date)-1,year(bill_date))=" & IIf(Month(Date) >= 1 And Month(Date) <= 3, Year(Date) - 1, Year(Date)))
```
how to change vb6 code (MS access) database to SQL Server 2012? | 2017/02/21 | [
"https://dba.stackexchange.com/questions/164974",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/118037/"
] | Since you only gave us the line that generates your recordset, we'll assume that you are able to establish your connection successfully.
First: the following statement should be valid in SQL Server 2012:
```
select IIF(MAX(bill_bno) IS NULL,1,MAX(bill_bno)+1) from rec_all
where rw=0
and iif(month(bill_date)>=1 AND month(bill_date)<=3,year(bill_date)-1,year(bill_date))
=iif(Month(GETDATE())>= 1 And Month(GETDATE()) <= 3, Year(GETDATE()) - 1, Year(GETDATE()))
```
As far as I can tell, this is what you listed above, with the HTML-ification removed, and the SQL Server current date and time function `GETDATE()` replacing what I believe is the MS Access current date function `Date`.
I've displayed the query on multiple lines with indenting for human readability; you can put the full query on one line, if that's what you're language requires.
Not knowing the language you're using, I can't tell you how to properly format your actual con.execute command; change `>` and `<` to `>` and `<` if required.
As the other answers showed, there are other commands in SQL more commonly used to do the things you're doing (I had to check to be sure `iif` was available in T-SQL), but the major problem query-wise seems to have been how to get the current system date. | this should work
```
select max( isnull(billno, 0) ) + 1 from rec_all
``` |
8,394,330 | I have just come across the javascript code
`file_upload_started = progress < 100;`
and I have NO idea how to read it and Google isn't really turning much up. I'm not even sure what to call it so it's hard to do a search.
If anyone has any information about this type of equation, that would be much appreciated. | 2011/12/06 | [
"https://Stackoverflow.com/questions/8394330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325626/"
] | It stores the result of the expression `progress < 100` (*a boolean result*) to the variable `file_upload_started`
So if `progress` is less than `100` then it will set the `file_upload_started` to `true`, otherwise to `false` | It's setting `file_upload_started` to the boolean result of `progress < 100`
So if `progress` is 99, `file_upload_started` will be `true`, and of course if progress is 100 or greater, then `file_upload_started` will be false;
Not to belabor the point, but you could write that same code as:
```
if (progress < 100)
file_upload_started = true;
else
file_upload_started = false;
``` |
8,394,330 | I have just come across the javascript code
`file_upload_started = progress < 100;`
and I have NO idea how to read it and Google isn't really turning much up. I'm not even sure what to call it so it's hard to do a search.
If anyone has any information about this type of equation, that would be much appreciated. | 2011/12/06 | [
"https://Stackoverflow.com/questions/8394330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325626/"
] | It's setting `file_upload_started` to the boolean result of `progress < 100`
So if `progress` is 99, `file_upload_started` will be `true`, and of course if progress is 100 or greater, then `file_upload_started` will be false;
Not to belabor the point, but you could write that same code as:
```
if (progress < 100)
file_upload_started = true;
else
file_upload_started = false;
``` | Read it something like this:
```
file_upload_started = (progress < 100);
```
It just returns a boolean value that is set to the variable. |
8,394,330 | I have just come across the javascript code
`file_upload_started = progress < 100;`
and I have NO idea how to read it and Google isn't really turning much up. I'm not even sure what to call it so it's hard to do a search.
If anyone has any information about this type of equation, that would be much appreciated. | 2011/12/06 | [
"https://Stackoverflow.com/questions/8394330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325626/"
] | It stores the result of the expression `progress < 100` (*a boolean result*) to the variable `file_upload_started`
So if `progress` is less than `100` then it will set the `file_upload_started` to `true`, otherwise to `false` | Read it something like this:
```
file_upload_started = (progress < 100);
```
It just returns a boolean value that is set to the variable. |
8,394,330 | I have just come across the javascript code
`file_upload_started = progress < 100;`
and I have NO idea how to read it and Google isn't really turning much up. I'm not even sure what to call it so it's hard to do a search.
If anyone has any information about this type of equation, that would be much appreciated. | 2011/12/06 | [
"https://Stackoverflow.com/questions/8394330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325626/"
] | It stores the result of the expression `progress < 100` (*a boolean result*) to the variable `file_upload_started`
So if `progress` is less than `100` then it will set the `file_upload_started` to `true`, otherwise to `false` | Standard javascript. The expression on the right hand side is evaluated and the result assigned to the left hand side, so:
```
progress < 100
```
is evaluated and will return either true or false (or an error if progress hasn't been defined). That result is assigned:
```
file_upload_started = <value of expression>;
``` |
8,394,330 | I have just come across the javascript code
`file_upload_started = progress < 100;`
and I have NO idea how to read it and Google isn't really turning much up. I'm not even sure what to call it so it's hard to do a search.
If anyone has any information about this type of equation, that would be much appreciated. | 2011/12/06 | [
"https://Stackoverflow.com/questions/8394330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/325626/"
] | Standard javascript. The expression on the right hand side is evaluated and the result assigned to the left hand side, so:
```
progress < 100
```
is evaluated and will return either true or false (or an error if progress hasn't been defined). That result is assigned:
```
file_upload_started = <value of expression>;
``` | Read it something like this:
```
file_upload_started = (progress < 100);
```
It just returns a boolean value that is set to the variable. |
69,220 | What is exactly meant by *output compliance* of a current source? I've read that it's the range of voltage over which the current source behaves well. What exactly does ***behaving well*** mean?
---
I've got a little problem based on this concept, but Im not sure how to go about it.
*You have +5 and +15 volt regulated supplies available in a circuit. Design a 5mA npn circuit source(sink) using the +5 volts on the base. What is the output compliance?*
How would you do this? | 2013/05/14 | [
"https://electronics.stackexchange.com/questions/69220",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/23856/"
] | A well behaved (ideal) current source keeps the current constant no matter what its voltage is.
There are of course lots of different topologies for making current sources, just like there are lots of ways of making voltage sources. However, what this question is referring to is a special property of BJTs that can be exploited to make simple current sources.
Consider these characteristic curves of a common NPN transistor (swiped from [here](http://www.physics.csbsju.edu/trace/NPN.CC.html)):

Each curve is the collector current as a function of the collector to emitter voltage for a particular base current. Note how the curves are pretty flat after 1/2 a volt or so accross C-E. That means that the current changes little despite large changes in voltage. Sound familiar? Now see if you can exploit this in a circuit to make a well behaved current sink. | An ideal current source has infinite output resistance. A reasonable one has very very high output resistance. What this menas is that it will drive, the designed for current, into the load regardless of what that load is. In a simple model if you have a 1A source and you drive a 1 Ohm load the current source has to be able to maintain that current at 1 volt. IF the load changes to 1000 Ohms the current source has to have the compliance to be able to drive 1 A into 1000 ohms at 1000 Volts. If it drops off of the mark, like in only having a 15V rail, then it is not compliant enough.
There is enough hints in your question, a BJT has certain voltage limits that must be met to ensure that it operates correctly. These will limit you compliance especially if the base is at 5V. |
7,243,703 | I'm trying to find a best practice for getting values for a databound control. The way my application works now (and usually) is on page load I call a getSettings() or something and that makes a database call for each of the DropDownLists or Repeaters.
In this particular occasion I bind data to a DropDownList depending on which Button is clicked. There is a delay before the data shows up while the app goes to the database and gets the required information.
I'm wondering if there is a better way to handle getting the values, perhaps without making a database call each time the page is loaded. I've included some example code just in case.
.aspx:
```
<asp:DropDownList ID="ddl" runat="server"></asp:DropDownList>
<asp:Button ID="btn1" runat="server" OnCommand="btn_Command" CommandName="change" CommandArgument="table1" />
<asp:Button ID="btn2" runat="server" OnCommand="btn_Command" CommandName="change" CommandArgument="table2" />
<asp:Button ID="btn3" runat="server" OnCommand="btn_Command" CommandName="change" CommandArgument="table3" />
<asp:Button ID="btn4" runat="server" OnCommand="btn_Command" CommandName="change" CommandArgument="table4" />
```
codebehind:
```
DBClass dbc = new DBClass();
protected void btn_Command (object sender, CommandEventArgs e){
if (e.CommandName == "change"){
ddl.DataSource = dbc.ExecuteQuery("SELECT * FROM " + e.CommandArgument);
ddl.DataTextField = "Text";
ddl.DataValueField = "Value";
ddl.DataBind();
}
}
```
Is there any way to cache the results? I know this one is rough since it's only one DropDownList, but even if there is one for each button, is there some way I could get the data without making 4 database calls?
Thanks in advance. | 2011/08/30 | [
"https://Stackoverflow.com/questions/7243703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/854803/"
] | This should be the safest and most universal way. It's null-safe, you don't need an extra != null check:
```
SomeClass.class.isInstance(result)
```
**Reference:**
[`Class.isInstance(Object)`](http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#isInstance%28java.lang.Object%29) | You can use `result.getClass()` |
7,243,703 | I'm trying to find a best practice for getting values for a databound control. The way my application works now (and usually) is on page load I call a getSettings() or something and that makes a database call for each of the DropDownLists or Repeaters.
In this particular occasion I bind data to a DropDownList depending on which Button is clicked. There is a delay before the data shows up while the app goes to the database and gets the required information.
I'm wondering if there is a better way to handle getting the values, perhaps without making a database call each time the page is loaded. I've included some example code just in case.
.aspx:
```
<asp:DropDownList ID="ddl" runat="server"></asp:DropDownList>
<asp:Button ID="btn1" runat="server" OnCommand="btn_Command" CommandName="change" CommandArgument="table1" />
<asp:Button ID="btn2" runat="server" OnCommand="btn_Command" CommandName="change" CommandArgument="table2" />
<asp:Button ID="btn3" runat="server" OnCommand="btn_Command" CommandName="change" CommandArgument="table3" />
<asp:Button ID="btn4" runat="server" OnCommand="btn_Command" CommandName="change" CommandArgument="table4" />
```
codebehind:
```
DBClass dbc = new DBClass();
protected void btn_Command (object sender, CommandEventArgs e){
if (e.CommandName == "change"){
ddl.DataSource = dbc.ExecuteQuery("SELECT * FROM " + e.CommandArgument);
ddl.DataTextField = "Text";
ddl.DataValueField = "Value";
ddl.DataBind();
}
}
```
Is there any way to cache the results? I know this one is rough since it's only one DropDownList, but even if there is one for each button, is there some way I could get the data without making 4 database calls?
Thanks in advance. | 2011/08/30 | [
"https://Stackoverflow.com/questions/7243703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/854803/"
] | This should be the safest and most universal way. It's null-safe, you don't need an extra != null check:
```
SomeClass.class.isInstance(result)
```
**Reference:**
[`Class.isInstance(Object)`](http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#isInstance%28java.lang.Object%29) | No.
Use [Class.isAssignableFrom()](http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#isAssignableFrom%28java.lang.Class%29) |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | The second approach is only significantly different from the first approach if you have application state stored in an *instance* of AppState, in which case your complaint doesn't apply. If you're just storing stuff in a class and using static/class methods, your class is no different than a module, and it would be pythonic to instead actually have it as a module. | Why not go with an instance of that class? That way you might even be able later on to have 2 different "sessions" running, depending on what instance you use. It might make it more flexible. Maybe add some method `get_appstate()` to the module so it instanciates the class once. Later on if you might want several instances you can change this method to eventually take a parameter and use some dictionary etc. to store those instances.
You could also use property decorators btw to make things more readable and have the flexibility of storing it how and where you want it stores.
I agree that it would be more pythonic to use the module approach instead of classmethods.
BTW, I am not such a big fan of having things available globally by some "magic". I'd rather use some explicit call to obtain that information. Then I know where things come from and how to debug it when things fail. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | Sounds like the classic conundrum :-).
In Python, there's nothing dirty or shameful about choosing to use a module if that's the best approach. After all, modules, functions, and the like are, in fact, first-class citizens in the language, and offer introspection and properties that many other programming languages offer only by the use of objects.
The way you've described your options, it kinda sounds like you're not too crazy about a class-based approach in this case.
I don't know if you've used the Django framework, but if not, have a look at the documentation on how it handle settings. These are app-wide, they are defined in a module, and they are available globally. The way it parses the options and expose them globally is quite elegant, and you may find such an approach inspiring for your needs. | Consider this example:
```
configuration
|
+-> graphics
| |
| +-> 3D
| |
| +-> 2D
|
+-> sound
```
The real question is: What is the difference between classes and modules in this hierarchy, as it could be represented by both means?
Classes represent types. If you implement your solution with classes instead of modules, you are able to check a graphics object for it's proper type, but write generic graphics functions.
With classes you can generate parametrized values. This means it is possible to initialize differently the *sounds* class with a constructor, but it is hard to initialize a module with different parameters.
The point is, that you really something different from the modeling standpoint. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | The second approach is only significantly different from the first approach if you have application state stored in an *instance* of AppState, in which case your complaint doesn't apply. If you're just storing stuff in a class and using static/class methods, your class is no different than a module, and it would be pythonic to instead actually have it as a module. | Consider this example:
```
configuration
|
+-> graphics
| |
| +-> 3D
| |
| +-> 2D
|
+-> sound
```
The real question is: What is the difference between classes and modules in this hierarchy, as it could be represented by both means?
Classes represent types. If you implement your solution with classes instead of modules, you are able to check a graphics object for it's proper type, but write generic graphics functions.
With classes you can generate parametrized values. This means it is possible to initialize differently the *sounds* class with a constructor, but it is hard to initialize a module with different parameters.
The point is, that you really something different from the modeling standpoint. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | The second approach is only significantly different from the first approach if you have application state stored in an *instance* of AppState, in which case your complaint doesn't apply. If you're just storing stuff in a class and using static/class methods, your class is no different than a module, and it would be pythonic to instead actually have it as a module. | I'd definitely go for the second option : having already used the first one, I'm now forced to refactor, as my application evolved and have to support more modular constructs, so I now need to handle multiple simulataneous 'configurations'.
The second approach is, IMO, more flexible and future proof. To avoid the longer lines of code, you could use `from appstate import AppState` instead of just `import appstate`. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | The second approach seems better. I'd use the first one only for configuration files or something.
Anyway, to avoid the problem you could always:
```
from myapp.appstate import AppState
```
That way you don't have to write the long line anymore. | Why not go with an instance of that class? That way you might even be able later on to have 2 different "sessions" running, depending on what instance you use. It might make it more flexible. Maybe add some method `get_appstate()` to the module so it instanciates the class once. Later on if you might want several instances you can change this method to eventually take a parameter and use some dictionary etc. to store those instances.
You could also use property decorators btw to make things more readable and have the flexibility of storing it how and where you want it stores.
I agree that it would be more pythonic to use the module approach instead of classmethods.
BTW, I am not such a big fan of having things available globally by some "magic". I'd rather use some explicit call to obtain that information. Then I know where things come from and how to debug it when things fail. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | The second approach seems better. I'd use the first one only for configuration files or something.
Anyway, to avoid the problem you could always:
```
from myapp.appstate import AppState
```
That way you don't have to write the long line anymore. | Consider this example:
```
configuration
|
+-> graphics
| |
| +-> 3D
| |
| +-> 2D
|
+-> sound
```
The real question is: What is the difference between classes and modules in this hierarchy, as it could be represented by both means?
Classes represent types. If you implement your solution with classes instead of modules, you are able to check a graphics object for it's proper type, but write generic graphics functions.
With classes you can generate parametrized values. This means it is possible to initialize differently the *sounds* class with a constructor, but it is hard to initialize a module with different parameters.
The point is, that you really something different from the modeling standpoint. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | Consider this example:
```
configuration
|
+-> graphics
| |
| +-> 3D
| |
| +-> 2D
|
+-> sound
```
The real question is: What is the difference between classes and modules in this hierarchy, as it could be represented by both means?
Classes represent types. If you implement your solution with classes instead of modules, you are able to check a graphics object for it's proper type, but write generic graphics functions.
With classes you can generate parametrized values. This means it is possible to initialize differently the *sounds* class with a constructor, but it is hard to initialize a module with different parameters.
The point is, that you really something different from the modeling standpoint. | I'd definitely go for the second option : having already used the first one, I'm now forced to refactor, as my application evolved and have to support more modular constructs, so I now need to handle multiple simulataneous 'configurations'.
The second approach is, IMO, more flexible and future proof. To avoid the longer lines of code, you could use `from appstate import AppState` instead of just `import appstate`. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | Sounds like the classic conundrum :-).
In Python, there's nothing dirty or shameful about choosing to use a module if that's the best approach. After all, modules, functions, and the like are, in fact, first-class citizens in the language, and offer introspection and properties that many other programming languages offer only by the use of objects.
The way you've described your options, it kinda sounds like you're not too crazy about a class-based approach in this case.
I don't know if you've used the Django framework, but if not, have a look at the documentation on how it handle settings. These are app-wide, they are defined in a module, and they are available globally. The way it parses the options and expose them globally is quite elegant, and you may find such an approach inspiring for your needs. | I'd definitely go for the second option : having already used the first one, I'm now forced to refactor, as my application evolved and have to support more modular constructs, so I now need to handle multiple simulataneous 'configurations'.
The second approach is, IMO, more flexible and future proof. To avoid the longer lines of code, you could use `from appstate import AppState` instead of just `import appstate`. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | Why not go with an instance of that class? That way you might even be able later on to have 2 different "sessions" running, depending on what instance you use. It might make it more flexible. Maybe add some method `get_appstate()` to the module so it instanciates the class once. Later on if you might want several instances you can change this method to eventually take a parameter and use some dictionary etc. to store those instances.
You could also use property decorators btw to make things more readable and have the flexibility of storing it how and where you want it stores.
I agree that it would be more pythonic to use the module approach instead of classmethods.
BTW, I am not such a big fan of having things available globally by some "magic". I'd rather use some explicit call to obtain that information. Then I know where things come from and how to debug it when things fail. | I'd definitely go for the second option : having already used the first one, I'm now forced to refactor, as my application evolved and have to support more modular constructs, so I now need to handle multiple simulataneous 'configurations'.
The second approach is, IMO, more flexible and future proof. To avoid the longer lines of code, you could use `from appstate import AppState` instead of just `import appstate`. |
600,190 | In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
1. Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it seems that I am missing *something* in clarity of my code.
2. Create a class AppState with class functions in a appstate.py file, all other modules have been defined by their specific jobs. This looks fine. But now I have to write longer line like appstate.AppState.get\_user\_list(). Moreover, the methods are not so much related to each other. I can create separate classes but that would be too many classes.
EDIT: If I use classes I will be using classmethods. I don't think there is a need to instantiate the class to an object. | 2009/03/01 | [
"https://Stackoverflow.com/questions/600190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69746/"
] | Sounds like the classic conundrum :-).
In Python, there's nothing dirty or shameful about choosing to use a module if that's the best approach. After all, modules, functions, and the like are, in fact, first-class citizens in the language, and offer introspection and properties that many other programming languages offer only by the use of objects.
The way you've described your options, it kinda sounds like you're not too crazy about a class-based approach in this case.
I don't know if you've used the Django framework, but if not, have a look at the documentation on how it handle settings. These are app-wide, they are defined in a module, and they are available globally. The way it parses the options and expose them globally is quite elegant, and you may find such an approach inspiring for your needs. | The second approach seems better. I'd use the first one only for configuration files or something.
Anyway, to avoid the problem you could always:
```
from myapp.appstate import AppState
```
That way you don't have to write the long line anymore. |
19,349,400 | When I get a run-time error, VS normally points me to the line where error occurred.
But I cannot edit anything until the program closes. And VS doesn't close it for me.
Instead I have to manually end it in Task Manager (What I have been doing so far)
Now, there must be a more convenient way of closing to program, and getting back to work,
without the use of Task Manager to do it.
How? | 2013/10/13 | [
"https://Stackoverflow.com/questions/19349400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945273/"
] | There are a couple of things that you can do to end the program. One common keyboard shortcut is Shift-F5 (stop debugging).
The other is the Stop Debugging button on the VS debugging toolbar. | There's a Stop button in the VS toolbar:
 |
19,349,400 | When I get a run-time error, VS normally points me to the line where error occurred.
But I cannot edit anything until the program closes. And VS doesn't close it for me.
Instead I have to manually end it in Task Manager (What I have been doing so far)
Now, there must be a more convenient way of closing to program, and getting back to work,
without the use of Task Manager to do it.
How? | 2013/10/13 | [
"https://Stackoverflow.com/questions/19349400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945273/"
] | There is stop button in Visual Studio.
 | There are a couple of things that you can do to end the program. One common keyboard shortcut is Shift-F5 (stop debugging).
The other is the Stop Debugging button on the VS debugging toolbar. |
19,349,400 | When I get a run-time error, VS normally points me to the line where error occurred.
But I cannot edit anything until the program closes. And VS doesn't close it for me.
Instead I have to manually end it in Task Manager (What I have been doing so far)
Now, there must be a more convenient way of closing to program, and getting back to work,
without the use of Task Manager to do it.
How? | 2013/10/13 | [
"https://Stackoverflow.com/questions/19349400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945273/"
] | There's a stop button (green square) on the debug toolbar. That will halt your program (in 99% of time).
The reason it is not stopped automatically, is to allow inspection of your failed program state. But that kind of speaks for itself.
Edit: (oh, sorry it's blue as Rahul's screencapture points out) | There's a Stop button in the VS toolbar:
 |
19,349,400 | When I get a run-time error, VS normally points me to the line where error occurred.
But I cannot edit anything until the program closes. And VS doesn't close it for me.
Instead I have to manually end it in Task Manager (What I have been doing so far)
Now, there must be a more convenient way of closing to program, and getting back to work,
without the use of Task Manager to do it.
How? | 2013/10/13 | [
"https://Stackoverflow.com/questions/19349400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945273/"
] | There is stop button in Visual Studio.
 | There's a stop button (green square) on the debug toolbar. That will halt your program (in 99% of time).
The reason it is not stopped automatically, is to allow inspection of your failed program state. But that kind of speaks for itself.
Edit: (oh, sorry it's blue as Rahul's screencapture points out) |
19,349,400 | When I get a run-time error, VS normally points me to the line where error occurred.
But I cannot edit anything until the program closes. And VS doesn't close it for me.
Instead I have to manually end it in Task Manager (What I have been doing so far)
Now, there must be a more convenient way of closing to program, and getting back to work,
without the use of Task Manager to do it.
How? | 2013/10/13 | [
"https://Stackoverflow.com/questions/19349400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945273/"
] | There is stop button in Visual Studio.
 | There's a Stop button in the VS toolbar:
 |
193,776 | I just want to get the pivot location of the 3d model!
[](https://i.stack.imgur.com/Beygz.png)
I tried to set the cursor to pivot position and print the cursor location
```
import bpy
bpy.ops.view3d.snap_cursor_to_selected()
print(bpy.context.scene.cursor.location)
```
I had this error:
```
RuntimeError: Operator bpy.ops.view3d.snap_cursor_to_selected.poll() failed, context is incorrect
Error: Python script failed, check the message in the system console
``` | 2020/09/07 | [
"https://blender.stackexchange.com/questions/193776",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/33446/"
] | Objects pivot around their origins, or (0, 0, 0) in their local space. An object's position is simply the location of its origin in world space. You can get this as a Vector from the object's location variable:
```
import bpy
obj = bpy.context.active_object
print(obj.location)
```
If you actually did want to set the cursor location:
```
bpy.context.scene.cursor.location = obj.location
```
See [How do you get an object's position and rotation through script?](https://blender.stackexchange.com/questions/39677/how-do-you-get-an-objects-position-and-rotation-through-script) for a more thorough look. | **Global and Local**
The scene cursor location is in global coordinates.
For an object `ob`
What you see in the location field of an object is its basis matrix translation.
```
ob.matrix_basis.translation # == ob.location
```
, Rarely for an object with parents and / or constraints will `ob.location` also be the global location of the origin of the object. An object with `ob.location == (0, 0, 0)` can be globally anywhere in scene via parenting or a copy location constraint to another object.
Using `ob.matrix_world.translation` will ensure global (or world) coordinates, hence to set the cursor location to the objects global location
```
scene.cursor.location = ob.matrix_world.translation
```
Be very wary of mixing the two. (global and local) |
562,288 | Does a similar connection cause conflicts or damage?
[](https://i.stack.imgur.com/IphPS.png)
An example of situation in which it's used. I've seen it's common practice in RF to put an inductor (RF Choke) between the drain of a MOSFET and VDD like in the following picture:
[](https://i.stack.imgur.com/n1QFK.png)
At DC, VDS is set equal to VDD. But between D and S there is a voltage controlled current source, since the MOSFET is biased between gate and source so that it can provide a proper drain current. So, current source in parallel with voltage source.
How can the MOSFET current source react when there is something that forces its voltage? In non-RF class A amplifiers, usually there is a resistor instead of an inductor and so this situation doesn't occur. | 2021/04/27 | [
"https://electronics.stackexchange.com/questions/562288",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/214898/"
] | As you would expect with a voltage and a current source in parallel, the current is defined by the current source, and voltage is defined by the voltage source.
The RF choke therefore constrains the DC value of the drain voltage to be equal to the supply. The FET causes its average current to flow through the RF choke.
It's at AC where things get interesting. The RF choke now behaves like a current source. We now have two current sources in parallel. The load resistance controls the voltage that the current produces.
At AC, the voltage can swing above and below the supply voltage. If the load had been a resistor, then the FET could have only pulled the voltage below the supply. | In your circuit at DC, think of the MOSFET more like a switch than a current source since at DC you'll mostly be in the triode region. The voltage Vdd squared divided by the drain-source resistance will give you the power dissipated, and you want that to be small enough to not burn out the transistor (when using it like a switch).
It doesn't work like an amplifier until you are at a frequency high enough that the inductor has some impedance. |
54,572,154 | I have question: I have stored procedure A(return three out paramters). I want to call procedure A in loop and insert these three parameters into temporaty table and return this table.
```
DECLARE
Type TestTable IS TABE OF NUMBER; -- for example one parameter!!!
myTable TestTable;
BEGIN
LOOP
A(o_param1, o_param2, o_param3);
-- myTable insert o_param1,2,3;
-- insert into myTable values(99); - here I have error PL/SQL: ORA-00942: table or view does not exist
END LOOP;
SELECT * FROM myTable;
END;
```
I dont know how to do -- myTable insert o\_param1,2,3;. Please help me. | 2019/02/07 | [
"https://Stackoverflow.com/questions/54572154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8927212/"
] | write insert statement inside the loop. so for each loop you can have the values inserted to the table and give a commit after the loop.
But you cannot have a select \* from table inside the anonymous block. Remove that from the block and after end; you can try running select \* from table to see the output.
```
BEGIN
LOOP
A(o_param1, o_param2, o_param3);
-- myTable insert o_param1,2,3;
insert into myTable values (o_param1, o_param2, o_param3);
END LOOP;
commit;
--SELECT * FROM myTable;-
END;
SELECT * FROM myTable;
> Blockquote
``` | First, you cannot insert data into myTable directly (insert into myTable) because Oracle table types, declared in a declare section of the script, are not visible in sql statements (exception - insert using 'bulk collect' with types, declared in Oracle dictionary).
Even if you insert data in myTable using myTable(idx)... you can not select it outside the script because myTable exists only inside the script.
I think the simpliest way is to create usual table or global temporary table. If you will use global temporary table create it with 'ON COMMIT PRESERVE ROWS' (if you use commit after insert) |
48,489 | I just bought a new electronic ballast to replace the old one for my florescent lamp. However, the connection diagram on the ballast does not indicate where I should connect the live and neutral wires. There are also no L and N markings on either side.

Does it matter at all or am I putting myself at risk of a shock if connected wrongly? | 2014/09/05 | [
"https://diy.stackexchange.com/questions/48489",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9165/"
] | @Aaron, what you propose is fine.
Remember, splices inside conduit are not allowed, so your plan to remove the j-box, extend the conduit, and pull new wire is perfect. | Wires that run through conduit must be complete and unbroken. So if you have to splice the wires together with wire nuts or whatever is appropriate for your jurisdiction, then no, you can just just join the conduit together.
Some other options:
* Cover the junction box with a blank cover and paint it to match your ceiling.
* Get an in-wall rated splice. <http://www.homedepot.com/p/Tyco-Electronics-Romex-Splice-Kit-2-Wire-1-Clam-CPGI-1116377-2/202204326>
* Pull new cable beginning to end and use the junction. |
54,728,490 | I have VPS instance from AWS running on Ubuntu. And I want to run Dart Http server on it to allow In/Outcmming request.
I have installed the Dart SDK and Apache server.
for example, I need to run this sample code on the server and I need to access this server by its Public IP from any PC or Phone as a user.
```
import 'dart:io';
Future main() async {
var server = await HttpServer.bind(
InternetAddress.loopbackIPv4,
4040,
);
print('Listening on localhost:${server.port}');
await for (HttpRequest request in server) {
request.response
..write('Hello, world!')
..close();
}
}
```
what are the pre-requested software to make this happen?
Thanks for any kind of help I been spent around two weeks Play with this | 2019/02/16 | [
"https://Stackoverflow.com/questions/54728490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8538499/"
] | It's a little bit weird that there is no error, however double check the file is in the correct place (an error should be thrown for this though if it can't find it) and also check the permissions on the file with `ls -l`. | You might wanna do:
```
fs.readFile("./quotes.json", "utf8", function(err, data) {
if(err) console.log(err);
```
So that it shows you the Error |
55,951,264 | With this code:
```
strs = ["111", "1000", "1000", "1000"]
# count the numbers of '0' and '1' respectively for each string in strs
counts = map(lambda x: [x.count('0'), x.count('1')], strs)
cntSortBy0 = sorted(counts, key=lambda x: x[0]) # sort with counts of '0'
cntSortBy1 = sorted(counts, key=lambda x: x[1]) # sort with counts of '1'
```
Here I have a list `strs` with strings as elements.
Then I count the numbers of '0' and '1' respectively for each string in strs and save the results in `counts` (I did this using map in python3, so `count` is a map object).
After that I sort `counts` for the first time, and it works fine,
but when I sort `counts` for the second time, it returns an empty list(`cntSortBy1` is empty),
I find that this is because `counts` became empty **after the first sort**:
```
>>> strs = ["111", "1000", "1000", "1000"]
>>> counts = map(lambda x: [x.count('0'), x.count('1')], strs)
>>> cntSortBy0 = sorted(counts, key=lambda x: x[0]) # sort with counts of '0'
>>> list(counts)
[]
```
No wonder `cntSortBy1` is empty, but why dose this happen?
Besides, if I just merely print `list(counts)`, `cntSortBy1` will also became empty, as shown below,
```
>>> strs = ["111", "1000", "1000", "1000"]
>>> counts = map(lambda x: [x.count('0'), x.count('1')], strs)
>>> list(counts)
[[0, 3], [3, 1], [3, 1], [3, 1]]
>>> cntSortBy0 = sorted(counts, key=lambda x: x[0])
>>> cntSortBy0
[]
```
* Dose this mean a map object could only be used once, after that it will become an empty list?
* Is there any other objects in Py3 with the same feature? (I have tried `range()`, it is not.)
Many Thanks!!! | 2019/05/02 | [
"https://Stackoverflow.com/questions/55951264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10870360/"
] | In Python3 `map` returns an iterator:
<https://docs.python.org/3/library/functions.html#map>
And iterators can (and should) be used only once. See official doc about iterators:
<https://docs.python.org/3/tutorial/classes.html#iterators>
In your case you need to convert `map` to `list` upon creation, that'll solve your problem:
```
counts = list(map(lambda x: [x.count('0'), x.count('1')], strs))
``` | Once an iterator has been exhausted (meaning, fully iterated over), there is nothing left to be iterated over, so iterating over it a second time won't yield anything. Take this example.
```
a = map(int,['1','2','3'])
for i in a:
print(i)
for i in a:
print(i)
```
This will output:
```
1
2
3
```
Whenever you need to iterate over an iterator multiple times, turn it into a list (or another type of sequence):
```
a = list(map(int,['1','2','3']))
```
This outputs:
```
1
2
3
1
2
3
```
When using `sorted()`, you're also iterating over the `map` iterator object:
```
a = map(int,['1','2','3'])
print(sorted(a)) # output: [1, 2, 3]
print(sorted(a)) # output: []
a = list(map(int,['1','2','3']))
print(sorted(a)) # output: [1, 2, 3]
print(sorted(a)) # output: [1, 2, 3]
``` |
55,951,264 | With this code:
```
strs = ["111", "1000", "1000", "1000"]
# count the numbers of '0' and '1' respectively for each string in strs
counts = map(lambda x: [x.count('0'), x.count('1')], strs)
cntSortBy0 = sorted(counts, key=lambda x: x[0]) # sort with counts of '0'
cntSortBy1 = sorted(counts, key=lambda x: x[1]) # sort with counts of '1'
```
Here I have a list `strs` with strings as elements.
Then I count the numbers of '0' and '1' respectively for each string in strs and save the results in `counts` (I did this using map in python3, so `count` is a map object).
After that I sort `counts` for the first time, and it works fine,
but when I sort `counts` for the second time, it returns an empty list(`cntSortBy1` is empty),
I find that this is because `counts` became empty **after the first sort**:
```
>>> strs = ["111", "1000", "1000", "1000"]
>>> counts = map(lambda x: [x.count('0'), x.count('1')], strs)
>>> cntSortBy0 = sorted(counts, key=lambda x: x[0]) # sort with counts of '0'
>>> list(counts)
[]
```
No wonder `cntSortBy1` is empty, but why dose this happen?
Besides, if I just merely print `list(counts)`, `cntSortBy1` will also became empty, as shown below,
```
>>> strs = ["111", "1000", "1000", "1000"]
>>> counts = map(lambda x: [x.count('0'), x.count('1')], strs)
>>> list(counts)
[[0, 3], [3, 1], [3, 1], [3, 1]]
>>> cntSortBy0 = sorted(counts, key=lambda x: x[0])
>>> cntSortBy0
[]
```
* Dose this mean a map object could only be used once, after that it will become an empty list?
* Is there any other objects in Py3 with the same feature? (I have tried `range()`, it is not.)
Many Thanks!!! | 2019/05/02 | [
"https://Stackoverflow.com/questions/55951264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10870360/"
] | In Python3 `map` returns an iterator:
<https://docs.python.org/3/library/functions.html#map>
And iterators can (and should) be used only once. See official doc about iterators:
<https://docs.python.org/3/tutorial/classes.html#iterators>
In your case you need to convert `map` to `list` upon creation, that'll solve your problem:
```
counts = list(map(lambda x: [x.count('0'), x.count('1')], strs))
``` | According to the docs: <https://docs.python.org/3/library/functions.html#map>
>
> map(function, iterable, ...)
>
> Return an iterator that applies function to every item of iterable, yielding the results.
>
>
>
What a map does is returns an iterator, which you can iterate on, but once you are done iterating on it, it becomes empty, or as you keep iterating on it, size of iterator keeps reducing
Hence when you done iterating over the iterator `counts` returned by `map(lambda x: [x.count('0'), x.count('1')], strs)` via `sorted(counts, key=lambda x: x[0])`, it becomes empty
To avoid this, you need to cast any iterator you want to reuse into a list using `list(map(...))` and then you can use it as much as you want, for example.
```
In [1]: strs = ["111", "1000", "1000", "1000"]
In [2]: counts = list(map(lambda x: [x.count('0'), x.count('1')], strs))
In [3]: counts)
Out[3]: [[0, 3], [3, 1], [3, 1], [3, 1]]
In [4]: cntSortBy0 = sorted(counts, key=lambda x: x[0])
In [5]: cntSortBy0
Out[5]: [[0, 3], [3, 1], [3, 1], [3, 1]]
In [6]: counts
Out[6]: [[0, 3], [3, 1], [3, 1], [3, 1]]
In [7]: cntSortBy1 = sorted(counts, key=lambda x: x[1])
In [9]: cntSortBy1
Out[9]: [[3, 1], [3, 1], [3, 1], [0, 3]]
In [10]: counts
Out[10]: [[0, 3], [3, 1], [3, 1], [3, 1]]
```
As you can see, we utilized `counts` twice, but it was never empties, since we now converted it to a list, which is intact even after you iterate on in countless number of times. |
55,951,264 | With this code:
```
strs = ["111", "1000", "1000", "1000"]
# count the numbers of '0' and '1' respectively for each string in strs
counts = map(lambda x: [x.count('0'), x.count('1')], strs)
cntSortBy0 = sorted(counts, key=lambda x: x[0]) # sort with counts of '0'
cntSortBy1 = sorted(counts, key=lambda x: x[1]) # sort with counts of '1'
```
Here I have a list `strs` with strings as elements.
Then I count the numbers of '0' and '1' respectively for each string in strs and save the results in `counts` (I did this using map in python3, so `count` is a map object).
After that I sort `counts` for the first time, and it works fine,
but when I sort `counts` for the second time, it returns an empty list(`cntSortBy1` is empty),
I find that this is because `counts` became empty **after the first sort**:
```
>>> strs = ["111", "1000", "1000", "1000"]
>>> counts = map(lambda x: [x.count('0'), x.count('1')], strs)
>>> cntSortBy0 = sorted(counts, key=lambda x: x[0]) # sort with counts of '0'
>>> list(counts)
[]
```
No wonder `cntSortBy1` is empty, but why dose this happen?
Besides, if I just merely print `list(counts)`, `cntSortBy1` will also became empty, as shown below,
```
>>> strs = ["111", "1000", "1000", "1000"]
>>> counts = map(lambda x: [x.count('0'), x.count('1')], strs)
>>> list(counts)
[[0, 3], [3, 1], [3, 1], [3, 1]]
>>> cntSortBy0 = sorted(counts, key=lambda x: x[0])
>>> cntSortBy0
[]
```
* Dose this mean a map object could only be used once, after that it will become an empty list?
* Is there any other objects in Py3 with the same feature? (I have tried `range()`, it is not.)
Many Thanks!!! | 2019/05/02 | [
"https://Stackoverflow.com/questions/55951264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10870360/"
] | Once an iterator has been exhausted (meaning, fully iterated over), there is nothing left to be iterated over, so iterating over it a second time won't yield anything. Take this example.
```
a = map(int,['1','2','3'])
for i in a:
print(i)
for i in a:
print(i)
```
This will output:
```
1
2
3
```
Whenever you need to iterate over an iterator multiple times, turn it into a list (or another type of sequence):
```
a = list(map(int,['1','2','3']))
```
This outputs:
```
1
2
3
1
2
3
```
When using `sorted()`, you're also iterating over the `map` iterator object:
```
a = map(int,['1','2','3'])
print(sorted(a)) # output: [1, 2, 3]
print(sorted(a)) # output: []
a = list(map(int,['1','2','3']))
print(sorted(a)) # output: [1, 2, 3]
print(sorted(a)) # output: [1, 2, 3]
``` | According to the docs: <https://docs.python.org/3/library/functions.html#map>
>
> map(function, iterable, ...)
>
> Return an iterator that applies function to every item of iterable, yielding the results.
>
>
>
What a map does is returns an iterator, which you can iterate on, but once you are done iterating on it, it becomes empty, or as you keep iterating on it, size of iterator keeps reducing
Hence when you done iterating over the iterator `counts` returned by `map(lambda x: [x.count('0'), x.count('1')], strs)` via `sorted(counts, key=lambda x: x[0])`, it becomes empty
To avoid this, you need to cast any iterator you want to reuse into a list using `list(map(...))` and then you can use it as much as you want, for example.
```
In [1]: strs = ["111", "1000", "1000", "1000"]
In [2]: counts = list(map(lambda x: [x.count('0'), x.count('1')], strs))
In [3]: counts)
Out[3]: [[0, 3], [3, 1], [3, 1], [3, 1]]
In [4]: cntSortBy0 = sorted(counts, key=lambda x: x[0])
In [5]: cntSortBy0
Out[5]: [[0, 3], [3, 1], [3, 1], [3, 1]]
In [6]: counts
Out[6]: [[0, 3], [3, 1], [3, 1], [3, 1]]
In [7]: cntSortBy1 = sorted(counts, key=lambda x: x[1])
In [9]: cntSortBy1
Out[9]: [[3, 1], [3, 1], [3, 1], [0, 3]]
In [10]: counts
Out[10]: [[0, 3], [3, 1], [3, 1], [3, 1]]
```
As you can see, we utilized `counts` twice, but it was never empties, since we now converted it to a list, which is intact even after you iterate on in countless number of times. |
69,600,941 | Using stripe's API and the Integration Builder, before you go to the checkout page, you can get the `id` of the `Ceckout Sessions` in the `create-checkout-session.php` file. (<https://stripe.com/docs/api/checkout/sessions/object?lang=php>)
My plan is to use that session ID later on to get the customer's ID and the subscription's ID.
But does these sessions expires? Meaning after some time, i won't be able retrieve that session? (<https://stripe.com/docs/api/checkout/sessions/retrieve?lang=php>).
Ps: I don't think it matters, but i'm using PHP as my backend language. | 2021/10/17 | [
"https://Stackoverflow.com/questions/69600941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16428646/"
] | To be clear,
* You can retrieve the full details of a [Checkout Session](https://stripe.com/docs/api/checkout/sessions) any time using the API : <https://stripe.com/docs/api/checkout/sessions/retrieve>. There is no "expiry" for this.
* You can only access the full data of an [Event](https://stripe.com/docs/api/events) e.g. `checkout.session.completed` if it was created within the last 13 months from the Dashboard. Events older than 30 days will only provide a summary view. Events within the last 30 days will be fully visible via the API and Dashboard. ([source](https://support.stripe.com/questions/stripe-event-retention-period))
* A Checkout Session expires 24 hours after they’re created (i.e. the customer cannot access/pay via the Checkout [url](https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-url)), but you can shorten the expiration time by setting `expires_at` ([source](https://stripe.com/docs/payments/checkout/abandoned-carts#adjust-session-expiration)). Note that you can still access the details of the Checkout Session as mentioned in the first point.
Ideally, you should rely on webhooks :
* <https://stripe.com/docs/payments/checkout/fulfill-orders>
* <https://stripe.com/docs/webhooks>
The `checkout.session.completed` event will contain the [customer](https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer) and [subscription](https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-subscription). | Checkout sessions aren't stored forever. They live for short period of time and after that they expire. However, if you need the customer and subscription id, you can follow the following steps (same i use in one of my project).
1. Create Checkout Session and once user redirect back to the website after successful checkout, retrieve the session using the session Id
2. Inside the retrieve session response, there is a customer (customerId) and subscriptionId if the payment mode is subscription.
3. [](https://i.stack.imgur.com/f4178.png)
4. Get the customer (customerId) and subscriptionId from the session retrieve api response and store both into database for later use.
5. Further to get the customer information, you can use the customer api and pass the customerId to get the detailed information about that customer.
6. [](https://i.stack.imgur.com/l5m4k.png)
7. Similarly, you can use the subscription api to retrieve the particular subscription.
8. [](https://i.stack.imgur.com/uC2SH.png) |
298,179 | My question is in the title above. I'm asking in informal way, I mean, can I use that in my daily conversation? This problem arose from learning languages app. The app said the correct answer is
>
> What are you thinking?
>
>
>
I consulted this problem to the app group, some English native speakers said it's incorrect to say **what're**, even though I've seen that word from an English comic (I don't care whether it's informal, since I only use that in my conversation). The second problem is the preposition **about**. Is it not OK to put *about* after *think* when we use it as an interrogative sentence? | 2021/09/21 | [
"https://ell.stackexchange.com/questions/298179",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/110852/"
] | '*My* favourite' means 'the one *I* like best'. 'Brooke's favourite' would be the one *she* likes best.
You could say 'It's my favourite of all Brooke's songs'. | The **'s** marker does not always indicate possession.
**My favorite song** *means* `the song that I like best.`
**Brooke's favorite song** *means* `the song that Brooke likes best.` And it means only that. It indicates nothing about the person who wrote or recorded the song, who owns the copyright, or anything like that.
**Collocation** is a reasonable way to describe this pattern.
In contrast, **Brooke's song** would usually suggest that Brooke was/is involved in the composition, performance, or ownership of the song.
Casually, you might say something like, **This is my song** when you mean, **This is my *favorite* song.** But the reverse is not true.
Another option is idiomatic, as randomhead points out, and might be what you are looking for. Without the **'s** marker, a name can function as a simple adjective. Consider:
>
> my favorite Stephen King novel
>
> my favorite Hitchcock film
>
> my favorite Chef John recipe
>
> my favorite Beatles song
>
>
>
All of these are quite common, and lead to these possibilities:
>
> my favorite Brooke Candy song
>
> *or*
>
> my favorite Brooke song
>
>
>
The words must come in this sequence, or the meaning will be garbled. Only one "possessive" adjective (**my**) is permitted. I mention **my favorite Beatles song** because, when spoken, you cannot hear a distinction between **Beatles** and **Beatles'.** This structure is used so frequently with musical groups whose names end in **-s** that the plural and the "possessive" are easily confused. But the "possessive" is incorrect. A native speaker instantly knows that **my favorite Hitchcock's film** is wrong.
Note: I would rather use the term "genitive" than "possessive" in this situation, but that controversy is irrelevant here. |
72,782,659 | I would like to install Flutter on my Apple M1 machine using [Homebrew](https://formulae.brew.sh/cask/flutter). But I am a bit hesitant because I am not sure if this will provide any benefits or it will create more trouble (e.g. permission issues). An alternative way would to be install Flutter using its installer from its [docs](https://docs.flutter.dev/get-started/install).
My question is, is there a recommended way to install Flutter on an Apple M1 macbook? I could not find any docs regarding installing Flutter using Homebrew. | 2022/06/28 | [
"https://Stackoverflow.com/questions/72782659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13690331/"
] | I ended up installing Flutter in with the following steps:
1. Install `Homebrew` (if you dont already have)\* - [install Homebrew](https://brew.sh/)
2. Install `fvm` using `Homebrew` - [install fvm](https://fvm.app/docs/getting_started/installation/)
3. Install your wanted `flutter` version through `fvm` - [fvm documentation](https://fvm.app/docs/guides/basic_commands)
4. Not necessary: Install `Sidekick` which basically gives you a visualization of your installed versions and flutter projects - [install sidekick](https://github.com/fluttertools/sidekick)
Example of using fvm: `fvm install {version} - # Installs specific version` | @ilpianoforte Does a great job outlining the steps, but I needed to do an additional step for macOS 13.x. So, I thought I would consolidate here.
To install Flutter via Homebrew.
1. Install `Homebrew`
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
2. Install `fvm` with `Homebrew` (this manages multiple versions of `Flutter`)
```
brew tap leoafarias/fvm
brew install fvm
```
3. Install the latest stable version of `Flutter`
```
fvm install stable
```
4. Append the path to `Flutter` to `PATH` by copying the line below into `.zshrc` (located in the home directory). IMPORTANT: Make sure to replace `[USER_HERE]` with your user name.
```
export PATH=$PATH:"/Users/[USER_HERE]/fvm/default/bin"
```
5. Reload `.zshrc`
```
source ~/.zshrc
```
6. Optional: Test `Flutter` installation.
```
flutter doctor
``` |
7,677,924 | I'm new to Git and I'm a little confused how to use "git fetch"
I have a central repository that I access using SSH, I have created a repository using git clone, just like this:
```
$ cd /my/local/repotest
$ git clone ssh://[email protected]/var/github/repotest .
```
Now other developer have pushed some new files to the central repo in "somedomain.com"
My question is, how can I fetch the new files and changes via command line? | 2011/10/06 | [
"https://Stackoverflow.com/questions/7677924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/488735/"
] | Converting a pointer to/from an integer is implementation defined.
[Here](http://gcc.gnu.org/onlinedocs/gcc/Arrays-and-pointers-implementation.html) is how gcc does it, i.e. it sign extends if the integer type is larger than the pointer type(this'll happen regardless of the integer being signed or unsigned, just because that's how gcc decided to implement it).
Presumably msvc behaves similar. Edit, the closest thing I can find on MSDN is [this](http://msdn.microsoft.com/en-us/library/aa983399.aspx)/[this](http://msdn.microsoft.com/en-us/library/aa384242%28v=vs.85%29.aspx), suggesting that converting 32 bit pointers to 64 bit also sign extends. | From the C99 standard (§6.3.2.3/6):
>
> Any pointer type may be converted to an integer type. Except as previously specified, **the
> result is implementation-defined**. If the result cannot be represented in the integer type,
> the behavior is undefined. The result need not be in the range of values of any integer
> type.
>
>
>
So you'll need to find your compiler's documentation that talks about that. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.