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 |
|---|---|---|---|---|---|
293,532 | People who don't understand Terminal are often afraid to use it for fear that they might mess up their command and crash their computer. Those who know Terminal better know that that's not the case - usually Terminal will just output an error. But are there actually commands that will crash your computer?
WARNING: yo... | 2017/07/31 | [
"https://apple.stackexchange.com/questions/293532",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/234283/"
] | Not sure what you mean about 'crash'ing the computer - if you would re-phrase it to say 'render the computer unusable', then yes. Certainly all it takes is a single stray command - just a moment where you're not thinking clearly about what you're doing, similar to when you speak without thinking, and the damage can be ... | Yes, you can completely destroy your system. Accidentally doing something with `sudo` privileges is one example that has been posted, whether it's forgetting a few characters that instruct the terminal to do something completely different than you intended. `rm`ing `/` instead of `/tmp/\*` is only a 5 character differe... |
293,532 | People who don't understand Terminal are often afraid to use it for fear that they might mess up their command and crash their computer. Those who know Terminal better know that that's not the case - usually Terminal will just output an error. But are there actually commands that will crash your computer?
WARNING: yo... | 2017/07/31 | [
"https://apple.stackexchange.com/questions/293532",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/234283/"
] | Not sure what you mean about 'crash'ing the computer - if you would re-phrase it to say 'render the computer unusable', then yes. Certainly all it takes is a single stray command - just a moment where you're not thinking clearly about what you're doing, similar to when you speak without thinking, and the damage can be ... | Modern macOS makes it *really* hard to crash your machine as an unprivileged user (i.e. without using `sudo`), because UNIX systems are meant to handle thousands of users without letting any of them break the whole system. So, thankfully, you'll usually have to be prompted before you do something that destroys your mac... |
293,532 | People who don't understand Terminal are often afraid to use it for fear that they might mess up their command and crash their computer. Those who know Terminal better know that that's not the case - usually Terminal will just output an error. But are there actually commands that will crash your computer?
WARNING: yo... | 2017/07/31 | [
"https://apple.stackexchange.com/questions/293532",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/234283/"
] | Modern macOS makes it *really* hard to crash your machine as an unprivileged user (i.e. without using `sudo`), because UNIX systems are meant to handle thousands of users without letting any of them break the whole system. So, thankfully, you'll usually have to be prompted before you do something that destroys your mac... | Answers that call `sudo` should be considered invalid. These already assume
administrative access to the system.
Try `perl -e 'exit if fork;for(;;){fork;}'`. OSX may have some safeguard against this now. If is presents an apple bubble asking if you want to terminate Terminal app and subprocesses, you're (almost) good.... |
293,532 | People who don't understand Terminal are often afraid to use it for fear that they might mess up their command and crash their computer. Those who know Terminal better know that that's not the case - usually Terminal will just output an error. But are there actually commands that will crash your computer?
WARNING: yo... | 2017/07/31 | [
"https://apple.stackexchange.com/questions/293532",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/234283/"
] | One way to crash a computer is to execute a so called [fork-bomb](https://en.wikipedia.org/wiki/Fork_bomb).
You can execute it on a unix-sytem by:
```
:(){ :|: & };:
```
It's a command that will recursively spawn processes till the OS is so busy it won't respond to any action anymore. | Suppose you don't know what your doing and attempting to do a backup of some hard drive
```
dd if=/dev/disk1 of=/dev/disk2
```
Well if you mix those up (switch if and of), it will overwrite the fresh data with old data, no questions asked.
Similar mix ups can happen with archive utils. And frankly with most comma... |
293,532 | People who don't understand Terminal are often afraid to use it for fear that they might mess up their command and crash their computer. Those who know Terminal better know that that's not the case - usually Terminal will just output an error. But are there actually commands that will crash your computer?
WARNING: yo... | 2017/07/31 | [
"https://apple.stackexchange.com/questions/293532",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/234283/"
] | Not sure what you mean about 'crash'ing the computer - if you would re-phrase it to say 'render the computer unusable', then yes. Certainly all it takes is a single stray command - just a moment where you're not thinking clearly about what you're doing, similar to when you speak without thinking, and the damage can be ... | I am only a bash beginner, but you could use something like this:
`while True; do COMMAND; done;`
Most people would try to use Ctrl+C to stop the command, not the external process (Ctrl+Z, which then need to be killed).
If the command in the `while True` loop is a resource-intensive operation (such as multiplying la... |
38,842,591 | I have a mvc devexpress grid, i want to acheive a functionality which when on editing of the grid, one of the column has to be readonly while other changeable.And while adding a new row, all the columsn have to be changeable including the previously said readonly column.
This is my code for the grid
```
@{
var ... | 2016/08/09 | [
"https://Stackoverflow.com/questions/38842591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2368862/"
] | Instead you can use CellEditorInitialize event on your desired column
```
settings.CellEditorInitialize += (s, e) =>
{
var abc = s as ASPxGridView;
if (e.Column.FieldName == "YourFieldName")
e.Editor.ReadOnly = !abc.IsNewRowEditing;
};
``` | I still think you should setup action **MVCxGridViewColumn.SetEditItemTemplateContent** on that specific column.
This is very similar issue to your previews one:
[Set ReadOnly property to a column of devexpress grid(MVC) only on edit click](https://stackoverflow.com/questions/38825706/set-readonly-property-to-a-colu... |
32,608,150 | I have the following string:
```
"Failed verification. \n Selected: First Name; Andrew; Last Name; Drew; correct options: First Name; Matt; Last Name; Darr;
```
I want to create array with data from this string that will look like this:
```
[ ["Andrew", "Matt"], ["Drew", "Darr"] ]
```
first key in array is select... | 2015/09/16 | [
"https://Stackoverflow.com/questions/32608150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2389501/"
] | spray-routing is build around the concept of [`Directive`](http://spray.io/documentation/1.2.3/spray-routing/key-concepts/directives/).
You can think of a `Directive` as a transformation over an HTTP request.
The cardinality associated with a directive is the number of arguments is passes down the transform chain aft... | Here I found a very good workshop.
<https://www.youtube.com/watch?v=XPuOlpWEvmw> |
4,397,600 | here is the example
```
<style>body{color:red;width:200px; }</style>
```
looking to strip the style tag and retrieve the data..but wanaa regx for strip tags and get data between them...someone plz help me... | 2010/12/09 | [
"https://Stackoverflow.com/questions/4397600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/516957/"
] | If this is your css:
```
<style>
body{
color:red;
width:200px;
}
</style>
```
Then you can *reliably* get the body's width like this:
```
$('body').css('width');
```
Try it: <http://jsfiddle.net/3SkY5/1/>
See <http://api.jquery.com/css/> | ```
$('style:first').html();
```
... for instance. Modify as needed.
I don't think regular expressions will be the best solution here. As somebody else will doubtlessly explain to you in a link, html is not regular. |
4,397,600 | here is the example
```
<style>body{color:red;width:200px; }</style>
```
looking to strip the style tag and retrieve the data..but wanaa regx for strip tags and get data between them...someone plz help me... | 2010/12/09 | [
"https://Stackoverflow.com/questions/4397600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/516957/"
] | If this is your css:
```
<style>
body{
color:red;
width:200px;
}
</style>
```
Then you can *reliably* get the body's width like this:
```
$('body').css('width');
```
Try it: <http://jsfiddle.net/3SkY5/1/>
See <http://api.jquery.com/css/> | Can you try this:
```
$('style').html();
``` |
29,647,529 | When I send email from my application using the default WildFly mail session, the auto-generated message ID gives away that my server is WildFly:
```
Message-ID: <524672585.11.1429091886393.JavaMail.wildfly@myserver.example.com>
```
For security reasons, I'd like to suppress or override the `wildfly` substring in th... | 2015/04/15 | [
"https://Stackoverflow.com/questions/29647529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338614/"
] | See [How do I specify the exit code of a console application in .NET?](https://stackoverflow.com/questions/155610/how-do-i-specify-the-exit-code-of-a-console-application-in-net), [MSDN: Main() Return Values (C# Programming Guide)](https://msdn.microsoft.com/en-us/library/0fwzzxz2.aspx) and [.NET Global exception handle... | You'll have to write a separate program that creates a new process that catches the error. When the catch is made you can send notification to yourself in the catch statement before the error handling notification.
It will likely need to run as a separate program called from the local user's system. |
1,241,265 | I am trying to use xdotool over ssh on Ubuntu 20.04 LTS. It works perfectly from within a terminal window when logged in locally, but over ssh it displays the following error from using any command:
```
$ xdotool click 1
Error: Can't open display: (null)
Failed creating new xdo instance
```
Looking up this error the... | 2020/05/19 | [
"https://askubuntu.com/questions/1241265",
"https://askubuntu.com",
"https://askubuntu.com/users/-1/"
] | You have to run `ssh` with `-X` option like below:
```
ssh -X user@hostname
```
and then execute "graphical" commands as usual. | The thing is this will control the system that is connected via SSH and not the Host you want to Control.
For a example I login with the ssh -X server@192.192.192.192 and then tell xdotool to move the mouse instead of moving the mouse on the Server it moves the mouse on the client that is connected. |
59,671,983 | I am trying to create a connection manager in Microsoft SQL Server Data Tools for Visual Studio 2017 (SSDT) for an integration services project.
In the **Connection Manager**:
1. The Provider is set to: **Native OLE DB\SQL Server Naive Client 11.0**
2. The Server name is set to: the name of the **local machine**
3. L... | 2020/01/09 | [
"https://Stackoverflow.com/questions/59671983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12685290/"
] | I have resolved the issue. It was an extremely silly oversight! On installation, the server name in the Visual Studio 17 Connection Manager was listed as: *Local MachineName* only. In SQL Server, the Server Name was listed as: *LocalMachineName*\SQLEXPRESS. The Server Name in VS17 has to be exactly the same as SQL Serv... | SQL Server Configuration Manager ==> SQL Server Services(Left sidebar) ==> Right Click and Start all Stopped services |
3,680,022 | Prove that if $x$ is a real number such that $x(x + 1)>2$, then $x <−2$ or $x > 1$.
I think this is easy to prove by contrapositive, and thus,
if $x\ge -2$ and $x\le{1}$, then $x(x+1)\le 2$.
Notice that $ x(x+1)=x^2+x$ and that $x^2\ge{0}$ for all $x$ in the real numbers.
Since $-2\le{x}\le{1}$ implies $x^2\le 4$.
... | 2020/05/18 | [
"https://math.stackexchange.com/questions/3680022",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/789642/"
] | The fact that the $D$ matrix is diagonal makes the problem much easier. The Lagrangian is:
$$L(x,y) = ||x-z||\_2^2 + y\left(x^TDx-1\right)$$
so the KKT conditions are:
$$(x\_i-z\_i) + yd\_i x\_i = 0 \quad \forall i$$
$$x^TDx = 1$$
The stationarity condition can also be expressed as:
$$x\_i = \frac{z\_i}{1+yd\_i}.$$
Thi... | One way to look at this problem is from a bounding perspective, although it only gives insight into the optimal distance $\|x^\*-z\|\_2$, and not necessarily localization information of $x^\*$ itself in general.
In particular, note that we can define a lifted variable $X=xx^\top$. Then the left side of the constraint ... |
66,456 | My longtable exceeds the page length. Any help would be highly appreciated.
```
\documentclass[11pt,a4paper,oneside]{report}
\usepackage{fontenc}
\usepackage{setspace}
\usepackage{array}
\usepackage{covington}
\usepackage{pslatex}
\usepackage{float}
\usepackage{longtable}
\usepackage{booktabs}
\newcolumntype{R}{>{\ra... | 2012/08/09 | [
"https://tex.stackexchange.com/questions/66456",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/17205/"
] | You should try to provide a minimum working example (MWE) instead of your full preamble and content. Also the comments of @hakaze above.
However, you should provide the placement options `[htbp]` to the `figure` environment so as to enable LaTeX to conveniently place your figure. With `\begin{figure}[htbp]`, your prob... | This answer is posted in response to some questions the OP posted to earlier comments. The main point of this posting is to demonstrate that it's possible to create the exact same layout of a "short" table, i.e., one that fits on a single page, using either the `longtable` environment or the `table`/`tabular` environme... |
5,933,025 | The following yields 6000:
```
firstLabel.text = [[NSString alloc] initWithFormat:@"%f",(6*pow(10,3))];
```
How can this be made to display the number in scientific notation, like `6 x 10^3` or `6e3`? | 2011/05/09 | [
"https://Stackoverflow.com/questions/5933025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/744592/"
] | <http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html>
in short you want %e. | Look at [NSNumberFormatter](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNumberFormatter_Class/Reference/Reference.html) and NSNumberFormatterScientificStyle.
```
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterS... |
2,821 | I met by chance one of the original/foundational SO developers at a bar the other day. He told me it had been a long day and he needed a beer. After talking I hopped on 'meta' later and saw the whole uproar over things related to moderators, community, etc. and understood a bit more about why it had been a long day for... | 2019/10/07 | [
"https://gamedev.meta.stackexchange.com/questions/2821",
"https://gamedev.meta.stackexchange.com",
"https://gamedev.meta.stackexchange.com/users/3830/"
] | I'd say, the question you can ask yourself is, will others benefit by the changes? It's not only OP that people are helping by answering, but future readers as well.
I saw this answer when it was posted, and I was really confused about what it is trying to do. I agree with you that it could use a lot of work to make i... | My answer will go along the lines of [TomTsagk](https://gamedev.meta.stackexchange.com/a/2819/40264), but will end differently:
1. provide the straight answer to their question;
2. add an horizontal line (`blank line` + `---`);
3. tell them that you think of ways of making their code "more optimal";
4. describe what y... |
2,821 | I met by chance one of the original/foundational SO developers at a bar the other day. He told me it had been a long day and he needed a beer. After talking I hopped on 'meta' later and saw the whole uproar over things related to moderators, community, etc. and understood a bit more about why it had been a long day for... | 2019/10/07 | [
"https://gamedev.meta.stackexchange.com/questions/2821",
"https://gamedev.meta.stackexchange.com",
"https://gamedev.meta.stackexchange.com/users/3830/"
] | I'd say, the question you can ask yourself is, will others benefit by the changes? It's not only OP that people are helping by answering, but future readers as well.
I saw this answer when it was posted, and I was really confused about what it is trying to do. I agree with you that it could use a lot of work to make i... | I've done this before, and typically the following applies:
* If the provided code is OK, barring that it might benefit from some refactoring, then I prefer to leave it be. The OP might be aware of this, or doing it this way for other reasons we don't immediately know about.
+ The classic example of this in a Gamedev... |
2,821 | I met by chance one of the original/foundational SO developers at a bar the other day. He told me it had been a long day and he needed a beer. After talking I hopped on 'meta' later and saw the whole uproar over things related to moderators, community, etc. and understood a bit more about why it had been a long day for... | 2019/10/07 | [
"https://gamedev.meta.stackexchange.com/questions/2821",
"https://gamedev.meta.stackexchange.com",
"https://gamedev.meta.stackexchange.com/users/3830/"
] | My answer will go along the lines of [TomTsagk](https://gamedev.meta.stackexchange.com/a/2819/40264), but will end differently:
1. provide the straight answer to their question;
2. add an horizontal line (`blank line` + `---`);
3. tell them that you think of ways of making their code "more optimal";
4. describe what y... | I've done this before, and typically the following applies:
* If the provided code is OK, barring that it might benefit from some refactoring, then I prefer to leave it be. The OP might be aware of this, or doing it this way for other reasons we don't immediately know about.
+ The classic example of this in a Gamedev... |
18,066,847 | ```
DWORD baseAddress = (DWORD) GetModuleHandle(NULL);
```
If I put that code into a DLL and inject it to a process, that seems to equal the base address of the injected process.
How does that work exactly? How does the cast from HMODULE to DWORD work? Would it work if I cast it to void\* instead of DWORD? | 2013/08/05 | [
"https://Stackoverflow.com/questions/18066847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2654180/"
] | This is an implementation detail of the 32-bit and 64-bit version of Windows. HMODULE is older than that, in the 16-bit version of Windows they were true handles. That was not necessary anymore in win32, the virtual memory address at which a module is loaded uniquely identifies the module. So using the VM address was p... | It works because Windows just happened to use the base address as an identifying handle, and because on a 32-bit system an address fits into a DWORD. Since Windows isn't required to do that, you shouldn't rely on it for anything. |
21,902,734 | I am developing on OS X. For testing I am using VirtualBox with windows VMs from <http://www.modern.ie/en-us/virtualization-tools#downloads>
When testing my web applications, should I be testing in IE10 on both Win7 *and* Win8, or can I safely assume that IE10 behaves identically on both platforms and only test on Win... | 2014/02/20 | [
"https://Stackoverflow.com/questions/21902734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/250605/"
] | No, they are not identical, but they should be the same for the common features that both support. IE10 and 11 on Windows 8 and 8.1 support a number of extra features that are not included on Windows 8. They mostly relate to touch and device hardware support. Windows 8.\* is a touch friendly OS while Win7 is a more tra... | [Please visit Microsoft IE 10 Dev Guide:](http://msdn.microsoft.com/en-us/library/ie/jj819730%28v=vs.85%29.aspx)
[IE Guide:](http://msdn.microsoft.com/en-us/library/ie/bg125382.aspx) |
44,277,771 | My UI asks for the inputs User\_ID and Supplier\_ID and I wanted a string validation accept inputs for Supplier\_ID like below:
```
1st scenario: 123456
2nd scenario: 123456,098765
3rd scenario: 123456,098765,345678
```
While it should not accept inputs like:
```
1st scenario: Any number less than 6 digits like 123... | 2017/05/31 | [
"https://Stackoverflow.com/questions/44277771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8090072/"
] | This pattern matches your test cases, and for any number of 6 digit groups separated by a comma.
```
^\d{6}(,\d{6})*$
``` | this is the expresion you are looking for
```
^\d{6}(\,\d{6}){0,2}$
``` |
44,277,771 | My UI asks for the inputs User\_ID and Supplier\_ID and I wanted a string validation accept inputs for Supplier\_ID like below:
```
1st scenario: 123456
2nd scenario: 123456,098765
3rd scenario: 123456,098765,345678
```
While it should not accept inputs like:
```
1st scenario: Any number less than 6 digits like 123... | 2017/05/31 | [
"https://Stackoverflow.com/questions/44277771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8090072/"
] | This pattern matches your test cases, and for any number of 6 digit groups separated by a comma.
```
^\d{6}(,\d{6})*$
``` | Create your regex as searchgroups and check first for a newline followed by 6 digits, and then for `,` followed by 6 digits groups.
```js
['123456',
'123456,098765',
'123456,098765,345678',
'123456,0987s65,345678',
'12345,098765,345678',
'123456/098765'
]
.forEach(function(line) {
if (line.toString... |
54,915,673 | I'm trying to run a Copy URL event using clipboard.js. I have it installed on my server and the reference to clipboard.js is there in my code. So I have this in my footer:
```
<script type="text/javascript">
var url = document.location.href;
new Clipboard('.btn', {
text: function() {
return url;
... | 2019/02/27 | [
"https://Stackoverflow.com/questions/54915673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1070096/"
] | Because the value of `castChar` is the integer value `5`, while the value of `realChar` is the *integer encoding of the character value* `'5'` (ASCII 53). These are not the same values.
Casting has nothing to do with it. Or, more accurately, casting `nr` to `char` doesn't give you the *character value* `'5'`, it just... | `(char)5` and `'5'` are not the same thing.
The literal `'5'` is an integer value that represents the character 5. Its value depends on the platform. Assuming ASCII representation for characters, this would be 53.
The literal `(char)5` is the integer value 5 that has been cast to type `char`. This means it retains th... |
60,568,456 | I am using FusionPro to create a gift ask string for an appeal letter based on a donors last gift. The letter is mailed to an area that has a high Jewish population so if a donors last gift is a multiple of 18, the ask string need to be created accordingly and only use multiples of 18. Here is my current script to crea... | 2020/03/06 | [
"https://Stackoverflow.com/questions/60568456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13020086/"
] | The easiest way to find if any number is evenly divisible by another is to use the mod operator. In many languages, the operator is a % [Reference](https://www.w3schools.com/js/js_arithmetic.asp)
Basically the mod operator gives you the remainder after a division operation. For example
>
> 4 % 2 is 0 7 % 2 is 3 Rema... | to find if a number is a multiple of x use the % function
so
```
if (StringToNumber(round) % 18 === 0) {
// Number is a multiple of 18
}
``` |
8,761,665 | **Hello everybody,**
I have a small code in PHP that I would like to convert in Delphi and I have some troubles...
Here is the PHP code :
```
$from = "121.198.0.0";
$to = "121.198.255.255";
$arry1 = explode(".", $from);
$arry2 = explode(".", $to);
$a1 = $arry1[0];
$b1 = $arry1[1];
$c1 = $arry1[2];
$d1 ... | 2012/01/06 | [
"https://Stackoverflow.com/questions/8761665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/778642/"
] | Here's what I can see just by looking at the code:
If think you have the parameters to `Explode` in the wrong order. The separator is the second parameter in the function to which you linked. So you should write:
```
Arry1 := Explode(RangeFrom, '.');
Arry2 := Explode(RangeTo, '.');
```
---
You are leaking memory b... | I think the reason it is not doing anything right now is you may not have any values in edit1.text or edit2.text.
For testing (before making this snippet a procedure or function) you could just assign some test data to RangeFrom and RangeTo.
Ex.
RangeFrom := '121.198.0.0';
RangeTo := '121.198.255.255'; |
8,761,665 | **Hello everybody,**
I have a small code in PHP that I would like to convert in Delphi and I have some troubles...
Here is the PHP code :
```
$from = "121.198.0.0";
$to = "121.198.255.255";
$arry1 = explode(".", $from);
$arry2 = explode(".", $to);
$a1 = $arry1[0];
$b1 = $arry1[1];
$c1 = $arry1[2];
$d1 ... | 2012/01/06 | [
"https://Stackoverflow.com/questions/8761665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/778642/"
] | Here's what I can see just by looking at the code:
If think you have the parameters to `Explode` in the wrong order. The separator is the second parameter in the function to which you linked. So you should write:
```
Arry1 := Explode(RangeFrom, '.');
Arry2 := Explode(RangeTo, '.');
```
---
You are leaking memory b... | Testing the goal:
```
procedure TForm1.Button1Click(Sender: TObject);
var
AddrList: TStringList;
StartAddress,
EndAddress: Cardinal;
a, b, c, d: PByte;
x: Cardinal;
begin
AddrList := TStringList.Create;
AddrList.Delimiter := '.';
AddrList.DelimitedText := Edit1.Text;
StartAddress := (Cardinal(StrToIn... |
67,509,234 | I was able to do it by looping accessing `list[i][j]`.
but wanted to do it without looping.
Any ideas how to do it
Example list :
Input: `["abc","def","ghi"]`
Output: `["$bc_","$ef_","$hi_"]` | 2021/05/12 | [
"https://Stackoverflow.com/questions/67509234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15146737/"
] | Use a list comprehension and concatenate or format the strings you want.
```
inlist = ['abc','def','ghi']
outlist = [f'${s[1:]}_' for s in inlist]
``` | You can use list comprehension:
```
lstIn = ['abc', 'def', 'ghi']
lstOut = [f'${i[1:]}_' for i in lstIn]
print(lstOut)
```
Prints:
```
['$bc_', '$ef_', '$hi_']
``` |
67,509,234 | I was able to do it by looping accessing `list[i][j]`.
but wanted to do it without looping.
Any ideas how to do it
Example list :
Input: `["abc","def","ghi"]`
Output: `["$bc_","$ef_","$hi_"]` | 2021/05/12 | [
"https://Stackoverflow.com/questions/67509234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15146737/"
] | Use a list comprehension and concatenate or format the strings you want.
```
inlist = ['abc','def','ghi']
outlist = [f'${s[1:]}_' for s in inlist]
``` | Try this
```
lst = ["abc","def","ghi"]
out = [ "".join(("$",s[1:],"_")) for s in lst ]
```
Output: `print(out)`
```
['$bc_', '$ef_', '$hi_']
``` |
63,483,417 | Say I have a dataframe
```
id category
1 A
2 A
3 B
4 C
5 A
```
And I want to create a new column with incremental values where `category == 'A'`. So it should be something like.
```
id category value
1 A 1
2 A 2
3 B NaN
4 C NaN
5 A 3
```
Curre... | 2020/08/19 | [
"https://Stackoverflow.com/questions/63483417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1676881/"
] | The following code for GNU sed:
```
sed 's/EndHere/&\n/g; s/\(StartHere\)[^\n]*\(EndHere\|$\)/\1\2/g; s/\n//g' <<EOF
StartHere Word1 EndHere
StartHere Word2
StartHere Word2 EndHere something else
something else StartHere Word2 EndHere something else
EOF
```
outputs:
```
StartHereEndHere
StartHere
StartHereEndHere s... | Instead of using `sed`, you could do it with Perl, which supports [negative lookahead](http://www.regular-expressions.info/lookaround.html).
Using the example you gave in your comment:
```
$ echo "oooo StartHere=Yo9897 EndHereYo" \
| perl -pe 's/(StartHere) (?: .*(EndHere) | .*(?!EndHere) )/$1$2/x'
```
would outp... |
689,798 | Suppose $\mathcal F$ is a family of functions from $A$ to $A$, and $B\subseteq A$. Prove that the closure of $B$ under $\mathcal F$ exists.
Attempt: I defined a set $$\bigcup\_{n \in \mathbb N}B\_n$$
where $B\_1=B$ and for all $n \ge 1$, $$B\_{n+1}=\{f(x)\mid f \in \mathcal F \,\text{and x $\in$ $B\_n$}\}$$
I am not... | 2014/02/25 | [
"https://math.stackexchange.com/questions/689798",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/82405/"
] | Write $\mathcal F = (f\_i)\_{i \in \mathbb{N}}$. Define $C\_0 := B$ and $C\_{i+1} := \cup\_{j \in \mathbb{N}} f\_j(C\_i)$ for $i \in \mathbb{N}^+$.
Case 1: $C\_1 \subseteq B$
Obviously $C\_{i+1} \subseteq C\_{i}$ for all $i \geq 1$. On the other hand, $|C\_i| \geq 1$ for every $i$ by the definition of a function. So ... | This answer is motivated by Enderton's "A Mathematical Introduction to Logic".
The closure of $B\subset A$ under family of functions $\mathcal{F}$ is defined as follows.
I will generalize to the case that $f\in \mathcal{F}$ has $f:\times^m A \to A$ for any $m\in \mathbb{N}$.
$C\subset A$ is said to be a closure of $B... |
689,798 | Suppose $\mathcal F$ is a family of functions from $A$ to $A$, and $B\subseteq A$. Prove that the closure of $B$ under $\mathcal F$ exists.
Attempt: I defined a set $$\bigcup\_{n \in \mathbb N}B\_n$$
where $B\_1=B$ and for all $n \ge 1$, $$B\_{n+1}=\{f(x)\mid f \in \mathcal F \,\text{and x $\in$ $B\_n$}\}$$
I am not... | 2014/02/25 | [
"https://math.stackexchange.com/questions/689798",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/82405/"
] | Write $\mathcal F = (f\_i)\_{i \in \mathbb{N}}$. Define $C\_0 := B$ and $C\_{i+1} := \cup\_{j \in \mathbb{N}} f\_j(C\_i)$ for $i \in \mathbb{N}^+$.
Case 1: $C\_1 \subseteq B$
Obviously $C\_{i+1} \subseteq C\_{i}$ for all $i \geq 1$. On the other hand, $|C\_i| \geq 1$ for every $i$ by the definition of a function. So ... | I'll add another answer using another approach. Let $B\subset A$ and $\mathcal{F}$ a family functions where $f\in \mathcal{F}$ means there exists $n\in \mathbb{N}$ such that $f:A^n \to A$.
A set $C$ is said to be $(A, B, \mathcal{F})$-inductive if
\begin{align\*}
&B \subset C\\
&\text{and}\\
&\forall f \in \mathcal{F... |
9,449,627 | I have two URLs:
<http://s140452.gridserver.com/view-pullsheet/>
<https://s140452.gridserver.com/locations/>
When browsing through any properties on the locations page (as well as any single property, filtering properties using the sidebar, adding and removing properties from the "pullsheet") the jcart.js script wor... | 2012/02/26 | [
"https://Stackoverflow.com/questions/9449627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/220761/"
] | because you are running into the same origin problem. https vs http
```
var path = 'https://s140452.gridserver.com/wp-content/themes/re/assets/functions/jcart',
```
to
```
var path = '//s140452.gridserver.com/wp-content/themes/re/assets/functions/jcart',
``` | With your error function you are assuming that the error can only be the incorrect path. Why not implement the function as `error(jqXHR, textStatus, errorThrown)` (see [ajax](http://api.jquery.com/jQuery.ajax/)), put a breakpoint in that function and then find out the true error. |
39,679,005 | I recently wrote some code in java that is supposed to send a string to a php script and it works perfectly fine. However it refuses to work when i use it in an android program. thought someone could help me find out what the problem is!
>
>
> ```
> public static String main(String x, String y){
> if (android.os... | 2016/09/24 | [
"https://Stackoverflow.com/questions/39679005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6858507/"
] | Make sure your `else` block executes. | That's a VERY bad practice - use Retrofit library for consuming REST apis instead. <http://www.vogella.com/tutorials/Retrofit/article.html> |
44,403,562 | I have tried Googling this question but no luck. Probably because I'm asking the wrong way. Any help is much appreciated.
I have variables `copy1`, `copy2`, etc. I want to iterate through them and select each one to check if it's contents has a certain number of characters. When I use any variation of the below, it wi... | 2017/06/07 | [
"https://Stackoverflow.com/questions/44403562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2067987/"
] | Agree with @jaromanda-x:
```
var copy1 = document.getElementById('copy1');
var copy2 = document.getElementById('copy2');
var copy3 = document.getElementById('copy3');
for (var i=1; i<4; i++) {
console.log(window['copy'+i]);
};
```
Or you can use more simple example, like:
```
for (var i=1; i<4; i++) {
var na... | You can store the properties in an object where values are set to the `DOM` element
```
let copies = {
1 : document.getElementById('copy1'),
2 : document.getElementById('copy2'),
3 : document.getElementById('copy3')
}
for (let [key, prop] of Object.entries(copies)) {
console.log(key, prop)
}
console.log(copies[... |
44,403,562 | I have tried Googling this question but no luck. Probably because I'm asking the wrong way. Any help is much appreciated.
I have variables `copy1`, `copy2`, etc. I want to iterate through them and select each one to check if it's contents has a certain number of characters. When I use any variation of the below, it wi... | 2017/06/07 | [
"https://Stackoverflow.com/questions/44403562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2067987/"
] | Agree with @jaromanda-x:
```
var copy1 = document.getElementById('copy1');
var copy2 = document.getElementById('copy2');
var copy3 = document.getElementById('copy3');
for (var i=1; i<4; i++) {
console.log(window['copy'+i]);
};
```
Or you can use more simple example, like:
```
for (var i=1; i<4; i++) {
var na... | Since nobody has addressed your "certain number of characters" requirement yet, I thought I would.
You could always use jQuery or write your own $ method, which works as a document.getElementById() wrapper function.
Here is a [jsfiddle](https://jsfiddle.net/fza0n701/) to see it in action.
**HTML**
```
<div id="copy... |
17,984,686 | Using `Backbone.Marionette`, I would like to render a collection of items along with a header.
I'm aware that `Marionette.CollectionView` does not have a template, as it only renders `ItemView`s.
I'm currently using `Marionette.LayoutView`, but have to define an extra DOM element for the 'list' region.
Is there any ... | 2013/08/01 | [
"https://Stackoverflow.com/questions/17984686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243673/"
] | <https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.compositeview.md>
Applied for you :
Templates
```
<script id="list-item" type="text/html">
<%= name %>
</script>
<script id="list-layout" type="text/html">
<div class='collection'>
<h3><%= name %></h3>
<ul></ul>... | I believe the solution above will render the li element directly under the containing div or other region specified, unless you also specify
```
tagName: "ul"
```
Then it renders the li elements within a ul element within the specified region. |
17,984,686 | Using `Backbone.Marionette`, I would like to render a collection of items along with a header.
I'm aware that `Marionette.CollectionView` does not have a template, as it only renders `ItemView`s.
I'm currently using `Marionette.LayoutView`, but have to define an extra DOM element for the 'list' region.
Is there any ... | 2013/08/01 | [
"https://Stackoverflow.com/questions/17984686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243673/"
] | <https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.compositeview.md>
Applied for you :
Templates
```
<script id="list-item" type="text/html">
<%= name %>
</script>
<script id="list-layout" type="text/html">
<div class='collection'>
<h3><%= name %></h3>
<ul></ul>... | Marionette 3 doesn't use `CompositeView` any more, so if we want to get something like this:
```
<div class='collection'>
<h3>List Name</h3>
<ul>
<li>FOO - BAR</li>
<li>FOO - BAR</li>
<li>FOO - BAR</li>
...
</ul>
</div>
```
We have to use `CollectionView` & `View` with regions.
1 - Templates
==... |
17,984,686 | Using `Backbone.Marionette`, I would like to render a collection of items along with a header.
I'm aware that `Marionette.CollectionView` does not have a template, as it only renders `ItemView`s.
I'm currently using `Marionette.LayoutView`, but have to define an extra DOM element for the 'list' region.
Is there any ... | 2013/08/01 | [
"https://Stackoverflow.com/questions/17984686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243673/"
] | Marionette 3 doesn't use `CompositeView` any more, so if we want to get something like this:
```
<div class='collection'>
<h3>List Name</h3>
<ul>
<li>FOO - BAR</li>
<li>FOO - BAR</li>
<li>FOO - BAR</li>
...
</ul>
</div>
```
We have to use `CollectionView` & `View` with regions.
1 - Templates
==... | I believe the solution above will render the li element directly under the containing div or other region specified, unless you also specify
```
tagName: "ul"
```
Then it renders the li elements within a ul element within the specified region. |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | In windows 10, you must add NMAKE to your path
[](https://i.stack.imgur.com/ry2l8.png)
After that you can run mix deps.compile until see message like this:
[](https://i.stack.imgur.co... | I found that, running on Windows, it was the latest version of erlang OTP, version 21,
that was causing the problem. I uninstalled this version and went for version 20 (which installs erlang 9.3 and latest version of Elixir then looks for this version when being compiled) and then bcrypt\_elixir compiled al |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | I faced same problem during distillery setup with my elixir project.
Installing package resolve issue as shown below.
I found bcrypt\_elixir need to install make and build-essential from Elixir Forum.
**platform:- ubuntu**
$ sudo apt install make
$ sudo apt-get install build-essential | Actually looking at this a bit closer, since you're running Cygwin and trying to build bcrypt under Cygwin, `nmake` doesn't even enter into the question. You need to install `make` into Cygwin. Re-run the cygwin installer, select the `Devel` category and then under Devel look for make.
EDIT:
-----
Ok, so if I had to... |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | For Visual Studio 2019 (VS2019) :
```
cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
``` | bcrypt\_elixir uses Windows' NMake (cf. bcrypt\_elixir's [**`Makefile.win`**](https://github.com/riverrun/bcrypt_elixir/blob/master/Makefile.win)).
**It seems like you don't have NMake installed.**
From [**NMake's documentation**](https://msdn.microsoft.com/en-us/library/dd9y37ha.aspx):
>
> NMAKE is included when y... |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | Actually looking at this a bit closer, since you're running Cygwin and trying to build bcrypt under Cygwin, `nmake` doesn't even enter into the question. You need to install `make` into Cygwin. Re-run the cygwin installer, select the `Devel` category and then under Devel look for make.
EDIT:
-----
Ok, so if I had to... | This answer is for anyone running elixir *directly on Windows*, and using VS Code with the ElixirLS extension. These instructions should work for other Visual Studio versions besides 2022, just change the path to vcvars64.bat.
1. Install Visual Studio 2022.
2. Use the Visual Studio Installer to install the optional `D... |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | I found that, running on Windows, it was the latest version of erlang OTP, version 21,
that was causing the problem. I uninstalled this version and went for version 20 (which installs erlang 9.3 and latest version of Elixir then looks for this version when being compiled) and then bcrypt\_elixir compiled al | This answer is for anyone running elixir *directly on Windows*, and using VS Code with the ElixirLS extension. These instructions should work for other Visual Studio versions besides 2022, just change the path to vcvars64.bat.
1. Install Visual Studio 2022.
2. Use the Visual Studio Installer to install the optional `D... |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | For Visual Studio 2019 (VS2019) :
```
cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
``` | I found that, running on Windows, it was the latest version of erlang OTP, version 21,
that was causing the problem. I uninstalled this version and went for version 20 (which installs erlang 9.3 and latest version of Elixir then looks for this version when being compiled) and then bcrypt\_elixir compiled al |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | I faced same problem during distillery setup with my elixir project.
Installing package resolve issue as shown below.
I found bcrypt\_elixir need to install make and build-essential from Elixir Forum.
**platform:- ubuntu**
$ sudo apt install make
$ sudo apt-get install build-essential | I found that, running on Windows, it was the latest version of erlang OTP, version 21,
that was causing the problem. I uninstalled this version and went for version 20 (which installs erlang 9.3 and latest version of Elixir then looks for this version when being compiled) and then bcrypt\_elixir compiled al |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | I faced same problem during distillery setup with my elixir project.
Installing package resolve issue as shown below.
I found bcrypt\_elixir need to install make and build-essential from Elixir Forum.
**platform:- ubuntu**
$ sudo apt install make
$ sudo apt-get install build-essential | bcrypt\_elixir uses Windows' NMake (cf. bcrypt\_elixir's [**`Makefile.win`**](https://github.com/riverrun/bcrypt_elixir/blob/master/Makefile.win)).
**It seems like you don't have NMake installed.**
From [**NMake's documentation**](https://msdn.microsoft.com/en-us/library/dd9y37ha.aspx):
>
> NMAKE is included when y... |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | For Visual Studio 2019 (VS2019) :
```
cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
``` | This answer is for anyone running elixir *directly on Windows*, and using VS Code with the ElixirLS extension. These instructions should work for other Visual Studio versions besides 2022, just change the path to vcvars64.bat.
1. Install Visual Studio 2022.
2. Use the Visual Studio Installer to install the optional `D... |
49,471,198 | I'm on Windows and I am trying to install the bcrypt\_elixir module.
I get the following error:
```
$ mix phx.server
==> bcrypt_elixir
could not compile dependency :bcrypt_elixir, "mix compile" failed. You can recompile this dependency with "mix deps.compile bcrypt_elixir", update it with "mix deps.update bcrypt_elix... | 2018/03/24 | [
"https://Stackoverflow.com/questions/49471198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152980/"
] | I faced same problem during distillery setup with my elixir project.
Installing package resolve issue as shown below.
I found bcrypt\_elixir need to install make and build-essential from Elixir Forum.
**platform:- ubuntu**
$ sudo apt install make
$ sudo apt-get install build-essential | For Visual Studio 2019 (VS2019) :
```
cmd /K "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
``` |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | You can always manually delete the packages; you can run:
```
sudo rm -rf /usr/local/lib/python2.7/dist-packages/twitter
```
to remove that package from your `dist-packages` directory. You may have to edit the `easy-install.pth` file in the same directory and remove the `twitter` entry from it. | While Martin's solution works, as a work around, it does not provide a direct answer.
Ubuntu's pip version for your Ubuntu version (12.04) is:
```
python-pip (1.0-1build1)
```
This is also the same version for Debian Wheezy. This version has a weired bug, which causes packages not to be removed.
If you obtain p... |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | You can always manually delete the packages; you can run:
```
sudo rm -rf /usr/local/lib/python2.7/dist-packages/twitter
```
to remove that package from your `dist-packages` directory. You may have to edit the `easy-install.pth` file in the same directory and remove the `twitter` entry from it. | I was facing difficulty while upgrading a package because pip was not able to uninstall it successfully. I had to delete the .egg-info and the folder as well in /usr/lib/python2.7/dist-packages and then I tried to install with --upgrade and it worked. |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | You can always manually delete the packages; you can run:
```
sudo rm -rf /usr/local/lib/python2.7/dist-packages/twitter
```
to remove that package from your `dist-packages` directory. You may have to edit the `easy-install.pth` file in the same directory and remove the `twitter` entry from it. | In my case (moving pyusb 0.4x to 1.0x), removing the old package with apt-get remove python-usb and manually installing the manually downloaded package via python setup.py worked. Not pretty, but working. |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | You can always manually delete the packages; you can run:
```
sudo rm -rf /usr/local/lib/python2.7/dist-packages/twitter
```
to remove that package from your `dist-packages` directory. You may have to edit the `easy-install.pth` file in the same directory and remove the `twitter` entry from it. | For me, it was due to the fact that I was running `pip freeze`, which gave me different results than `sudo pip freeze`.
Since I was uninstalling using `sudo`, it was not uninstalling it in the "non-`sudo`" session. Uninstalling without `sudo` fixed that. |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | While Martin's solution works, as a work around, it does not provide a direct answer.
Ubuntu's pip version for your Ubuntu version (12.04) is:
```
python-pip (1.0-1build1)
```
This is also the same version for Debian Wheezy. This version has a weired bug, which causes packages not to be removed.
If you obtain p... | I was facing difficulty while upgrading a package because pip was not able to uninstall it successfully. I had to delete the .egg-info and the folder as well in /usr/lib/python2.7/dist-packages and then I tried to install with --upgrade and it worked. |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | While Martin's solution works, as a work around, it does not provide a direct answer.
Ubuntu's pip version for your Ubuntu version (12.04) is:
```
python-pip (1.0-1build1)
```
This is also the same version for Debian Wheezy. This version has a weired bug, which causes packages not to be removed.
If you obtain p... | In my case (moving pyusb 0.4x to 1.0x), removing the old package with apt-get remove python-usb and manually installing the manually downloaded package via python setup.py worked. Not pretty, but working. |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | While Martin's solution works, as a work around, it does not provide a direct answer.
Ubuntu's pip version for your Ubuntu version (12.04) is:
```
python-pip (1.0-1build1)
```
This is also the same version for Debian Wheezy. This version has a weired bug, which causes packages not to be removed.
If you obtain p... | For me, it was due to the fact that I was running `pip freeze`, which gave me different results than `sudo pip freeze`.
Since I was uninstalling using `sudo`, it was not uninstalling it in the "non-`sudo`" session. Uninstalling without `sudo` fixed that. |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | I was facing difficulty while upgrading a package because pip was not able to uninstall it successfully. I had to delete the .egg-info and the folder as well in /usr/lib/python2.7/dist-packages and then I tried to install with --upgrade and it worked. | In my case (moving pyusb 0.4x to 1.0x), removing the old package with apt-get remove python-usb and manually installing the manually downloaded package via python setup.py worked. Not pretty, but working. |
14,572,773 | **Background**
I'm working on an academic project to (basically) analyze some "who follows whom" graphs and wanted to get some real data (by building some small datasets) from Twitter using one of the Python Twitter API packages in order to test some ideas I have.
I was a bit careless and installed two packages:
a) ... | 2013/01/28 | [
"https://Stackoverflow.com/questions/14572773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019798/"
] | For me, it was due to the fact that I was running `pip freeze`, which gave me different results than `sudo pip freeze`.
Since I was uninstalling using `sudo`, it was not uninstalling it in the "non-`sudo`" session. Uninstalling without `sudo` fixed that. | In my case (moving pyusb 0.4x to 1.0x), removing the old package with apt-get remove python-usb and manually installing the manually downloaded package via python setup.py worked. Not pretty, but working. |
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | ```
if (testNum == 0);
else if (testNum % 2 == 0);
else if ((testNum % 2) != 0 );
``` | ```
function isEven(n) {return parseInt(n)%2===0?true:parseInt(n)===0?true:false}
```
when 0/even wanted but
```
isEven(0) //true
isEven(1) //false
isEven(2) //true
isEven(142856) //true
isEven(142856.142857)//true
isEven(142857.1457)//false
```
|
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | Use modulus:
```
function isEven(n) {
return n % 2 == 0;
}
function isOdd(n) {
return Math.abs(n % 2) == 1;
}
```
You can check that any value in Javascript can be coerced to a number with:
```
Number.isFinite(parseFloat(n))
```
This check should preferably be done outside the `isEven` and `isOdd` function... | Why not just do this:
```
function oddOrEven(num){
if(num % 2 == 0)
return "even";
return "odd";
}
oddOrEven(num);
``` |
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | ```js
var isOdd = x => Boolean(x % 2);
var isEven = x => !isOdd(x);
``` | Otherway using strings because why not
```
function isEven(__num){
return String(__num/2).indexOf('.') === -1;
}
``` |
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | A simple modification/improvement of Steve Mayne answer!
```
function isEvenOrOdd(n){
if(n === parseFloat(n)){
return isNumber(n) && (n % 2 == 0);
}
return false;
}
```
Note: Returns false if invalid! | ```
var num = someNumber
isEven;
parseInt(num/2) === num/2 ? isEven = true : isEven = false;
``` |
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | We just need one line of code for this!
Here a newer and alternative way to do this, using the new [ES6](https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Functions/Arrow_functions) syntax for JS functions, and the [one-line syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Oper... | ```
function isEven(n) {return parseInt(n)%2===0?true:parseInt(n)===0?true:false}
```
when 0/even wanted but
```
isEven(0) //true
isEven(1) //false
isEven(2) //true
isEven(142856) //true
isEven(142856.142857)//true
isEven(142857.1457)//false
```
|
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | I prefer using a bit test:
```
if(i & 1)
{
// ODD
}
else
{
// EVEN
}
```
This tests whether the first bit is on which signifies an odd number. | ```
var num = someNumber
isEven;
parseInt(num/2) === num/2 ? isEven = true : isEven = false;
``` |
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | ```
var isEven = function(number) {
// Your code goes here!
if (number % 2 == 0){
return(true);
}
else{
return(false);
}
};
``` | ```
if (i % 2) {
return odd numbers
}
if (i % 2 - 1) {
return even numbers
}
``` |
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | Maybe this?
if(ourNumber % 2 !== 0) | ```
function isEven(n) {return parseInt(n)%2===0?true:parseInt(n)===0?true:false}
```
when 0/even wanted but
```
isEven(0) //true
isEven(1) //false
isEven(2) //true
isEven(142856) //true
isEven(142856.142857)//true
isEven(142857.1457)//false
```
|
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | A few
```
x % 2 == 0; // Check if even
!(x & 1); // bitmask the value with 1 then invert.
((x >> 1) << 1) == x; // divide value by 2 then multiply again and check against original value
~x&1; // flip the bits and bitmask
``` | ```
if (testNum == 0);
else if (testNum % 2 == 0);
else if ((testNum % 2) != 0 );
``` |
6,211,613 | I decided to create simple *isEven* and *isOdd* function with a very simple algorithm:
```
function isEven(n) {
n = Number(n);
return n === 0 || !!(n && !(n%2));
}
function isOdd(n) {
return isEven(Number(n) + 1);
}
```
That is OK if n is with certain parameters, but fails for many scenarios. So I set out to ... | 2011/06/02 | [
"https://Stackoverflow.com/questions/6211613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257182/"
] | We just need one line of code for this!
Here a newer and alternative way to do this, using the new [ES6](https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Functions/Arrow_functions) syntax for JS functions, and the [one-line syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Oper... | ```js
for(var a=0; a<=20;a++){
if(a%2!==0){
console.log("Odd number "+a);
}
}
for(var b=0; b<=20;a++){
if(b%2===0){
console.log("Even number "+b);
}
}
``` |
29,344,335 | I am writing a game engine, in which a set of objects held in a `ArrayList` are iterated over using a for loop. Obviously, efficiency is rather important, and so I was wondering about the efficiency of the loop.
```
for (String extension : assetLoader.getSupportedExtensions()) {
// do stuff with the extension here... | 2015/03/30 | [
"https://Stackoverflow.com/questions/29344335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3025267/"
] | By specification, the idiom
```
for (String extension : assetLoader.getSupportedExtensions()) {
...
}
```
expands into
```
for (Iterator<String> it = assetLoader.getSupportedExtensions().iterator(); it.hasNext();)
{
String extension = it.next();
...
}
```
Therefore the call you ask about occurs only onc... | No, the method `assetLoader.getSupportedExtensions()` is called only once before the first iteration of the loop, and is used to create an `Iterator<String>` used by the enhanced for loop.
The two snippets will have the same performance. |
29,344,335 | I am writing a game engine, in which a set of objects held in a `ArrayList` are iterated over using a for loop. Obviously, efficiency is rather important, and so I was wondering about the efficiency of the loop.
```
for (String extension : assetLoader.getSupportedExtensions()) {
// do stuff with the extension here... | 2015/03/30 | [
"https://Stackoverflow.com/questions/29344335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3025267/"
] | No, the method `assetLoader.getSupportedExtensions()` is called only once before the first iteration of the loop, and is used to create an `Iterator<String>` used by the enhanced for loop.
The two snippets will have the same performance. | 1. Direct cost.
Since, as people said before, the following
```
for (String extension : assetLoader.getSupportedExtensions()) {
//stuff
}
```
transforms into
```
for (Iterator<String> it = assetLoader.getSupportedExtensions().iterator(); it.hasNext();) {
String extension = it.next();
//stuf
}
```
getS... |
29,344,335 | I am writing a game engine, in which a set of objects held in a `ArrayList` are iterated over using a for loop. Obviously, efficiency is rather important, and so I was wondering about the efficiency of the loop.
```
for (String extension : assetLoader.getSupportedExtensions()) {
// do stuff with the extension here... | 2015/03/30 | [
"https://Stackoverflow.com/questions/29344335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3025267/"
] | By specification, the idiom
```
for (String extension : assetLoader.getSupportedExtensions()) {
...
}
```
expands into
```
for (Iterator<String> it = assetLoader.getSupportedExtensions().iterator(); it.hasNext();)
{
String extension = it.next();
...
}
```
Therefore the call you ask about occurs only onc... | 1. Direct cost.
Since, as people said before, the following
```
for (String extension : assetLoader.getSupportedExtensions()) {
//stuff
}
```
transforms into
```
for (Iterator<String> it = assetLoader.getSupportedExtensions().iterator(); it.hasNext();) {
String extension = it.next();
//stuf
}
```
getS... |
19,909,467 | I have a few div elements on the page, each has its own border.
The problem is that the lower div border ("#a") is visible although other elements ("#b", "c#") are on top of it.
see the following JS fiddle for example and code: <http://jsfiddle.net/4jntf/>
HTML:
```
<div id="container">
<div id="a"></div>
<d... | 2013/11/11 | [
"https://Stackoverflow.com/questions/19909467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1117735/"
] | The compiler turns each source file into machine code (aka object code), but doesn't create an executable program.
The linker links together one or more object files to make an executable program.
The debugger allows you to examine the program while it's running, to help investigate why it doesn't work. | [Compiler, Assembler, Linker and Loader: A Brief Story](http://www.tenouk.com/ModuleW.html)
Whereas, [Debugger](http://en.wikipedia.org/wiki/Debugger) is a different beast compared to the above.
A lot of information is already available on this topic. Just use your favorite search engine :) |
19,909,467 | I have a few div elements on the page, each has its own border.
The problem is that the lower div border ("#a") is visible although other elements ("#b", "c#") are on top of it.
see the following JS fiddle for example and code: <http://jsfiddle.net/4jntf/>
HTML:
```
<div id="container">
<div id="a"></div>
<d... | 2013/11/11 | [
"https://Stackoverflow.com/questions/19909467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1117735/"
] | The compiler turns each source file into machine code (aka object code), but doesn't create an executable program.
The linker links together one or more object files to make an executable program.
The debugger allows you to examine the program while it's running, to help investigate why it doesn't work. | Very roughly, the compiler converts from human-readable source code into (almost) machine-runnable object code, and the linker joins up all the different sections of object code (and external libraries) to form a complete program.
The debugger is totally separate. It lets the programmer analyse what's happening when t... |
49,937,863 | >
> error
> .Uncaught SyntaxError: Invalid shorthand property initializer angular.js:38 Uncaught Error: [$injector:modulerr] <http://errors.angularjs.org/1.4.5/>$injector/modul
>
>
>
This is my **app.js** code:
```
var myApp = angular.module("myapp", ["ngRoute"]);
myApp.controller("myController", function($scop... | 2018/04/20 | [
"https://Stackoverflow.com/questions/49937863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7336130/"
] | Fix `ng-app="myApp"` to `ng-app="myapp"` in html file. [check this plunkr](https://plnkr.co/edit/DUqZ7xwhOwydfkxtjMT8?p=preview)
```
var myApp = angular.module("myApp", []);
myApp.controller("myController", function($scope){
console.log("This is app.js ...........");
$scope.users = [
{username: "John" , email:"j... | That's not the way to declare an object. Replace = with :
```
$scope.users = [
{username:"Shanto" , email:"shanto@gmail.com"},
{username : "Adam" , email : "Adam@adam.com"}
];
``` |
28,080,911 | New to the site as well as c#. This is my first time using c# and I can't get my objects to print properly. (example Million, Max 55. Cardenas, Jose, 22). I am pretty sure the error is in my accessors but I can't seem to get it right.
```
using System.IO;
using System;
class PersonApp
{
static void Main()... | 2015/01/22 | [
"https://Stackoverflow.com/questions/28080911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4480881/"
] | You need to access property of the method to get the values printed
Wrong code :
```
Console.WriteLine(p1,p2); // You are trying to print Objects and this is wrong. !!
```
Correction : Use accessory's get to print the output.
```
Console.WriteLine(p1.Fname); // Print first name "Max"
```
Likewise
```
... | You can't expect C# to know the format you want the object output in. You have to concatenate the strings yourself to produce the output.
The neatest way to do this is expose a readonly property on `Person` that formats it how you want, something like this:
```
public string DisplayName {
get {
return Lna... |
28,080,911 | New to the site as well as c#. This is my first time using c# and I can't get my objects to print properly. (example Million, Max 55. Cardenas, Jose, 22). I am pretty sure the error is in my accessors but I can't seem to get it right.
```
using System.IO;
using System;
class PersonApp
{
static void Main()... | 2015/01/22 | [
"https://Stackoverflow.com/questions/28080911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4480881/"
] | You have a few issues in your code.
First, you can't pass multiple values to `Console.WriteLine` like this:
```
Console.WriteLine(p1, p2);
```
Do one at a time:
```
Console.WriteLine(p1);
Console.WriteLine(p2);
```
Second, you can't name your private backing field and the public property used to get/set it the s... | You can't expect C# to know the format you want the object output in. You have to concatenate the strings yourself to produce the output.
The neatest way to do this is expose a readonly property on `Person` that formats it how you want, something like this:
```
public string DisplayName {
get {
return Lna... |
211,740 | We know that $$\oint \boldsymbol{F}\cdot d\boldsymbol{r}= \iint (\nabla \times \boldsymbol{F})\cdot d\boldsymbol{s}.$$ Now if $\boldsymbol{F}$ is a constant vector, then $\nabla \times \boldsymbol{F}=0$, this gives that $\oint \boldsymbol{F}\cdot d\boldsymbol{r}=0$. And $\oint \boldsymbol{F} \cdot d\boldsymbol{r}$ repr... | 2015/10/10 | [
"https://physics.stackexchange.com/questions/211740",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/94972/"
] | This isn't surprising. Remember, $\oint$ means that you're integrating around a closed path. Without that requirement you can't use Stokes's Theorem to get a curl. All you've shown is that a constant vector does no work if you go in a big loop. This is the situation with, for instance, gravity close to Earth's surface.... | It is possible for conservative forces. Closed integral of a conservative force (say Electric force) is zero.[](https://i.stack.imgur.com/22KrX.png) |
211,740 | We know that $$\oint \boldsymbol{F}\cdot d\boldsymbol{r}= \iint (\nabla \times \boldsymbol{F})\cdot d\boldsymbol{s}.$$ Now if $\boldsymbol{F}$ is a constant vector, then $\nabla \times \boldsymbol{F}=0$, this gives that $\oint \boldsymbol{F}\cdot d\boldsymbol{r}=0$. And $\oint \boldsymbol{F} \cdot d\boldsymbol{r}$ repr... | 2015/10/10 | [
"https://physics.stackexchange.com/questions/211740",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/94972/"
] | It's perfectly possible, because it's not just any work; it's the work done around a closed curve. If you have a uniform force field (which is a special case of a conservative force field) and you move an object around in a closed curve you won't get any **net** work out of the force field. A good example is gravity cl... | It is possible for conservative forces. Closed integral of a conservative force (say Electric force) is zero.[](https://i.stack.imgur.com/22KrX.png) |
23,594,867 | I have a JTextArea in which i want to display messages aligned to right or left, depending on a variable I pass along with the message. Can I do that?
---
What did I do wrong? Nothing gers added to the text pane when i run my GUI
```
battleLog = new JTextPane();
StyledDocument bL = battleLog.getStyledDocument();... | 2014/05/11 | [
"https://Stackoverflow.com/questions/23594867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3450315/"
] | Not with a JTextArea.
You need to use a `JTextPane` which supports different text and paragraph attributes. An example to CENTER the text:
```
JTextPane textPane = new JTextPane();
textPane.setText("Line1");
StyledDocument doc = textPane.getStyledDocument();
// Define the attribute you want for the line of text
Si... | ```
if("left".equals(input)){
setAlignmentX(Component.LEFT_ALIGNMENT);
}
```
Have a try! |
370,781 | I have a custom post type called products, which I have attached a custom taxonomy called Product Categories.
On each of the Product Categories, I have used Advanced Custom Fields to add fields such as product category colour, logo etc.
Initially, I'm trying to display the Product Category colour as a background colo... | 2020/07/10 | [
"https://wordpress.stackexchange.com/questions/370781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112099/"
] | I would try something like this...
```php
// Assume there is only one category.
$product_category = get_the_terms($post, 'product-category')[0];
$cat_fields = get_fields("term_$product_category");
$color = $cat_fields['category_colour_primary'];
```
You could also do this...
```php
// Assume there is only one cat... | Managed to get it working with the following code:
```
<?php
$terms = wp_get_object_terms($post->ID, 'product_category');
if(!empty($terms)){
foreach($terms as $term){
$exampleName = $term->name;
$exampleSlugs[] = $term->slug;
$category_colour_primary = get_field('category_colour_primary', $term);
$... |
11,782,812 | I'm sorry, for I'm sure there's a way to do this with a viewModel, however I'm very inexperienced with this and don't even know if I'm doing it correctly.
What I'm trying to do is pass multiple blogs and the profile info of the user who posted each blog to a view.
I'm getting the following error.
>
> The model item... | 2012/08/02 | [
"https://Stackoverflow.com/questions/11782812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1196221/"
] | I guess you need to change your view model a little to:
```
public class BlogViewModel
{
public Blog Blog { get; set; }
public Profile Profile{ get; set; }
}
```
and then return it as follow:
```
var results = (from r in db.Blog.AsEnumerable()
join a in db.Profile on r.AccountID equal... | I'm not entirely sure what you're trying to accomplish with the ViewModel in this case, but it seems like you are expecting for the page to represent a single blog with a collection of comments. In this case you should replace
```
IEnumerable<ACapture.Models.ViewModels.BlogViewModel>
```
With
```
ACapture.Models.V... |
7,489 | We try to add the invoice status column to the sales order grid.
We added the code beneath to the prepareCollection function:
```
$collection->getSelect()->join('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.parent_id',array('state'));
```
And the code beneath to the prepareColumns function:
```
... | 2013/09/03 | [
"https://magento.stackexchange.com/questions/7489",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/2289/"
] | Firstly - **be careful with joining live tables on your sales\_order\_grid** in the admin view. The reason is simple - any action or long-running query that your admins might be executing (for instance, sorting by a custom unindexed column with no other filters and 300k+ orders) may cause locks for your join table and ... | Replace `sales_flat_invoice.parent_id` with `sales_flat_invoice.order_id`. Not sure if it will give you the desired result, but you won't get the error anymore. The reference to the order table is kept in `order_id`. `parent_id` does not exist. |
7,489 | We try to add the invoice status column to the sales order grid.
We added the code beneath to the prepareCollection function:
```
$collection->getSelect()->join('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.parent_id',array('state'));
```
And the code beneath to the prepareColumns function:
```
... | 2013/09/03 | [
"https://magento.stackexchange.com/questions/7489",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/2289/"
] | Replace `sales_flat_invoice.parent_id` with `sales_flat_invoice.order_id`. Not sure if it will give you the desired result, but you won't get the error anymore. The reference to the order table is kept in `order_id`. `parent_id` does not exist. | If you want to add the invoice id in the sales order grid then you can use the following code in your prepareCollection() function as
```
$collection->getSelect()->joinLeft('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.order_id', 'increment_id as invoice_id');
```
By using the following code you ... |
7,489 | We try to add the invoice status column to the sales order grid.
We added the code beneath to the prepareCollection function:
```
$collection->getSelect()->join('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.parent_id',array('state'));
```
And the code beneath to the prepareColumns function:
```
... | 2013/09/03 | [
"https://magento.stackexchange.com/questions/7489",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/2289/"
] | Replace `sales_flat_invoice.parent_id` with `sales_flat_invoice.order_id`. Not sure if it will give you the desired result, but you won't get the error anymore. The reference to the order table is kept in `order_id`. `parent_id` does not exist. | ```
$collection->getSelect()->joinLeft(array('soa'=> 'sales_flat_invoice'), 'soa.entity_id = main_table.entity_id', array('soa.state'));
$this->addColumn('state', array(
'header' => Mage::helper('sales')->__('invoice Status'),
'index' => 'state',
'type' => 'options',
'filter... |
7,489 | We try to add the invoice status column to the sales order grid.
We added the code beneath to the prepareCollection function:
```
$collection->getSelect()->join('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.parent_id',array('state'));
```
And the code beneath to the prepareColumns function:
```
... | 2013/09/03 | [
"https://magento.stackexchange.com/questions/7489",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/2289/"
] | Firstly - **be careful with joining live tables on your sales\_order\_grid** in the admin view. The reason is simple - any action or long-running query that your admins might be executing (for instance, sorting by a custom unindexed column with no other filters and 300k+ orders) may cause locks for your join table and ... | If you want to add the invoice id in the sales order grid then you can use the following code in your prepareCollection() function as
```
$collection->getSelect()->joinLeft('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.order_id', 'increment_id as invoice_id');
```
By using the following code you ... |
7,489 | We try to add the invoice status column to the sales order grid.
We added the code beneath to the prepareCollection function:
```
$collection->getSelect()->join('sales_flat_invoice', 'main_table.entity_id = sales_flat_invoice.parent_id',array('state'));
```
And the code beneath to the prepareColumns function:
```
... | 2013/09/03 | [
"https://magento.stackexchange.com/questions/7489",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/2289/"
] | Firstly - **be careful with joining live tables on your sales\_order\_grid** in the admin view. The reason is simple - any action or long-running query that your admins might be executing (for instance, sorting by a custom unindexed column with no other filters and 300k+ orders) may cause locks for your join table and ... | ```
$collection->getSelect()->joinLeft(array('soa'=> 'sales_flat_invoice'), 'soa.entity_id = main_table.entity_id', array('soa.state'));
$this->addColumn('state', array(
'header' => Mage::helper('sales')->__('invoice Status'),
'index' => 'state',
'type' => 'options',
'filter... |
11,420,894 | I cannot figure out which way it goes. It seems like casting it into an int would make more sense because of the whole float point issue but like I said, I am not sure. Does anyone know? | 2012/07/10 | [
"https://Stackoverflow.com/questions/11420894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1260028/"
] | Try this code:
```
#include <stdio.h>
int main(void)
{
if (100.1 == 100)
printf("Must be integer compare\n");
else
printf("Must be floating point compare\n");
return 0;
}
```
Also, think about things like `int i = 10; float j = 100.5 + i;` or `100.2 == 100`. You don't want it to be done ... | It's listed in 6.3.1.8 under "the usual arithmetic conversions".
>
> Otherwise, if the corresponding real type of either operand is double,
> the other operand is converted, without change of type domain,
> to a type whose corresponding real type is double
>
>
>
And 6.5.9 spells it for `==`:
>
> If both of the ... |
11,289,342 | When learning C I see that `printf` can receive many arguments as it is passed.
And I don't know how C can implement a function like this, where the user can type as many parameters as the user wants. I have thought about pointers, too but still have no bright idea. If anyone has any ideas about this type of function,... | 2012/07/02 | [
"https://Stackoverflow.com/questions/11289342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1192728/"
] | You need to use va\_args, va\_list and the like.
Have a look at this tutorial.
<http://www.cprogramming.com/tutorial/c/lesson17.html>
That should be helpful. | You have to use the `...` notation in your function declaration as the last argument.
Please see this tutorial to learn more: <http://www.cprogramming.com/tutorial/c/lesson17.html> |
11,289,342 | When learning C I see that `printf` can receive many arguments as it is passed.
And I don't know how C can implement a function like this, where the user can type as many parameters as the user wants. I have thought about pointers, too but still have no bright idea. If anyone has any ideas about this type of function,... | 2012/07/02 | [
"https://Stackoverflow.com/questions/11289342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1192728/"
] | You need to use va\_args, va\_list and the like.
Have a look at this tutorial.
<http://www.cprogramming.com/tutorial/c/lesson17.html>
That should be helpful. | You use C `varargs` to write a *variadic function*. You'll need to include `stdargs.h`, which gives you macros for iterating over an argument list of unknown size: `va_start`, `va_arg`, and `va_end`, using a datatype: `va_list`.
Here's a mostly useless function that prints out it's variable length argument list:
```
... |
11,289,342 | When learning C I see that `printf` can receive many arguments as it is passed.
And I don't know how C can implement a function like this, where the user can type as many parameters as the user wants. I have thought about pointers, too but still have no bright idea. If anyone has any ideas about this type of function,... | 2012/07/02 | [
"https://Stackoverflow.com/questions/11289342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1192728/"
] | You need to use va\_args, va\_list and the like.
Have a look at this tutorial.
<http://www.cprogramming.com/tutorial/c/lesson17.html>
That should be helpful. | ```
#include <stdarg.h>
#include <stdio.h>
int add_all(int num,...)
{
va_list args;
int sum = 0;
va_start(args,num);
int x = 0;
for(x = 0; x < num;x++)
sum += va_arg(args,int);
va_end(args);
return sum;
}
int main()
{
printf("Added 2 + 5 + 3: %d\n",add_all(3,2,5,3));
}
``` |
60,901,780 | So to provide context, my system is little endian and the file that I am reading from is big endian (MIDI format, for those that are interested). I am supposed to read a variety of data from the file, including unsigned integers (8 bit, 16 bit, and 32 bit), chars, and booleans.
So far I know that reading unsigned inte... | 2020/03/28 | [
"https://Stackoverflow.com/questions/60901780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I believe you have mistaken the `contractions` package available on [PyPI](https://pypi.org/project/contractions/) with the `contractions` module from a textbook called "Text Analytics with Python" ([source code](https://github.com/dipanjanS/text-analytics-with-python/tree/master/Old-First-Edition)).
The `CONTRACTIONS... | after you install contractions by pip install contractions, you can use contractions\_dict instead of CONTRACTION\_MAP |
603,469 | I recently downloaded Puppy Linux which is almost 280MB .iso file. I had a 4GB USB drive. So I fired up good old `dd` command to burn the iso to the live usb. Everything went well, however, after live boot, all I was left with was 4MB ish disk space in the USB. Then I formatted it, burned a Debian distro in the same US... | 2020/08/08 | [
"https://unix.stackexchange.com/questions/603469",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/387728/"
] | try:
```
sed "s/\$t\>/foo/g" /tmp/file
```
`\>` is a regular expression pattern match for the end of the word. | Tried with below sed and awk command
```
awk '{for(i=1;i<=NF;i++){if($i =="$t"){gsub(/\$t/,"foo",$i)}}}1' filename
```
sed command
```
sed "s/\$t /foo /g" filename
```
output
```
$one foo $three
$one foo $three foo $thre
```
e |
2,346,363 | Am wondering if there are any drawbacks of using Adobe Stratus. Since it is only P2P, when will there be a case where P2P can't be used? On the site it says something like when UDP packets are blocked. How often is that? Say a thousand people use the service, approximately what percentage would not be able to use it?
... | 2010/02/27 | [
"https://Stackoverflow.com/questions/2346363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426996/"
] | About half on average are not able to talk directly. Depending on service provider, organization if any, country, continent, weather, extraterrestrial presence etc :-) | I have been looking at this for a client who is developing a peer to peer video conferencing app.
In his experience about 10%+ of people out of a small group surveyed had UDP blocked, and therefore were unable to use Adobe Stratus to make connections and LTMFP |
2,346,363 | Am wondering if there are any drawbacks of using Adobe Stratus. Since it is only P2P, when will there be a case where P2P can't be used? On the site it says something like when UDP packets are blocked. How often is that? Say a thousand people use the service, approximately what percentage would not be able to use it?
... | 2010/02/27 | [
"https://Stackoverflow.com/questions/2346363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426996/"
] | with a pretty global audience, i had about 20% failing the initial test with cc.rtmfp.net . then a number of those who passed couldn't make direct connections to some users, although they could with others.
i wouldn't use stratus by itself for anything where reliability matters. use fms until red5 adds support for rt... | I have been looking at this for a client who is developing a peer to peer video conferencing app.
In his experience about 10%+ of people out of a small group surveyed had UDP blocked, and therefore were unable to use Adobe Stratus to make connections and LTMFP |
64,267,107 | My problem that is in a child component, I have a state that updated via post method and I must show this state in my parent component both these component are the class base component | 2020/10/08 | [
"https://Stackoverflow.com/questions/64267107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13935145/"
] | The ReactJS is a library with **One directional data binding**. So that is not possible to pass data like *Angular* or *VueJS*. you should pass a handler function to the child-component and then after the *Axios* answer update the local and also the parent component.
And there is a little hint here, there is no differ... | React's practice is one-directional. For best practice, you must 'Raise' the states into the parent component.
But if you were looking specifically to pass data up, you need to pass a callback down as a prop. use that callback function to pass the data up:
Parent:
```
<Parent>
<Child callback={console.log} />
</P... |
14,847,635 | I am using .NET framework 1.1 with C#. My problem description is given below.
1. I have server side textbox control with id:= *txtFromDate*. view state is enabled and its readonly.
2. when page loaded for the first time i am setting current date value in above textbox.
3. after that I change the value of textbox with ... | 2013/02/13 | [
"https://Stackoverflow.com/questions/14847635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046955/"
] | Instead of using **txtFromDate.Text** I used **Request.Form[txtFromDate.ClientID]** and problem got solved. | Although you can always use set get method to store the values from java script ... But here is some simple way to solve it...
case 1 - If control is just for storing purpose ,
put display : none in it's style and make visible = true in the attribute of the control.
case 2 - if control is to be displayed but in disab... |
14,847,635 | I am using .NET framework 1.1 with C#. My problem description is given below.
1. I have server side textbox control with id:= *txtFromDate*. view state is enabled and its readonly.
2. when page loaded for the first time i am setting current date value in above textbox.
3. after that I change the value of textbox with ... | 2013/02/13 | [
"https://Stackoverflow.com/questions/14847635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046955/"
] | Instead of using **txtFromDate.Text** I used **Request.Form[txtFromDate.ClientID]** and problem got solved. | ```
clientIDMode="Static"
```
will work perfectly. |
14,847,635 | I am using .NET framework 1.1 with C#. My problem description is given below.
1. I have server side textbox control with id:= *txtFromDate*. view state is enabled and its readonly.
2. when page loaded for the first time i am setting current date value in above textbox.
3. after that I change the value of textbox with ... | 2013/02/13 | [
"https://Stackoverflow.com/questions/14847635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046955/"
] | Instead of using **txtFromDate.Text** I used **Request.Form[txtFromDate.ClientID]** and problem got solved. | changes you make to the controls on client side are not accessible to the code behind at the server, unless those changes are made to the values of input controls.
so, youu can also use hiddenfield along with label which youu want to change in javascript/ Jquery then, store the new label value in hiddenfield as well
t... |
14,847,635 | I am using .NET framework 1.1 with C#. My problem description is given below.
1. I have server side textbox control with id:= *txtFromDate*. view state is enabled and its readonly.
2. when page loaded for the first time i am setting current date value in above textbox.
3. after that I change the value of textbox with ... | 2013/02/13 | [
"https://Stackoverflow.com/questions/14847635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046955/"
] | Instead of using **txtFromDate.Text** I used **Request.Form[txtFromDate.ClientID]** and problem got solved. | **Need to Keep in Mind**
1. If any Server Control Example: TextBox. is Disabled or ReadOnly from Aspx Page or Code behind.
2. It's value is being changed from JQuery or Javascipt.
3. You try to get the changed value of this control from code behind then you will never get it.
4. When you post back this control then se... |
14,847,635 | I am using .NET framework 1.1 with C#. My problem description is given below.
1. I have server side textbox control with id:= *txtFromDate*. view state is enabled and its readonly.
2. when page loaded for the first time i am setting current date value in above textbox.
3. after that I change the value of textbox with ... | 2013/02/13 | [
"https://Stackoverflow.com/questions/14847635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046955/"
] | changes you make to the controls on client side are not accessible to the code behind at the server, unless those changes are made to the values of input controls.
so, youu can also use hiddenfield along with label which youu want to change in javascript/ Jquery then, store the new label value in hiddenfield as well
t... | Although you can always use set get method to store the values from java script ... But here is some simple way to solve it...
case 1 - If control is just for storing purpose ,
put display : none in it's style and make visible = true in the attribute of the control.
case 2 - if control is to be displayed but in disab... |
14,847,635 | I am using .NET framework 1.1 with C#. My problem description is given below.
1. I have server side textbox control with id:= *txtFromDate*. view state is enabled and its readonly.
2. when page loaded for the first time i am setting current date value in above textbox.
3. after that I change the value of textbox with ... | 2013/02/13 | [
"https://Stackoverflow.com/questions/14847635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1046955/"
] | changes you make to the controls on client side are not accessible to the code behind at the server, unless those changes are made to the values of input controls.
so, youu can also use hiddenfield along with label which youu want to change in javascript/ Jquery then, store the new label value in hiddenfield as well
t... | ```
clientIDMode="Static"
```
will work perfectly. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.