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 |
|---|---|---|---|---|---|
9,197,084 | in C# I need to keep data in a dictionary object, looks like:
```
Dictionary<string, Dictionary<string, string>> MyDict =
new Dictionary<string, Dictionary<string, string>>();
```
Now I realised, that I would need in some cases some other (not dictionary-like) data as value of the main dict.
Is there any kind ... | 2012/02/08 | [
"https://Stackoverflow.com/questions/9197084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/659017/"
] | You'll loose strong types and all their benefits.
Can you not create a new class that has a Dictionary property and add your other data to it:
```
public class CallItWhatYouLike
{
public Dictionary<string, string> Dictionary {get; set;}
public int AnotherProperty {get; set;}
...
}
var MyDict = new Dictionary<s... | No, there's no problem. If you need to type the value as `Dictionary<string, string>` just cast it and you'll have this solved. |
9,197,084 | in C# I need to keep data in a dictionary object, looks like:
```
Dictionary<string, Dictionary<string, string>> MyDict =
new Dictionary<string, Dictionary<string, string>>();
```
Now I realised, that I would need in some cases some other (not dictionary-like) data as value of the main dict.
Is there any kind ... | 2012/02/08 | [
"https://Stackoverflow.com/questions/9197084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/659017/"
] | By using object as the value in your dictionary you will incur some risk and complications:
* Lack of type safety (anything can be set to the value)
* You would have to cast to a particular type, probably based on the value
You should probably rethink your design. But if you really want a the flexibility you could cr... | You will pay a performance penalty when you [unbox](http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx) the `System.Object`, but other than that there isn't a problem with your approach other than excessive casting for indexers (*due to weak typing*).
You may consider using a [System.Tuple](http://msdn.microsoft.c... |
9,197,084 | in C# I need to keep data in a dictionary object, looks like:
```
Dictionary<string, Dictionary<string, string>> MyDict =
new Dictionary<string, Dictionary<string, string>>();
```
Now I realised, that I would need in some cases some other (not dictionary-like) data as value of the main dict.
Is there any kind ... | 2012/02/08 | [
"https://Stackoverflow.com/questions/9197084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/659017/"
] | You can do that. After retrieving data from the main dictionary, you will have to cast the result to an appropriate type:
```
object obj;
If(mainDict.TryGetValue("key", out obj)) {
var dict = obj as Dictionary<string, string>>;
if (dict != null) {
// work with dict
} else {
var value = obj ... | You'll loose strong types and all their benefits.
Can you not create a new class that has a Dictionary property and add your other data to it:
```
public class CallItWhatYouLike
{
public Dictionary<string, string> Dictionary {get; set;}
public int AnotherProperty {get; set;}
...
}
var MyDict = new Dictionary<s... |
9,197,084 | in C# I need to keep data in a dictionary object, looks like:
```
Dictionary<string, Dictionary<string, string>> MyDict =
new Dictionary<string, Dictionary<string, string>>();
```
Now I realised, that I would need in some cases some other (not dictionary-like) data as value of the main dict.
Is there any kind ... | 2012/02/08 | [
"https://Stackoverflow.com/questions/9197084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/659017/"
] | By using object as the value in your dictionary you will incur some risk and complications:
* Lack of type safety (anything can be set to the value)
* You would have to cast to a particular type, probably based on the value
You should probably rethink your design. But if you really want a the flexibility you could cr... | You'll loose strong types and all their benefits.
Can you not create a new class that has a Dictionary property and add your other data to it:
```
public class CallItWhatYouLike
{
public Dictionary<string, string> Dictionary {get; set;}
public int AnotherProperty {get; set;}
...
}
var MyDict = new Dictionary<s... |
9,197,084 | in C# I need to keep data in a dictionary object, looks like:
```
Dictionary<string, Dictionary<string, string>> MyDict =
new Dictionary<string, Dictionary<string, string>>();
```
Now I realised, that I would need in some cases some other (not dictionary-like) data as value of the main dict.
Is there any kind ... | 2012/02/08 | [
"https://Stackoverflow.com/questions/9197084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/659017/"
] | Yes, your dictionary would not be strongly typed anymore - in the first approach you could do something like:
```
string value = myDict["foo"]["bar"];
```
In the second approach this is not possible anymore since you have to cast first:
```
string value = ((Dictionary<string,string>)myDict["foo"])["bar"];
```
It ... | Well, your code will be less typesafe and you will need runtime type checks and type casts, but otherwise you can use `object` as a dictionary value type and store any types there. |
50,407,429 | Is there any way to change the column property from `unique=true` to `unique=false` without dropping the table?
Now I am stuck in the situation where tables has been created earlier and these table are containing data too. When I changed `unique=true` to `unique=false` it doesn't making any changes in table. | 2018/05/18 | [
"https://Stackoverflow.com/questions/50407429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5871008/"
] | the answer was here: [How do I return the response from an asynchronous call?](https://stackoverflow.com/q/14220321/3461055)
Request is a asynchronous call!
the Solution is not pretty but it's work!
```
setTimeout(function() { console.log('test', test);}, 3000);
``` | request is asynchronous so the console.log in the bottom will be executed before test variable is assigned with the body.
So the console.log needs to be inside the request response function.
If you want to use the body later on outside the response function, depends on how you plan to use it. |
25,964,697 | I am trying to make a UI for this countdown timer, I keep running into the problem with python not seeing that variables are defined outside of whatever function I am making. I tried using globals but this sometimes doesn't work either. Is there anyway of getting functions to recognize that I have set the variables out... | 2014/09/21 | [
"https://Stackoverflow.com/questions/25964697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3763447/"
] | I just tried the Immediate Window and it works providing you have write permission to the output file directory. So if your code is:
```
var a = "Lawrence\r\nLessig";
```
Then in the immediate Window use:
```
File.WriteAllText (@"c:\Users\MyUserLogin\documents\foo.txt", a);
```
Creates foo.txt containing:
```
La... | I work on [a commercial Visual Studio extension](http://www.oz-code.com) that can probably help you achieve what you need to do:
If you need to Filter the list, you can use OzCode's [Filter](http://o.oz-code.com/videos#98426700). If you want to do a text search on the values of the fields, you can use OzCode's Search.... |
62,572,361 | i'm trying to catch an discord.js error
This error pops up when internet is off, but i want some clean code instead this messy one...
How can i catch this?
I did really try everything..
code:
```
(node:11052) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND disc
ordapp.com
at GetAddrInfoReqWrap.onl... | 2020/06/25 | [
"https://Stackoverflow.com/questions/62572361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm not sure I fully understand your use case, the way I'd model the relationship between your types is something like the following
```js
type Season =
| "winter"
| "spring"
| "summer"
| "fall"
type Month =
| "January"
| "February"
| "March"
| "April"
| "May"
| "June"
| "July"
| "August"
| ... | Just found a somewhat convoluted way to extract the literal type information from the keys while still checking the values:
```js
function EnumWith<P>() {
return function <K extends keyof any, R extends Record<K, P>>(defs: R): R {
return defs
}
}
```
which allows to write this:
```js
const Seasons =... |
15,022,442 | I am unable to use the function fromStdString.
it is said in the qt assistant that, "This operator is only available if Qt is configured with STL compatibility enabled.". but i don know how to enable this.
please provide the solution.
```
int main(int argc, char *argv[])
{
std::string read;
QStrin... | 2013/02/22 | [
"https://Stackoverflow.com/questions/15022442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1530573/"
] | STL support is compiled in by default (at least when you build it yourself).
Unless something has changed in 4.8 that I am unaware of, fromStdString is a static member of QString, so you should be calling it like
```
monthsArr[i] = QString::fromStdString(read);
```
Simply calling fromStdString in the global namespa... | Even if Qt was configured with -no-stl you can interact with std::string and containers, it only disables some syntactictic sugar. You can e.g. used QString::fromLatin1(some\_std\_string.c\_str(), some\_std\_string.size()) or QString::fromUtf8(...) or fromLocal8bit(...) depending on the encoding of the data in the std:... |
35,611,921 | The problem asks to find the maximum of a xor b for all pair of integers
pairs of integers a, b (l ≤ a ≤ b ≤ r).If l and R are 8 and 16 ,answer is 31 which is actually 15 xor 16.I came across this piece of code and it gives correct output but the logic part is not clear .
```
int main() {
cin >> A >> B;
ll num... | 2016/02/24 | [
"https://Stackoverflow.com/questions/35611921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5929408/"
] | Well, I can crash that code easily. By entering the same number twice. If l = r then the algorithm crashes, but the largest value for a xor b is obviously 0, since l = a = b = r.
Assume l < r, and that for some n we have (l / (2^n)) = (r / (2^n)). There is such an n because we can just pick n making 2^n > r. And n > ... | Lets take the example with l = 8 and r = 16, or
```
l = 00010
r = 00001
```
what the code does, is shifting the bits until the numbers are the same:
```
num=2 num=4 num=8 num=16 num=32
00100 01000 10000 00000 00000
00010 00100 01000 10000 00000 -> done : max xor is 32-1
```
this works, becaus... |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | As Jerry said, you cannot do it directly. You can, however, package your program into something like a self extracting RAR file which includes the DLL as part of the single EXE, which automatically extracts the EXE and associated DLLs to a temp folder and starts the main program. | On windows, you can get the lib file to run your program if you have the corresponding def file. You can use the command prompt window of visual studio to get the lib file. The command line is as follows: lib /def:XXX.def /machine:x64 (or x86 to get 32bit lib)/out:XXX.lib. You need to make sure the def file and dll fil... |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | Sorry, but there's no direct way to do so. A DLL is a fully linked executable format file, where a static library is a collection of separate object files collected together. With a little bit of work, you can convert a static library to a DLL, but doing the reverse is non-trivial (to put it mildly). | As Jerry said, you cannot do it directly. You can, however, package your program into something like a self extracting RAR file which includes the DLL as part of the single EXE, which automatically extracts the EXE and associated DLLs to a temp folder and starts the main program. |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | Sorry, but there's no direct way to do so. A DLL is a fully linked executable format file, where a static library is a collection of separate object files collected together. With a little bit of work, you can convert a static library to a DLL, but doing the reverse is non-trivial (to put it mildly). | I agree with Jerry, and if it is a deployment problem, you may use [Nullsoft Scriptable Install System](http://nsis.sourceforge.net/Main_Page). |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | False, it is possible to do this. For example there is a tool called [dlltolib](http://www.binary-soft.com/dll2lib/dll2lib.htm) which can do it. | I agree with Jerry, and if it is a deployment problem, you may use [Nullsoft Scriptable Install System](http://nsis.sourceforge.net/Main_Page). |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | Sorry, but there's no direct way to do so. A DLL is a fully linked executable format file, where a static library is a collection of separate object files collected together. With a little bit of work, you can convert a static library to a DLL, but doing the reverse is non-trivial (to put it mildly). | False, it is possible to do this. For example there is a tool called [dlltolib](http://www.binary-soft.com/dll2lib/dll2lib.htm) which can do it. |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | As Jerry said, you cannot do it directly. You can, however, package your program into something like a self extracting RAR file which includes the DLL as part of the single EXE, which automatically extracts the EXE and associated DLLs to a temp folder and starts the main program. | I am absolutely horrified at the lack of understanding in at least one of the (supposedly popular?) answers.
I have written a linker from the ground up, every line of code. I know everything there is to know about DLLs.
A DLL contains much much more information than a lib, and it does, guaranteed, contain absolutely... |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | As Jerry said, you cannot do it directly. You can, however, package your program into something like a self extracting RAR file which includes the DLL as part of the single EXE, which automatically extracts the EXE and associated DLLs to a temp folder and starts the main program. | False, it is possible to do this. For example there is a tool called [dlltolib](http://www.binary-soft.com/dll2lib/dll2lib.htm) which can do it. |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | False, it is possible to do this. For example there is a tool called [dlltolib](http://www.binary-soft.com/dll2lib/dll2lib.htm) which can do it. | On windows, you can get the lib file to run your program if you have the corresponding def file. You can use the command prompt window of visual studio to get the lib file. The command line is as follows: lib /def:XXX.def /machine:x64 (or x86 to get 32bit lib)/out:XXX.lib. You need to make sure the def file and dll fil... |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | On windows, you can get the lib file to run your program if you have the corresponding def file. You can use the command prompt window of visual studio to get the lib file. The command line is as follows: lib /def:XXX.def /machine:x64 (or x86 to get 32bit lib)/out:XXX.lib. You need to make sure the def file and dll fil... | I am absolutely horrified at the lack of understanding in at least one of the (supposedly popular?) answers.
I have written a linker from the ground up, every line of code. I know everything there is to know about DLLs.
A DLL contains much much more information than a lib, and it does, guaranteed, contain absolutely... |
2,576,910 | I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe? | 2010/04/05 | [
"https://Stackoverflow.com/questions/2576910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303006/"
] | I agree with Jerry, and if it is a deployment problem, you may use [Nullsoft Scriptable Install System](http://nsis.sourceforge.net/Main_Page). | I am absolutely horrified at the lack of understanding in at least one of the (supposedly popular?) answers.
I have written a linker from the ground up, every line of code. I know everything there is to know about DLLs.
A DLL contains much much more information than a lib, and it does, guaranteed, contain absolutely... |
16,865,724 | I was wondering if it is possible for Visual Studio to automatically insert a custom Code block after every Sub or function.
So Everytime you declare a new function it adds the code block. For Example
```
Sub dothis()
'*******************************************
'Name: Sub dothis()
'Function:
'Variables:
'Calls
'Cal... | 2013/05/31 | [
"https://Stackoverflow.com/questions/16865724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/867621/"
] | you need to pass a `Context` to the `makeText` method. Here this is not a context. It is just a reference of your `AboutMeActivity` class which is not an activity
May be you are trying to create an `Activity`. if so then you have to extend `Activity` class like this
```
public class AboutMeActivity extends Activity
... | [Toast](http://developer.android.com/reference/android/widget/Toast.html) has two methods called `makeText()`, and both of them take a Context as first argument. `AboutMeActivity` is not a Context (I guess you want it to extend Activity, but it doesn't), so the code doesn't compile. |
16,865,724 | I was wondering if it is possible for Visual Studio to automatically insert a custom Code block after every Sub or function.
So Everytime you declare a new function it adds the code block. For Example
```
Sub dothis()
'*******************************************
'Name: Sub dothis()
'Function:
'Variables:
'Calls
'Cal... | 2013/05/31 | [
"https://Stackoverflow.com/questions/16865724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/867621/"
] | you need to pass a `Context` to the `makeText` method. Here this is not a context. It is just a reference of your `AboutMeActivity` class which is not an activity
May be you are trying to create an `Activity`. if so then you have to extend `Activity` class like this
```
public class AboutMeActivity extends Activity
... | You need activity context to display toast. I guess you want to display toast on button click and you would have defined in your layout xml for button the attribute android:onClick="showAboutMessage". Your class must extend activity. Also you need to set the content of the layout to your activity.
```
public class Abo... |
16,865,724 | I was wondering if it is possible for Visual Studio to automatically insert a custom Code block after every Sub or function.
So Everytime you declare a new function it adds the code block. For Example
```
Sub dothis()
'*******************************************
'Name: Sub dothis()
'Function:
'Variables:
'Calls
'Cal... | 2013/05/31 | [
"https://Stackoverflow.com/questions/16865724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/867621/"
] | [Toast](http://developer.android.com/reference/android/widget/Toast.html) has two methods called `makeText()`, and both of them take a Context as first argument. `AboutMeActivity` is not a Context (I guess you want it to extend Activity, but it doesn't), so the code doesn't compile. | You need activity context to display toast. I guess you want to display toast on button click and you would have defined in your layout xml for button the attribute android:onClick="showAboutMessage". Your class must extend activity. Also you need to set the content of the layout to your activity.
```
public class Abo... |
356,269 | I'm building an application which uses SQLite, and now want to add settings that are stored between sessions
I'm considering if I'm going to store the settings in a **config file** or if I'm going to use **a table in the database** for this
(Please note that I'm using SQLite which stores data locally and doesn't have... | 2017/08/25 | [
"https://softwareengineering.stackexchange.com/questions/356269",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/196326/"
] | I don't agree that storing settings in a database table is a bad separation of concerns. Your "concerns" will be separated by not defining a relationship between the settings table and other tables in your database. This is fine.
The main thing to consider is how you expect the administrator of your system to make cha... | It all depends on how big your settings are. If it was a couple of values, then it would be simpler and less overhead to store it in a file. Especially that this file could be an XML that is easy to handle.
If you need to store your settings somewhere safe (e.g. saving credentials), then a database would be a slightl... |
356,269 | I'm building an application which uses SQLite, and now want to add settings that are stored between sessions
I'm considering if I'm going to store the settings in a **config file** or if I'm going to use **a table in the database** for this
(Please note that I'm using SQLite which stores data locally and doesn't have... | 2017/08/25 | [
"https://softwareengineering.stackexchange.com/questions/356269",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/196326/"
] | The largish legacy application I maintain has gone back and forth on this over the years, but has evolved towards keeping most settings in the DB. Yes, the DB connection string is read from the config file. This is a desktop application that heavily uses a DB and which has quite a few settings. If you have very few thi... | It all depends on how big your settings are. If it was a couple of values, then it would be simpler and less overhead to store it in a file. Especially that this file could be an XML that is easy to handle.
If you need to store your settings somewhere safe (e.g. saving credentials), then a database would be a slightl... |
356,269 | I'm building an application which uses SQLite, and now want to add settings that are stored between sessions
I'm considering if I'm going to store the settings in a **config file** or if I'm going to use **a table in the database** for this
(Please note that I'm using SQLite which stores data locally and doesn't have... | 2017/08/25 | [
"https://softwareengineering.stackexchange.com/questions/356269",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/196326/"
] | The largish legacy application I maintain has gone back and forth on this over the years, but has evolved towards keeping most settings in the DB. Yes, the DB connection string is read from the config file. This is a desktop application that heavily uses a DB and which has quite a few settings. If you have very few thi... | I don't agree that storing settings in a database table is a bad separation of concerns. Your "concerns" will be separated by not defining a relationship between the settings table and other tables in your database. This is fine.
The main thing to consider is how you expect the administrator of your system to make cha... |
35,014,550 | I want to draw smoothed lines for chart.
I have already made a chart using teechart.js, but it is not good working.
I've attached an image. Left image is mine.
[I'd like to make line such as right](http://i.stack.imgur.com/jPkAM.png)
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equi... | 2016/01/26 | [
"https://Stackoverflow.com/questions/35014550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5772257/"
] | Checking your code I see it misses a couple of details, but correcting them it works without problems:
* Set smoothed lines. In your example it would be:
```
Chart1.series.items[0].smooth = 0.5;
Chart1.series.items[1].smooth = 0.5;
```
* Include `teechart-extras.js` to define `Tee.drawSpline`. It would be something ... | I think you should take a look [at `THREE.TubeGeometry`](http://threejs.org/docs/#Reference/Extras.Geometries/TubeGeometry) where you can pass a spline/curve as a path for the tube:
```
extrudePath = // define some spline or curve;
segments = 64;
radius = 5;
radiusSegments = 8;
closed = false;
tube = new THREE.TubeGeo... |
2,407,451 | I am building a CAD-file converter on top of two libraries (Opencascade and DWF Toolkit).
However, my question is plattform agnostic:
*Given:*
I have generated a mesh as a list of triangular faces form a model constructed through my application. Each Triangle is defined through three vertexes, which consist of thre... | 2010/03/09 | [
"https://Stackoverflow.com/questions/2407451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264347/"
] | Three solutions. There are certainly others
1. Use a hash map. This will only work if "same" means exactly the same
2. Use a binary space partition to divide up the points
3. Use a regular grid to divide up your points.
In cases 2 and 3 if you want to specify some tolerance you will need to search more than one part ... | The common idea to get hash is to multiply each bitpattern of a float with a [prime](http://en.wikipedia.org/wiki/Prime_number) and add them together. Something like that:
```
unsigned int hash_point(float x, float y, float z)
{
unsigned int* px = (unsigned int*)&x;
unsigned int* py = (unsigned int*)&y;
unsig... |
2,407,451 | I am building a CAD-file converter on top of two libraries (Opencascade and DWF Toolkit).
However, my question is plattform agnostic:
*Given:*
I have generated a mesh as a list of triangular faces form a model constructed through my application. Each Triangle is defined through three vertexes, which consist of thre... | 2010/03/09 | [
"https://Stackoverflow.com/questions/2407451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264347/"
] | Dump all the vertices in an array, then do `unique(sort(array))`. This should be O(k n log(n)), where k is the average number of triangles that share a vertex, usually k<7.
The only caveat I can think of is that your `unique` function should be able to take a pointer to a comparison function, since you probably want t... | Three solutions. There are certainly others
1. Use a hash map. This will only work if "same" means exactly the same
2. Use a binary space partition to divide up the points
3. Use a regular grid to divide up your points.
In cases 2 and 3 if you want to specify some tolerance you will need to search more than one part ... |
2,407,451 | I am building a CAD-file converter on top of two libraries (Opencascade and DWF Toolkit).
However, my question is plattform agnostic:
*Given:*
I have generated a mesh as a list of triangular faces form a model constructed through my application. Each Triangle is defined through three vertexes, which consist of thre... | 2010/03/09 | [
"https://Stackoverflow.com/questions/2407451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264347/"
] | Dump all the vertices in an array, then do `unique(sort(array))`. This should be O(k n log(n)), where k is the average number of triangles that share a vertex, usually k<7.
The only caveat I can think of is that your `unique` function should be able to take a pointer to a comparison function, since you probably want t... | The common idea to get hash is to multiply each bitpattern of a float with a [prime](http://en.wikipedia.org/wiki/Prime_number) and add them together. Something like that:
```
unsigned int hash_point(float x, float y, float z)
{
unsigned int* px = (unsigned int*)&x;
unsigned int* py = (unsigned int*)&y;
unsig... |
47,543,990 | I have an input and when the "enter" key is pressed, using "onKeyPress" I want to set some state. What it does is update the languages array on the state by adding in the new input value.
The functionality works, but the test fails. Here is my code.
This is the function that gets called when "onKeyPress" gets called.... | 2017/11/29 | [
"https://Stackoverflow.com/questions/47543990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7874233/"
] | You can use `preg_match_all` combined with the following expression to achieve what you want:
```
/(?(?=^).*?propertyComplexity(?=(?:\/[^\/]+)*\/?$)|\G)\/\K([^\/]+)/
```
The '\G' assertion matches at the first position in the subject, which in this case effectively means that it matches at the position where the las... | Here's one solution that combines a regex with `explode()`, as I'm pretty sure it's not possible to separately capture (or count) repeating groups, with PCRE.
The regex pattern expects any `/`-delimited segment after `/propertyComplexity` (I've prepended the slash for a little more rigor) to be non-empty and so allows... |
8,235,597 | In Haskell (F#, Ocaml, and others), I can do this:
```
sign x | x > 0 = 1
| x == 0 = 0
| x < 0 = -1
```
Which calculates the sign of a given integer.
This can concisely express certain logic flows; I've encountered one of these flows in Perl.
Right now what I am doing i... | 2011/11/22 | [
"https://Stackoverflow.com/questions/8235597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26227/"
] | Here's one other possible approach, which is still a bit wordy, but perhaps reflects the flow better. (In the book Perl Best Practices, the author suggests mostly avoiding the postfix form of `if` because you need to scan all the way to the right to understand what is going on.) You could add parentheses if that helps ... | For what it's worth, Perl 5.10 or later gives you:
[given](http://perldoc.perl.org/functions/given.html)
...which would allow:
```
...
use feature qw( switch say);
use Carp;
sub frobnicator {
my $frob = shift;
given ($frob) {
when ('Foomaticator') {
return q(foo);
}
when (... |
8,235,597 | In Haskell (F#, Ocaml, and others), I can do this:
```
sign x | x > 0 = 1
| x == 0 = 0
| x < 0 = -1
```
Which calculates the sign of a given integer.
This can concisely express certain logic flows; I've encountered one of these flows in Perl.
Right now what I am doing i... | 2011/11/22 | [
"https://Stackoverflow.com/questions/8235597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26227/"
] | Here's one other possible approach, which is still a bit wordy, but perhaps reflects the flow better. (In the book Perl Best Practices, the author suggests mostly avoiding the postfix form of `if` because you need to scan all the way to the right to understand what is going on.) You could add parentheses if that helps ... | You could use the conditional operator:
```
sub frobnicator {
my $frob = shift;
return $frob eq 'Foomaticator' ? 'foo' :
$frob eq 'Barmaticator' ? 'bar' :
croak("Unable to frob legit value: $frob received");
}
```
It turns your original example into something like:
```
sub sign {
my $x = shi... |
8,235,597 | In Haskell (F#, Ocaml, and others), I can do this:
```
sign x | x > 0 = 1
| x == 0 = 0
| x < 0 = -1
```
Which calculates the sign of a given integer.
This can concisely express certain logic flows; I've encountered one of these flows in Perl.
Right now what I am doing i... | 2011/11/22 | [
"https://Stackoverflow.com/questions/8235597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26227/"
] | Here's one other possible approach, which is still a bit wordy, but perhaps reflects the flow better. (In the book Perl Best Practices, the author suggests mostly avoiding the postfix form of `if` because you need to scan all the way to the right to understand what is going on.) You could add parentheses if that helps ... | ```
sub sign {
my $x = shift;
return $x <=> 0;
}
```
Expressive? If you know what the ["spaceship" operator](http://perldoc.perl.org/perlop.html#Equality-Operators) does, yes. If not, not so much. How expressive a piece of perl code feels to you is entirely dependent on your familiarity with perl, I would sa... |
12,496 | Almost all WWII movies depicts Nazi officers and soldiers as well-dressed and handsome.
On the other hand, allied officers and soldiers are always shown wearing torn uniforms, etc.
Why? | 2013/07/14 | [
"https://movies.stackexchange.com/questions/12496",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/-1/"
] | My answer here is to the point of history and not movie making ... Please remember what Hitler was trying to build and exemplify, that of the "master race". His Nazis would have fit that mold to a tee. Blond, blue eyed, blah, blah, blah. You get the picture. This may now be a bit over done in movies, but it is what it ... | @Paulster2 well you have a point, which is true. The 1st reason is that half of the time these movies are about what they did rather about the war so mostly they were captors of some people or whatever the situation was germans were in much safer locations. The 2nd reason is the color of the uniforms. Allied uniforms w... |
33,796,287 | How can I get respon JSON dictionaries from server with POST:
```
import json
import requests
url = 'http://apiurl.com'
parameters = {'code':1,
'user': 'username',
'password': 'password'
}
headers = {'content-type': 'application/json'}
response = requests.post(url, ... | 2015/11/19 | [
"https://Stackoverflow.com/questions/33796287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5579696/"
] | ```
response = requests.post(url, data=json.dumps(parameters), headers=headers)
print(response)
print(response.text)
``` | Since, you are going to receive a JSON object you can simply use [request's built-in JSON decoder](http://docs.python-requests.org/en/latest/user/quickstart/#json-response-content) Simply do:
```
j = response.json()
``` |
8,171,504 | I need to import different feeds at different times, and my plan is to set up separate scheduled tasks, i.e. one that runs weekly, one monthly and so on, with different arguments depending on which feeds should be run. My question is what the best practice is when doing that - should I check if the exe is still running... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8171504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324001/"
] | The width of the image MUST be [even](http://developer.android.com/reference/android/media/FaceDetector.html#FaceDetector%28int,%20int,%20int%29). | ```
Bitmap bitmap565 = bmp.copy(Bitmap.Config.RGB_565, true);
``` |
8,171,504 | I need to import different feeds at different times, and my plan is to set up separate scheduled tasks, i.e. one that runs weekly, one monthly and so on, with different arguments depending on which feeds should be run. My question is what the best practice is when doing that - should I check if the exe is still running... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8171504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324001/"
] | After a lot of searching,
You should put your images in **drawable-nodpi** folder. | ```
Bitmap bitmap565 = bmp.copy(Bitmap.Config.RGB_565, true);
``` |
8,171,504 | I need to import different feeds at different times, and my plan is to set up separate scheduled tasks, i.e. one that runs weekly, one monthly and so on, with different arguments depending on which feeds should be run. My question is what the best practice is when doing that - should I check if the exe is still running... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8171504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324001/"
] | The width of the image MUST be [even](http://developer.android.com/reference/android/media/FaceDetector.html#FaceDetector%28int,%20int,%20int%29). | After a lot of searching,
You should put your images in **drawable-nodpi** folder. |
8,171,504 | I need to import different feeds at different times, and my plan is to set up separate scheduled tasks, i.e. one that runs weekly, one monthly and so on, with different arguments depending on which feeds should be run. My question is what the best practice is when doing that - should I check if the exe is still running... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8171504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324001/"
] | The width of the image MUST be [even](http://developer.android.com/reference/android/media/FaceDetector.html#FaceDetector%28int,%20int,%20int%29). | As per the documentation of <http://developers.android.com> if the image **width** is not even then this exception occur.
For further detail check this link:
<http://developer.android.com/reference/android/media/FaceDetector.html> |
8,171,504 | I need to import different feeds at different times, and my plan is to set up separate scheduled tasks, i.e. one that runs weekly, one monthly and so on, with different arguments depending on which feeds should be run. My question is what the best practice is when doing that - should I check if the exe is still running... | 2011/11/17 | [
"https://Stackoverflow.com/questions/8171504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324001/"
] | After a lot of searching,
You should put your images in **drawable-nodpi** folder. | As per the documentation of <http://developers.android.com> if the image **width** is not even then this exception occur.
For further detail check this link:
<http://developer.android.com/reference/android/media/FaceDetector.html> |
17,911,946 | my code works when i am not using a proxy but i want to use a proxy so that my real IP is not revealed when sending a request. Whenever i try to run my program it gives me an error saying "The remote server returned an error: (417) Expectation Failed." and it is pointing at "response = CType(request.GetResponse(), Http... | 2013/07/28 | [
"https://Stackoverflow.com/questions/17911946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2567566/"
] | ```
<Runtime.InteropServices.DllImport("wininet.dll", SetLastError:=True)> _
Private Shared Function InternetSetOption(ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean
End Function
Public Structure Struct_INTERNET_PROXY_INFO
Public dwAcce... | ```
Dim myProxy As New WebProxy("173.234.249.68:8800", true)
Dim request As HttpWebRequest
Dim response As HttpWebResponse
Dim tempCookies As New CookieContainer
request = CType(WebRequest.Create("http://samplewebsite.com"), HttpWebRequest)
request.Proxy = myProxy
reques... |
17,911,946 | my code works when i am not using a proxy but i want to use a proxy so that my real IP is not revealed when sending a request. Whenever i try to run my program it gives me an error saying "The remote server returned an error: (417) Expectation Failed." and it is pointing at "response = CType(request.GetResponse(), Http... | 2013/07/28 | [
"https://Stackoverflow.com/questions/17911946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2567566/"
] | ```
<Runtime.InteropServices.DllImport("wininet.dll", SetLastError:=True)> _
Private Shared Function InternetSetOption(ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean
End Function
Public Structure Struct_INTERNET_PROXY_INFO
Public dwAcce... | Cahnge the line:
```
Dim myProxy As New WebProxy("173.234.249.68", 8800)
```
To
```
Dim myProxy As New WebProxy("173.234.249.68:8800")
``` |
28,265,126 | I have an HTML form that a user can use to edit a row in a mysql database, the PHP script queries the database and then displays the current data in form. I have this working fine for text fields with something like:
```
Correct Answer:<input type="text" name="answer" value="<?php echo $row['CorrectAnswer']; ?>"><br>
... | 2015/02/01 | [
"https://Stackoverflow.com/questions/28265126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972388/"
] | You can add an `if` clause on your `option` creation that will at the `selected` attribute if needed.
```
<?php $options = array(
"Hazard Awareness" => hazardawareness,
"Observation" => observation,
"Insurance" => insurance,
"Attitude" => attitude ... | I think this will help you to do the work using less code:
```
<?php
$options = array(
"Hazard Awareness" => hazardawareness,
"Observation" => observation,
"Insurance" => insurance,
"Attitude" => attitude
);
echo 'Category: <select name="category">';
foreach($options as $display => $value) {
if ($row['Category'] == t... |
25,464,105 | I have written the following query:
```
DECLARE @countryCode TINYINT
SET @countryCode = 1;
SELECT
DivingSite.SiteCode,
DATEPART(Month, divingDate) AS 'month number' ,
COUNT (divingNo) AS 'number of dives in month'
FROM
DivingSite
INNER JOIN
tblDiving ON DivingSite.SiteCode = tblDiving.SiteCode... | 2014/08/23 | [
"https://Stackoverflow.com/questions/25464105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2755993/"
] | Try this - use a CTE (Common Table Expression) with a `ROW_NUMBER` function that "partitions" your data by the `siteCode` and numbers each row for a single `siteCode` starting at one - with the one with the highest number of dives having `RowNum = 1` and any others having higher row numbers.
By selecting only those ro... | You could create a query on top of the one you already have, like so:
```
select
DivingSite.SiteCode,
DATEPART(Month, divingDate) as 'month number' ,
count (divingNo) as 'number of dives in month'
into #dives
from DivingSite
inner join tblDiving on DivingSite.SiteCode = t... |
33,320,523 | I'm trying to write a function that takes a list and an element to look for in that list and returns true if the element is in the list and false otherwise. I want to use List.Fold to make the function much shorter. Right now it looks like this
```
let isInList(elementToFind, listToCheck) =
List.fold(fun(a, b) ->... | 2015/10/24 | [
"https://Stackoverflow.com/questions/33320523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2757398/"
] | You can implement this using List.fold as follows:
```
let isInList elementToFind listToCheck =
List.fold(fun acc x -> acc || x = elementToFind) false listToCheck
```
Example:
```
let x = [1;2;2;3]
let y = 4
let z = 2
isInList y x |> printfn "%A"
isInList z x |> printfn "%A"
```
Print:
```
false
true
```
... | Way too many parenthesis and comas in your code.
To declare a function that takes 2 parameters you should use
```
let f param1 param2 = ...
```
No parenthesis, no comas. If you define a function as
```
let f2 (param1, param2) = ...
```
you define a function that takes 1 argument, and this argument is a 2-elemen... |
33,320,523 | I'm trying to write a function that takes a list and an element to look for in that list and returns true if the element is in the list and false otherwise. I want to use List.Fold to make the function much shorter. Right now it looks like this
```
let isInList(elementToFind, listToCheck) =
List.fold(fun(a, b) ->... | 2015/10/24 | [
"https://Stackoverflow.com/questions/33320523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2757398/"
] | You can implement this using List.fold as follows:
```
let isInList elementToFind listToCheck =
List.fold(fun acc x -> acc || x = elementToFind) false listToCheck
```
Example:
```
let x = [1;2;2;3]
let y = 4
let z = 2
isInList y x |> printfn "%A"
isInList z x |> printfn "%A"
```
Print:
```
false
true
```
... | When performance is needed you better use tryFind, because fold is non-short-circuit.
That means if the list is 1 Mio. elements long and the first element is searched, the fold runs until the end of the list.
```
let isInList elementToFind listToCheck =
List.tryFind ((=) elementToFind) listToCheck
let x = [1;2;2... |
33,320,523 | I'm trying to write a function that takes a list and an element to look for in that list and returns true if the element is in the list and false otherwise. I want to use List.Fold to make the function much shorter. Right now it looks like this
```
let isInList(elementToFind, listToCheck) =
List.fold(fun(a, b) ->... | 2015/10/24 | [
"https://Stackoverflow.com/questions/33320523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2757398/"
] | Way too many parenthesis and comas in your code.
To declare a function that takes 2 parameters you should use
```
let f param1 param2 = ...
```
No parenthesis, no comas. If you define a function as
```
let f2 (param1, param2) = ...
```
you define a function that takes 1 argument, and this argument is a 2-elemen... | When performance is needed you better use tryFind, because fold is non-short-circuit.
That means if the list is 1 Mio. elements long and the first element is searched, the fold runs until the end of the list.
```
let isInList elementToFind listToCheck =
List.tryFind ((=) elementToFind) listToCheck
let x = [1;2;2... |
33,342,582 | I have table for tasks list.
I usually use linux time to set the dates but this time I tried DATE type.
how can I select all the task that their targetDate is in 2 days or less?
I know how to do it in the SQL query:
```
SELECT * FROM tasks
WHERE `targetDate` >= CURDATE()
AND `targetDate` < DATE_ADD(CURDATE(), ... | 2015/10/26 | [
"https://Stackoverflow.com/questions/33342582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4545846/"
] | ```
SELECT * FROM tasks WHERE targetDate BETWEEN '2015-10-13' AND '2015-10-27'
```
OR
```
SELECT * FROM tasks WHERE DATE_FORMAT(targetDate,'%Y-%m-%d') BETWEEN '2015-10-13' AND '2015-10-27'
``` | your Date type in `SQL` is in `"YYYY-MM-DD"` format. So in your query, you have to give the `same format` to grab the data you wanted.
Hope that helps.. |
33,342,582 | I have table for tasks list.
I usually use linux time to set the dates but this time I tried DATE type.
how can I select all the task that their targetDate is in 2 days or less?
I know how to do it in the SQL query:
```
SELECT * FROM tasks
WHERE `targetDate` >= CURDATE()
AND `targetDate` < DATE_ADD(CURDATE(), ... | 2015/10/26 | [
"https://Stackoverflow.com/questions/33342582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4545846/"
] | ```
SELECT * FROM tasks WHERE targetDate BETWEEN '2015-10-13' AND '2015-10-27'
```
OR
```
SELECT * FROM tasks WHERE DATE_FORMAT(targetDate,'%Y-%m-%d') BETWEEN '2015-10-13' AND '2015-10-27'
``` | You can use `BETWEEN` CLAUSE in combination with date\_sub( now( ) , `INTERVAL 2 DAY ) AND NOW( )`
```
SELECT * FROM tasks
WHERE
targetDate BETWEEN date_sub( now( ) , INTERVAL 2 DAY ) AND NOW( )
``` |
33,342,582 | I have table for tasks list.
I usually use linux time to set the dates but this time I tried DATE type.
how can I select all the task that their targetDate is in 2 days or less?
I know how to do it in the SQL query:
```
SELECT * FROM tasks
WHERE `targetDate` >= CURDATE()
AND `targetDate` < DATE_ADD(CURDATE(), ... | 2015/10/26 | [
"https://Stackoverflow.com/questions/33342582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4545846/"
] | ```
SELECT * FROM tasks WHERE targetDate BETWEEN '2015-10-13' AND '2015-10-27'
```
OR
```
SELECT * FROM tasks WHERE DATE_FORMAT(targetDate,'%Y-%m-%d') BETWEEN '2015-10-13' AND '2015-10-27'
``` | use mysql `CURDATE()` or `INTERVAL`
```
SELECT * FROM tasks
WHERE
targetDate BETWEEN (CURDATE() - INTERVAL 2 DAY ) and CURDATE()
``` |
16,745,595 | I'm having trouble deploying to Heroku, I've installed postgresql but I don't think I've configured it properly. This may or may not be the problem, but I have a hunch it has something to do with it. please advice.
the git for the blog: <https://github.com/Apane/Blogit_blog>
Updated Heroku Logs
```
2013-05-25T02... | 2013/05/25 | [
"https://Stackoverflow.com/questions/16745595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975127/"
] | Have you run 'heroku run rake db:migrate'? It seems like Heroku doesn't see your User model, which means it might not yet be in the database.
Here's a similar question: [Heroku Postgres Error: PGError: ERROR: relation "organizations" does not exist (ActiveRecord::StatementInvalid)](https://stackoverflow.com/questions/... | Looks like you are using Webrick, I am pretty sure you should be using Thin for Heroku. Not sure if it will fix your problem though. |
16,745,595 | I'm having trouble deploying to Heroku, I've installed postgresql but I don't think I've configured it properly. This may or may not be the problem, but I have a hunch it has something to do with it. please advice.
the git for the blog: <https://github.com/Apane/Blogit_blog>
Updated Heroku Logs
```
2013-05-25T02... | 2013/05/25 | [
"https://Stackoverflow.com/questions/16745595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975127/"
] | Have you run 'heroku run rake db:migrate'? It seems like Heroku doesn't see your User model, which means it might not yet be in the database.
Here's a similar question: [Heroku Postgres Error: PGError: ERROR: relation "organizations" does not exist (ActiveRecord::StatementInvalid)](https://stackoverflow.com/questions/... | I noticed in your `Gemfile` you have a mistake with the indention of `end` in your `:production` group.
Change this
```
group :production do
gem 'pg'
end
```
to this
```
group :production do
gem 'pg'
end
```
Also, if you are using `sqlite` for development and `postgresql` for production and you are not su... |
16,745,595 | I'm having trouble deploying to Heroku, I've installed postgresql but I don't think I've configured it properly. This may or may not be the problem, but I have a hunch it has something to do with it. please advice.
the git for the blog: <https://github.com/Apane/Blogit_blog>
Updated Heroku Logs
```
2013-05-25T02... | 2013/05/25 | [
"https://Stackoverflow.com/questions/16745595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975127/"
] | As stated in the error logs, the problem is coming from
```
app/controllers/application_controller.rb:5:in `current_user'
```
which is
```
@current_user ||= User.first || User.create!(name: "APane")
```
You are trying to create a new row in the User table passing in a name attribute on the user table, but it doe... | Have you run 'heroku run rake db:migrate'? It seems like Heroku doesn't see your User model, which means it might not yet be in the database.
Here's a similar question: [Heroku Postgres Error: PGError: ERROR: relation "organizations" does not exist (ActiveRecord::StatementInvalid)](https://stackoverflow.com/questions/... |
16,745,595 | I'm having trouble deploying to Heroku, I've installed postgresql but I don't think I've configured it properly. This may or may not be the problem, but I have a hunch it has something to do with it. please advice.
the git for the blog: <https://github.com/Apane/Blogit_blog>
Updated Heroku Logs
```
2013-05-25T02... | 2013/05/25 | [
"https://Stackoverflow.com/questions/16745595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975127/"
] | As stated in the error logs, the problem is coming from
```
app/controllers/application_controller.rb:5:in `current_user'
```
which is
```
@current_user ||= User.first || User.create!(name: "APane")
```
You are trying to create a new row in the User table passing in a name attribute on the user table, but it doe... | Looks like you are using Webrick, I am pretty sure you should be using Thin for Heroku. Not sure if it will fix your problem though. |
16,745,595 | I'm having trouble deploying to Heroku, I've installed postgresql but I don't think I've configured it properly. This may or may not be the problem, but I have a hunch it has something to do with it. please advice.
the git for the blog: <https://github.com/Apane/Blogit_blog>
Updated Heroku Logs
```
2013-05-25T02... | 2013/05/25 | [
"https://Stackoverflow.com/questions/16745595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975127/"
] | As stated in the error logs, the problem is coming from
```
app/controllers/application_controller.rb:5:in `current_user'
```
which is
```
@current_user ||= User.first || User.create!(name: "APane")
```
You are trying to create a new row in the User table passing in a name attribute on the user table, but it doe... | I noticed in your `Gemfile` you have a mistake with the indention of `end` in your `:production` group.
Change this
```
group :production do
gem 'pg'
end
```
to this
```
group :production do
gem 'pg'
end
```
Also, if you are using `sqlite` for development and `postgresql` for production and you are not su... |
5,391,554 | I have the following problem: in index.php, I have set the variable $activelang. I
```
$activelang = active_language ();
echo $activelang; //works perfectly
```
Later in my index.php code, I include a new php file.
```
include ('myotherfile.php');
```
If I try to use $activelang in myotherfile.php, it does not... | 2011/03/22 | [
"https://Stackoverflow.com/questions/5391554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/345157/"
] | include should be used to include **files**, not some network resources.
if you bother to run **the code you posted here** you'll be surprized, as it will print $activelang all right. | When working with WordPress templates you should create functions in your functions.php file for handling includes and then call those functions in your templates.
So in functions.php you should have:
```
function myOtherFile() {
include('myotherfile.php');
}
```
And in index.php call myOtherFile()
Now, if y... |
8,894,955 | Libraries/Tools used:
1) Jasper Reports
2) iReport
3) Java
I've already generated some standard barcodes for my reports, but this time, I'm trying to generate a custom barcode, for which I've a font file custom-barcode.ttf. As of now, iReport supports 2 barcode libraries - Barcode4j and Barbecue, which don't support ... | 2012/01/17 | [
"https://Stackoverflow.com/questions/8894955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/401727/"
] | Just tried @mdahlman's answer and it worked. I generated the value `"CODE123"` using a [barcode39 font](http://www.barcodesinc.com/free-barcode-font/) (free) and Jaspersoft Barbecue. 
Setting the size is not very easy using the font but the result is the same. I ve... | Given that you have custom-barcode.ttf, it really can be treated as text. So your steps are like this:
1. Create a font extension in iReport for custom-barcode.ttf.
2. Create a Text Field in the report with a relevant expression.
3. Set the font for the Text Field to "custom-barcode" (or whatever you call your font ex... |
69,644,131 | Hi i want to wrap the content of a component with some specific html tag let say `button` for this example.
i have a function which dynamically returns a value which i use as a prop, based on that i want to wrap the content of a component.
i know i could have achieved this way too `<button><compA/></button>` it does ... | 2021/10/20 | [
"https://Stackoverflow.com/questions/69644131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10054910/"
] | This is a perfect example for render functions. Instead of using a template you can use a render function to render the template for you. [Read more about render functions](https://v2.vuejs.org/v2/guide/render-function.html)
```js
const localComponent = {
name:'first-comp',
props:['wrappwithbutton', 'text'],
method... | This is my idea, but I think the template should have a more concise way of writing
```js
const localComponent = {
name: "first-comp",
template: `
<template v-if="wrappwithbutton">
<button>
<div> {{text}}</div>
</button>
</template>
<template v-else>
<div> {{text}}</div>
<... |
37,621,882 | I run an apply-family function over a big dataset and so I wonder if there is a way to know how is going the job so far, how many elements got viewed so far, or something like this? | 2016/06/03 | [
"https://Stackoverflow.com/questions/37621882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4383566/"
] | You can consider creating a global counter, and specify when you want to print the progress, for example, you can print a notice whenever 10% of your data has been processed;
```
counter <- 0
data <- rnorm(100)
results <- sapply(data, function(x) {
counter <<- counter + 1;
if(coun... | You could add a print statement to the function you are using like this
```
apply(mtcars,2, function(i) {print(i[1])
mean(i)})
```
Isn't pretty but does what you want |
20,963,992 | I've gotten myself into a pickle, but perhaps there is still hope.
I've commented out the user "pi" while acting as root after typing the following:
nano etc/passwd
Saved and exited. Next I literally exit terminal. Now upon opening a new terminal window I get the following message:
I have no name!@raspberrypi ~ $... | 2014/01/07 | [
"https://Stackoverflow.com/questions/20963992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2416078/"
] | This is not a huge problem, since the file can be edited like any text document.
If you are at ssh and have root privileges, just nano /etc/passwd (i feel evil typing that haha), otherwise if there is another user with root privileges (other than pi) login in as them and edit the passwd file.
If there are no other ... | I solved it by uncommenting the line that begins with `#pi 1000 1000` (something like that) in the file passwd (access it by typing nano/etc/paswwd) by erasing the `#`, when I did that, everything returns to normality and I was enable to use sudo commands again. |
29,850,406 | How do I sort an associative array in bash?
For example, I have array in bash:
```
[0,0]="Max"
[0,1]="25"
[1,0]="Vladimir"
[1,1]="0"
[2,0]="Mayki"
[2,1]="50"
```
Output must be:
1. Mayki - 50
2. Max - 25
3. Vladimir - 0
I don't know how sort this array.
Additional Info: I parse assoc array from text file ("log... | 2015/04/24 | [
"https://Stackoverflow.com/questions/29850406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4829089/"
] | There are a couple of approaches to this problem. One of the easiest is probably to read the pairs of strings into an indexed array and then reverse numeric sort on the number field:
```
#!/bin/bash
declare -A arr
declare -a sa
arr[0,0]="Max"
arr[0,1]="25"
arr[1,0]="Vladimir"
arr[1,1]="0"
arr[2,0]="Mayki"
arr[2,1]="... | I'd probably switch to Perl for such a complicated task, even if it's still doable in bash:
```
#!/bin/bash
declare -A arr
arr=([0,0]="Max"
[0,1]="25"
[1,0]="Vladimir"
[1,1]="0"
[2,0]="Mayki"
[2,1]="50"
[10,0]=Ivan
[10,1]=10
)
indices=( $( (IFS=$'\n' ; echo "${!arr[*]}") | grep... |
50,686,943 | I found useful article about uploading image using Active Storage in activeadmin: <https://medium.com/@maris.cilitis/using-ruby-on-rails-active-storage-image-uploads-for-active-admin-backed-resources-5638a9ca0b46>
But how to upload multiple images in activeadmin with Active Storage the same way? | 2018/06/04 | [
"https://Stackoverflow.com/questions/50686943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6613717/"
] | You just need do some changes
model:
```
has_many_attached :images
```
instead of
```
has_one_attached :image
```
activeadmin:
```
permit_params images: []
form do |f|
f.inputs do
f.input :images, as: :file, input_html: { multiple: true }
end
end
```
and you'll can choose many files to upload | This works for me, upload and show multiple images in active\_admin using active storage.
```
ActiveAdmin.register Post do
permit_params :content, :published, :user_id, :images => []
form html: { multipart: true } do |f|
f.inputs "Publication" do
f.input :user
f.input :content
f.input :publ... |
46,617,582 | I tried to use aws-sdk + Paperclip gems with Ruby On Rails to use DigitalOcean Spaces to upload files
The problem i have is the result of configuration, i get "{name\_buncket}.s3.nyc3.amazonaws.com" instead of "{name\_buncket}.s3.nyc3.digitaloceanspaces.com", that last is the correct result to acces to DigitalOcean Sp... | 2017/10/07 | [
"https://Stackoverflow.com/questions/46617582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8299929/"
] | I think you're out of luck at the moment, although not for the hostname problem you're currently having.
The `s3_host_name` key should be outside of your `s3_credentials` block. If you change your configuration to this:
```
config.paperclip_defaults = {
storage: :s3,
url: '.....',
s3_region: 'nyc3',
s3_creden... | I started the ticket for Paperclip and have one with Digital Ocean as well with no reply yet. The above example that drosboro entered should work in theory but it does not. Specifying s3\_host\_name does nothing and shows as the host name specified in the original post, though i do agree the issue must lie with a authe... |
46,617,582 | I tried to use aws-sdk + Paperclip gems with Ruby On Rails to use DigitalOcean Spaces to upload files
The problem i have is the result of configuration, i get "{name\_buncket}.s3.nyc3.amazonaws.com" instead of "{name\_buncket}.s3.nyc3.digitaloceanspaces.com", that last is the correct result to acces to DigitalOcean Sp... | 2017/10/07 | [
"https://Stackoverflow.com/questions/46617582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8299929/"
] | In addition to setting `s3_host_name`, you'll also need to configure the `endpoint` used by the AWS SDK. Paperclip does not expose this directly, but it can be set through `s3_options` I am able to successfully use Paperclip with Spaces with the following config, where the env variable `S3_HOST_NAME` is set to `nyc3.di... | I think you're out of luck at the moment, although not for the hostname problem you're currently having.
The `s3_host_name` key should be outside of your `s3_credentials` block. If you change your configuration to this:
```
config.paperclip_defaults = {
storage: :s3,
url: '.....',
s3_region: 'nyc3',
s3_creden... |
46,617,582 | I tried to use aws-sdk + Paperclip gems with Ruby On Rails to use DigitalOcean Spaces to upload files
The problem i have is the result of configuration, i get "{name\_buncket}.s3.nyc3.amazonaws.com" instead of "{name\_buncket}.s3.nyc3.digitaloceanspaces.com", that last is the correct result to acces to DigitalOcean Sp... | 2017/10/07 | [
"https://Stackoverflow.com/questions/46617582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8299929/"
] | In addition to setting `s3_host_name`, you'll also need to configure the `endpoint` used by the AWS SDK. Paperclip does not expose this directly, but it can be set through `s3_options` I am able to successfully use Paperclip with Spaces with the following config, where the env variable `S3_HOST_NAME` is set to `nyc3.di... | I started the ticket for Paperclip and have one with Digital Ocean as well with no reply yet. The above example that drosboro entered should work in theory but it does not. Specifying s3\_host\_name does nothing and shows as the host name specified in the original post, though i do agree the issue must lie with a authe... |
61,746,709 | I'm pretty new of RN but I don't really understand Promises with async.
I got how works but I don't use them correctly cause they don't work in my code.
Example
```js
const getAnimationTime = () => {
let res = meditationTime;
return new Promise(resolve => resolve(res));
};
```
and then:
```js
useEffect(() => ... | 2020/05/12 | [
"https://Stackoverflow.com/questions/61746709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12553215/"
] | Use [`DataFrame.cumsum`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.cumsum.html), compare if greater like `0` and convert mask to `0,1` value by [`DataFrame.astype`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.astype.html):
```
df = df.cumsum(axis=1).gt(0)... | Assuming that the number of columns is reasonably small, I would iterate over the columns:
```
for col in reversed(df.columns[1:-1]):
df.loc[df[col]==1, col:] = 1
```
it gives as expected:
```
Index Day1 Day2 Day3 Day4
0 1 0 1 1 1
1 2 1 1 1 1
2 3 0 0... |
61,746,709 | I'm pretty new of RN but I don't really understand Promises with async.
I got how works but I don't use them correctly cause they don't work in my code.
Example
```js
const getAnimationTime = () => {
let res = meditationTime;
return new Promise(resolve => resolve(res));
};
```
and then:
```js
useEffect(() => ... | 2020/05/12 | [
"https://Stackoverflow.com/questions/61746709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12553215/"
] | Use [`DataFrame.cumsum`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.cumsum.html), compare if greater like `0` and convert mask to `0,1` value by [`DataFrame.astype`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.astype.html):
```
df = df.cumsum(axis=1).gt(0)... | Use Pandas Dataframe .transform() method. Check for membership in the row and replace.
```
df.transform(lambda row: [1]*4 if 1 in row.values else row, axis=1)
``` |
3,139,189 | in objc.h , there is definition for Class
```
typedef struct objc_class *Class;
typedef struct objc_object {
Class isa;
} *id;
```
Case : use Class in NSObject :
```
/*************** Basic protocols ***************/
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (NSUInteger)hash;
- (Class)superclass;
- (C... | 2010/06/29 | [
"https://Stackoverflow.com/questions/3139189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338204/"
] | This sets the French option:
```
$('.goog-te-combo').val("fr");
``` | Without jQuery you need brute force
```
var country="fr";
//If you know the form and name of the select:
var sel = document.forms[0].sel1;
//If you know the id of the select:
var sel = document.getElementById('sel1');
// If you only know the className:
var sels = document.getElementsByTagName('select');
for (var i=0... |
3,139,189 | in objc.h , there is definition for Class
```
typedef struct objc_class *Class;
typedef struct objc_object {
Class isa;
} *id;
```
Case : use Class in NSObject :
```
/*************** Basic protocols ***************/
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (NSUInteger)hash;
- (Class)superclass;
- (C... | 2010/06/29 | [
"https://Stackoverflow.com/questions/3139189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338204/"
] | This sets the French option:
```
$('.goog-te-combo').val("fr");
``` | The following snippet will also set the fr option:
```
$('option[value="fr"]').attr({selected: 'true'});
``` |
48,963,746 | I am trying to run a method in C# Interactive that return some data from local db using Entity Framework. But it return an error saying that the connection string named 'InteractiveConsoleDBEntities' could be found in the application config file.
I am using data base first.
I use the option "Initialize Interactive wit... | 2018/02/24 | [
"https://Stackoverflow.com/questions/48963746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4134790/"
] | You can use [`split()`](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/split) instead of `match()` providing both lengths in one regex:
```
(.)(..)?
```
*Optional quantifier is essential when string length is not even.*
JS Code:
```js
console.log(
'112213'.split(/(.)(..)?/)... | ```js
function myFunction() {
var text = document.getElementById("input").value;
console.clear()
var re = /(.)(.{2})/g;
var m;
var arr = [];
do {
m = re.exec(text);
if (m) {
arr.push(m[1], m[2]);
}
} while (m);
console.log(arr)
}
```
```html
<form action="javas... |
56,951,955 | I need to get a timestamp in resolution of microseconds. I found options like using timeval struct and calling gettimeofday. The problem is all structs have long variables in them and I can work only with 32 bit variables.
How can I get a timestamp (in c) using only 32 bit variables? | 2019/07/09 | [
"https://Stackoverflow.com/questions/56951955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2958571/"
] | *[This site](http://www.catb.org/esr/time-programming/)* is a very good reference for time and clock related programming in general, including function prototypes, struct definitions as well as programming examples that are relevant to your request. You should have a look.
There are several answers from *[here](https:... | If the `struct timeval` fields are in `long` integer format (which can be or cannot) in 32bit format, **is because you need it to be that size.** Let's do some analysis: I took this timestamp in NTP format, and converted it to `struct timeval` format (for a *now* timestamp) on my system:
```
ntpts.c:120:process: NTP(... |
58,248,821 | I have clicked countless of stackoverflow links similar to my question, but none of the answers is working for me.
<https://soundoftext.com/>
This site. I'm trying to download several audios at once by pressing each individual download button. Trying to do this in the console for chrome.
```js
$( ".card__actions a:c... | 2019/10/05 | [
"https://Stackoverflow.com/questions/58248821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8121387/"
] | Creator of Sound of Text here. I think you may have emailed me?
Any way, here is the javascript that works for me in Chrome. It opens a new tab for each mp3 file:
```
$('.sounds.grid').querySelectorAll('a[download]').forEach(a => window.open(a.href))
``` | Try creating new links and clicking them
```
buttons = document.getElementsByClassName('card__action')
function downloadURI(uri, name)
{
var link = document.createElement("a")
link.download = name
link.href = uri
setTimeout(()=>{
link.click()
},50)
}
for (let i=0;i<buttons.length; i++) {
... |
38,385,984 | The canonical way of using a `Selector` in java NIO is :
1. regist the a `ServerSocketChannel` with the `SelectionKey.OP_ACCEPT` event type .
2. invoke `select` method (which block the thread)in a loop method
3. then when a `OP_ACCEPT` event happened , and the relative `AcceptEventHandler` is invoked to accept a `Sock... | 2016/07/15 | [
"https://Stackoverflow.com/questions/38385984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2905284/"
] | First, **file** is a predefined package; please don't use it for a variable name, or you may have trouble getting to some of the facilities. Try **my\_file** or just the C-language **fp** (for "file pointer").
After you write new information to the file, your position pointer (bookmark) is likely at the end of the fil... | When it comes to reading and writing files in python, if you do not call the method `(filename).close()` after making a change to a file, it will not save anything to it because it thinks you're still a) writing to it or b) still reading it!
Hope this helps! |
3,358,770 | Some stated that python dictionary is thread safe. Does it mean I can or cannot modify the items in a dictionary while iterating over it? | 2010/07/29 | [
"https://Stackoverflow.com/questions/3358770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/388200/"
] | The two concepts are completely different. [Thread safety](http://en.wikipedia.org/wiki/Thread_safety) means that two threads cannot modify the same object at the same time, thereby leaving the system in an inconsistent state.
That said, you cannot modify a dictionary while iterating over it. See the [documentation.](... | No. Recent version of python will raise an exception if you try to iterate over a dictionary that has changed size between iterations.
```
>>> d={'one':1, 'two':2}
>>> for x in d:
... d['three']=3
... print x
...
two
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: dictionar... |
3,358,770 | Some stated that python dictionary is thread safe. Does it mean I can or cannot modify the items in a dictionary while iterating over it? | 2010/07/29 | [
"https://Stackoverflow.com/questions/3358770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/388200/"
] | The two concepts are completely different. [Thread safety](http://en.wikipedia.org/wiki/Thread_safety) means that two threads cannot modify the same object at the same time, thereby leaving the system in an inconsistent state.
That said, you cannot modify a dictionary while iterating over it. See the [documentation.](... | You cannot iterate over a dictionary if you **add** or **delete** elements in the another thread concurrently. You can get "RuntimeError: dictionary changed size during iteration" or "KeyError" errors.
See [**live example**](https://repl.it/@IvanErgunov/iteratedictthreadsafe-1) and you can play with it.
And yes, you ... |
3,358,770 | Some stated that python dictionary is thread safe. Does it mean I can or cannot modify the items in a dictionary while iterating over it? | 2010/07/29 | [
"https://Stackoverflow.com/questions/3358770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/388200/"
] | The other answers already correctly addressed what's apparently your actual question:
>
> Does it mean I can or cannot modified
> the items in a dictionary while
> iterating over it?
>
>
>
by explaining that thread safety has nothing to do with the issue, **and** in any case, no, you cannot modify a dict while ... | No. Recent version of python will raise an exception if you try to iterate over a dictionary that has changed size between iterations.
```
>>> d={'one':1, 'two':2}
>>> for x in d:
... d['three']=3
... print x
...
two
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: dictionar... |
3,358,770 | Some stated that python dictionary is thread safe. Does it mean I can or cannot modify the items in a dictionary while iterating over it? | 2010/07/29 | [
"https://Stackoverflow.com/questions/3358770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/388200/"
] | No. Recent version of python will raise an exception if you try to iterate over a dictionary that has changed size between iterations.
```
>>> d={'one':1, 'two':2}
>>> for x in d:
... d['three']=3
... print x
...
two
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: dictionar... | You cannot iterate over a dictionary if you **add** or **delete** elements in the another thread concurrently. You can get "RuntimeError: dictionary changed size during iteration" or "KeyError" errors.
See [**live example**](https://repl.it/@IvanErgunov/iteratedictthreadsafe-1) and you can play with it.
And yes, you ... |
3,358,770 | Some stated that python dictionary is thread safe. Does it mean I can or cannot modify the items in a dictionary while iterating over it? | 2010/07/29 | [
"https://Stackoverflow.com/questions/3358770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/388200/"
] | The other answers already correctly addressed what's apparently your actual question:
>
> Does it mean I can or cannot modified
> the items in a dictionary while
> iterating over it?
>
>
>
by explaining that thread safety has nothing to do with the issue, **and** in any case, no, you cannot modify a dict while ... | You cannot iterate over a dictionary if you **add** or **delete** elements in the another thread concurrently. You can get "RuntimeError: dictionary changed size during iteration" or "KeyError" errors.
See [**live example**](https://repl.it/@IvanErgunov/iteratedictthreadsafe-1) and you can play with it.
And yes, you ... |
4,146,250 | I know that the integral of
$1/x^2$ is $(-1/x +C)$
Can we split $(1/x^2)$ as $(1/x)(1/x)$ and say that the integral of $(1/x^2)$ is $\ln x\cdot\ln x$?
PS: I am new to high school. And this is my first question on Stack Exchange. | 2021/05/21 | [
"https://math.stackexchange.com/questions/4146250",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/926572/"
] | It is good to ask no problem. The integral behaves nicely with addition and subtraction , I mean, if $\int f(x) dx$ and $\int g(x) dx$ exist then $$\int(f(x)+g(x) dx=\int f(x) dx+\int g(x) dx$$ The same for subtraction. But in general , we can NOT say $$\int f(x) g(x) dx=\int f(x) dx \times \int g(x) dx$$
I hope this h... | If you know how to differentiate a product you will know that $(fg)'=f'g+fg'$ (where $f'$ is the derivative of $f$). Set $h=f'$ so that $f=\int h dx $.
Then $(fg)'=hg+fg'$ and $$\int hg dx=\int\left((fg)'-fg'\right)dx=fg-\int(fg')dx$$which is the formula for integration by parts.
---
Because I began from the derivat... |
33,287,147 | Iam trying to make a regular UILocalNotification with default sound
this is my function
```
func makeLocalNotificationForNow(str : String , id : String)
{
let notification = UILocalNotification()
notification.alertBody = str // text that will be displayed in the notification
notification.alertAction = "open" // te... | 2015/10/22 | [
"https://Stackoverflow.com/questions/33287147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3703910/"
] | I always love a question where the answer is Aggregate.
```
var result = data.Aggregate(
// base object to store
new { A = 0, CM = 0, CO = 0, O = 0},
// add in an element
(a,d) => {
switch(d.sum)
{
case "A & E FEE":
a.A += d.Account;
break;
case "CM... | This produced the results I was looking for
```
var accounts = new List<string>()
{
"A & E FEE",
"cm fee",
"contract value",
"overhead"
};
var commission = ... |
46,928,286 | I'm using Apple's Core ML to visually recognize items in an image but it's returning incorrect answers sometimes identifying shoes as a knife etc. Is there a way to provide feedback about CoreML and hopefully guide it towards correctly identifying the items in an image? | 2017/10/25 | [
"https://Stackoverflow.com/questions/46928286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You're probably giving the Core ML model inputs that it does not expect. I wrote a blog post about the most common mistakes: <http://machinethink.net/blog/help-core-ml-gives-wrong-output/> | I would open a feedback ticket at <https://developer.apple.com/bug-reporting/>
Apple is really glad to get devs feedback. Try to detail yours as deeply as possible :)
EDIT : I would also suggest that you try another CoreML model ! I had a few tries with Inception V3 which worked like a charm with my apps. <https://de... |
4,631,474 | This website wants to run the following add-on: Adobe Flash Player from ...
why would i be getting this if i am not running any flash on my page?? thanks | 2011/01/08 | [
"https://Stackoverflow.com/questions/4631474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/313565/"
] | So this is caused when you have two namespaces that contain Types with the same name within a single piece of code.
So this section
```
using Stream = System.IO.MemoryStream;
LoadImageFromDB(int ID, ref Stream streamReturnVal);
```
should explicitly define what kind of `Stream` is being passed.
It should probably ... | Try moving the `using Stream = System.IO.MemoryStream` is inside your namespace declaration. |
4,631,474 | This website wants to run the following add-on: Adobe Flash Player from ...
why would i be getting this if i am not running any flash on my page?? thanks | 2011/01/08 | [
"https://Stackoverflow.com/questions/4631474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/313565/"
] | So this is caused when you have two namespaces that contain Types with the same name within a single piece of code.
So this section
```
using Stream = System.IO.MemoryStream;
LoadImageFromDB(int ID, ref Stream streamReturnVal);
```
should explicitly define what kind of `Stream` is being passed.
It should probably ... | Do you have using WebReference? That may create a problem. |
493,007 | [According to Wikipedia](https://en.wikipedia.org/wiki/Antithesis):
>
> An antithesis must always contain two ideas within one statement
>
>
>
A similar effect (parallelism emphasizing opposition of ideas) can be created in which the first element is implied by some famous phrase that is so well known that it can... | 2019/04/08 | [
"https://english.stackexchange.com/questions/493007",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/343134/"
] | I think there are a few words that could be used, depending on how the sentence is changed.
A **parody**, which as defined by Oxford Dictionary is, "imitation of the style of a particular writer, artist, or genre with deliberate exaggeration for comic effect." Though, in this case, it's not necessarily for comedic eff... | It is called "antithetic parallelism". The Bible offers many examples:
* A **wise son** maketh **a glad father**, but a **foolish son** is **the heaviness of his mother**.
Proverbs 10:1
* For the Lord knoweth **the way of the righteous**; but **the way of the ungodly** shall perish. Psalms 1:6
* **The fear of the Lord... |
493,007 | [According to Wikipedia](https://en.wikipedia.org/wiki/Antithesis):
>
> An antithesis must always contain two ideas within one statement
>
>
>
A similar effect (parallelism emphasizing opposition of ideas) can be created in which the first element is implied by some famous phrase that is so well known that it can... | 2019/04/08 | [
"https://english.stackexchange.com/questions/493007",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/343134/"
] | I think there are a few words that could be used, depending on how the sentence is changed.
A **parody**, which as defined by Oxford Dictionary is, "imitation of the style of a particular writer, artist, or genre with deliberate exaggeration for comic effect." Though, in this case, it's not necessarily for comedic eff... | I would recommend
***CACOGRAPHY***:
According to [Merriam-Webster's Dictionary:](https://www.merriam-webster.com/dictionary/cacography#note-1)
***cacography***
: bad spelling
As a stylistic device it's defined in [Wikipedia](https://en.m.wikipedia.org/wiki/Cacography?wprov=sfla1):
"***Cacography*** is deliberate ... |
76,987 | I can't remember for the life of me, and google isn't making it easy. e.g. the things labeled 24/40 etc., as in this picture:
[](https://i.stack.imgur.com/9SC81.jpg) | 2017/06/28 | [
"https://chemistry.stackexchange.com/questions/76987",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/17821/"
] | Those are called **Keck Clips**. 24/40 is the size of the joint. | They are called Keck clamps.
Here's a link to the page for ChemGlass: <http://www.chemglass.com/product_view.asp?pnr=CG-145> |
76,987 | I can't remember for the life of me, and google isn't making it easy. e.g. the things labeled 24/40 etc., as in this picture:
[](https://i.stack.imgur.com/9SC81.jpg) | 2017/06/28 | [
"https://chemistry.stackexchange.com/questions/76987",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/17821/"
] | Those are called **Keck Clips**. 24/40 is the size of the joint. | The clips are named after Hermann Keck - Chemistry World's Classic Kit columnist, Andrea Sella, spoke to him to get the story of the invention before he died a few years ago. <https://www.chemistryworld.com/opinion/classic-kit-keck-clip/3004921.article> |
76,987 | I can't remember for the life of me, and google isn't making it easy. e.g. the things labeled 24/40 etc., as in this picture:
[](https://i.stack.imgur.com/9SC81.jpg) | 2017/06/28 | [
"https://chemistry.stackexchange.com/questions/76987",
"https://chemistry.stackexchange.com",
"https://chemistry.stackexchange.com/users/17821/"
] | They are called Keck clamps.
Here's a link to the page for ChemGlass: <http://www.chemglass.com/product_view.asp?pnr=CG-145> | The clips are named after Hermann Keck - Chemistry World's Classic Kit columnist, Andrea Sella, spoke to him to get the story of the invention before he died a few years ago. <https://www.chemistryworld.com/opinion/classic-kit-keck-clip/3004921.article> |
17,729,021 | I have a view.py that looks like this:EDIT: NOW LOOKS LIKE THIS
```
def sessionscheduler(request):
c = connection.cursor()
c.execute("SELECT * FROM meter_schedule WHERE id = 1")
scheduleArray = []
for row in c.fetchall():
data = dict([('lastUpdate',row[1]), ('weekdaysOn',row[2]), ('... | 2013/07/18 | [
"https://Stackoverflow.com/questions/17729021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2453183/"
] | It is likely that your generated JavaScript is invalid. The simplest approach to exporting data from Python to JS is through JSON.
```
import json
def sessionscheduler(request):
latest_schedule_update = schedule.objects.all()
context = {'latest_schedule_update': json.dumps(latest_schedule_update)}
return r... | Don't mix `python` and `javascript` if you're templating a javascript file, make sure to put the values that comes from your server-side/django application in quotation marks. |
644,239 | I want to reproduce the following:
[](https://i.stack.imgur.com/mjpE6.png)
The inner min-Problem I make with a `\begin{equation}\begin{aligned} inner min-Problem \end{aligned}\end{equation}`
But I can't find a way to make brackets around it nor to w... | 2022/05/14 | [
"https://tex.stackexchange.com/questions/644239",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/270399/"
] | A solution I often use to draw phase diagrams is this one from [How to draw slope fields with all the possible solution curves in latex](https://tex.stackexchange.com/a/139078/140133), which I added my version with two functions in `quiver={ u={f(x,y)}, v={g(x,y)} ...}`.
It lets me generate local quivers from function... | I guess this could be made with `pgfplots`, using a variation of this code? (Note that it must be compiled with `lualatex`.)
```
\documentclass[border=0.2cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
view = {0}{90},
domain = -0.2:0.2,
... |
53,439,780 | I just wrote a code that draws a bordered square.
Given the square size of 5 for example, the code should print the following multi-line string:
```
#####
# #
# #
# #
#####
```
and I was wondering if there's anyway of simplifying this more and reduce time complexity.
```js
var BoxFiller = "#";
var BoxSize... | 2018/11/23 | [
"https://Stackoverflow.com/questions/53439780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1044161/"
] | This is an alternative which reduces Space and Time complexity.
*Time complexity: `O(n)`*
```js
var BoxFiller = "#";
var BoxSize = 8;
var Row = "";
var spaces = " ".repeat(BoxSize - 2);
var hashtags = BoxFiller.repeat(BoxSize);
function DrawSquare() {
console.log(hashtags);
for (var i = 1; i < BoxSize ... | Can use recursion
```js
let BoxFiller = "#";
let Row = "";
var spaces, hashtags;
function DrawRow(BoxSize, CurrPos) {
if(CurrPos >= BoxSize - 2)
return;
console.log(BoxFiller + spaces + BoxFiller);
DrawRow(BoxSize, CurrPos + 1);
}
function DrawSquare(BoxSize) {
spaces = " ".repeat(BoxSize - 2);
... |
53,439,780 | I just wrote a code that draws a bordered square.
Given the square size of 5 for example, the code should print the following multi-line string:
```
#####
# #
# #
# #
#####
```
and I was wondering if there's anyway of simplifying this more and reduce time complexity.
```js
var BoxFiller = "#";
var BoxSize... | 2018/11/23 | [
"https://Stackoverflow.com/questions/53439780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1044161/"
] | This is an alternative which reduces Space and Time complexity.
*Time complexity: `O(n)`*
```js
var BoxFiller = "#";
var BoxSize = 8;
var Row = "";
var spaces = " ".repeat(BoxSize - 2);
var hashtags = BoxFiller.repeat(BoxSize);
function DrawSquare() {
console.log(hashtags);
for (var i = 1; i < BoxSize ... | Slight alteration to @Ele's version that allows for both a size and a filler to be passed in.
```js
function DrawSquare(size, filler) {
const line = filler.repeat(size);
const mid = filler+' '.repeat(size-2)+filler;
let lines = [line];
for (var i = 1; i < size - 1; i++) {
lines.push(mid);
}
l... |
59,976,256 | So the little nav section is at the bottom and the other two sections are at the top of the footer.
Also how would I remove the tiny bit of white space left at the bottom of the page?
Thank you for any help, code is below.
```css
.footer{
display: flex;
justify-content: space-around;
flex-direction: row;
mar... | 2020/01/29 | [
"https://Stackoverflow.com/questions/59976256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12808925/"
] | You can use `align-items: center` to centralise your items, though I believe you're also looking for `flex-direction: column` to 'align' your items based on their HTML flow. This also has the effect of removing the whitespace at the bottom, as it stems from the `<li>`. This gives separation from the copyright, so I ass... | "In the center" meaning everything horizontally centered, below each other?
If yes, add `flex-direction: column;` to stack the items above each other and `align-items: center;` to center them horizontally:
```css
.footer {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-... |
59,976,256 | So the little nav section is at the bottom and the other two sections are at the top of the footer.
Also how would I remove the tiny bit of white space left at the bottom of the page?
Thank you for any help, code is below.
```css
.footer{
display: flex;
justify-content: space-around;
flex-direction: row;
mar... | 2020/01/29 | [
"https://Stackoverflow.com/questions/59976256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12808925/"
] | like so
```css
footer{
position:fixed;
bottom:0%;
left:20%;
right:20%;
}
/*style*/
footer{
background-color:black;
color:white;
}
```
```html
<footer><center><p>Copyright Company 2020 - your date </p> </center></footer>
```
note you can put anything inside the center tag to center it and then the left 20 ... | "In the center" meaning everything horizontally centered, below each other?
If yes, add `flex-direction: column;` to stack the items above each other and `align-items: center;` to center them horizontally:
```css
.footer {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-... |
59,976,256 | So the little nav section is at the bottom and the other two sections are at the top of the footer.
Also how would I remove the tiny bit of white space left at the bottom of the page?
Thank you for any help, code is below.
```css
.footer{
display: flex;
justify-content: space-around;
flex-direction: row;
mar... | 2020/01/29 | [
"https://Stackoverflow.com/questions/59976256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12808925/"
] | You can use `align-items: center` to centralise your items, though I believe you're also looking for `flex-direction: column` to 'align' your items based on their HTML flow. This also has the effect of removing the whitespace at the bottom, as it stems from the `<li>`. This gives separation from the copyright, so I ass... | Read my comments then see this:
```css
*{
box-sizing:border-box; padding:0; margin:0;
}
html,body{
width:100%; height:100%;
}
.footer{
width:100%; background:silver; text-align:center; padding:50px;
}
nav+div{
margin-top:7px;
}
<!-- begin snippet: js hide: false console: true babel: false -->
```
... |
59,976,256 | So the little nav section is at the bottom and the other two sections are at the top of the footer.
Also how would I remove the tiny bit of white space left at the bottom of the page?
Thank you for any help, code is below.
```css
.footer{
display: flex;
justify-content: space-around;
flex-direction: row;
mar... | 2020/01/29 | [
"https://Stackoverflow.com/questions/59976256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12808925/"
] | like so
```css
footer{
position:fixed;
bottom:0%;
left:20%;
right:20%;
}
/*style*/
footer{
background-color:black;
color:white;
}
```
```html
<footer><center><p>Copyright Company 2020 - your date </p> </center></footer>
```
note you can put anything inside the center tag to center it and then the left 20 ... | You can use `align-items: center` to centralise your items, though I believe you're also looking for `flex-direction: column` to 'align' your items based on their HTML flow. This also has the effect of removing the whitespace at the bottom, as it stems from the `<li>`. This gives separation from the copyright, so I ass... |
59,976,256 | So the little nav section is at the bottom and the other two sections are at the top of the footer.
Also how would I remove the tiny bit of white space left at the bottom of the page?
Thank you for any help, code is below.
```css
.footer{
display: flex;
justify-content: space-around;
flex-direction: row;
mar... | 2020/01/29 | [
"https://Stackoverflow.com/questions/59976256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12808925/"
] | You can use `align-items: center` to centralise your items, though I believe you're also looking for `flex-direction: column` to 'align' your items based on their HTML flow. This also has the effect of removing the whitespace at the bottom, as it stems from the `<li>`. This gives separation from the copyright, so I ass... | ```
footer{
position:fixed;
bottom:0%;
left:0%;
right:0%;
background-color:black;
color:white;
}
``` |
59,976,256 | So the little nav section is at the bottom and the other two sections are at the top of the footer.
Also how would I remove the tiny bit of white space left at the bottom of the page?
Thank you for any help, code is below.
```css
.footer{
display: flex;
justify-content: space-around;
flex-direction: row;
mar... | 2020/01/29 | [
"https://Stackoverflow.com/questions/59976256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12808925/"
] | You can use `align-items: center` to centralise your items, though I believe you're also looking for `flex-direction: column` to 'align' your items based on their HTML flow. This also has the effect of removing the whitespace at the bottom, as it stems from the `<li>`. This gives separation from the copyright, so I ass... | ```
.footer-nav {
margin: 10px auto;
float: left;
padding: 0;
}
.footer-nav li {
float: left;
padding: 0 10px;
list-style-type: none;
}
``` |
59,976,256 | So the little nav section is at the bottom and the other two sections are at the top of the footer.
Also how would I remove the tiny bit of white space left at the bottom of the page?
Thank you for any help, code is below.
```css
.footer{
display: flex;
justify-content: space-around;
flex-direction: row;
mar... | 2020/01/29 | [
"https://Stackoverflow.com/questions/59976256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12808925/"
] | like so
```css
footer{
position:fixed;
bottom:0%;
left:20%;
right:20%;
}
/*style*/
footer{
background-color:black;
color:white;
}
```
```html
<footer><center><p>Copyright Company 2020 - your date </p> </center></footer>
```
note you can put anything inside the center tag to center it and then the left 20 ... | Read my comments then see this:
```css
*{
box-sizing:border-box; padding:0; margin:0;
}
html,body{
width:100%; height:100%;
}
.footer{
width:100%; background:silver; text-align:center; padding:50px;
}
nav+div{
margin-top:7px;
}
<!-- begin snippet: js hide: false console: true babel: false -->
```
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.