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 |
|---|---|---|---|---|---|
40,258,599 | I am having a little routing problem in Laravel 5.2. I have a result page which shows detailed information about personnel. I would like a button, which when enabled, generates a PDF page. Passing the variables has been a problem but I am very close now! I will public my code to elaborate.
result page
```
<form acti... | 2016/10/26 | [
"https://Stackoverflow.com/questions/40258599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6925077/"
] | When you're using `get` method, you can do just this:
```
<a href="{{ route('route.name', $parameter) }}">
<button type="submit" class="btn btn-default">Generate PDF!</button>
</a>
```
For other methods you can use something like this (this one is for `DELETE` method):
```
<form method="POST" action="{{ route('... | I don't know Laravel but I think when in your `action=""` of the form you can put your route with its parameters no ?
I've found it here : <https://laravel.com/docs/4.2/html#opening-a-form>
And access the variable in your controller using the `$request` var |
55,635 | I am trying to advertise some discounts in Facebook and to do that I have to provide an image that has a small amount of text informing potential customers about the discount I am offering.
I am having trouble deciding where to properly place the text, what size it should be or what color. My goal is to make the text ... | 2015/06/25 | [
"https://graphicdesign.stackexchange.com/questions/55635",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/45859/"
] | First of all my suggestion would be to ensure that the aspect ration of the image is maintained. This is one of the most important aspect of making any design aesthetically pleasing.
Secondly, my suggestion would be to create a tab on the side of the image, (As I think you have a narrower image than required.
This tab... | My suggestion is to create narrow white rectangle box spanning the entire image width and place the discount info in that box. Use simple fonts, no glow or anything just contrasting color for the font. The rest of the info goes just below that white box with contact info on the bottom left corner. |
55,635 | I am trying to advertise some discounts in Facebook and to do that I have to provide an image that has a small amount of text informing potential customers about the discount I am offering.
I am having trouble deciding where to properly place the text, what size it should be or what color. My goal is to make the text ... | 2015/06/25 | [
"https://graphicdesign.stackexchange.com/questions/55635",
"https://graphicdesign.stackexchange.com",
"https://graphicdesign.stackexchange.com/users/45859/"
] | First of all my suggestion would be to ensure that the aspect ration of the image is maintained. This is one of the most important aspect of making any design aesthetically pleasing.
Secondly, my suggestion would be to create a tab on the side of the image, (As I think you have a narrower image than required.
This tab... | Here are some thoughts that hopefully arn't too off topic.
In some cases **it may be better to leave out some of the information** on the image and place that in the message area on Facebook. One suggestion, have the only text on the image be "$40 OFF MOBILE CAR DETAILING.
Example
;
global $user_email;
get_currentuserinfo();
$headers_mail = "From: ".$current->first_name." ".$current->last_name." <".$user_email... | 2011/09/28 | [
"https://Stackoverflow.com/questions/7581936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343201/"
] | No, `C#` do not allows this.
Specification section 1.6.7.3 saying:
>
> An indexer is a member that enables objects to be indexed in the same
> way as an array. An indexer is declared like a property except that
> the name of the member is this followed by a parameter list written
> between the delimiters [ and ].... | No,
Actually your property `Value` already have indexer from string and returns char. Probably you need something like this:
```
public class MyClass
{
Dictionary<int, string> myCollection = new Dictionary<int, string>();
public Dictionary<int, string> Value
{
get { return myCollection; }
set {... |
7,581,936 | I would to customize the sender of the email so I am trying to set properly the headers of the email.
This is the cose I use to customize the headers:
```
$current = wp_get_current_user();
global $user_email;
get_currentuserinfo();
$headers_mail = "From: ".$current->first_name." ".$current->last_name." <".$user_email... | 2011/09/28 | [
"https://Stackoverflow.com/questions/7581936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343201/"
] | No, `C#` do not allows this.
Specification section 1.6.7.3 saying:
>
> An indexer is a member that enables objects to be indexed in the same
> way as an array. An indexer is declared like a property except that
> the name of the member is this followed by a parameter list written
> between the delimiters [ and ].... | You can't do it that way, (not supported by C#)
How about instead
```
public class MyClass
{
public MyClass()
{
Values = new Dictionary<int, string>()
}
public Dictionary<int, string> Values { get; set }
}
```
which will then allow you to do
```
MyClass foo = new MyClass();
var someV... |
7,581,936 | I would to customize the sender of the email so I am trying to set properly the headers of the email.
This is the cose I use to customize the headers:
```
$current = wp_get_current_user();
global $user_email;
get_currentuserinfo();
$headers_mail = "From: ".$current->first_name." ".$current->last_name." <".$user_email... | 2011/09/28 | [
"https://Stackoverflow.com/questions/7581936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343201/"
] | No,
Actually your property `Value` already have indexer from string and returns char. Probably you need something like this:
```
public class MyClass
{
Dictionary<int, string> myCollection = new Dictionary<int, string>();
public Dictionary<int, string> Value
{
get { return myCollection; }
set {... | You can't do it that way, (not supported by C#)
How about instead
```
public class MyClass
{
public MyClass()
{
Values = new Dictionary<int, string>()
}
public Dictionary<int, string> Values { get; set }
}
```
which will then allow you to do
```
MyClass foo = new MyClass();
var someV... |
20,333,827 | I got a linked list with only one node. How do you remove that only node?
You can't "skip" it by pointing the `*next` struct of the previous struct to the next structure because there are no next structures, nor previous structures.
I've tried using `free()` but it didn't work either.
So the question is:
How do you rem... | 2013/12/02 | [
"https://Stackoverflow.com/questions/20333827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2809690/"
] | Because there are multiple ways in which linked lists are used, there's no single pattern which is best for every application. Nonetheless, a pattern which is very frequently helpful is to have one or two "special" and/or "pre-allocated" nodes which are used for the start and/or end of a linked list (sometimes it's hel... | Assuming you have
```
struct foo * head;
```
somewhere which actually **does** point at your node, you should be able to
```
free(head);
```
If you can't, then you should post your code so that we can look at what you're actually doing wrong. |
20,333,827 | I got a linked list with only one node. How do you remove that only node?
You can't "skip" it by pointing the `*next` struct of the previous struct to the next structure because there are no next structures, nor previous structures.
I've tried using `free()` but it didn't work either.
So the question is:
How do you rem... | 2013/12/02 | [
"https://Stackoverflow.com/questions/20333827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2809690/"
] | Assuming you have
```
struct foo * head;
```
somewhere which actually **does** point at your node, you should be able to
```
free(head);
```
If you can't, then you should post your code so that we can look at what you're actually doing wrong. | If you have the lasting node, then the `head` is that node. So, after you `free(head)` , make sure to declare `head = NULL` . This a good practice as long as I understand.
And, let's say you have a function to delete nodes. At the beginning, don't forget to code
```
if (*head == NULL)
return ("your error code... |
20,333,827 | I got a linked list with only one node. How do you remove that only node?
You can't "skip" it by pointing the `*next` struct of the previous struct to the next structure because there are no next structures, nor previous structures.
I've tried using `free()` but it didn't work either.
So the question is:
How do you rem... | 2013/12/02 | [
"https://Stackoverflow.com/questions/20333827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2809690/"
] | Because there are multiple ways in which linked lists are used, there's no single pattern which is best for every application. Nonetheless, a pattern which is very frequently helpful is to have one or two "special" and/or "pre-allocated" nodes which are used for the start and/or end of a linked list (sometimes it's hel... | If you have the lasting node, then the `head` is that node. So, after you `free(head)` , make sure to declare `head = NULL` . This a good practice as long as I understand.
And, let's say you have a function to delete nodes. At the beginning, don't forget to code
```
if (*head == NULL)
return ("your error code... |
3,273,869 | I am trying to clear up my conceptions of merge sort. What I cannot understand how merge sort takes less number of comparisons during best case.
Let me explain, looking at the merge procedure given below, I can make some inferences. First, merge sort will always take $\log\_2{n}$ divisions. Whether it is best or the ... | 2019/06/25 | [
"https://math.stackexchange.com/questions/3273869",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/407302/"
] | When merging $L\_1 = (a\_1, a\_2, a\_3, a\_4)$ and $L\_2 = (b\_1, b\_2, b\_3, b\_4)$, it's true that we need $4$ comparisons when all elements of $L\_1$ come before all elements of $L\_2$ (which is the best case). It's also true that we need $4$ comparisons when all elements of $L\_2$ come before all elements of $L1$.
... | The advantage of *merge sort* in best cases arises when you sort linked lists. For example if you merge one list L1 with another L2 whose elements are all smaller, you will scan L1 and then directly attache L2 at the end of L1. That makes for $O(n\_1)$ operations as opposed to $O(n\_1+n\_2)$.
If you want to work on ar... |
67,757,485 | I have a service to make HTTP requests as below. I am trying to add dynamic content type in the request header in the service.
How I can add the content type as an extra argument in the `apiCall` function?
```js
@Injectable()
export class AjaxService {
constructor(private _http: HttpClient) {}
apiCall(
... | 2021/05/30 | [
"https://Stackoverflow.com/questions/67757485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12626654/"
] | You can try Runtime Settings below your code inside the AWS Management Console for your lambda handler. There you can choose your runtime (eg. Python 3.8 or 2.7). Up to you to fix all back-compatibility issues.
Obviously, this means you need to do this for each one of your handlers.
A better way, if you aren't doing t... | If you want to do it the manual way go to the Lambda Console -> Actions -> Export Function -> Download Deployment Package. This will download a zip with the Lambda and any supporting libraries. This process can be reversed by createing a new Lambda with the correct name and role and runtime and then the Upload From -> ... |
67,757,485 | I have a service to make HTTP requests as below. I am trying to add dynamic content type in the request header in the service.
How I can add the content type as an extra argument in the `apiCall` function?
```js
@Injectable()
export class AjaxService {
constructor(private _http: HttpClient) {}
apiCall(
... | 2021/05/30 | [
"https://Stackoverflow.com/questions/67757485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12626654/"
] | You can try Runtime Settings below your code inside the AWS Management Console for your lambda handler. There you can choose your runtime (eg. Python 3.8 or 2.7). Up to you to fix all back-compatibility issues.
Obviously, this means you need to do this for each one of your handlers.
A better way, if you aren't doing t... | As @markonic said, you need handling of your code to be compatible with python3.X.
But about only to changing your lambda runtime of 2.7 to 3.6 you can use the command below:
```
aws lambda --region 'us-east-1' update-function-configuration \
--function-name ArnOfYourFunction \
--runtime python3.6
```
You can use ... |
67,757,485 | I have a service to make HTTP requests as below. I am trying to add dynamic content type in the request header in the service.
How I can add the content type as an extra argument in the `apiCall` function?
```js
@Injectable()
export class AjaxService {
constructor(private _http: HttpClient) {}
apiCall(
... | 2021/05/30 | [
"https://Stackoverflow.com/questions/67757485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12626654/"
] | If you want to do it the manual way go to the Lambda Console -> Actions -> Export Function -> Download Deployment Package. This will download a zip with the Lambda and any supporting libraries. This process can be reversed by createing a new Lambda with the correct name and role and runtime and then the Upload From -> ... | As @markonic said, you need handling of your code to be compatible with python3.X.
But about only to changing your lambda runtime of 2.7 to 3.6 you can use the command below:
```
aws lambda --region 'us-east-1' update-function-configuration \
--function-name ArnOfYourFunction \
--runtime python3.6
```
You can use ... |
20,722,263 | I need to return back to the beginning of the code shown here after a user enters the wrong key. Is there any simple line of code that will just return back to another line? As you can see I already have an if statement set up so I can just add something that can return back to the beginning or to another area in my co... | 2013/12/21 | [
"https://Stackoverflow.com/questions/20722263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3117457/"
] | C# supports labels in code, however it is not recommended due to the fact that it violates many coding best practices, but I guess there is always an exception to any rule.
```
class Program
{
static void Main(string[] args)
{
Start:
Console.WriteLine("Start Here... Press any key");
var key... | you have a couple options, you can use a while loop
```
bool continue = true;
while(continue == true)// or you can simply type "while(continue)"
{
/* everything inside the `while` loop will be
repeated until `continue` is not `true`. */
}
```
you can also use methods
```
public static void doStuff()
{
... |
20,722,263 | I need to return back to the beginning of the code shown here after a user enters the wrong key. Is there any simple line of code that will just return back to another line? As you can see I already have an if statement set up so I can just add something that can return back to the beginning or to another area in my co... | 2013/12/21 | [
"https://Stackoverflow.com/questions/20722263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3117457/"
] | C# supports labels in code, however it is not recommended due to the fact that it violates many coding best practices, but I guess there is always an exception to any rule.
```
class Program
{
static void Main(string[] args)
{
Start:
Console.WriteLine("Start Here... Press any key");
var key... | One answer to this is to check that you have valid input in a loop like this:
```
while (true)
{
ConsoleKey i = Console.ReadKey()
if (i == ConsoleKey.D1 || ... ) //Check if it's equal to any valid key, you
//might be able to simplify it with <= and
... |
17,620,102 | We have an intern who wrote
```
$this->method(ct);
```
instead of
```
$this->method('ct');
```
This doesn't throw an error, but I want it to. How?
I don't like PHP guessing. | 2013/07/12 | [
"https://Stackoverflow.com/questions/17620102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448147/"
] | It is documented behaviour that PHP treats an undefined constant as a string constant with the name of the constant as a value. So this code actually works!
It issues a warning, though, but that warning may be ignored. You can call [`error_reporting`](http://php.net/manual/en/function.error-reporting.php) to set whic... | in your method do testing if argument is string
```
function method($arg){
if (!is_string($arg)){
throw new exception("argument must be a string. ".get_type($arg)." given");
}
}
``` |
17,620,102 | We have an intern who wrote
```
$this->method(ct);
```
instead of
```
$this->method('ct');
```
This doesn't throw an error, but I want it to. How?
I don't like PHP guessing. | 2013/07/12 | [
"https://Stackoverflow.com/questions/17620102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448147/"
] | Turn on PHP error reporting with `error_reporting(E_ALL)` so that all warnings and errors are reported. From there, you can make your own error handling method to catch these warnings/errors and do with them what you want instead of them just being piped out to the output. A good example of an error handling method is ... | in your method do testing if argument is string
```
function method($arg){
if (!is_string($arg)){
throw new exception("argument must be a string. ".get_type($arg)." given");
}
}
``` |
17,620,102 | We have an intern who wrote
```
$this->method(ct);
```
instead of
```
$this->method('ct');
```
This doesn't throw an error, but I want it to. How?
I don't like PHP guessing. | 2013/07/12 | [
"https://Stackoverflow.com/questions/17620102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448147/"
] | Turn on PHP error reporting with `error_reporting(E_ALL)` so that all warnings and errors are reported. From there, you can make your own error handling method to catch these warnings/errors and do with them what you want instead of them just being piped out to the output. A good example of an error handling method is ... | It is documented behaviour that PHP treats an undefined constant as a string constant with the name of the constant as a value. So this code actually works!
It issues a warning, though, but that warning may be ignored. You can call [`error_reporting`](http://php.net/manual/en/function.error-reporting.php) to set whic... |
26,404,999 | Really basic question:
I have items being added to some collection (I don't mind which yet) and I want a method which prints the items in groups e.g.
```
public enum Animal{
COW("cow"), PIG("pig"), SHEEP("sheep");
private String itemName;
public String toString() {
return itemName;
}
}
public class Farm {
pri... | 2014/10/16 | [
"https://Stackoverflow.com/questions/26404999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3734896/"
] | Yes `HashMap` is the better choice,but use your `Animal` as a `key` here
```
HashMap<Animal, Integer> animalHashMap=new HashMap<Animal, Integer>();
animalHashMap.put(Animal.COW, 3);
animalHashMap.put(Animal.SHEEP, 10);
animalHashMap.put(Animal.PIG, 2);
``` | You could use a Multiset(Bag) e.g. from the guava collection: [Multiset](https://code.google.com/p/guava-libraries/wiki/NewCollectionTypesExplained#Multiset)
You just add the elements (animals) and can query for each animal how many times it is in the set.
Usage:
```
Multiset<String> animals = HashMultiset.creat... |
26,404,999 | Really basic question:
I have items being added to some collection (I don't mind which yet) and I want a method which prints the items in groups e.g.
```
public enum Animal{
COW("cow"), PIG("pig"), SHEEP("sheep");
private String itemName;
public String toString() {
return itemName;
}
}
public class Farm {
pri... | 2014/10/16 | [
"https://Stackoverflow.com/questions/26404999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3734896/"
] | Yes `HashMap` is the better choice,but use your `Animal` as a `key` here
```
HashMap<Animal, Integer> animalHashMap=new HashMap<Animal, Integer>();
animalHashMap.put(Animal.COW, 3);
animalHashMap.put(Animal.SHEEP, 10);
animalHashMap.put(Animal.PIG, 2);
``` | It depends on what you want to do
The idea of a `ArrayList` is to keep items in order. Then if its a requirement then you should keep using it and use another algorithm to count them.
But if you dont want any of those details you can use something like a `MultiMap` (not native java). Or you can create one of your ow... |
26,404,999 | Really basic question:
I have items being added to some collection (I don't mind which yet) and I want a method which prints the items in groups e.g.
```
public enum Animal{
COW("cow"), PIG("pig"), SHEEP("sheep");
private String itemName;
public String toString() {
return itemName;
}
}
public class Farm {
pri... | 2014/10/16 | [
"https://Stackoverflow.com/questions/26404999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3734896/"
] | Yes `HashMap` is the better choice,but use your `Animal` as a `key` here
```
HashMap<Animal, Integer> animalHashMap=new HashMap<Animal, Integer>();
animalHashMap.put(Animal.COW, 3);
animalHashMap.put(Animal.SHEEP, 10);
animalHashMap.put(Animal.PIG, 2);
``` | With Java 8 you can stream the animals and count them:
```
Map<Animal, Long> summary = animals.stream().collect(groupingBy(a -> a, counting()));
```
which requires the following imports:
```
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
``` |
26,404,999 | Really basic question:
I have items being added to some collection (I don't mind which yet) and I want a method which prints the items in groups e.g.
```
public enum Animal{
COW("cow"), PIG("pig"), SHEEP("sheep");
private String itemName;
public String toString() {
return itemName;
}
}
public class Farm {
pri... | 2014/10/16 | [
"https://Stackoverflow.com/questions/26404999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3734896/"
] | Yes `HashMap` is the better choice,but use your `Animal` as a `key` here
```
HashMap<Animal, Integer> animalHashMap=new HashMap<Animal, Integer>();
animalHashMap.put(Animal.COW, 3);
animalHashMap.put(Animal.SHEEP, 10);
animalHashMap.put(Animal.PIG, 2);
``` | From your question you don't need to keep track of each element's order so you don't have to use an `ArrayList` for example.
You can simply use `EnumMap` with `Integer` as value:
```
EnumMap map = new EnumMap<Animal, Integer>();
```
You can then check for each element if it exist in your map and if so increase the ... |
26,404,999 | Really basic question:
I have items being added to some collection (I don't mind which yet) and I want a method which prints the items in groups e.g.
```
public enum Animal{
COW("cow"), PIG("pig"), SHEEP("sheep");
private String itemName;
public String toString() {
return itemName;
}
}
public class Farm {
pri... | 2014/10/16 | [
"https://Stackoverflow.com/questions/26404999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3734896/"
] | Yes `HashMap` is the better choice,but use your `Animal` as a `key` here
```
HashMap<Animal, Integer> animalHashMap=new HashMap<Animal, Integer>();
animalHashMap.put(Animal.COW, 3);
animalHashMap.put(Animal.SHEEP, 10);
animalHashMap.put(Animal.PIG, 2);
``` | Here's a self-contained example, Java 5+ compatible (within a `Main` class)...
```
public static void main(String[] args) throws Exception {
ArrayList<Animal> animals = new ArrayList<>();
animals.add(Animal.COW);
animals.add(Animal.COW);
animals.add(Animal.PIG);
animals.add(Animal.COW);
animal... |
26,404,999 | Really basic question:
I have items being added to some collection (I don't mind which yet) and I want a method which prints the items in groups e.g.
```
public enum Animal{
COW("cow"), PIG("pig"), SHEEP("sheep");
private String itemName;
public String toString() {
return itemName;
}
}
public class Farm {
pri... | 2014/10/16 | [
"https://Stackoverflow.com/questions/26404999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3734896/"
] | Yes `HashMap` is the better choice,but use your `Animal` as a `key` here
```
HashMap<Animal, Integer> animalHashMap=new HashMap<Animal, Integer>();
animalHashMap.put(Animal.COW, 3);
animalHashMap.put(Animal.SHEEP, 10);
animalHashMap.put(Animal.PIG, 2);
``` | If you don't want to use `Collections.frequency()`. You can store it in a map like this
```
Map< Animal,Integer> countAnimals = new HasMap< Animal,Integer>();
// Initializing all the animal count to zero
for(Animal animal: Animal.values()){
countAnimals(animal,0);
}
// counting for all animals
for(Animal animal:m... |
16,733,133 | I have a Table and its rows are created dynamically.
I want to prompt a message [alert] when the tr or td is generated.
At first it will be like
```
<table class="tab"></table>
```
After that the rows will be added dynamically.
```
<table class="tab">
<tr class="row">
<td> Message1</td>
<td> Message2</td>
... | 2013/05/24 | [
"https://Stackoverflow.com/questions/16733133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1790632/"
] | Here i am Just Modifying Your `Layout` just check it out!!
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/txtFilename"
and... | I have written Demo for this Like:
if you want to fix Height of `ListView` to 5 items. then you have to set Height of `ListView` pragmatically by calculating `listItems` height.
First you need to create Layout for List Item and give it some fixed height, here i'm added height in `Tag` cause `runtime` i was getting l... |
66,439 | As far as I know in sharepoint 2013 app I can deploy lists, content types, etc. And as far as I know these resources are for that app only. So other apps wont be able to access them.
The question is, where are they stored? Are they stored in content database where the app is installed? is storage isolated for each ins... | 2013/04/22 | [
"https://sharepoint.stackexchange.com/questions/66439",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/5032/"
] | There are different types of apps and where they are stored is based on there type.
Check this figure out,

[Source - 1](http://msdn.microsoft.com/en-us/library/fp179930.aspx)
>
> If an app contains SharePoint components, those components are sto... | The simple answer would have been:
```
1. SharePoint Hosted App - a subweb of the site that is automatically created when you install the app (the ugly URL using wildcard Site Collections)
2. Auto-Hosted Apps - in Azure Webs
3. Provider-Hosted - depends on the Provider setup - usually on other servers outside Share... |
29,891,580 | Can I use an XmlWriter to write to **both** a file and a string?
When writing to a file I do this:
```
using (var xw = XmlWriter.Create("myFile.xml"))
{
//Build the xml
}
```
And when writing to a string I do this:
```
using (var sw = new StringWriter())
{
using (var xw = XmlWriter.Create(sw))
{
... | 2015/04/27 | [
"https://Stackoverflow.com/questions/29891580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4836949/"
] | You could create a method like this:
```
private static void WriteXML(TextWriter writer)
{
using (var xw = XmlWriter.Create(writer))
{
// Build the xml
}
}
```
And then call it like:
```
using (StreamWriter sw = new StreamWriter(...))
WriteXML(sw);
```
to write a file or
```
string xml = ... | Create a [composite](http://en.wikipedia.org/wiki/Composite_pattern) `XmlWriter` which wraps many `XmlWriter` instances.
```
public class CompositeXmlWriter : XmlWriter
{
private readonly IEnumerable<XmlWriter> writers;
public CompositeXmlWriter(IEnumerable<XmlWriter> writers)
{
this.writers = writ... |
72,009 | I'm running a full node (v0.16.0). I added txnindex=1 to my configuration file and restarted the Bitcoin-Qt. It took 2+ days to build the index but when I check addresses with known final balances>0 the amount is still zero. For example...
REMOTE FINAL BALANCE=66.76870249 BTC:
```
https://blockchain.info/address/1A1z... | 2018/03/08 | [
"https://bitcoin.stackexchange.com/questions/72009",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/77986/"
] | One can't say what's more or less dangerous for a cryptocurrency value. You don't have a control group. You would need a parallel universe where Flypool had no more than 51% to compare prices there to prices in our universe.
Saying that, being decentralized it's the very point of a cryptocurrency, and very few people ... | Mining pools besides ASIC manufactures are extremely dangerous for every PoW based cryptocurrency. A mining pool or a group of pools with >51% hashing power can destroy the network in minutes. The fact you wonder why Flypool doesn't double spend on ZCash is a bad thing per se. You shouldn't ever be in a position you ha... |
35,466,486 | I managed to do this.
BUT I need at the end of this image gallery to have two links.
Right after last image in the middle of the screen I need to have (next, info) links.
please help, thanks.
I dont want any javascript. I tried everything but the text I cannot make to be where i want to.
```css
html, body{
wi... | 2016/02/17 | [
"https://Stackoverflow.com/questions/35466486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5513151/"
] | Using [Css only](https://codepen.io/Microsmsm/pen/mVgKEP) Here
`CSS Only`
```css
@keyframes slidy {
0% {
left: 0%;
}
20% {
left: 0%;
}
25% {
left: -100%;
}
45% {
left: -100%;
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: -300%;
}
... | you can use flexbox:
html:
```
<ul>
<li>
<img src="http://filipkartousek.com/new/Barum/01.jpg"/>
</li>
<li>
<img src="http://filipkartousek.com/new/Barum/02.jpg"/>
</li>
<li>
<img src="http://filipkartousek.com/new/Barum/03.jpg"/>
</li>
<li>
<img src="http://filipkartousek.com/new/Baru... |
35,466,486 | I managed to do this.
BUT I need at the end of this image gallery to have two links.
Right after last image in the middle of the screen I need to have (next, info) links.
please help, thanks.
I dont want any javascript. I tried everything but the text I cannot make to be where i want to.
```css
html, body{
wi... | 2016/02/17 | [
"https://Stackoverflow.com/questions/35466486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5513151/"
] | Here is a copy of yours having links in the end.
I changed the `ul`/`li` to `display: table`/`display: table-cell`.
```css
html, body{
width:100%;
height:100%;
font-family: "minion-pro", serif !important;
}
#wrapper {
height: 100%;
}
html, body, ul, li{
padding:0;
margin:0;
border:0;
tex... | you can use flexbox:
html:
```
<ul>
<li>
<img src="http://filipkartousek.com/new/Barum/01.jpg"/>
</li>
<li>
<img src="http://filipkartousek.com/new/Barum/02.jpg"/>
</li>
<li>
<img src="http://filipkartousek.com/new/Barum/03.jpg"/>
</li>
<li>
<img src="http://filipkartousek.com/new/Baru... |
65,737 | You have `n` students sitting in a line and you want to move them so that no student is sitting next to anyone they were originally sitting next to. What is the minimum total distance the students have to move to achieve this?
Say the students start at desks numbered `1` to `n`, all those desks have be filled with stu... | 2018/05/13 | [
"https://puzzling.stackexchange.com/questions/65737",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/8998/"
] | Here's a first attempt at a bound. I claim that:
>
> For $n = 5k$, we may attain $6k$ total distance. (This also holds true for $n = 5k-1, 5k+1$ with minor modifications.)
>
> To do this, we may partition in groups of 5, ordering the students $5a+1, 5a+2, 5a+3, 5a+4, 5a+5 \rightarrow 5a+1, 5a+3, 5a+5, 5a+2, 5a+4... | **An easy lower bound:**
>
> For $n$ students, there must be at least $\frac{1}{2}n$ moves (rounded up).
>
>
>
Because
>
> For any pair of neighbours, *at least one of them* has to move.
>
>
>
**We can improve this:**
>
> For $n$ students, there must be at least $\frac{2}{3}n$ moves (rounded up).
>
> ... |
6,436,722 | I have 2 related questions for my web cam live capture application.
1. The webcams capture data in varying formats such as YUY2, RGB24, I420, MJPG etc. I need to convert the captured data to I420 irrespective of the input format. Hence I need to know the current scope/capability of the Direct Show inbuilt Transform f... | 2011/06/22 | [
"https://Stackoverflow.com/questions/6436722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809787/"
] | Sample Grabber does not change media type of the data, but if you set a preferred media type before connecting then it will require the input stream to be of that mediatype. Just use RenderStream (intelligent connect, not direct one) and DirectShow will insert required decoders or transformers, if they are present. | Take a look at the RGBFilters example in the directx sdk. For example one of the filters included is TransNull24. That filter will pass all samples unmodified, but is only able to connect when the input is MEDIASUBTYPE\_RGB24. What you do is connect the webcam filter to the TransNull24, and the TransNull24 with the sam... |
1,840,693 | I would like to know if it is possible to do something like this:
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "";
}
}
onHumans: {
test: function() {
... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1840693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447371/"
] | You're missing a comma before onHumans. I've assumed mb to be a global variable; you can use var instead if that's what you need. Also, it's easier to read if you structure it differently, like this:
```
window.mb = window.mb || {};
window.mb = {
tests: {
onAnimals: {
test: function(){
return "";
... | Your code is mostly valid, and you don't even have to do the initial if-check. Just type `var mb = { ...`, and you'll start set `mb` to a new object, regardless of whether it was one before, or undefined, or something else...
What you're missing is a comma after the onAnimals declaration tho:
```
mb = {
tests: {
... |
1,840,693 | I would like to know if it is possible to do something like this:
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "";
}
}
onHumans: {
test: function() {
... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1840693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447371/"
] | You're missing a comma before onHumans. I've assumed mb to be a global variable; you can use var instead if that's what you need. Also, it's easier to read if you structure it differently, like this:
```
window.mb = window.mb || {};
window.mb = {
tests: {
onAnimals: {
test: function(){
return "";
... | You don't need to declare the variable as an object beforehand, simply using the brackets like that is all you need. You do have a syntax error, missing a commas before "onHumans", but aside from that, it looks good to me. You should be able to reach the functions via `mb.tests.onAnimals.test` and `mb.tests.onHumans.te... |
1,840,693 | I would like to know if it is possible to do something like this:
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "";
}
}
onHumans: {
test: function() {
... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1840693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447371/"
] | You're missing a comma before onHumans. I've assumed mb to be a global variable; you can use var instead if that's what you need. Also, it's easier to read if you structure it differently, like this:
```
window.mb = window.mb || {};
window.mb = {
tests: {
onAnimals: {
test: function(){
return "";
... | You are missing a comma before `onHumans`
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "animal";
}
},
onHumans: {
test: function() {
r... |
1,840,693 | I would like to know if it is possible to do something like this:
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "";
}
}
onHumans: {
test: function() {
... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1840693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447371/"
] | You're missing a comma before onHumans. I've assumed mb to be a global variable; you can use var instead if that's what you need. Also, it's easier to read if you structure it differently, like this:
```
window.mb = window.mb || {};
window.mb = {
tests: {
onAnimals: {
test: function(){
return "";
... | As stated in some of the comments above testing for the existence of the variable mb is redundant when you just re-declare it to append your methods and properties.
If you are testing for the existence of the variable to add additional methods to the object you should use a method like jQuery's extend or ExtJs's apply... |
1,840,693 | I would like to know if it is possible to do something like this:
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "";
}
}
onHumans: {
test: function() {
... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1840693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447371/"
] | You are missing a comma before `onHumans`
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "animal";
}
},
onHumans: {
test: function() {
r... | Your code is mostly valid, and you don't even have to do the initial if-check. Just type `var mb = { ...`, and you'll start set `mb` to a new object, regardless of whether it was one before, or undefined, or something else...
What you're missing is a comma after the onAnimals declaration tho:
```
mb = {
tests: {
... |
1,840,693 | I would like to know if it is possible to do something like this:
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "";
}
}
onHumans: {
test: function() {
... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1840693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447371/"
] | You are missing a comma before `onHumans`
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "animal";
}
},
onHumans: {
test: function() {
r... | You don't need to declare the variable as an object beforehand, simply using the brackets like that is all you need. You do have a syntax error, missing a commas before "onHumans", but aside from that, it looks good to me. You should be able to reach the functions via `mb.tests.onAnimals.test` and `mb.tests.onHumans.te... |
1,840,693 | I would like to know if it is possible to do something like this:
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "";
}
}
onHumans: {
test: function() {
... | 2009/12/03 | [
"https://Stackoverflow.com/questions/1840693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/447371/"
] | You are missing a comma before `onHumans`
```
if (mb == null || typeof (mb) != "object") {
var mb = new Object();
}
mb = {
tests: {
onAnimals: {
test: function() {
return "animal";
}
},
onHumans: {
test: function() {
r... | As stated in some of the comments above testing for the existence of the variable mb is redundant when you just re-declare it to append your methods and properties.
If you are testing for the existence of the variable to add additional methods to the object you should use a method like jQuery's extend or ExtJs's apply... |
6,280,670 | I am trying to run this query on <http://dbpedia.org/sparql> but I get an error that my query is too expensive. When I run the query trough <http://dbpedia.org/snorql/> I get:
```
The estimated execution time 25012730 (sec) exceeds the limit of 1500 (sec) ...
```
When running the query through my python script usin... | 2011/06/08 | [
"https://Stackoverflow.com/questions/6280670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159596/"
] | Forget it. You won't be able to get that query back from dbpedia with just one SPARQL. Those optionals are very expensive.
To work it around you need to first run something like:
```
SELECT DISTINCT ?uri WHERE {
?uri rdf:type dbpedia-owl:EducationalInstitution .
?uri foaf:name ?name .... | **Don't** try and get the entire dataset at once! Add a `LIMIT` and a `OFFSET` clause and use those to page through the data.
With `LIMIT 50` added I get back a result for your query almost instantly, I managed to get the limit up much higher than that and still get a response so play with it. Once you've found a page... |
6,280,670 | I am trying to run this query on <http://dbpedia.org/sparql> but I get an error that my query is too expensive. When I run the query trough <http://dbpedia.org/snorql/> I get:
```
The estimated execution time 25012730 (sec) exceeds the limit of 1500 (sec) ...
```
When running the query through my python script usin... | 2011/06/08 | [
"https://Stackoverflow.com/questions/6280670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/159596/"
] | Forget it. You won't be able to get that query back from dbpedia with just one SPARQL. Those optionals are very expensive.
To work it around you need to first run something like:
```
SELECT DISTINCT ?uri WHERE {
?uri rdf:type dbpedia-owl:EducationalInstitution .
?uri foaf:name ?name .... | If you know the exact URI (e.g. from a previous query), then putting the URI directly in the where clause is faster (at least in my experience) than putting the URI in a FILTER.
e.g., prefer:
```
WHERE { <http:/...> ... }
```
over
```
WHERE { ?uri .... FILTER (?uri...)
```
Also I've found UNION's actually perfor... |
37,954,379 | Due to security limitations at work, I am not allowed to install Chrome extensions. Chrome has a ruler built in to the developer tools, but I can't figure out how to define start and end points like a ruler would permit.
Are there any tools or techniques for measuring pixels that don't require installing a Chrome exte... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37954379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221537/"
] | You could create your own ruler functionality and paste it into the console. Here's a basic example:
```js
var fromX, fromY;
var svg = document.createElementNS ('http://www.w3.org/2000/svg',"svg");
svg.setAttribute("style", "position: absolute; top:0;left:0;height: " + document.body.clientHeight + "px;width: 100%");
v... | I think the best you can do without any extensions is a mixture of using the ruler with Inspector, the Computed metrics panel, and the Command Line API to view offsets (as per @amza's suggestion).
In the following screenshot, I have inspected `mainbar` element of this page. You can see the pixel offset from the top-l... |
37,954,379 | Due to security limitations at work, I am not allowed to install Chrome extensions. Chrome has a ruler built in to the developer tools, but I can't figure out how to define start and end points like a ruler would permit.
Are there any tools or techniques for measuring pixels that don't require installing a Chrome exte... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37954379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221537/"
] | If you are not looking for exact measurements, but a ballpark estimate, a tool I use to measure pixels on Chrome without using a Chrome extension is the **macOS** screenshot tool.
Press *Command + shift + 4*, click and drag to measure pixels, and press **ESC** or right-click (if left is your primary mouse button) to ... | I think the best you can do without any extensions is a mixture of using the ruler with Inspector, the Computed metrics panel, and the Command Line API to view offsets (as per @amza's suggestion).
In the following screenshot, I have inspected `mainbar` element of this page. You can see the pixel offset from the top-l... |
37,954,379 | Due to security limitations at work, I am not allowed to install Chrome extensions. Chrome has a ruler built in to the developer tools, but I can't figure out how to define start and end points like a ruler would permit.
Are there any tools or techniques for measuring pixels that don't require installing a Chrome exte... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37954379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221537/"
] | Another way to measure pixel in chrome without extension is:
* Open Developer tool by pressing F12 in window or mouse right click + inspect element
* Inspect element in the browser to measure
* Open Computed tab and mouse over on blocks to see highlighted area in browse.
[.
In the following screenshot, I have inspected `mainbar` element of this page. You can see the pixel offset from the top-l... |
37,954,379 | Due to security limitations at work, I am not allowed to install Chrome extensions. Chrome has a ruler built in to the developer tools, but I can't figure out how to define start and end points like a ruler would permit.
Are there any tools or techniques for measuring pixels that don't require installing a Chrome exte... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37954379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221537/"
] | You could create your own ruler functionality and paste it into the console. Here's a basic example:
```js
var fromX, fromY;
var svg = document.createElementNS ('http://www.w3.org/2000/svg',"svg");
svg.setAttribute("style", "position: absolute; top:0;left:0;height: " + document.body.clientHeight + "px;width: 100%");
v... | If you are not looking for exact measurements, but a ballpark estimate, a tool I use to measure pixels on Chrome without using a Chrome extension is the **macOS** screenshot tool.
Press *Command + shift + 4*, click and drag to measure pixels, and press **ESC** or right-click (if left is your primary mouse button) to ... |
37,954,379 | Due to security limitations at work, I am not allowed to install Chrome extensions. Chrome has a ruler built in to the developer tools, but I can't figure out how to define start and end points like a ruler would permit.
Are there any tools or techniques for measuring pixels that don't require installing a Chrome exte... | 2016/06/21 | [
"https://Stackoverflow.com/questions/37954379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221537/"
] | You could create your own ruler functionality and paste it into the console. Here's a basic example:
```js
var fromX, fromY;
var svg = document.createElementNS ('http://www.w3.org/2000/svg',"svg");
svg.setAttribute("style", "position: absolute; top:0;left:0;height: " + document.body.clientHeight + "px;width: 100%");
v... | Another way to measure pixel in chrome without extension is:
* Open Developer tool by pressing F12 in window or mouse right click + inspect element
* Inspect element in the browser to measure
* Open Computed tab and mouse over on blocks to see highlighted area in browse.
[ to ... | Another way to measure pixel in chrome without extension is:
* Open Developer tool by pressing F12 in window or mouse right click + inspect element
* Inspect element in the browser to measure
* Open Computed tab and mouse over on blocks to see highlighted area in browse.
[ you still need the `android.permission.ACCESS_FINE_LOCATION` and `android.permission.ACCESS_COARSE_LOCATION` permissions to be set in the Manifest and request t... | I found that Andriod 12 still requires Location services enabled, `android.permission.ACCESS_FINE_LOCATION` and additionally `android.permission.BLUETOOTH_SCAN` **without** `android:usesPermissionFlags="neverForLocation"` flag in AndroidManifest, and explicit granting of these permissions by user in runtime to search f... |
70,578,610 | I'm trying to make the function add to cart but it's not working, i got the error as "**cart is not defined**" as i click on the button "add to cart". Is there anything wrong with my codes, please help me! Thank you so much!
App.js:
```
import React, { useState } from "react";
import Products from "./components/Produ... | 2022/01/04 | [
"https://Stackoverflow.com/questions/70578610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17796477/"
] | I found the solution. Contrary to the statements in the [official documentation](https://developer.android.com/guide/topics/connectivity/bluetooth/permissions) you still need the `android.permission.ACCESS_FINE_LOCATION` and `android.permission.ACCESS_COARSE_LOCATION` permissions to be set in the Manifest and request t... | ```
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
android:name="android.permission.BLUETOOTH_CONNECT"
```
Add these two permission in manifest and make to ask permission from user |
70,578,610 | I'm trying to make the function add to cart but it's not working, i got the error as "**cart is not defined**" as i click on the button "add to cart". Is there anything wrong with my codes, please help me! Thank you so much!
App.js:
```
import React, { useState } from "react";
import Products from "./components/Produ... | 2022/01/04 | [
"https://Stackoverflow.com/questions/70578610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17796477/"
] | I found that Andriod 12 still requires Location services enabled, `android.permission.ACCESS_FINE_LOCATION` and additionally `android.permission.BLUETOOTH_SCAN` **without** `android:usesPermissionFlags="neverForLocation"` flag in AndroidManifest, and explicit granting of these permissions by user in runtime to search f... | ```
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
android:name="android.permission.BLUETOOTH_CONNECT"
```
Add these two permission in manifest and make to ask permission from user |
40,599,313 | I have a cpp project which works but has a bad performance.
```
int currentPos = getPos();
int length = getLength();
if (1.0 * currentPos / length < 0.5)
{
// do something
}
else
{
// do something
}
```
The problem is: `1.0 * currentPos / length` takes too much time.
Google told me that division always to... | 2016/11/14 | [
"https://Stackoverflow.com/questions/40599313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3305546/"
] | Division is avoided trivially.
```
if (length > 2 * currentPos)
```
Shift instead of division is a micro-optimisation that any decent compiler will perform automatically for you, without you messing up your code and making it unreadable. | There's a way of making pretty quick divisions by a constant, but that only works if you know the value at compile-time. The general algorithm is described in the book [Hacker's Delight](http://www.hackersdelight.org/divcMore.pdf). There are plenty of examples floating around the internet as well. Your case is differen... |
40,599,313 | I have a cpp project which works but has a bad performance.
```
int currentPos = getPos();
int length = getLength();
if (1.0 * currentPos / length < 0.5)
{
// do something
}
else
{
// do something
}
```
The problem is: `1.0 * currentPos / length` takes too much time.
Google told me that division always to... | 2016/11/14 | [
"https://Stackoverflow.com/questions/40599313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3305546/"
] | Division is avoided trivially.
```
if (length > 2 * currentPos)
```
Shift instead of division is a micro-optimisation that any decent compiler will perform automatically for you, without you messing up your code and making it unreadable. | NOTE: To divide an integer by 2 you only shift by 1 ... (4 >> 1) == 2.
(and 4 >> 2 == 1)
---
I recently learned (the hard way) that full optimization (-O3) does not always do what you want. (g++ v5.2.1, ubuntu 64)
In a 5x10^9 loop, I manually changed code from:
```
if (ZERO == (n & B00) // n-even
{
...even acti... |
40,599,313 | I have a cpp project which works but has a bad performance.
```
int currentPos = getPos();
int length = getLength();
if (1.0 * currentPos / length < 0.5)
{
// do something
}
else
{
// do something
}
```
The problem is: `1.0 * currentPos / length` takes too much time.
Google told me that division always to... | 2016/11/14 | [
"https://Stackoverflow.com/questions/40599313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3305546/"
] | Let's get honest for a moment. On a even remotely modern CPU, division of a floating point number will be pipelined away and take roughly as much time as most other FPU or even Integer operations.
Instead, you should use a profiler on your code to see exactly where your bottlenecks are actually occurring. As your cod... | There's a way of making pretty quick divisions by a constant, but that only works if you know the value at compile-time. The general algorithm is described in the book [Hacker's Delight](http://www.hackersdelight.org/divcMore.pdf). There are plenty of examples floating around the internet as well. Your case is differen... |
40,599,313 | I have a cpp project which works but has a bad performance.
```
int currentPos = getPos();
int length = getLength();
if (1.0 * currentPos / length < 0.5)
{
// do something
}
else
{
// do something
}
```
The problem is: `1.0 * currentPos / length` takes too much time.
Google told me that division always to... | 2016/11/14 | [
"https://Stackoverflow.com/questions/40599313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3305546/"
] | Let's get honest for a moment. On a even remotely modern CPU, division of a floating point number will be pipelined away and take roughly as much time as most other FPU or even Integer operations.
Instead, you should use a profiler on your code to see exactly where your bottlenecks are actually occurring. As your cod... | NOTE: To divide an integer by 2 you only shift by 1 ... (4 >> 1) == 2.
(and 4 >> 2 == 1)
---
I recently learned (the hard way) that full optimization (-O3) does not always do what you want. (g++ v5.2.1, ubuntu 64)
In a 5x10^9 loop, I manually changed code from:
```
if (ZERO == (n & B00) // n-even
{
...even acti... |
33,181,974 | I am frequently getting below exceptions. Please advise what to do..
```
javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.j: PKIX path validation failed: java.security.cert.CertPathValidatorException: Fail to verify issue... | 2015/10/17 | [
"https://Stackoverflow.com/questions/33181974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5455929/"
] | I don't see any problem related to the `model` field transforming the interface `A` into an abstract class.
There is no need to reimplement the method in the subclasses if it is the same, unless you want to change its behavior (override it).
```
public abstract class A {
// Make it protected so it can accessible... | Create a parent class A with said field, and said function. Have the other classes extend A. No need to override them if they function the same. |
33,181,974 | I am frequently getting below exceptions. Please advise what to do..
```
javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.j: PKIX path validation failed: java.security.cert.CertPathValidatorException: Fail to verify issue... | 2015/10/17 | [
"https://Stackoverflow.com/questions/33181974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5455929/"
] | I don't see any problem related to the `model` field transforming the interface `A` into an abstract class.
There is no need to reimplement the method in the subclasses if it is the same, unless you want to change its behavior (override it).
```
public abstract class A {
// Make it protected so it can accessible... | To deduplicate, you can either make A an abstract class and move the implementation of the method and the field there, or create an abstract class, say E, that implements the interface with that method and field and then have B, C and D extend that class E.
For the more general question of depending on a subclass's fi... |
33,181,974 | I am frequently getting below exceptions. Please advise what to do..
```
javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.j: PKIX path validation failed: java.security.cert.CertPathValidatorException: Fail to verify issue... | 2015/10/17 | [
"https://Stackoverflow.com/questions/33181974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5455929/"
] | I don't see any problem related to the `model` field transforming the interface `A` into an abstract class.
There is no need to reimplement the method in the subclasses if it is the same, unless you want to change its behavior (override it).
```
public abstract class A {
// Make it protected so it can accessible... | If you are using java 8 you could use `default` method in interface A, with a getter method for model.
```
public interface A{
default public String someMethod() {
if(getModel() instanceof X){
System.out.print(true);
}
}
public Object model getModel();
}... |
33,181,974 | I am frequently getting below exceptions. Please advise what to do..
```
javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.j: PKIX path validation failed: java.security.cert.CertPathValidatorException: Fail to verify issue... | 2015/10/17 | [
"https://Stackoverflow.com/questions/33181974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5455929/"
] | I don't see any problem related to the `model` field transforming the interface `A` into an abstract class.
There is no need to reimplement the method in the subclasses if it is the same, unless you want to change its behavior (override it).
```
public abstract class A {
// Make it protected so it can accessible... | If you're going to do this you must have `model` to be of the same (basic) type in all derived objects. If it were of the same type there's a case for putting the `model` to a base class. Anyway if they are of different derived types you would need to have an accessor to get it.
```
interface B {
BaseModel getM... |
33,181,974 | I am frequently getting below exceptions. Please advise what to do..
```
javax.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.j: PKIX path validation failed: java.security.cert.CertPathValidatorException: Fail to verify issue... | 2015/10/17 | [
"https://Stackoverflow.com/questions/33181974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5455929/"
] | I don't see any problem related to the `model` field transforming the interface `A` into an abstract class.
There is no need to reimplement the method in the subclasses if it is the same, unless you want to change its behavior (override it).
```
public abstract class A {
// Make it protected so it can accessible... | If I was given a chance to refactor it, I will follow below approach, leveraging Java 8 [Default Methods](https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html):
```
interface A {
default String someMethod(X objectType) {
if (objectType instanceof X) {
System.out.println(true);... |
14,705,695 | I am using tfhpple on IOS to fetch some data feom web.
I have this bit of code:
```
<tr class="odd">
<td class="datet t1360260000-6-1-0-0">
07/02
<br>
19:00
</td>
<td>
....................
</td>
</tr>
```
The portion I am trying to fetch is 07/02 and 19:00 (concatenated, if possible). But I have problems not only wi... | 2013/02/05 | [
"https://Stackoverflow.com/questions/14705695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1589613/"
] | If you want to use a solution with databinding + converter, implement this and it will work for you. (I tried it and it worked.)
**First**, in the View the XAML-Part:
```
<TextBox Height="23" HorizontalAlignment="Left" Margin="78,60,0,0" Name="textBox1" VerticalAlignment="Top" Width="120"
Text="{Bin... | >
> Converter is working but it's not changing text when I add some
> numbers. There are no calling for Convert method again. How can I do
> this? Everytime when I changed letter in TextBox call Converter?
>
>
>
The converter should be updated automatically.
Are you sure that you `PhonePageViewModel` implements... |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | This will do:
```
shopt -s extglob
for f in !(*.txt) ; do
echo $f
done
```
You just inverse the glob pattern using `!(glob_pat)`, and to use it, you need to enable extended glob.
If you want to ignore directories, then:
```
shopt -s extglob
for f in !(*.txt) ; do
[ -d "$f" ] && continue # This will ignor... | Do
```
find /path/to/look -type f -not -name "*.txt" -print0 | while read -r -d '' file_name
do
echo "$file_name"
done
```
when your filenames may be nonstandard.
**Note:**
If you don't wish to recursively search for files in subfolders include `-maxdepth 1`
just before `-type f`. |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | Do
```
find /path/to/look -type f -not -name "*.txt" -print0 | while read -r -d '' file_name
do
echo "$file_name"
done
```
when your filenames may be nonstandard.
**Note:**
If you don't wish to recursively search for files in subfolders include `-maxdepth 1`
just before `-type f`. | ```
for f in $(ls --hide="*.txt")
do
echo $f
done
``` |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | Do
```
find /path/to/look -type f -not -name "*.txt" -print0 | while read -r -d '' file_name
do
echo "$file_name"
done
```
when your filenames may be nonstandard.
**Note:**
If you don't wish to recursively search for files in subfolders include `-maxdepth 1`
just before `-type f`. | If you are ok for a `GNU` solution, give a try to this:
```
for f in $(find . -maxdepth 1 -type f \! -name \*.txt) ; do
printf "%s\n" "${f}"
done
```
This is going to break if special chars are contained in the filenames, such as (space).
For something safe, still `GNU`, try:
```
find . -maxdepth 1 -type f \! -... |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | You can pattern-match with the `==` operator.
```
for f in *; do
[[ $f == *.txt ]] && continue
# [[ $f != *.txt ]] || continue
...
done
```
If this might run in an empty directory, either use `shopt -s nullglob` prior to the loop, or put `[ -e "$f" ] || continue` in side the loop. (The former is preferab... | ```
for f in $(ls --hide="*.txt")
do
echo $f
done
``` |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | This will do:
```
shopt -s extglob
for f in !(*.txt) ; do
echo $f
done
```
You just inverse the glob pattern using `!(glob_pat)`, and to use it, you need to enable extended glob.
If you want to ignore directories, then:
```
shopt -s extglob
for f in !(*.txt) ; do
[ -d "$f" ] && continue # This will ignor... | ```
for f in $(ls --hide="*.txt")
do
echo $f
done
``` |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | You can pattern-match with the `==` operator.
```
for f in *; do
[[ $f == *.txt ]] && continue
# [[ $f != *.txt ]] || continue
...
done
```
If this might run in an empty directory, either use `shopt -s nullglob` prior to the loop, or put `[ -e "$f" ] || continue` in side the loop. (The former is preferab... | This will do:
```
shopt -s extglob
for f in !(*.txt) ; do
echo $f
done
```
You just inverse the glob pattern using `!(glob_pat)`, and to use it, you need to enable extended glob.
If you want to ignore directories, then:
```
shopt -s extglob
for f in !(*.txt) ; do
[ -d "$f" ] && continue # This will ignor... |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | >
> to loop files inside a directory that do not match a specific extension
>
>
>
You can use `extglob`:
```
shopt -s extglob
for f in *.!(txt); do
echo "$f"
done
```
pattern `*.!(txt)` will match all entries with a dot and no `txt` after the dot.
---
**EDIT:** Please see comments below. Here is a `find`... | If you are ok for a `GNU` solution, give a try to this:
```
for f in $(find . -maxdepth 1 -type f \! -name \*.txt) ; do
printf "%s\n" "${f}"
done
```
This is going to break if special chars are contained in the filenames, such as (space).
For something safe, still `GNU`, try:
```
find . -maxdepth 1 -type f \! -... |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | If you are ok for a `GNU` solution, give a try to this:
```
for f in $(find . -maxdepth 1 -type f \! -name \*.txt) ; do
printf "%s\n" "${f}"
done
```
This is going to break if special chars are contained in the filenames, such as (space).
For something safe, still `GNU`, try:
```
find . -maxdepth 1 -type f \! -... | ```
for f in $(ls --hide="*.txt")
do
echo $f
done
``` |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | You can pattern-match with the `==` operator.
```
for f in *; do
[[ $f == *.txt ]] && continue
# [[ $f != *.txt ]] || continue
...
done
```
If this might run in an empty directory, either use `shopt -s nullglob` prior to the loop, or put `[ -e "$f" ] || continue` in side the loop. (The former is preferab... | If you are ok for a `GNU` solution, give a try to this:
```
for f in $(find . -maxdepth 1 -type f \! -name \*.txt) ; do
printf "%s\n" "${f}"
done
```
This is going to break if special chars are contained in the filenames, such as (space).
For something safe, still `GNU`, try:
```
find . -maxdepth 1 -type f \! -... |
37,258,673 | I'm writing a bash script that needs to loop files inside a directory that do not match a specific extension. So far, I've found that the following code loops all files that matches the given extension:
```
for f in *.txt ; do
echo $f;
done
```
How could insthead loop through files that do not match the specifie... | 2016/05/16 | [
"https://Stackoverflow.com/questions/37258673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746388/"
] | >
> to loop files inside a directory that do not match a specific extension
>
>
>
You can use `extglob`:
```
shopt -s extglob
for f in *.!(txt); do
echo "$f"
done
```
pattern `*.!(txt)` will match all entries with a dot and no `txt` after the dot.
---
**EDIT:** Please see comments below. Here is a `find`... | Do
```
find /path/to/look -type f -not -name "*.txt" -print0 | while read -r -d '' file_name
do
echo "$file_name"
done
```
when your filenames may be nonstandard.
**Note:**
If you don't wish to recursively search for files in subfolders include `-maxdepth 1`
just before `-type f`. |
19,131,141 | I have the below code to loop through each row of a selected range. However when only a single cell is selected, the code loops through each row in the worksheet rather than just dealing with the one instance.
What do I need to do so that the for loop only handles the one row when a single cell is selected?
```
Dim m... | 2013/10/02 | [
"https://Stackoverflow.com/questions/19131141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2837456/"
] | I don't know the reason why the code behave as such. It looks ok.
But to get what you want, try this:
```
Dim myRange As Range
Dim currRow As Range
Set myRange = Selection
If myRange.Rows.count = 1 And myRange.Columns.count = 1 Then
For Each currRow In myRange.Rows
MsgBox currRow.Address
Next currRo... | Just add an if statement to the code to handle hidden rows:
```
Dim myRange As Range
Dim currRow As Range
Set myRange = Selection
For Each currRow In myRange
If currRow.EntireRow.Hidden = False Then
'Place your code here.
Debug.Print currRow.Address
End If
... |
28,448 | Ignorance is the cause of suffering.
Buddha says in [SN 12.2](https://suttacentral.net/sn12.2/en/bodhi) :
>
> “And what, bhikkhus, is ignorance? Not knowing suffering, not knowing
> the origin of suffering, not knowing the cessation of suffering, not
> knowing the way leading to the cessation of suffering. This is... | 2018/07/31 | [
"https://buddhism.stackexchange.com/questions/28448",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/11541/"
] | There are 3 types of wisdom
1. suta-maya panna: wisdom gained by listening to others
2. cinta-maya panna: intellectual, analytical understanding
3. bhavana-maya panna: wisdom based on direct knowledge or meditative(Vipassana) wisdom
Knowing here means the third type. When a monk preaches or when you read a sutta on ... | You don't know suffering. If you knew suffering, there would be no suffering.
Now, you are drowning in suffering rather than knowing suffering.
If you knew suffering, you would know the tiniest thought of clinging (*upadana*) is suffering. |
28,448 | Ignorance is the cause of suffering.
Buddha says in [SN 12.2](https://suttacentral.net/sn12.2/en/bodhi) :
>
> “And what, bhikkhus, is ignorance? Not knowing suffering, not knowing
> the origin of suffering, not knowing the cessation of suffering, not
> knowing the way leading to the cessation of suffering. This is... | 2018/07/31 | [
"https://buddhism.stackexchange.com/questions/28448",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/11541/"
] | I think you're right that the dhamma includes more than only the knowledge of suffering -- see pages 45-46 of Piya Tan's introducton to [SN 56.11](http://www.themindingcentre.org/dharmafarer/wp-content/uploads/2009/12/1.1-Dhammacakka-Pavattana-S-s56.11-piya.pdf)
1. Suffering -- known
2. Craving -- abandoned
3. Cessati... | You don't know suffering. If you knew suffering, there would be no suffering.
Now, you are drowning in suffering rather than knowing suffering.
If you knew suffering, you would know the tiniest thought of clinging (*upadana*) is suffering. |
28,448 | Ignorance is the cause of suffering.
Buddha says in [SN 12.2](https://suttacentral.net/sn12.2/en/bodhi) :
>
> “And what, bhikkhus, is ignorance? Not knowing suffering, not knowing
> the origin of suffering, not knowing the cessation of suffering, not
> knowing the way leading to the cessation of suffering. This is... | 2018/07/31 | [
"https://buddhism.stackexchange.com/questions/28448",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/11541/"
] | There are 3 types of wisdom
1. suta-maya panna: wisdom gained by listening to others
2. cinta-maya panna: intellectual, analytical understanding
3. bhavana-maya panna: wisdom based on direct knowledge or meditative(Vipassana) wisdom
Knowing here means the third type. When a monk preaches or when you read a sutta on ... | I think you're right that the dhamma includes more than only the knowledge of suffering -- see pages 45-46 of Piya Tan's introducton to [SN 56.11](http://www.themindingcentre.org/dharmafarer/wp-content/uploads/2009/12/1.1-Dhammacakka-Pavattana-S-s56.11-piya.pdf)
1. Suffering -- known
2. Craving -- abandoned
3. Cessati... |
28,448 | Ignorance is the cause of suffering.
Buddha says in [SN 12.2](https://suttacentral.net/sn12.2/en/bodhi) :
>
> “And what, bhikkhus, is ignorance? Not knowing suffering, not knowing
> the origin of suffering, not knowing the cessation of suffering, not
> knowing the way leading to the cessation of suffering. This is... | 2018/07/31 | [
"https://buddhism.stackexchange.com/questions/28448",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/11541/"
] | There are 3 types of wisdom
1. suta-maya panna: wisdom gained by listening to others
2. cinta-maya panna: intellectual, analytical understanding
3. bhavana-maya panna: wisdom based on direct knowledge or meditative(Vipassana) wisdom
Knowing here means the third type. When a monk preaches or when you read a sutta on ... | **Ignorance is the root cause of the suffering**? Hmm...let's take a look.
Actually the Dhamma says: [Nandī dukkhassa mūlan’ti](https://suttacentral.net/mn1/en/sujato#172-194.28). There are also references and translations throughout the Dhamma for *attachment*, *desire*, and *delight* being the root of suffering.
T... |
28,448 | Ignorance is the cause of suffering.
Buddha says in [SN 12.2](https://suttacentral.net/sn12.2/en/bodhi) :
>
> “And what, bhikkhus, is ignorance? Not knowing suffering, not knowing
> the origin of suffering, not knowing the cessation of suffering, not
> knowing the way leading to the cessation of suffering. This is... | 2018/07/31 | [
"https://buddhism.stackexchange.com/questions/28448",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/11541/"
] | There are 3 types of wisdom
1. suta-maya panna: wisdom gained by listening to others
2. cinta-maya panna: intellectual, analytical understanding
3. bhavana-maya panna: wisdom based on direct knowledge or meditative(Vipassana) wisdom
Knowing here means the third type. When a monk preaches or when you read a sutta on ... | According to [MN 9](https://www.accesstoinsight.org/tipitaka/mn/mn.009.than.html) (below), as long as you still have fermentation or [effluents](https://buddhism.stackexchange.com/questions/9414/what-is-effluent), you would still have ignorance, and vice versa (also see [this question](https://buddhism.stackexchange.co... |
28,448 | Ignorance is the cause of suffering.
Buddha says in [SN 12.2](https://suttacentral.net/sn12.2/en/bodhi) :
>
> “And what, bhikkhus, is ignorance? Not knowing suffering, not knowing
> the origin of suffering, not knowing the cessation of suffering, not
> knowing the way leading to the cessation of suffering. This is... | 2018/07/31 | [
"https://buddhism.stackexchange.com/questions/28448",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/11541/"
] | I think you're right that the dhamma includes more than only the knowledge of suffering -- see pages 45-46 of Piya Tan's introducton to [SN 56.11](http://www.themindingcentre.org/dharmafarer/wp-content/uploads/2009/12/1.1-Dhammacakka-Pavattana-S-s56.11-piya.pdf)
1. Suffering -- known
2. Craving -- abandoned
3. Cessati... | **Ignorance is the root cause of the suffering**? Hmm...let's take a look.
Actually the Dhamma says: [Nandī dukkhassa mūlan’ti](https://suttacentral.net/mn1/en/sujato#172-194.28). There are also references and translations throughout the Dhamma for *attachment*, *desire*, and *delight* being the root of suffering.
T... |
28,448 | Ignorance is the cause of suffering.
Buddha says in [SN 12.2](https://suttacentral.net/sn12.2/en/bodhi) :
>
> “And what, bhikkhus, is ignorance? Not knowing suffering, not knowing
> the origin of suffering, not knowing the cessation of suffering, not
> knowing the way leading to the cessation of suffering. This is... | 2018/07/31 | [
"https://buddhism.stackexchange.com/questions/28448",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/11541/"
] | I think you're right that the dhamma includes more than only the knowledge of suffering -- see pages 45-46 of Piya Tan's introducton to [SN 56.11](http://www.themindingcentre.org/dharmafarer/wp-content/uploads/2009/12/1.1-Dhammacakka-Pavattana-S-s56.11-piya.pdf)
1. Suffering -- known
2. Craving -- abandoned
3. Cessati... | According to [MN 9](https://www.accesstoinsight.org/tipitaka/mn/mn.009.than.html) (below), as long as you still have fermentation or [effluents](https://buddhism.stackexchange.com/questions/9414/what-is-effluent), you would still have ignorance, and vice versa (also see [this question](https://buddhism.stackexchange.co... |
47,049,309 | i want to make a vb program that asks random questions in a label with predefined multiple choices from option buttons. Each question and multiple choices should be in a specific sub procedure. so that if there are 10 questions to be asked, then there will be 10 sub procedures for the questions. Since i want the questi... | 2017/11/01 | [
"https://Stackoverflow.com/questions/47049309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8581476/"
] | (Much of the meat of this answer is copied from my [other answer on calling a function by its name as a String](https://stackoverflow.com/a/45568872/65839), and while this question may be a duplicate some people may find it helpful to describe the solution in this context as well.)
VB6 is in many ways an object-orient... | i manage to somwhow find a simpler way through @bob77 idea of using decision making statements. i chose to use select case as a possible solution and of course its simplicity. i however got rid of the array(guess this will no longer be answering the question as it is, but will still implement what was expected). here i... |
48,781,398 | I have a table of entities (let's say documents), where each document may have a different entity connected to it (let's say permission). A permission has a foreign key to the document table.
Example:
**Schema**:
```
Document -> Id | Data
Permission -> Id | EntityId | PermissionData
```
**Content**:
```
Document ... | 2018/02/14 | [
"https://Stackoverflow.com/questions/48781398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3213034/"
] | this is the code snippet I am using first line is the dependency from my build.sbt file
```
//lib dependency in build.sbt
"org.elasticsearch" %% "elasticsearch-spark-20" % "5.6.5"
//below is the connection variables required by Spark
val resources: String =
s"${appConf.getString("es-index")}/${appConf.getString("e... | I got a workaround as of now to push the records at a time to ES index and removed this bulk API (bulk API also does the same thing behind the scene). |
9,451,912 | Is there a way to stop the default keyboard and have my custom designed keyboard when user clicks on TextField ?
I already designed my buttons to be always available similar to a calculator. It has numbers from 0 to 9 , decimal dot and backspace. | 2012/02/26 | [
"https://Stackoverflow.com/questions/9451912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1217778/"
] | Starting with iOS 3.2, you can attach any `UIView` to your `UITextField` to be used as a keyboard:
```
myTextField.inputView = myFakeKeyboard;
```
You can also attach a toolbar above the keyboard (system or custom one) :
```
myTextField.inputAccessoryView = myToolbar;
```
By the way, if you need a numeric pad wit... | You need to use this in your viewController and its enough :)
```
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return NO; //hide keyboard
}
``` |
70,233,716 | I try to calculate the relative weights of `df1` in each row with a max value of 0.5. So far, I was able to calculate the relative weights in `df2` but without an upper boundary. Here would be a simple example:
```
import pandas as pd
df1 = pd.DataFrame({
'Dates':['2021-01-01', '2021-01-02', '2021-01-03', '2021-01... | 2021/12/05 | [
"https://Stackoverflow.com/questions/70233716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16250224/"
] | I achieved the goal without changing the HTML layout using `clip-path` animation.
<https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path>
```css
.wrapper {
width: 152px;
height: 152px;
background-image: url('https://i.ibb.co/5T3p5sY/icon-3151974-1280.png');
background-position: center;
background-rep... | For more Information and Full Explaination, Reach to <https://dev.to/shantanu_jana/circular-progress-bar-using-html-and-css-1oda>
```css
body {
background:#d2eaf1;
}
.circle-wrap {
margin: 150px auto;
width: 150px;
height: 150px;
background: #fefcff;
border-radius: 50%;
border: 1px solid #cdcbd0;
}
.circ... |
8,254,981 | I have a web application with an upload functionality for HTML files generated by chess software to be able to include a javascript player that reproduces a chess game.
I do not like to load the uploaded files in a frame so I reconstruct the HTML and javascript generated by the software by parsing the dynamic parts of... | 2011/11/24 | [
"https://Stackoverflow.com/questions/8254981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/352878/"
] | I'd say your best option is to use something like [HTML Agility Pack](http://htmlagilitypack.codeplex.com/) to parse the generated HTML, and then ask it to re-serialize it to string (hopefully correcting any formatting problems in the process). [Any attempt at Regexes or other direct string manipulation of HTML is goin... | you could use something like:
```
string ouputString = Regex.Replace(inputString, @"(?<=\<[^<>]*)\'(?=[^<>]*\>)", "\"");
```
Changed it after Oded's remark, this leaves the body HTML intact. But I agree, Regex is a bad idea for parsing HTML. Mark's answer is better. |
3,177,420 | An ABC triangle has an AD edge that comes over the BC edge over angle A. The ABD angle is 20 degrees and the ACD angle is 40 degrees. Find the degree of BAD angle
[](https://i.stack.imgur.com/VOs89.jpg) | 2019/04/06 | [
"https://math.stackexchange.com/questions/3177420",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/661555/"
] | [](https://i.stack.imgur.com/ZcRJ5.png)
Extend $BC$ and make $CE=BD$. Then $\triangle{ACE}$ is isosceles. $\angle{ACE}=140^{\circ}$ so $\angle{CAE}=\angle{CEA}=20^{\circ}$. Now we see that $\triangle{ABE}$ is isosceles and $AE=AB$. Furthermore, $\tria... | Use the sine law:
$$
\sin20°:AD=\sin x:BD,\quad
\sin40°:AD=\sin(20°+x):AC.
$$
Dividing the second equation by the first yields:
$$
\sin 40°:\sin20°=\sin(20°+x):\sin x,
$$
an equation easy to solve for $x$. |
32,547,676 | I am trying to insert post details into a SQL table, but only my `id` and `date` values are inserted and all the other columns remain blank.
Here is my form's HTML code:
```
<!DOCTYPE html>
<html>
<head>
<title>xmudios14285</title>
<link rel="stylesheet" type="text/css" href="../css/foundation.min... | 2015/09/13 | [
"https://Stackoverflow.com/questions/32547676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5330299/"
] | You should add the `POST` `method` attribute to your form like this:
```
<form action="chapter_exec.php" enctype="multipart/form-data" method="post">
``` | try replacing your form tag with:
```
<form action="chapter_exec.php" enctype="multipart/form-data" method="post">
```
to verify that you post values are getting corretly, write oh php file:
```
print_r($_POST);
``` |
32,547,676 | I am trying to insert post details into a SQL table, but only my `id` and `date` values are inserted and all the other columns remain blank.
Here is my form's HTML code:
```
<!DOCTYPE html>
<html>
<head>
<title>xmudios14285</title>
<link rel="stylesheet" type="text/css" href="../css/foundation.min... | 2015/09/13 | [
"https://Stackoverflow.com/questions/32547676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5330299/"
] | You should add the `POST` `method` attribute to your form like this:
```
<form action="chapter_exec.php" enctype="multipart/form-data" method="post">
``` | As mentioned already, put the `method = POST` in your `<form>` tag, add a hidden field for `secure-checking` in the php.
```
<form action="chapter_exec.php" method = "POST" enctype="multipart/form-data">
<!-- blah3 -->
<input type = "hidden" name = "check">
</form>
```
And then in your `php` use a `isset` like:
```... |
32,547,676 | I am trying to insert post details into a SQL table, but only my `id` and `date` values are inserted and all the other columns remain blank.
Here is my form's HTML code:
```
<!DOCTYPE html>
<html>
<head>
<title>xmudios14285</title>
<link rel="stylesheet" type="text/css" href="../css/foundation.min... | 2015/09/13 | [
"https://Stackoverflow.com/questions/32547676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5330299/"
] | Form method is missing .
Default method for form is "**GET**" and you are using to receive data using **$\_POST** method .Correct this issue using **method="post"**. | You should add the `POST` `method` attribute to your form like this:
```
<form action="chapter_exec.php" enctype="multipart/form-data" method="post">
``` |
32,547,676 | I am trying to insert post details into a SQL table, but only my `id` and `date` values are inserted and all the other columns remain blank.
Here is my form's HTML code:
```
<!DOCTYPE html>
<html>
<head>
<title>xmudios14285</title>
<link rel="stylesheet" type="text/css" href="../css/foundation.min... | 2015/09/13 | [
"https://Stackoverflow.com/questions/32547676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5330299/"
] | Form method is missing .
Default method for form is "**GET**" and you are using to receive data using **$\_POST** method .Correct this issue using **method="post"**. | try replacing your form tag with:
```
<form action="chapter_exec.php" enctype="multipart/form-data" method="post">
```
to verify that you post values are getting corretly, write oh php file:
```
print_r($_POST);
``` |
32,547,676 | I am trying to insert post details into a SQL table, but only my `id` and `date` values are inserted and all the other columns remain blank.
Here is my form's HTML code:
```
<!DOCTYPE html>
<html>
<head>
<title>xmudios14285</title>
<link rel="stylesheet" type="text/css" href="../css/foundation.min... | 2015/09/13 | [
"https://Stackoverflow.com/questions/32547676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5330299/"
] | Form method is missing .
Default method for form is "**GET**" and you are using to receive data using **$\_POST** method .Correct this issue using **method="post"**. | As mentioned already, put the `method = POST` in your `<form>` tag, add a hidden field for `secure-checking` in the php.
```
<form action="chapter_exec.php" method = "POST" enctype="multipart/form-data">
<!-- blah3 -->
<input type = "hidden" name = "check">
</form>
```
And then in your `php` use a `isset` like:
```... |
45,799,046 | I have a `locker` object, with a bunch of fields, and a `lots` array of objects -- both passed in via `props`. For the *locker* object, one of the fields holds the `id` of a specific `lot` in the `lots` array. Like so:
```
locker: { locker_num: 'AH3', part_of_lot: '235', allocation: '' , etc...}
```
The `lots` objec... | 2017/08/21 | [
"https://Stackoverflow.com/questions/45799046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/717682/"
] | Try checking the return value for non-zero, which indicates an error occurred with the install. Not all errors trigger exceptions.
```
import pip
def install(package_name):
try:
pipcode = pip.main(['install', package_name])
if pipcode != 0:
print("Unable to install " + ... | You can check the value of package to verify if no matching distribution was find. Normally the package will return 0 if exists a installation candidate, otherwise will return 1 for no candidate found
```
import pip
def install(package_name):
package = pip.main(['install', package_name])
result = "Pack... |
21,679,677 | I have a grid presenting people. Their names with a picture. The name must be displayed on 2 line. First name on the first line and surname on second one.
**I can't change the html** (I would use `<br/>` tag and it would be solved).
I need to find a way (CSS prefered) to achieve this.
**[FIDDLE](http://jsfiddle.net/... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21679677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1811992/"
] | If you are allowed to modify the HTML dynamically you can do this (using jQuery):
```
var $splitter = $("#wrap article header h2 a");
$splitter.each(function(i, e){
var $e = $(e);
var name = $e.text().split(" ");
var firstname = name.splice(0, 1);
var last = "";
for(var i = 0; i < nam... | Your best bet is using
```
word-spacing:225px;
```
on the `h2 a` selector this way each word takes atleast 225px which is 33.3% of the 670px
Other than that you have to either use Javascript or HTML |
21,679,677 | I have a grid presenting people. Their names with a picture. The name must be displayed on 2 line. First name on the first line and surname on second one.
**I can't change the html** (I would use `<br/>` tag and it would be solved).
I need to find a way (CSS prefered) to achieve this.
**[FIDDLE](http://jsfiddle.net/... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21679677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1811992/"
] | Your best bet is using
```
word-spacing:225px;
```
on the `h2 a` selector this way each word takes atleast 225px which is 33.3% of the 670px
Other than that you have to either use Javascript or HTML | Try This
```
var name = $("#wrap article header h2 a").text().split(" ");
$("#wrap article header h2 a").html(name[0] + "<br/>" + name[1]);
``` |
21,679,677 | I have a grid presenting people. Their names with a picture. The name must be displayed on 2 line. First name on the first line and surname on second one.
**I can't change the html** (I would use `<br/>` tag and it would be solved).
I need to find a way (CSS prefered) to achieve this.
**[FIDDLE](http://jsfiddle.net/... | 2014/02/10 | [
"https://Stackoverflow.com/questions/21679677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1811992/"
] | If you are allowed to modify the HTML dynamically you can do this (using jQuery):
```
var $splitter = $("#wrap article header h2 a");
$splitter.each(function(i, e){
var $e = $(e);
var name = $e.text().split(" ");
var firstname = name.splice(0, 1);
var last = "";
for(var i = 0; i < nam... | Try This
```
var name = $("#wrap article header h2 a").text().split(" ");
$("#wrap article header h2 a").html(name[0] + "<br/>" + name[1]);
``` |
54,048,383 | Is there any good regex/function or packages that allows us to parse indented structured text/data into a dictionary? For example, I have data something like this (can have deeper levels than I mentioned below):
```none
xyz1 : 14
xyz2 : 35
xyz3 : 14
xyz4
... | 2019/01/05 | [
"https://Stackoverflow.com/questions/54048383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515997/"
] | TL;DR
=====
* Use the [fs module](https://nodejs.org/api/fs.html) to read you JSON files
* Call `JSON.parse()` to parse the raw JSON
* Choose the file according to `var lang = req.params.lang` using some kind of logic (for example, `'spanish' -> './data/spanish.json'`)
Code
====
```js
const fs = require('fs');
// S... | It's simple to return json data with express.
Just use `res.json({key: value , key2: value2})` instead of `res.send`
In your case, you can
```
const language = req.params.lang;
res.json({lang: lang})
```
you will receive a JSON object instead of text |
310,319 | I was wondering if the [canonical commutation relations](http://en.wikipedia.org/wiki/Canonical_commutation_relation) have any connection to geometry?
If so, could you explain the connection in fairly simple and intuitive terms? | 2017/02/07 | [
"https://physics.stackexchange.com/questions/310319",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/75628/"
] | Well, this is a fairly broad topic.
1. Here is one way [CCR](http://en.wikipedia.org/wiki/Canonical_commutation_relation)s arise from a rather large class of geometries: Given a [Fedosov manifold](http://en.wikipedia.org/wiki/Fedosov_manifold) $(M,\omega, \nabla)$ [i.e. a manifold $M$ endowed with a symplectic $2$-fo... | Roughly speaking, the gauge potential is identical to connection where the gauge potential is related to amplitude (field variable).
The commutation relation in quantum theory can be written as the commutation relation of field variables (amplitude).
So it is natural to have the commutation relation expressed in conn... |
25,673,707 | I have a situation which only occurs on IE11. Chrome, Firefox, Safari (tablet and phone) all work as expected. I have created a transition for a panel(DIV) that slides in/out from the side. On pageload it should NOT "animate" but snap into the appropriate position. But on IE11 when the page loads the transition is "pla... | 2014/09/04 | [
"https://Stackoverflow.com/questions/25673707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3546826/"
] | Worked with MicroSoft support and logged a bug. There is a workaround for this issue.
Instead of using the media query
```
@media only screen and (max-width:800px)
```
change the query to be the following:
```
@media only screen and (min-width:1px) and (max-width:800px)
```
This should not be required (it should... | Not a completely javascript free solution but you can add a class to the entire page on the body tag:
```
body.pageload * {
-webkit-transition: none !important;
-moz-transition: none !important;
-ms-transition: none !important;
-o-transition: none !important;
}
```
and remove that class after the pag... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.