qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
16,097,031 | Alright, let's say my MySQL table is set up with entries similar to:
```
id code sold
1 JKDA983J1KZMN49 0
2 JZMA093KANZB481 1
3 KZLMMA98309Z874 0
```
I'd like it to pick a random ID within the ranges already in the database (or just go from 1-X) and then just assign it to a variable for my own a... | 2013/04/19 | [
"https://Stackoverflow.com/questions/16097031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2297714/"
] | It seems that your codes are already random, so why not just take the first item; if you have many unsold records in your database, doing the typical `ORDER BY RAND()` will hurt the database performance.
```
SELECT *
FROM codes
WHERE sold = 0
LIMIT 1
FOR UPDATE;
```
I've also added `FOR UPDATE` to avoid race conditi... | Have you tried
```
SELECT * FROM myTable WHERE sold = 0 ORDER BY RAND() LIMIT 1
``` |
16,097,031 | Alright, let's say my MySQL table is set up with entries similar to:
```
id code sold
1 JKDA983J1KZMN49 0
2 JZMA093KANZB481 1
3 KZLMMA98309Z874 0
```
I'd like it to pick a random ID within the ranges already in the database (or just go from 1-X) and then just assign it to a variable for my own a... | 2013/04/19 | [
"https://Stackoverflow.com/questions/16097031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2297714/"
] | If you don't need the random, then don't use it. It can affect performance very negatively. Since you mentioned in your post that it wasn't necessary, I would recomment using Ezequiel's answer above and dropping the rand. See [Most Efficient Way To Retrieve MYSQL data in random order PHP](https://stackoverflow.com/ques... | Adding `ORDER BY RAND()` to the rest of your `SELECT` query is the most straightforward way to accomplish this. |
16,097,031 | Alright, let's say my MySQL table is set up with entries similar to:
```
id code sold
1 JKDA983J1KZMN49 0
2 JZMA093KANZB481 1
3 KZLMMA98309Z874 0
```
I'd like it to pick a random ID within the ranges already in the database (or just go from 1-X) and then just assign it to a variable for my own a... | 2013/04/19 | [
"https://Stackoverflow.com/questions/16097031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2297714/"
] | It seems that your codes are already random, so why not just take the first item; if you have many unsold records in your database, doing the typical `ORDER BY RAND()` will hurt the database performance.
```
SELECT *
FROM codes
WHERE sold = 0
LIMIT 1
FOR UPDATE;
```
I've also added `FOR UPDATE` to avoid race conditi... | Adding `ORDER BY RAND()` to the rest of your `SELECT` query is the most straightforward way to accomplish this. |
5,337,279 | The scenario is: I current have an old website that runs on PHP. Over time, that code has become hacked up and messy. It's due for a rewrite. However, I don't have time to do that rewrite yet. But I'd like to plan for it in the future.
What I need to do now is add a 'welcome' type page to the website. I'd like to code... | 2011/03/17 | [
"https://Stackoverflow.com/questions/5337279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/756597/"
] | You indicated in a comment that you're waiting for a `SocketException`. If so you need to catch `SocketTimeoutException` instead. For example, this code will output `timeout!` if you telnet to port 3434 and wait 3 seconds:
```
try {
ServerSocket ss = new ServerSocket(3434);
Socket socket = ss.accept();
soc... | Check the full thread dump for deadlock.
`ctrl + break` for windows.
`ctrl + |` or `kill -3 PID` for linux.
or Use `jvisualvm` or `jconsole` tools.
`timeout` value should be in milliseconds. |
51,438,410 | Can you guys tell me what is wrong here.
**RxJS**
[Jsfiddle Demo](http://jsfiddle.net/eqffs/1064/)
I was expecting the value will print only one time,but it is printing mulitple times
[](https://i.stack.imgur.com/a9VdN.png)
```
function Search(sel) {
let observab... | 2018/07/20 | [
"https://Stackoverflow.com/questions/51438410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/665864/"
] | Changed your code in fiddle [check here](http://jsfiddle.net/d2heokyn/). You don't need to subscribe to `input` event on every `keyup`. And `distinctUntilChanged` was getting event object which is different always. So it can't do anything. Before that event should be mapped to text, then it can be compared in `distinct... | Any time you `keyup` you run the function `Search(sel)`.
Any time you run the function `Search(sel)` you create an Observable and you subscribe to it.
So after **n** `keyup` events you end up having **n** active subscriptions to **n** different source Observables, and therefore you see **n** repetitions of the line l... |
31,541,329 | I've create one content view for get news from `JSon`but i want load randomly.
I have 2 method:
```
- (void)radioNews {}
- (void)topNews {}
```
now i want get random radioNews or topNews in my `viewDidLoad`
```
- (void)viewDidLoad {
[self radioNews];
}
```
this is correct only to load one meth... | 2015/07/21 | [
"https://Stackoverflow.com/questions/31541329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1071686/"
] | Try
```
- (void)viewDidLoad {
[super viewDidLoad];
NSInteger random = arc4random()%2;
if (random == 0) {
[self radioNews];
}else{
[self topNews];
}
}
``` | You can call a `selector` from a `NSString`
Start creating a `NSArray` with `NSString`
```
// Define an NSArray of NSString, where a single string is the method name
NSArray *methods = @[@"radioNews", @"topNews"];
// Retrieve a random index
NSUInteger index = arc4random()%methods.count;
// You can use objectAtIndex wi... |
16,749,354 | I really new to java and I've Googled this in every possible phrase i know how.
So I have a table made of 36 rows and 12 columns, I've been trying to write a method that will delete the a row when it becomes full and then move everything down one, I figured I could use a count to see if all spaces add up to 12 then d... | 2013/05/25 | [
"https://Stackoverflow.com/questions/16749354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2420175/"
] | >
> since the size of union is the largest data member size
>
>
>
That need not be true. Consider
```
union Pad {
char arr[sizeof (double) + 1];
double d;
};
```
The largest member of that union is `arr`. But usually, a `double` will be aligned on a multiple of four or eight bytes (depends on architectu... | Union when we use with primitive types inside it
```
union
{
char c;
int x;
}
```
It seems like it doesn't use padding because the largest size data is anyway is aligned to boundary.
But when we nest a structure within union it does.
```
union u
{
struct ss
{
char s;
... |
9,915,157 | I'm trying to pick out the word/phrase (wrapped in hashtags) after a certain string. For instance:
>
> This is an example paragraph and I am trying to get the word/phrase after the artist name which is in hash tags, such as @calvinharris #feel so close#.
>
>
>
Now, I have been able to successfully grab all @word... | 2012/03/28 | [
"https://Stackoverflow.com/questions/9915157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/255109/"
] | Try the following regexp:
```
^@(.+)#(.+)#$
```
And if you want to remove spaces
```
^@(.+)\S*#(.+)\S*#$
```
And if you want to trim a lot
```
^@\S*(.+)\S*#\S*(.+)\S*#$
```
And you are not sure there is hashtag (or wathever it is called)
```
^@\S*(.+)\S*(#\S*(.+)\S*#)?$
``` | This should do the trick.
```
preg_match_all('/@(\w+)\s?(?:#([^#]+)#)?/', $string, $matches);
```
`$matches[1]` will contain the "artist name"
`$matches[2]` will contain the optional phrase |
9,915,157 | I'm trying to pick out the word/phrase (wrapped in hashtags) after a certain string. For instance:
>
> This is an example paragraph and I am trying to get the word/phrase after the artist name which is in hash tags, such as @calvinharris #feel so close#.
>
>
>
Now, I have been able to successfully grab all @word... | 2012/03/28 | [
"https://Stackoverflow.com/questions/9915157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/255109/"
] | Try the following regexp:
```
^@(.+)#(.+)#$
```
And if you want to remove spaces
```
^@(.+)\S*#(.+)\S*#$
```
And if you want to trim a lot
```
^@\S*(.+)\S*#\S*(.+)\S*#$
```
And you are not sure there is hashtag (or wathever it is called)
```
^@\S*(.+)\S*(#\S*(.+)\S*#)?$
``` | Remember to make your character sets as specific as possible:
```
preg_match_all('!@([^\s]+) #([^#]+)#!U', $string, $matches)
```
`[^\s]+` will match up to the first white space, `[^#]+` will match up to the closing hash tag. |
9,915,157 | I'm trying to pick out the word/phrase (wrapped in hashtags) after a certain string. For instance:
>
> This is an example paragraph and I am trying to get the word/phrase after the artist name which is in hash tags, such as @calvinharris #feel so close#.
>
>
>
Now, I have been able to successfully grab all @word... | 2012/03/28 | [
"https://Stackoverflow.com/questions/9915157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/255109/"
] | Try the following regexp:
```
^@(.+)#(.+)#$
```
And if you want to remove spaces
```
^@(.+)\S*#(.+)\S*#$
```
And if you want to trim a lot
```
^@\S*(.+)\S*#\S*(.+)\S*#$
```
And you are not sure there is hashtag (or wathever it is called)
```
^@\S*(.+)\S*(#\S*(.+)\S*#)?$
``` | This seems to do the trick (no / / delimiters included):
```
@(\S+)\s+#(.+?)#
```
"1 or more non-whitespace, followed by 1 or more whitespace, followed by some characters enclosed by #"
Note the use of the non-greedy operator (?) for the text inside the hash.
EDIT:
after `preg_match_all`, $match[1] will correspon... |
9,915,157 | I'm trying to pick out the word/phrase (wrapped in hashtags) after a certain string. For instance:
>
> This is an example paragraph and I am trying to get the word/phrase after the artist name which is in hash tags, such as @calvinharris #feel so close#.
>
>
>
Now, I have been able to successfully grab all @word... | 2012/03/28 | [
"https://Stackoverflow.com/questions/9915157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/255109/"
] | Try the following regexp:
```
^@(.+)#(.+)#$
```
And if you want to remove spaces
```
^@(.+)\S*#(.+)\S*#$
```
And if you want to trim a lot
```
^@\S*(.+)\S*#\S*(.+)\S*#$
```
And you are not sure there is hashtag (or wathever it is called)
```
^@\S*(.+)\S*(#\S*(.+)\S*#)?$
``` | You can easily make this by using groups and preg\_match.
```
$name = "calvinharris";
preg_match('/@'.$name.' #([\w\s]+)#/', "This is an example paragraph and I am trying to get the word/phrase after the artist name which is in hash tags, such as @calvinharris #feel so close#. ", $match);
echo '$match = ' . $match[1];... |
64,192,452 | I'm having issues with the below code displays Thursday as the dayOfTheWeek regardless of the date. Any ideas where I've gone wrong with this?
```java
public void CreatePlan() {
editPlanName = findViewById(R.id.editPlanName);
String plan_name = editPlanName.getText().toString();
DatabaseManager db;
int... | 2020/10/04 | [
"https://Stackoverflow.com/questions/64192452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14216903/"
] | ```swift
var a = false
var b = false
var c = false
mutateValues(&a, &b, &c) { n in
n = true
}
print(a, b, c) // will be printed "true true true"
func mutateValues<Value>(_ values: UnsafeMutablePointer<Value>..., mutate: (inout Value) -> Void) {
values.forEach {
mutate(&$0.pointee)
}
}
``` | An Array in Swift is a struct, hence a value type.
Iterating over his children, and changing one, will not be possible unless:
* The type of child is aa class (which is reference typed)
* You iterate over the indices and change the real values!
+ E.G:
```
var a: Int = 1
var b: Int = 2
var array: [Int] = [a,b]
... |
64,192,452 | I'm having issues with the below code displays Thursday as the dayOfTheWeek regardless of the date. Any ideas where I've gone wrong with this?
```java
public void CreatePlan() {
editPlanName = findViewById(R.id.editPlanName);
String plan_name = editPlanName.getText().toString();
DatabaseManager db;
int... | 2020/10/04 | [
"https://Stackoverflow.com/questions/64192452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14216903/"
] | It is possible to do this with key paths. Let's say the properties are in a class `Foo`:
```
class Foo {
var a = false
var b = false
var c = false
func makeAllTrue() {
for n in [\Foo.a, \Foo.b, \Foo.c] {
self[keyPath: n] = true
}
}
}
```
If `Foo` is a struct, use `mut... | An Array in Swift is a struct, hence a value type.
Iterating over his children, and changing one, will not be possible unless:
* The type of child is aa class (which is reference typed)
* You iterate over the indices and change the real values!
+ E.G:
```
var a: Int = 1
var b: Int = 2
var array: [Int] = [a,b]
... |
64,192,452 | I'm having issues with the below code displays Thursday as the dayOfTheWeek regardless of the date. Any ideas where I've gone wrong with this?
```java
public void CreatePlan() {
editPlanName = findViewById(R.id.editPlanName);
String plan_name = editPlanName.getText().toString();
DatabaseManager db;
int... | 2020/10/04 | [
"https://Stackoverflow.com/questions/64192452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14216903/"
] | ```swift
var a = false
var b = false
var c = false
mutateValues(&a, &b, &c) { n in
n = true
}
print(a, b, c) // will be printed "true true true"
func mutateValues<Value>(_ values: UnsafeMutablePointer<Value>..., mutate: (inout Value) -> Void) {
values.forEach {
mutate(&$0.pointee)
}
}
``` | It is possible to do this with key paths. Let's say the properties are in a class `Foo`:
```
class Foo {
var a = false
var b = false
var c = false
func makeAllTrue() {
for n in [\Foo.a, \Foo.b, \Foo.c] {
self[keyPath: n] = true
}
}
}
```
If `Foo` is a struct, use `mut... |
2,762,398 | Suppose X and U are independent random variables with
$$P(X = k) =\frac{1}{N+1}\quad\quad\quad k=0,1,2,....N$$
and $U$ having a uniform distribution on $[0, 1]$. Let $Y = X + U$
a) Find the CDF of Y.
i know how to do transform continuous with continuous , but in mixed case i have no idea | 2018/05/01 | [
"https://math.stackexchange.com/questions/2762398",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Note that
$$ \begin{align}(x+y)(x^2+y^2)&=x^3+y^3+xy(x+y)\\&\tag1\ge 2+xy(x+y)\\&=2+\frac{(x+y)^2-(x^2+y^2)}{2}(x+y)\\
&=2+\frac 12(x+y)^3-\frac12(x+y)(x^2+y^2)\end{align}$$
Therefore,
$$ \tag2(x+y)(x^2+y^2)\ge \frac 43+\frac13(x+y)^3$$
So if the first factor is larger, we first find from $(1)$
$$ x+y>\sqrt2$$
and the... | By symmetry $x = y = z$
then
$$
2z^3 \ge 2 \Rightarrow z^3 \ge 1 \Rightarrow z^2 \ge z
$$
Comparison with $x^3+y^3 \ge 2$ (light blue) and the circle $(x-\frac{1}{2})^2+(y-\frac{1}{2})^2 = 1/2$ (red)
[](https://i.stack.imgur.com/uGGTb.jpg) |
2,762,398 | Suppose X and U are independent random variables with
$$P(X = k) =\frac{1}{N+1}\quad\quad\quad k=0,1,2,....N$$
and $U$ having a uniform distribution on $[0, 1]$. Let $Y = X + U$
a) Find the CDF of Y.
i know how to do transform continuous with continuous , but in mixed case i have no idea | 2018/05/01 | [
"https://math.stackexchange.com/questions/2762398",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Consider $f(x,y)=x^2+y^2-x-y$. The inequality is equivalent to the fact that the following minimum is non-negative
$$
\min f(x,y)\quad\text{subject to }x^3+y^3\ge 2,\ x\ge 0,\ y\ge 0.
$$
1. As $f(x,y)=(x-\frac12)^2+(y-\frac12)^2-\frac12$ has compact sublevel sets, the minimum exists. Apply the necessary condition for ... | By symmetry $x = y = z$
then
$$
2z^3 \ge 2 \Rightarrow z^3 \ge 1 \Rightarrow z^2 \ge z
$$
Comparison with $x^3+y^3 \ge 2$ (light blue) and the circle $(x-\frac{1}{2})^2+(y-\frac{1}{2})^2 = 1/2$ (red)
[](https://i.stack.imgur.com/uGGTb.jpg) |
29,466,351 | I have a series of rather large text files and am looking to resolve references in each file for a specific noun phrase eg. 'Harry Potter'
I wouldn't want to run the the pipeline in full for every single possibility of reference resolution as that would take far far too long.
Thanks very much!
Here is what I have so... | 2015/04/06 | [
"https://Stackoverflow.com/questions/29466351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4753451/"
] | 1) If you only care about the co-reference resolution of pronominal antecedents, I would recommend checking out David Bamman's [book-nlp](https://github.com/dbamman/book-nlp).
It does very fast coref for novel-length texts, but only for pronominal antecedents (which are probably what you are most interested in anyways... | Unfortunately a full coreference analysis is required to get any usable annotations for a particular noun phrase. (Without a full analysis resolving tough anaphora like pronouns would be impossible.)
The best I can recommend is that you do processing in small blocks which are fairly "independent" in terms of coreferen... |
21,816,241 | I am new to programing I need to write a code that finds the oldest person in Person Array. Please help. The program compiled but did not execute. it gave me only the size of the Array but not the oldest person. I would appreciate any help.
My code is bellow:
```
import java.util.ArrayList;
public class PersonCollect... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21816241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3316776/"
] | You are not calling the `oldestPerson` method anywhere (better to call it `findOldestPerson`). Further you should design that method to take a `List<Person>` as a parameter.
This might help:
```java
public static void findOldestPerson(List<Person> persons) {
Person oldest = null;
for (Person p : persons) {
... | After `System.out.println("The size of the list is:" + aList.size());`
you must add a call to yours `oldestPerson` method, and you can update your method in this way:
```
public static void oldestPerson(ArrayList<Person> aList)
{
Person oldest = new Person();
for (Person p : aList)
{
... |
21,816,241 | I am new to programing I need to write a code that finds the oldest person in Person Array. Please help. The program compiled but did not execute. it gave me only the size of the Array but not the oldest person. I would appreciate any help.
My code is bellow:
```
import java.util.ArrayList;
public class PersonCollect... | 2014/02/16 | [
"https://Stackoverflow.com/questions/21816241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3316776/"
] | With Java 8...
```
public class PersonTest {
public static class Person {
public String first;
public String last;
public int age;
public char gender;
public String ssn;
public Person(String first, String last, int age, char gender, String ssn) {
this.fi... | After `System.out.println("The size of the list is:" + aList.size());`
you must add a call to yours `oldestPerson` method, and you can update your method in this way:
```
public static void oldestPerson(ArrayList<Person> aList)
{
Person oldest = new Person();
for (Person p : aList)
{
... |
40,419,595 | I am implementing a winform application in c# so that it contains four picture boxes and some control buttons in one corner.
[](https://i.stack.imgur.com/wclGK.png)
My main problem is that I cannot achieve the behaviour shown in the picture. The idea... | 2016/11/04 | [
"https://Stackoverflow.com/questions/40419595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3661551/"
] | So, let's say you have the following picture boxes:
```
pictureBox1 | pictureBox2 | panel
------------|------------
pictureBox3 | pictureBox4
```
Then the following should do the trick:
set the forms Resize event to this eventhandler:
```
private void Form1_Resize(object sender, EventArgs e)
{
int spaceBetweenP... | Are four image boxes supposed to support resizing at runtime (allowing end user to resize)? if not then following will give you desired result.
1 TableLayoutPanel with 2 rows and two columns. Set the initial size to fill the desired area, set the anchor to all four directions.
Add 4 picture boxes to 4 cells and set Do... |
11,703,311 | I am looking for a solution to multiple submit buttons using simple php.
Here is my form code
```
<!-- Widget Starts -->
<div class="widget">
<div class="title js_opened">
<div class="icon"><img src="themes/<?php echo WEBSITE_ADMIN_PANEL_THEM... | 2012/07/28 | [
"https://Stackoverflow.com/questions/11703311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1530513/"
] | Check whether the name of the submit button is set, and do the operation based on it.
For example:
```
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') // if form is submitted...
{
if(isset($_POST['save'])) // check whether it is the "Save" button that's being clicked
{
//code for saving
echo 's... | Make a hidden field somewhere in your form:
```
<input type="hidden" id="myHiddenField" value="" name="add">
```
Make two buttons:
```
<button onclick="formSubmit(save)">Save!</button>
<button onclick="formSubmit(something)">Something else!</button>
```
Then apply some Javascript:
```
<script language="javascri... |
64,804,093 | I have the following code:
```
-module(a).
-compile(export_all).
say(2,0) ->
[1,2];
say(A,B) ->
say(A-1,B-1).
loop(0) ->
io:format("");
loop(Times) ->
L = spawn(a, say, [4,2]),
io:fwrite( "L is ~w ~n", [L] ),
loop(Times-1).
run() ->
loop(4).
```
I want to have the list [1,2] in L ea... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13692000/"
] | I had the same problem, I imported the `NgSelectModule` at both the main application module and the component module and it was fixed.
You might also want to look at [this](https://github.com/ng-select/ng-select/issues/1464). | We had a different problem. We used @ng-select/ng-select": "3.7.2" and one of the third party component used the version 3.7.3.
After we updated to the same version the problem disappeared. |
64,804,093 | I have the following code:
```
-module(a).
-compile(export_all).
say(2,0) ->
[1,2];
say(A,B) ->
say(A-1,B-1).
loop(0) ->
io:format("");
loop(Times) ->
L = spawn(a, say, [4,2]),
io:fwrite( "L is ~w ~n", [L] ),
loop(Times-1).
run() ->
loop(4).
```
I want to have the list [1,2] in L ea... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13692000/"
] | I had the same problem, I imported the `NgSelectModule` at both the main application module and the component module and it was fixed.
You might also want to look at [this](https://github.com/ng-select/ng-select/issues/1464). | I faced similar issue while running test case.
I resolved it by importing `NgSelectModule` under `imports` block.
If you are using `NgSelectComponent` in your code for some use-case/scenario purpose then you can also declare `NgSelectComponent` under `declarations` block if needed
```
TestBed.configureTestingModule(... |
64,804,093 | I have the following code:
```
-module(a).
-compile(export_all).
say(2,0) ->
[1,2];
say(A,B) ->
say(A-1,B-1).
loop(0) ->
io:format("");
loop(Times) ->
L = spawn(a, say, [4,2]),
io:fwrite( "L is ~w ~n", [L] ),
loop(Times-1).
run() ->
loop(4).
```
I want to have the list [1,2] in L ea... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13692000/"
] | I had the same problem, I imported the `NgSelectModule` at both the main application module and the component module and it was fixed.
You might also want to look at [this](https://github.com/ng-select/ng-select/issues/1464). | Do import `NgSelectModule` in your `app.module.ts` along with the component module. |
64,804,093 | I have the following code:
```
-module(a).
-compile(export_all).
say(2,0) ->
[1,2];
say(A,B) ->
say(A-1,B-1).
loop(0) ->
io:format("");
loop(Times) ->
L = spawn(a, say, [4,2]),
io:fwrite( "L is ~w ~n", [L] ),
loop(Times-1).
run() ->
loop(4).
```
I want to have the list [1,2] in L ea... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13692000/"
] | I had the same problem, I imported the `NgSelectModule` at both the main application module and the component module and it was fixed.
You might also want to look at [this](https://github.com/ng-select/ng-select/issues/1464). | Only add `NgSelectModule` to `app.module.ts` and it works all across your app. This module doesn't work properly in a modal for example, because of it lazy loading. |
64,804,093 | I have the following code:
```
-module(a).
-compile(export_all).
say(2,0) ->
[1,2];
say(A,B) ->
say(A-1,B-1).
loop(0) ->
io:format("");
loop(Times) ->
L = spawn(a, say, [4,2]),
io:fwrite( "L is ~w ~n", [L] ),
loop(Times-1).
run() ->
loop(4).
```
I want to have the list [1,2] in L ea... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13692000/"
] | We had a different problem. We used @ng-select/ng-select": "3.7.2" and one of the third party component used the version 3.7.3.
After we updated to the same version the problem disappeared. | I faced similar issue while running test case.
I resolved it by importing `NgSelectModule` under `imports` block.
If you are using `NgSelectComponent` in your code for some use-case/scenario purpose then you can also declare `NgSelectComponent` under `declarations` block if needed
```
TestBed.configureTestingModule(... |
64,804,093 | I have the following code:
```
-module(a).
-compile(export_all).
say(2,0) ->
[1,2];
say(A,B) ->
say(A-1,B-1).
loop(0) ->
io:format("");
loop(Times) ->
L = spawn(a, say, [4,2]),
io:fwrite( "L is ~w ~n", [L] ),
loop(Times-1).
run() ->
loop(4).
```
I want to have the list [1,2] in L ea... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13692000/"
] | We had a different problem. We used @ng-select/ng-select": "3.7.2" and one of the third party component used the version 3.7.3.
After we updated to the same version the problem disappeared. | Only add `NgSelectModule` to `app.module.ts` and it works all across your app. This module doesn't work properly in a modal for example, because of it lazy loading. |
64,804,093 | I have the following code:
```
-module(a).
-compile(export_all).
say(2,0) ->
[1,2];
say(A,B) ->
say(A-1,B-1).
loop(0) ->
io:format("");
loop(Times) ->
L = spawn(a, say, [4,2]),
io:fwrite( "L is ~w ~n", [L] ),
loop(Times-1).
run() ->
loop(4).
```
I want to have the list [1,2] in L ea... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13692000/"
] | Do import `NgSelectModule` in your `app.module.ts` along with the component module. | I faced similar issue while running test case.
I resolved it by importing `NgSelectModule` under `imports` block.
If you are using `NgSelectComponent` in your code for some use-case/scenario purpose then you can also declare `NgSelectComponent` under `declarations` block if needed
```
TestBed.configureTestingModule(... |
64,804,093 | I have the following code:
```
-module(a).
-compile(export_all).
say(2,0) ->
[1,2];
say(A,B) ->
say(A-1,B-1).
loop(0) ->
io:format("");
loop(Times) ->
L = spawn(a, say, [4,2]),
io:fwrite( "L is ~w ~n", [L] ),
loop(Times-1).
run() ->
loop(4).
```
I want to have the list [1,2] in L ea... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13692000/"
] | Do import `NgSelectModule` in your `app.module.ts` along with the component module. | Only add `NgSelectModule` to `app.module.ts` and it works all across your app. This module doesn't work properly in a modal for example, because of it lazy loading. |
60,191,572 | I want to inspect assemblies if they have a specific type without loading the assembly in the current scope, which is available via MetadataLoadContext in .NET Core 3.
But if I try the following example
```
internal static class Program
{
// ReSharper disable once UnusedParameter.Local
private static void Mai... | 2020/02/12 | [
"https://Stackoverflow.com/questions/60191572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/616194/"
] | The existing answer didn't worked for me (.NET Core 2.1). It fails with error that System.Runtime is not found. If i hardcode full path to System.Runtime, it fails for other assemblies, like System.Private.CoreLib. Also checking types via IsAssignableFrom seems not working when one type isn't from MetadataLoadContext. ... | Providing the following paths of the .NET core libs works
```
var paths = new string[] {@"Plugin.dll", @"netstandard.dll", "System.Runtime.dll"};
``` |
60,191,572 | I want to inspect assemblies if they have a specific type without loading the assembly in the current scope, which is available via MetadataLoadContext in .NET Core 3.
But if I try the following example
```
internal static class Program
{
// ReSharper disable once UnusedParameter.Local
private static void Mai... | 2020/02/12 | [
"https://Stackoverflow.com/questions/60191572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/616194/"
] | Here is a method that works on `net6.0`. The method extracts custom attributes from the assembly that was provided as an argument.
```
public static FreshInfo GetInfo(string pathToMainExecutable) {
if (string.IsNullOrWhiteSpace(pathToMainExecutable))
throw new ArgumentException(@"Value cannot be nu... | Providing the following paths of the .NET core libs works
```
var paths = new string[] {@"Plugin.dll", @"netstandard.dll", "System.Runtime.dll"};
``` |
60,191,572 | I want to inspect assemblies if they have a specific type without loading the assembly in the current scope, which is available via MetadataLoadContext in .NET Core 3.
But if I try the following example
```
internal static class Program
{
// ReSharper disable once UnusedParameter.Local
private static void Mai... | 2020/02/12 | [
"https://Stackoverflow.com/questions/60191572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/616194/"
] | The existing answer didn't worked for me (.NET Core 2.1). It fails with error that System.Runtime is not found. If i hardcode full path to System.Runtime, it fails for other assemblies, like System.Private.CoreLib. Also checking types via IsAssignableFrom seems not working when one type isn't from MetadataLoadContext. ... | Here is a method that works on `net6.0`. The method extracts custom attributes from the assembly that was provided as an argument.
```
public static FreshInfo GetInfo(string pathToMainExecutable) {
if (string.IsNullOrWhiteSpace(pathToMainExecutable))
throw new ArgumentException(@"Value cannot be nu... |
8,799,518 | How can I re-use a function?
Okay lets say I have this "main" function below:
```
bool A = false;
bool B = true;
void MainFunction(bool Whatever) {
if(!Whatever) {
A = true;
if(A) {
B = false;
} else if(!A) {
B = true;
}
}
}
```
Now I want to make a ne... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8799518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129071/"
] | You're welcome to have one function call another. For example:
```
void ANewFunction() {
MainFunction(false);
}
void AnotherNewFunction() {
MainFunction(true);
}
```
You can even get fancy:
```
#include <functional>
auto ANewFunction = std::bind(&MainFunction, false);
auto AnotherNewFunction = std::bind(&MainFu... | You can't "re-use" functions, at least not in the way I understand your question.
But you can create a new function that calls the original function and then does some additional work of its own. For example:
```
void PrevFunction(int one)
{
int i = one;
// do whatever
}
void NewFunction(int one)
{
PrevF... |
8,799,518 | How can I re-use a function?
Okay lets say I have this "main" function below:
```
bool A = false;
bool B = true;
void MainFunction(bool Whatever) {
if(!Whatever) {
A = true;
if(A) {
B = false;
} else if(!A) {
B = true;
}
}
}
```
Now I want to make a ne... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8799518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129071/"
] | You can't "re-use" functions, at least not in the way I understand your question.
But you can create a new function that calls the original function and then does some additional work of its own. For example:
```
void PrevFunction(int one)
{
int i = one;
// do whatever
}
void NewFunction(int one)
{
PrevF... | Simply call MainFunction from your other function?
```
void ANewFunction()
{
MainFunction(false);
}
void AnotherNewFunction()
{
MainFunction(true);
}
```
If your question is how do you make AnotherNewFunction refer to a different A and B than ANewFunction, the answer is you can't, at least not without help f... |
8,799,518 | How can I re-use a function?
Okay lets say I have this "main" function below:
```
bool A = false;
bool B = true;
void MainFunction(bool Whatever) {
if(!Whatever) {
A = true;
if(A) {
B = false;
} else if(!A) {
B = true;
}
}
}
```
Now I want to make a ne... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8799518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129071/"
] | You can't "re-use" functions, at least not in the way I understand your question.
But you can create a new function that calls the original function and then does some additional work of its own. For example:
```
void PrevFunction(int one)
{
int i = one;
// do whatever
}
void NewFunction(int one)
{
PrevF... | Another new-fangled solution, using *lambda's*:
```
auto ANewFunction = [](){ MainFunction(false); }
auto AnotherNewFunction = [](){ MainFunction(true); }
``` |
8,799,518 | How can I re-use a function?
Okay lets say I have this "main" function below:
```
bool A = false;
bool B = true;
void MainFunction(bool Whatever) {
if(!Whatever) {
A = true;
if(A) {
B = false;
} else if(!A) {
B = true;
}
}
}
```
Now I want to make a ne... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8799518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129071/"
] | You're welcome to have one function call another. For example:
```
void ANewFunction() {
MainFunction(false);
}
void AnotherNewFunction() {
MainFunction(true);
}
```
You can even get fancy:
```
#include <functional>
auto ANewFunction = std::bind(&MainFunction, false);
auto AnotherNewFunction = std::bind(&MainFu... | Simply call MainFunction from your other function?
```
void ANewFunction()
{
MainFunction(false);
}
void AnotherNewFunction()
{
MainFunction(true);
}
```
If your question is how do you make AnotherNewFunction refer to a different A and B than ANewFunction, the answer is you can't, at least not without help f... |
8,799,518 | How can I re-use a function?
Okay lets say I have this "main" function below:
```
bool A = false;
bool B = true;
void MainFunction(bool Whatever) {
if(!Whatever) {
A = true;
if(A) {
B = false;
} else if(!A) {
B = true;
}
}
}
```
Now I want to make a ne... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8799518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129071/"
] | You're welcome to have one function call another. For example:
```
void ANewFunction() {
MainFunction(false);
}
void AnotherNewFunction() {
MainFunction(true);
}
```
You can even get fancy:
```
#include <functional>
auto ANewFunction = std::bind(&MainFunction, false);
auto AnotherNewFunction = std::bind(&MainFu... | ```
typedef int (*function_t)(int); // new type - defines function type - address of function
// your function, PrevFunction is simply variable holding address of the function:
int PrevFunction(int one) { return one; }
// new variable of type function_t initialized by PrevFunction address:
function_t NewFunction = ... |
8,799,518 | How can I re-use a function?
Okay lets say I have this "main" function below:
```
bool A = false;
bool B = true;
void MainFunction(bool Whatever) {
if(!Whatever) {
A = true;
if(A) {
B = false;
} else if(!A) {
B = true;
}
}
}
```
Now I want to make a ne... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8799518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129071/"
] | You're welcome to have one function call another. For example:
```
void ANewFunction() {
MainFunction(false);
}
void AnotherNewFunction() {
MainFunction(true);
}
```
You can even get fancy:
```
#include <functional>
auto ANewFunction = std::bind(&MainFunction, false);
auto AnotherNewFunction = std::bind(&MainFu... | Another new-fangled solution, using *lambda's*:
```
auto ANewFunction = [](){ MainFunction(false); }
auto AnotherNewFunction = [](){ MainFunction(true); }
``` |
8,799,518 | How can I re-use a function?
Okay lets say I have this "main" function below:
```
bool A = false;
bool B = true;
void MainFunction(bool Whatever) {
if(!Whatever) {
A = true;
if(A) {
B = false;
} else if(!A) {
B = true;
}
}
}
```
Now I want to make a ne... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8799518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129071/"
] | ```
typedef int (*function_t)(int); // new type - defines function type - address of function
// your function, PrevFunction is simply variable holding address of the function:
int PrevFunction(int one) { return one; }
// new variable of type function_t initialized by PrevFunction address:
function_t NewFunction = ... | Simply call MainFunction from your other function?
```
void ANewFunction()
{
MainFunction(false);
}
void AnotherNewFunction()
{
MainFunction(true);
}
```
If your question is how do you make AnotherNewFunction refer to a different A and B than ANewFunction, the answer is you can't, at least not without help f... |
8,799,518 | How can I re-use a function?
Okay lets say I have this "main" function below:
```
bool A = false;
bool B = true;
void MainFunction(bool Whatever) {
if(!Whatever) {
A = true;
if(A) {
B = false;
} else if(!A) {
B = true;
}
}
}
```
Now I want to make a ne... | 2012/01/10 | [
"https://Stackoverflow.com/questions/8799518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129071/"
] | ```
typedef int (*function_t)(int); // new type - defines function type - address of function
// your function, PrevFunction is simply variable holding address of the function:
int PrevFunction(int one) { return one; }
// new variable of type function_t initialized by PrevFunction address:
function_t NewFunction = ... | Another new-fangled solution, using *lambda's*:
```
auto ANewFunction = [](){ MainFunction(false); }
auto AnotherNewFunction = [](){ MainFunction(true); }
``` |
55,681,995 | I have a series of unreferenced aerial images that I would like to georeference using python. The images are identical spatially (they are actually frames extracted from a video), and I obtained ground control points for them by manually georeferencing one frame in ArcMap. I would like to apply the ground control point... | 2019/04/15 | [
"https://Stackoverflow.com/questions/55681995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8836524/"
] | I ended up reading a book "Geoprocessing with Python" and finally found a solution that worked for me. Here is the code I adapted to my problem:
```
import shutil
from osgeo import gdal, osr
orig_fn = 'image.tif'
output_fn = 'output.tif'
# Create a copy of the original file and save it as the output filename:
shutil... | For your gdal method, just using gdal.Warp with the outdataset should work, e.g.
```
outdataset.SetProjection(srs.ExportToWkt())
wkt = outdataset.GetProjection()
outdataset.SetGCPs(gcp_list,wkt)
gdal.Warp("output_name.tif", outdataset, dstSRS='EPSG:2193', format='gtiff')
```
This will create a new file, output\_na... |
55,681,995 | I have a series of unreferenced aerial images that I would like to georeference using python. The images are identical spatially (they are actually frames extracted from a video), and I obtained ground control points for them by manually georeferencing one frame in ArcMap. I would like to apply the ground control point... | 2019/04/15 | [
"https://Stackoverflow.com/questions/55681995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8836524/"
] | For your gdal method, just using gdal.Warp with the outdataset should work, e.g.
```
outdataset.SetProjection(srs.ExportToWkt())
wkt = outdataset.GetProjection()
outdataset.SetGCPs(gcp_list,wkt)
gdal.Warp("output_name.tif", outdataset, dstSRS='EPSG:2193', format='gtiff')
```
This will create a new file, output\_na... | As an addition to @Kat's answer, to avoid quality loss of the original image file and set the nodata-value to 0, the following can be used.
```
#Load the original file
src_ds = gdal.Open(orig_fn)
#Create tmp dataset saved in memory
driver = gdal.GetDriverByName('MEM')
tmp_ds = driver.CreateCopy('', src_ds, strict=0)
... |
55,681,995 | I have a series of unreferenced aerial images that I would like to georeference using python. The images are identical spatially (they are actually frames extracted from a video), and I obtained ground control points for them by manually georeferencing one frame in ArcMap. I would like to apply the ground control point... | 2019/04/15 | [
"https://Stackoverflow.com/questions/55681995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8836524/"
] | I ended up reading a book "Geoprocessing with Python" and finally found a solution that worked for me. Here is the code I adapted to my problem:
```
import shutil
from osgeo import gdal, osr
orig_fn = 'image.tif'
output_fn = 'output.tif'
# Create a copy of the original file and save it as the output filename:
shutil... | As an addition to @Kat's answer, to avoid quality loss of the original image file and set the nodata-value to 0, the following can be used.
```
#Load the original file
src_ds = gdal.Open(orig_fn)
#Create tmp dataset saved in memory
driver = gdal.GetDriverByName('MEM')
tmp_ds = driver.CreateCopy('', src_ds, strict=0)
... |
42,804,448 | I am new in Angular JS. And I am creating a custom service in it.
```js
var myApp = angular
.module("myModule", [])
.controller("myController", function ($scope, stringService) {
$scope.callMe = function (input) {
$scope.wish= stringService.processFunct... | 2017/03/15 | [
"https://Stackoverflow.com/questions/42804448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7646829/"
] | `myApp` holds the reference to the module you defined using `angular.module('modulename', []);`
if you want to get the same module reference again without existing variable you can do so by using `.module` method without second argument, when second argument `dependency` is present it defines module and if second argu... | Adding to Sam answer, note the difference between:
```
angular.module("myModule", [])
```
and:
```
angular.module("myModule")
```
With a second argument (an array of dependencies), you *declare* a module. Without the dependencies argument, you get *a reference to an already-defined module*. Mixing the two forms... |
26,560,838 | I'm following a video tutorial about underscoreJS and everything was going fine until I reached the point where you put logic inside templates
SampleData.js contains students array:
```
var students = [
{
"firstname": "Woody",
"lastname" : "Johnson",
"school" : "Thoreau",
"grade" :... | 2014/10/25 | [
"https://Stackoverflow.com/questions/26560838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2535267/"
] | Please look at the documentation for the `_.template()` function carefully. <http://underscorejs.org/#template>
The `template` utility function takes a template string as the first argument and returns a **function** that you can use to pass in your template data:
```
// `myTemplate` here is a function!
var myTemplat... | I've tried your code, it runs good
And my recommend is replacing your underscore.js with this underscore library
<https://github.com/thomasdavis/backbonetutorials/blob/gh-pages/examples/modular-backbone/js/libs/underscore/underscore-min.js>
I've gotten a problem like yours, library on underscorejs.org can't work
I ... |
252,296 | I have the following problem:
A truck transports oranges. Each orange has a mean weight of 85g and a sd of 9 g.
If the truck transports 2000 oranges what is the probability that the total weight is greater than 175kg?
Now suppose that there are 3400 oranges and the total weight is 255kg. What is the probability that th... | 2016/12/19 | [
"https://stats.stackexchange.com/questions/252296",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/133996/"
] | I don't see why you need any statistical calculations for the second problem.
There are 3400 oranges with a total weight is 255,000 g. So the average weight of an orange is 255000/3400= 75 grams. That is exact. There is zero (0.000000000000....) chance that the average weight is greater than 76 grams. The average weig... | If we assume that the weight of an orange is normally distributed and that the weights of oranges are independent. Let $X$ be the weight of each orange. So:
$$X\sim N(\mu,\sigma^{2})$$
Define $Y$ as weight of oranges in the truck:
$$Y=\sum\_{i=1}^{2000}X\sim N(2000\mu,2000\sigma^{2})$$
Therefore you want:
$$\begin... |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | ASP.Net Webforms is a completely different abstraction over the base framework than ASP.NET MVC. With MVC you've got more control over what happens under the covers than with ASP.NET Webforms.
In my opinion learning different ways to do things will usually make you a better programmer but in this case there might be b... | IMO, there are more pitfalls in normal web forms scenarios than with just MVC. Viewstate and databinding can be tricky at times.
But for MVC, it's just plain simple form post/render things old-school way. Not that it is bad, it is just different, and cleaner too. |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | I agree with Nick: MVC is much closer to the *real* web paradigm and by using it you'll be confronted with how your website really works. WebForms astracts most of these things away from you and, coming from a PHP background, I found it really anti-intuitive.
I suggest you directly jump to MVC and skip WebForms. As sa... | If you don't know how or haven't has experience with raw level web request / response and raw html/css rendering then MVC will would be good place to start.
You will then better understand the pros and cons of both webforms and mvc. They will both be around in the future as the both address different needs.
Though I ... |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | Here is the great thing about MVC. It works closer to the base of the framework than normal ASP.NET Web Forms. So by using MVC and understanding it, you will have a better understanding of how WebForms work. The problem with WebForms is there is a lot of magic and about 6 years of trying to make the Web work like Windo... | If you don't know how or haven't has experience with raw level web request / response and raw html/css rendering then MVC will would be good place to start.
You will then better understand the pros and cons of both webforms and mvc. They will both be around in the future as the both address different needs.
Though I ... |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | I agree with Nick: MVC is much closer to the *real* web paradigm and by using it you'll be confronted with how your website really works. WebForms astracts most of these things away from you and, coming from a PHP background, I found it really anti-intuitive.
I suggest you directly jump to MVC and skip WebForms. As sa... | It depends on your motivations. If you're going to sell yourself as an ASP.NET developer, you will need both.
If this is just for your own pleasure, then go to MVC.
My personal feeling is that webforms will be around for quite a few years more. So many people have time and energy invested in them. However, I think pe... |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | I agree with Nick: MVC is much closer to the *real* web paradigm and by using it you'll be confronted with how your website really works. WebForms astracts most of these things away from you and, coming from a PHP background, I found it really anti-intuitive.
I suggest you directly jump to MVC and skip WebForms. As sa... | ASP.NET MVC is for developers who desire to decouple the client code from the server code. I have wanted to write JavaScript, XHTML, CSS clients that can move from server to server (without regard to server technology). Clients are time-consuming to fit and finish so you would want to use them (and sub-components) for ... |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | ASP.NET MVC is for developers who desire to decouple the client code from the server code. I have wanted to write JavaScript, XHTML, CSS clients that can move from server to server (without regard to server technology). Clients are time-consuming to fit and finish so you would want to use them (and sub-components) for ... | IMO, there are more pitfalls in normal web forms scenarios than with just MVC. Viewstate and databinding can be tricky at times.
But for MVC, it's just plain simple form post/render things old-school way. Not that it is bad, it is just different, and cleaner too. |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | It depends on your motivations. If you're going to sell yourself as an ASP.NET developer, you will need both.
If this is just for your own pleasure, then go to MVC.
My personal feeling is that webforms will be around for quite a few years more. So many people have time and energy invested in them. However, I think pe... | I can't really speak technically about MVC vs "traditional" as I have only used the traditional model so far. From what I have read though, I don't think one is vastly superior to the other. I think once you "get it", you can be very productive in both.
Practically though, I would take into consideration that most bo... |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | Here is the great thing about MVC. It works closer to the base of the framework than normal ASP.NET Web Forms. So by using MVC and understanding it, you will have a better understanding of how WebForms work. The problem with WebForms is there is a lot of magic and about 6 years of trying to make the Web work like Windo... | ASP.Net Webforms is a completely different abstraction over the base framework than ASP.NET MVC. With MVC you've got more control over what happens under the covers than with ASP.NET Webforms.
In my opinion learning different ways to do things will usually make you a better programmer but in this case there might be b... |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | Here is the great thing about MVC. It works closer to the base of the framework than normal ASP.NET Web Forms. So by using MVC and understanding it, you will have a better understanding of how WebForms work. The problem with WebForms is there is a lot of magic and about 6 years of trying to make the Web work like Windo... | IMO, there are more pitfalls in normal web forms scenarios than with just MVC. Viewstate and databinding can be tricky at times.
But for MVC, it's just plain simple form post/render things old-school way. Not that it is bad, it is just different, and cleaner too. |
41,712 | As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series and... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | Here is the great thing about MVC. It works closer to the base of the framework than normal ASP.NET Web Forms. So by using MVC and understanding it, you will have a better understanding of how WebForms work. The problem with WebForms is there is a lot of magic and about 6 years of trying to make the Web work like Windo... | I agree with Nick: MVC is much closer to the *real* web paradigm and by using it you'll be confronted with how your website really works. WebForms astracts most of these things away from you and, coming from a PHP background, I found it really anti-intuitive.
I suggest you directly jump to MVC and skip WebForms. As sa... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | There's no direct equivalent of "friend" - the closest that's available (and it isn't very close) is [InternalsVisibleTo](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx). I've only ever used this attribute for testing - where it's very handy!
**Example:** To be... | There isn't a 'friend' keyword in C# but one option for testing private methods is to use System.Reflection to get a handle to the method. This will allow you to invoke private methods.
Given a class with this definition:
```
public class Class1
{
private int CallMe()
{
return 1;
}
}
```
You can... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | There's no direct equivalent of "friend" - the closest that's available (and it isn't very close) is [InternalsVisibleTo](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx). I've only ever used this attribute for testing - where it's very handy!
**Example:** To be... | Take a very common pattern. Class Factory makes Widgets. The Factory class needs to muck about with the internals, because, it is the Factory. Both are implemented in the same file and are, by design and desire and nature, tightly coupled classes -- in fact, Widget is really just an output type from factory.
In C++, m... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | There's no direct equivalent of "friend" - the closest that's available (and it isn't very close) is [InternalsVisibleTo](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx). I've only ever used this attribute for testing - where it's very handy!
**Example:** To be... | The closet equivalent is to create a nested class which will be able to access the outer class' private members. Something like this:
```
class Outer
{
class Inner
{
// This class can access Outer's private members
}
}
```
or if you prefer to put the Inner class in another file:
```
Outer.cs
part... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | There's no direct equivalent of "friend" - the closest that's available (and it isn't very close) is [InternalsVisibleTo](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx). I've only ever used this attribute for testing - where it's very handy!
**Example:** To be... | You can simulate a friend access if the class that is given the right to access is inside another package and if the methods you are exposing are marked as internal or internal protected. You have to modify the assembly you want to share and add the following settings to AssemblyInfo.cs :
```
// Expose the internal me... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | Take a very common pattern. Class Factory makes Widgets. The Factory class needs to muck about with the internals, because, it is the Factory. Both are implemented in the same file and are, by design and desire and nature, tightly coupled classes -- in fact, Widget is really just an output type from factory.
In C++, m... | There isn't a 'friend' keyword in C# but one option for testing private methods is to use System.Reflection to get a handle to the method. This will allow you to invoke private methods.
Given a class with this definition:
```
public class Class1
{
private int CallMe()
{
return 1;
}
}
```
You can... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | The closet equivalent is to create a nested class which will be able to access the outer class' private members. Something like this:
```
class Outer
{
class Inner
{
// This class can access Outer's private members
}
}
```
or if you prefer to put the Inner class in another file:
```
Outer.cs
part... | There isn't a 'friend' keyword in C# but one option for testing private methods is to use System.Reflection to get a handle to the method. This will allow you to invoke private methods.
Given a class with this definition:
```
public class Class1
{
private int CallMe()
{
return 1;
}
}
```
You can... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | There isn't a 'friend' keyword in C# but one option for testing private methods is to use System.Reflection to get a handle to the method. This will allow you to invoke private methods.
Given a class with this definition:
```
public class Class1
{
private int CallMe()
{
return 1;
}
}
```
You can... | You can simulate a friend access if the class that is given the right to access is inside another package and if the methods you are exposing are marked as internal or internal protected. You have to modify the assembly you want to share and add the following settings to AssemblyInfo.cs :
```
// Expose the internal me... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | The closet equivalent is to create a nested class which will be able to access the outer class' private members. Something like this:
```
class Outer
{
class Inner
{
// This class can access Outer's private members
}
}
```
or if you prefer to put the Inner class in another file:
```
Outer.cs
part... | Take a very common pattern. Class Factory makes Widgets. The Factory class needs to muck about with the internals, because, it is the Factory. Both are implemented in the same file and are, by design and desire and nature, tightly coupled classes -- in fact, Widget is really just an output type from factory.
In C++, m... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | Take a very common pattern. Class Factory makes Widgets. The Factory class needs to muck about with the internals, because, it is the Factory. Both are implemented in the same file and are, by design and desire and nature, tightly coupled classes -- in fact, Widget is really just an output type from factory.
In C++, m... | You can simulate a friend access if the class that is given the right to access is inside another package and if the methods you are exposing are marked as internal or internal protected. You have to modify the assembly you want to share and add the following settings to AssemblyInfo.cs :
```
// Expose the internal me... |
204,739 | >
> **Possible Duplicate:**
>
> [Why does C# not provide the C++ style ‘friend’ keyword?](https://stackoverflow.com/questions/203616/why-does-c-sharp-not-provide-the-c-style-friend-keyword)
>
>
>
I'd like the private member variables of a class to be accessible to a Tester class without exposing them to other ... | 2008/10/15 | [
"https://Stackoverflow.com/questions/204739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22185/"
] | The closet equivalent is to create a nested class which will be able to access the outer class' private members. Something like this:
```
class Outer
{
class Inner
{
// This class can access Outer's private members
}
}
```
or if you prefer to put the Inner class in another file:
```
Outer.cs
part... | You can simulate a friend access if the class that is given the right to access is inside another package and if the methods you are exposing are marked as internal or internal protected. You have to modify the assembly you want to share and add the following settings to AssemblyInfo.cs :
```
// Expose the internal me... |
49,811,904 | I have a question related to Monte Carlo simulation based on the probability of rolling 2 dices. How can you present when coding in python the fact that the sum is larger than n and smaller than m? As an example I made this in mathlab:
```
NT = 10^5; %number of throws
log = zeros(1,12);
for throw = 1:NT
dices = ce... | 2018/04/13 | [
"https://Stackoverflow.com/questions/49811904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9634762/"
] | The first red flag is that you use the database only to *hold data*. That beast can search way faster than you can, if you *let it*.
For each line in your excel, build a corresponding search statement for your database and fire it. Let your database worry about the best way to search through 10K records.
The second ... | If this is sql server then you should be using ssis.
It has fuzzy matching which is pretty much a must for matching records on addresses from two different sources.
I would import the data to a table using ssis as well and do any pre processing of data in the pipeline.
The whole thing could be run using a job ... |
49,811,904 | I have a question related to Monte Carlo simulation based on the probability of rolling 2 dices. How can you present when coding in python the fact that the sum is larger than n and smaller than m? As an example I made this in mathlab:
```
NT = 10^5; %number of throws
log = zeros(1,12);
for throw = 1:NT
dices = ce... | 2018/04/13 | [
"https://Stackoverflow.com/questions/49811904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9634762/"
] | The first red flag is that you use the database only to *hold data*. That beast can search way faster than you can, if you *let it*.
For each line in your excel, build a corresponding search statement for your database and fire it. Let your database worry about the best way to search through 10K records.
The second ... | First, nvoight is right: you should normalize data in database and use its power to do searches. However, if you can't change the database, then you can do improvements in your code.
1) Most important is to move out of loops things that can be done once. This is data normalization (replacements, tolower etc). Iterate ... |
49,811,904 | I have a question related to Monte Carlo simulation based on the probability of rolling 2 dices. How can you present when coding in python the fact that the sum is larger than n and smaller than m? As an example I made this in mathlab:
```
NT = 10^5; %number of throws
log = zeros(1,12);
for throw = 1:NT
dices = ce... | 2018/04/13 | [
"https://Stackoverflow.com/questions/49811904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9634762/"
] | First, nvoight is right: you should normalize data in database and use its power to do searches. However, if you can't change the database, then you can do improvements in your code.
1) Most important is to move out of loops things that can be done once. This is data normalization (replacements, tolower etc). Iterate ... | If this is sql server then you should be using ssis.
It has fuzzy matching which is pretty much a must for matching records on addresses from two different sources.
I would import the data to a table using ssis as well and do any pre processing of data in the pipeline.
The whole thing could be run using a job ... |
653,102 | I have a Compaq pc with Windows 7 64 bit. I am getting no audio from speakers. I do hear a clicking noise when I plug in or touch the audio cable/jack coming thru the speakers. I have upgraded drivers and checked the bios. Any suggestion? | 2013/10/02 | [
"https://superuser.com/questions/653102",
"https://superuser.com",
"https://superuser.com/users/258746/"
] | right click the sound icon in your Task Tray (next to the clock). Select Playback devices. Make sure your speakers are selected as the default sound device (should have a green check). If not, right click the speakers and select default sound device. | Noise in the way you describe it suggests a bad physical connection, most likely a problem with the receptacle in the computer rather than the cable.
You could try another cable first, but .... |
653,102 | I have a Compaq pc with Windows 7 64 bit. I am getting no audio from speakers. I do hear a clicking noise when I plug in or touch the audio cable/jack coming thru the speakers. I have upgraded drivers and checked the bios. Any suggestion? | 2013/10/02 | [
"https://superuser.com/questions/653102",
"https://superuser.com",
"https://superuser.com/users/258746/"
] | right click the sound icon in your Task Tray (next to the clock). Select Playback devices. Make sure your speakers are selected as the default sound device (should have a green check). If not, right click the speakers and select default sound device. | This seems like a duplicate question to me, but could be coincidence. In any case: go into Control Panel > Sound. Click the Communications tab & change from "reduce the volume of other sounds" to "Do nothing". And if this resolves your problem (since you say the sound is OK on VOIP calls) then I'll have to find out whe... |
14,841,235 | I got a table that i'm quering to get the `DeliveryDate` but some of the records don't have `DeliveryDate` so VB considers that as 00:00:00.
How do I make an `IF` condition to check a date and see if it's 00:00:00?
Because I want to set a variable to **TRUE** when the date is nothing(00:00:00). | 2013/02/12 | [
"https://Stackoverflow.com/questions/14841235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972768/"
] | You can check if your Date equals the date part:
`If DeliveryDate.Date = DeliveryDate Then ...` | I personally use `New Date` but it is a style choice - you can also use Nothing.
```
If DeliveryDate = New Date Then
```
or
```
If DeliveryDate = Nothing Then
``` |
14,841,235 | I got a table that i'm quering to get the `DeliveryDate` but some of the records don't have `DeliveryDate` so VB considers that as 00:00:00.
How do I make an `IF` condition to check a date and see if it's 00:00:00?
Because I want to set a variable to **TRUE** when the date is nothing(00:00:00). | 2013/02/12 | [
"https://Stackoverflow.com/questions/14841235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1972768/"
] | Looks like you want to check if date was assigned to `Nothing`, in which case it would default to [Date.MinValue](http://msdn.microsoft.com/en-us/library/system.datetime.minvalue.aspx). The quick and dirty approach would be to check:
```
If DeliveryDate = Date.MinValue Then
```
It will work fine for packages deliver... | I personally use `New Date` but it is a style choice - you can also use Nothing.
```
If DeliveryDate = New Date Then
```
or
```
If DeliveryDate = Nothing Then
``` |
26,991,680 | I have a Laravel Model:
```
class Order extends Eloquent{
protected $table = 'orders';
public function orderItems(){
return $this->hasMany('OrderItem');
}
public static function findByUserMonthYear($user_id, $month, $year){
return Order::where('user_id', '=', $user_id)
->... | 2014/11/18 | [
"https://Stackoverflow.com/questions/26991680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/630203/"
] | Your `->get()` within you findByUserMonth is returning a Collection. If this query returns only one collection then use the `->first()` instead, but if your query returns multiple results then eager load the results of orderItems like so;
```
public static function findByUserMonthYear($user_id, $month, $year){
ret... | your second class must be extends Order class
use this line for OrderItem class :
```
class OrderItem extends Order {
``` |
1,553,594 | I have an experience about the compiler phrases and I interested in Programming Languages & Compilers field and I hope somebody gives me some explanation about what is the good approach to write a new compiler from scratch for a new programming language ? (**I mean STEPS**). | 2009/10/12 | [
"https://Stackoverflow.com/questions/1553594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The first step is to read the [Dragon Book](http://en.wikipedia.org/wiki/Principles_of_Compiler_Design).
It offers a good introduction to the whole field of compiler building, but also goes into enough detail to actually build your own.
As for the following steps I suggest following the chapters of the book. It's not... | I would look at integrating your langauge/front end with the GNU compiler framework.
That way you only (ONLY!) need to write the parser and translator to gcc's portable object format. You get the optimiser, object code generation for the chip of choice, linker etc for free.
Another alternative would be to target a Ja... |
1,553,594 | I have an experience about the compiler phrases and I interested in Programming Languages & Compilers field and I hope somebody gives me some explanation about what is the good approach to write a new compiler from scratch for a new programming language ? (**I mean STEPS**). | 2009/10/12 | [
"https://Stackoverflow.com/questions/1553594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The first step is to read the [Dragon Book](http://en.wikipedia.org/wiki/Principles_of_Compiler_Design).
It offers a good introduction to the whole field of compiler building, but also goes into enough detail to actually build your own.
As for the following steps I suggest following the chapters of the book. It's not... | I managed to write a compiler without any particular book (though I had read some compiler books in the past, just not in any real detail).
The first thing you should do is play with any of the "Compiler compiler" type tools (flex, bison, antlr, javacc) and get your grammar working. Grammars are mostly straightforward... |
1,553,594 | I have an experience about the compiler phrases and I interested in Programming Languages & Compilers field and I hope somebody gives me some explanation about what is the good approach to write a new compiler from scratch for a new programming language ? (**I mean STEPS**). | 2009/10/12 | [
"https://Stackoverflow.com/questions/1553594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Please don't use the Dragon Book, it's old and mostly outdated (and uses weird names for most of the stuff).
For books, I'd recommand Apple's Tiger Book, or Cooper's Engineering a compiler. I'd strongly suggest you to use a framework like [llvm](http://llvm.org) so you don't have to re-implement a bunch of stuff for c... | I would look at integrating your langauge/front end with the GNU compiler framework.
That way you only (ONLY!) need to write the parser and translator to gcc's portable object format. You get the optimiser, object code generation for the chip of choice, linker etc for free.
Another alternative would be to target a Ja... |
1,553,594 | I have an experience about the compiler phrases and I interested in Programming Languages & Compilers field and I hope somebody gives me some explanation about what is the good approach to write a new compiler from scratch for a new programming language ? (**I mean STEPS**). | 2009/10/12 | [
"https://Stackoverflow.com/questions/1553594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Please don't use the Dragon Book, it's old and mostly outdated (and uses weird names for most of the stuff).
For books, I'd recommand Apple's Tiger Book, or Cooper's Engineering a compiler. I'd strongly suggest you to use a framework like [llvm](http://llvm.org) so you don't have to re-implement a bunch of stuff for c... | I managed to write a compiler without any particular book (though I had read some compiler books in the past, just not in any real detail).
The first thing you should do is play with any of the "Compiler compiler" type tools (flex, bison, antlr, javacc) and get your grammar working. Grammars are mostly straightforward... |
46,293,017 | How can I concatenate a Sass variable?
This is the the code in the scss file.
```
$url = 'siteurl.com';
#some-div{
background-image: url(+ $url +/images/img.jpg);
}
```
I want the result in the CSS file to be:
```
#some-div{
background-image: url('siteurl.com/images/img.jpg');
}
```
I found this questio... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46293017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3471458/"
] | Multiple issues here, the correct syntax is
```
$url: 'siteurl.com';
#some-div{
background-image: url($url + '/images/img.jpg');
}
```
* When you assign a value to the variable, you need to use `:` and not `=`
* You should quote the image path as it's a string.
* Remove the stray `+` symbol before `$url`
You can... | Use this:
```
$domain: 'domain.ru';
#some-div {
background-image: url('#{$domain}/images/img.jpg');
}
``` |
46,293,017 | How can I concatenate a Sass variable?
This is the the code in the scss file.
```
$url = 'siteurl.com';
#some-div{
background-image: url(+ $url +/images/img.jpg);
}
```
I want the result in the CSS file to be:
```
#some-div{
background-image: url('siteurl.com/images/img.jpg');
}
```
I found this questio... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46293017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3471458/"
] | Multiple issues here, the correct syntax is
```
$url: 'siteurl.com';
#some-div{
background-image: url($url + '/images/img.jpg');
}
```
* When you assign a value to the variable, you need to use `:` and not `=`
* You should quote the image path as it's a string.
* Remove the stray `+` symbol before `$url`
You can... | The best to do it via interpolation `( #{} )`, where all strings become unquoted.
```
$basePath= 'example.com';
#some-div{
background-image: url('#{$basePath}/images/photo.jpg');
}
```
This is a safer way for this particular use-case as you won't want any additional quotes added to your url. |
46,293,017 | How can I concatenate a Sass variable?
This is the the code in the scss file.
```
$url = 'siteurl.com';
#some-div{
background-image: url(+ $url +/images/img.jpg);
}
```
I want the result in the CSS file to be:
```
#some-div{
background-image: url('siteurl.com/images/img.jpg');
}
```
I found this questio... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46293017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3471458/"
] | Multiple issues here, the correct syntax is
```
$url: 'siteurl.com';
#some-div{
background-image: url($url + '/images/img.jpg');
}
```
* When you assign a value to the variable, you need to use `:` and not `=`
* You should quote the image path as it's a string.
* Remove the stray `+` symbol before `$url`
You can... | A example:
```
$dot: '0.';
@for $i from 1 through 9 {
.op#{$i} {
opacity: #{$dot}#{$i};
}
}
```
By logic, the variable is declared in `$dot: '0.';` and I called her in `#{$dot}`.
This example above shows two concatenated variables in SCSS. |
46,293,017 | How can I concatenate a Sass variable?
This is the the code in the scss file.
```
$url = 'siteurl.com';
#some-div{
background-image: url(+ $url +/images/img.jpg);
}
```
I want the result in the CSS file to be:
```
#some-div{
background-image: url('siteurl.com/images/img.jpg');
}
```
I found this questio... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46293017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3471458/"
] | Use this:
```
$domain: 'domain.ru';
#some-div {
background-image: url('#{$domain}/images/img.jpg');
}
``` | The best to do it via interpolation `( #{} )`, where all strings become unquoted.
```
$basePath= 'example.com';
#some-div{
background-image: url('#{$basePath}/images/photo.jpg');
}
```
This is a safer way for this particular use-case as you won't want any additional quotes added to your url. |
46,293,017 | How can I concatenate a Sass variable?
This is the the code in the scss file.
```
$url = 'siteurl.com';
#some-div{
background-image: url(+ $url +/images/img.jpg);
}
```
I want the result in the CSS file to be:
```
#some-div{
background-image: url('siteurl.com/images/img.jpg');
}
```
I found this questio... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46293017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3471458/"
] | Use this:
```
$domain: 'domain.ru';
#some-div {
background-image: url('#{$domain}/images/img.jpg');
}
``` | A example:
```
$dot: '0.';
@for $i from 1 through 9 {
.op#{$i} {
opacity: #{$dot}#{$i};
}
}
```
By logic, the variable is declared in `$dot: '0.';` and I called her in `#{$dot}`.
This example above shows two concatenated variables in SCSS. |
46,293,017 | How can I concatenate a Sass variable?
This is the the code in the scss file.
```
$url = 'siteurl.com';
#some-div{
background-image: url(+ $url +/images/img.jpg);
}
```
I want the result in the CSS file to be:
```
#some-div{
background-image: url('siteurl.com/images/img.jpg');
}
```
I found this questio... | 2017/09/19 | [
"https://Stackoverflow.com/questions/46293017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3471458/"
] | The best to do it via interpolation `( #{} )`, where all strings become unquoted.
```
$basePath= 'example.com';
#some-div{
background-image: url('#{$basePath}/images/photo.jpg');
}
```
This is a safer way for this particular use-case as you won't want any additional quotes added to your url. | A example:
```
$dot: '0.';
@for $i from 1 through 9 {
.op#{$i} {
opacity: #{$dot}#{$i};
}
}
```
By logic, the variable is declared in `$dot: '0.';` and I called her in `#{$dot}`.
This example above shows two concatenated variables in SCSS. |
48,061,053 | I have a below HTML structure :
```
<ol class="slds-progress__list" id="olid">
<li class="slds-progress__item"> 123 </li>
<li class="slds-progress__item"> 345 </li>
</ol>
```
I have written below Jquery to get selected li element and apply other class to it :
```
<script src="//ajax.googleapis.com/ajax/li... | 2018/01/02 | [
"https://Stackoverflow.com/questions/48061053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9163729/"
] | Using `android:tint` property you can set the color like this
```
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:tint="@android:color/white"
android:sr... | Simply, to change color of `drawable`, locate `res/drawable` folder and open your desired `drawable` which code looks like,
```
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="26dp"
android:height="26dp"
android:viewportWidth="24.0"
android:viewportHeig... |
14,247,932 | I'm sorry to say that I cannot describe my problem more to the core or more abstractly. I feel the best way to explain my problem is by means of this quite specific example.
I want to define a function 'readCollection' which would parse a String and give me a specific collection of a specific type, based on how I call... | 2013/01/09 | [
"https://Stackoverflow.com/questions/14247932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1648459/"
] | Think about splitting up the parsing/construction from the object itself. In many cases, the two are very separate concerns.
You're on the right track, but I would recommend:
1. Don't have your element types inherit from the `Readable` interface
2. Rename the `Readable` interface to `Reader`
3. Implement a `Reader` ... | APIs should be defined through interfaces.
Shared implementations should be through abstract base classes.
So how do you use an abstract base class without losing the benefits of an interface?
Easy! Simply have the abstract base class implement the interface.
Then any class that needs the shared functionality can e... |
14,247,932 | I'm sorry to say that I cannot describe my problem more to the core or more abstractly. I feel the best way to explain my problem is by means of this quite specific example.
I want to define a function 'readCollection' which would parse a String and give me a specific collection of a specific type, based on how I call... | 2013/01/09 | [
"https://Stackoverflow.com/questions/14247932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1648459/"
] | Think about splitting up the parsing/construction from the object itself. In many cases, the two are very separate concerns.
You're on the right track, but I would recommend:
1. Don't have your element types inherit from the `Readable` interface
2. Rename the `Readable` interface to `Reader`
3. Implement a `Reader` ... | I'm glad that I'm able to tell you that I have found the final and best answer myself, with the help of your comment (@stevevls) and the help of a friend.
I now have
```
public interface Reader {
public Reader read(String str); }
```
so I've removed the generic argument, shich was unneccesary
```
public class ... |
40,107,754 | >
> I have two kind of profiles in database.one is candidate
> prodile,another is job profile posted by recruiter.
>
>
> in both the profiles i have 3 common field say location,skill and
> experience
>
>
> i know the algorithm but i am having problem in creating training data
> set where my input feature will b... | 2016/10/18 | [
"https://Stackoverflow.com/questions/40107754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3411933/"
] | As I understand you want to predict job profile given candidate profile using some prediction algorithm.
Well, if you want to use regression you need to know some historical data -- which candidates were given which jobs, then you can create some model based on this historical data. If you don't have such training da... | You could look at "recommender systems", they can be an answer to your problem.
Starting with a content based algorithm (you will have to find a way to automate the labels of the jobs, or manually do them), you can improve to an hybrid one by gathering which jobs your users were actually interested (and become an hybri... |
379,044 | Cannot access SAMBA share on Ubuntu 12.04 box from XP box.
SAMBA is up and running on the Ubuntu box. `smb.conf` has the correct windows workgroup name in it, and I can see the Ubuntu box from the XP machine.
On the Ubuntu box, I have set up a UNIX username `CCD1` with a password for the purposes of sharing. I have ... | 2013/11/18 | [
"https://askubuntu.com/questions/379044",
"https://askubuntu.com",
"https://askubuntu.com/users/112740/"
] | I just want to get into a public record that nowadays you need to add these configurations into the [Global] section of /etc/samba/smb.conf to make Windows XP able to connect to your Samba 4.5 server:
```
server max protocol = NT1
lanman auth = yes
ntlm auth = yes
```
Of course that compromises the security on some ... | For me it works:
Edit `/etc/samba/smb.cfg`.
Add the following at beginning (global):
```
server min protocol = NT1
lanman auth = yes
ntlm auth = yes
```
NT1 is a old version of security: SMBv1... necessary for Windows XP!
The other 2 lines is necessary to make logon, if not, you cannot make login. |
379,044 | Cannot access SAMBA share on Ubuntu 12.04 box from XP box.
SAMBA is up and running on the Ubuntu box. `smb.conf` has the correct windows workgroup name in it, and I can see the Ubuntu box from the XP machine.
On the Ubuntu box, I have set up a UNIX username `CCD1` with a password for the purposes of sharing. I have ... | 2013/11/18 | [
"https://askubuntu.com/questions/379044",
"https://askubuntu.com",
"https://askubuntu.com/users/112740/"
] | Just to update on the answer from @loop. I'd recommend using `min protocol = NT1` instead of `server max protocol = NT1` to allow other clients to use the more up-to-date and secure versions of SMB. | For me it works:
Edit `/etc/samba/smb.cfg`.
Add the following at beginning (global):
```
server min protocol = NT1
lanman auth = yes
ntlm auth = yes
```
NT1 is a old version of security: SMBv1... necessary for Windows XP!
The other 2 lines is necessary to make logon, if not, you cannot make login. |
58,097,820 | Given this json object
```
{
"contacts": [
{
"name": "Jane doe",
"numbers": [
{
"number": "07123456789"
}
],
"groups": [
{
"group": "Everyone"
},
... | 2019/09/25 | [
"https://Stackoverflow.com/questions/58097820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10483212/"
] | Following this [post](https://stackoverflow.com/questions/38375646/filtering-array-of-objects-with-arrays-based-on-nested-value) i changed the second most upvoted answer code a bit to have this :
```
const getContactsByGroupName = (groupName) => {
return a.contacts
.filter((element) =>
element.... | You could simply run trough every entry of contacts and generate an output-object containing arrays of numbers for each group. Here is an example.
```js
var input_json = {
"contacts": [
{
"name": "Jane doe",
"numbers": [
{
"number": "0712345... |
58,097,820 | Given this json object
```
{
"contacts": [
{
"name": "Jane doe",
"numbers": [
{
"number": "07123456789"
}
],
"groups": [
{
"group": "Everyone"
},
... | 2019/09/25 | [
"https://Stackoverflow.com/questions/58097820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10483212/"
] | The following can do what you want with simply using the Array prototype methods:
```
function filterByGroup(obj, val) {
const objArray = obj.contacts.filter((innerObj, index, array) => {
a = innerObj.groups.filter(group => group.group === val)
return a.length > 0 ? innerObj : false;
}... | You could simply run trough every entry of contacts and generate an output-object containing arrays of numbers for each group. Here is an example.
```js
var input_json = {
"contacts": [
{
"name": "Jane doe",
"numbers": [
{
"number": "0712345... |
58,097,820 | Given this json object
```
{
"contacts": [
{
"name": "Jane doe",
"numbers": [
{
"number": "07123456789"
}
],
"groups": [
{
"group": "Everyone"
},
... | 2019/09/25 | [
"https://Stackoverflow.com/questions/58097820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10483212/"
] | Here is piece of code which creates a JSON which has three groups of numbers:
```
final_data = {"Everyone": [], "Exec": [], "Overseas": [] }
data.contacts.forEach( (contact) => {
contact.groups.forEach(group => {
final_data[group.group].push(contact.numbers);
})
})
console.log(final_data);
``` | You could simply run trough every entry of contacts and generate an output-object containing arrays of numbers for each group. Here is an example.
```js
var input_json = {
"contacts": [
{
"name": "Jane doe",
"numbers": [
{
"number": "0712345... |
58,097,820 | Given this json object
```
{
"contacts": [
{
"name": "Jane doe",
"numbers": [
{
"number": "07123456789"
}
],
"groups": [
{
"group": "Everyone"
},
... | 2019/09/25 | [
"https://Stackoverflow.com/questions/58097820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10483212/"
] | Following this [post](https://stackoverflow.com/questions/38375646/filtering-array-of-objects-with-arrays-based-on-nested-value) i changed the second most upvoted answer code a bit to have this :
```
const getContactsByGroupName = (groupName) => {
return a.contacts
.filter((element) =>
element.... | The following can do what you want with simply using the Array prototype methods:
```
function filterByGroup(obj, val) {
const objArray = obj.contacts.filter((innerObj, index, array) => {
a = innerObj.groups.filter(group => group.group === val)
return a.length > 0 ? innerObj : false;
}... |
58,097,820 | Given this json object
```
{
"contacts": [
{
"name": "Jane doe",
"numbers": [
{
"number": "07123456789"
}
],
"groups": [
{
"group": "Everyone"
},
... | 2019/09/25 | [
"https://Stackoverflow.com/questions/58097820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10483212/"
] | Following this [post](https://stackoverflow.com/questions/38375646/filtering-array-of-objects-with-arrays-based-on-nested-value) i changed the second most upvoted answer code a bit to have this :
```
const getContactsByGroupName = (groupName) => {
return a.contacts
.filter((element) =>
element.... | Here is piece of code which creates a JSON which has three groups of numbers:
```
final_data = {"Everyone": [], "Exec": [], "Overseas": [] }
data.contacts.forEach( (contact) => {
contact.groups.forEach(group => {
final_data[group.group].push(contact.numbers);
})
})
console.log(final_data);
``` |
8,143,321 | i want my bitmap in the center of my screen..i m trying it that way but its not working...
```
Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.compass);
int w = canvas.getWidth();
int h = canvas.getHeight();
int bw=myBitmap.getWidth();
int bh=... | 2011/11/15 | [
"https://Stackoverflow.com/questions/8143321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/519526/"
] | Here's the code you need in your view:
```java
private int mWidth;
private int mHeight;
private float mAngle;
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
mWidth = View.MeasureSpec.getSize(widthMeasureSpec);
mHeight = View.MeasureSpec.getSize(heightMeasureSpec);
setMe... | You can try this :
```
int width = containerBitmap.getWidth();
int height = containerBitmap.getHeight();
float centerX = (width - centeredBitmap.getWidth()) * 0.5f;
float centerY = (height- centeredBitmap.getHeight()) * 0.5f;
```
You can use it to draw a bitmap at the center of anot... |
53,234,529 | So this is new on V2, when I publish with Visual Studio (probably with vsts publishing as well). It says the dll is busy, it didn't used to do that in V1.
I suppose it's fine to stop the functions (Or probably I can do slot deployment as well, although all mine are triggered and scheduled, so I don't really need slots... | 2018/11/09 | [
"https://Stackoverflow.com/questions/53234529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1216820/"
] | Looks like you meet [ERROR\_FILE\_IN\_USE](https://learn.microsoft.com/en-us/iis/publish/troubleshooting-web-deploy/web-deploy-error-codes#errorfileinuse).
You can configure the appOffline rule in the publishing profile (In Solution explorer> Properties>PublishProfiles>\*.pubxml). Set the EnableMSDeployAppOffline to t... | With the caveat that ZIP deployment is now preferred, the solution to this is to add an app setting MSDEPLOY\_RENAME\_LOCKED\_FILES with value 1. |
178,951 | "A" is related to "B" and "C". How do I show that "B" and "C" might, by this context, be related as well?
### Example:
Here are a few headlines about a recent Broadway play:
1. David Mamet's Glengarry Glen Ross, Starring Al Pacino, Opens on Broadway
2. Al Pacino in 'Glengarry Glen Ross': What did the critics think?... | 2012/12/10 | [
"https://softwareengineering.stackexchange.com/questions/178951",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/74763/"
] | It's called [cluster analysis](http://en.wikipedia.org/wiki/Cluster_analysis), which is basically grouping objects into clusters with similar properties. It's a huge topic, but that should give you a place to start. | You're entering the world of Semantics. There are public services that will parse text and pull out the major concepts (a quick search for [Semantic API](http://www.bing.com/search?q=semantic%20api&src=ie9tr) turned up a few) that will parse a free form document and return the major topics encountered including people,... |
178,951 | "A" is related to "B" and "C". How do I show that "B" and "C" might, by this context, be related as well?
### Example:
Here are a few headlines about a recent Broadway play:
1. David Mamet's Glengarry Glen Ross, Starring Al Pacino, Opens on Broadway
2. Al Pacino in 'Glengarry Glen Ross': What did the critics think?... | 2012/12/10 | [
"https://softwareengineering.stackexchange.com/questions/178951",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/74763/"
] | It's called [cluster analysis](http://en.wikipedia.org/wiki/Cluster_analysis), which is basically grouping objects into clusters with similar properties. It's a huge topic, but that should give you a place to start. | If at all possible, get the story along with the headline. Headlines can sometimes get "cute" and make only tangential reference to what is being discussed. This works OK with humans (because they have *global context*), but not so well with NLP.
As mentioned in Karl Bielefeldt's answer, clustering is a good approach,... |
178,951 | "A" is related to "B" and "C". How do I show that "B" and "C" might, by this context, be related as well?
### Example:
Here are a few headlines about a recent Broadway play:
1. David Mamet's Glengarry Glen Ross, Starring Al Pacino, Opens on Broadway
2. Al Pacino in 'Glengarry Glen Ross': What did the critics think?... | 2012/12/10 | [
"https://softwareengineering.stackexchange.com/questions/178951",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/74763/"
] | You're entering the world of Semantics. There are public services that will parse text and pull out the major concepts (a quick search for [Semantic API](http://www.bing.com/search?q=semantic%20api&src=ie9tr) turned up a few) that will parse a free form document and return the major topics encountered including people,... | If at all possible, get the story along with the headline. Headlines can sometimes get "cute" and make only tangential reference to what is being discussed. This works OK with humans (because they have *global context*), but not so well with NLP.
As mentioned in Karl Bielefeldt's answer, clustering is a good approach,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.