qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
43,535,048 | I am going to develop a simple Angular 2 application. I have created a project with routing, using Angular CLI and added several components to the app using 'ng generate component ' command. Then I specified routing in the **app-routing.module.ts** as following.
```
import { NgModule } from '@angular/core';
import { R... | 2017/04/21 | [
"https://Stackoverflow.com/questions/43535048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1697885/"
] | This problem is solved by implementing `HashLocationStrategy` which adds `#` to all your routes. You achieve this by adding `HashLocationStrategy` to `AppModule` `providers`.
```js
providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}],
```
and add the corresponding import
```js
import { HashLocat... | **For Apache server:**
*in the Production servers*
Add or create ".htaccess" file into the project root, add a rewrite rule to the .htaccess file as shown
```
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOC... |
43,535,048 | I am going to develop a simple Angular 2 application. I have created a project with routing, using Angular CLI and added several components to the app using 'ng generate component ' command. Then I specified routing in the **app-routing.module.ts** as following.
```
import { NgModule } from '@angular/core';
import { R... | 2017/04/21 | [
"https://Stackoverflow.com/questions/43535048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1697885/"
] | If you use href, change them to routerlink. | ```
export const routes: Routes =[
**{ path: '', redirectTo: '/', pathMatch: 'full'},**
{ path: 'about', component: AboutComponent},
{ path: 'user', component: UserComponent},
{ path: 'specialpage', component: SpecialpageComponent},
{ path: '**', component: ErrorComponent}
];
```
Look at... |
65,549 | I've created a very basic character so that I can learn to do basic rigging and animation, but I'm struggling with areas of the mesh that will bend.
This will be easier to show. In the first picture, you can see the leg is bent, however, I want the mesh to remain as boxy as possible. I don't mind some deforming, but i... | 2016/10/21 | [
"https://blender.stackexchange.com/questions/65549",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/22235/"
] | I will go ahead and post this although I am not sure that it will completely satisfy all points of your question. I found this to be an interesting question that allowed me to learn some new things as I researched it, so thank you for that.
I found the currently supported attributes for smoke and fire to be located at... | As a sort of "wrap up" of the comments I will answer my own question.
Available attributes from version 2.78 in a Smoke Simulation are:
* color
* density
* flame
* heat \*
* velocity \*
They are now all defined in /addons/cycles/kernel/kernel\_types. It is not certain if the last two keywords (heat, velocity) are ye... |
5,810,551 | the thing I am asking is like this,say I went to webpage but I dont like the font-face they used or the font-size or may be the background color, can I change it from my pc using any local css? In firefox, there is a plugin firebug, using which I can do some changes temporarily, but I want it to remain unless I change ... | 2011/04/27 | [
"https://Stackoverflow.com/questions/5810551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/728115/"
] | yes, I remember an extension for firefox: [greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/).
It's easy to change color and other styles of standard elements, like background, headers (h1, ...), paragraph, ... but I don't know about custom css class that are widely used across web sites. So a... | You could use [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/), and associate a Javascript with every page you want to modify. |
20,209,896 | I want to store Kannada in sql server 2005. I tried to insert via query and baraha direct. that stored as ?????
. Can any one please tell me how i can store Kannada in sql server 2005.
i went through the following link they are telling Kannada is not supporting by default. Is it true?.
<http://msdn.microsoft.com/en-u... | 2013/11/26 | [
"https://Stackoverflow.com/questions/20209896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642633/"
] | `LOAD DATA INFILE` is the fastest.
hello, so you are dumping table by your own program. if loading speed is important. please consider belows:
* ensure that multiple `INSERT INTO .. VALUES (...), (...)`
* Disable INDEX before loading, enable after loading. This is faster.
* `LOAD DATA INFILE` is super faster than mul... | `INSERT` is faster, because you are skip parsing of csv.
If your table at `MyISAM`, you can copy files: `*.frm`, `*.myi`, `*.myd` and this migration will be faster. |
20,209,896 | I want to store Kannada in sql server 2005. I tried to insert via query and baraha direct. that stored as ?????
. Can any one please tell me how i can store Kannada in sql server 2005.
i went through the following link they are telling Kannada is not supporting by default. Is it true?.
<http://msdn.microsoft.com/en-u... | 2013/11/26 | [
"https://Stackoverflow.com/questions/20209896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642633/"
] | `INSERT` is faster, because you are skip parsing of csv.
If your table at `MyISAM`, you can copy files: `*.frm`, `*.myi`, `*.myd` and this migration will be faster. | In my experience, loading a csv is almost always faster with large datasets; it is built for mass loading.
See here for more info
<https://dba.stackexchange.com/questions/16809/why-is-load-data-infile-faster-than-normal-insert-statements> |
20,209,896 | I want to store Kannada in sql server 2005. I tried to insert via query and baraha direct. that stored as ?????
. Can any one please tell me how i can store Kannada in sql server 2005.
i went through the following link they are telling Kannada is not supporting by default. Is it true?.
<http://msdn.microsoft.com/en-u... | 2013/11/26 | [
"https://Stackoverflow.com/questions/20209896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1642633/"
] | `LOAD DATA INFILE` is the fastest.
hello, so you are dumping table by your own program. if loading speed is important. please consider belows:
* ensure that multiple `INSERT INTO .. VALUES (...), (...)`
* Disable INDEX before loading, enable after loading. This is faster.
* `LOAD DATA INFILE` is super faster than mul... | In my experience, loading a csv is almost always faster with large datasets; it is built for mass loading.
See here for more info
<https://dba.stackexchange.com/questions/16809/why-is-load-data-infile-faster-than-normal-insert-statements> |
68,021,844 | I need to create a variable that lists all the existing databases in my system, because I need it and I don't know how to do it. I have tried to create variables like this one:
```
DECLARE @nombreBD INT;
SET @nombreBD = (SELECT [database_id] FROM sys.databases Where name = 'model' )
SELECT @nombreBD AS Database_ID
PRI... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68021844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16253659/"
] | You need to use `Object.defineProperty` function, for make a restriction in descriptor, **enumerable** to **false** and `getter`, `setter` with specific condition, here a complete example:
```js
//A small example of how to make an invisible property in Child class.
class Parent{
constructor(){
this.propertyToKee... | That's not possible. If you declare an attribute in a parent class, you can't restrict his visibility in a child class.
From the model design point of view, that doesn't make sense as well. The problem you are exposing here indicates that your class hierarchy is not well designed and you must rethink and redesign it. |
68,021,844 | I need to create a variable that lists all the existing databases in my system, because I need it and I don't know how to do it. I have tried to create variables like this one:
```
DECLARE @nombreBD INT;
SET @nombreBD = (SELECT [database_id] FROM sys.databases Where name = 'model' )
SELECT @nombreBD AS Database_ID
PRI... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68021844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16253659/"
] | Here is one way to do it:
```js
class Parent {
propertyToKeep = 'hi';
propertyToDelete = 'bye';
constructor() {}
}
class Child extends Parent {
constructor() {
super();
delete this.propertyToDelete;
}
}
const myObject = new Child();
console.log(myObject);
/* OUTPUT:
{
"propertyToKeep": "hi"
... | That's not possible. If you declare an attribute in a parent class, you can't restrict his visibility in a child class.
From the model design point of view, that doesn't make sense as well. The problem you are exposing here indicates that your class hierarchy is not well designed and you must rethink and redesign it. |
68,021,844 | I need to create a variable that lists all the existing databases in my system, because I need it and I don't know how to do it. I have tried to create variables like this one:
```
DECLARE @nombreBD INT;
SET @nombreBD = (SELECT [database_id] FROM sys.databases Where name = 'model' )
SELECT @nombreBD AS Database_ID
PRI... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68021844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16253659/"
] | I just came across the same use case as you and here's how I did it:
```
const Omit = <T, K extends keyof T>(Class: new () => T, keys: K[]): new () => Omit<T, typeof keys[number]> => Class;
```
Then you can use it like so :
```
class Child extends Omit(Parent, ['propertyToDelete']), {}
```
[As you can see child o... | That's not possible. If you declare an attribute in a parent class, you can't restrict his visibility in a child class.
From the model design point of view, that doesn't make sense as well. The problem you are exposing here indicates that your class hierarchy is not well designed and you must rethink and redesign it. |
68,021,844 | I need to create a variable that lists all the existing databases in my system, because I need it and I don't know how to do it. I have tried to create variables like this one:
```
DECLARE @nombreBD INT;
SET @nombreBD = (SELECT [database_id] FROM sys.databases Where name = 'model' )
SELECT @nombreBD AS Database_ID
PRI... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68021844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16253659/"
] | Here is one way to do it:
```js
class Parent {
propertyToKeep = 'hi';
propertyToDelete = 'bye';
constructor() {}
}
class Child extends Parent {
constructor() {
super();
delete this.propertyToDelete;
}
}
const myObject = new Child();
console.log(myObject);
/* OUTPUT:
{
"propertyToKeep": "hi"
... | You need to use `Object.defineProperty` function, for make a restriction in descriptor, **enumerable** to **false** and `getter`, `setter` with specific condition, here a complete example:
```js
//A small example of how to make an invisible property in Child class.
class Parent{
constructor(){
this.propertyToKee... |
68,021,844 | I need to create a variable that lists all the existing databases in my system, because I need it and I don't know how to do it. I have tried to create variables like this one:
```
DECLARE @nombreBD INT;
SET @nombreBD = (SELECT [database_id] FROM sys.databases Where name = 'model' )
SELECT @nombreBD AS Database_ID
PRI... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68021844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16253659/"
] | I just came across the same use case as you and here's how I did it:
```
const Omit = <T, K extends keyof T>(Class: new () => T, keys: K[]): new () => Omit<T, typeof keys[number]> => Class;
```
Then you can use it like so :
```
class Child extends Omit(Parent, ['propertyToDelete']), {}
```
[As you can see child o... | You need to use `Object.defineProperty` function, for make a restriction in descriptor, **enumerable** to **false** and `getter`, `setter` with specific condition, here a complete example:
```js
//A small example of how to make an invisible property in Child class.
class Parent{
constructor(){
this.propertyToKee... |
68,021,844 | I need to create a variable that lists all the existing databases in my system, because I need it and I don't know how to do it. I have tried to create variables like this one:
```
DECLARE @nombreBD INT;
SET @nombreBD = (SELECT [database_id] FROM sys.databases Where name = 'model' )
SELECT @nombreBD AS Database_ID
PRI... | 2021/06/17 | [
"https://Stackoverflow.com/questions/68021844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16253659/"
] | I just came across the same use case as you and here's how I did it:
```
const Omit = <T, K extends keyof T>(Class: new () => T, keys: K[]): new () => Omit<T, typeof keys[number]> => Class;
```
Then you can use it like so :
```
class Child extends Omit(Parent, ['propertyToDelete']), {}
```
[As you can see child o... | Here is one way to do it:
```js
class Parent {
propertyToKeep = 'hi';
propertyToDelete = 'bye';
constructor() {}
}
class Child extends Parent {
constructor() {
super();
delete this.propertyToDelete;
}
}
const myObject = new Child();
console.log(myObject);
/* OUTPUT:
{
"propertyToKeep": "hi"
... |
15,195,764 | I have a folder `/image/` that has the following files:
`1.jpg, 2.jpg, 5.jpg`
And a list:
```
img = [1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg]
```
How do I compare the list and the directory contents to find out that `3.jpg` and `4.jpg` files are missing?
I searched online but the only solutions I found show how to comp... | 2013/03/04 | [
"https://Stackoverflow.com/questions/15195764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2024445/"
] | ```
import os
path= r"C:\yourdirectory"
fileList = os.listdir(path)
img = [...]
missing = [name for name in img if name not in fileList]
```
If order is not important you can use sets instead
```
import os
path= r"C:\yourdirectory"
fileSet = set(os.listdir(path))
img = [...]
missing = set(img)-fileSet
``` | What about this .
Get all file extension first from a file
```
import os
createlist = []
for r,d,f in os.walk("/images"):
for files in f:
if files.endswith(".jpg"):
createlist.append[files]
```
And then compare both list like.
```
print [(i,j) for i,j in zip(img,createlist) if i!=j]
``` |
15,195,764 | I have a folder `/image/` that has the following files:
`1.jpg, 2.jpg, 5.jpg`
And a list:
```
img = [1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg]
```
How do I compare the list and the directory contents to find out that `3.jpg` and `4.jpg` files are missing?
I searched online but the only solutions I found show how to comp... | 2013/03/04 | [
"https://Stackoverflow.com/questions/15195764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2024445/"
] | To search for files in a directory, you can use [`glob`](http://docs.python.org/2/library/glob.html), like this:
```
import glob
dir_to_search = '/some/path/to/images/'
files_in_dir = glob.glob("{}{}".format(dir_to_search,'*.jpg'))
list_of_files = ['1.jpg','2.jpg','3.jpg']
missing_files = [x for x in list_of_files... | ```
import os
path= r"C:\yourdirectory"
fileList = os.listdir(path)
img = [...]
missing = [name for name in img if name not in fileList]
```
If order is not important you can use sets instead
```
import os
path= r"C:\yourdirectory"
fileSet = set(os.listdir(path))
img = [...]
missing = set(img)-fileSet
``` |
15,195,764 | I have a folder `/image/` that has the following files:
`1.jpg, 2.jpg, 5.jpg`
And a list:
```
img = [1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg]
```
How do I compare the list and the directory contents to find out that `3.jpg` and `4.jpg` files are missing?
I searched online but the only solutions I found show how to comp... | 2013/03/04 | [
"https://Stackoverflow.com/questions/15195764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2024445/"
] | To search for files in a directory, you can use [`glob`](http://docs.python.org/2/library/glob.html), like this:
```
import glob
dir_to_search = '/some/path/to/images/'
files_in_dir = glob.glob("{}{}".format(dir_to_search,'*.jpg'))
list_of_files = ['1.jpg','2.jpg','3.jpg']
missing_files = [x for x in list_of_files... | What about this .
Get all file extension first from a file
```
import os
createlist = []
for r,d,f in os.walk("/images"):
for files in f:
if files.endswith(".jpg"):
createlist.append[files]
```
And then compare both list like.
```
print [(i,j) for i,j in zip(img,createlist) if i!=j]
``` |
6,806,034 | I have a function f(x,y) of two variables, of which I need to know the location of the curves at which it crosses zero. ContourPlot does that very efficiently (that is: it uses clever multi-grid methods, not just a brute force fine-grained scan) but just gives me a plot. I would like to have a set of values {x,y} (with... | 2011/07/24 | [
"https://Stackoverflow.com/questions/6806034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/120751/"
] | If you end up extracting points from `ContourPlot`, this is one easy way to do it:
```
points = Cases[
Normal@ContourPlot[Sin[x] Sin[y] == 1/2, {x, -3, 3}, {y, -3, 3}],
Line[pts_] -> pts,
Infinity
]
Join @@ points (* if you don't want disjoint components to be separate *)
```
**EDIT**
It appears that `Conto... | A slight variation for extracting points from `ContourPlot` (possibly due to David Park):
```
pts = Cases[
ContourPlot[Cos[x] + Cos[y] == 1/2, {x, 0, 4 Pi}, {y, 0, 4 Pi}],
x_GraphicsComplex :> First@x, Infinity];
```
or (as a list of {x,y} points)
```
ptsXY = Cases[
Cases[ContourPlot[
Cos[x] + Cos[y... |
42,691,631 | I have few tables in my database and I want to count total rows of all those tables based on AppoitmentID for which I use a scalar cursor and a table variable to store some data of those tables based on AppoitmentID. After the end of cursor I count rows of table variable in which I had inserted data using dynamic query... | 2017/03/09 | [
"https://Stackoverflow.com/questions/42691631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1309558/"
] | C++17's fold-expressions make this a breeze:
```
template <class... Points>
point barycentre(Points... points) {
point const sum{
(points.x_ + ...),
(points.y_ + ...)
};
int const num = sizeof...(Points);
return {
sum.x_ / num,
sum.y_ / num
};
}
```
[See it live ... | Initializer list is simpler for taking elements of the same type.
```
Point average(std::initializer_list<Point> list)
{
int x = 0, y = 0;
for(auto &i: list) {x += i.x_; y += i.y_;}
return {x / list.size(), y / list.size()};
}
```
Variadic templates is generic on **types**, so it doesn't fit for your cas... |
42,691,631 | I have few tables in my database and I want to count total rows of all those tables based on AppoitmentID for which I use a scalar cursor and a table variable to store some data of those tables based on AppoitmentID. After the end of cursor I count rows of table variable in which I had inserted data using dynamic query... | 2017/03/09 | [
"https://Stackoverflow.com/questions/42691631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1309558/"
] | If you are using C++14 you could simply iterate through points in constexpr function, e.g. like this (example borrowed from [Quentin's answer](https://stackoverflow.com/a/42692165/4324224)):
```
#include <iostream>
struct point{
int x_, y_;
};
template <class... Points>
constexpr point barycentre(Points... point... | Initializer list is simpler for taking elements of the same type.
```
Point average(std::initializer_list<Point> list)
{
int x = 0, y = 0;
for(auto &i: list) {x += i.x_; y += i.y_;}
return {x / list.size(), y / list.size()};
}
```
Variadic templates is generic on **types**, so it doesn't fit for your cas... |
37,947,054 | Every time I try to run this code I get this error:
'Runtime error 1004: Application defined or Object defined error'
It specifically is not liking the "Find" Function, with out it, it runs fine.
My Code looks like this:
```
Public Sub main()
Dim maxVal As Long
Dim origValue As Long
Dim CaseNumber As Lon... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37947054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6216934/"
] | `Set FoundCell = Sheets("Complications").Cells.Range("A1:A50000").Find(What:=CaseNumber)`
You just typed the range incorrectly. | being Bruce Wayne the answer to your question, the following may help you to avoid possible future problems:
```
Public Sub main()
Dim maxVal As Long
Dim origValue As Long
Dim FoundCell As Range
With Worksheets("Complications") '<--| reference this sheet once and for all and rest assure you're dealing... |
4,751,791 | I am using the public api of class DownloadManager, I am able to download files to sdcard, so-called external storage. However, when I tried to download a file to other places, like /cache partition, it throw a security exception which says "Destination must be on external storage".
Does anyone know how to bypass this... | 2011/01/20 | [
"https://Stackoverflow.com/questions/4751791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/455544/"
] | If you're developing a system app, there is a hidden function on DownloadManager.Request named setDestinationToSystemCache()
It requires these permissions:
```
android.permission.ACCESS_DOWNLOAD_MANAGER
android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED"
android.permission.ACCESS_CACHE_FILESYSTEM
``` | Actually I found a way to download files to /cache partition.
In the DownloadManager class, there is an api
setDestinationUri(), call this function with parameter "null", the android would download files to /cache partition. Moreover, if the parameter is not null, the uri must start with "/mnt/sdcard/..." otherwise an... |
52,065,029 | Today, I wanna to scan some QR codes using C#. Because, why no?
So, I am using Emgu (package from NuGet), and when I am trying to save image, I receive this error.
```
System.Runtime.InteropServices.ExternalException: 'A generic error occurred in GDI+.'
```
This is code I am using:
```
Capture capture = new Capture... | 2018/08/28 | [
"https://Stackoverflow.com/questions/52065029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10286560/"
] | Ran across this and found that my issue was resolved by specifying a format in the save:
```
bmpImage.Save(filename,System.Drawing.Imaging.ImageFormat.Png);
``` | Fix some path error:
```
string path = Path.Combine(baseDirectory, "img" + i.ToString() + ".jpg");
``` |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> I know that CSS used to style HTML docs, but is that the only way ?
>
>
>
It is the only sensible way
>
> Can I use JavaScript to style HTML, somehow ?
>
>
>
You can generate CSS with JavaScript. (Not advisable for general styling).
You can use [JSSS](http://en.wikipedia.org/wiki/JavaScript_Style_Sheet... | You're also able to style HTML with HTML-attributes itself, but this way is pretty impractical and old-fashioned. Most of these techniques are deprecated and the functionality is VERY limited. |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | JavaScript is a scripting language, not a styling language. While you can use JavaScript to apply CSS, it's still CSS, not JavaScript, that's defining the styles.
There exist HTML presentational attributes from [a long time ago](http://www.w3.org/TR/REC-html32), but those have been superseded by CSS. You can still use... | As mentioned previously, CSS is not the only way to stylize HTML but definitely the standard. If you're looking for a more programmatic way utilizing JavaScript you can look into [less](http://lesscss.org/) which (taken directly from the webpage) ...extends CSS with dynamic behavior such as variables, mixins, operation... |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> I know that CSS used to style HTML docs, but is that the only way ?
>
>
>
It is the only sensible way
>
> Can I use JavaScript to style HTML, somehow ?
>
>
>
You can generate CSS with JavaScript. (Not advisable for general styling).
You can use [JSSS](http://en.wikipedia.org/wiki/JavaScript_Style_Sheet... | I suppose the correct answer to your question is no, because html includes some basic style elements itself. But CSS is the best way to style your documents and you absolutely should learn and use it. Once you're comfortable using CSS, try using a framework such as [Twitter bootstrap](http://twitter.github.com/bootstra... |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> I know that CSS used to style HTML docs, but is that the only way ?
>
>
>
It is the only sensible way
>
> Can I use JavaScript to style HTML, somehow ?
>
>
>
You can generate CSS with JavaScript. (Not advisable for general styling).
You can use [JSSS](http://en.wikipedia.org/wiki/JavaScript_Style_Sheet... | It's not the only way but the recommended way.
You can include styling in your html tags but it becomes messy.
That's why CSS was invented so use it ! |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It's not the only way but the recommended way.
You can include styling in your html tags but it becomes messy.
That's why CSS was invented so use it ! | As mentioned previously, CSS is not the only way to stylize HTML but definitely the standard. If you're looking for a more programmatic way utilizing JavaScript you can look into [less](http://lesscss.org/) which (taken directly from the webpage) ...extends CSS with dynamic behavior such as variables, mixins, operation... |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You're also able to style HTML with HTML-attributes itself, but this way is pretty impractical and old-fashioned. Most of these techniques are deprecated and the functionality is VERY limited. | As mentioned previously, CSS is not the only way to stylize HTML but definitely the standard. If you're looking for a more programmatic way utilizing JavaScript you can look into [less](http://lesscss.org/) which (taken directly from the webpage) ...extends CSS with dynamic behavior such as variables, mixins, operation... |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | JavaScript is a scripting language, not a styling language. While you can use JavaScript to apply CSS, it's still CSS, not JavaScript, that's defining the styles.
There exist HTML presentational attributes from [a long time ago](http://www.w3.org/TR/REC-html32), but those have been superseded by CSS. You can still use... | You're also able to style HTML with HTML-attributes itself, but this way is pretty impractical and old-fashioned. Most of these techniques are deprecated and the functionality is VERY limited. |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | JavaScript is a scripting language, not a styling language. While you can use JavaScript to apply CSS, it's still CSS, not JavaScript, that's defining the styles.
There exist HTML presentational attributes from [a long time ago](http://www.w3.org/TR/REC-html32), but those have been superseded by CSS. You can still use... | I suppose the correct answer to your question is no, because html includes some basic style elements itself. But CSS is the best way to style your documents and you absolutely should learn and use it. Once you're comfortable using CSS, try using a framework such as [Twitter bootstrap](http://twitter.github.com/bootstra... |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | JavaScript is a scripting language, not a styling language. While you can use JavaScript to apply CSS, it's still CSS, not JavaScript, that's defining the styles.
There exist HTML presentational attributes from [a long time ago](http://www.w3.org/TR/REC-html32), but those have been superseded by CSS. You can still use... | >
> I know that CSS used to style HTML docs, but is that the only way ?
>
>
>
It is the only sensible way
>
> Can I use JavaScript to style HTML, somehow ?
>
>
>
You can generate CSS with JavaScript. (Not advisable for general styling).
You can use [JSSS](http://en.wikipedia.org/wiki/JavaScript_Style_Sheet... |
14,692,027 | I am a beginner web-designer. I know the basics of HTML, CSS and Javascript. I know that CSS used to style HTML docs, but is that the only way ? Can I use JavaScript to style HTML, somehow ? Or Is there any other way rather than CSS ? | 2013/02/04 | [
"https://Stackoverflow.com/questions/14692027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | JavaScript is a scripting language, not a styling language. While you can use JavaScript to apply CSS, it's still CSS, not JavaScript, that's defining the styles.
There exist HTML presentational attributes from [a long time ago](http://www.w3.org/TR/REC-html32), but those have been superseded by CSS. You can still use... | It's not the only way but the recommended way.
You can include styling in your html tags but it becomes messy.
That's why CSS was invented so use it ! |
3,557,369 | In our project we use Eclipse launch configurations which are under version control to be shared with all developers. Now it is necessary to include an external archive to a launch configuration file's classpath. Fortunately the required archive is in every developer's local Maven repository.
I already found out that ... | 2010/08/24 | [
"https://Stackoverflow.com/questions/3557369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428477/"
] | Edit your launch configuration.
Go to the "classpath" tab.
Focus on "User Entries".
Click the "Advanced" button.
* To add an entry based on a *classpath variable*, select *Add classpath variable* and click OK. A dialog will open. Focus on `M2_REPO` and click the "Extend" button. Select your JAR file.
* To add an entry... | You could load that value from [maven properties](http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide).
Maven stores repository path in `maven.repo.local` property.
Place `${maven.repo.local}` into your configuration file.
```
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
...
<listEnt... |
12,698,909 | I want to add a class to a **link\_to** only if a statement is true.
```
<%= link_to product.name, product, :class => "last" if product == @products.last %>
```
The problem that the IF statement affects the whole line and not just the **:class** part.
I know i can get it done with IF ELSE, but is it possible to do ... | 2012/10/02 | [
"https://Stackoverflow.com/questions/12698909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/717559/"
] | ```
<%= link_to product.name, product, :class => (product == @products.last ? "last" : "") %>
``` | Well you could abstract this away in a helper:
```
def product_link(product)
if product == @products.last
link_to product.name, product, :class => "last"
else
link_to product.name, product
end
end
```
Then in your view you can just do `product_link(product)`.
**Update**: or in a more compact way:
```... |
39,243,803 | First, I'm very new in ReactJS. I've done simple reactjs project based on following link. <http://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm> and I can run and test perfectly by running "`npm start`". But when I'm trying to integrate with expressJs as edit/developed as follow coding, I cannot render a... | 2016/08/31 | [
"https://Stackoverflow.com/questions/39243803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2555911/"
] | Another simple mistake for new Unity users. Spelling counts! Simply replace `onCollisionEnter` with `OnCollisionEnter`. The callback functions are case sensitive and their first letter is usually **capitalized**.
If changing this does not work, attach Rigidbody to your enemy too. Make sure they both have Colliders at... | Several solutions could fit. Maybe you simply forgot to set the tag on your enemy?
Please have a look at the Unity3D collision matrix (<https://docs.unity3d.com/Manual/CollidersOverview.html> - at the bottom of the page).
The collision matrix tells you when you will get collision messages. E.g. you can't have a stati... |
55,586,832 | I have an input text box which use ngModel bind to a variable inside the component class. Upon clicking a button I want to clear the input text, however changing the variable value doesn't change the input text.
I have re-assign the variable and call detectChanges() from ChangeDetectorRef, but it still doesn't work.
... | 2019/04/09 | [
"https://Stackoverflow.com/questions/55586832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3794740/"
] | It should be `[(ngModel)]="inputValue"` if you want two-way data binding. `[ngModel]` works fine for one-way data binding.
Try changing the code as:
```
<form #beaconForm="ngForm" autocomplete="off">
<input #searchBox id="search-query" name="search-query"
\/\/
[(ngModel)]="inputV... | >
> Try this.
>
>
>
```
[(ngModel)]={{inputValue}}
``` |
55,586,832 | I have an input text box which use ngModel bind to a variable inside the component class. Upon clicking a button I want to clear the input text, however changing the variable value doesn't change the input text.
I have re-assign the variable and call detectChanges() from ChangeDetectorRef, but it still doesn't work.
... | 2019/04/09 | [
"https://Stackoverflow.com/questions/55586832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3794740/"
] | It should be `[(ngModel)]="inputValue"` if you want two-way data binding. `[ngModel]` works fine for one-way data binding.
Try changing the code as:
```
<form #beaconForm="ngForm" autocomplete="off">
<input #searchBox id="search-query" name="search-query"
\/\/
[(ngModel)]="inputV... | See the following working version:
<https://stackblitz.com/edit/angular-cqpqjj>
ts
```
inputValue: string = "";
action(value) {
this.inputValue = "";
}
```
html
```
<form #beaconForm="ngForm" autocomplete="off">
<input #searchBox
id="search-query"
name="search-q... |
55,586,832 | I have an input text box which use ngModel bind to a variable inside the component class. Upon clicking a button I want to clear the input text, however changing the variable value doesn't change the input text.
I have re-assign the variable and call detectChanges() from ChangeDetectorRef, but it still doesn't work.
... | 2019/04/09 | [
"https://Stackoverflow.com/questions/55586832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3794740/"
] | It should be `[(ngModel)]="inputValue"` if you want two-way data binding. `[ngModel]` works fine for one-way data binding.
Try changing the code as:
```
<form #beaconForm="ngForm" autocomplete="off">
<input #searchBox id="search-query" name="search-query"
\/\/
[(ngModel)]="inputV... | After your comment I understand, why your doesn't work with one way binding.
Lets start with `inputValue = 1111`
On button click, which triggers `action()` method call, we set `inputValue` to `''`. Now whenever we change value in the input box directly, the value of the `inputValue` variable doesn't change since its ... |
55,586,832 | I have an input text box which use ngModel bind to a variable inside the component class. Upon clicking a button I want to clear the input text, however changing the variable value doesn't change the input text.
I have re-assign the variable and call detectChanges() from ChangeDetectorRef, but it still doesn't work.
... | 2019/04/09 | [
"https://Stackoverflow.com/questions/55586832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3794740/"
] | See the following working version:
<https://stackblitz.com/edit/angular-cqpqjj>
ts
```
inputValue: string = "";
action(value) {
this.inputValue = "";
}
```
html
```
<form #beaconForm="ngForm" autocomplete="off">
<input #searchBox
id="search-query"
name="search-q... | >
> Try this.
>
>
>
```
[(ngModel)]={{inputValue}}
``` |
55,586,832 | I have an input text box which use ngModel bind to a variable inside the component class. Upon clicking a button I want to clear the input text, however changing the variable value doesn't change the input text.
I have re-assign the variable and call detectChanges() from ChangeDetectorRef, but it still doesn't work.
... | 2019/04/09 | [
"https://Stackoverflow.com/questions/55586832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3794740/"
] | After your comment I understand, why your doesn't work with one way binding.
Lets start with `inputValue = 1111`
On button click, which triggers `action()` method call, we set `inputValue` to `''`. Now whenever we change value in the input box directly, the value of the `inputValue` variable doesn't change since its ... | >
> Try this.
>
>
>
```
[(ngModel)]={{inputValue}}
``` |
55,586,832 | I have an input text box which use ngModel bind to a variable inside the component class. Upon clicking a button I want to clear the input text, however changing the variable value doesn't change the input text.
I have re-assign the variable and call detectChanges() from ChangeDetectorRef, but it still doesn't work.
... | 2019/04/09 | [
"https://Stackoverflow.com/questions/55586832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3794740/"
] | After your comment I understand, why your doesn't work with one way binding.
Lets start with `inputValue = 1111`
On button click, which triggers `action()` method call, we set `inputValue` to `''`. Now whenever we change value in the input box directly, the value of the `inputValue` variable doesn't change since its ... | See the following working version:
<https://stackblitz.com/edit/angular-cqpqjj>
ts
```
inputValue: string = "";
action(value) {
this.inputValue = "";
}
```
html
```
<form #beaconForm="ngForm" autocomplete="off">
<input #searchBox
id="search-query"
name="search-q... |
29,332,270 | I am trying to utilize the [Bitcoin Charts API](http://api.bitcoincharts.com/v1/markets.json) to display bitcoin value in all currencies as list items.
Currently I am repeating this PHP snippet in each list item:
```
<li class="myClass">
<?php
foreach(json_decode(file_get_contents("http://api.bitcoinchart... | 2015/03/29 | [
"https://Stackoverflow.com/questions/29332270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1054754/"
] | With the new CRUD API in the 3.0.0 Java driver, the proper way to do it is with the projection method that is chained off off MongoCollection.find(). Since the projection method takes an instance of the Bson interface, there are a number of different classes you can use to specify the projection:
```
// using Basi... | Have a look at the implementation of [**DBCollection**](http://api.mongodb.org/java/3.0/com/mongodb/DBCollection.html#find-com.mongodb.DBObject-com.mongodb.DBObject-) [**`find()`**](http://api.mongodb.org/java/2.7.2/com/mongodb/DBCollection.html#find%28com.mongodb.DBObject,%20com.mongodb.DBObject%29). The following ret... |
29,332,270 | I am trying to utilize the [Bitcoin Charts API](http://api.bitcoincharts.com/v1/markets.json) to display bitcoin value in all currencies as list items.
Currently I am repeating this PHP snippet in each list item:
```
<li class="myClass">
<?php
foreach(json_decode(file_get_contents("http://api.bitcoinchart... | 2015/03/29 | [
"https://Stackoverflow.com/questions/29332270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1054754/"
] | With the new CRUD API in the 3.0.0 Java driver, the proper way to do it is with the projection method that is chained off off MongoCollection.find(). Since the projection method takes an instance of the Bson interface, there are a number of different classes you can use to specify the projection:
```
// using Basi... | `collection
.find(new Document(...).append(...))
.projection(new Document(...).append(...))`
This will give you a `FindIterable` and then you can iterate through as you would `DBCursor`. |
44,477,376 | Div block hasn't free space for buttons in one line
I have a block with a buttons, the buttons look good when 1920x1080 px but how to make adaptive buttons for 1080x720 and mobile platforms? Adaptive buttons will work in wordpress?
```css
.main_button_left {
color: white;
text-decoration: none;
padding: 12px... | 2017/06/10 | [
"https://Stackoverflow.com/questions/44477376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8078041/"
] | You can use a flexbox for the buttons and set a minimum width. With media queries you can present them in a different way, depending on your requirements. When stacked, set the minimum width to 100%.
```css
button {
color: white;
background: #ff6500;
border-color: #ff6500;
font-size: 15px;
text-decorati... | On small screen you can stack buttons vertically, or hide a menu and create a button, thats will show buttons. |
37,315,266 | I'm having no luck getting a response from v4 of the Google Sheets API when running against a public (i.e. "Published To The Web" AND shared with "Anyone On The Web") spreadsheet.
The relevant documentation states:
"If the request doesn't require authorization (***such as a request for public data***), then the appli... | 2016/05/19 | [
"https://Stackoverflow.com/questions/37315266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6354407/"
] | I managed to get this working. Even I was frustrated at first. And, this is not a bug. Here's how I did it:
1. First, enable these in your GDC to get rid of authentication errors.
-Google Apps Script Execution API
-Google Sheets API
**Note**: Make sure the Google account you used in GDC must be the same account you... | We recently fixed this and it should now be working. Sorry for the troubles, please try again.
The document must be shared to "Anyone with the link" or "Public on the web". (Note: the publishing settings from "File -> Publish to the web" are irrelevant, unlike in the v3 API.) |
37,315,266 | I'm having no luck getting a response from v4 of the Google Sheets API when running against a public (i.e. "Published To The Web" AND shared with "Anyone On The Web") spreadsheet.
The relevant documentation states:
"If the request doesn't require authorization (***such as a request for public data***), then the appli... | 2016/05/19 | [
"https://Stackoverflow.com/questions/37315266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6354407/"
] | We recently fixed this and it should now be working. Sorry for the troubles, please try again.
The document must be shared to "Anyone with the link" or "Public on the web". (Note: the publishing settings from "File -> Publish to the web" are irrelevant, unlike in the v3 API.) | This is not a solution of the problem but I think this is a good way to achieve the goal. On site <http://embedded-lab.com/blog/post-data-google-sheets-using-esp8266/> I found how to update spreadsheet using Google Apps Script. This is an example with GET method. I will try to show you POST method with JSON format.
Ho... |
37,315,266 | I'm having no luck getting a response from v4 of the Google Sheets API when running against a public (i.e. "Published To The Web" AND shared with "Anyone On The Web") spreadsheet.
The relevant documentation states:
"If the request doesn't require authorization (***such as a request for public data***), then the appli... | 2016/05/19 | [
"https://Stackoverflow.com/questions/37315266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6354407/"
] | We recently fixed this and it should now be working. Sorry for the troubles, please try again.
The document must be shared to "Anyone with the link" or "Public on the web". (Note: the publishing settings from "File -> Publish to the web" are irrelevant, unlike in the v3 API.) | If your feed is public and you are using api key, make sure you are throwing a http GET request.In case of POST request, you will receive this error.
I faced same.
Getting data using
Method: spreadsheets.getByDataFilter has POST request |
37,315,266 | I'm having no luck getting a response from v4 of the Google Sheets API when running against a public (i.e. "Published To The Web" AND shared with "Anyone On The Web") spreadsheet.
The relevant documentation states:
"If the request doesn't require authorization (***such as a request for public data***), then the appli... | 2016/05/19 | [
"https://Stackoverflow.com/questions/37315266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6354407/"
] | I managed to get this working. Even I was frustrated at first. And, this is not a bug. Here's how I did it:
1. First, enable these in your GDC to get rid of authentication errors.
-Google Apps Script Execution API
-Google Sheets API
**Note**: Make sure the Google account you used in GDC must be the same account you... | This is not a solution of the problem but I think this is a good way to achieve the goal. On site <http://embedded-lab.com/blog/post-data-google-sheets-using-esp8266/> I found how to update spreadsheet using Google Apps Script. This is an example with GET method. I will try to show you POST method with JSON format.
Ho... |
37,315,266 | I'm having no luck getting a response from v4 of the Google Sheets API when running against a public (i.e. "Published To The Web" AND shared with "Anyone On The Web") spreadsheet.
The relevant documentation states:
"If the request doesn't require authorization (***such as a request for public data***), then the appli... | 2016/05/19 | [
"https://Stackoverflow.com/questions/37315266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6354407/"
] | I managed to get this working. Even I was frustrated at first. And, this is not a bug. Here's how I did it:
1. First, enable these in your GDC to get rid of authentication errors.
-Google Apps Script Execution API
-Google Sheets API
**Note**: Make sure the Google account you used in GDC must be the same account you... | If your feed is public and you are using api key, make sure you are throwing a http GET request.In case of POST request, you will receive this error.
I faced same.
Getting data using
Method: spreadsheets.getByDataFilter has POST request |
37,315,266 | I'm having no luck getting a response from v4 of the Google Sheets API when running against a public (i.e. "Published To The Web" AND shared with "Anyone On The Web") spreadsheet.
The relevant documentation states:
"If the request doesn't require authorization (***such as a request for public data***), then the appli... | 2016/05/19 | [
"https://Stackoverflow.com/questions/37315266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6354407/"
] | This is not a solution of the problem but I think this is a good way to achieve the goal. On site <http://embedded-lab.com/blog/post-data-google-sheets-using-esp8266/> I found how to update spreadsheet using Google Apps Script. This is an example with GET method. I will try to show you POST method with JSON format.
Ho... | If your feed is public and you are using api key, make sure you are throwing a http GET request.In case of POST request, you will receive this error.
I faced same.
Getting data using
Method: spreadsheets.getByDataFilter has POST request |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | It's 1 or -1 with 50/50 chance.
An equivalent C# code would be:
```
((new Random().Next(0, 2)) == 0) ? 1.0 : -1.0;
```
`Next(0,2)` will return either 0 or 1.
If the code gets called a lot you should store the instance of `Random` and re-use it. When you create a new instance of `Random` it gets initialized with a... | Either 1.0 or -1.0 with equal chance of either one
rand() generates a number witch is anded with 0x01 i.e. the first bit and depending on if you get a bit or not you get 1.0 or -1.0 |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | It's 1 or -1 with 50/50 chance.
An equivalent C# code would be:
```
((new Random().Next(0, 2)) == 0) ? 1.0 : -1.0;
```
`Next(0,2)` will return either 0 or 1.
If the code gets called a lot you should store the instance of `Random` and re-use it. When you create a new instance of `Random` it gets initialized with a... | You can just randomize with 50% chance, as others said.
If you want an exact translation, it would be:
```
((new Random().Next() & 1 > 0) ? 1.0 : -1.0)
```
You have to make a boolean out of the first part of conditional expression. |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | It's 1 or -1 with 50/50 chance.
An equivalent C# code would be:
```
((new Random().Next(0, 2)) == 0) ? 1.0 : -1.0;
```
`Next(0,2)` will return either 0 or 1.
If the code gets called a lot you should store the instance of `Random` and re-use it. When you create a new instance of `Random` it gets initialized with a... | You may use
```
Random rnd = new Random();
(rnd.NextInt(2) * 2 -1); // 1 or -1
``` |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | Either 1.0 or -1.0 with equal chance of either one
rand() generates a number witch is anded with 0x01 i.e. the first bit and depending on if you get a bit or not you get 1.0 or -1.0 | You can just randomize with 50% chance, as others said.
If you want an exact translation, it would be:
```
((new Random().Next() & 1 > 0) ? 1.0 : -1.0)
```
You have to make a boolean out of the first part of conditional expression. |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | You may use
```
Random rnd = new Random();
(rnd.NextInt(2) * 2 -1); // 1 or -1
``` | Either 1.0 or -1.0 with equal chance of either one
rand() generates a number witch is anded with 0x01 i.e. the first bit and depending on if you get a bit or not you get 1.0 or -1.0 |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | The C++ sample generates a random number, uses its lowest bit and throws away the rest. The lowest bit is then used to pick either -1 or 1.
In C#, the equivalent is as follows.
```
new Random().Next(0, 2) * 2 - 1
```
**Important**: If you do this in a loop, store the instance of `Random` somewhere and only call `Ne... | Either 1.0 or -1.0 with equal chance of either one
rand() generates a number witch is anded with 0x01 i.e. the first bit and depending on if you get a bit or not you get 1.0 or -1.0 |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | You may use
```
Random rnd = new Random();
(rnd.NextInt(2) * 2 -1); // 1 or -1
``` | You can just randomize with 50% chance, as others said.
If you want an exact translation, it would be:
```
((new Random().Next() & 1 > 0) ? 1.0 : -1.0)
```
You have to make a boolean out of the first part of conditional expression. |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | The C++ sample generates a random number, uses its lowest bit and throws away the rest. The lowest bit is then used to pick either -1 or 1.
In C#, the equivalent is as follows.
```
new Random().Next(0, 2) * 2 - 1
```
**Important**: If you do this in a loop, store the instance of `Random` somewhere and only call `Ne... | You can just randomize with 50% chance, as others said.
If you want an exact translation, it would be:
```
((new Random().Next() & 1 > 0) ? 1.0 : -1.0)
```
You have to make a boolean out of the first part of conditional expression. |
13,001,143 | Trying to convert some code, but for all my googling I can't figure out how to convert this bit.
```
float fR = fHatRandom(fRadius);
float fQ = fLineRandom(fAngularSpread ) * (rand()&1 ? 1.0 : -1.0);
float fK = 1;
```
This bit
```
(rand()&1 ? 1.0 : -1.0);
```
I can't figure out. | 2012/10/21 | [
"https://Stackoverflow.com/questions/13001143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1188183/"
] | The C++ sample generates a random number, uses its lowest bit and throws away the rest. The lowest bit is then used to pick either -1 or 1.
In C#, the equivalent is as follows.
```
new Random().Next(0, 2) * 2 - 1
```
**Important**: If you do this in a loop, store the instance of `Random` somewhere and only call `Ne... | You may use
```
Random rnd = new Random();
(rnd.NextInt(2) * 2 -1); // 1 or -1
``` |
60,668,763 | I am trying to pass on an argument to a function, which is a string but must be evaluated both for it's name (symbol?) and it's value (see example below). So far I am able to use `base::get` to get the actual value, but the assignment in `flowCore::'transform,flowSet-method'` fails.
I am aware that many questions on SO... | 2020/03/13 | [
"https://Stackoverflow.com/questions/60668763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1654947/"
] | One possible way using `rlang` expression arithmetic:
```
# Compose the expression `Time = Time - min(Time)`
tfarg <- rlang::exprs( !!timeSym := !!timeSym - min(!!timeSym) )
# Compose the expression `flowCore::transform(Bcells, Time = Time - min(Time))`
xpr <- rlang::expr( flowCore::transform(Bcells, !!!tfarg) )
xpr... | It looks like this function basically mimics `base::transform` and its non-standard evaluation. That means I can use this as a MRE:
```
expectedresult <- transform(airquality, Ozone = Ozone - min(Ozone))
```
First we rewrite this using `do.call`:
```
all.equal(
do.call(transform, list(`_data` = airquality, Ozone ... |
48,044,232 | [Example Link](https://codepen.io/1eddy87/pen/MrmZOq/)
I'm trying to loop through an object with nested objects inside so that I can use the values.
The object can be found in my state within the code area below.I need to use the the following so that I can use it in my card as shown below within `render()`
I used `... | 2017/12/31 | [
"https://Stackoverflow.com/questions/48044232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Slicing is *syntax*, not a string. See the [*Slicings* expressions reference documentation](https://docs.python.org/3/reference/expressions.html#slicings):
>
> The semantics for a slicing are as follows. The primary is indexed (using the same `__getitem__()` method as normal subscription) with a key that is construct... | You should use a list of `slice` instances (or tuples thereof), not strings.
Here's an example.
```
>>> import numpy as np
>>>
>>> listofindexvalues = [(slice(1, 6), slice(3, 4))]
>>> a = np.arange(100).reshape(10,10)
>>> a[listofindexvalues[0]]
array([[13],
[23],
[33],
[43],
[53]])
```
... |
12,521,009 | I want to ability to take a class (written and maintained by a third party), wrap it with some magic C# sugar, that lets me wrap each member function (or more) with a custom locking mechanism (or logging mechanism or whatever).
For example,
```
class Foo { // someone else wrote this and I can't touch it.
void A... | 2012/09/20 | [
"https://Stackoverflow.com/questions/12521009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364818/"
] | Every [Service](http://developer.android.com/reference/android/app/Service.html) has its own Context, just use that. You don't need to pass a Service an Activity's Context.
I don't see why you need a specific Activity's Context to call `getSystemService()` and a Service will receive Intents from a BroadcastReceiver as... | >
> How to pass an activity context in an application to a service in an other application
>
>
>
This is not possible. These applications are running in separate virtual machines in separate applications -- you cannot pass an object across these boundaries. |
12,521,009 | I want to ability to take a class (written and maintained by a third party), wrap it with some magic C# sugar, that lets me wrap each member function (or more) with a custom locking mechanism (or logging mechanism or whatever).
For example,
```
class Foo { // someone else wrote this and I can't touch it.
void A... | 2012/09/20 | [
"https://Stackoverflow.com/questions/12521009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364818/"
] | Every [Service](http://developer.android.com/reference/android/app/Service.html) has its own Context, just use that. You don't need to pass a Service an Activity's Context.
I don't see why you need a specific Activity's Context to call `getSystemService()` and a Service will receive Intents from a BroadcastReceiver as... | Perhaps Interprocess communication might help you there.
[Some randomly googled Android IPC slides here](http://kobablog.wordpress.com/2011/06/04/inter-process-communication-of-android/) |
13,457,841 | I have a simple conversion form from kg to lbs.
**html**
```
<input type="text" id="kg" name="kg">
<input type="text" id="lbs" name="lbs">
```
I have it setup so that the lbs box updates while you type in the kg box with this code.
**jQuery**
```
$("#kg").keyup(function(){
$('#lbs').val($('#kg').val()*2.20462... | 2012/11/19 | [
"https://Stackoverflow.com/questions/13457841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738750/"
] | use [`toFixed`](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed):
```
$('#lbs').val(($('#kg').val()*2.20462).toFixed(2));
```
---
```
number.toFixed( [digits] )
```
>
> **Parameter**
>
>
> **digits** The number of digits to appear after the decimal point; this
> may ... | Use [toFixed](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed)
```
var string = yourNumber.toFixed(2);
``` |
13,457,841 | I have a simple conversion form from kg to lbs.
**html**
```
<input type="text" id="kg" name="kg">
<input type="text" id="lbs" name="lbs">
```
I have it setup so that the lbs box updates while you type in the kg box with this code.
**jQuery**
```
$("#kg").keyup(function(){
$('#lbs').val($('#kg').val()*2.20462... | 2012/11/19 | [
"https://Stackoverflow.com/questions/13457841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738750/"
] | Use [toFixed](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed)
```
var string = yourNumber.toFixed(2);
``` | also this
```
(10.8).toFixed(2); // 10.80
var num = 2.4;
alert(num.toFixed(2)); // 2.40
```
[Formatting a number with exactly two decimals in JavaScript](https://stackoverflow.com/questions/1726630/javascript-formatting-number-with-exactly-two-decimals) |
13,457,841 | I have a simple conversion form from kg to lbs.
**html**
```
<input type="text" id="kg" name="kg">
<input type="text" id="lbs" name="lbs">
```
I have it setup so that the lbs box updates while you type in the kg box with this code.
**jQuery**
```
$("#kg").keyup(function(){
$('#lbs').val($('#kg').val()*2.20462... | 2012/11/19 | [
"https://Stackoverflow.com/questions/13457841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1738750/"
] | use [`toFixed`](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number/toFixed):
```
$('#lbs').val(($('#kg').val()*2.20462).toFixed(2));
```
---
```
number.toFixed( [digits] )
```
>
> **Parameter**
>
>
> **digits** The number of digits to appear after the decimal point; this
> may ... | also this
```
(10.8).toFixed(2); // 10.80
var num = 2.4;
alert(num.toFixed(2)); // 2.40
```
[Formatting a number with exactly two decimals in JavaScript](https://stackoverflow.com/questions/1726630/javascript-formatting-number-with-exactly-two-decimals) |
1,438,773 | I have a financial pricing application written in Python 2.4.4 which runs as an Excel plugin. Excel has a 1GB memory limit for all addins, so if any addin process tries to allocate more than 1Gb in total it will cause Excel to crash.
I've recently made a change to the program which may have changed the overall memory... | 2009/09/17 | [
"https://Stackoverflow.com/questions/1438773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46411/"
] | I don't believe XP keeps track of the peak memory requirements of a process (the way Linux does in /proc/pid/status for example). You can use third-party utilities such as [this one](http://www.loriotpro.com/ServiceAndSupport/How_to/How_to_control_Memory_usage.php) and set it to "poll" the process very frequently to ge... | Simplest solution might just be to run your app from the command line and use Task Manager to see how much memory it's using.
Edit:
For something more complicated have a look at this question / answer [How to get memory usage under Windows in C++](https://stackoverflow.com/questions/282194/how-to-get-memory-usage-unde... |
72,776,698 | I am trying to find the average time of the dataset below in R
```
c("1:00", "12:45", "12:45", "1:00", "7:30", "12:45", "7:15",
"8:00", "12:30", "12:15", "12:45", "7:30", "7:45", "12:45", "11:30",
"11:00", "10:45", "10:30", "4:30", "11:00", "11:00", "9:45",
"9:45", "11:00", "11:15", "4:45", "11:15", "11:15", "11:00... | 2022/06/27 | [
"https://Stackoverflow.com/questions/72776698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13773321/"
] | In `base R` you can use this:
```
format(mean(strptime(times, "%H:%M")), "%H:%M")
```
Output:
```
[1] "09:24"
``` | Here is a way.
1. Coerce the character strings vector to package `chron` S3 class `"time"`;
2. compute the mean times with the method `mean` for this class;
3. round to minutes;
4. remove the seconds digits.
```r
times <- c("1:00", "12:45", "12:45", "1:00", "7:30", "12:45", "7:15",
"8:00", "12:30", "12:15... |
351,603 | sorry for stupid question but I do need help with connect of my ammeter from ebay. I bought this [Ammeter 0-50A](https://www.ebay.com/itm/0-36-Direct-Current-Digitals-LED-Digital-Display-Ammeter-Ampermeter-Panel/142521877008?ssPageName=STRK%3AMEBIDX%3AIT&var=441512420138&_trksid=p2057872.m2749.l2649) but there is no co... | 2018/01/23 | [
"https://electronics.stackexchange.com/questions/351603",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/170853/"
] | What this device must be doing is measuring voltage on this R050 (0.05 Ohm) resistor and converting it to the value of current. The device really misses the documentation, and as Leon said in comment to your question you either get documentation for it, or better junk it.
Red/Black wire pair *seem to be* the power sup... | You can solder a 50 mOHM = 0.05ohm resistor like on the picture. The tube is the same as a resistor. However be careful and find a through-hole resistor for high Amperes.
The tube is a resistor of a kind.
Or go after a 50 mOHM = 0.05ohm SMD like in the example.
So you undertand that's a SHUNT resistor to measure the... |
29,930 | On the German Chinese web page [here](https://dict.leo.org/forum/viewWrongentry.php?idThread=1373913&lang=de&lp=chde) there is a question about the use of 把
in 我们把那张画儿挂上去吧。So I thought, just rearrange to 我们挂上去那幅画吧。to try to explain.
However, my friend, 晓云, immediately said: 笨蛋的老外,这样不行!
I asked why, she immediately sa... | 2018/05/26 | [
"https://chinese.stackexchange.com/questions/29930",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/6991/"
] | >
> [1. 我们] [2. 挂] [3. 上去] [4. 那幅画] [5. 吧]
>
>
> [1. subject] [2. verb] [3. directional (verb) complement] [4. object] [5. final particle]
>
>
>
The problem here is, in Chinese grammar, the object should be inserted between the 'verb' and the 'directional complement'
The following is the correct structure:
>
... | I don’t know how to explain it .if you don’t use 把 that sounds weird .But it does not affect the meaning of the sentence. |
29,930 | On the German Chinese web page [here](https://dict.leo.org/forum/viewWrongentry.php?idThread=1373913&lang=de&lp=chde) there is a question about the use of 把
in 我们把那张画儿挂上去吧。So I thought, just rearrange to 我们挂上去那幅画吧。to try to explain.
However, my friend, 晓云, immediately said: 笨蛋的老外,这样不行!
I asked why, she immediately sa... | 2018/05/26 | [
"https://chinese.stackexchange.com/questions/29930",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/6991/"
] | >
> [1. 我们] [2. 挂] [3. 上去] [4. 那幅画] [5. 吧]
>
>
> [1. subject] [2. verb] [3. directional (verb) complement] [4. object] [5. final particle]
>
>
>
The problem here is, in Chinese grammar, the object should be inserted between the 'verb' and the 'directional complement'
The following is the correct structure:
>
... | " 我们挂上那幅画吧"
The point is verb, not 收起, 扔掉 or anything else but 挂上.
我们把那张画儿挂上去.
The point is 那张(not 这张...) or 画(not 照片...). |
29,930 | On the German Chinese web page [here](https://dict.leo.org/forum/viewWrongentry.php?idThread=1373913&lang=de&lp=chde) there is a question about the use of 把
in 我们把那张画儿挂上去吧。So I thought, just rearrange to 我们挂上去那幅画吧。to try to explain.
However, my friend, 晓云, immediately said: 笨蛋的老外,这样不行!
I asked why, she immediately sa... | 2018/05/26 | [
"https://chinese.stackexchange.com/questions/29930",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/6991/"
] | >
> [1. 我们] [2. 挂] [3. 上去] [4. 那幅画] [5. 吧]
>
>
> [1. subject] [2. verb] [3. directional (verb) complement] [4. object] [5. final particle]
>
>
>
The problem here is, in Chinese grammar, the object should be inserted between the 'verb' and the 'directional complement'
The following is the correct structure:
>
... | These sentences are correct:
>
> 我们把那张画儿挂上去吧。
>
>
> 那张画儿挂在墙上。
>
>
> 把那张画挂在墙上。
>
>
>
I think the point is the verb 挂. 挂 is usually followed with the location words/phrases, like 在墙上,在xxx, and it's not that natural when it's followed by the direct object, like 画,照片,etc. However, if you want to express you hang ... |
16,018,965 | I have the following page querystring:
```
register.aspx?id="jSmith"
```
I have the following code to retrieve the value of ID
```
string qString = string.IsNullOrEmpty(Request.QueryString["id"]) ? string.Empty : HttpUtility.UrlDecode(Request.QueryString["id"]);
```
When I view the value of qString I get som... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16018965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996431/"
] | That is because the correct way to give the path in this case would be `register.aspx?id=jSmith`, without the quotes. If you need spaces, or other special characters, in your ID, these should be URL encoded (and will be decoded by your code), but *not* enclosed in quotes.
For example, if your id was the string `john s... | You don't need to put quotes around values in querystring, by definition they're all strings...
Your querystring should look like :
```
register.aspx?id=jSmith
``` |
16,018,965 | I have the following page querystring:
```
register.aspx?id="jSmith"
```
I have the following code to retrieve the value of ID
```
string qString = string.IsNullOrEmpty(Request.QueryString["id"]) ? string.Empty : HttpUtility.UrlDecode(Request.QueryString["id"]);
```
When I view the value of qString I get som... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16018965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996431/"
] | The code is correct.
The problem is that you are passing to the page `"jSmith"` with the double quotes as part of the string.
Try invoke the page this way
```
register.aspx?id=jSmith
``` | You don't need to put quotes around values in querystring, by definition they're all strings...
Your querystring should look like :
```
register.aspx?id=jSmith
``` |
16,018,965 | I have the following page querystring:
```
register.aspx?id="jSmith"
```
I have the following code to retrieve the value of ID
```
string qString = string.IsNullOrEmpty(Request.QueryString["id"]) ? string.Empty : HttpUtility.UrlDecode(Request.QueryString["id"]);
```
When I view the value of qString I get som... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16018965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996431/"
] | That is because the correct way to give the path in this case would be `register.aspx?id=jSmith`, without the quotes. If you need spaces, or other special characters, in your ID, these should be URL encoded (and will be decoded by your code), but *not* enclosed in quotes.
For example, if your id was the string `john s... | You do not need the quotation marks in your querystring.
It should read
```
register.aspx?id=jSmith
``` |
16,018,965 | I have the following page querystring:
```
register.aspx?id="jSmith"
```
I have the following code to retrieve the value of ID
```
string qString = string.IsNullOrEmpty(Request.QueryString["id"]) ? string.Empty : HttpUtility.UrlDecode(Request.QueryString["id"]);
```
When I view the value of qString I get som... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16018965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996431/"
] | That is because the correct way to give the path in this case would be `register.aspx?id=jSmith`, without the quotes. If you need spaces, or other special characters, in your ID, these should be URL encoded (and will be decoded by your code), but *not* enclosed in quotes.
For example, if your id was the string `john s... | You should look for
```
if (qString == "\"jSmith\"")
```
the `\` is escaping the extra `"`
or you could perform a replace to remove the extra `"` |
16,018,965 | I have the following page querystring:
```
register.aspx?id="jSmith"
```
I have the following code to retrieve the value of ID
```
string qString = string.IsNullOrEmpty(Request.QueryString["id"]) ? string.Empty : HttpUtility.UrlDecode(Request.QueryString["id"]);
```
When I view the value of qString I get som... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16018965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996431/"
] | That is because the correct way to give the path in this case would be `register.aspx?id=jSmith`, without the quotes. If you need spaces, or other special characters, in your ID, these should be URL encoded (and will be decoded by your code), but *not* enclosed in quotes.
For example, if your id was the string `john s... | use
```
Response.Redirect("Qstring.aspx?name= smith");
```
and on the page Qstring.aspx load event
```
string s=Request.QueryString["name"].ToString();
```
gives u "smith" in s variable |
16,018,965 | I have the following page querystring:
```
register.aspx?id="jSmith"
```
I have the following code to retrieve the value of ID
```
string qString = string.IsNullOrEmpty(Request.QueryString["id"]) ? string.Empty : HttpUtility.UrlDecode(Request.QueryString["id"]);
```
When I view the value of qString I get som... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16018965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996431/"
] | The code is correct.
The problem is that you are passing to the page `"jSmith"` with the double quotes as part of the string.
Try invoke the page this way
```
register.aspx?id=jSmith
``` | You do not need the quotation marks in your querystring.
It should read
```
register.aspx?id=jSmith
``` |
16,018,965 | I have the following page querystring:
```
register.aspx?id="jSmith"
```
I have the following code to retrieve the value of ID
```
string qString = string.IsNullOrEmpty(Request.QueryString["id"]) ? string.Empty : HttpUtility.UrlDecode(Request.QueryString["id"]);
```
When I view the value of qString I get som... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16018965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996431/"
] | The code is correct.
The problem is that you are passing to the page `"jSmith"` with the double quotes as part of the string.
Try invoke the page this way
```
register.aspx?id=jSmith
``` | You should look for
```
if (qString == "\"jSmith\"")
```
the `\` is escaping the extra `"`
or you could perform a replace to remove the extra `"` |
16,018,965 | I have the following page querystring:
```
register.aspx?id="jSmith"
```
I have the following code to retrieve the value of ID
```
string qString = string.IsNullOrEmpty(Request.QueryString["id"]) ? string.Empty : HttpUtility.UrlDecode(Request.QueryString["id"]);
```
When I view the value of qString I get som... | 2013/04/15 | [
"https://Stackoverflow.com/questions/16018965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/996431/"
] | The code is correct.
The problem is that you are passing to the page `"jSmith"` with the double quotes as part of the string.
Try invoke the page this way
```
register.aspx?id=jSmith
``` | use
```
Response.Redirect("Qstring.aspx?name= smith");
```
and on the page Qstring.aspx load event
```
string s=Request.QueryString["name"].ToString();
```
gives u "smith" in s variable |
3,394,560 | i am facing a problem while making an application of Blackberry that i have upto 7 threds call, of which each downloads an audio from the Server and it works fine but when i start my application twice then an uncaught exception has been occurred that "TOO MANY THREADS ERROR EXCEPTION", So, let me know that how i can so... | 2010/08/03 | [
"https://Stackoverflow.com/questions/3394560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/345138/"
] | i think instead of starting 7 threads use single thread.
1. create a TaskWorker class
```
public class TaskWorker implements Runnable {
private boolean quit = false;
private Vector queue = new Vector();
public TaskWorker() {
new Thread(this).start();
}
private Task getNext() {
Tas... | If it happens when you RESTART the application, it means you must have some zombies... **are you sure to join all your threads ?** |
469,340 | I am trying to convert Maxwell's equations from the well known differential form (found on Wikipedia [Maxwell's equations](https://en.wikipedia.org/wiki/Maxwell%27s_equations)) into scalar equations involving partial derivatives (more than four equations). The problem I'm having is finding the definitions of physical q... | 2019/03/29 | [
"https://physics.stackexchange.com/questions/469340",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/226743/"
] | >
> I'm not sure how charge density and current density are expressed in euclidean space.
>
>
>
Charge density $\rho$ is just a scalar density (measured in Coulomb/m$^3$).
And current density $\vec{J}$ is a vector density (with cartesian components
$J\_x, J\_y, J\_z$, measured in Ampere/m$^2$).
>
> What are M... | If I understand you correctly,there are a couple ways you can proceed.
Method 1:
Maxwell's Equations in vector form already represent partial differential equations of the components of the Electric and Magnetic Fields. You can re-express the standard equations strictly in terms of those components.
This can be don... |
58,190 | Scientific literature has items called letters, communications and journal papers. They all seem quite similar in terms of format and content. What are the differences between them? | 2015/11/14 | [
"https://academia.stackexchange.com/questions/58190",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/30698/"
] | At my university in the USA, it would likely be illegal for the instructor or the TAs of the particular class to participate in this. There is just too much of a (perceived) conflict of interest since they are evaluating you for a grade for the class.
However, there would not be anything barring you from approaching a... | The appropriate way to do it is explain what you want, and why you are willing to pay for it. You have to be careful to not say something like "I want to pass this course, and I'm willing to pay you to make that happen", since that would look like an offer of a bribe which would be illegal. It is not illegal to pay a p... |
11,713 | The slice-ribbon conjecture asserts that all slice knots are ribbon.
This assumes the context:
1) A `knot' is a smooth embedding $S^1 \to S^3$. We're thinking of the 3-sphere as the boundary of the 4-ball $S^3 = \partial D^4$.
2) A knot being slice means that it's the boundary of a 2-disc smoothly embedded in $D^... | 2010/01/14 | [
"https://mathoverflow.net/questions/11713",
"https://mathoverflow.net",
"https://mathoverflow.net/users/1465/"
] | Ryan, I think this is an open problem. The best related result I know is a theorem of Casson and Gordon [A loop theorem for duality spaces and fibred ribbon knots. Invent. Math. 74 (1983)] saying that for a fibred knot that bounds a homotopically ribbon disk in the 4-ball, the slice complement is also fibred.
More pr... | As far as I know, extension of slice and ribbon to links is not unique.
There are "strong slice", "weak slice", "strong ribbon" and "weak ribbon" for links.
"CHARACTERIZATION OF SLICES AND RIBBONS" (by H.FOX) mentioned these concepts. |
52,503,413 | Tried to paste the code from one book (TCP/IP learning) to send a message from client to server. But nothing happens, except the message "The server is ready to receive".
Server code:
```
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET, SOCK_STREAM)
serverSocket.bind(('', serverPort))
serverSoc... | 2018/09/25 | [
"https://Stackoverflow.com/questions/52503413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10360433/"
] | You entered the wrong server name. The server name is actually the IP address, and `0.0.0.0.0` is not a valid IP address.
Try changing
```
serverName = '0.0.0.0.0' -> '0.0.0.0' or '127.0.0.1'
``` | The value for *serverName* is not a valid IP address ('0.0.0.0.0'). Try `0.0.0.0` instead.
If you want to check for a valid IP address beforehand, try this.
```
if re.match(r'[0-9]+(?:\.[0-9]+){3}', input_string):
serverName = input_string # True, valid
else:
print('Invalid IP Address')
``` |
72,105,722 | ```py
if __name__ == "__main__":
from SettingsHandler import YamlParser
from UIComponents.IncrementSlider import IncrementSlider
from UIComponents.ToggleSwitch import ToggleSwitch
from UI.SettingsPane import SettingsPane
#from KeyStrokeWrapper import KeyStrokeWrapper
else:
from Handlers.SettingsHandler impo... | 2022/05/03 | [
"https://Stackoverflow.com/questions/72105722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12246801/"
] | The title is incorrect, as some users pointed out and you should throw some code snippets to showcase what you've been doing and where exactly your problem is.
From the form of the question and details, I would suggest you do some research into the differences between frontend and backend and the solution will be clear... | Check out Node's [EventEmitter](https://nodejs.dev/learn/the-nodejs-event-emitter). With this class, you can emit events and listen for them. You can also create your own classes which extend `EventEmitter` and make use of its functionality like so:
```
const { EventEmitter } = require('events');
class MyClass extend... |
35,619,409 | Hi I am using R and have a cluster assignment matrix that comes out of my clustering function. (I am applying a clustering algorithm on a gaussian mixture data) I want to create a data matrix of clusters. Here is a toy example of what I want to do.
```
#simulate data
dat=Z<-c(rnorm(2,0,1),rnorm(2,2,3),rnorm(3,0,1),r... | 2016/02/25 | [
"https://Stackoverflow.com/questions/35619409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2328572/"
] | The problem is it's sorting the name as text, without respect to the numeric value of the items. In text, a "1" is less than an "8", and it doesn't matter that the "1" is followed by a "0".
Do this:
```
string[] files = Directory.GetFiles(folderDlg.SelectedPath);
files = files.OrderBy(f => int.Parse(f.Split(".")[0])... | It looks like you are struggling with strings representing versions.
You can convert them to version and sort them.
```
var sortedVersions = files.Select(x => new Version(x)).OrderBy(x => x);
```
Now you can use the `sortedVersions` or convert it back to an array of strings.
```
files = sortedVersions.Select(x => ... |
35,619,409 | Hi I am using R and have a cluster assignment matrix that comes out of my clustering function. (I am applying a clustering algorithm on a gaussian mixture data) I want to create a data matrix of clusters. Here is a toy example of what I want to do.
```
#simulate data
dat=Z<-c(rnorm(2,0,1),rnorm(2,2,3),rnorm(3,0,1),r... | 2016/02/25 | [
"https://Stackoverflow.com/questions/35619409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2328572/"
] | If file names are actually *versions* sort them as versions:
```
string[] files = Directory.GetFiles(folderDlg.SelectedPath);
Array.Sort(files, (left, right) =>
new Version(Path.GetFileNameWithoutExtension(left)).CompareTo(
new Version(Path.GetFileNameWithoutExtension(right))));
```
**Edit:** in *gener... | It looks like you are struggling with strings representing versions.
You can convert them to version and sort them.
```
var sortedVersions = files.Select(x => new Version(x)).OrderBy(x => x);
```
Now you can use the `sortedVersions` or convert it back to an array of strings.
```
files = sortedVersions.Select(x => ... |
3,275 | A method to orthogonalize a set of vectors (vectors of unit length that are mutually orthogonal) is the Gram-Schmidt process:
<http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process>
Note that the the nested *for* loops imply that the difference is between vector $v\_i$ and vectors $\{v\_1, \dots, v\_{i-1}\}$.
How... | 2012/09/13 | [
"https://scicomp.stackexchange.com/questions/3275",
"https://scicomp.stackexchange.com",
"https://scicomp.stackexchange.com/users/1069/"
] | This is a damped Richardson method. Since one step of this operation, $x\_k \mapsto x\_{k+1}$ is not a linear operation, it is not a stationary iteration. The presence of the extra matrix multiply and extra reduction per iteration make the method very unattractive compared to Krylov subspace methods which need onyl one... | It is easy to verify that $x=A^{-1}b$ is indeed a fixed point of the iteration. The question is whether the iteration operator
$$
I - \alpha A
$$
is a contraction. If $A$ is SPD, this is the case if $\alpha$ were less than or equal $\frac{1}{\lambda\_{\textrm{max}}}$.
On the other hand, we can only infer with simple ... |
3,275 | A method to orthogonalize a set of vectors (vectors of unit length that are mutually orthogonal) is the Gram-Schmidt process:
<http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process>
Note that the the nested *for* loops imply that the difference is between vector $v\_i$ and vectors $\{v\_1, \dots, v\_{i-1}\}$.
How... | 2012/09/13 | [
"https://scicomp.stackexchange.com/questions/3275",
"https://scicomp.stackexchange.com",
"https://scicomp.stackexchange.com/users/1069/"
] | This is known as the steepest descent method, which converges for any symmetric and positive definite matrix (with a linear rate that depends on its condition number) independent of the initialization; see chapter 5.3.1 of Saad's [Iterative Methods for Sparse Linear Systems](http://www-users.cs.umn.edu/~saad/IterMethBo... | This is a damped Richardson method. Since one step of this operation, $x\_k \mapsto x\_{k+1}$ is not a linear operation, it is not a stationary iteration. The presence of the extra matrix multiply and extra reduction per iteration make the method very unattractive compared to Krylov subspace methods which need onyl one... |
3,275 | A method to orthogonalize a set of vectors (vectors of unit length that are mutually orthogonal) is the Gram-Schmidt process:
<http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process>
Note that the the nested *for* loops imply that the difference is between vector $v\_i$ and vectors $\{v\_1, \dots, v\_{i-1}\}$.
How... | 2012/09/13 | [
"https://scicomp.stackexchange.com/questions/3275",
"https://scicomp.stackexchange.com",
"https://scicomp.stackexchange.com/users/1069/"
] | This is known as the steepest descent method, which converges for any symmetric and positive definite matrix (with a linear rate that depends on its condition number) independent of the initialization; see chapter 5.3.1 of Saad's [Iterative Methods for Sparse Linear Systems](http://www-users.cs.umn.edu/~saad/IterMethBo... | It is easy to verify that $x=A^{-1}b$ is indeed a fixed point of the iteration. The question is whether the iteration operator
$$
I - \alpha A
$$
is a contraction. If $A$ is SPD, this is the case if $\alpha$ were less than or equal $\frac{1}{\lambda\_{\textrm{max}}}$.
On the other hand, we can only infer with simple ... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | Not sure when this became supported but tried this in ASP.NET Core 2.0 with Hangfire 1.7.0. The following code schedules a job every 20 seconds:
```
RecurringJob.AddOrUpdate<SomeJob>(
x => x.DoWork(),
"*/20 * * * * *");
```
If I am not mistaken 6 tokens (as opposed to standard 5 tokens) is supported due to H... | I had a similar requirement, in that I had a recurring job that needs running every 15 seconds.
What I did to try to get around this limitation was to just delay the creation of the scheduled jobs (set to 1 minute intervals), which seemed to do the trick.
However what I found was that, taking into account the polling i... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | Not sure when this became supported but tried this in ASP.NET Core 2.0 with Hangfire 1.7.0. The following code schedules a job every 20 seconds:
```
RecurringJob.AddOrUpdate<SomeJob>(
x => x.DoWork(),
"*/20 * * * * *");
```
If I am not mistaken 6 tokens (as opposed to standard 5 tokens) is supported due to H... | I think anyone who is against allowing a recurring trigger of less than 1 min is short sighted. After all, is 55 secs any less efficient than 1 min ? It seems so arbitrary! As much as I love Hangfire, I've encountered situations where I've had to steer a client to Quartz.net simply because there was a business requirem... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | Hangfire doesn't support intervals of less than a minute for recurring jobs.
Why? Imagine if they allowed less than a minute: let say 1 sec. How frequently would hangfire check recurring jobs in the database? This would cause a lot of database IO.
See [this discussion](https://discuss.hangfire.io/t/recurring-job-ev... | I faced with the same problem, and here it is my solution:
```
private void TimingExecuteWrapper(Action action, int sleepSeconds, int intervalSeconds)
{
DateTime beginTime = DateTime.UtcNow, endTime;
var interval = TimeSpan.FromSeconds(intervalSeconds);
while (true)
{
action();
Thread.S... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | I had to do the same but with 5 seconds. The default schedule polling interval is set to 15s. So it requires 2 steps to achieve a 5s interval job.
in Startup.cs
```
var options = new BackgroundJobServerOptions
{
SchedulePollingInterval = TimeSpan.FromMilliseconds(5000)
};
app.UseHangfireDashboard();
app.UseHangf... | I had a similar requirement, in that I had a recurring job that needs running every 15 seconds.
What I did to try to get around this limitation was to just delay the creation of the scheduled jobs (set to 1 minute intervals), which seemed to do the trick.
However what I found was that, taking into account the polling i... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | Not sure when this became supported but tried this in ASP.NET Core 2.0 with Hangfire 1.7.0. The following code schedules a job every 20 seconds:
```
RecurringJob.AddOrUpdate<SomeJob>(
x => x.DoWork(),
"*/20 * * * * *");
```
If I am not mistaken 6 tokens (as opposed to standard 5 tokens) is supported due to H... | Although Hangfire doesn't allow you to schedule tasks for less than a minute, you can actually achieve this by having the function recursively scheduling itself; i.e. let's say you want some method to be hit every 2s you can schedule a background job that calls the method on Startup;
```
BackgroundJob.Schedule(() => P... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | I think anyone who is against allowing a recurring trigger of less than 1 min is short sighted. After all, is 55 secs any less efficient than 1 min ? It seems so arbitrary! As much as I love Hangfire, I've encountered situations where I've had to steer a client to Quartz.net simply because there was a business requirem... | I had a similar requirement, in that I had a recurring job that needs running every 15 seconds.
What I did to try to get around this limitation was to just delay the creation of the scheduled jobs (set to 1 minute intervals), which seemed to do the trick.
However what I found was that, taking into account the polling i... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | Not sure when this became supported but tried this in ASP.NET Core 2.0 with Hangfire 1.7.0. The following code schedules a job every 20 seconds:
```
RecurringJob.AddOrUpdate<SomeJob>(
x => x.DoWork(),
"*/20 * * * * *");
```
If I am not mistaken 6 tokens (as opposed to standard 5 tokens) is supported due to H... | I had to do the same but with 5 seconds. The default schedule polling interval is set to 15s. So it requires 2 steps to achieve a 5s interval job.
in Startup.cs
```
var options = new BackgroundJobServerOptions
{
SchedulePollingInterval = TimeSpan.FromMilliseconds(5000)
};
app.UseHangfireDashboard();
app.UseHangf... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | I think anyone who is against allowing a recurring trigger of less than 1 min is short sighted. After all, is 55 secs any less efficient than 1 min ? It seems so arbitrary! As much as I love Hangfire, I've encountered situations where I've had to steer a client to Quartz.net simply because there was a business requirem... | Hangfire doesn't support intervals of less than a minute for recurring jobs.
Why? Imagine if they allowed less than a minute: let say 1 sec. How frequently would hangfire check recurring jobs in the database? This would cause a lot of database IO.
See [this discussion](https://discuss.hangfire.io/t/recurring-job-ev... |
38,367,398 | Is there a way to set hangfire recurring jobs every few seconds?
I do not seek a solution where fire and forget task creates another fire and forget task, and if not, what are suggested alternatives? | 2016/07/14 | [
"https://Stackoverflow.com/questions/38367398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645827/"
] | I think anyone who is against allowing a recurring trigger of less than 1 min is short sighted. After all, is 55 secs any less efficient than 1 min ? It seems so arbitrary! As much as I love Hangfire, I've encountered situations where I've had to steer a client to Quartz.net simply because there was a business requirem... | I had to do the same but with 5 seconds. The default schedule polling interval is set to 15s. So it requires 2 steps to achieve a 5s interval job.
in Startup.cs
```
var options = new BackgroundJobServerOptions
{
SchedulePollingInterval = TimeSpan.FromMilliseconds(5000)
};
app.UseHangfireDashboard();
app.UseHangf... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.