qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
6,813,490 | I used multiple model from in rails, it fails to work properly in a sinario
```
<%= form_for [@listing] do |f| %>
<%= f.fields_for :photos do |ph| %>
<%= ph.file_field :data %>
<% end %>
<% end %>
```
while validation,i didn't upload a image(image is optional one) and submit the form. if the fi... | 2011/07/25 | [
"https://Stackoverflow.com/questions/6813490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/859428/"
] | Because you pass an array of unknown size which is equivalent to a pointer in this context. `sizeof` is calculated at **compile** time, not runtime. | Arrays as function arguments *do* decay to pointer, though. Since this happens before sizeof() is called, you can't prevent it.
Just think about it: how can sizeof() know the size of an array if any size array can be passed and no extra info is available? You get sizeof(pointer), and that seems to be the same size as... |
212,429 | Scenario:
I'm currently writing a layer to abstract 3 similar webservices into one useable class. Each webservice exposes a set of objects that share commonality. I have created a set of intermediary objects which exploit the commonality. However in my layer I need to convert between the web service objects and my obj... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4950/"
] | As others have said, the array has to be of the right type to start with. The other answers have shown how to convert a genuine object[] after the fact, but you can create the right kind of array to start with using [Array.CreateInstance](http://msdn.microsoft.com/en-us/library/system.array.createinstance.aspx):
```
o... | That's correct, but that doesn't mean that you can cast containers of type Object to containers of other types. An Object[] is not the same thing as an Object (though you, strangely, could cast Object[] to Object). |
483,259 | I'm searching for an adjective that is between rare and common - e.g. something that is everyday, or ordinary, or not remarkable.
Can anyone help suggest some words I might try?
Thank you, | 2019/01/29 | [
"https://english.stackexchange.com/questions/483259",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/10835/"
] | First of all, **common** *is* something everyday or ordinary.
However, if you want a word that's between *rare* and *common* on a frequency scale, I suggest [**occasional**](https://www.merriam-webster.com/dictionary/occasional):
>
> [Merriam-Webster]
>
>
> **3** : encountered, occurring, appearing, or taken at ir... | How about "uncommon"? Typically the word used in gaming circles. |
8,871,682 | I have a string say `123dance456` which I need to split into two strings containing the first sub-string before the sub-string `dance` (i.e. `123`) and after the sub-string `dance` (i.e. `456`). I need to find them and hold them in separate string variables, say `String firstSubString = 123;` and String `secondSubStrin... | 2012/01/15 | [
"https://Stackoverflow.com/questions/8871682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/411449/"
] | Easiest is to use the `split` method as the other answers suggest. You can also use a [`Matcher`](http://docs.oracle.com/javase/6/docs/api/java/util/regex/Matcher.html) and a [`Pattern`](http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) for a more general approach:
```
String str = "123dance456";
... | Using the Scanner is a nice alternative:
```
Scanner scanner = new Scanner( "123dance456" ).useDelimiter( "dance" );
if ( scanner.hasNext() )
System.out.println( scanner.next() );
if ( scanner.hasNext() )
System.out.println( scanner.next() );
```
It is quite convenient to process the tokens as a stream and si... |
594,886 | My local computer uses Windows 7 Pro and belongs to realm LR, managed by AD servers. I login to my computer while attached to that realm's network. I can view the TGT with MIT Kerberos for Windows ver. 4.0.1.
I want to access resources on a foreign realm, FR. There is no Kerberos trust between LR and FR, but they allo... | 2014/05/13 | [
"https://serverfault.com/questions/594886",
"https://serverfault.com",
"https://serverfault.com/users/117064/"
] | OK, I've come up with a working solution that needs some more polish, so might not work in all environments.
This works with:
1. [MIT Kerberos](http://web.mit.edu/kerberos/dist/) for Windows 4.0.1 with Windows support tools (KSETUP.EXE, KTPASS.EXE)
2. [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/) 0.63
3... | Following on to Toddius' answer, I have a co-worker in a similar situation (Windows 7 Enterprise 64-bit, joined to an AD domain, also running MIT Kerberos for Windows 4.0.1): His copy of the Kerberos Ticket Manager would only allow him to have one principal/one TGT. Whenever he would use the "Get Ticket" button to get ... |
616,532 | How can I compile java code from an arbitrary string (in memory) in Java 5 and Java 6, load it and run a specific method on it (predefined)?
Before you flame this, I looked over existing implementations:
* Most rely on Java 6 Compiler API.
* Those that don't, rely on tricks.
* Yes, I checked out commons-jci. Either I... | 2009/03/05 | [
"https://Stackoverflow.com/questions/616532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/931/"
] | You might want to check out Janino as well.
From their website:
Janino is a compiler that reads a JavaTM expression, block, class body, source file or a set of source files, and generates JavaTM bytecode that is loaded and executed directly. Janino is not intended to be a development tool, but an embedded compiler fo... | Run inside a web container like Tomcat and first generate a JSP page, and then invoke it.
This also allow you to get rid of the old class definitions by simply overwriting the JSP page instead of having your classloader slowly run full.
Is the "in-memory" requirement due to speed or due to not changing the code bas... |
52,848 | Suppose you were standing on the rotating Earth (not necessarily Equator or the poles) and suddenly your body lost the ability to avoid effortlessly passing through solid rock.
Because the earth's rotation at the surface is considerably below escape velocity, you would slip below the earth's surface. If the earth's gr... | 2013/02/02 | [
"https://physics.stackexchange.com/questions/52848",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/20505/"
] | The force you experience is of the form $\vec{F} = - Gmr\vec{u\_r}$, and we also know that in the surface, $r=R$, it is $\vec{F}=- gm\vec{u\_r}$, so
$$\vec{F} = -gm\frac{r}{R}\vec{u\_r}$$
This is a conservative force that can be derived from a potential
$$U = \frac{1}{2}gm\frac{r^2}{R}$$
Because this is a central f... | This is a pretty fun topic of classical mechanics.
You should check this article out: [here](http://www.wired.com/wiredscience/2012/11/how-long-would-it-take-to-fall-through-the-earth/)
It has a really detailed analysis of how to calculate the time it takes to fall through the earth. |
69,310,681 | I followed an AWS tutorial for setting up Lambda + API Gateway using SAM Template.
But the event defined under lambda template creates a Proxy integration.
I followed this tutorial because I wanted to set up similar for one of my projects.
I need Non-proxy integration for that specific use case. Because I have to retur... | 2021/09/24 | [
"https://Stackoverflow.com/questions/69310681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16958390/"
] | I think i solved by myself
```
paid = joins(:invoices).where(invoices: {status: true}).pluck(:id)
unpaid = joins(:invoices).where(invoices: {status: false}).pluck(:id)
#return paid
where(id: paid - unpaid)
#return unpaid
where(id: unpaid - paid)
#return partial paid
where(id: paid & unpaid)
``` | Since `paid` is a boolean field here, it holds either true or false value.
If you have another field(probably `payment_status`) in `Invoice` table that should identify the record as "Fully Paid", "Partially Paid", "Not Paid". Then the query would be:
```
Purchase.joins(:invoice).where(invoices: {paid: true, payment_s... |
8,140,990 | I'm trying to change the css of the following label using JQuery but I can't figure it out. This is actually the html from my checkboxlist (asp.net) and this is what I have so far. Can anybody please help? Thank you.
The JQuery below finds the entire table and makes all labels red, not just the one that I checked.
`... | 2011/11/15 | [
"https://Stackoverflow.com/questions/8140990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/967092/"
] | ```
$("#CheckBoxList1").click(function() {
$(this).find('label').removeClass('red');
$('span.checked').parent().next('label').addClass('red');
});
``` | Can you add an class/id to the labels and checkboxes and access it that way:
```
$(".check").click(function() {
var id = $(this).attr("id").split("_");
//access array of id
$(".label_"+id[1]).addClass("red");
}
```
then add the id/ classes onto your html:
```
<input id="CheckBoxList1_0" id="check_1" typ... |
62,202,674 | I am working on a program that displays a object from my Stock class in a jlist. I have it working where I can write this information to a file but when I try to read from that same file my program just freezes. I am wondering if I have my code set up wrong to read from the file as this is my first time trying that. Al... | 2020/06/04 | [
"https://Stackoverflow.com/questions/62202674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13682433/"
] | You need an `if` block instead of a `while` block because you want to set values to only one `Stock` object.
Replace
```
while(inputString != null)
```
with
```
if(inputString != null)
```
Also, change the return type from `void` to `Stock` and return `aStock` so that you can use the returned value.
```
public ... | Your loop is not set up correctly, and thus will never exit. Notice that after you read the first line, you are never reading another new line, so the loop never ends.
Secondly, if you are writing to the file at the same time as you are reading from it, inputString will never be null - the call to inbuffer.readLine wi... |
74,410,527 | I'm trying to make simple function to adding elements to my array but it doesnt work well. can you help me?
```
void insert(int &n, string name[]){
cin>>n;
for (int i = 0; i < n; i++)
{
cin>>name[i];
}
}
int main(){
int n;
string name[n];
insert(n,name);
}
``` | 2022/11/12 | [
"https://Stackoverflow.com/questions/74410527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20483219/"
] | C++ arrays [] do not grow on run time, use std::vector instead.
Also, since you are reading an integer from cin, you should insert in the vector the same type, not a string.
```
std::vector<int> v; // creates a vector
v.push_back( 10 ); // include a number in a vector
```
<https://godbolt.org/z/v4xG6WEo1> | You are declaring the size of your array "name[]" to be "n" but you are asking the value of "n" after you have allocated the memory for array already. Either ask for size before creating array or just use vector to have it resize during runtime.
If you want to use arrays then do this:
```
void insert(string name[]){
... |
52,166,826 | I am building mock restful API to learn better. I am using MongoDB and node.js, and for testing I use postman.
I have a router that sends update request `router.patch`. In my DB, I have `name` (string), `price` (number) and `imageProduct` (string - I hold the path of the image).
I can update my `name` and `price` ob... | 2018/09/04 | [
"https://Stackoverflow.com/questions/52166826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7943285/"
] | I know this answer might be too late to help you but it might help someone in 2020 and beyond.
First, comment out this block:
```
//const updateOps = {};
//for (const ops of req.body) {
//updateOps[ops.propName] = ops.value;
//}
```
and change this line:
```
Product.updateMany({_id: id}, {$set: updateOps})
```
... | To handle multi-part form data, the `bodyParser.urlencoded()` or `app.use(bodyParser.json());`body parser will not work.
See the suggested modules [here](https://www.npmjs.com/package/body-parser#readme) for parsing multipart bodies.
You would be required to use `multer` in that case
```
var bodyParser = require('... |
320,716 | I'm trying to find a reliable way of finding which process on my machine is changing a configuration file (`/etc/hosts` to be specific).
I know I can use `lsof /etc/hosts` to find out what processes currently have the file open, but this doesn't help because the process is obviously opening the file, writing to it, an... | 2011/10/12 | [
"https://serverfault.com/questions/320716",
"https://serverfault.com",
"https://serverfault.com/users/138387/"
] | You can use auditing to find this. If not already available, install and enable auditing for your distro.
set an audit watch on /etc/hosts
```
/sbin/auditctl -w /etc/hosts -p war -k hosts-file
-w watch /etc/hosts
-p warx watch for write, attribute change, execute or read events
-k hosts-file is a search key.
```
... | probably better to use something like incron then
<http://inotify.aiken.cz/?section=incron&page=about&lang=en>
you can then get it to trigger a script to so some sort of diags |
6,382 | Who knows two hundred ten?
--------------------------
*Please cite/link your sources, if possible. At some point at least twenty-four hours from now, I will:*
* *Upvote all interesting answers.*
* *Accept the best answer.*
* *Go on to the next number.* | 2011/03/18 | [
"https://judaism.stackexchange.com/questions/6382",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/2/"
] | 210 are the years of *shi'bud Mitzrayim*. (*[Rash"i](http://he.wikisource.org/wiki/%D7%9E%22%D7%92_%D7%91%D7%A8%D7%90%D7%A9%D7%99%D7%AA_%D7%98%D7%95_%D7%99%D7%92#.D7.A8.D7.A9.22.D7.99_.28.D7.9B.D7.9C_.D7.94.D7.A4.D7.A8.D7.A7.29.28.D7.9B.D7.9C_.D7.94.D7.A4.D7.A1.D7.95.D7.A7.29)* on *B'reshis* 15:13) | 210 is the total number of days in all the *Adar Rishon* months in a nineteen-year cycle. |
44,292,527 | I have two activities, Activity A and Activity B. Activity A has a button that leads to Activity B, and when the back button pressed, it returns to Activity A as it should.
However, if I go to Activity B and minimize the app, open the app, and then press the back button, it closes the app. How can I preserve the navi... | 2017/05/31 | [
"https://Stackoverflow.com/questions/44292527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3765618/"
] | Use `window.self` instead of `self`. | Add `var self = this;` or use `this.addEventListener(...)` |
29,909,648 | So I've attached a debugger, and tried different inputs and I can't seem to figure out why this won't get past the loop. When ran I enter "l" or "L", then entry gets set to that, then input is set to the capitalized version and then it repeats.
```
public static char displayMenu(){
char input;
sc.nextLine();//... | 2015/04/28 | [
"https://Stackoverflow.com/questions/29909648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4840151/"
] | your have used logical or condition it needs just one true statement to run, even though you enter 'L' , at this point your one statement is false but other statements became true that why it keeps on repeating. | ```
public static char displayMenu(){
char input;
sc.nextLine();//clear junk
do {
System.out.println();
System.out.println("\t\t Enter L to (L)oad ");
String entry = sc.nextLine();
input = entry.toUpperCase().charAt(0);
} while ((input != 'L') && (input!='M') && (input !=... |
49,381,139 | This is a tricky one - I have a java interface that I want to implement in scala:
```
public interface Foo {
public void bar(scala.Array arr);
}
```
Is it even possible to implement in scala? when I try:
```
class FooImpl extends Foo {
override def bar(arr: Array[_]): Unit = ???
}
```
I get:
```
Error:(13, 7... | 2018/03/20 | [
"https://Stackoverflow.com/questions/49381139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5417333/"
] | The error message is giving you the answer for any generic type other than `Array` (after replacing the name, of course):
>
> To implement a raw type, use `Array[_]`
>
>
>
"Raw type" is what Java calls a generic type used without a type parameter and e.g. <https://docs.oracle.com/javase/tutorial/java/generics/raw... | To make the code work you either have to
* Make the `FooImpl` declaration as `abstract` class
* Implement the `bar` method
because "Java interfaces don’t implement behaviour".
For your reference see [this](https://alvinalexander.com/scala/how-to-extend-java-interfaces-like-scala-traits) page. |
1,282,622 | Show that a rectangular prism (box) of given volume has minimum surface area if the box is a cube.
Could you give me some hints what we are supposed to do??
$$$$
**EDIT**:
Having found that for $z=\frac{V}{xy}$ the function $A\_{\star}(x, y)=A(x, y, \frac{V}{xy})$ has its minimum at $(\sqrt[3]{V}, \sqrt[3]{V})$... | 2015/05/14 | [
"https://math.stackexchange.com/questions/1282622",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/80708/"
] | **Hint:** Let a box be $x$-by-$y$-by-$z$. Here we assume $x>0$, $y>0$, $z>0$. Then the surface area of the box is
$$A=2(xy+xz+yz)$$
and the volume $V=xyz$ is fixed. We need to find the minimum of $A(x,y,z)$ given additional condition $V=xyz$. But $z=\frac{V}{xy}$ and, hence, $A$ can be considered as a function in two ... | Volume $V=xyz$ given. Area $A(x,y,z)=2(xy+yz+zx)$, to minimise, when $x,y,z>0$ and $xyz=V$.
**Fact.** If $a,b,c>0$, then $a+b+c\ge 3\sqrt[3]{abc}$, and equality holds if and only if $a=b=c$.
*Proof.* We set $X=\sqrt[3]{a}$, $Y=\sqrt[3]{b}$ and $Z=\sqrt[3]{c}$. Then the identity
$$
X^3+Y^3+Z^3-3XYZ=\frac{1}{2}(X+Y+Z)... |
9,211,405 | I would like to know the recommended way to move our code from a SVN repository to a GIT repository, so that we transition our developers team & start using GIT.
Can we do the transition and keep all the commits done in the SVN repository ?
Also, our team is happy with SVN currently, but, they don't know that branchi... | 2012/02/09 | [
"https://Stackoverflow.com/questions/9211405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396681/"
] | Eric Raymond (esr) has created [reposurgeon](http://catb.org/~esr/reposurgeon/), “a command interpreter for performing tricky editing operations on version-control histories.” The tool includes scripts for various purposes, including cleaning up the results of VCS conversions. Check it out from <https://gitlab.com/esr/... | Update Apr 2014
There is a tool called [Svn2Git](https://github.com/nirvdrum/svn2git) that does a pretty good job of making this process a bit easier. The documentation on the Github project is pretty good. (**Ruby required**)
It's worth noting that while git-svn defaults to pulling from just the path you specify, no... |
4,912,755 | I have an integer array of length 900 that contains only binary data [0,1].
I want to short the length of the array without losing binary data formate(original array values).
Is it possible to short the length of array of 900 into 10 or 20 length in C#??? | 2011/02/06 | [
"https://Stackoverflow.com/questions/4912755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/605171/"
] | You could actually apply some compression on bits and then store it. if its only 1s and 0s, Run-length encoding may help reduce size drastically in not-worst scenarios.
[Run length encoding - Wiki article](http://en.wikipedia.org/wiki/Run-length_encoding) | In fact, you have a binary integer with 900 digits. There are lots of ways you can hold that "number" depending on the what do you want with it and how fast.
Ask yourself:
* do I need fast set function ( `arr[n] = something` )
* do I need fast retrieval function ( val = arr[n] )
* do I need iteration of some kind, fo... |
38,393,747 | I'm working on an addon which opens a new tab on click on a button with a special html. Right now, the html file is on a dedicated webspace but is there a workaround for that that means, can I put the html file in the data structure of the addon itself and access it from there? Problem is, I deliver the url of the acti... | 2016/07/15 | [
"https://Stackoverflow.com/questions/38393747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5551126/"
] | In theory, I don't see any problems.
Place your HTML-file in your data folder, and access it through:
```
var file = data.url("overlay.html");
```
Edit: M.Onyshchuk is correct in saying that this will trigger an
>
> The address isn't valid
>
>
>
error. I didn't think of the ":". In order to fix this simply re... | It is not enough to change the file loading URI:
```
var file = data.url("overlay.html");
```
You will see error in this case as
>
> The address isn't valid
>
>
>
But you can modify your code and send current tab url not as a query part of URI, but as a fragment part:
```
let currUrl = tabs.activeTab.ur... |
7,811,468 | When trying to write read an int from standard in I'm getting a compile error.
```
System.out.println("Hello Calculator : \n");
int a=System.in.read();
```
The program throws an exception:
```
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type IOException a... | 2011/10/18 | [
"https://Stackoverflow.com/questions/7811468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/868995/"
] | in.read() can throw a checked exception of type IOException.
You can read about Exception Handling in Java [Here.](http://download.oracle.com/javase/tutorial/essential/exceptions/index.html)
You can either change your program to throw an IOException, or you can put the read in a try catch block.
```
try{
int a=Sy... | The program doesn't have a bug.
The method `read()` requires you to catch an `Exception` in case something goes wrong.
Enclose the method inside a `try/catch`statement:
```
try {
int a = System.in.read();
...
}
catch (Exception e) {
e.printStackTrace();
}
```
In any case **I strongly suggest you to use document... |
17,960,817 | I need to check if a number is even.
Here's what I've tried.
```
newY="281"
eCheck=$(( $newY % 2 ))
echo $newY
echo $eCheck
while [ $eCheck -eq 0 ]; do
newY=$((newY-1))
eCheck=$(( $newY % 2 ))
echo $newY
done
```
...
returns `eCheck = 1`
how can it be? 281/2 = 140.5
i've also tried using `... | 2013/07/31 | [
"https://Stackoverflow.com/questions/17960817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2228383/"
] | Nici is right, "%" is the modulo, and gives you the remainder of the division.
Your script can be simplified as follows :
```
if [[ $((var % 2)) -eq 0 ]];
then echo "$var is even";
else echo "$var is odd";
fi
``` | Since this question is tagged as Bash, the right way to check if a number is even in Bash is:
```
if ((num%2 == 0)); then
echo "The number is even"
fi
```
or, more even shorter:
```
if ((num % 2)); then
echo "The number is even"
fi
```
We don't need to use `[[ ... ]]` in this case.
---
See also:
* [Dif... |
17,595,091 | How can I create new `File` (from `java.io`) in memory, not on the hard disk?
I am using the Java language. I don't want to save the file on the hard drive.
I'm faced with a bad API (`java.util.jar.JarFile`). It's expecting `File file` of `String filename`. I have no file (only `byte[]` content) and can create tempo... | 2013/07/11 | [
"https://Stackoverflow.com/questions/17595091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It is not possible to create a `java.io.File` that holds its content in (Java heap) memory \*.
Instead, normally you would use a stream. To write to a stream, in memory, use:
```
OutputStream out = new ByteArrayOutputStream();
out.write(...);
```
But unfortunately, a stream can't be used as input for `java.util.jar... | I think temporary file can be another solution for that.
```
File tempFile = File.createTempFile(prefix, suffix, null);
FileOutputStream fos = new FileOutputStream(tempFile);
fos.write(byteArray);
```
There is a an answer about that [here](https://stackoverflow.com/questions/19006461/create-a-temporary-java-io-file-... |
10,316 | What is the difference between 硕士英语A班 and 工程硕士英语?
I just want to know their exact meaning as Google Translate gives me the same result for both but these words seems to have different meaning.
What I am supposing is that 硕士英语A班 is masters English class and 工程硕士英语 is *not* a class but a whole department or whatever. S... | 2014/11/12 | [
"https://chinese.stackexchange.com/questions/10316",
"https://chinese.stackexchange.com",
"https://chinese.stackexchange.com/users/3713/"
] | `硕士` means the college degree in modern Chinese, nothing else, unlike the English word Master.
`工程硕士` is Master of Engineering.
`硕士英语` is the English course for a student who is pursuing a master's degree.
`班` is an assembly in which people study and take exams together, usually consisting of 30 or more people.
S... | 工程硕士英语 - English for Master Engineering
硕士英语A班 - English class A for Master (Engineering).
Note that 硕士英语A班 could also be Master (level) English Class A, in a sense of Beginner - Intermediate - Master. `Master` here is referring to the level not a degree |
26,739,622 | I'm trying to import both android support libraries. I'm trying to implent GoogleMaps AP2 into my Android Application. Therefore I need both libraries. I'm using AndroidStudio and Gradle.
```
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt "org.androidannotations:androidannotations:$AAVers... | 2014/11/04 | [
"https://Stackoverflow.com/questions/26739622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2908475/"
] | You have to use the latest version of support-v13:21.0.+
You have this error because both appcompat and support-v13 depends on support-v4 and their is a version conflict.
Not the best error by the way. | Remove line: `compile 'com.android.support:appcompat-v7:21.0.+'` |
47,716,468 | I am trying to fix a button to the right edge of a div.
**HTML:**
```
<div id="header">
<button type="button" uk-toggle="target: #offcanvas-flip" uk-icon="icon: plus"></button>
</div>
```
**CSS:**
```
#header {
margin-left: 240px;
background-color: #0070e0;
padding: 20px;
position: relative;
}
#... | 2017/12/08 | [
"https://Stackoverflow.com/questions/47716468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2190986/"
] | It is not ignored, absolute position will not take the padding of parent div. Just set the height of div and center the absolute element. The 20px padding is probabbly the entire height of parent div, if the child element is absolute. To clarify better: Your header is taking the height of 40px (20px padding top, 20px p... | Padding is not removed when you use `absolute`, but the `height` and `width` of your `absolute` element is not a part of your `parent` element anymore so therefore is loses `height`. Now if you want to change `height` of parent element you can either increase `padding` or give it `height` property.
```css
#header {
... |
59,030,141 | The following is the date column and it's vardump :
```
<td>{{$words['return_dt'] }}</td>
```
```
2019-11-25 10:08:55
```
How can I add three hours to this so that the output would be :
```
2019-11-25 01:08:55
``` | 2019/11/25 | [
"https://Stackoverflow.com/questions/59030141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6053564/"
] | you can do this via
```
{{ date("Y-m-d H:i:s", strtotime($words["return_dt"]." +3 hours")) }}
```
and output will become
>
> 2019-11-25 13:08:55
>
>
>
If you need `2019-11-25 01:08:55` then you have to minus 9 Hours. | If you use twig you can try this:
```
{{ $words['return_dt']|date_modify("+3 hours")|date("Y-m-d H:i:s") }}
``` |
154,586 | I read this in late '90s and thought the premise was fascinatingly haunting: A very ancient alien race created either a single or many "berzerker" (?) machines during a war with another race. The machines were programmed so that, IIRC, they would continue to go around smashing any planet found to have sentient life.
T... | 2017/03/13 | [
"https://scifi.stackexchange.com/questions/154586",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/28213/"
] | Others ([dmckee](https://scifi.stackexchange.com/questions/154586/identify-science-fiction-novel-about-ancient-machines-destroying-all-sentient-pl#comment402088_154586) and [can-ned food](https://scifi.stackexchange.com/questions/154586/identify-science-fiction-novel-about-ancient-machines-destroying-all-sentient-pl/15... | If it wasn't a book, it could've been this:
>
> An alien probe approaches the station with a series of questions that have to be answered correctly within 24 hours, or Babylon 5 will be destroyed.
>
> The probe does not in fact explode but is part of a Berserker style campaign, designed to wipe out races that ar... |
29,480,421 | A friend of mine had to draw a mandelbrot with opengl in c. I decided to do it in Swift.
The first method I tried was by creating an array with ARGB data and convert this into a CGImage and view that one in an UIImageView. However this was not fast enough.
Now I am wondering, what is the fastest way to draw individu... | 2015/04/06 | [
"https://Stackoverflow.com/questions/29480421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3696798/"
] | Rather than using vertex and fragment shaders, take a look at using a kernel function (or compute shader). This would be a single shader that does the maths and sets the color value at each pixel of a texture. You can then render the texture to screen using CAMetalLayer.
Take a look at this blog post where I write to ... | If you want to compute the fractal on the GPU, then this is much more an OpenGL (or Metal) question than a Swift question. You need to take smaller steps:
1. Get a solid-color triangle on the screen with OpenGL.
2. Fill the screen with two solid-color triangles.
3. Fill the triangles with a simple gradient using a fra... |
50,673,678 | I have written a python class whose constructor takes two lists as arguments.
```
class nn:
def __init__(layer_dimensions=[],activations=[]):
self.parameters = {}
self.cache = []
self.activations= []
initialize_parameters(layer_dimensions)
initialize_activations(act... | 2018/06/04 | [
"https://Stackoverflow.com/questions/50673678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8253860/"
] | Really appreciate your question, it is very typical to manage if you don't know the way.
Here is a solution.
Magic method is [requestDisallowInterceptTouchEvent](https://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent(android.view.MotionEvent)), this method can allow or deny touch ev... | Can you please try following example or way may be this will help you.
```
myRecyclerViewHorizental.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false) {
@Override
public boolean canScrollHorizontally() {
//return false if you don't want... |
2,004,870 | I have a comma separated string, out of which I need to create a new string which contains a random order of the items in the original string, while making sure there are no recurrences.
For example:
Running 1,2,3,1,3 will give 2,3,1 and another time 3,1,2, and so on.
I have a code which picks a random item in the ori... | 2010/01/05 | [
"https://Stackoverflow.com/questions/2004870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/124110/"
] | You can still use a 'hash' in javascript to remove duplicates. Only in JS they're called objects:
```
function removeDuplicates(arr) {
var hash = {};
for (var i=0,l=arr.length;i<l;i++) {
hash[arr[i]] = 1;
}
// now extract hash keys... ahem...
// I mean object members:
arr = [];
for ... | With your solution, you are not guaranteed not to pick same number several times, thus leaving some others of them never being picked. If the number of elements is not big (up to 100), deleting items from the source array will give the best result.
**Edit**
```
originalArray = originalList.split(',');
for... |
48,148,163 | I have an existing pdf file with multiple pages to which I would like to put a border to all pages.
So I create a class that inherits from PdfPageEventHelper and I override the OnEndPage and assign the instance of that class to the PageEvent of PdfWriter instance:
```
using iTextSharp.text;
using iTextSharp.text.pdf;... | 2018/01/08 | [
"https://Stackoverflow.com/questions/48148163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1624552/"
] | You do
```
document.Open();
document.Close(); // here it crashes, see below in post exception thrown
```
I.e. you start a new document, add nothing to it, and then close it. Thus, it would be empty which iText responds to with `The document has no pages.`
Thus, the exception is completely correct.
---
The correc... | The **The document has no pages** error is thrown because you create a document that has no pages. It's as simple as that.
Look at your code:
```
Document document = new Document(reader.GetPageSizeWithRotation(1));
PdfWriter writer = PdfWriter.GetInstance(document, fileStream);
document.Open();
document.Close();
```... |
4,863,650 | In C, I sometimes used structures such as
```
enum {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewA... | 2011/02/01 | [
"https://Stackoverflow.com/questions/4863650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/282635/"
] | You don't need that binary logic with enums in java any more. You just need `enum` itself and `EnumSet`.
For example:
```
enum Color {
Red, Green, Blue, Orange, White, Black
}
...
EnumSet<Color> mainColors = EnumSet.of(Color.Red, Color.Green, Color.Blue);
Color color = getSomeColor();
if (mainColors.contains(col... | Don't really know what that C code does, but here's the closest you'll get to it in Java:
```
enum UIView {
UIViewAutoresizingNone ( 0),
UIViewAutoresizingFlexibleLeftMargin ( 1 << 0),
UIViewAutoresizingFlexibleWidth ( 1 << 1),
UIViewAutoresizingFlexibleRightMargin ( 1 << 2),
... |
47,000,335 | I have a variable `var image = SKSpriteNode(imageNamed: "image")` and it is an outline. I want to fill the image with colour but do not know the code necessary. Would someone be able to provide a solution? | 2017/10/29 | [
"https://Stackoverflow.com/questions/47000335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6784553/"
] | Simply
```
[.?!]*(?=[.?!]$)
```
should do it for you. Like
```
Regex re = new Regex("[.?!]*(?=[.?!]$)");
Console.WriteLine(re.Replace("This is a string....!", ""));
```
This replaces all punctuations but the last with nothing.
`[.?!]*` matches any number of consecutive punctuation characters, and the `(?=[.?!]$)... | Your solution works almost fine ([demo](https://ideone.com/VamiZW)), the only issue is when the same sequence could be matched starting at different spots. For example, `..!?!?` from your last line is not part of the substitution list, so `..!?` and `!?` get replaced by two separate matches, producing `??` in the outpu... |
14,671 | I've got a dataset of demographic details of store customers and which store they (most frequently) visit. **I would like to categorize the stores based on their customers.**
To clarify: The issue here is to create clusters of shops, on the basis of the characteristics of the customers who have attended them. In othe... | 2011/08/23 | [
"https://stats.stackexchange.com/questions/14671",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/179/"
] | I would greatly consider looking into Latent Dirichlet Allocation. It's not a clustering algorithm, but rather a topic model -- individual stores would be modeled as mixes of underlying themes. Different types of customers would have varying likelihoods based on particular themes. It is a fully generative, Bayesian mod... | I'm doing something similar and my process is described. Using PCA could be helpful. This will give you the most significant variables from the demographics that are present. Using K-means, pam, clara etc, cluster the stores using the significant variables.
Hope This Helps |
69,065,985 | I have two JSON objects with the same structure/value and I want to concat them together using Javascript.
My first array looks like this:
```js
[{
"name": "Spain",
"year": [
"2010"
]
},
{
"name": "Brazil",
"year": [
"1994",
"1970",
... | 2021/09/05 | [
"https://Stackoverflow.com/questions/69065985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15005346/"
] | Map through the first array and use [`Object.assign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) to assign the properties from the item with the same `name` property in the second array (with [`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... | A naive solution to work with any number of dynamic keys:
[Solution Link](https://jsfiddle.net/2n5xf47d/)
```
const json1 = [{
name: "test1",
city: [
]
}, {
name: "test2",
city: [
]
}];
const json2 = [{
age: "19",
address:"cb usa"
}, {
age: "20"
}];
let t = Object.assign({}, json1)... |
15,464,146 | My goal is get a JSON like
```json
{
"meta": {
"error_type": "error type",
"code": 400,
"error_message": "error msg"
}
}
```
In case something went wrong.
I tried to put the try catch block both in the rest controller's action and in the model but I get the whole exception stack (I mean with t... | 2013/03/17 | [
"https://Stackoverflow.com/questions/15464146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/356380/"
] | **Yet another way**
Do you have access to MS-Access 2000+?
If so add the Access Objects library reference and you will be able to use Eval function:
```
result = Eval("'y' IN ('x1', 'x2', '...' 'xn')")
```
It evaluates string expressions. Some of the SQL operators like the `IN` can be used.
See [documentation](http... | Quite easy idea to check if the value exist is to use `Match` function:
```
Dim myTBL As Variant
myTBL = Array(20, 30, 40, 50, 60)
'if value '30' exists in array than the position (which is >0) will be returned
Debug.Print WorksheetFunction.Match(30, myTBL, 0)
```
The only problem is that if the value doesn... |
16,635,182 | I have this CSS rule for rounded corner:
```
th, td { padding: 8px;
background: #E8ECE0;
text-align: center;
border: 1px solid #444;
border-bottom-width: 0px;
}
thead { background-color: #446bb3 ; color :#fff; padding:4px; line-height:30px }
tbody tr:nth-child(even) {background: #F... | 2013/05/19 | [
"https://Stackoverflow.com/questions/16635182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/362461/"
] | This answer doesn't answer your question directly, but a variant.
If you dont want the middle columns to have rounded corners, this is a possible solution:
Illustration:

Properties for the table row (tr): update the table data (td) for the left mos... | You can give id to the td elements and using the id's of td elements set the border radius to 0px. |
31,418,569 | Whenever I try to install any of Google's cocoapods I get one of two errors.
Either:
```
$ pod install
Analyzing dependencies
[!] The version of CocoaPods used to generate the lockfile (0.38.0.beta.2) is higher than the version of the current executable (0.37.2). Incompatibility issues may arise.
CocoaPods 0.38.0.be... | 2015/07/14 | [
"https://Stackoverflow.com/questions/31418569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5117157/"
] | Try updating your gem
```
sudo gem update -n /usr/local/bin cocoapods
pod install
``` | **After 6 hours i found this**
go to <http://cocoapods.org/> and download tar file |
15,096,486 | I am trying to track `pageviews` with `Google Analytics` but I keep getting an error on the import. I have listed in the code below where the errors are.
I also have put the jar file in the java build path and added the two lines in the `Android Manifest`.
My question is how to get the below code to compile correctly... | 2013/02/26 | [
"https://Stackoverflow.com/questions/15096486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1866707/"
] | You are trying to track Button clicks in google analytics but don't use trackPageView inside onClick() to track button events
```
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
tracker.trackPageView("/Categories"); //Error: "The import com.google.android.... | GoogleAnalyticsTracker is used in libGoogleAnalyticsV1.jar but you are using libGoogleAnalyticsV2.jar which is the latest version. To track a page view in libGoogleAnalyticsV2 use the following code
Declare
```
private Tracker GaTracker;
private GoogleAnalytics GaInstance;
```
Inside onCreate() method
```
GaInstanc... |
19,996,124 | How can implement in current class every abstracts methods quickly from her extended classes in Android Studio?
For example, in Eclipse, putting mouse over warning and pressing on implement abstract methods message do it automatically. | 2013/11/15 | [
"https://Stackoverflow.com/questions/19996124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/851951/"
] | `android studio` Right click than Select `Generate..` or `Alt` + `Enter` and get list of methods you can add into your `Activity`
For more to Implementing Methods of an Interface IntelliJ IDEA check <https://www.jetbrains.com/idea/help/implementing-methods-of-an-interface.html> | Which Android-Studio version are you using? I'm using Android-Studio 0.3.6 and this is working pretty similar to eclipse just hover the error , click the red light and Android-Studio offers you to generate the missing methods. |
110,364 | Can somebody please explain the difference between "ask of me" and "ask me"? Why do we use "of" between ask and me? | 2013/04/04 | [
"https://english.stackexchange.com/questions/110364",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/12348/"
] | "Ask of someone" would tend to imply asking for something from someone, perhaps a favor. Whereas, "ask someone" simply means to ask someone something, like a question. | I think they are both like a question, just with different usage between "ask something of someone" and "ask someone something". |
847,946 | If I want to define domain controller then i would say DC is where active directory installed or
Acitve Directory simply means: Secure centralized authentication and management
and domain controller = ADDS + DNS.
But I get confused when i read [here](https://serverfault.com/questions/573681/should-i-expose-my-active... | 2017/05/03 | [
"https://serverfault.com/questions/847946",
"https://serverfault.com",
"https://serverfault.com/users/413527/"
] | Active Directory is what is called a directory service, it stores objects like users and computers. So you can consider it as as database that store users and computers configuration in AD domain.
A domain controller is the server running Active Directory; Domain controllers are typically referred as DC. Domain control... | Active directory is just like a database that stores information as object of users and computers. But Domain Controller (DC) is a server that runs Active Directory and use data stored on AD for authentication and authorization of users. Domain controller manages security policies of Window NT or Windows Server. |
19,406,149 | I have a UITableView and I have set my cell background color to RGB 244, 240, 246. I've done this by setting the background color on the table, table cell, and the content view in the table cell.
However, the accessory (in this case the checkmark) has a black background instead.
![UIAccessoryView has black background... | 2013/10/16 | [
"https://Stackoverflow.com/questions/19406149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1293818/"
] | The problem was caused by the colour object. The correct line is:
```
cell.editingAccessoryView.backgroundColor = [UIColor colorWithRed:244/255.0f green:240/255.0f blue:246/255.0f alpha:1.0];
```
My best guess is that without the .0f it was treating the numbers as ints and truncating all the values to 0 (which would... | For table view cell, there is a property called `backgroundView`. You only need to change the backgroundcolor for the backgroundView. Thats it.
```
cell.backgroundView.backgroundColor = [UIColor yourcolor];
``` |
33,689,875 | I know that
```
class A { }
class B extends A { }
class C extends B { }
```
is completely legal and I can
```
C obj = new C();
obj.anyMethodfromA();
```
is possible.
Now question is this What if I don't want to access **class A** methods in **class C** only **class B** methods should be inherited.
Is this p... | 2015/11/13 | [
"https://Stackoverflow.com/questions/33689875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Restricting access for certain subclasses is not possible. You could use interfaces instead to add certain a functionality to a specific class in addition to inheritance. | You can use some sleight of hand using `interface` to hide the `methodFromA` but you cannot actually remove it.
```
class A {
public void methodFromA() {
System.out.println("methodFromA");
}
}
class B extends A {
public void methodFromB() {
System.out.println("methodFromB");
}
}
cla... |
40,257,207 | I'm having this simple `<input>` radio user choice.
```
<sample>
<ul>
<li each={ techs }>
<input
type='radio'
name='dev_choice'
value={ name }
onclick={ check_choice }>
{ name }
</input>
</li>
</ul>
<button onclick={ chec... | 2016/10/26 | [
"https://Stackoverflow.com/questions/40257207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/554374/"
] | I'm using closures for this kind of problem
```
<sample>
<h2>{ message }</h2>
<ul>
<li each={ techs }>
<input
type='radio'
name='dev_choice'
value={ name }
checked={currentRank === rank}
onclick={ check_choice(rank) }>
{ na... | I am 100% sure what you want but I interpret that you want to get the full object of the tech (with name and rank) for the selected object. If so here is what I will do ( [Plnkr](http://plnkr.co/edit/2ZuIF4iZQ1WS2CuOOiQb?p=preview) )
Basically I add a var to get the selected item for later access.
```
var selecte... |
15,689,440 | Is it possible to display an icon or image in a row of a dataview when using the XPages UP1 mobile control?
A facet for an icon is available in the control but it does not seem to render an image/icon on the browser page. | 2013/03/28 | [
"https://Stackoverflow.com/questions/15689440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1195975/"
] | The iconColumn does render on mobile controls using Domino 9.0 | Icons can be displayed in **DataView** on mobile.
On **DataView** control there is a property **iconColumn -> icons**.
It can be done like so:
```
<xe:this.iconColumn>
<xe:viewIconColumn>
<xe:this.icons>
<xe:iconEntry alt="Discussion" styleClass="mblListItemIcon">
<xp:this.url>.....
```
For a ... |
114,803 | A race of pseudo-humans army must plan a system of rations for a long campaign on a faraway land in which they cannot rely on foraging. The campaign’s expected to last somewhere between a few months to a couple of years.
Here are the details of the army:
1. It numbers around 50.000 men, all will leave the country, l... | 2018/06/11 | [
"https://worldbuilding.stackexchange.com/questions/114803",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/38809/"
] | With 16th century logistics, staying in the field for extended periods of time probably requires extensive foraging / raiding. There is an old adage about an army traveling on it's stomach....
Consider this: if it takes 1 lb of food (ignore calories for now) to feed 1 soldier for one day, then feeding 50 soldiers for ... | Please refer to a book called **Supplying war** by *Martin van Creveld*. There's special part dedicated to water systems in supplying armies.
Two things:
* For water armies always relied on local sources. In the 16 century it was not only for humans but all animals that went along. And they did bring a lot of them,... |
158,845 | *Edit: I was walking down an intolerably long sidewalk one day, and every time a mounted another hill, I saw more of it seeming to stretch out before me. It got me to thinking: is there a word for "going on and on for miles and miles?"*
I'm looking for a single adjective that is aptly descriptive of a road that stretc... | 2014/03/20 | [
"https://english.stackexchange.com/questions/158845",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/66066/"
] | You're making this much harder than it really is.
The word you are looking for is "endless", used like this:
"He traveled what seemed an endless road.
It was indeed a long and tiresome road, stretching out before him as though it would never reach its destination" | The first word that came to mind is *spanning*, which according to [TFD's citation of AHD](http://www.thefreedictionary.com/span) means
>
> To extend across in space or time
>
>
>
Because it is a transitive verb, it needs an object, as in:
>
> It was a long road, stretching and spanning the countryside as it we... |
54,100,469 | I have a custom pipe for transform temperature value. I want call this pipe on started component (done) and when value of lang change (not working). Can you help me?
My pipe:
```
@Pipe({
name: 'temperatureConverter'
})
export class TemperatureConverterPipe implements PipeTransform {
value: number;
constructor(priv... | 2019/01/08 | [
"https://Stackoverflow.com/questions/54100469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8720463/"
] | UPDATE:
The solution is to put the the "pure" flag to false. This solves the issue.
```
@Pipe({
name: 'TemperatureConverter',
pure: false
})
```
--- Previous answer ---
I have the same issue. What I have found out is that having the language as an parameter works. Not what I was hoping for but this could work f... | you first need to register your pipes into your module declarations. After that you can call it inside your html page simply by
```
{{ myTempDegree | temperatureConverter : 'fr' }}
``` |
55,036 | I have list of data and its plot and I don't know how to fit the plot with fourier series of either sine or cosine.
Full Data:
```
{{0., -0.176091}, {0.034, -0.163291}, {0.067, -0.156391}, {0.1,
-0.152791}, {0.134, -0.149391}, {0.167, -0.144791}, {0.2, -0.141291},
{0.234, -0.135991}, {0.267, -0.126191}, {0.301, -0.... | 2014/07/16 | [
"https://mathematica.stackexchange.com/questions/55036",
"https://mathematica.stackexchange.com",
"https://mathematica.stackexchange.com/users/16094/"
] | I've done this from first principles:
some random data:
```
data = Table[{x + RandomReal[{-.05, .05}] + 4,
Sin[x] + Sin[x/3] + RandomReal[{-.3, .3}]}, {x, 0, 12 Pi , .1}];
```
treat the discrete data as a function and and use trapezoidal integration:
```
trule = Mean /@
Partition[
... | I took george2079's statement "Now I expect someone will show a built-in way to get this..." as a challenge, so I did the same thing using `FindFit`. Also, writing it this way seems more clear to me what the actual function being fitted is (but obviously relying on the internal `FindFit` function)
```
len = (Max[#] - ... |
16,284,264 | I have 3 lists, one for hours, one for minutes, and one for seconds. What I have done is create a function that will take 3 lists as input and calculate the total amount of time.
My issue is that the function is so redundant and my question to you, is simpy: what is a better way to do this.
Here is my function:
```
... | 2013/04/29 | [
"https://Stackoverflow.com/questions/16284264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2127988/"
] | I would probably convert it all to seconds first:
```
seconds = sum(3600*h + 60*m + s for (h,m,s) in zip(hours,minutes,seconds)
```
Now break it back down:
```
n_hours,minutes = divmod(seconds,3600)
n_minutes,n_seconds = divmod(minutes,60)
``` | I would use time objects from Datetime <http://docs.python.org/2/library/datetime.html#time-objects>
That would be something like :
```
def final_time(hours,minutes,seconds):
times=[datetime.time(hours[i],minutes[i],seconds[i]) for i in range(0,length(hours))]
return sum(times)
``` |
35,006,628 | I have an array of strings:
```
strings = ['fo','foo','fooo']
```
What code should I write in order to find a string that has only `oo` in it?
I tried following code
```
strings.select!{|string| string.include? 'oo'}
#=> ['foo','fooo']
```
However, `'fooo'` is not what I wanted in a resulting array, in this c... | 2016/01/26 | [
"https://Stackoverflow.com/questions/35006628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4635750/"
] | To determine whether a string contains one or more strings of the form "xooy", where "x" and "y" are any characters other than "o", but contains no strings "xoy" and or "ooo" (and by extension, no "oooo", etc.), you could do the following:
```
def double_os_only?(str)
str.scan(/o+/).map(&:size).minmax == [2,2]
end
... | Use negative lookarounds..
```
> strings.select{ |i| i[/(?<!o)oo(?!o)/] }
=> ["foo"]
```
`(?<!o)` asserts that the match won't be preceded by `o`, `(?!o)` asserts that the match won't be followed by `o`
To match the string which contain exactly 2 o's
```
strings.select{ |i| i[/^[^o]*oo[^o]*$/] }
``` |
7,798,237 | What is the best way of performing the following in C++. Whilst my current method works I'm not sure it's the best way to go:
1) I have a master class that has some function in it
2) I have a thread that takes some instructions on a socket and then runs one of the functions in the master class
3) There are a number ... | 2011/10/17 | [
"https://Stackoverflow.com/questions/7798237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/702845/"
] | This is the solution, I just had to get the proper value from the first unitName I wanted...
```
public class XElementComparer : IEqualityComparer<XElement>
{
public bool Equals(XElement x, XElement y)
{
string unitNameX = x.Element("unitName ").Value;
st... | You can also write something which will work for most of xml.
```
public class XElementComparer : IEqualityComparer<XElement>
{
public bool Equals(XElement x, XElement y)
{
return (x.FirstAttribute.Value.Equals(y.FirstAttribute.Value)
&& x.LastAttribute.Value.Equals(y.LastAttribute.Va... |
41,478,698 | In my website, text is dynamically appended to the page.
My need if the `td` has attribute has `colspan=2`, apply `text-align:center`.
```
tblCustomers tr td
{
padding-left:25px;
}
//how do I do this
tblCustomer tr td:hasattribute(colspan=2)
{
text-align:center;
}
```
**Note:-**
* No suggestion for adding c... | 2017/01/05 | [
"https://Stackoverflow.com/questions/41478698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1326367/"
] | Here is a solution
```
tblCustomer tr td[colspan="2"]
{
text-align:center;
}
``` | Just added `width: 100%` to your table so you see visualize the effect properly.
```css
.tblCustomer
{
width: 100%;
}
.tblCustomer tr td[colspan="2"]
{
text-align:center;
}
```
```html
<table class="tblCustomer">
<tr>
<td colspan="2">Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
</table... |
23,364,419 | Consider a base class `class Base` which has a function `virtual void foo(void)`. This function is implemented in `Base`; i.e. is not pure virtual.
Is there a pattern I can use which when inheriting from this class, i.e. `class Child : public Base`, compels me to override `foo`? | 2014/04/29 | [
"https://Stackoverflow.com/questions/23364419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3415258/"
] | Yes, actually there is:
```
#include <iostream>
class Base
{
public:
virtual void someFun() {std::cout << "Base::fun" << std::endl;}
virtual ~Base() {}
};
class AlmostBase : public Base
{
public:
virtual void someFun() = 0;
};
class Derived : public AlmostBase
{
public:
virtual void someFun() {std:... | you can make the base method throw an exception when called, then the class must override it to avoid the parent execution.
this is used in the MFC FrameWork for example
```
// Derived class is responsible for implementing these handlers
// for owner/self draw controls (except for the optional DeleteItem)
void CComb... |
42,189,357 | I am creating a chat box using bootstrap css version 3 like this:
```
<div class="col-md-12 col-sm-12 col-xs-12" id="chatBox">
<div class="row" id="chatHeader">
<div class="col-md-10 col-sm-10 col-xs-10">Chat bot</div>
<div class="col-md-2 col-sm-2 col-xs-2">x</div>
</div>
<div class="row" ... | 2017/02/12 | [
"https://Stackoverflow.com/questions/42189357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1800583/"
] | Do not set the height of the `#chatBox` (you overflowing it currently), but if you need it to be exactly `300px` as you set, play with `#chatContent` and make it flexible height for example. | One of the main reasons is that you have a `padding` set to your header. The padding is pushing everything under it down. I guess the best option is to set the `bottom` to `25px`. This will do no damage as far I can see. |
5,109,537 | I had a site <http://www.test.com>
Now i make the folder 'test' secure
So the site is avialable in <https://www.test.com>
My requirement is ,when some one type <http://www.test.com> ,
then it should go to <https://www.test.com>.
Is there any way using .Htaccess or any other method? | 2011/02/24 | [
"https://Stackoverflow.com/questions/5109537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/310850/"
] | In Apache2 configuration, you could use the redirect command :
```
<VirtualHost *:80>
ServerName www.test.com
Redirect / https://www.test.com/
</VirtualHost>
<VirtualHost *:443>
ServerName www.test.com
...
</VirtualHost>
``` | ```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD>
<BODY>
Optional page text here.
</BODY>
</HTML>
```
That should do it. |
120,894 | So I decided I wanted to make this script part of a separate swap-able weapon so I made a child and put the script there. Before the script worked fine but now it won't work. The script works as follows: if the left mouse button is pressed send a ray cast out forward, if it hits something matching the condition (a tag ... | 2016/05/03 | [
"https://gamedev.stackexchange.com/questions/120894",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/69408/"
] | A Couple things to check:
1) Transform.forward may not be the direction you actually want to shoot the ray. For example if this is a first-person game, the direction the PhysGun is facing (transform.forward) may be totally different than where the *camera* is looking, and in that case you would probably want to shoot ... | Well I finally figured out the issue with some help from here and Reddit. Basically I was trying to send the raycast from the model's (the child) forward and that was the wrong forward.
So I changed the third (2nd) line of code in the update statement to `Ray ray = new Ray(Player.transform.position, Player.transform.f... |
20,607,260 | How do I show one random icon on page load with js? Below is the HTML code I have:
```
<span>
<i class="fa fa-trash-o" id="icon-one"></i>
<i class="fa fa-frown-o" id="icon-two"></i>
<i class="fa fa-thumbs-o-down" id="icon-three"></i>
</span>
```
I need to show only one of the three icons. | 2013/12/16 | [
"https://Stackoverflow.com/questions/20607260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2210364/"
] | My HTML would be
```
<span id = "mySpan"></span>
```
You can do this using javascript
```
var myRand = Math.floor(Math.random() * 3) + 1;
var randString = '';
if(myRand == 1)
randString = 'one';
else if(myRand == 2)
randString = 'two';
else if(myRand == 3)
randString = 'three';
var ele = document.c... | you can use java script here. So if there are only three icons one , two and three.
use random function to generate a number between one two and three
```
var x= Math.floor((Math.random()*3)+1);
if (x==1)
{
//fetch the div id = "icon-one" and display
}
else if (x==2)
{
//fetch the div id = "icon-two" and display
}
e... |
51,091 | I own a url shortening service. I want to deliver only legitimate statistics to my clients. There are possible scenarios that a particular user writes a script to automatically open the shortened URL, thus making the statistics look bad. What are the approaches one can follow to detect if a click is legitimate or not? ... | 2014/02/07 | [
"https://security.stackexchange.com/questions/51091",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/39635/"
] | There's a number of potential methods you can use to differentiate bots from humans but none of them are likely 100%
Obviously as you say rate limiting catches the really stupid bots who don't know to click at human speed. You could say one click per IP but that will artificially deflate your stats in the case of huma... | Try checking for valid user agents and referers. User Agents can always be spoofed but that's your best bet. Even if a bot is clicking through though, I'd consider that traffic. |
28,110 | ### The issue
My father has lately made a few sexist (and other -ist) "jokes", in the form of what I came to learn are called "disparagement jokes".
This has made me, and my wife, a bit uncomfortable.
Given the way he has raised me, I am convinced he can be taught to be better.
### What I tried
The first case ... | 2023/01/10 | [
"https://interpersonal.stackexchange.com/questions/28110",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/23093/"
] | Your father has made it indirectly apparent that he does not care about the impact of his behaviour on you or your wife.
The next step may be to confront him directly and tell him very clearly the effect his behaviour is having on you.
He will then have the opportunity to modify his behaviour. The silly adage "you ca... | If it were practicable to change someone's mind by stratagem, then we'd have done away with politics both domestic and international. I don't think you should be trying to change your father's mind, at least not directly. Instead, focus on his behaviour (which might lead him to change his mind "himself", too).
In eith... |
27,459,548 | I have 3 true conditions:
**EDITED:**
```
#sell-status-no {
background-color: #fe220b;
margin: 0 auto;
width: 240px;
border: 1px solid #000000;
}
#sell-status-yes {
background-color: #25b116;
margin: 0 auto;
width: 240px;
border: 1px solid #000000;
}
if (($profit >= 10.00 && $markup_percen... | 2014/12/13 | [
"https://Stackoverflow.com/questions/27459548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3914746/"
] | Add following to `YourClass.m` file:
```
@interface YourClass() {
int variableName;
}
```
@end
in `viewDidLoad` initialize variableName to `0`.
```
- (IBAction)btn:(id)sender
{
if (variableName == arrayImg.count)
{
variableName = 0;
}
[img setImage:[arrayImg objectAtIndex:classVariable... | In your `viewDidLoad`, add one more line:
```
[buttonName setTag:0];
```
Here change in btn event:
```
- (IBAction)btn:(UIButton *)sender {
[img setImage: [arrayImg objectAtIndex: [sender tag]]];
[sender setTag: [sender tag]+1];
if ([sender tag] > [arrayImg count]) {
[sender setTag: 0];
}
}
```... |
560,777 | We all know the famous Euler's Formula.
It says that if a polyhedron has F(Faces), V(vertices) and E(edges) then F + V – E = 2.
My question is “is there any restriction on these variables?”
By restriction, I mean something like aF + bV + cE > 0 (for some a, b and c) must be satisfied before the formula can be applie... | 2013/11/10 | [
"https://math.stackexchange.com/questions/560777",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/42351/"
] | (ii)/(iii): Putting the other parts of your question aside, this is something that is an issue. For instance, a [decagonal prism](http://en.wikipedia.org/wiki/Decagonal_prism) and a [dodecahedron](http://en.wikipedia.org/wiki/Dodecahedron) both have 12 faces, 20 vertices, and 30 edges, so these counts alone don't alway... | Observe the following two constructions, where I assume $V$ is even.
Behold the glory of MS Paint.


In the first construction, $V/2$ vertices are on top, $V/2$ on the bottom, and ... |
39,480,832 | I'm trying to leverage any automatic handling of validation and displaying errors for a form using multiple entities.
The user can dynamically create multiple new entities via the form UI. The data is marshalled through `newEntities()`:
```
$this->MyModel->newEntities($data);
```
The first part of the problem I hav... | 2016/09/14 | [
"https://Stackoverflow.com/questions/39480832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/851885/"
] | simply pass the array of entities to your form
```
$this->Form->create($entities);
```
also you don't have to specify the model name in the input name. Simply
```
$this->Form->hidden("$i.field");
```
and not
```
$this->Form->hidden("MyModel.$i.field");
``` | Use newEntity and add those to an array. Loop over that array accessing errors().
```
$array = [];
$array[] = $TableRegistry->newEntity([
'hi' => 'hey'
]);
foreach($array as $r){
var_dump($r->errors());
}
```
Hopefully that works with your use-case. I've never used newEntities, but you may be able to iterat... |
25,780 | I am fed up with the text editor [TextMate](https://web.archive.org/web/20221208003521/https://macromates.com/). It's great, but it's old and keeps crashing on me. No development in (what, 3+?) years, etc.
So I'm looking for a viable alternative, mainly for [PHP](https://en.wikipedia.org/wiki/Php) development. However... | 2011/09/23 | [
"https://apple.stackexchange.com/questions/25780",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/9454/"
] | Have a look at Sublime Text. It basically is what I would expect TextMate2 to be.
<http://www.sublimetext.com/> | [MacVIM](https://github.com/b4winckler/macvim) + the [Janus Plugins](https://github.com/carlhuda/janus)
-------------------------------------------------------------------------------------------------------
Fear not the VIM. MacVIM gives you visual VIM that's OS X friendly. All the usual suspects work (Cmd+S, Cmd+W, ... |
3,189,245 | What is the integral of:
$$I=\int \sin(ax) \cos(ax) dx$$
My approach is down below. I have attempted the problem and posted it as an answer. I did the problem using trigonometric substitution.
$$u=ax$$
$$\frac{du}a=dx$$
$$\frac{1}a\int\sin u \cos u \ du$$
$$g=\sin u$$
$$dg = \cos u \ du$$
$$\frac{1}a\int g\ dg$$
$$I=\... | 2019/04/15 | [
"https://math.stackexchange.com/questions/3189245",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/372659/"
] | If we have that
$$f(x)=\frac1{1+e^{\frac{x-b}{c}}}=k$$
for some $k\in\mathbb{C}$ then we can rearrange this to get
$$1+e^{\frac{x-b}{c}}=\frac1k$$
$$e^{\frac{x-b}{c}}=\frac1k-1$$
$$\frac{x-b}{c}=\ln{\left(\frac1k-1\right)}$$
$$x-b=c\ln{\left(\frac1k-1\right)}$$
$$x=b+c\ln{\left(\frac1k-1\right)}$$
Which is undefined fo... | It sounds like you are seeking an analytic solution to the equation
$$
\frac{1}{1+\exp((x-b)/c)} = 0,
$$
but the LHS is always positive for any $x$ since exponent is always positive, so both numerator and denominator are always positive.
However, as $x \to \infty$ if $c>0$ you will get the desired effect. |
5,830,833 | Is it possible to select a form element using it's name attribute?
For example if I had something like this:
```
<input type="text" name="my_element" />
```
How would I go about setting a javascript variable to the value of this input?
```
var name_val = $(input[name='my_element']).val();
```
? | 2011/04/29 | [
"https://Stackoverflow.com/questions/5830833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278533/"
] | Your almost there
```
var name_val = $('input[name=my_element]').val();
``` | The following should work:
```
var name_val = $('input[name="my_element"]').val();
``` |
5,214 | What does *salad days* mean? I've heard the term used to describe past better days, but what does that have to do with salad?
Also, when was the phrase coined? | 2010/11/18 | [
"https://english.stackexchange.com/questions/5214",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/1914/"
] | It refers to the time of youth when one was naive and inexperienced, and therefore happy and optimistic - in other words, when one was "green," as in "unripe" or "not yet mature." It's a bit of a convoluted pun.
Like so many English idioms, the term was coined by Shakespeare in the 17th century (Antony and Cleopatra.) | Just agreeing with @PyroTyger, with [the actual quote](http://www.enotes.com/antony-and-cleopatra-text/act-scene-5#saladdays):
>
> Charmian: By your most gracious
> pardon, I sing but after you.
>
>
> Cleopatra: My **salad days**, When I was
> green in judgment, cold in blood, To
> say as I said then!
>
>
> |
50,393,027 | I'm pulling information from 3 different tables in MSSQL 2008 and I'd like to get the SUM of `CC_qty` as well as each `Location` condensed into one field per `id`. If this can be done in the query itself that would be fantastic - `listagg` and `GROUP_CONCAT` are not cutting it. Otherwise I've been working with array\_r... | 2018/05/17 | [
"https://Stackoverflow.com/questions/50393027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5116212/"
] | Being that I left an answer for MySQL, it wasn't going to work for this. I don't know MSSQL well enough to use it, so here's a way to do it with PHP so I don't leave you completely without an answer.
```
$arr = array
(
array
(
'id' => 'abc-abc-12',
'qty' => 0,
'locationID' => 276,
... | I don't have any experience with MSSQL, but I feel rather confident that it provides the necessary functionality to merge, sum, and concatenate. Anyhow, I am compelled to post an answer because I find the answer from Thomas to be unrefined.
Essentially, you should use the `id` values as temporary keys to determine if ... |
32,678,080 | How can I call a javascript function (`repeatedFunction()`) repeatedly but make it so that, let's say an `alert("This function is being executed for the first time")`, is only activated the first time that `repeatedFunction()` is, but the `//other code` is always activated? And also, how can I make the `alert()` allowe... | 2015/09/20 | [
"https://Stackoverflow.com/questions/32678080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5308892/"
] | JavaScript [closure approach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) will fit in this task. It has no global variables, and keeps your task in a single function.
```js
var closureFunc = function(){
var numberOfCalls = 0;
return function(){
if(numberOfCalls===0)
{
... | ```
var firstTime = true;
var myFunction = function() {
if(firstTime) {
alert("This function is being executed for the first time");
firstTime=false;
}else{
//whatever you want to do...
}
}; //firstTime will be true for the first time, after then it will be false
var milliseconds = 1000;
se... |
60,542,960 | I have been researching this problem for 2 hours online (including combing though other SO questions) and I can't seem to find an answer, so this is a last resort. For completeness I have added the entire function as it is only just over 100 lines.
Quick Summary : I have a button that the user clicks to start a functi... | 2020/03/05 | [
"https://Stackoverflow.com/questions/60542960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9946112/"
] | To hide the browser while executing tests using [Selenium](https://stackoverflow.com/questions/54459701/what-is-selenium-and-what-is-webdriver/54482491#54482491)'s [python](/questions/tagged/python "show questions tagged 'python'") you can use the [minimize\_window()](https://www.selenium.dev/selenium/docs/api/py/webdr... | If you're using Firefox, try this:
```py
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
driver_exe = 'path/to/firefoxdriver'
options = Options()
options.add_argument("--headless")
driver = webdriver.Firefox(driver_exe, options=options)
```
similar to what @Meshi answered in ca... |
6,092 | I've asked this myself sometimes already. A lot of knowledgeable developers are using Stackoverflow to give advice and help solving other peoples problems - for free. Giving back your own knowledge and helping students, newcomers or just less experienced developers can be a really good thing. It's a great feeling to kn... | 2019/12/07 | [
"https://cseducators.stackexchange.com/questions/6092",
"https://cseducators.stackexchange.com",
"https://cseducators.stackexchange.com/users/8691/"
] | I is hard to give a sufficiently nuanced answer to this question. There are many factors. I will try to give my own perspective.
First, I give away a lot for free in this forum and in others, both within the SE framework and to the [SIGCSE](https://sigcse.org/sigcse/) and [APCS](https://en.wikipedia.org/wiki/AP_Compu... | A key difference with stackoverflow vs. private mentoring is that one doesn't need to be invested in any particular person's understanding. If the OP doesn't get it, marks my answer down, upvotes or checkmarks an answer I consider incorrect, no problem for me. Maybe some other random person(s) will find my answer usefu... |
66,651,478 | I have an array with nested objects having parent-child relationship like so:
```
[
{id: 1, title: 'hello', parent: 0, children: [
{id: 3, title: 'hello', parent: 1, children: [
{id: 4, title: 'hello', parent: 3, children: [
{id: 5, title: 'hello', parent: 4, children: []},
{id: 6, ... | 2021/03/16 | [
"https://Stackoverflow.com/questions/66651478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744195/"
] | In ES5 you can also use some *functional programming* approach, and flatten an array with `[].concat.apply`:
```js
function flatten(arr) {
return [].concat.apply([], arr.map(function (obj) {
return [].concat.apply([
{ id: obj.id, title: obj.title, parent: obj.parent }
], flatten(obj.chi... | if data is large can consider use tail optimization and async/await
```js
const arr = [
{id: 1, title: 'hello', parent: 0, children: [
{id: 3, title: 'hello', parent: 1, children: [
{id: 4, title: 'hello', parent: 3, children: [
{id: 5, title: 'hello', parent: 4},
{id: 6, title: 'he... |
1,243,113 | I often want to clear the session store in Rails, in particular, the default cookie-based session store. Some sites seem to suggest that
```
rake tmp:sessions:clear
```
accomplishes this task, but it appears that it does not. What is the proper way to clear the cookie-based session store? | 2009/08/07 | [
"https://Stackoverflow.com/questions/1243113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85509/"
] | The problem is that cookies are client side. Running a rake task on your server won't delete cookies on all the machines that have visited the web page, obviously.
Perhaps you can use `session.clear` in your controllers somehow? You're right about changing the cookie key, though. Doing so would invalidate any session ... | If you are running this on a production server I recommend:
```
rake secret
```
Which is simply generating a random secure token. The rake task is basically doing this, which you could do in a console.
```
SecureRandom.hex(64)
```
Never check the production key into version control / GIT but use an environment va... |
4,767,010 | I am trying to give my div and textarea some padding. When I do this, it increases the size of the element, instead of shrinking the content area inside of it. Is there any way to achieve what I am trying to do? | 2011/01/22 | [
"https://Stackoverflow.com/questions/4767010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/576389/"
] | You could add `box-sizing:border-box` to the container element, to be able to specify a width and height that don't vary when you add padding and/or border to the element.
See [here (MDN)](https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing) for specifications.
**Update (copied comment to answer)**
Right n... | It depends on the browser and it's implementation of the [box model](http://www.w3.org/TR/CSS21/box.html). What you are experiencing is the correct behavior.
IE traditionally got it wrong: <http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug> |
6,380,191 | ```
double ***x;
```
what does it mean to declare declare a variable with three asterisks? Is this a pointer to a pointer to a pointer to a double? | 2011/06/17 | [
"https://Stackoverflow.com/questions/6380191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/574733/"
] | It is a pointer to a pointer to a pointer to a double. | Indeed it is a pointer to a pointer to a pointer to a double.
Either a big multi-dimensional array, or just many levels of pointer indirection. |
40,246 | I'm currently writing a story in the universe of the role playing game "Mahamot".
Basically, in this world, what's left of human kind lives on huge spaceships swarming with little plants called "micelis" (it seems to be a French game, so I don't have any translation for this word which doesn't even exist in French). ... | 2016/04/18 | [
"https://worldbuilding.stackexchange.com/questions/40246",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/19976/"
] | There are two ideas I have about this.
First is purification. Maybe the hulls of the spaceships are made from metal alloy that is simply impossible to work with or separate using technology available to humans. But the micelis could separate the various components of the alloy, thus producing raw materials that then c... | So you have a colonial micelis that is grown in a mold of the weapon that you need, it naturally forms firm cellular links between the individual micelis so that they're effectively a single larger organism. They don't live long in this formation but they can be feed a metal salt solution that they convert into a solid... |
38,536,737 | Each line in my table has an Edit button.
I trying to fetch the row number by clicking on the Edit button. I succeed to do that in JavaScript but in PHP I don't know how.
So I thought to pass the variable from JS to PHP and from some reason I get an error
>
> Undefined index: selectedRow
>
>
>
when I use this: ... | 2016/07/22 | [
"https://Stackoverflow.com/questions/38536737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3178398/"
] | Change your anchor tag href value in while loop with following text :
```
<a href="?editRow=true"> <---> <a href="javascript:;">
```
And now replace your window.location.href in script
```
'window.location.href = "?selectedRow="+ num;'. <---> 'window.location.href = "?editRow=true&selectedRow="+ num;'.
```
... | I continued to do tests, Someone test my code in his computer and told me that my code works, I continued my tests and eventually found the way it works.
I removed this line : `'<a href="?editRow=true">'.` from the table.
I add the **editRow=true** to the JS function with **selectedRow** like this: `'window.location.... |
64,878,896 | i am currently building a shopping website . i finished the homepage and i have to make routing for other pages
i have 3 main files: App.js, Menuitem.js (which is to execute props), and Homepage.js (which also is used to apply executing props from sections array which includes titles and background images and sections ... | 2020/11/17 | [
"https://Stackoverflow.com/questions/64878896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14638199/"
] | with cut:
```
cut -d\/ -f1,2,3 file
``` | This might work for you (GNU sed):
```
sed -E 's/^(([^/]*[/]){3}).*/\1/' file
```
Delete everything after the third group of non-forward-slashes/slash. |
2,254,222 | What are the points that should be kept in mind while writing code that should be portable on both 32 bit and 64 bit machines?
Thinking more on this, I feel if you can add your experience interms of issues faced, that would help.
Adding further on this, I once faced a problem due to a missing prototype for a function... | 2010/02/12 | [
"https://Stackoverflow.com/questions/2254222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/236222/"
] | Gotchas:
1. Casting pointers to integer types is dangerous
2. Data structure sizes can change
3. Watch out for sign extension
4. Different ABI?
Some tips & tricks I've found helpful:
1. Get yourself a native-size integer type (from a header or `typedef` your own) and use it when you have variables that don't care ab... | Write automated tests and run them regularly on both platforms. |
15,862,741 | does anybody know a way or a tool how inheritance can be used in CSS independent of the structure of the elements?
Example:
```
.bg_red {
background: red;
}
.bold {
font-weight: bold;
}
.bg_red_and_bold {
//this class should inherit all the properties of the above two classes
}
```
I hope it is clear what I... | 2013/04/07 | [
"https://Stackoverflow.com/questions/15862741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1313884/"
] | CSS does not support this.
Consider using [LESS](http://lesscss.org), which compiles to CSS and supports mixins:
```
.bg_red_and_bold {
.bg_red();
.bold();
}
``` | Probably not what you want but there is aggregation:
```
<div class="bg_red bold"...
```
The div will "inherit" characteristics of both styles. |
3,405,511 | for example if it is given to make all the choices between 1 to 5 and the answer goes like this..
```
1,2,3,4,5,
1-2,1-3,1-4,1-5,2-3,2-4,2-5,3-4,3-5,4-5,
1-2-3,1-2-4,1-2-5,1-3-4,
.....,
1-2-3-4-5.
```
can anyone suggest a fast algorithm? | 2010/08/04 | [
"https://Stackoverflow.com/questions/3405511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172543/"
] | The fastest is by using [template metaprogramming](http://en.wikipedia.org/wiki/Template_metaprogramming), which will trade compile time and code size for execution time. But this will only be practical for lowish numbers of combinations, and you have to know them ahead of time. But, you said "fast" :)
```
#include <i... | >
> can anyone suggest a fast algorithm?
>
>
>
Algorithms can be expressed in many languages, here is the power set in Haskell:
```
power [] = [[]]
power (x:xs) = rest ++ map (x:) rest
where rest = power xs
``` |
24,990 | I have a list called *Tenders*. I need to make sure that when Tender status field is set to "open" no one can delete it. Ideally would be if I won't see options in ecb and ribbon. It is not connected to users permissions but with state of list item. Should I use jQuery or is there an easier way? | 2011/12/09 | [
"https://sharepoint.stackexchange.com/questions/24990",
"https://sharepoint.stackexchange.com",
"https://sharepoint.stackexchange.com/users/4064/"
] | You could create an Event Receiver for the OnDeleting event that prevents the item from being deleted. Basically have the event receiver check for the value of the field and cancel deletion if the right requirements are not met. | Could you check this post for some help? - <http://pholpar.wordpress.com/2011/10/16/disabling-item-deletion-at-the-sharepoint-user-interface/> |
307,600 | During the installation, there is a choice to let you choose which desktop and whether or not install the `standard system utilities`. See [here](http://csmojo.com/posts/what-debian-standard-system-utilities-include.html) for the screen shot and the packages included.
[ *standard system utilities* consists of following packages on **Debian 8** (jessie):
>
> apt-listchanges, lsof, mlocate, w3m, at, libswitch-perl, xz-utils, telnet, dc, bsd-mailx, file, exim4-config, m4, bc, dnsut... |
62,057,338 | **In angular simple app, I have to show common header to all pages after login, but common header is not visible to user details page**
**I want to make common header visible to user details page also, which is not going to happen.**
```
-myapp
-src
-layout
-common
-header
header.component.css
... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62057338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13553758/"
] | I have made a simple example code like this, you could take it a try and change what you want:
```js
import React, { Component } from "react";
import {TextInput } from "react-native";
class App extends Component {
constructor(props) {
super(props);
this.state = { text: '' };
}
onChangeTextHandler(text)... | for **point 1** you can use `onFocus` prop of TextInput like this
```
<TextInput
value={this.state.searchTerm}
style={/* your style*/}
onFocus={()=>{
if(this.state.searchTerm==""){
this.setState({searchTerm:"ABCDE-"})
}
}}
/>
```
for **Point 2** use `keyboardType` and `onChangeText` prop of T... |
68,006,623 | I have the following PHP Script, and a HTML form that will send POST values to the php page. My problem is, when I select the "override schedule message" and submit the form, it displays the correct message, However when I go directly to the url.php, it displays the same message every time, regardless of what was submi... | 2021/06/16 | [
"https://Stackoverflow.com/questions/68006623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16245175/"
] | Another alternate way to achieve this is to just relay on the GridPane constraint features.
You can add Column/Row constraints and set the fillHeight/fillWidth to `true` and hgrow/vgrow policies to `ALWAYS`. Also set the desired nodes maxWidth/maxHeight to `Infinity` to auto stretch.
[:
cursor = getConnection.cursor()
cursor.execute("select * from student")
return cursor
cur = get_db_data()
for row in cur.fetchall():
print(row["student_name"])
... | 2018/09/10 | [
"https://Stackoverflow.com/questions/52251389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7386335/"
] | If you want to access a column by name, you should specify it as an attribute of the row rather than an index:
```
for row in cur.fetchall():
print(row.student_name)
``` | As per the pyodbc documentation "Row objects are similar to tuples, but they also allow access to columns by name". You can try row[0] or row.student\_name (Assuming column index for student\_name is 0)
```
import pyodbc
def get_db_data():
cursor = getConnection.cursor()
cursor.execute("select * from student"... |
19,444,933 | I want to export my java project (using eclipse) into executable jar,
but I want hibernate.cfg.xml, config.properties, and log4j.properties editable for future,
so how to make hibernate access that file from outside project folder or any other way to make that file editable for future,
I have try this code for acces h... | 2013/10/18 | [
"https://Stackoverflow.com/questions/19444933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1941064/"
] | there is my solution to your problem:
**config.properties**
You define your configuration file trough parameter `-DconfigurationFile` set to your JVM. Then try to find `confiFile` in your `classpath` (inside jar) if is not found then filesystem will be searched. Well, as last the properties will be override with JVM ... | You can instruct hibernate to load config file from file system,
There are lots of overloaded `configure()` methods are available, see the link for the documentaion
and below is the way you can do:
```
File conf = new File(ABS_PATH_TO_CONFIG+File.separator+"hibernate.cfg.xml");
Configuration configuration = new Co... |
16,410,085 | is there difference between char\* pt and char \*pt in c++?
type\* pt or type \*pt?
as titled, Thanks in advance. | 2013/05/07 | [
"https://Stackoverflow.com/questions/16410085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288446/"
] | No but be careful of something like `char* a, b;` only a is a pointer in this statement. | They have no functional difference. |
109,789 | *Moderator note:* A [follow-on question about how to avoid the behavior described here](https://academia.stackexchange.com/questions/109937/how-can-i-avoid-being-intolerant-and-unsupportive-of-diversity-at-scientific-mee) has been posted.
---
In recent news, two academics are at odds over this incident [full article... | 2018/05/15 | [
"https://academia.stackexchange.com/questions/109789",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/92788/"
] | **tl;dr**: The joke was funny because it was absurd and taboo (made people uncomfortable). It was "offensive" because it may have been intended to make the person operating the elevator feel embarrassed or singled-out. Avoid making jokes that make people feel singled-out.
How is the joke funny?
----------------------
... | I think the main reason why this joke gave offense has already been covered in Najib Idrissi's answer, i.e. the lingerie/sex-object angle, but there's another aspect to it:
>
> When [Prof. X] was young, in the 1950s, he said, it was a "standard
> gag line" to ask the elevator operator for the hardware or lingerie
> ... |
9,294,603 | I am playing with fragments in Android.
I know I can change a fragment by using the following code:
```
FragmentManager fragMgr = getSupportFragmentManager();
FragmentTransaction fragTrans = fragMgr.beginTransaction();
MyFragment myFragment = new MyFragment(); //my custom fragment
fragTrans.replace(android.R.id.con... | 2012/02/15 | [
"https://Stackoverflow.com/questions/9294603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/959734/"
] | You can query which fragment is loaded into your Activities content frame, and retrieve the fragment class, or fragment 'simple name' (as a string).
```
public String getCurrentFragment(){
return activity.getSupportFragmentManager().findFragmentById(R.id.content_frame).getClass().getSimpleName();
}
```
Usage:
... | ```
public Fragment getVisibleFragment() {
FragmentManager fragmentManager = getSupportFragmentManager();
List<Fragment> fragments = fragmentManager.getFragments();
if(fragments != null) {
for (Fragment fragment : fragments) {
if (fragment != null && fragment.isVisible())
... |
1,703,980 | Suppose I have a static variable declared inside a function in C.
If I call that function multiple times, does the static variable get re-allocated in memory every time the function is called?
If it does get re-allocated, why is the last value always maintained?
Example:
```
void add()
{
static int x = 1;
x... | 2009/11/09 | [
"https://Stackoverflow.com/questions/1703980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | No - static variables are basically globals that live within the local namespace. | No, the variable is not reallocated everytime.
It is like having a global variable, but it only has local scope; i.e., you can only reference it from inside of that function. |
53,139,121 | Should I give width and Height for an object like button while setting layout?
If I use Greater than or equal to option, It expands the button in bigger screens?
How to make a button stay in same size regardless of the device its being viewed?
Is it a good practise to design like this ? or the object should get bigg... | 2018/11/04 | [
"https://Stackoverflow.com/questions/53139121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10602954/"
] | Generally speaking, it's quite a bad practice to set width and height for a button. Because the size of its content might expand depending on the user's settings (accessibility settings, for instance).
It's better just to set the **top+leading** *OR* **top+trailing** *OR* **bottom+leading**, etc...
This is mostly s... | It mostly depends on yours app design.
Many built-in UIKit views (including buttons) have their own (intrinsic) size. So it is not necessary to define size explicitly, but you can do this if you want. Remember that you shouldn't make excessive use of expicit sizes as this can lead to non-adaptive design.
In most cas... |
24,229,442 | I am retrieving columns names from a SQL database through Java. I know I can retrieve columns names from `ResultSet` too. So I have this sql query
```
select column_name from information_schema.columns where table_name='suppliers'
```
The problem is I don't know how can I get columns names from `ResultSet` and my ... | 2014/06/15 | [
"https://Stackoverflow.com/questions/24229442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1495272/"
] | 1) Instead of `PreparedStatement` use `Statement`
2) After executing query in `ResultSet`, extract values with the help of `rs.getString()` as :
```
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery(sql);
while(rs.next())
{
rs.getString(1); //or rs.getString("column name");
}
``` | For those who wanted more better version of the resultset printing as util class
This was really helpful for printing resultset and does many things from a single [util](https://github.com/htorun/dbtableprinter)... thanks to Hami Torun!
In this class `printResultSet` uses `ResultSetMetaData` in a generic way have a lo... |
55,756,647 | I recently updated my Android Studio (and I'm pretty sure the Gradle version), and now I've been getting a bunch of errors when trying to compile my project. Here's the one that is plaguing me at the moment:
```
Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core... | 2019/04/19 | [
"https://Stackoverflow.com/questions/55756647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7492795/"
] | Like others says, the solution is to migrating to AndroidX, it works for me. However, it isn´t an easy way and it requires a bit of pacience... These are the steps that I did:
* First, is **very important** that you do all this changes in a different branch or you make a backup of your project.
* You need to have the ... | This solution from here worked the best for me. Migrating to androidX
<https://developer.android.com/jetpack/androidx/migrate>
>
> With Android Studio 3.2 and higher, you can migrate an existing
> project to AndroidX by selecting Refactor > Migrate to AndroidX from
> the menu bar.
>
>
> The refactor command mak... |
115,782 | There is the following statement in Jeffery Archer’s fiction “The Fourth Estate,” of which I admit I’m a terribly slow reader:
>
> “The tactics made it possible for Armstrong Communication to declare a
> profit of 90,000 the year he and Hahn (co-owner) parted, and a year
> later the Manchester Guardian named Richar... | 2013/06/04 | [
"https://english.stackexchange.com/questions/115782",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/3119/"
] | I think this should be treated like any other multi-word phrase. Use two words when it's a noun phrase:
>
> The go live will be this weekend
>
>
>
And a hyphen when it's an adjectival phrase:
>
> We're preparing for your go-live transition.
>
>
>
Now, unless *Go Live* or *Go-Live* is a proper name, I don't ... | The word **activate** would convey the intent and I would encourage you to use it.
Consistency in terminology as a defense only goes so far and I don't believe it will be enough to earn your audience's forgiveness for using a phrase like "the go live" or "your go live"
>
> Preparing for your software/website activa... |
8,042,212 | In my program using java nio, the socketchannel.write() becomes very slow when it tries to write 10 KB messages consecutively. The measured time for writing a complete 10 KB message is between 160 ms and 200 ms. But the time for writing a complete 5 KB message is only takes 0.8 ms.
In the selector, I only have Selecti... | 2011/11/07 | [
"https://Stackoverflow.com/questions/8042212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1028519/"
] | If write takes more than 20 micro-seconds, I would suggest you have a buffer full issue. I assume you are using blocking NIO. When the send buffer is not full it usually takes between 5 - 20 micro-seconds. In the past I have configured my server to kill any slow consumer which takes 2 ms to write. (Possibly a bit aggre... | I suggest that your reading process is slow and that this is causing its receive buffer to back up, which is causing your send buffer to back up, which stalls your sends.
Or else you haven't written the code correctly for non-blocking mode. If you get a zero result from the write() method, you must (a) change the inte... |
30,505,225 | When using css, how can I specify a nested class.
Here is my `html` code:
```
<div class="box1">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Collapsable</h3>
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget... | 2015/05/28 | [
"https://Stackoverflow.com/questions/30505225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3736648/"
] | The classes in your CSS need periods before them. Note `i` doesn't since it's an element not a class.
```
<style type="text/css">
.box1 .box-body i{width: 30px;}
</style>
``` | You just need to know how css selectors work. [Here](http://www.w3schools.com/cssref/css_selectors.asp) is brief description about css selectors.
In your case,
```
.box .box-body i{
width:30px;
}
```
space between two selectors defines second element is child of first.
In your case, element i is child element of... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.