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 |
|---|---|---|---|---|---|
24,412,696 | I have some running code and I would like to add a conditional breakpoint, but I only know how to add conditions to existing breakpoints. For example if I add a breakpoint to a line of my C# code, using for example `F9`, I can then right-click on the breakpoint's red dot in the left gutter which gives me this menu
![... | 2014/06/25 | [
"https://Stackoverflow.com/questions/24412696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/575530/"
] | I work on [OzCode, a commercial extension to Visual Studio](http://www.oz-code.com) that has two ways of adding a Conditional Breakpoint in one click -
1. As QuickAction (similar to Alt+Enter in Resharper). This will suggest relevant conditions for your Conditional Breakpoint, based on the type of the variable (ie, `>... | Tricky conditional breakpoints can be easily created programmatically.
```
bool someAwfullyRareCondition = true;
if (someAwfullyRareCondition)
{
System.Diagnostics.Debugger.Break();
}
``` |
24,412,696 | I have some running code and I would like to add a conditional breakpoint, but I only know how to add conditions to existing breakpoints. For example if I add a breakpoint to a line of my C# code, using for example `F9`, I can then right-click on the breakpoint's red dot in the left gutter which gives me this menu
![... | 2014/06/25 | [
"https://Stackoverflow.com/questions/24412696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/575530/"
] | >
> *I do not want to stop the code debugging […].*
> *When I first insert the breakpoint, but before I have had a chance to add its condition, it will fire and the program will 'break'.*
>
>
>
You can prevent this by making sure that the debugger isn't attached to the running process at that time:
1. **Detach th... | I work on [OzCode, a commercial extension to Visual Studio](http://www.oz-code.com) that has two ways of adding a Conditional Breakpoint in one click -
1. As QuickAction (similar to Alt+Enter in Resharper). This will suggest relevant conditions for your Conditional Breakpoint, based on the type of the variable (ie, `>... |
24,412,696 | I have some running code and I would like to add a conditional breakpoint, but I only know how to add conditions to existing breakpoints. For example if I add a breakpoint to a line of my C# code, using for example `F9`, I can then right-click on the breakpoint's red dot in the left gutter which gives me this menu
![... | 2014/06/25 | [
"https://Stackoverflow.com/questions/24412696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/575530/"
] | >
> *I do not want to stop the code debugging […].*
> *When I first insert the breakpoint, but before I have had a chance to add its condition, it will fire and the program will 'break'.*
>
>
>
You can prevent this by making sure that the debugger isn't attached to the running process at that time:
1. **Detach th... | Tricky conditional breakpoints can be easily created programmatically.
```
bool someAwfullyRareCondition = true;
if (someAwfullyRareCondition)
{
System.Diagnostics.Debugger.Break();
}
``` |
305,835 | I have multi websites site. I have multiple users with different user roles. Is there any way to save and check which admin user has added the product in admin panel backend. | 2020/03/02 | [
"https://magento.stackexchange.com/questions/305835",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/81147/"
] | By default, Its not possible to track which Admin user added the Products. There are two way to achive this:
1. Third Part Extension: You can use Advanced Permission Third Party extension that provide this feature and many other features as well.
2. Customization: Create One Product attribute Or Field in `Catalog_Prod... | First of all create a custom attribute called : "updated\_by" from magento backend and don't forget to drag that into default attribute set otherwise it will not work!!
Add events.xml file to vendor/module/etc/adminhtml/
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNam... |
41,043 | Would like to set up a key-value store that is sharded across multiple machines.
We are currently using MongoDB, is there a reason why we shouldn't use MongoDB for this purpose?
We also use Redis, however for this use case, we would like to use the hard drive and Redis is in-RAM only. | 2013/04/26 | [
"https://dba.stackexchange.com/questions/41043",
"https://dba.stackexchange.com",
"https://dba.stackexchange.com/users/21254/"
] | There are a number of reasons not to use MongoDB as a pure key-value store, and there are some reasons to consider it. Mongo is optimized as a document store - it indexes all the fields in a document, and has rich primitives for JSON objects and hierarchies. You can use it as a key-value store, but the single-threaded ... | I agree with @Brian that it makes more sense to use Redis for this purpose, except that its clustering functionality is in Alpha (it still is at this point - see the official [cluster specification](http://redis.io/topics/cluster-spec) which is a work in progress). However, another option that has not been mentioned is... |
24,423,239 | I'm initializing nested collection like te following:
```
var post = {
id: 123,
title: 'Sterling Archer',
comments: [
{text: 'Comment text', tags: ['tag1', 'tag2', 'tag3']},
{text: 'Comment test', tags: ['tag2', 'tag5']}
]
};
var PostModel = Backbone.Model.extend({
parse: function (response) ... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24423239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1006884/"
] | You can override `destroy` method of your `PostModel` instead of `sync` (which will not be called in case of a new model without `id` attribute):
```
destroy: function(options) {
this.get('comments').each(function(mdl) {
mdl.destroy();
});
Backbone.Model.prototype.destroy.call(this, options)
}
... | This something can be use to delete comments.
```
sync : function(method,model,options){
if(method=='delete'){
this.comments.destroy();
}
Backbone.sync(method,model,options);
}
``` |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | **Disclaimer**:
In my experience needing multiple inheritance is the exception rather than the rule, careful design of class hierarchies can usually avoid needing this feature. I agree with JP that this requirement could be avoided in your sample.
Back to the question, there is no clean solution, however you have a... | I agree that inheritance doesn't seem to be the right thing here. I'm not sure that I know the perfect answer, but perhaps the [Decorator pattern](http://www.primos.com.au/primos/Default.aspx?PageContentID=25&tabid=65) is appropriate.
Another, more esoteric idea is to think about aspect-oriented programming. You can ... |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | Here's a scholarly paper on the subject that I think is pretty interesting ([PDF link](http://users.jyu.fi/~sakkinen/inhws/papers/Crespo.pdf)).
But, I think you are trying to impose *business logic* in your generalizations. You happen to know that an InternalCandidate will never have his GPA looked at. But, an Interna... | I agree that inheritance doesn't seem to be the right thing here. I'm not sure that I know the perfect answer, but perhaps the [Decorator pattern](http://www.primos.com.au/primos/Default.aspx?PageContentID=25&tabid=65) is appropriate.
Another, more esoteric idea is to think about aspect-oriented programming. You can ... |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | **Immutable data value classes.** If any **properties** in your various Candidate subclasses represent some kind of meaningful data value, create an immutable class for it, with the behaviors you need. Each of your distinct Candidate subclasses can then use the data type, but your code is still encapsulated in the data... | I agree that inheritance doesn't seem to be the right thing here. I'm not sure that I know the perfect answer, but perhaps the [Decorator pattern](http://www.primos.com.au/primos/Default.aspx?PageContentID=25&tabid=65) is appropriate.
Another, more esoteric idea is to think about aspect-oriented programming. You can ... |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | I agree that inheritance doesn't seem to be the right thing here. I'm not sure that I know the perfect answer, but perhaps the [Decorator pattern](http://www.primos.com.au/primos/Default.aspx?PageContentID=25&tabid=65) is appropriate.
Another, more esoteric idea is to think about aspect-oriented programming. You can ... | I'd just use the [Delegation pattern](http://en.wikipedia.org/wiki/Delegation_pattern). Ultimately I'd use an interface for each distinct piece of functionality, then have a concrete class as a delegate for each interface. Then your final classes just use the delegates they need and can inherit from multiple interfaces... |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | **Immutable data value classes.** If any **properties** in your various Candidate subclasses represent some kind of meaningful data value, create an immutable class for it, with the behaviors you need. Each of your distinct Candidate subclasses can then use the data type, but your code is still encapsulated in the data... | **Disclaimer**:
In my experience needing multiple inheritance is the exception rather than the rule, careful design of class hierarchies can usually avoid needing this feature. I agree with JP that this requirement could be avoided in your sample.
Back to the question, there is no clean solution, however you have a... |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | **Disclaimer**:
In my experience needing multiple inheritance is the exception rather than the rule, careful design of class hierarchies can usually avoid needing this feature. I agree with JP that this requirement could be avoided in your sample.
Back to the question, there is no clean solution, however you have a... | I'd just use the [Delegation pattern](http://en.wikipedia.org/wiki/Delegation_pattern). Ultimately I'd use an interface for each distinct piece of functionality, then have a concrete class as a delegate for each interface. Then your final classes just use the delegates they need and can inherit from multiple interfaces... |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | **Immutable data value classes.** If any **properties** in your various Candidate subclasses represent some kind of meaningful data value, create an immutable class for it, with the behaviors you need. Each of your distinct Candidate subclasses can then use the data type, but your code is still encapsulated in the data... | Here's a scholarly paper on the subject that I think is pretty interesting ([PDF link](http://users.jyu.fi/~sakkinen/inhws/papers/Crespo.pdf)).
But, I think you are trying to impose *business logic* in your generalizations. You happen to know that an InternalCandidate will never have his GPA looked at. But, an Interna... |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | Here's a scholarly paper on the subject that I think is pretty interesting ([PDF link](http://users.jyu.fi/~sakkinen/inhws/papers/Crespo.pdf)).
But, I think you are trying to impose *business logic* in your generalizations. You happen to know that an InternalCandidate will never have his GPA looked at. But, an Interna... | I'd just use the [Delegation pattern](http://en.wikipedia.org/wiki/Delegation_pattern). Ultimately I'd use an interface for each distinct piece of functionality, then have a concrete class as a delegate for each interface. Then your final classes just use the delegates they need and can inherit from multiple interfaces... |
804,702 | UPDATE:
So pretty much everyone here has told me that I just need to start all over again on how I designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, I started doing extensive reading on the [strategy pattern](http://www.dofactory.com/Patterns/PatternStrategy.aspx). I want to... | 2009/04/29 | [
"https://Stackoverflow.com/questions/804702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34315/"
] | **Immutable data value classes.** If any **properties** in your various Candidate subclasses represent some kind of meaningful data value, create an immutable class for it, with the behaviors you need. Each of your distinct Candidate subclasses can then use the data type, but your code is still encapsulated in the data... | I'd just use the [Delegation pattern](http://en.wikipedia.org/wiki/Delegation_pattern). Ultimately I'd use an interface for each distinct piece of functionality, then have a concrete class as a delegate for each interface. Then your final classes just use the delegates they need and can inherit from multiple interfaces... |
6,493,361 | I have this Address table like below:
```
Address
-------
ID (pk)
OWNERTYPE (int)
OWNERID (int)
ADDR1
ADDR2
....
```
this is a "child" table, where it would be mapped to any possible "parent" table. To discriminate which parent table it has relation to, it has the column "ONWERTYPE". "OWNERTYPE" will store the iden... | 2011/06/27 | [
"https://Stackoverflow.com/questions/6493361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/817422/"
] | You need to use an `<any>` mapping, as explained [here](http://www.nhforge.org/doc/nh/en/index.html#mapping-types-anymapping). | I have found another solution but I need advice whether I'm doing the correct way.
The database tables itself is not design by me, thus I cant help but to follow the structure.
because all of the address data is stored only in one table, I use an inheritance mapping to do this.
for example i have 3 tables like this;
... |
72,080,293 | Here is one function from my code
```
def seq():
q=1
n=rann()
List=[n]
while q<n:
if (n % 2):
n = 3*n + 1
List.append(n)
else:
n=n//2
List.append(n)
if (len(List)>=len(y)):
print(List)
else:
return(rann())
x=input("enter name") ... | 2022/05/01 | [
"https://Stackoverflow.com/questions/72080293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18445143/"
] | This will work best acc. to your use case.
```js
const btn = document.getElementById("btn");
btn.onclick = () => {
// Here you will add path to local file you have
const audio = new Audio(
"https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3"
);
audio.play();
};
```
```html
<!DOCTYPE html>
<ht... | Yeah, JavaScript is pretty much required for this. You can use the `audio` element for this, something [like so (codepen.io)](https://codepen.io/isaactfa/pen/xxOpeex):
```html
<button class="start-audio-btn">Click me!</button>
<!-- just some random mp3 I found -->
<audio src="https://www.soundhelix.com/examples/mp3/S... |
72,080,293 | Here is one function from my code
```
def seq():
q=1
n=rann()
List=[n]
while q<n:
if (n % 2):
n = 3*n + 1
List.append(n)
else:
n=n//2
List.append(n)
if (len(List)>=len(y)):
print(List)
else:
return(rann())
x=input("enter name") ... | 2022/05/01 | [
"https://Stackoverflow.com/questions/72080293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18445143/"
] | This will work best acc. to your use case.
```js
const btn = document.getElementById("btn");
btn.onclick = () => {
// Here you will add path to local file you have
const audio = new Audio(
"https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3"
);
audio.play();
};
```
```html
<!DOCTYPE html>
<ht... | This would solve anything you would need dealing with audio => Play, Pause, Stop, Mute & Unmute :)
```js
playBtn.onclick = () => audio.play()
stopBtn.onclick = () => {audio.pause(); audio.currentTime = 0;}
pauseBtn.onclick = () => audio.pause()
muteBtn.onclick = () => audio.muted = !audio.muted
```
```html
<audio con... |
71,032,011 | I am trying to write a code that is capturing number 3. using while loop as the condition, so that the for statement will be the evaluation condition of $x, of the while loop statement, and by the same time, using if statement to evaluate the value of $x=3 and so it can **echo 'three..';** . please enlighten me. thank ... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71032011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18140231/"
] | You need to "pop" that element from normal flow with `position` rule with specified dimensions. E.g. `position: fixed;`
```css
.outer {
width: 10vw;
height: 10vh;
position: relative;
background: rgba(130, 130, 255, .3);
border: 1px solid red;
}
.inner {
width: 90vw;
height: 90vh;
position: absolute;
... | You can use absolute sizing in CSS to have a child `div` be larger than the parent. You will also need to add in the `top` and `left` attributes and set them to 0. This will frame the `div` to begin in the top left corner.
If you want a `div` to be the full width and height of the viewport, use the following CSS:
```... |
71,032,011 | I am trying to write a code that is capturing number 3. using while loop as the condition, so that the for statement will be the evaluation condition of $x, of the while loop statement, and by the same time, using if statement to evaluate the value of $x=3 and so it can **echo 'three..';** . please enlighten me. thank ... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71032011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18140231/"
] | You can do it easily. As long as the parent doesn't have `overflow: hidden`, you can even define its dimensions with pixels and see it working!
```css
.parent {
height: 40px;
width: 40px;
background: red;
}
.child {
height: 100px;
width: 100px;
background: transparent;
border: 1px solid green;
}
```
``... | You can use absolute sizing in CSS to have a child `div` be larger than the parent. You will also need to add in the `top` and `left` attributes and set them to 0. This will frame the `div` to begin in the top left corner.
If you want a `div` to be the full width and height of the viewport, use the following CSS:
```... |
71,032,011 | I am trying to write a code that is capturing number 3. using while loop as the condition, so that the for statement will be the evaluation condition of $x, of the while loop statement, and by the same time, using if statement to evaluate the value of $x=3 and so it can **echo 'three..';** . please enlighten me. thank ... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71032011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18140231/"
] | You need to "pop" that element from normal flow with `position` rule with specified dimensions. E.g. `position: fixed;`
```css
.outer {
width: 10vw;
height: 10vh;
position: relative;
background: rgba(130, 130, 255, .3);
border: 1px solid red;
}
.inner {
width: 90vw;
height: 90vh;
position: absolute;
... | Give a certain `height` & `width` to your parent.
Use `%` for the your `.child` element.
```css
.parent {
height: 40px;
width: 40px;
background: gray;
}
.child {
height: 125%;
width: 125%;
background: transparent;
border: 1px solid green;
}
```
```html
<div class="parent">
<div class="child"></di... |
71,032,011 | I am trying to write a code that is capturing number 3. using while loop as the condition, so that the for statement will be the evaluation condition of $x, of the while loop statement, and by the same time, using if statement to evaluate the value of $x=3 and so it can **echo 'three..';** . please enlighten me. thank ... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71032011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18140231/"
] | You need to "pop" that element from normal flow with `position` rule with specified dimensions. E.g. `position: fixed;`
```css
.outer {
width: 10vw;
height: 10vh;
position: relative;
background: rgba(130, 130, 255, .3);
border: 1px solid red;
}
.inner {
width: 90vw;
height: 90vh;
position: absolute;
... | You can do it easily. As long as the parent doesn't have `overflow: hidden`, you can even define its dimensions with pixels and see it working!
```css
.parent {
height: 40px;
width: 40px;
background: red;
}
.child {
height: 100px;
width: 100px;
background: transparent;
border: 1px solid green;
}
```
``... |
71,032,011 | I am trying to write a code that is capturing number 3. using while loop as the condition, so that the for statement will be the evaluation condition of $x, of the while loop statement, and by the same time, using if statement to evaluate the value of $x=3 and so it can **echo 'three..';** . please enlighten me. thank ... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71032011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18140231/"
] | You can do it easily. As long as the parent doesn't have `overflow: hidden`, you can even define its dimensions with pixels and see it working!
```css
.parent {
height: 40px;
width: 40px;
background: red;
}
.child {
height: 100px;
width: 100px;
background: transparent;
border: 1px solid green;
}
```
``... | Give a certain `height` & `width` to your parent.
Use `%` for the your `.child` element.
```css
.parent {
height: 40px;
width: 40px;
background: gray;
}
.child {
height: 125%;
width: 125%;
background: transparent;
border: 1px solid green;
}
```
```html
<div class="parent">
<div class="child"></di... |
13,264,342 | I will start by saying this is probably a dumb question so apologies if I am staring at the answer but cannot see.
I have used VCS in the past primarily as a method of allowing me to revert my code if something goes wrong. I have always had a single lime of development. However I get into the usual trouble when releas... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13264342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/420363/"
] | Not entirely sure why you'll want that, but maybe you can try this?
```
module ActiveRecord
class Base
def self.your_method
# implementation goes here
end
end
end
```
You will need to save this file and put it in `config/intializers`. | You can also extend the ActiveRecord::Base class in order to add the those methods dynamically which are directly callable by the class inheriting the ActiveRecord::Base...Many acts\_as plugins are defined and made according to this practice... |
402,779 | I'm running a site on AWS with the following setup:
1. Single m1.small instance (web server)
2. Single RDS m1.small db
3. Joomla 1.5
Generally, the site is performant, but is fairly low-traffic - say around 50-100 visits / hour. However, at peak time, we see about double that traffic. During peak time, pretty much ev... | 2012/06/27 | [
"https://serverfault.com/questions/402779",
"https://serverfault.com",
"https://serverfault.com/users/12172/"
] | Rather than dumping queries, you can enable [slow query logging](http://aws.amazon.com/rds/faqs/#14) using RDS DB Parameter Groups. RDS saves slow queries in table mysql.slow\_log. Here is a helpful [thread](https://forums.aws.amazon.com/message.jspa?messageID=288679).
To boost the performance, use some caching mechan... | I don't think this is a MySQL issue. What you describe is what I've experienced on Joomla websites when the memory allocation for the instance (slice) isn't sufficient. I suggest increasing the memory allocation and then monitor the results for improvement.
If you still think this is a MySQL issue, I would create a du... |
62,886,015 | I am trying to rename the columns of a DataFrame that has more than one hundred columns by their position (x1, x2, x3, etc.). I created the code below, but it is very inefficient. Is there a faster and better way of doing this in Pandas-Python?
```
for i, column_name in enumerate(df.columns.values):
df.rename(col... | 2020/07/13 | [
"https://Stackoverflow.com/questions/62886015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11396737/"
] | You can directly assign to "df.columns".
```py
df.columns = [f'x{i+1}' for i in range(len(df.columns))]
``` | Let us do
```
df.columns=np.arange(df.shape[1])+1
df=df.add_prefix('x')
``` |
13,861,413 | >
> **Possible Duplicate:**
>
> [java/shellscript code to find out if a jar file is already running on current machine](https://stackoverflow.com/questions/13857979/java-shellscript-code-to-find-out-if-a-jar-file-is-already-running-on-current-ma)
>
>
>
I would love to get a cross-platform solution for this, bu... | 2012/12/13 | [
"https://Stackoverflow.com/questions/13861413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1146032/"
] | You could make your program open a dummy file for writing with a [FileWriter](http://docs.oracle.com/javase/7/docs/api/java/io/FileWriter.html) when your program starts, and keep the file open until the program is finished.
When you now start a second instance of your program, it will also try to open this file for wr... | You can create a temporary file on a fixed location.
```
private static final File LOCK_FILE = new File("app.lock");
public static boolean checkIfAlreadyRunning()
{
return LOCK_FILE.exists();
}
public static void createLockFile()
{
LOCK_FILE.createNewFile();
Runnable shutDown = new Runnable()
{
... |
13,861,413 | >
> **Possible Duplicate:**
>
> [java/shellscript code to find out if a jar file is already running on current machine](https://stackoverflow.com/questions/13857979/java-shellscript-code-to-find-out-if-a-jar-file-is-already-running-on-current-ma)
>
>
>
I would love to get a cross-platform solution for this, bu... | 2012/12/13 | [
"https://Stackoverflow.com/questions/13861413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1146032/"
] | You could make your program open a dummy file for writing with a [FileWriter](http://docs.oracle.com/javase/7/docs/api/java/io/FileWriter.html) when your program starts, and keep the file open until the program is finished.
When you now start a second instance of your program, it will also try to open this file for wr... | I had exactly the same problem, and it can be pretty tricky to solve. Both File and Socket based approaches can be made to work, but it gets really tricky on some OS's (think of Windows with multiple users in multiple terminal server sessions etc.).
First, determine the *scope* where you want only one instance. Then d... |
13,861,413 | >
> **Possible Duplicate:**
>
> [java/shellscript code to find out if a jar file is already running on current machine](https://stackoverflow.com/questions/13857979/java-shellscript-code-to-find-out-if-a-jar-file-is-already-running-on-current-ma)
>
>
>
I would love to get a cross-platform solution for this, bu... | 2012/12/13 | [
"https://Stackoverflow.com/questions/13861413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1146032/"
] | You could use a port as a semaphore. See [this question](https://stackoverflow.com/questions/4883771/check-for-open-ports-with-java) for more info on that. I think a port would be a good cross-platform solution | You can create a temporary file on a fixed location.
```
private static final File LOCK_FILE = new File("app.lock");
public static boolean checkIfAlreadyRunning()
{
return LOCK_FILE.exists();
}
public static void createLockFile()
{
LOCK_FILE.createNewFile();
Runnable shutDown = new Runnable()
{
... |
13,861,413 | >
> **Possible Duplicate:**
>
> [java/shellscript code to find out if a jar file is already running on current machine](https://stackoverflow.com/questions/13857979/java-shellscript-code-to-find-out-if-a-jar-file-is-already-running-on-current-ma)
>
>
>
I would love to get a cross-platform solution for this, bu... | 2012/12/13 | [
"https://Stackoverflow.com/questions/13861413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1146032/"
] | You could use a port as a semaphore. See [this question](https://stackoverflow.com/questions/4883771/check-for-open-ports-with-java) for more info on that. I think a port would be a good cross-platform solution | I had exactly the same problem, and it can be pretty tricky to solve. Both File and Socket based approaches can be made to work, but it gets really tricky on some OS's (think of Windows with multiple users in multiple terminal server sessions etc.).
First, determine the *scope* where you want only one instance. Then d... |
37,800,595 | I'm digging AMP html a bit and this line immediately got my attention.
>
> AMP HTML documents MUST:
>
>
> Contain a top-level `<html ⚡>` tag (`<html amp>` is accepted as well).
>
>
>
So my first question here is - is `<html ⚡>` valid HTML? I mean, it seems to work - but I looks really weird to me. Can anyone po... | 2016/06/13 | [
"https://Stackoverflow.com/questions/37800595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4253183/"
] | Tag names in HTML must begin with an ASCII letter, but attribute names can be nearly anything. See [12.2.4.32 Before attribute name state](https://html.spec.whatwg.org/multipage/syntax.html#before-attribute-name-state) in the standard. | You can use Unicode, or you can use `<html amp>`; either works. But you must use one to signal the status of the document. Failing to use one will fail AMP validation. I just use `<html amp>` because it's easier to type. |
37,800,595 | I'm digging AMP html a bit and this line immediately got my attention.
>
> AMP HTML documents MUST:
>
>
> Contain a top-level `<html ⚡>` tag (`<html amp>` is accepted as well).
>
>
>
So my first question here is - is `<html ⚡>` valid HTML? I mean, it seems to work - but I looks really weird to me. Can anyone po... | 2016/06/13 | [
"https://Stackoverflow.com/questions/37800595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4253183/"
] | You can use Unicode, or you can use `<html amp>`; either works. But you must use one to signal the status of the document. Failing to use one will fail AMP validation. I just use `<html amp>` because it's easier to type. | You can still try it in [W3C Markup Validation Service](https://validator.w3.org) (known also as HTML validator, and yea, it's still exists!)
In case of validity it writes almost the same **Error**
`Attribute amp not allowed on element html at this point.` or
`Attribute ⚡ not allowed on element html at this point.`
... |
37,800,595 | I'm digging AMP html a bit and this line immediately got my attention.
>
> AMP HTML documents MUST:
>
>
> Contain a top-level `<html ⚡>` tag (`<html amp>` is accepted as well).
>
>
>
So my first question here is - is `<html ⚡>` valid HTML? I mean, it seems to work - but I looks really weird to me. Can anyone po... | 2016/06/13 | [
"https://Stackoverflow.com/questions/37800595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4253183/"
] | Tag names in HTML must begin with an ASCII letter, but attribute names can be nearly anything. See [12.2.4.32 Before attribute name state](https://html.spec.whatwg.org/multipage/syntax.html#before-attribute-name-state) in the standard. | You can still try it in [W3C Markup Validation Service](https://validator.w3.org) (known also as HTML validator, and yea, it's still exists!)
In case of validity it writes almost the same **Error**
`Attribute amp not allowed on element html at this point.` or
`Attribute ⚡ not allowed on element html at this point.`
... |
66,395,041 | I'm trying to make a JavaScript function that tells how many times a vowel was repeated in a given string.
Here's what I have tried:
```
function checkVowel(str) {
vowels = ['a', 'e', 'i', 'o', 'u']
str = "hello world"
for(let i = 0; i < str.length; i++){
if(str[i].includes(vowels)){
... | 2021/02/27 | [
"https://Stackoverflow.com/questions/66395041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10860975/"
] | Is it this what you're looking for?
```js
function checkVowel(str) {
const counts = Object.seal({ a: 0, e: 0, i: 0, o: 0, u: 0 });
for (let char of str) {
counts[char.toLowerCase()]++;
}
return counts;
}
console.log(checkVowel("hello world"));
``` | **Another solution**
```js
function countVowel(word) {
const vowels = ["a", "e", "i", "o", "u"];
const wordArray = word.split("").map((s) => s.toLowerCase());
const result = {
a: 0,
e: 0,
i: 0,
o: 0,
u: 0
};
return wordArray.reduce((acc, curr) => {
if (vowels.includes(curr)) {
+... |
13,038,779 | Suppose I have the following code
```
callbacks = []
for i in range(10):
callbacks.append(lambda x: i)
```
all functions in `callbacks` will return the final value of `i`. How can I create callbacks that return the *current value for i at creation time*? | 2012/10/23 | [
"https://Stackoverflow.com/questions/13038779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/128580/"
] | ```
for i in range(10):
callbacks.append(lambda x = i : x)
``` | ```
In [113]: callbacks=[]
In [114]: for i in range(10):
callbacks.append(lambda x=i:x**2)
.....:
.....:
In [117]: callbacks[0]()
Out[117]: 0
In [118]: callbacks[1]()
Out[118]: 1
In [119]: callbacks[2]()
Out[119]: 4
In [120]: callbacks[4]()
Out[120]: 16
``` |
12,873,513 | I have used javacv for my project to deal with avi.
The video shows faster than normal, I want to get the fps to set the speed of the video. But grabber.getFrameRate() return 0, as the same with grabber.getLengthInFrames() and grabber.getSampleRate(), can anyone tell me why?
code snippet below:
```
FrameGrabber grabbe... | 2012/10/13 | [
"https://Stackoverflow.com/questions/12873513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1661672/"
] | Your code is declaring an empty string `s` and then is assigning to elements of it...
```
...
string s,res;int c=0;
int sum,carry=0;
for(int i=m-1;i>=0;i--)
{
sum=(a[i]-'0')*2+carry;
s[c]=sum%10+'0'; // This is undefined behavior, s is empty
carry=sum/10;
c++;
}
...
``` | This is just a extension of the answer from @6502.
It looks like [ostringstream](http://www.cplusplus.com/reference/iostream/ostringstream/) would be a good fit for what you want.
```
ostringstream oss;
string s,res;
int c=0;
int sum,carry=0;
for(int i=m-1;i>=0;i--)
{
sum=(a[i]-'0')*2+carry;
oss << (sum%10) ... |
12,873,513 | I have used javacv for my project to deal with avi.
The video shows faster than normal, I want to get the fps to set the speed of the video. But grabber.getFrameRate() return 0, as the same with grabber.getLengthInFrames() and grabber.getSampleRate(), can anyone tell me why?
code snippet below:
```
FrameGrabber grabbe... | 2012/10/13 | [
"https://Stackoverflow.com/questions/12873513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1661672/"
] | Your code is declaring an empty string `s` and then is assigning to elements of it...
```
...
string s,res;int c=0;
int sum,carry=0;
for(int i=m-1;i>=0;i--)
{
sum=(a[i]-'0')*2+carry;
s[c]=sum%10+'0'; // This is undefined behavior, s is empty
carry=sum/10;
c++;
}
...
``` | This is a possible answer to your [problem](http://www.spoj.pl/problems/M00PAIR/) and not your question.
I guess the question has as algorithmic flavour and its aim is to find the
a solution with least time complexity (perhaps a linear time solution).
It is helpful to do some prepossessing for questions related to bes... |
12,873,513 | I have used javacv for my project to deal with avi.
The video shows faster than normal, I want to get the fps to set the speed of the video. But grabber.getFrameRate() return 0, as the same with grabber.getLengthInFrames() and grabber.getSampleRate(), can anyone tell me why?
code snippet below:
```
FrameGrabber grabbe... | 2012/10/13 | [
"https://Stackoverflow.com/questions/12873513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1661672/"
] | This is a possible answer to your [problem](http://www.spoj.pl/problems/M00PAIR/) and not your question.
I guess the question has as algorithmic flavour and its aim is to find the
a solution with least time complexity (perhaps a linear time solution).
It is helpful to do some prepossessing for questions related to bes... | This is just a extension of the answer from @6502.
It looks like [ostringstream](http://www.cplusplus.com/reference/iostream/ostringstream/) would be a good fit for what you want.
```
ostringstream oss;
string s,res;
int c=0;
int sum,carry=0;
for(int i=m-1;i>=0;i--)
{
sum=(a[i]-'0')*2+carry;
oss << (sum%10) ... |
644,086 | I would like to print the following table in latex:[](https://i.stack.imgur.com/j6cG9.jpg)
Any hint is wellcome! | 2022/05/13 | [
"https://tex.stackexchange.com/questions/644086",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/270318/"
] | With `{NiceTabular}` of `nicematrix`.
```
\documentclass[landscape]{article}
\usepackage{nicematrix}
\begin{document}
\setlength{\tabcolsep}{0pt}
\sffamily
\begin{NiceTabular}{*{38}{wc{3mm}}}
\Block[l]{1-10}{Nom} \\
\Block[hvlines]{1-38}{}
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& \\
\rule{0pt}{15pt}
\Block[l]{1-10}{A... | This is by no means the answer I'm only just starting myself, but it might get you on the right track.
```
\documentclass{article}
\begin{document}
Name\\\
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
&&&&&&&\\
\hline
\end{tabular}
SecondItem\\\
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
&&&&&&&\\
\hline
\end{tabular}
... |
11,158,106 | One of our users is getting an error in our web application. We couldnt duplicate this problem, and I suspected it was network related. I had the user try the application using their notebook at their office and their home, and confirmed the problem only happens at their office.
I logged into the server and looked at ... | 2012/06/22 | [
"https://Stackoverflow.com/questions/11158106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/782880/"
] | jQuery objects currently support 3 array methods:
```
var methods = 'pop push reverse shift sort splice unshift concat join slice toString indexOf lastIndexOf filter forEach every map some reduce reduceRight'.split(' ')
var implemented = $.grep(methods, function(m) {
return $.prototype[m] == Array.prototype[m];
})... | jQuery does have a `.sort` method, it just isn't officially documented because it does not follow the usual format of jQuery methods.
The only methods that are supported are the ones listed in the [api](http://api.jquery.com).
`.sort` is implemented as:
```
$.fn.sort = [].sort;
```
You can add your own additional ... |
3,834,363 | Are there any potential issues with updating UI bound properties of the ViewModel from the Backgroundworker? I am trying to update the VM while it is bound to the UI, and potentially users might be typing in.. how does the the synchronization work here (I don't think I can use Lock statements from XAML).
Thanks in adv... | 2010/09/30 | [
"https://Stackoverflow.com/questions/3834363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249198/"
] | When updating scalar properties, you don't need to worry about doing it on the UI thread. The `PropertyChanged` event is automatically marshalled to the UI thread.
However, it **won't work** for collections that implement `INotifyCollectionChanged`. The `CollectionChanged` event won't be marshalled to the UI thread, a... | In my experience with Silverlight, trying to do so will cause an exception anyway.
Basically you need to update the bound properties from the dispatcher thread, just as if you were modifying the UI directly.
In order to allow the ViewModel to do that without knowing about a real `Dispatcher`, I've found it useful to ... |
11,801,585 | I'm trying to encrypt my entire site over SSL. However, I'm not finding a clear cut way to do this with Django 1.4. Does anyone know a solution? | 2012/08/03 | [
"https://Stackoverflow.com/questions/11801585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1408431/"
] | You could use a middleware such as those provided in [django-secure](http://django-secure.readthedocs.org/) or you could handle this at the Apache/Nginx/HAProxy level by redirecting all HTTP requests to HTTPS. | On apache+django (1.6) this can be done a number of ways but a simple way can be done in the .htaccess or httpd.conf file is:
```
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URL}
```
Here's a link for further info on it:
<http://wiki.apache.org/httpd/RewriteHTTPToHTTPS>
... |
527,180 | I have a question regarding the ADCs **ADS58B19** inputclock, this ADC can be clocked with LVDS.
The data sheet says that Vpp = 700mV, which is +-350mV. The ADCs Vcm = 1.7V, is this the in and output Vcm?
Is it possible to clock the ADC with a Vpp = 700mV and Vcm = 1V?
Datasheet: <https://www.ti.com/lit/ds/symlink/ads... | 2020/10/13 | [
"https://electronics.stackexchange.com/questions/527180",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/265053/"
] | >
> *The ADCs Vcm = 1.7V, is this the in and output Vcm?*
>
>
>
Vcm is an output voltage and can be used to bias the clock inputs if only a single ended clock is used (see figure 64 below). The clock signal is then fed via a capacitor. For full differential clocks you don't need to bias (figure 65): -
[](https://i.stack.imgur.com/NqUfn.png)
My jdk ... | 2016/12/07 | [
"https://Stackoverflow.com/questions/41013882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3734176/"
] | I mean, you could try putting the following code in build.gradle under
android {
```
compileSdkVersion 24
buildToolsVersion "23.0.3"
```
So it should look like this:
```
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
```
At least that works for me, not sure if it will help you. I myself am a s... | Just i have changed everything in my build.gradle file to latest build tools like this. It worked for me
```
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVers... |
17,104,003 | I need to create new activity in my project, and I want to show pictures. The layout that I want to create is like that.

All heights must have "wrap\_content" property.
Which layouts I must use? | 2013/06/14 | [
"https://Stackoverflow.com/questions/17104003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1001261/"
] | Try this:
```
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >... | I think you want to create an StaggeredGridView.
StaggeredGridView is a modified version of Android’s experimental StaggeredGridView. The StaggeredGridView allows the user to create a GridView with uneven rows similar to how Pinterest looks. Includes own OnItemClickListener and OnItemLongClickListener, selector, and f... |
17,104,003 | I need to create new activity in my project, and I want to show pictures. The layout that I want to create is like that.

All heights must have "wrap\_content" property.
Which layouts I must use? | 2013/06/14 | [
"https://Stackoverflow.com/questions/17104003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1001261/"
] | Try this:
```
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >... | Consider using a [TableLayout](http://developer.android.com/reference/android/widget/TableLayout.html) or a [GridView](http://developer.android.com/reference/android/widget/GridView.html) and use the attribute **layout\_weight** on the children.
Your first child (66%) can have a layout weight of 2, the second (33%) a ... |
17,104,003 | I need to create new activity in my project, and I want to show pictures. The layout that I want to create is like that.

All heights must have "wrap\_content" property.
Which layouts I must use? | 2013/06/14 | [
"https://Stackoverflow.com/questions/17104003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1001261/"
] | Try this:
```
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >... | Why do you insist on using wrap\_content?
You have "fixed" width of boxes (66% and 33%). You can use sp/dp units to achieve this, I am sure. With some tweaking, of course.
For more info regarding this topic go to
<http://developer.android.com/guide/practices/screens_support.html>
and
[What is the difference between ... |
1,623,158 | I have been reading some proofs on the elementary theorems of differential equations. One such proof uses the concept of a "contraction". See the definition below.
>
> **Definition 4** Let $(X,d)$ be a space equipped with a distance function $d$. A function $\Phi:X\to X$ from $X$ to itself is a contraction if there i... | 2016/01/23 | [
"https://math.stackexchange.com/questions/1623158",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/215976/"
] | Besides the fact that your understanding omits the mapping of points to other points, the existence of $k<1$ such that a certain thing is always less than $k$ is NOT the same as saying that that certain thing is always less than $1$. For example, consider the function $f(x) = \sqrt{1+x^2}$. Then one has $|f(x)-f(y)|<1\... | No, a contraction is not a metric(aka distance function). What a contraction does is bring every pair of points closer together(in the implicit metric). For instance, $f(x)=x/2$ is a contraction in the euclidean metric of $\mathbb{R}$. |
14,162,928 | When two or more objects are added as listeners for the same event, which listener is first invoked to handle the event?
The listener which is added first or the one which is added at last.
By event I mean the AWT events. | 2013/01/04 | [
"https://Stackoverflow.com/questions/14162928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1453008/"
] | In Swing, these are often implemented using `EventListenerList` objects which preserve insertion order (they are backed by an array). However, it does not mean that listeners will be invoked in that order. As an example, this is the implementation in `AbstractButton`:
```
protected void fireStateChanged() {
// Pro... | I believe [this](https://stackoverflow.com/questions/4760267/java-swing-multiple-event-listeners-for-a-single-event-source-in-a-single-thread) is what you're looking for. In short, the firing order is indeterminate. If you wish to ensure a specific order perhaps try adding only one of the listeners and pass the event o... |
17,150,736 | I’m currently deploying my Rails application on Amazon and I’m facing a problem with environment variables.
I'm using the dotenv gem on development and testing and it works just fine while trying to access my environment variables, but in production it does not seem to work. I read that the dotenv gem isn't meant to w... | 2013/06/17 | [
"https://Stackoverflow.com/questions/17150736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/829928/"
] | The [dotenv-deployment readme](https://github.com/bkeepers/dotenv-deployment#capistrano-3) mentions how you can use it in a production environment:
**If you're using Capistrano 3+:**
Just add .env to your list of linked\_files:
```
set :linked_files, %w{.env}
```
**If you're using Capistrano 2.x.x version:**
In y... | You could use the [figaro](https://github.com/laserlemon/figaro) gem. I am using this and it works fine in production. |
17,150,736 | I’m currently deploying my Rails application on Amazon and I’m facing a problem with environment variables.
I'm using the dotenv gem on development and testing and it works just fine while trying to access my environment variables, but in production it does not seem to work. I read that the dotenv gem isn't meant to w... | 2013/06/17 | [
"https://Stackoverflow.com/questions/17150736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/829928/"
] | You could use the [figaro](https://github.com/laserlemon/figaro) gem. I am using this and it works fine in production. | In Capistrano 3 add `require "dotenv/rails-now"` to your Capfile.
This will make sure that capistrano has access to the environment as well.
(We had issues with capistrano accessing the API token for appsignal, so capistrano wasn't able to notify appsignal when a new deploy was done) |
17,150,736 | I’m currently deploying my Rails application on Amazon and I’m facing a problem with environment variables.
I'm using the dotenv gem on development and testing and it works just fine while trying to access my environment variables, but in production it does not seem to work. I read that the dotenv gem isn't meant to w... | 2013/06/17 | [
"https://Stackoverflow.com/questions/17150736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/829928/"
] | The [dotenv-deployment readme](https://github.com/bkeepers/dotenv-deployment#capistrano-3) mentions how you can use it in a production environment:
**If you're using Capistrano 3+:**
Just add .env to your list of linked\_files:
```
set :linked_files, %w{.env}
```
**If you're using Capistrano 2.x.x version:**
In y... | In Capistrano 3 add `require "dotenv/rails-now"` to your Capfile.
This will make sure that capistrano has access to the environment as well.
(We had issues with capistrano accessing the API token for appsignal, so capistrano wasn't able to notify appsignal when a new deploy was done) |
19,721,041 | do anybody know about how to read a SMS in iOS with Xamarin iOS ? and then I want to pass a string from that SMS to the application via link. For example when user click the link in the SMS it will pass a string value to the application and in the application a method is waiting to trigger that. | 2013/11/01 | [
"https://Stackoverflow.com/questions/19721041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2839950/"
] | It's impossible to read incoming or storing SMS's due to iOS security restriction. | If Jason's answer of using a link to the app, there is an alternative. In my case a web service is sending down a code (two stage auth). When I know its going to be coming, I prompt the user to looks for it, and when it comes long press the message bubble, and copy the whole message to the pasteboard.
When the user sw... |
19,721,041 | do anybody know about how to read a SMS in iOS with Xamarin iOS ? and then I want to pass a string from that SMS to the application via link. For example when user click the link in the SMS it will pass a string value to the application and in the application a method is waiting to trigger that. | 2013/11/01 | [
"https://Stackoverflow.com/questions/19721041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2839950/"
] | It's impossible to read incoming or storing SMS's due to iOS security restriction. | It is possible from iOS 12
```
textField.textContentType = .oneTimeCode
```
Please check [this](https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view) doc |
19,721,041 | do anybody know about how to read a SMS in iOS with Xamarin iOS ? and then I want to pass a string from that SMS to the application via link. For example when user click the link in the SMS it will pass a string value to the application and in the application a method is waiting to trigger that. | 2013/11/01 | [
"https://Stackoverflow.com/questions/19721041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2839950/"
] | Although you can't directly intercept SMS messages, you can create a [custom URL scheme](https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW50) so that if a user clicks a link in your message it w... | If Jason's answer of using a link to the app, there is an alternative. In my case a web service is sending down a code (two stage auth). When I know its going to be coming, I prompt the user to looks for it, and when it comes long press the message bubble, and copy the whole message to the pasteboard.
When the user sw... |
19,721,041 | do anybody know about how to read a SMS in iOS with Xamarin iOS ? and then I want to pass a string from that SMS to the application via link. For example when user click the link in the SMS it will pass a string value to the application and in the application a method is waiting to trigger that. | 2013/11/01 | [
"https://Stackoverflow.com/questions/19721041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2839950/"
] | Although you can't directly intercept SMS messages, you can create a [custom URL scheme](https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW50) so that if a user clicks a link in your message it w... | It is possible from iOS 12
```
textField.textContentType = .oneTimeCode
```
Please check [this](https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view) doc |
19,721,041 | do anybody know about how to read a SMS in iOS with Xamarin iOS ? and then I want to pass a string from that SMS to the application via link. For example when user click the link in the SMS it will pass a string value to the application and in the application a method is waiting to trigger that. | 2013/11/01 | [
"https://Stackoverflow.com/questions/19721041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2839950/"
] | If Jason's answer of using a link to the app, there is an alternative. In my case a web service is sending down a code (two stage auth). When I know its going to be coming, I prompt the user to looks for it, and when it comes long press the message bubble, and copy the whole message to the pasteboard.
When the user sw... | It is possible from iOS 12
```
textField.textContentType = .oneTimeCode
```
Please check [this](https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view) doc |
65,397,044 | ```
<select>
<option value="0"></option>
<option value="1"></option>
<option value="2"></option>
<option value="3"></option>
</select>
```
Is there a way to select that options where have this values: 0, 2, 3
Something like this:
```
$('option[value=0,2,3]')
``` | 2020/12/21 | [
"https://Stackoverflow.com/questions/65397044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11939541/"
] | No, you can't put a list in an attribute selector.
You can use a list of selectors separated by comma, but there's no shorthand.
```js
$('option[value=0],option[value=2],option[value=3]')
```
Perhaps a better solution would be to give all those options the same class, then use a class selector. | use the `:not()` css function `option:not([value=1])`
```js
const selected = $('option:not([value=1])').text('selected')
console.log(selected)
```
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select>
<option value="0"></option>
<option value="1"></option>
<... |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | [05AB1E](https://github.com/Adriandmen/05AB1E), ~~76~~ ~~74~~ ~~72~~ 66 bytes
=============================================================================
-6 bytes thanks to @carusocomputing
```
'~T×ð8×'~6×ð5×" _
| ~-_
| o ~-_
| ~ÿ~-_
| \ÿ
| * \
|ÿ\
|ÿ\"
```
String interpolation replaces the `ÿ`s. In order ... | Java 8, 96 bytes
================
```
()->" _\n| ~-_\n| o ~-_\n| ~ ~-_\n| \~~~~~~\n| * \\n| \\n|~~~~~~~~~~\"
```
Boring, but it probably can't be shortened by using some fancy `.replace` or loops anyway in Java..
[Try it here.](https://tio.run/##PY9BDoIwEEX3nuKHVTGBCxC9gWxcqjG1VFPElkAhMUpPxp08Ag5Q... |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | [05AB1E](https://github.com/Adriandmen/05AB1E), 50 bytes
========================================================
```
•ζ1VS¹Tšã¦1d’sΩç!ÙT>_äтÿÀ†{ECZ{Ý•7ÝJ"_ -~|\*o"‡8¡»
```
[Try it online!](https://tio.run/##AVsApP8wNWFiMWX//@KAos62MVZTwrlUxaHDo8KmMWTigJlzzqnDpyHDmVQ@X8Ok0YLDv8OA4oCge0VDWnvDneKAojfDnUoiXyAtfnzvvLwqb... | [Jelly](https://github.com/DennisMitchell/jelly), ~~51~~ 50 bytes
=================================================================
```
“ ½|~-o*_‘;65340Ọ“ßṆiṣ€|ʂwĊeḌ\<S@DƝbƘשṗþ8¥Ḅ3Zȥ ’ṃ
```
[Try it online!](https://tio.run/##AV4Aof9qZWxsef//4oCcIMK9fH4tbypf4oCYOzY1MzQw4buM4oCcw5/huYZp4bmj4oKsfMqCd8SKZeG4jFw8U0BExp1... |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | Python 2, ~~94~~ ~~92~~ 96 bytes
================================
```
print(""" _
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\""")
```
[Try it online!](https://tio.run/##K6gsycjPM/7/v6AoM69EQ0lJSSGeq0ahThdE5itAGXUKIABhA8H7PXvqwADE1YIIQGQUYJw6OABygaZq/v8PAA) | Mathematica, 84 bytes
=====================
```
"_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\"
``` |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | [SOGL](https://github.com/dzaima/SOGL), 49 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
===========================================================================================================
```
⁰∑J“ζ"Ω‰Θx(;╝φ╚○Δ§∆qσG⅛>K█׀IR'ΚΧqΞ⅞≥№█▼¡└+Β8‘# ~ŗ
```
If the flag used any other character than `... | [Retina](https://github.com/m-ender/retina), ~~60~~ 59 bytes
============================================================
```
1_!1~-_!1o2~-_!1~5~-_!4\""!2*3\!8\!"""~\
"
~~~
!
¶|
\d
$*
```
[Try it online!](https://tio.run/##K0otycxL/P@fyzBe0bBOF0jkG4GpOlMQZfJ@zx4lJUUjLWMgQ9ECRCgpKdUBaS4lrrq6Oi5FrkPbarhiUrhUtBT@/wcA... |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | [Japt](https://github.com/ETHproductions/japt), ~~83 79~~ 78 bytes (UTF-8)
==========================================================================
```
" _
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
|{8ç}\
|{Aç'~}\
```
Hardcodes most of the string
[Try it online!](http://ethproductions.github.io/japt/?v=1.4... | Bubblegum, 40
=============
Not sure why no-one posted the bubblegum answer yet - Is bubblegum frowned upon these days?
xxd dump:
```
00000000: 5388 e7aa 51a8 d305 91f9 0a50 469d 0210 S...Q......PF...
00000010: 40d9 40f0 7ecf 9e3a 3000 71b5 2002 1019 @.@.~..:0.q. ...
00000020: 0518 a70e 0e80 5c00 ... |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | [SOGL](https://github.com/dzaima/SOGL), 49 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
===========================================================================================================
```
⁰∑J“ζ"Ω‰Θx(;╝φ╚○Δ§∆qσG⅛>K█׀IR'ΚΧqΞ⅞≥№█▼¡└+Β8‘# ~ŗ
```
If the flag used any other character than `... | Bubblegum, 40
=============
Not sure why no-one posted the bubblegum answer yet - Is bubblegum frowned upon these days?
xxd dump:
```
00000000: 5388 e7aa 51a8 d305 91f9 0a50 469d 0210 S...Q......PF...
00000010: 40d9 40f0 7ecf 9e3a 3000 71b5 2002 1019 @.@.~..:0.q. ...
00000020: 0518 a70e 0e80 5c00 ... |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | Python 2, ~~94~~ ~~92~~ 96 bytes
================================
```
print(""" _
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\""")
```
[Try it online!](https://tio.run/##K6gsycjPM/7/v6AoM69EQ0lJSSGeq0ahThdE5itAGXUKIABhA8H7PXvqwADE1YIIQGQUYJw6OABygaZq/v8PAA) | Java 8, 96 bytes
================
```
()->" _\n| ~-_\n| o ~-_\n| ~ ~-_\n| \~~~~~~\n| * \\n| \\n|~~~~~~~~~~\"
```
Boring, but it probably can't be shortened by using some fancy `.replace` or loops anyway in Java..
[Try it here.](https://tio.run/##PY9BDoIwEEX3nuKHVTGBCxC9gWxcqjG1VFPElkAhMUpPxp08Ag5Q... |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | [05AB1E](https://github.com/Adriandmen/05AB1E), 50 bytes
========================================================
```
•ζ1VS¹Tšã¦1d’sΩç!ÙT>_äтÿÀ†{ECZ{Ý•7ÝJ"_ -~|\*o"‡8¡»
```
[Try it online!](https://tio.run/##AVsApP8wNWFiMWX//@KAos62MVZTwrlUxaHDo8KmMWTigJlzzqnDpyHDmVQ@X8Ok0YLDv8OA4oCge0VDWnvDneKAojfDnUoiXyAtfnzvvLwqb... | C#, 89 bytes
============
```c#
_=>@" _
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\"
```
Any formatting options in C# for this require too many extra bytes that it is just cheaper to hard code the output as far as I can tell. |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | [Japt](https://github.com/ETHproductions/japt), ~~83 79~~ 78 bytes (UTF-8)
==========================================================================
```
" _
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
|{8ç}\
|{Aç'~}\
```
Hardcodes most of the string
[Try it online!](http://ethproductions.github.io/japt/?v=1.4... | Java 8, 96 bytes
================
```
()->" _\n| ~-_\n| o ~-_\n| ~ ~-_\n| \~~~~~~\n| * \\n| \\n|~~~~~~~~~~\"
```
Boring, but it probably can't be shortened by using some fancy `.replace` or loops anyway in Java..
[Try it here.](https://tio.run/##PY9BDoIwEEX3nuKHVTGBCxC9gWxcqjG1VFPElkAhMUpPxp08Ag5Q... |
124,852 | Given no input, output the following:
```
_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\
```
Note the backslashes are actually `\`, which is `U+FF3C`
Trailing whitespace is allowed, however leading whitespace is not.
This is [code-golf](/questions/tagged/code-golf "show questions tagge... | 2017/06/06 | [
"https://codegolf.stackexchange.com/questions/124852",
"https://codegolf.stackexchange.com",
"https://codegolf.stackexchange.com/users/44998/"
] | [05AB1E](https://github.com/Adriandmen/05AB1E), ~~76~~ ~~74~~ ~~72~~ 66 bytes
=============================================================================
-6 bytes thanks to @carusocomputing
```
'~T×ð8×'~6×ð5×" _
| ~-_
| o ~-_
| ~ÿ~-_
| \ÿ
| * \
|ÿ\
|ÿ\"
```
String interpolation replaces the `ÿ`s. In order ... | Mathematica, 84 bytes
=====================
```
"_
| ~-_
| o ~-_
| ~ ~-_
| \~~~~~~
| * \
| \
|~~~~~~~~~~\"
``` |
64,869 | I need help understanding conditional probability. I was reading an answer here which talks about conditional probability. But, frankly I do not know what it is. | 2019/07/25 | [
"https://philosophy.stackexchange.com/questions/64869",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/40482/"
] | Simple (and rational!) answer is yes
Empirical answer like all empirical data – ostriches and penguins are birds but don't fly etc – is more messy.
eg [Imre Lakatos](https://en.wikipedia.org/wiki/Proofs_and_Refutations) showed how surprisingly fallibilistic a historical trajectory math actually takes. And the greates... | The difference between rationalism and empiricism is in the method of proof.
Empiricism requires, by the conventional definition and usual understanding of the term, that the proof of your claim be an observation of the material world.
Rationalism requires instead that the proof of your claim be an observation of y... |
64,869 | I need help understanding conditional probability. I was reading an answer here which talks about conditional probability. But, frankly I do not know what it is. | 2019/07/25 | [
"https://philosophy.stackexchange.com/questions/64869",
"https://philosophy.stackexchange.com",
"https://philosophy.stackexchange.com/users/40482/"
] | Say I squat down and draw figures in the sand with a stick, one with three sides and one with four sides. That's a triangle and a square. They are empirical objects, perfectly visible to everyone present. If someone asks me which is the triangle and which is the square, I point out the sides with my stick: '1, 2, 3', a... | The difference between rationalism and empiricism is in the method of proof.
Empiricism requires, by the conventional definition and usual understanding of the term, that the proof of your claim be an observation of the material world.
Rationalism requires instead that the proof of your claim be an observation of y... |
2,440,820 | I am asking about converting parametric equations into cartesian equations.
I'm taking multivariable calc course and there is something I do not quite understand among sample questions. (It's in vector-valued function section)
We are supposed to sketch a space curve which is
$$r(t) = 4 \cos t \hat{i} + 4 \sin t \ha... | 2017/09/22 | [
"https://math.stackexchange.com/questions/2440820",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/483556/"
] | We have,
$$x^2 + y^2 = (4\sin(t))^2 + (4\cos(t))^2 = 16\sin^2(t) + 16\cos^2(t)$$
We know that
$$\sin^2(t) + \cos^2(t) = 1$$
so,
$$16(\sin^2(t) + \cos^2(t)) = 16$$
So, we have,
$$x^2 + y^2 = 16$$
Which can be written as,
$$\left(\frac x 4\right)^2 + \left(\frac y 4\right)^2 = 1$$
If that's what you meant i... | Conversely, if $u^2+v^2=1$, then there exists exactly one $t\in[0,2\pi)$ s.t. $u=\cos t,\;v=\sin t$. That is why such trigonometric parametrisation of a circle is possible. |
74,325,368 | I have a Kafka application which suffers from intermittent deserialisation errors (due to connectivity problems to the host which provides Avro schemas)
I would like to back off and retry serialisation exceptions, but I have not been able to figure out how to set that up.
Here's my test configuration:
```java
@org.s... | 2022/11/05 | [
"https://Stackoverflow.com/questions/74325368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11002/"
] | 1. When you `malloc()` a string you need to allocate an extra byte for the terminating '\0'.
2. In `delete()` you need to have two frees in the loop followed by a free of the queue (reverse order of what would happen in the push; except in this case it's easier to deallocate from head). You need temporary variable `t2`... | The primary problem is that you are accessing freed data:
```
for (temp = q->head; temp != NULL; temp = temp->next) {
free(temp->data);
free(temp);
}
```
When `temp = temp->next` is evaluated, `temp` is freed. You have to capture the pointer before you free the structure. One way to do it would be this (... |
69,427,687 | For an app a table, that is dynamically populated with data, is important.
How should I do the tab order for tables of data? I searched for guidelines, but could not find a good one so far.
Possibilities I see are:
* Only include the table itsef using a 'tabindex=0' attribute in the 'table' tag.
* Include the table ... | 2021/10/03 | [
"https://Stackoverflow.com/questions/69427687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3143823/"
] | The table itself and the rows themselves are generally **not** keyboard focusable because they're not interactive elements. If the row was selectable or expandable, then *maybe* it could be focusable but it's usually an **element** in the table row (or more accurately, an element in a the table cell) that is selectable... | Lately I heard another suggestion from an expert.
Generally speaking, all interactive elements should be included in the tab index, such as buttons, form fields and links. If the entire table row can be clicked, this should be in the tab flow by means of a tab index 0. |
8,973 | Has anyone tried doing a software PWM on the GPIO pins via a custom written module in kernel space?
Wouldn't want to reinvent the wheel, so if there where tries, please forward me to them. Will update the answer when i get new insights. | 2013/08/12 | [
"https://raspberrypi.stackexchange.com/questions/8973",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/8681/"
] | As Guzunty mentioned, I've used both [pi-blaster](https://github.com/sarfata/pi-blaster/) and [servoblaster](https://github.com/richardghirst/PiBits/tree/master/ServoBlaster) for using PWM to control LEDs. The latter includes a kernel module, but the recommended method is now the user-space daemon. Both methods create ... | Google Pi-blaster and servo blaster which are both software based solutions for RPi. |
20,108,622 | I have written an EDI document generator, and it currently pads any fields in the ISA segment that are less than the required number of characters with spaces on the left, e.g. ' 1234567890' for a 15 character element. I have a client who wants me to pad with spaces on the right. I can do this, but does ANSI X12 specif... | 2013/11/20 | [
"https://Stackoverflow.com/questions/20108622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132319/"
] | Just calling `.toStream` on your data should do it:
```
firstNumber(data.toStream)
``` | you could use Streams:
<http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Stream>
One way of stream creation:
```
1 #:: 2 #:: empty
``` |
20,108,622 | I have written an EDI document generator, and it currently pads any fields in the ISA segment that are less than the required number of characters with spaces on the left, e.g. ' 1234567890' for a 15 character element. I have a client who wants me to pad with spaces on the right. I can do this, but does ANSI X12 specif... | 2013/11/20 | [
"https://Stackoverflow.com/questions/20108622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132319/"
] | One possibility would be to use Scala's collection views:
<http://www.scala-lang.org/docu/files/collections-api/collections_42.html>
Calling `.view` on a collection allows you to call functions like `map`, `flatMap` etc on the collection without generating intermediate results.
So in your case you could write:
```
d... | you could use Streams:
<http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Stream>
One way of stream creation:
```
1 #:: 2 #:: empty
``` |
20,108,622 | I have written an EDI document generator, and it currently pads any fields in the ISA segment that are less than the required number of characters with spaces on the left, e.g. ' 1234567890' for a 15 character element. I have a client who wants me to pad with spaces on the right. I can do this, but does ANSI X12 specif... | 2013/11/20 | [
"https://Stackoverflow.com/questions/20108622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132319/"
] | ```
data.iterator.flatMap(numbers).take(1).toList
```
Don't use streams; you don't need the old data stored. Don't use views; they aren't being carefully maintained and are overkill anyway.
If you want an `Int`, you need some default behavior. Depending on what that is, you might choose
```
data.iterator.flatMap(nu... | you could use Streams:
<http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Stream>
One way of stream creation:
```
1 #:: 2 #:: empty
``` |
20,108,622 | I have written an EDI document generator, and it currently pads any fields in the ISA segment that are less than the required number of characters with spaces on the left, e.g. ' 1234567890' for a 15 character element. I have a client who wants me to pad with spaces on the right. I can do this, but does ANSI X12 specif... | 2013/11/20 | [
"https://Stackoverflow.com/questions/20108622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132319/"
] | ```
data.iterator.flatMap(numbers).take(1).toList
```
Don't use streams; you don't need the old data stored. Don't use views; they aren't being carefully maintained and are overkill anyway.
If you want an `Int`, you need some default behavior. Depending on what that is, you might choose
```
data.iterator.flatMap(nu... | Just calling `.toStream` on your data should do it:
```
firstNumber(data.toStream)
``` |
20,108,622 | I have written an EDI document generator, and it currently pads any fields in the ISA segment that are less than the required number of characters with spaces on the left, e.g. ' 1234567890' for a 15 character element. I have a client who wants me to pad with spaces on the right. I can do this, but does ANSI X12 specif... | 2013/11/20 | [
"https://Stackoverflow.com/questions/20108622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132319/"
] | ```
data.iterator.flatMap(numbers).take(1).toList
```
Don't use streams; you don't need the old data stored. Don't use views; they aren't being carefully maintained and are overkill anyway.
If you want an `Int`, you need some default behavior. Depending on what that is, you might choose
```
data.iterator.flatMap(nu... | One possibility would be to use Scala's collection views:
<http://www.scala-lang.org/docu/files/collections-api/collections_42.html>
Calling `.view` on a collection allows you to call functions like `map`, `flatMap` etc on the collection without generating intermediate results.
So in your case you could write:
```
d... |
47,056 | I won't go into details, but I am dealing with horrible guilt and shame over cruel acts I have committed in the past. It feels like I am now come to terms with the significance of these actions, and seeing the ripening of this accumulated negative karma into a hellish mental state. I had previously compartmentalized wh... | 2022/04/16 | [
"https://buddhism.stackexchange.com/questions/47056",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/23647/"
] | Higher Buddhism explains all things are "not-self" ("anatta"). In other words, there is no real self that is the "doer" of unwholesome actions. Instead, the Buddha explained (explicitly in [SN 12.17](https://www.accesstoinsight.org/tipitaka/sn/sn12/sn12.017.than.html)) the "doer" of unwholesome actions is the element o... | Sadhu. It's fine now. Go on and keep the focus on the path toward liberation, not following other than that, good householder. |
47,056 | I won't go into details, but I am dealing with horrible guilt and shame over cruel acts I have committed in the past. It feels like I am now come to terms with the significance of these actions, and seeing the ripening of this accumulated negative karma into a hellish mental state. I had previously compartmentalized wh... | 2022/04/16 | [
"https://buddhism.stackexchange.com/questions/47056",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/23647/"
] | Higher Buddhism explains all things are "not-self" ("anatta"). In other words, there is no real self that is the "doer" of unwholesome actions. Instead, the Buddha explained (explicitly in [SN 12.17](https://www.accesstoinsight.org/tipitaka/sn/sn12/sn12.017.than.html)) the "doer" of unwholesome actions is the element o... | To endorse Dhamma Dhatu's answer: as a lay person living alongside regular people, a certain degree of skill is needed when approaching confessions and in some cases confession may not be the most appropriate approach at all.
Counsellors or psychotherapists can help you unpack the issue until you find yourself surroun... |
47,056 | I won't go into details, but I am dealing with horrible guilt and shame over cruel acts I have committed in the past. It feels like I am now come to terms with the significance of these actions, and seeing the ripening of this accumulated negative karma into a hellish mental state. I had previously compartmentalized wh... | 2022/04/16 | [
"https://buddhism.stackexchange.com/questions/47056",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/23647/"
] | Here is a good resource worth reading: <https://manjushridharmacenter.org/rinpoches-wisdom/the-four-powers-of-purification-of-negative-karma/>
The problem when we don't forgive ourselves for our past is many times we create a cycle where our self loathing will cause us to act in unvirtuous ways and we remain tied to o... | Sadhu. It's fine now. Go on and keep the focus on the path toward liberation, not following other than that, good householder. |
47,056 | I won't go into details, but I am dealing with horrible guilt and shame over cruel acts I have committed in the past. It feels like I am now come to terms with the significance of these actions, and seeing the ripening of this accumulated negative karma into a hellish mental state. I had previously compartmentalized wh... | 2022/04/16 | [
"https://buddhism.stackexchange.com/questions/47056",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/23647/"
] | What you did before was cruel to others. Assuming that you have ceased being cruel to others (which is not an assumption I make lightly, or take for granted, because 'ceasing' is far more difficult than most imagine), the question is this: are going to be cruel to yourself?
Don't bother. There are no reparations (repa... | Sadhu. It's fine now. Go on and keep the focus on the path toward liberation, not following other than that, good householder. |
47,056 | I won't go into details, but I am dealing with horrible guilt and shame over cruel acts I have committed in the past. It feels like I am now come to terms with the significance of these actions, and seeing the ripening of this accumulated negative karma into a hellish mental state. I had previously compartmentalized wh... | 2022/04/16 | [
"https://buddhism.stackexchange.com/questions/47056",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/23647/"
] | Here is a good resource worth reading: <https://manjushridharmacenter.org/rinpoches-wisdom/the-four-powers-of-purification-of-negative-karma/>
The problem when we don't forgive ourselves for our past is many times we create a cycle where our self loathing will cause us to act in unvirtuous ways and we remain tied to o... | To endorse Dhamma Dhatu's answer: as a lay person living alongside regular people, a certain degree of skill is needed when approaching confessions and in some cases confession may not be the most appropriate approach at all.
Counsellors or psychotherapists can help you unpack the issue until you find yourself surroun... |
47,056 | I won't go into details, but I am dealing with horrible guilt and shame over cruel acts I have committed in the past. It feels like I am now come to terms with the significance of these actions, and seeing the ripening of this accumulated negative karma into a hellish mental state. I had previously compartmentalized wh... | 2022/04/16 | [
"https://buddhism.stackexchange.com/questions/47056",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/23647/"
] | What you did before was cruel to others. Assuming that you have ceased being cruel to others (which is not an assumption I make lightly, or take for granted, because 'ceasing' is far more difficult than most imagine), the question is this: are going to be cruel to yourself?
Don't bother. There are no reparations (repa... | To endorse Dhamma Dhatu's answer: as a lay person living alongside regular people, a certain degree of skill is needed when approaching confessions and in some cases confession may not be the most appropriate approach at all.
Counsellors or psychotherapists can help you unpack the issue until you find yourself surroun... |
10,369,671 | Edit: this code actually works. I had problem in the code that used it. Leaving it anyway in case anybody will find it useful.
I have a class with two methods to write and read a boolean persisted preference. However, if I write a new value and then try to read it, I still get the old value. Only if I kill the app and... | 2012/04/29 | [
"https://Stackoverflow.com/questions/10369671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1139880/"
] | ```
public static boolean getBooleanFromSP(String key) {
// TODO Auto-generated method stub
SharedPreferences preferences = getApplicationContext().getSharedPreferences(" SHARED_PREFERENCES_NAME ", android.content.Context.MODE_PRIVATE);
return preferences.getBoolean(key, false);
}//getPWDFromSP()
public static... | ```
public static boolean getBooleanFromSP(String key) {
// TODO Auto-generated method stub
SharedPreferences preferences =
getApplicationContext().getSharedPreferences(" SHARED_PREFERENCES_NAME ",
android.content.Context.MODE_PRIVATE);
return preferences.getBoolean(key, false);
}//getPWDFromSP()
public static... |
10,369,671 | Edit: this code actually works. I had problem in the code that used it. Leaving it anyway in case anybody will find it useful.
I have a class with two methods to write and read a boolean persisted preference. However, if I write a new value and then try to read it, I still get the old value. Only if I kill the app and... | 2012/04/29 | [
"https://Stackoverflow.com/questions/10369671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1139880/"
] | ```
public static boolean getBooleanFromSP(String key) {
// TODO Auto-generated method stub
SharedPreferences preferences = getApplicationContext().getSharedPreferences(" SHARED_PREFERENCES_NAME ", android.content.Context.MODE_PRIVATE);
return preferences.getBoolean(key, false);
}//getPWDFromSP()
public static... | ```
public class SharePref {
private static final String TAG = SharePref.class.getSimpleName();
private static SharePref mThis;
private Context mContext;
private SharedPreferences mPreference;
private SharePref() {
}
public static void init(Context context) {
if (mThis == null) {
mThis = new SharePref();... |
28,785,692 | I need to declare an empty array in php and add some elements to that array. I know this is possible to fill array in this way:
```
$list = array("value1", "value2", "value3");
```
But I want to have something like this:
```
$list = array();
$list->add("value1"); //pseudo-code
// some other program code
$list->add... | 2015/02/28 | [
"https://Stackoverflow.com/questions/28785692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1531130/"
] | There is the [array\_push](http://php.net/manual/en/function.array-push.php) method in PHP:
`array_push($list, "value");` | You are looking for [Array\_Push()](http://php.net/manual/en/function.array-push.php)
Here is an example of it being used:
```
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
```
outputs
```
Array
(
[0] => orange
[1] => banana
[2] => apple
[3] => raspb... |
28,785,692 | I need to declare an empty array in php and add some elements to that array. I know this is possible to fill array in this way:
```
$list = array("value1", "value2", "value3");
```
But I want to have something like this:
```
$list = array();
$list->add("value1"); //pseudo-code
// some other program code
$list->add... | 2015/02/28 | [
"https://Stackoverflow.com/questions/28785692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1531130/"
] | Alternatively:
```
$list = [];
// add values
$list[] = 'foo';
//add more...
$list[] = 'bar';
``` | You are looking for [Array\_Push()](http://php.net/manual/en/function.array-push.php)
Here is an example of it being used:
```
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
```
outputs
```
Array
(
[0] => orange
[1] => banana
[2] => apple
[3] => raspb... |
9,022,044 | I am working on a simple thing to uncheck all radio buttons in a sec when a page is loaded. For a bit, I've been tearing my hair out about this:
```
alert('uncheck');
$("input[name=PreviousMailAID]:checked").prop('checked', false);
alert('uncheck2');
```
What happens is I get the first alert, then the radio button i... | 2012/01/26 | [
"https://Stackoverflow.com/questions/9022044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/202184/"
] | Works fine. [demo](http://jsfiddle.net/4WnGy/)
PS: `.prop()` comes from jQuery 1.6, before that you have to use `.attr()` method. | [`jQuery().prop`](http://api.jquery.com/prop/) was added at [version 1.6](http://api.jquery.com/category/version/1.6/). Upgrade your jQuery version, or use:
```
$("input[name=PreviousMailAID]:checked").attr('checked', false);
```
Alternatively, you can combine jQuery with vanilla JavaScript:
```
$("input[name=Previ... |
9,022,044 | I am working on a simple thing to uncheck all radio buttons in a sec when a page is loaded. For a bit, I've been tearing my hair out about this:
```
alert('uncheck');
$("input[name=PreviousMailAID]:checked").prop('checked', false);
alert('uncheck2');
```
What happens is I get the first alert, then the radio button i... | 2012/01/26 | [
"https://Stackoverflow.com/questions/9022044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/202184/"
] | Works fine. [demo](http://jsfiddle.net/4WnGy/)
PS: `.prop()` comes from jQuery 1.6, before that you have to use `.attr()` method. | For jquery 1.3.2 use this
```
alert('uncheck');
$("input[name=PreviousMailAID]:checked").attr('checked', false);
alert('uncheck2');
``` |
9,022,044 | I am working on a simple thing to uncheck all radio buttons in a sec when a page is loaded. For a bit, I've been tearing my hair out about this:
```
alert('uncheck');
$("input[name=PreviousMailAID]:checked").prop('checked', false);
alert('uncheck2');
```
What happens is I get the first alert, then the radio button i... | 2012/01/26 | [
"https://Stackoverflow.com/questions/9022044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/202184/"
] | [`jQuery().prop`](http://api.jquery.com/prop/) was added at [version 1.6](http://api.jquery.com/category/version/1.6/). Upgrade your jQuery version, or use:
```
$("input[name=PreviousMailAID]:checked").attr('checked', false);
```
Alternatively, you can combine jQuery with vanilla JavaScript:
```
$("input[name=Previ... | For jquery 1.3.2 use this
```
alert('uncheck');
$("input[name=PreviousMailAID]:checked").attr('checked', false);
alert('uncheck2');
``` |
31,613,479 | I have a problem of else case in SQL case statement.
In my SQL table column `L_Keyword2` contains below value and is of `varchar` type.
```
YES,
LAND INCLUDED,
N/APPLICABLE,
3,
1.5,
NO,
4.5+,
OTHER,
NULL,
2,
1,
LAND LEASED,
0,
3.5,
N/A,
OE,
4,
2.5,
```
When I use this column in case statement like as
```
SELECT
... | 2015/07/24 | [
"https://Stackoverflow.com/questions/31613479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5152738/"
] | Firstly, `CASE` in T-SQL is **not** a statement - it's an **expression**. As such, all the values that it can return from its various `WHEN` clauses have to be of the same **datatype**, and if they're not, then SQL Server has a precedence list ([see the relevant MSDN documentation for details](https://msdn.microsoft.co... | Maybe this:
```
SELECT
L_Keyword2,
CASE
WHEN class LIKE 'RE_1' THEN L_Keyword2 ELSE '0' END
FROM Mytable
```
If you want to use `LIKE` put `%` wildcard. Otherwise it is simple comparison (`WHEN class = 'RE_1'`). |
29,512,894 | I'm trying to convert a text delimited by comments in a element which contains this text.
Source XML :
```
<?xml version="1.0" encoding="utf-8"?>
<DOC>
<TEXT>
<!--SectionLeRubrum-->
<para>R1</para>
<para>R2</para>
<para>...</para>
<!--SectionFaits-->
<para>F1</para>
<para>F2</para>
<para>...</para>
<!--SectionConside... | 2015/04/08 | [
"https://Stackoverflow.com/questions/29512894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4763442/"
] | This is a fairly standard *grouping problem* - you need to associate each `para` element with its nearest preceding comment, then process the *comments* and do the appropriate thing with each group. You can use a *key* to achieve this:
```
<xsl:key name="paraByComment" match="para"
use="generate-id(preceding-... | in principle, you have to exclude these elements in "normal" mode by a template like this:
```
<xsl:template match="*[preceding-sibling::comment()='SectionConsiderants' and following-sibling::comment()='SectionDispositif']"/>
```
However, this all just works once: If you happen to have more than one "zone", then th... |
10,208,206 | I have a CSV file like this:
```
text,0
more text,2
some more text,100
```
I need to delete any line containing only `0` in the second column, e.g., the output of the above would be:
```
more text,2
some more text,100
```
How can I delete all lines from a CSV with an exact match? | 2012/04/18 | [
"https://Stackoverflow.com/questions/10208206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/834616/"
] | If that's your last field, grep will do the trick:
```
grep -v ',0$'
```
If not, and your fields don't contain `,`, use awk:
```
awk -F , '{if ($2!='0') print}'
```
If it's even more complex use python or ruby with a CSV parser. | If you want an inline edit to your file you could try the following. REMEMBER TO BACKUP YOUR FILE PRIOR TO ATTEMPTING ANY INLINE EDIT. (Will delete lines that contain a match)
```
sed -i "s/.*match.*//g" /yourfile.csv
```
To delete any blank lines within your file. (REMEMBER TO BACKUP YOUR FILE PRIOR TO ATTEMPTING A... |
10,208,206 | I have a CSV file like this:
```
text,0
more text,2
some more text,100
```
I need to delete any line containing only `0` in the second column, e.g., the output of the above would be:
```
more text,2
some more text,100
```
How can I delete all lines from a CSV with an exact match? | 2012/04/18 | [
"https://Stackoverflow.com/questions/10208206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/834616/"
] | If that's your last field, grep will do the trick:
```
grep -v ',0$'
```
If not, and your fields don't contain `,`, use awk:
```
awk -F , '{if ($2!='0') print}'
```
If it's even more complex use python or ruby with a CSV parser. | This might work for you:
```
awk -F, '$2' file
``` |
10,208,206 | I have a CSV file like this:
```
text,0
more text,2
some more text,100
```
I need to delete any line containing only `0` in the second column, e.g., the output of the above would be:
```
more text,2
some more text,100
```
How can I delete all lines from a CSV with an exact match? | 2012/04/18 | [
"https://Stackoverflow.com/questions/10208206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/834616/"
] | If that's your last field, grep will do the trick:
```
grep -v ',0$'
```
If not, and your fields don't contain `,`, use awk:
```
awk -F , '{if ($2!='0') print}'
```
If it's even more complex use python or ruby with a CSV parser. | A simple sed solution...
```
sed /,0$/d
``` |
33,466 | Dronacharya and Kripacharya were powerful warriors who fought in the Mahabharata war. However, they were Brahmanas and not Kshatriyas.
Why did they decide to fight?
*Apastamba* says:
>
> 6. A Brāhmaṇa shall not take a weapon into his hand, though he be only
> desirous of examining it.
>
>
>
However, the [*Man... | 2019/03/02 | [
"https://hinduism.stackexchange.com/questions/33466",
"https://hinduism.stackexchange.com",
"https://hinduism.stackexchange.com/users/11726/"
] | If protecting the dharma was the reason, they would never have taken up arms, as it was evident that the Pandavas were the one on side of true dharma (As Krishna was on their side, it itself is enough evidence).
So, one reason they took up arms (unwillingly), as they were ordered to. They were indeed the servants of K... | It was a very basic reason called being true to your salt, do not betray your loyalty. Drona's early life was one of poverty, he and his family had to suffer a lot because of it. The incident when his son Aswathamma, was fooled into believing a mixture of rice powder and water as milk, hurt him deeply, and he resolved,... |
40,102,236 | How to press (down arrow +shift key) button using selenium WebDriver?
I need to select options from multi Select box. For that i need to know how to press both keys together. Please help. Thanks. | 2016/10/18 | [
"https://Stackoverflow.com/questions/40102236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7035133/"
] | Here is a really simple example:
```
import org.openqa.selenium.Keys;
String multiSelect = Keys.chord(Keys.SHIFT, Keys.DOWN);
driver.findElement(By.xpath("//xpath")).sendKeys(multiSelect);
```
You can do it of course in other combinations, too. | Using the Robot class in Java you can perform like shown below
```
Robot robot=new Robot();
robot.keyPress(KeyEvent.VK_SHIFT);
//This will press shift key on keyboard.
robot.keyPress(KeyEvent.VK_DOWN);
//This will press the down key on your numpad.
robot.keyRelease(KeyEvent.VK_DOWN);
//This will release the down ... |
12,366,553 | Using Python as an example, vim will highlight `list`, but not `collections.defaultdict(list)`
and `len`, but not `len()`. Anyone have any idea what the reason for this is? | 2012/09/11 | [
"https://Stackoverflow.com/questions/12366553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Could you please post the contents of your `/usr/share/vim/vim72/syntax/python.vim` file?
My vim doesn't hilight builtin functions, unless I uncomment the string
```
" let python_highlight_builtins = 1
```
When I do so, both `len` and `len()` get hilighted properly. | How would you like `collections.defaultdict(list)` to be highlighted? Vim's default Python syntax file doesn't seem to define a syntax group for function calls, only function definitions (`pythonFunction`). `collections` and `defaultdict` are not recognized either. `list` is highlighted because it's recognized as a bui... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.